tracy icon indicating copy to clipboard operation
tracy copied to clipboard

Win32 API symbols

Open slomp opened this issue 4 months ago • 2 comments

This is just a follow-up on the brief discussion we had here: https://github.com/wolfpld/tracy/pull/1125#discussion_r2248801613

I was able to build a client application on Windows via MinGW with both gcc (15.1.0) and clang (20.1.7). The only requirement is to link with WinSock2 (-lws2_32) and Dbghelp (-ldbghelp), given that there is no #pragma comment(lib, ...) in gcc/clang. The other Windows API libraries that TracyClient.cpp relies on all seem to get linked implicitly.

As such, the indirect, runtime dispatch calls in TracySysTrace.cpp seem unnecessary, and we can just call them directly, as is the case in TracyCallstack.cpp: https://github.com/wolfpld/tracy/blob/1393278afd855fc8ca928859d4bacc86cd82d7cb/public/client/TracySysTrace.cpp#L149-L152

That said, some of the Sym* API calls are being called indirectly in TracyCallstack.cpp, however: https://github.com/wolfpld/tracy/blob/1393278afd855fc8ca928859d4bacc86cd82d7cb/public/client/TracyCallstack.cpp#L340-L343 This also seems redundant, since it should be "all or nothing", and we're still forced to pass -ldbghelp for the direct calls.

I suggest we remove the indirect calls to cleanup the code, and update the documentation hinting that applications compiled in MinGW must link with -ldbghelp. Either that, or we create a proper, unified Win32 indirection stub file that is shared across all callers (TracyCallstack.cpp, TracySysTrace.cpp, and possibly more code).

slomp avatar Aug 02 '25 00:08 slomp

Another subtle issue for MinGW programs going through Tracy's sampling profiler is that Tracy won't be able to resolve most client symbols using the Dbghelp/Sym API symbol resolution path, since gcc/clang will emit DWARF for debug information.

(Unless a pdb file is extracted from the program binary later using something like cv2pdb).

slomp avatar Aug 02 '25 00:08 slomp

Another subtle issue for MinGW programs going through Tracy's sampling profiler is that Tracy won't be able to resolve most client symbols using the Dbghelp/Sym API symbol resolution path, since gcc/clang will emit DWARF for debug information.

Note this has been discussed in https://github.com/wolfpld/tracy/issues/1007

Lectem avatar Aug 09 '25 20:08 Lectem