Commit Graph

67 Commits

Author SHA1 Message Date
Bartosz Taudul
6b58f7d8d0 Report system tracing setup failures.
SysTraceStart previously reported success even when no perf events
could be opened, leaving a worker thread running over no buffers
and an empty CPU section without explanation; it now fails in that
case. Also log when /proc/kallsyms cannot be read, which otherwise
silently results in ??? kernel stack frames.
2026-08-19 22:18:59 +02:00
Bartosz Taudul
05f0508684 Fix system tracing on kernels older than 4.1.
perf_event_attr.use_clockid only exists since Linux 4.1 and
sample_max_stack since Linux 4.8; older kernels (e.g. the 3.18
kernels of 32-bit Android devices) reject the attributes with
EINVAL/E2BIG, which silently disabled all of system tracing.
Classify the running kernel from uname(2) and only send the fields
its perf_event_open ABI supports.
2026-08-19 22:18:57 +02:00
Bartosz Taudul
453d649c1a Add TRACY_ASSERT for custom assert implementations. 2026-08-16 13:32:44 +02:00
Bartosz Taudul
756411d802 Allow disabling wait stacks capture. 2026-08-14 01:28:22 +02:00
Bartosz Taudul
d3db50c201 Mingw fixes. 2026-06-04 12:08:53 +02:00
Bartosz Taudul
7d139a7bf1 Use proper data types for MemWrite. 2026-06-04 00:49:02 +02:00
Clément Grégoire
fd68959223 Rename InitRpmalloc to InitAllocator.
The function is about to dispatch between rpmalloc and a pluggable allocator hook, so the rpmalloc-specific name no longer fits. Pure rename plus a small consequence: the SymbolWorker call site no longer needs the TRACY_USE_RPMALLOC guard, since the no-op static-inline fallback in TracyAlloc.hpp makes InitAllocator() safe to call unconditionally.
2026-05-24 15:04:31 +02:00
Bartosz Taudul
a6c72f1cc7 Do not repeatedly read from all ring buffers to find minimum time entry. 2026-05-09 20:41:29 +02:00
Bartosz Taudul
95416a4b9c Since active[] order doesn't matter, memmove can be replaced with a swap. 2026-05-09 17:48:57 +02:00
Bartosz Taudul
61a6fb6780 Batch ring buffer reads. 2026-05-09 00:50:50 +02:00
Bartosz Taudul
8c2a970222 Merge pull request #1352 from wolfpld/slomp/apple-systrace
System tracing (callstack sampling) for Apple devices
2026-05-05 19:05:41 +02:00
Clément Grégoire
2997a78872 Fix #1243 compatibility with WinSDK < 10.0.26100
After investigating (downloading and installing) all publicly available SDKs at https://learn.microsoft.com/en-us/windows/apps/windows-sdk/downloads-archive I concluded the `TRACEHANDLE` deprecation started in `10.0.26100`.
This defines `PROCESSTRACE_HANDLE` and `CONTROLTRACE_ID` as done by the SDK when using older versions. Using `WDK_NTDDI_VERSION` (and not `NTDDI_VERSION` which may change based on `_WIN32_WINNT` or user input seems to be the most reliable way to do it. While it says "WDK" it's been part of the SDK in `shared\sdkddkver.h`. Note it doesn't work for MinGW because it updates half of its sdk files for some reason.
Tested with both 10.0.26100 and 10.0.22621.0 which is the last one I found without the new types.
Also changes CONTROLTRACE_ID to ULONG64 on mingw which is correct (type used by `TRACEHANDLE` too in mingw fe2763863a/mingw-w64-headers/include/evntrace.h (L60) )
2026-05-05 16:14:21 +02:00
Marcos Slomp
5a168f7ae4 initial prototype of system tracing for Apple devices 2026-05-04 15:29:24 -07:00
Bartosz Taudul
7448c0fbe1 Cover all target threads in tracy-monitor.
perf_event_open(pid>0, cpu>=0) binds to a single task, so the previous
setup only sampled the target's main thread. In monitor mode, enumerate
/proc/<pid>/task/ and open one per-task event per existing thread with
cpu=-1; inherit=1 then covers every descendant. Self-profiling behavior
is preserved byte-for-byte: the iter list becomes (currentPid, i) for
each CPU, exactly what the old code did inline.
2026-04-24 21:14:33 +02:00
Bartosz Taudul
217bdcf5a9 Merge pull request #1343 from siliceum/fix/better-tracefs-detection
Better tracefs detection
2026-04-21 11:55:10 +02:00
Clément Grégoire
4aac9e677d Fix formating/whitespaces in SysTraceStart 2026-04-21 09:51:43 +02:00
Clément Grégoire
aba343e429 Pick first debugfs entry only 2026-04-21 09:51:42 +02:00
Clément Grégoire
cb9ef7814e Use ReadFile and atoi 2026-04-20 18:05:31 +02:00
Clément Grégoire
8f208d732a Fix extra space 2026-04-20 18:04:41 +02:00
Clément Grégoire
8816dd0557 Allow finding tracefs through debugfs as a fallback for older kernels/systems that only mount debugfs 2026-04-20 15:04:33 +02:00
Clément Grégoire
0a5647b20f Use mnt_type instead of mnt_fsname for tracefs discovery
This is to be consistent with what libtracefs does: 6fad6a14ba/src/tracefs-utils.c (L104)
In theory one may mount tracefs with another name, though unlikely.
2026-04-20 15:00:37 +02:00
Clément Grégoire
d48794024d Log why SysTrace does not start on Linux 2026-04-20 14:49:57 +02:00
Clément Grégoire
95b6fdeed3 Fixes #1337: On Linux, respect perf_event_max_sample_rate to avoid lost events
This may be especially useful for low performance machines. We also warn about this behaviour through TracyDebug which ends up in Messages.
2026-04-20 14:31:41 +02:00
Clément Grégoire
e550e15ce6 Turn GetSamplingPeriod into SamplingFrequencyToPeriodNs
This forces to (re)use frequency values as input, which may be changed by the platform code later on. This way we have a single "source of truth" for sample freq.
Also removed the Win32 `GetSamplingInterval` which was a wrapper above `GetSamplingPeriod` but its value would be divided again anyway.
2026-04-20 14:29:35 +02:00
Bartosz Taudul
3ac364ebcb Add mingw ETW compat header. 2026-04-03 01:56:46 +02:00
Bartosz Taudul
739123d005 Add a way to override profiled program name and PID. 2026-03-31 01:18:50 +02:00
Clément Grégoire
b890719fdd Remove stray newline in TracySysTrace.cpp 2026-02-09 11:44:16 +01:00
Clément Grégoire
b778b67676 Fix trailing whitespace 2026-02-09 11:37:07 +01:00
Clément Grégoire
2b2fafbcfc Start cleaning TRACY_HW_TIMER checks.
Ideally I think we might want to have TRACY_HW_TIMER mean only TSC/CNTVCT, and define TRACY_TIMER_FALLBACK for platforms that don't have them or have a special case such as iOS.
But for now, keep the same behaviour.
2026-02-09 11:30:24 +01:00
Clément Grégoire
b27561c21e Add TRACY_DISALLOW_HW_TIMER for VMs / WSL2 2026-02-08 17:10:24 +01:00
Clément Grégoire
79cb60025d Monotonic clock fallback for systrace 2026-02-08 17:07:00 +01:00
Marcos Slomp
839b38d2ec removing implicit/default argument value 2026-01-15 11:29:49 -08:00
Marcos Slomp
44696c47c6 formatting 2026-01-15 11:27:49 -08:00
Marcos Slomp
dacb3dbae6 support for toggling EnableFlags after the singleton kernel session has started 2026-01-15 11:20:06 -08: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
Marcos Slomp
db745611c4 more explicit error check 2025-12-16 13:38:42 -08:00
Marcos Slomp
2403438bd9 error flow control for VSync tracing 2025-12-16 09:11:11 -08:00
Marcos Slomp
a0092a793a abandoning the private kernel session for now 2025-12-15 16:21:42 -08:00
Marcos Slomp
86a6b9b671 add admin check (and don't log it if it fails). 2025-12-08 08:40:26 -08:00
Marcos Slomp
04c32562a0 adressing review comments 2025-12-07 15:51:07 -08:00
Marcos Slomp
d363ddde2a missing events 2025-12-05 12:46:27 -08:00
Marcos Slomp
7b5de9e2b9 relocating ETW events (structs), and adding checks and comments 2025-12-05 12:03:57 -08:00
Marcos Slomp
f0b8658346 splitting event consumer 2025-12-03 14:55:08 -08:00
Marcos Slomp
bca011966d code formatting 2025-12-03 14:55:08 -08:00
Marcos Slomp
e5ca27966e ASCII 2025-12-03 14:55:08 -08:00
Marcos Slomp
f6965c62a9 reminder 2025-12-03 14:55:07 -08:00
Marcos Slomp
0adb0dbc57 refactoring ETW kernel session 2025-12-03 14:55:07 -08:00
Bartosz Taudul
be23d9354a Handle Lost_Event in Vsync callback on Windows. 2025-11-22 15:39:52 +01:00
Bartosz Taudul
5f4cccaa00 Use proper API to read /proc/mounts. 2025-11-13 19:40:28 +01:00
Bartosz Taudul
b762dc2a82 Retrieve tracefs mount path. 2025-10-25 21:06:37 +02:00