Commit Graph

10989 Commits

Author SHA1 Message Date
Bartosz Taudul
da5c8153bc Disable capture-daemon directory lock on windows. 2026-09-06 01:48:06 +02:00
Bartosz Taudul
ad0785f6c2 Update pandoc to 3.11.
Pandoc 3.11 appends the LaTeX caption label to Markdown table
captions as a {#id} identifier; strip it in tablecaption() since the
manual renderer has no identifiers.
2026-09-06 01:25:08 +02:00
Bartosz Taudul
82a4eea9d5 Update manual. 2026-09-06 01:07:47 +02:00
Bartosz Taudul
6992454dfd Save the tracy-monitor trace to a file. 2026-09-06 01:07:47 +02:00
Bartosz Taudul
3909a7407a Capture the trace in-process in tracy-monitor. 2026-09-06 01:07:47 +02:00
Bartosz Taudul
89c2b9e5f8 Add the capture-side server to the monitor build.
The monitor embeds the capture side of the protocol (TracyWorker) to
save traces to disk; like tracy-capture, build it without statistics
and at C++20.
2026-09-06 01:07:47 +02:00
Bartosz Taudul
d288c38c98 Add a per-directory lock file to the capture daemon.
Only one daemon can write to a given output directory at a time. The
lock holds the daemon PID and is removed on a clean exit; a lock whose
owner is verifiably gone is taken over on the next start, and a lock
whose owner cannot be read or that reads as alive must be removed by
hand.
2026-09-06 01:07:47 +02:00
Bartosz Taudul
6735c64306 Extend GUI skill to support headless X11. 2026-09-06 01:07:47 +02:00
Bartosz Taudul
fab65fae88 Agent guidance. 2026-09-06 01:07:47 +02:00
Bartosz Taudul
2dfe5c5c75 Save tracy-update output through a temporary file. 2026-09-06 01:07:46 +02:00
Bartosz Taudul
927ca83894 Save tracy-merge output through a temporary file. 2026-09-06 01:07:46 +02:00
Bartosz Taudul
51160bcc28 Save GUI traces through a temporary file. 2026-09-06 01:07:46 +02:00
Bartosz Taudul
e848076dfa Add a file writer that replaces its target only on completion.
The data is written to <fn>.tmp in the same directory as the target
and moved to <fn> on Commit(); a failed or interrupted write leaves
the previous file untouched, with an orphaned .tmp.
2026-09-06 01:07:46 +02:00
Bartosz Taudul
6aa41759d0 Flush the output file in FileWrite::Finish.
The final compressed block was left in the stdio buffer until the
destructor closed the file, so a caller that inspected the file after
Finish() saw a truncated trace.
2026-09-06 01:07:46 +02:00
Bartosz Taudul
4cbec36af6 Remove undefined source list variables from the capture build. 2026-09-06 01:07:46 +02:00
Bartosz Taudul
db6a46cf3e Extract shared capture-side tool code into TracyUtil. 2026-09-06 01:07:46 +02:00
Bartosz Taudul
ebf5ebd9bd Replace the output file safely in tracy-capture.
The old pre-flight truncated the output at startup with -f, so an
interrupted capture lost the trace, and the probe fopen followed a
symlink. The existing file is now moved to FILE~ for the duration of
the capture and restored if the trace cannot be written.
2026-09-06 01:07:45 +02:00
Bartosz Taudul
cf3407bbe3 Fix empty rate sample list read in the connection popup. 2026-09-06 01:07:45 +02:00
Bartosz Taudul
89f12318a1 Fix empty rate sample list read in the daemon stats. 2026-09-06 01:07:45 +02:00
Bartosz Taudul
fa4336dd26 Fix empty rate sample list read in the progress line.
HasData() flips when the connection is established, but the rate
list is only filled by the worker periodic stats update, whose first
entry arrives ~200ms later, so the first render could read an empty
list.
2026-09-06 01:07:45 +02:00
Bartosz Taudul
89132aed2a Merge pull request #1466 from akx/macos-level
Use CMAKE_OSX_DEPLOYMENT_TARGET 15.0 by default
2026-09-02 14:23:33 +02:00
Aarni Koskela
76c310eade Use CMAKE_OSX_DEPLOYMENT_TARGET 15.0 by default
As it is, the CI-built macOS binaries refuse to work on
macOS Sequoia because it defaults to the runner machine's level.

This sets a lower-than-default default for the target.
2026-09-02 10:39:36 +03:00
Bartosz Taudul
538af5c89c Learn the actual port of an adopted listen socket.
Adopting a pre-bound socket via SetReservedListenSocket left Worker()'s
port bookkeeping untouched, so GetPort() and the broadcast announcement
reported the computed default instead of the port the socket listens on.
The monitor kept this correct by mirroring the reserved port into
TRACY_PORT; direct users of the public API had no such coupling.

The bound socket is now authoritative: Worker() reads the local port
back via getsockname after binding. The search-loop bookkeeping stays
only as a fallback for a getsockname failure.
2026-08-31 19:30:23 +02:00
Bartosz Taudul
f52bf6a718 Merge pull request #1461 from ofoure/master
Added Profiler::GetPort() and TracyPort macro
2026-08-31 19:07:37 +02:00
Bartosz Taudul
70e4170e26 Cache the downloaded pandoc binary. 2026-08-31 18:54:55 +02:00
Bartosz Taudul
c6f1cb7585 Generate markdown manual at build time. 2026-08-31 18:54:55 +02:00
Bartosz Taudul
00e152b97a Allow embedding files from the build directory. 2026-08-31 18:54:53 +02:00
Olivier Fouré
17a4080713 Documented the TracyPort macro in the manual. 2026-08-31 09:58:26 +02:00
Bartosz Taudul
c756e7418e Fix android build. 2026-08-31 02:48:20 +02:00
Bartosz Taudul
71f0c992f7 Build monitor on CI. 2026-08-31 02:48:16 +02:00
Bartosz Taudul
06f4e13012 Document tracy-monitor in the user manual. 2026-08-31 01:58:38 +02:00
Bartosz Taudul
a66cc184e8 Annotate the file sections. 2026-08-31 01:58:37 +02:00
Bartosz Taudul
c9abfce098 Add a TRACY_ON_DEMAND build option. 2026-08-31 01:58:37 +02:00
Bartosz Taudul
a15e08f135 Rewrite the usage text. 2026-08-31 01:58:37 +02:00
Bartosz Taudul
fdff78584a Raise the fd limit for the sample events.
External sampling opens one event per CPU for each existing thread
(attach) or per CPU (launch) per event type, so a multithreaded target
needs many fds.
2026-08-31 01:12:41 +02:00
Bartosz Taudul
893439772f Reject client configurations that cannot work.
TRACY_NO_CALLSTACK, TRACY_NO_SYSTEM_TRACING, TRACY_NO_SAMPLING and
TRACY_SAMPLING_PROFILER_MANUAL_START either fail to build (the external
target API lives in the callstack code) or silently produce an empty
capture (no sampling event fails, so IsSystemTracingFailed stays false).
The first three are #error'd at compile time; the TRACY_NO_SYS_TRACE /
TRACY_NO_SAMPLING environment variables are refused at startup.
2026-08-31 01:12:41 +02:00
Bartosz Taudul
6d794801c6 Verify the exec stop in launch mode.
A caught signal (the handlers are inherited by the child) delivered
between PTRACE_TRACEME and exec first produces a signal-delivery stop;
without handling it, the setup would run on the still pre-exec child and
capture the monitor's own image as the target's. Re-inject the caught
signal and wait again until the exec stop is reached. Job-control stops
are the exception - re-injecting SIGSTOP/SIGTSTP re-stops the child, and
PTRACE_CONT rejects a stop carrying the 0x80 job-control bit - so resume
those without a signal instead.
2026-08-31 01:12:41 +02:00
Bartosz Taudul
b36c8f2fc5 Refuse to start without tracefs.
The client's system tracing cannot start without a tracefs (or debugfs)
mount - the tracepoint ids live under it - so starting anyway would
capture no samples.
2026-08-31 01:12:41 +02:00
Bartosz Taudul
2f2d8a7ba9 Fail when system tracing fails to start.
IsSystemTracingFailed reports a SysTraceStart that the preflight could
not predict (the target exiting between the checks, the kernel rejecting
the event setup); starting anyway would capture no samples.
2026-08-31 01:12:41 +02:00
Bartosz Taudul
d498829518 Verify the client is listening after startup.
Polling IsDataPortListening is the only reliable check: probing the port
itself cannot distinguish the client's listener from another process
holding it.
2026-08-31 01:12:40 +02:00
Bartosz Taudul
e87b7c873e Reserve the client listen port.
When TRACY_PORT is not pinned the client probes 8086..8105 at startup.
Reserve the first free port up front and hand the already-bound socket
to the client via SetReservedListenSocket, so the reservation is atomic
and the reported port matches what the client listens on. A pinned
TRACY_PORT is validated like --port, since the client pins to any
nonzero value with no fallback.
2026-08-31 01:12:40 +02:00
Bartosz Taudul
6109ab27b5 Add sample rate and port options. 2026-08-31 01:12:40 +02:00
Bartosz Taudul
7357b9fa52 Attach by process name.
The name is matched against /proc/<pid>/comm, which the kernel truncates
to 15 characters. Several matches are listed so the user can pick one
with -p; a match is only accepted if /proc/<pid>/exe is readable, which
excludes zombies (they keep a comm but have no executable to map) and
inaccessible processes.
2026-08-31 01:12:40 +02:00
Bartosz Taudul
46f2489f92 Report the active data sources at startup. 2026-08-31 01:12:40 +02:00
Bartosz Taudul
ac970771ee Preflight the exact sample event.
The old preflight opened one generic event, which said little about
whether the client's actual setup would work. PreflightSamplingEvent now
opens the client's exact external event shape (the per-CPU pid-filtered
CPU_CLOCK callstack event of SysTraceStart), verifies the ring mmap
works, and probes the hardware PMU counters informationally. On
EACCES/EPERM retry user-space only - both event and callchain, since the
callchain part still requires perf_allow_kernel - and report kernel
frames as unavailable; any other error is fatal, as the client's
identical shape would fail the same way.
2026-08-31 01:12:40 +02:00
Bartosz Taudul
d87cbed7eb Probe system-wide tracepoints and RAPL. 2026-08-31 01:12:40 +02:00
Bartosz Taudul
252a3dae43 Treat zombie targets as dead.
kill(pid, 0) succeeds for zombies, so a SIGKILLed attach target whose
parent had not reaped it yet kept the monitor polling indefinitely - in
attach mode the monitor cannot reap it. Liveness now also reads the
/proc state and treats Z as dead.
2026-08-31 01:12:40 +02:00
Bartosz Taudul
c9d3ec0088 Harden external thread name lookups against dead threads.
A thread exiting between fopen and read leaves the comm and status
buffers under-filled or uninitialized: zero-initialize them, treat a
short or empty read as unknown, and never scan the status when the read
returned nothing.
2026-08-31 01:12:39 +02:00
Bartosz Taudul
e5d20e1377 Free the tid buffer when thread enumeration yields nothing.
A task directory yielding no numeric entries (the target exiting
mid-enumeration) returned 0 with the freshly allocated array still
handed back through *out, and the caller's failure path returned without
freeing it.
2026-08-31 01:12:39 +02:00
Bartosz Taudul
da0d2328f5 Require per-target events for external sampling success.
SysTraceStart only failed when no event of any kind opened, but in
external mode the global sched/vsync tracepoints (pid -1) succeed
independently of the target: a target exiting after thread enumeration
left every per-target open failing while the startup still reported
success. s_ctxBufferIdx is the per-target ring count right after the
per-target setup, so in external mode require it to be non-zero as well.
2026-08-31 01:12:39 +02:00