trace-cmd: Stop recording when processes traced with -P exit
PATCH v4 1/1 trace-cmd: Stop recording when processes traced with -P exit
From: Bijan Tabatabai <[email protected]>
When the -F flag is used in trace-cmd record, trace-cmd stops recording when the executable it is tracing terminates.
This patch makes the -P flag act similarly.
---
v4 fixes a bug where trace-cmd would stop tracing after the processes in the first instance exited.
--- tracecmd/include/trace-local.h | 2 + tracecmd/trace-record.c | 91 +++++++++++++++++++++++++++++++++- 2 files changed, 92 insertions(+), 1 deletion(-)
tracecmd/include/trace-local.h +2 -0
@@ -215,9 +215,11 @@ struct buffer_instance {struct opt_list *options;struct filter_pids *filter_pids; +struct filter_pids *process_pids;char *common_pid_filter;int nr_filter_pids;int len_filter_pids; +int nr_process_pids;bool ptrace_child;int have_set_event_pid;
tracecmd/trace-record.c +90 -1
128 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 6 lines · On Thu, 14 May 2020 11:42:44 -0500 Bijan Tabatabai <[email protected]> wrote:
From: Bijan Tabatabai <[email protected]>
When the -F flag is used in trace-cmd record, trace-cmd stops recording when the executable it is tracing terminates.
This patch makes the -P flag act similarly.
Quoted 6 lines
Signed-off-by Bijan Tabatabai <[email protected]>---
v4 fixes a bug where trace-cmd would stop tracing after the processes in the first instance exited.
---
Looks good, but there's one small nit.
tracecmd/trace-record.c static void record_trace(int argc, char **argv, · line 6450
Quoted 12 lines
tracecmd/trace-record.c +7
-1@@ -6361,7 +6441,16 @@ static void record_trace(int argc, char **argv, }/* sleep till we are woken with Ctrl^C */ printf ("Hit Ctrl^C to stop recording\n" ); -while (!finished) +for_all_instances (instance) { +/* If an instance is not tracing individual processes +* or there is an error while waiting for a process to +* exit, fallback to waiting indefinitely. +*/ +if (!instance->nr_process_pids + ||trace_wait_for_processes (instance))
My preference is:
if (!instance->nr_process_pids || trace_wait_for_processes(instance))
But I can make this change.
Thanks!
-- Steve
Quoted 6 lines
tracecmd/trace-record.c +3
-0+ wait_indefinitely = true; + } +while (!finished && wait_indefinitely)trace_or_sleep (type, pwait); }