@@ -60,12 +60,22 @@ void PrintTraceboxUsage() {
6060 printf (R"( Welcome to Perfetto tracing!
6161
6262Tracebox is a bundle containing all the tracing services and the perfetto
63- cmdline client in one binary.
63+ cmdline client in one binary. It can be used in two modes:
6464
65- QUICK START (end-to-end workflow):
66- tracebox ctl start # Start daemons
67- tracebox -t 10s -o trace.pftrace sched # Capture trace
68- tracebox ctl stop # Stop daemons (optional)
65+ MODE 1: Daemon mode (Recommended)
66+ Background daemons are started once and shared across multiple tracing sessions.
67+ This supports SDKs (track_event), reduces latency and is generally more robust.
68+
69+ > tracebox ctl start
70+ > tracebox -t 10s -o trace.pftrace sched
71+ > tracebox ctl stop
72+
73+ MODE 2: Autodaemonize mode
74+ Spawns temporary daemons only for the duration of the trace.
75+ Useful for quick ftrace debugging or self-contained scripts.
76+ Note: SDK apps (track_event) might not connect due to private sockets.
77+
78+ > tracebox --autodaemonize -t 10s -o trace.pftrace sched
6979)" );
7080
7181 PrintTraceboxCtlUsage ();
@@ -75,13 +85,6 @@ QUICK START (end-to-end workflow):
7585 applets += " " + std::string (applet.name );
7686
7787 printf (R"(
78- ADVANCED: --legacy (NOT RECOMMENDED)
79- Example: tracebox --legacy -t 10s -o trace.pftrace sched
80-
81- Spawns temporary daemons for one trace only.
82- Limitations: SDK apps won't connect, inefficient for multiple traces.
83- Use only for quick one-offs or when persistent daemons aren't feasible.
84-
8588Available applets:%s
8689
8790See also:
@@ -91,8 +94,9 @@ See also:
9194 applets.c_str ());
9295}
9396
94- // Legacy mode: spawns temporary daemons with private sockets for one trace.
95- int RunLegacy (int argc, char ** argv) {
97+ // Autodaemonize mode: spawns temporary daemons with private sockets for one
98+ // trace.
99+ int RunAutodaemonize (int argc, char ** argv) {
96100 auto * end = std::remove_if (argv, argv + argc, [](char * arg) {
97101 return !strcmp (arg, " --system-sockets" );
98102 });
@@ -242,11 +246,11 @@ int TraceboxMain(int argc, char** argv) {
242246 return 1 ;
243247 }
244248
245- bool legacy_mode = false ;
249+ bool autodaemonize = false ;
246250 bool use_system_sockets = false ;
247251 for (int i = 1 ; i < argc;) {
248- if (strcmp (argv[i], " --legacy " ) == 0 ) {
249- legacy_mode = true ;
252+ if (strcmp (argv[i], " --autodaemonize " ) == 0 ) {
253+ autodaemonize = true ;
250254 memmove (static_cast <void *>(&argv[i]), static_cast <void *>(&argv[i + 1 ]),
251255 sizeof (char *) * static_cast <size_t >(argc - i - 1 ));
252256 argc--;
@@ -258,39 +262,41 @@ int TraceboxMain(int argc, char** argv) {
258262 }
259263 }
260264
261- if (legacy_mode) {
265+ if (autodaemonize) {
266+ // If --system-sockets is passed with --autodaemonize, it's a valid (though
267+ // slightly contradictory in name) way to say "spawn daemons but use public
268+ // sockets". We warn if they try to mix them in a way that suggests they
269+ // expect the old default behavior without the flag.
262270 if (use_system_sockets) {
263271 PERFETTO_ELOG (
264- " Legacy mode using system sockets is deprecated. Please prefer to "
265- " start daemons separately with `tracebox ctl start` for better "
266- " stability and compatibility. See "
267- " https://perfetto.dev/docs/reference/tracebox for details." );
268- } else {
269- PERFETTO_ELOG (
270- " Using legacy autodaemonize mode. This is fine for quick "
271- " one-off traces, but for production use or SDK compatibility, please "
272- " use `tracebox ctl start` followed by `tracebox`. See "
273- " https://perfetto.dev/docs/reference/tracebox for details." );
272+ " Warning: --system-sockets with --autodaemonize is supported but "
273+ " deprecated. Prefer `tracebox ctl start` for persistent daemons." );
274274 }
275- return RunLegacy (argc, argv);
275+ // We don't warn for plain --autodaemonize as it's a valid mode.
276+ return RunAutodaemonize (argc, argv);
276277 }
277278
278279 if (use_system_sockets) {
279280 PERFETTO_FATAL (
280- " System sockets is not a valid option for the new mode. By default "
281- " tracebox uses system sockets. If you want the old self-contained "
282- " behavior (autostarting daemons), append --legacy." );
281+ " System sockets is the default. If you want the old self-contained "
282+ " behavior (spawning temporary daemons), use --autodaemonize." );
283283 }
284284
285285 ServiceSockets sockets = perfetto::GetRunningSockets ();
286286 if (!sockets.IsValid ()) {
287- fprintf (stderr,
288- " Error: Perfetto tracing daemons (traced, traced_probes) are not "
289- " running.\n "
290- " - To run daemons as the current user: `tracebox ctl start`\n "
291- " - For a self-contained run: `tracebox --legacy ...` (Not "
292- " Recommended)\n "
293- " More info at: https://perfetto.dev/docs/reference/tracebox\n " );
287+ fprintf (
288+ stderr,
289+ " Error: Perfetto tracing daemons (traced, traced_probes) are not "
290+ " running.\n\n "
291+ " Tracebox behavior has changed. It no longer spawns temporary daemons "
292+ " by default.\n "
293+ " You have two options:\n "
294+ " 1. Start the daemons manually (Recommended):\n "
295+ " tracebox ctl start\n "
296+ " tracebox ...\n\n "
297+ " 2. Use the --autodaemonize flag for the old behavior:\n "
298+ " tracebox --autodaemonize ...\n "
299+ " \n More info at: https://perfetto.dev/docs/reference/tracebox\n " );
294300 return 1 ;
295301 }
296302 perfetto::SetServiceSocketEnv (sockets);
0 commit comments