Commit Graph

73 Commits

Author SHA1 Message Date
Bartosz Taudul
46bccd9a92 Refresh external image cache on symbolization misses.
FindExternalImageRefresh already re-parsed /proc/<pid>/maps on miss,
but only one of three external decode paths used it. Switch the
DecodeCallstackPtrFastExternal and DecodeSymbolAddressExternal paths
over so symbol-name and file/line lookups stay fresh after the target
dlopens a library.

Rate-limit the re-parse to once per wall-clock second so samples
landing on permanently unresolvable regions (JIT, vDSO, stacks) do
not trigger a full parse each time.
2026-04-24 21:16:42 +02:00
Erik van Zwol
70fc86536c Add static cast to uint64_t for std::min
On 32-bit arm, phdr.p_vaddr is 32-bit, which causes a compilation
error because std::min expects both arguments to be of the same
type. Adding the static cast handles this case explicitly.
2026-04-17 09:45:43 -06:00
Clément Grégoire
313d5b681e Fix #1321 linux compilation issue introduc 2026-03-31 13:43:36 +02:00
Bartosz Taudul
16f7cd3c68 Merge pull request #1321 from siliceum/refactor/tracycallstack
Small cosmetic changes + symsrv.dll detection
2026-03-31 12:25:12 +02:00
Bartosz Taudul
850cfd90f7 Add callstack decode functionality for external processes. 2026-03-31 01:18:51 +02:00
Bartosz Taudul
f8c6f4a7ba Cosmetics. 2026-03-31 01:18:51 +02:00
Bartosz Taudul
53439ea5e2 Add external image cache machinery. 2026-03-31 01:18:50 +02:00
Clément Grégoire
da4b95bf59 Use CopyString(Fast) where possible in TracyCallstack 2026-03-30 22:33:43 +02:00
Clément Grégoire
79f7d99b02 Add SymSrv.dll check
This is often a source of missing symbols or incomprehension as to why they are not getting resolved. Having a debug log will help debugging such cases.
2026-03-30 22:33:43 +02:00
Clément Grégoire
8c5724d125 Fix formating in DbgHelpInit 2026-03-30 22:33:43 +02:00
Clément Grégoire
cf33cbd33f Extract MakeUnresolvedCallstackEntryData 2026-03-30 22:33:42 +02:00
Marcos Slomp
853144214b buffer checks and typo 2026-02-18 16:13:26 -08:00
Marcos Slomp
12da626fd1 ensure executable path is inspected when looking for pdb files 2026-02-17 14:27:07 -08:00
Bartosz Taudul
73694c7a24 Cleanup enums. 2026-01-24 01:50:11 +01:00
Clément Grégoire
f17bd3f444 TracyDebug now uses TracyInternalMessage by default unless TRACY_VERBOSE or TRACY_NO_INTERNAL_MESSAGE is defined 2025-12-28 15:00:59 +01:00
Clément Grégoire
8ccc76c66b Use CopyStringFast in FormatImageName 2025-10-24 13:10:23 +02:00
Clément Grégoire
fe516e3596 IsKernelAddress helper 2025-10-24 13:10:23 +02:00
Clément Grégoire
2bdefc2aa3 Move drivers and modules caching to their own functions 2025-10-24 13:10:23 +02:00
Clément Grégoire
903cde50d9 Replace windows caches with ImageCache
- Introduce both s_imageCache and s_krnlCache on all platforms, even if unused (will be reused later to unify platforms handling)
- This means that what userland images that used to be unsorted are now sorted
2025-10-24 13:10:23 +02:00
Clément Grégoire
e1e9fb680d Rename TRACY_USE_IMAGE_CACHE to TRACY_HAS_DL_ITERATE_PHDR_TO_REFRESH_IMAGE_CACHE
Windows is already using a cache, and the only platforms that won't have one for now are those without dl_iterate_phdr.
2025-10-24 13:10:23 +02:00
Clément Grégoire
3b5b32d307 Replace hardcoded string duplication by CopyStringFast
This can be CopyStringFast since we allocated the cache on the same thread.
2025-10-24 13:10:22 +02:00
Clément Grégoire
32f94a05cb Support adding new entries and keeping the image cache sorted
Image cache will remain potentially unsorted until first access or `Sort` is called explicitely.
2025-10-24 12:54:35 +02:00
Clément Grégoire
0b814a2532 Split ImageCache to seperate platform specific so that it can be used on other platforms 2025-10-24 12:50:27 +02:00
Clément Grégoire
aa68c31780 Add path to ImageEntry in prevision of replacing KernelDriver use + add DestroyImageEntry for ImageEntry cleanup 2025-10-24 12:50:26 +02:00
Clément Grégoire
385f72f9dc Rename ImageCache::Contains to ContainsImage
The name was a bit misleading as it could be mistaken to mean "The cache contains the address" and not as "has an image with this start address". ie: that it could be mistaken to do GetImageForAddress( startAddress ) != nullptr.
2025-10-11 14:13:33 +02:00
Clément Grégoire
12026dae5b Make ImageEntry m_startAddress/m_endAddress uint64_t as it will later be used in server, and thus not pointing to current process memory 2025-10-11 14:10:18 +02:00
Clément Grégoire
9665f7ac42 Move ImageEntry to header in prevision of sharing it with other CPP files in the future 2025-10-11 13:52:03 +02:00
Bartosz Taudul
3bff910a27 Merge pull request #1121 from siliceum/feature/faster-module-caching-windows
Add faster module caching fallback by using GetModuleHandleExA
2025-08-01 20:44:19 +02:00
Gabriel Bon
1f6531f46d Add faster module caching fallback by using GetModuleHandleExA 2025-07-31 15:06:15 +02:00
Clément Grégoire
8c06fec09e Refactor libbacktrace usage with TRACY_USE_LIBBACKTRACE 2025-07-31 10:41:37 +02:00
Clément Grégoire
10c6e3dee1 Fix delay loading by not exporting variables
[`/DELAYLOAD`](https://learn.microsoft.com/en-us/cpp/build/reference/delayload-delay-load-import?view=msvc-170) only works with exported functions, not variables (as it patches thunks after the first load).
So instead of using exporting a pointer for `___tracy_RtlWalkFrameChain`, make it a function that will call said pointer. This only adds a `mov`+`jmp` instructions in optimized builds to the call, which is negligible compared to the actual cost of RtlWalkFrameChain. This also does not affect the reported callstack since it will use a `jmp` without touching the stack, so `___tracy_RtlWalkFrameChain` won't appear in the capture stacktrace.
2025-05-12 11:56:38 +02:00
Bartosz Taudul
be40c1e38e Use strlen instead of pointer walking in the rest of places. 2024-06-16 18:20:16 +02:00
Bartosz Taudul
1ff73edd20 Add linux kernel symbol code retrieval. 2024-05-26 20:49:43 +02:00
Bartosz Taudul
82aecbdb31 Calculate size of kernel code sections. 2024-05-25 17:18:41 +02:00
Bartosz Taudul
64aad9e751 Load all kernel symbols, mark non-code sections with null name. 2024-05-25 17:18:41 +02:00
Bartosz Taudul
d5064aa8ea Try to prevent reallocs when building kernel symbols table.
% wc -l /proc/kallsyms
419362 /proc/kallsyms
2024-05-25 17:18:41 +02:00
Bartosz Taudul
c45683506c Merge pull request #783 from tiago-rodrigues/trodrigues/image_cache_deadlock_fix
Instead of calling dladdr inside the dl_iterate_phdr callback, do it outside to avoid deadlocks with other loader code
2024-05-04 11:33:54 +02:00
trodrigues
4bf9a8cecc Instead of calling dladdr inside the dl_iterate_phdr callback, do it outside to avoid deadlocks with other loader code 2024-05-03 16:05:59 -05:00
Elliot
a26f076a0e fix build warnings when compiling with clang-cl 2024-03-11 14:44:44 -04:00
Bartosz Taudul
4226f7888e Manually allocate and free s_di_known.
Otherwise destructor will be called when main() returns while symbol
retrieval may still want to actively use the vector.
2024-02-26 23:03:37 +01:00
Bartosz Taudul
e9911ab127 Fix includes. 2023-12-20 13:16:51 +01:00
Bartosz Taudul
c39b7af4b3 Proper spelling of dbghelp. 2023-12-20 13:14:06 +01:00
Bartosz Taudul
cc3cbfe6f2 No need for indirection of ImageEntry vector. 2023-12-12 19:27:53 +01:00
Bartosz Taudul
5decb91cd0 Don't clear image cache on refresh. 2023-12-12 19:23:27 +01:00
Bartosz Taudul
7fc7935359 Cosmetics. 2023-12-12 19:09:41 +01:00
Bartosz Taudul
073e04e967 Remove redundant include. 2023-12-12 19:04:43 +01:00
trodrigues
ab1ec3f01c make sure we always copy the image name in ImageCache 2023-12-09 19:12:53 -06:00
trodrigues
15f1b6b0b4 make a copy of dli_fname after calling dladdr. Call ImageCache destructor. 2023-12-09 09:40:07 -06:00
trodrigues
55f53b9979 remove option to enable image cache, use it for TRACY_HAS_CALLSTACK == 3 to obtain image path and addreses instead of dladdr() 2023-12-05 20:01:12 -06:00
trodrigues
a618b6e6f8 simplify return from tracy::FastVector iterator 2023-12-03 08:36:54 -06:00