trace-cmd: Use BTF to parse function arguments
cover trace-cmd: Use BTF to parse function arguments
From: "Steven Rostedt (Google)" <[email protected]>
If function tracer is recorded with func-args option set, or the function_graph tracer is recorded with the funcgraph-args option set, then record the BTF file in a new BTF_FILE section in the trace.dat file.
This is compressed on disk, and when the trace.dat file is read, it is loaded into memory and sent to the libtraceevent tep_load_btf() function.
This will be used to show arguments of the function tracer:
# trace-cmd record -p function -O func-args cat /etc/passwd # trace-cmd report
cat-33501 [005] ..... 136155.767937: function: mutex_unlock(lock=0xffffffff831dbbe0)
cat-33501 [005] ..... 136155.767939: function: __mutex_unlock_slowpath(lock=0xffffffff831dbbe0, ip=0xffffffff814a7154)
cat-33501 [005] ..... 136155.767940: function: __f_unlock_pos(f=0xffff8881538de000)
cat-33501 [005] ..... 136155.767940: function: mutex_unlock(lock=0xffff8881538de090)
cat-33501 [005] ..... 136155.767940: function: __mutex_unlock_slowpath(lock=0xffff8881538de090, ip=0xffffffff816e8ed1)
cat-33501 [005] ..... 136155.767941: function: mem_cgroup_handle_over_high(gfp_mask=0xcc0)
cat-33501 [005] ..... 136155.767941: function: blkcg_maybe_throttle_current()
cat-33501 [005] ..... 136155.767942: function: __rseq_handle_notify_resume(ksig=0x0, regs=0xffffc9000e3eff58)
cat-33501 [005] d.... 136155.767943: function: fpregs_assert_state_consistent()
cat-33501 [005] d.... 136155.767943: function: switch_fpu_return()
cat-33501 [005] ..... 136155.767950: function: __x64_sys_execve(regs=0xffffc9000e3eff58)
cat-33501 [005] ..... 136155.767951: function: getname_flags(filename=0x7ffe7d33f3d0, flags=0)
cat-33501 [005] ..... 136155.767951: function: getname_flags.part.0(7ffe7d33f3d0, 0, 0, 0, 0, 0)
cat-33501 [005] ..... 136155.767951: function: kmem_cache_alloc_noprof(s=0xffff8881001d3800, gfpflags=0xcc0)And the same for function graph tracer:
# trace-cmd record -p function_graph -O funcgraph-args cat /etc/passwd # trace-cmd report
cat-43792 [006] ..... 147894.472393: funcgraph_entry: | mutex_unlock(lock=0xffffffff831dbbe0) {
cat-43792 [006] ..... 147894.472394: funcgraph_entry: 1.005 us | __mutex_unlock_slowpath(lock=0xffffffff831dbbe0, ip=0xffffffff812f2e30); (ret=0x0)
cat-43792 [006] ..... 147894.472396: funcgraph_exit: 3.581 us | } (ret=0x0)
cat-43792 [006] ..... 147894.472397: funcgraph_entry: | __f_unlock_pos(f=0xffff8881538df980) {
cat-43792 [006] ..... 147894.472397: funcgraph_entry: | mutex_unlock(lock=0xffff8881538dfa10) {
cat-43792 [006] ..... 147894.472397: funcgraph_entry: 0.434 us | __mutex_unlock_slowpath(lock=0xffff8881538dfa10, ip=0xffffffff812f2e30); (ret=0x0)
cat-43792 [006] ..... 147894.472398: funcgraph_exit: 1.216 us | } (ret=0x0)
cat-43792 [006] ..... 147894.472399: funcgraph_exit: 2.152 us | } (ret=0x0)
cat-43792 [006] d.... 147894.472399: funcgraph_entry: 0.360 us | fpregs_assert_state_consistent(); (ret=0x6)
cat-43792 [006] ..... 147894.472403: funcgraph_entry: | __x64_sys_execve(regs=0xffffc900029f3f58) {
cat-43792 [006] ..... 147894.472404: funcgraph_entry: | getname_flags(filename=0x7fff4a902080, flags=0) {
cat-43792 [006] ..... 147894.472404: funcgraph_entry: | getname_flags.part.0(7fff4a902080, 0, 0, 0, 0, 0) {
cat-43792 [006] ..... 147894.472405: funcgraph_entry: | kmem_cache_alloc_noprof(s=0xffff8881001d3800, gfpflags=0xcc0) {
cat-43792 [006] ..... 147894.472405: funcgraph_entry: 0.618 us | fs_reclaim_acquire(gfp_mask=0xcc0); (ret=0x0)
cat-43792 [006] ..... 147894.472406: funcgraph_entry: 0.380 us | fs_reclaim_release(gfp_mask=0xcc0); (ret=0x0)
cat-43792 [006] ..... 147894.472407: funcgraph_entry: | kmemleak_alloc(ptr=0xffff8881120b0000, size=0x1000, min_count=1, gfp=0xcc0) {
cat-43792 [006] ..... 147894.472408: funcgraph_entry: | __create_object(ptr=0xffff8881120b0000, size=0x1000, min_count=1, gfp=0xcc0, objflags=0x0) {
cat-43792 [006] ..... 147894.472408: funcgraph_entry: | __alloc_object(gfp=0xcc0) {
cat-43792 [006] ..... 147894.472408: funcgraph_entry: | kmem_cache_alloc_noprof(s=0xffff888100045700, gfpflags=0x92cc0) {
cat-43792 [006] ..... 147894.472409: funcgraph_entry: 0.570 us | fs_reclaim_acquire(gfp_mask=0x92cc0); (ret=0x0)
cat-43792 [006] ..... 147894.472410: funcgraph_entry: 0.370 us | fs_reclaim_release(gfp_mask=0x92cc0); (ret=0x0)
cat-43792 [006] ..... 147894.472411: funcgraph_exit: 2.226 us | } (ret=0xffff88814bbcf6a8)Steven Rostedt (Google) (5):
libtracecmd: Remove "compress" parameter from save_string_section()
libtracecmd: Remove "compress" parameter from tcmd_out_compress*()
functions
libtracecmd: Add write_compress_section_header() for writing compress
sections
trace-cmd record / report: Record BTF file if function arguments are
recorded
libtracecmd: Add printing of arguments for function graph tracer
.../include/private/trace-cmd-private.h | 3 + lib/trace-cmd/include/trace-cmd-local.h | 7 +- lib/trace-cmd/trace-compress.c | 26 ++ lib/trace-cmd/trace-ftrace.c | 41 +++- lib/trace-cmd/trace-input.c | 57 +++-- lib/trace-cmd/trace-output.c | 228 ++++++++++-------- tracecmd/trace-record.c | 42 +++- 7 files changed, 271 insertions(+), 133 deletions(-)
Signature · 1 line
2.47.2
PATCH 1/5 libtracecmd: Remove "compress" parameter from save_string_section()
From: "Steven Rostedt (Google)" <[email protected]>
The function save_string_section() is always called with the compress parameter as "true". There's no reason to have it. Just always make it true.
--- lib/trace-cmd/trace-output.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
lib/trace-cmd/trace-output.c +8 -10
@@ -97,7 +97,7 @@ struct list_event_system {#define HAS_SECTIONS (H ) ((H)->file_version >= FILE_VERSION_SECTIONS)static int write_options (struct tracecmd_output *handle); -static int save_string_section (struct tracecmd_output *handle,bool compress); +static int save_string_section (struct tracecmd_output *handle);__hidden long long tcmd_do_write_check (struct tracecmd_output *handle,const void *data,long long size)
@@ -290,7 +290,7 @@ void tracecmd_output_flush(struct tracecmd_output *handle)write_options (handle);/* write strings section */ -save_string_section (handle, true); +save_string_section (handle); } }
@@ -577,9 +577,9 @@ __hidden int tcmd_out_update_section_header(struct tracecmd_output *handle, tsizreturn 0 ; } -static int save_string_section (struct tracecmd_output *handle,bool compress) +static int save_string_section (struct tracecmd_output *handle) { -enum tracecmd_section_flags flags =0 ; +enum tracecmd_section_flags flags =TRACECMD_SEC_FL_COMPRESS ;tsize_t offset;if (!handle->strings || !handle->strings_p)
@@ -591,18 +591,16 @@ static int save_string_section(struct tracecmd_output *handle, bool compress)return -1 ; } -if (compress) - flags |=TRACECMD_SEC_FL_COMPRESS ; offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_STRINGS ,"strings" , flags, false);if (offset == (off_t)-1 )return -1 ; -tcmd_out_compression_start (handle, compress); +tcmd_out_compression_start (handle, true);if (tcmd_do_write_check (handle, handle->strings, handle->strings_p)) goto error; -if (tcmd_out_compression_end (handle, compress)) +if (tcmd_out_compression_end (handle, true)) goto error;if (tcmd_out_update_section_header (handle, offset))
@@ -616,7 +614,7 @@ static int save_string_section(struct tracecmd_output *handle, bool compress)return 0 ; error: -tcmd_out_compression_reset (handle, compress); +tcmd_out_compression_reset (handle, true);return -1 ; }
@@ -2122,7 +2120,7 @@ int tracecmd_write_meta_strings(struct tracecmd_output *handle)if (!HAS_SECTIONS (handle))return 0 ; -return save_string_section (handle, true); +return save_string_section (handle); }int tracecmd_write_options (struct tracecmd_output *handle)
Signature · 1 line
2.47.2
PATCH 2/5 libtracecmd: Remove "compress" parameter from tcmd_out_compress*() functions
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
All the tcmd_out_compression*() functions test if the handle passed in has its "compress" field set as well as the "compress" parameter is set. If either of them are not set, then those functions return without doing anything.
But the passed in "compress" value is derived from the handle->compress field, which makes it redundant.
Remove it as it's not need.
This also removes the tcmd_out_check_compression() which was used to see if the handle had its compress field set in order to set the compress variable!
--- lib/trace-cmd/include/trace-cmd-local.h | 7 ++- lib/trace-cmd/trace-input.c | 42 ++++++++--------- lib/trace-cmd/trace-output.c | 61 ++++++++++++------------- 3 files changed, 49 insertions(+), 61 deletions(-)
lib/trace-cmd/include/trace-cmd-local.h +3 -4
@@ -65,10 +65,9 @@ bool tcmd_check_file_state(unsigned long file_version, int current_state, int nebool tcmd_check_out_state (struct tracecmd_output *handle,int new_state);int tcmd_out_uncompress_block (struct tracecmd_output *handle); -int tcmd_out_compression_start (struct tracecmd_output *handle,bool compress); -int tcmd_out_compression_end (struct tracecmd_output *handle,bool compress); -void tcmd_out_compression_reset (struct tracecmd_output *handle,bool compress); -bool tcmd_out_check_compression (struct tracecmd_output *handle); +int tcmd_out_compression_start (struct tracecmd_output *handle); +int tcmd_out_compression_end (struct tracecmd_output *handle); +void tcmd_out_compression_reset (struct tracecmd_output *handle);void tcmd_out_set_file_state (struct tracecmd_output *handle,int new_state); int tcmd_out_save_options_offset(struct tracecmd_output *handle,
lib/trace-cmd/trace-input.c +18 -24
186 lines not on this page · raw message
lib/trace-cmd/trace-output.c +28 -33
204 lines not on this page · raw message
Signature · 1 line
2.47.2
PATCH 3/5 libtracecmd: Add write_compress_section_header() for writing compress sections
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
All the functions that write compressed sections has a "compress" parameter this is set when the handle->compress is set. But this is redundant and can be removed.
There's one function that still calls tcmd_out_write_section_header() without the compress flag set and that's write_options_start() as the options section is never compressed.
Since all the other functions compress their sections, add a wrapper function write_compress_section_header() that calls tcmd_out_write_section_header() with its compress flag set, and have those functions use the wrapper.
--- lib/trace-cmd/trace-output.c | 93 +++++++++++++----------------------- 1 file changed, 34 insertions(+), 59 deletions(-)
lib/trace-cmd/trace-output.c +34 -59
@@ -549,6 +549,14 @@ tcmd_out_write_section_header(struct tracecmd_output *handle, unsigned short heareturn offset; } +static unsigned long long +write_compress_section_header (struct tracecmd_output *handle,unsigned short header_id, +char *description,bool option) +{ +return tcmd_out_write_section_header (handle, header_id, description, +TRACECMD_SEC_FL_COMPRESS , option); +} + __hidden int tcmd_out_update_section_header(struct tracecmd_output *handle, tsize_t offset) {tsize_t current;
@@ -579,7 +587,6 @@ __hidden int tcmd_out_update_section_header(struct tracecmd_output *handle, tsizstatic int save_string_section (struct tracecmd_output *handle) { -enum tracecmd_section_flags flags =TRACECMD_SEC_FL_COMPRESS ;tsize_t offset;if (!handle->strings || !handle->strings_p)
@@ -591,7 +598,7 @@ static int save_string_section(struct tracecmd_output *handle)return -1 ; } - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_STRINGS ,"strings" , flags, false); + offset =write_compress_section_header (handle,TRACECMD_OPTION_STRINGS ,"strings" , false);if (offset == (off_t)-1 )return -1 ;
@@ -618,9 +625,8 @@ error:return -1 ; } -static int read_header_files (struct tracecmd_output *handle,bool compress) +static int read_header_files (struct tracecmd_output *handle) { -enum tracecmd_section_flags flags =0 ;tsize_t size, check_size, endian8;struct stat st;tsize_t offset;
@@ -638,10 +644,8 @@ static int read_header_files(struct tracecmd_output *handle, bool compress)if (!path)return -1 ; -if (compress) - flags |=TRACECMD_SEC_FL_COMPRESS ; - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_HEADER_INFO , -"headers" , flags, true); + offset =write_compress_section_header (handle,TRACECMD_OPTION_HEADER_INFO , +"headers" , true);if (offset == (off_t)-1 ) {put_tracing_file (path);return -1 ;
@@ -959,9 +963,8 @@ create_event_list_item(struct tracecmd_output *handle,tracecmd_warning ("Insufficient memory" ); } -static int read_ftrace_files (struct tracecmd_output *handle,bool compress) +static int read_ftrace_files (struct tracecmd_output *handle) { -enum tracecmd_section_flags flags =0 ;struct list_event_system *systems =NULL ;struct tracecmd_event_list list = { .glob ="ftrace/*" };tsize_t offset;
@@ -973,10 +976,8 @@ static int read_ftrace_files(struct tracecmd_output *handle, bool compress)return -1 ; } -if (compress) - flags |=TRACECMD_SEC_FL_COMPRESS ; - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_FTRACE_EVENTS , -"ftrace events" , flags, true); + offset =write_compress_section_header (handle,TRACECMD_OPTION_FTRACE_EVENTS , +"ftrace events" , true);if (offset == (off_t)-1 )return -1 ;
@@ -1014,9 +1015,8 @@ create_event_list(struct tracecmd_output *handle, }static int read_event_files (struct tracecmd_output *handle, -struct tracecmd_event_list *event_list,bool compress) +struct tracecmd_event_list *event_list) { -enum tracecmd_section_flags flags =0 ;struct list_event_system *systems;struct list_event_system *slist;struct tracecmd_event_list *list;
@@ -1032,10 +1032,8 @@ static int read_event_files(struct tracecmd_output *handle,return -1 ; } -if (compress) - flags |=TRACECMD_SEC_FL_COMPRESS ; - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_EVENT_FORMATS , -"events format" , flags, true); + offset =write_compress_section_header (handle,TRACECMD_OPTION_EVENT_FORMATS , +"events format" , true);if (offset == (off_t)-1 )return -1 ;/*
@@ -1128,9 +1126,8 @@ err:tracecmd_warning ("can't set kptr_restrict" ); } -static int read_proc_kallsyms (struct tracecmd_output *handle,bool compress) +static int read_proc_kallsyms (struct tracecmd_output *handle) { -enum tracecmd_section_flags flags =0 ;unsigned int size, check_size, endian4;const char *path ="/proc/kallsyms" ;tsize_t offset;
@@ -1146,10 +1143,8 @@ static int read_proc_kallsyms(struct tracecmd_output *handle, bool compress)if (handle->kallsyms) path = handle->kallsyms; -if (compress) - flags |=TRACECMD_SEC_FL_COMPRESS ; - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_KALLSYMS , -"kallsyms" , flags, true); + offset =write_compress_section_header (handle,TRACECMD_OPTION_KALLSYMS , +"kallsyms" , true);if (offset == (off_t)-1 )return -1 ;
@@ -1192,9 +1187,8 @@ out:return ret; } -static int read_ftrace_printk (struct tracecmd_output *handle,bool compress) +static int read_ftrace_printk (struct tracecmd_output *handle) { -enum tracecmd_section_flags flags =0 ;unsigned int size, check_size, endian4;tsize_t offset;struct stat st;
@@ -1211,9 +1205,7 @@ static int read_ftrace_printk(struct tracecmd_output *handle, bool compress)if (!path)return -1 ; -if (compress) - flags |=TRACECMD_SEC_FL_COMPRESS ; - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_PRINTK ,"printk" , flags, true); + offset =write_compress_section_header (handle,TRACECMD_OPTION_PRINTK ,"printk" , true);if (offset == (off_t)-1 ) {put_tracing_file (path);return -1 ;
@@ -1679,25 +1671,21 @@ static int output_write_init(struct tracecmd_output *handle)int tracecmd_output_write_headers (struct tracecmd_output *handle,struct tracecmd_event_list *list) { -bool compress = false; -if (!handle || handle->file_state <TRACECMD_FILE_ALLOCATED )return -1 ;/* Write init data, if not written yet */ if (handle->file_state <TRACECMD_FILE_INIT &&output_write_init (handle))return -1 ; -if (handle->compress) - compress = true; -if (read_header_files (handle, compress)) +if (read_header_files (handle))return -1 ; -if (read_ftrace_files (handle, compress)) +if (read_ftrace_files (handle))return -1 ; -if (read_event_files (handle, list, compress)) +if (read_event_files (handle, list))return -1 ; -if (read_proc_kallsyms (handle, compress)) +if (read_proc_kallsyms (handle))return -1 ; -if (read_ftrace_printk (handle, compress)) +if (read_ftrace_printk (handle))return -1 ;return 0 ; }
@@ -2268,8 +2256,6 @@ static tsize_t get_buffer_file_offset(struct tracecmd_output *handle, const charint tracecmd_write_cmdlines (struct tracecmd_output *handle) { -enum tracecmd_section_flags flags =0 ; -bool compress = false;tsize_t offset;int ret;
@@ -2279,13 +2265,8 @@ int tracecmd_write_cmdlines(struct tracecmd_output *handle)return -1 ; } -if (handle->compress) - compress = true; - -if (compress) - flags |=TRACECMD_SEC_FL_COMPRESS ; - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_CMDLINES , -"command lines" , flags, true); + offset =write_compress_section_header (handle,TRACECMD_OPTION_CMDLINES , +"command lines" , true);if (offset == (off_t)-1 )return -1 ;
@@ -2420,7 +2401,6 @@ tcmd_out_add_buffer_option(struct tracecmd_output *handle, const char *name,struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus,int file_version,const char *compression) { -enum tracecmd_section_flags flags =0 ;struct tracecmd_output *handle;tsize_t offset;char *path;
@@ -2472,11 +2452,9 @@ struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, in !tcmd_out_add_buffer_option(handle, "", TRACECMD_OPTION_BUFFER_TEXT, offset, 0, NULL, getpagesize())) goto out_free; -if (handle->compress) - flags |=TRACECMD_SEC_FL_COMPRESS ; - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_BUFFER_TEXT , -"buffer latency" , flags, false); + offset =write_compress_section_header (handle,TRACECMD_OPTION_BUFFER_TEXT , +"buffer latency" , false);copy_file_compress (handle, path,NULL );if (tcmd_out_update_section_header (handle, offset))
@@ -2595,7 +2573,6 @@ __hidden int tcmd_out_write_cpu_data(struct tracecmd_output *handle, const char *buff_name) {struct data_file_write *data_files =NULL ; -enum tracecmd_section_flags flags =0 ;tsize_t data_offs, offset;unsigned long long endian8;unsigned long long read_size;
@@ -2625,11 +2602,9 @@ __hidden int tcmd_out_write_cpu_data(struct tracecmd_output *handle,if (!HAS_SECTIONS (handle) &&tcmd_do_write_check (handle,"flyrecord" ,10 )) goto out_free; -if (handle->compress) - flags |=TRACECMD_SEC_FL_COMPRESS ;if (asprintf (&str,"buffer flyrecord %s" , buff_name) <1 ) goto out_free; - offset =tcmd_out_write_section_header (handle,TRACECMD_OPTION_BUFFER , str, flags, false); + offset =write_compress_section_header (handle,TRACECMD_OPTION_BUFFER , str, false);free (str);if (offset == (off_t)-1 ) goto out_free;
@@ -2713,7 +2688,7 @@ __hidden int tcmd_out_write_cpu_data(struct tracecmd_output *handle,if (!tracecmd_get_quiet (handle)) {fprintf (stderr," %llu bytes in size" , (unsigned long long )data_files[i].write_size); -if (flags &TRACECMD_SEC_FL_COMPRESS ) +if (handle->compress)fprintf (stderr," (%llu uncompressed)" , (unsigned long long )data_files[i].file_size);fprintf (stderr,"\n" );
Signature · 1 line
2.47.2
PATCH 4/5 trace-cmd record / report: Record BTF file if function arguments are recorded
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
If function tracer is recorded with func-args option set, or the function_graph tracer is recorded with the funcgraph-args option set, then record the BTF file in a new BTF_FILE section in the trace.dat file.
This is compressed on disk, and when the trace.dat file is read, it is loaded into memory and sent to the libtraceevent tep_load_btf() function.
This will be used to show arguments of the function tracer:
cat-33501 [005] ..... 136155.767937: function: mutex_unlock(lock=0xffffffff831dbbe0)
cat-33501 [005] ..... 136155.767939: function: __mutex_unlock_slowpath(lock=0xffffffff831dbbe0, ip=0xffffffff814a7154)
cat-33501 [005] ..... 136155.767940: function: __f_unlock_pos(f=0xffff8881538de000)
cat-33501 [005] ..... 136155.767940: function: mutex_unlock(lock=0xffff8881538de090)
cat-33501 [005] ..... 136155.767940: function: __mutex_unlock_slowpath(lock=0xffff8881538de090, ip=0xffffffff816e8ed1)
cat-33501 [005] ..... 136155.767941: function: mem_cgroup_handle_over_high(gfp_mask=0xcc0)
cat-33501 [005] ..... 136155.767941: function: blkcg_maybe_throttle_current()
cat-33501 [005] ..... 136155.767942: function: __rseq_handle_notify_resume(ksig=0x0, regs=0xffffc9000e3eff58)
cat-33501 [005] d.... 136155.767943: function: fpregs_assert_state_consistent()
cat-33501 [005] d.... 136155.767943: function: switch_fpu_return()
cat-33501 [005] ..... 136155.767950: function: __x64_sys_execve(regs=0xffffc9000e3eff58)
cat-33501 [005] ..... 136155.767951: function: getname_flags(filename=0x7ffe7d33f3d0, flags=0)
cat-33501 [005] ..... 136155.767951: function: getname_flags.part.0(7ffe7d33f3d0, 0, 0, 0, 0, 0)
cat-33501 [005] ..... 136155.767951: function: kmem_cache_alloc_noprof(s=0xffff8881001d3800, gfpflags=0xcc0)--- .../include/private/trace-cmd-private.h | 3 + lib/trace-cmd/trace-compress.c | 26 ++++++++ lib/trace-cmd/trace-input.c | 15 +++++ lib/trace-cmd/trace-output.c | 64 +++++++++++++++++++ tracecmd/trace-record.c | 42 +++++++++++- 5 files changed, 149 insertions(+), 1 deletion(-)
lib/trace-cmd/include/private/trace-cmd-private.h +3 -0
@@ -159,6 +159,7 @@ enum {TRACECMD_OPTION_PRINTK ,TRACECMD_OPTION_CMDLINES ,TRACECMD_OPTION_BUFFER_TEXT , +TRACECMD_OPTION_BTF_FILE , TRACECMD_OPTION_MAX, };
@@ -340,6 +341,7 @@ int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,struct tracecmd_output *tracecmd_get_output_handle_fd (int fd);unsigned long tracecmd_get_out_file_version (struct tracecmd_output *handle);size_t tracecmd_get_out_file_offset (struct tracecmd_output *handle); +int tracecmd_append_btf_file (struct tracecmd_output *handle);/* --- Reading the Fly Recorder Trace --- */
@@ -568,6 +570,7 @@ int tracecmd_uncompress_chunk(struct tracecmd_compression *handle, struct tracecmd_compress_chunk *chunk, char *data);int tracecmd_load_chunks_info (struct tracecmd_compression *handle,struct tracecmd_compress_chunk **chunks_info); +void *tracecmd_uncompress_buffer (struct tracecmd_compression *handle,size_t *size);/* --- Plugin handling --- */ extern struct tep_plugin_option trace_ftrace_options[];
lib/trace-cmd/trace-compress.c +26 -0
@@ -363,6 +363,32 @@ out:free (buf);return ret; } +/** +* tracecmd_uncompress_buffer - Returned the current uncompressed buffer +* @handle: compression handle +* @size: A pointer to place the size of the uncompressed buffer in +* +* Returns the current uncompressed buffer and resets the compression +* @handle. +* +* Returns the buffer (must be freed with free()) or NULL. +* @size (if not NULL) will contain the size of the uncompressed buffer. +*/ +void *tracecmd_uncompress_buffer (struct tracecmd_compression *handle,size_t *size) +{ +void *buffer; + +if (!handle) +return NULL ; + +if (size) + *size = handle->capacity; + + buffer = handle->buffer; + handle->buffer =NULL ; +tracecmd_compress_reset (handle); +return buffer; +}/** * tracecmd_compress_buffer_write - write() to compression buffer
lib/trace-cmd/trace-input.c +15 -0
@@ -1026,6 +1026,17 @@ static int read_ftrace_printk(struct tracecmd_input *handle)return 0 ; } +static int read_btf (struct tracecmd_input *handle) +{ +void *raw_data; +size_t size; + + raw_data =tracecmd_uncompress_buffer (handle->compress, &size); + +tep_load_btf (handle->pevent, raw_data, size); +return 0 ; +} +static int read_and_parse_cmdlines (struct tracecmd_input *handle);/**
@@ -1203,6 +1214,9 @@ static int handle_section(struct tracecmd_input *handle, struct file_section *secase TRACECMD_OPTION_CMDLINES : ret =read_and_parse_cmdlines (handle);break ; +case TRACECMD_OPTION_BTF_FILE : + ret =read_btf (handle); +break ;default : ret =0 ;break ;
@@ -4174,6 +4188,7 @@ static int handle_options(struct tracecmd_input *handle)case TRACECMD_OPTION_KALLSYMS :case TRACECMD_OPTION_PRINTK :case TRACECMD_OPTION_CMDLINES : +case TRACECMD_OPTION_BTF_FILE :if (size <8 )break ; section_add_or_update(handle, option, -1,
lib/trace-cmd/trace-output.c +64 -0
70 lines not on this page · raw message
tracecmd/trace-record.c +41 -1
64 lines not on this page · raw message
Signature · 1 line
2.47.2
Re: [PATCH 4/5] trace-cmd record / report: Record BTF file if function arguments are recorded
Don't forget to update the doc as well :)Documentation/trace-cmd/trace-cmd.dat.v7.5.txt
Quoted 285 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
If function tracer is recorded with func-args option set, or the
function_graphtracer is recorded with the funcgraph-args option set, then record the BTF file in a newBTF_FILEsection in the trace.dat file.This is compressed on disk, and when the trace.dat file is read, it is loaded into memory and sent to the libtraceevent
tep_load_btf()function.This will be used to show arguments of the function tracer:
cat-33501 [005] ..... 136155.767937: function: mutex_unlock(lock=0xffffffff831dbbe0) cat-33501 [005] ..... 136155.767939: function: __mutex_unlock_slowpath(lock=0xffffffff831dbbe0, ip=0xffffffff814a7154) cat-33501 [005] ..... 136155.767940: function: __f_unlock_pos(f=0xffff8881538de000) cat-33501 [005] ..... 136155.767940: function: mutex_unlock(lock=0xffff8881538de090) cat-33501 [005] ..... 136155.767940: function: __mutex_unlock_slowpath(lock=0xffff8881538de090, ip=0xffffffff816e8ed1) cat-33501 [005] ..... 136155.767941: function: mem_cgroup_handle_over_high(gfp_mask=0xcc0) cat-33501 [005] ..... 136155.767941: function: blkcg_maybe_throttle_current() cat-33501 [005] ..... 136155.767942: function: __rseq_handle_notify_resume(ksig=0x0, regs=0xffffc9000e3eff58) cat-33501 [005] d.... 136155.767943: function: fpregs_assert_state_consistent() cat-33501 [005] d.... 136155.767943: function: switch_fpu_return() cat-33501 [005] ..... 136155.767950: function: __x64_sys_execve(regs=0xffffc9000e3eff58) cat-33501 [005] ..... 136155.767951: function: getname_flags(filename=0x7ffe7d33f3d0, flags=0) cat-33501 [005] ..... 136155.767951: function: getname_flags.part.0(7ffe7d33f3d0, 0, 0, 0, 0, 0) cat-33501 [005] ..... 136155.767951: function: kmem_cache_alloc_noprof(s=0xffff8881001d3800, gfpflags=0xcc0)Signed-off-by Steven Rostedt (Google) <[email protected]>--- .../include/private/trace-cmd-private.h | 3 + lib/trace-cmd/trace-compress.c | 26 ++++++++ lib/trace-cmd/trace-input.c | 15 +++++ lib/trace-cmd/trace-output.c | 64 +++++++++++++++++++ tracecmd/trace-record.c | 42 +++++++++++- 5 files changed, 149 insertions(+), 1 deletion(-)lib/trace-cmd/include/private/trace-cmd-private.h +3
-0@@ -159,6 +159,7 @@ enum {TRACECMD_OPTION_PRINTK ,TRACECMD_OPTION_CMDLINES ,TRACECMD_OPTION_BUFFER_TEXT , +TRACECMD_OPTION_BTF_FILE , TRACECMD_OPTION_MAX, };@@ -340,6 +341,7 @@ int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,struct tracecmd_output *tracecmd_get_output_handle_fd (int fd);unsigned long tracecmd_get_out_file_version (struct tracecmd_output *handle);size_t tracecmd_get_out_file_offset (struct tracecmd_output *handle); +int tracecmd_append_btf_file (struct tracecmd_output *handle);/* --- Reading the Fly Recorder Trace --- */ @@ -568,6 +570,7 @@ int tracecmd_uncompress_chunk(struct tracecmd_compression *handle, struct tracecmd_compress_chunk *chunk, char *data);int tracecmd_load_chunks_info (struct tracecmd_compression *handle,struct tracecmd_compress_chunk **chunks_info); +void *tracecmd_uncompress_buffer (struct tracecmd_compression *handle,size_t *size);/* --- Plugin handling --- */ extern struct tep_plugin_option trace_ftrace_options[];lib/trace-cmd/trace-compress.c +26
-0@@ -363,6 +363,32 @@ out:free (buf);return ret; } +/** +* tracecmd_uncompress_buffer - Returned the current uncompressed buffer +* @handle: compression handle +* @size: A pointer to place the size of the uncompressed buffer in +* +* Returns the current uncompressed buffer and resets the compression +* @handle. +* +* Returns the buffer (must be freed with free()) or NULL. +* @size (if not NULL) will contain the size of the uncompressed buffer. +*/ +void *tracecmd_uncompress_buffer (struct tracecmd_compression *handle,size_t *size) +{ +void *buffer; + +if (!handle) +return NULL ; + +if (size) + *size = handle->capacity; + + buffer = handle->buffer; + handle->buffer =NULL ; +tracecmd_compress_reset (handle); +return buffer; +}/** * tracecmd_compress_buffer_write - write() to compression buffer lib/trace-cmd/trace-input.c +15
-0@@ -1026,6 +1026,17 @@ static int read_ftrace_printk(struct tracecmd_input *handle)return 0 ; } +static int read_btf (struct tracecmd_input *handle) +{ +void *raw_data; +size_t size; + + raw_data =tracecmd_uncompress_buffer (handle->compress, &size); + +tep_load_btf (handle->pevent, raw_data, size); +return 0 ; +} +static int read_and_parse_cmdlines (struct tracecmd_input *handle);/** @@ -1203,6 +1214,9 @@ static int handle_section(struct tracecmd_input *handle, struct file_section *secase TRACECMD_OPTION_CMDLINES : ret =read_and_parse_cmdlines (handle);break ; +case TRACECMD_OPTION_BTF_FILE : + ret =read_btf (handle); +break ;default : ret =0 ;break ;@@ -4174,6 +4188,7 @@ static int handle_options(struct tracecmd_input *handle)case TRACECMD_OPTION_KALLSYMS :case TRACECMD_OPTION_PRINTK :case TRACECMD_OPTION_CMDLINES : +case TRACECMD_OPTION_BTF_FILE :if (size <8 )break ; section_add_or_update(handle, option, -1,lib/trace-cmd/trace-output.c +64
-0@@ -2288,6 +2288,70 @@ int tracecmd_write_cmdlines(struct tracecmd_output *handle)return 0 ; } +#define BTF_FILE "/sys/kernel/btf/vmlinux" + +int tracecmd_append_btf_file (struct tracecmd_output *handle) +{ +tsize_t offset, size, check_size; +struct tracecmd_option *option; +struct iovec *vect; +struct stat st; +int ret; + +if (!HAS_SECTIONS (handle)) +return -1 ; + + offset =write_compress_section_header (handle,TRACECMD_OPTION_BTF_FILE ,NULL , true); +if (offset == (off_t)-1 ) +return -1 ; + +tcmd_out_compression_start (handle); + + ret =stat (BTF_FILE , &st); +if (ret <0 ) +return -1 ; + + check_size =copy_file (handle,BTF_FILE ); +if (st.st_size != check_size) { + errno =EINVAL ; +tracecmd_warning ("error in size of file '%s'" ,BTF_FILE ); +return -1 ; + } + +if (tcmd_out_compression_end (handle)) +return -1 ; + +if (tcmd_out_update_section_header (handle, offset)) +return -1 ; + +return 0 ; + +/* +* BTF file +* - data offset in the file +* - data size +*/ + + vect =calloc (2 ,sizeof (struct iovec )); +if (!vect) +return -1 ; + vect[0 ].iov_base = &offset; + vect[0 ].iov_len =8 ; + vect[1 ].iov_base = &size; + vect[1 ].iov_len =8 ; + + option =tracecmd_add_option_v (handle,TRACECMD_OPTION_BTF_FILE , vect,2 ); +free (vect); + +if (!option) +return -1 ; + +if (do_lseek (handle,0 ,SEEK_END ) == (off_t)-1 ) +return -1 ; + +return 0 ; +} +static char *get_clock (struct tracecmd_output *handle) {struct tracefs_instance *inst;tracecmd/trace-record.c +41
-1@@ -4632,12 +4632,46 @@ error:return NULL ; } +static void check_need_btf (bool *need_btf,struct tracefs_instance *instance) +{ +bool func_graph_trace; +bool func_trace; +char *current; + +/* Nothing to do if it's already set */ +if (*need_btf) +return ; + + current =tracefs_instance_file_read (instance,"current_tracer" ,NULL ); +if (!current) +return ; + + func_trace =strcmp (current,"function\n" ) ==0 ; + func_graph_trace =strcmp (current,"function_graph\n" ) ==0 ; + +free (current); +if (!func_trace && !func_graph_trace) +return ; + +if (func_trace) + current =tracefs_instance_file_read (instance,"options/func-args" ,NULL ); +else + current =tracefs_instance_file_read (instance,"options/funcgraph-args" ,NULL ); +if (!current) +return ; + + *need_btf =strncmp (current,"1" ,1 ) ==0 ; + +free (current); +} +static void record_data (struct common_record_context *ctx) {struct tracecmd_output *handle;struct buffer_instance *instance;bool have_proxy = false;bool local = false; +bool need_btf = false;int max_cpu_count = local_cpu_count;char **temp_files;int i;@@ -4733,11 +4767,17 @@ static void record_data(struct common_record_context *ctx)tracefs_instance_get_name (instance->tracefs), cpus);add_buffer_stat (handle, instance); +check_need_btf (&need_btf, instance->tracefs); } } -if (!no_top_instance () && !top_instance.msg_handle) +if (!no_top_instance () && !top_instance.msg_handle) {print_stat (&top_instance); +check_need_btf (&need_btf, top_instance.tracefs); + } + +if (need_btf) +tracecmd_append_btf_file (handle);for_all_instances (instance) {add_pid_maps (handle, instance);
PATCH 5/5 libtracecmd: Add printing of arguments for function graph tracer
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
If the function graph tracer was recorded with the funcgraph-args option set, then the BTF file would also be recorded. Print the contents of the arguments with the information provided by BTF.
The output will look like this:
cat-43792 [006] ..... 147894.472393: funcgraph_entry: | mutex_unlock(lock=0xffffffff831dbbe0) {
cat-43792 [006] ..... 147894.472394: funcgraph_entry: 1.005 us | __mutex_unlock_slowpath(lock=0xffffffff831dbbe0, ip=0xffffffff812f2e30); (ret=0x0)
cat-43792 [006] ..... 147894.472396: funcgraph_exit: 3.581 us | } (ret=0x0)
cat-43792 [006] ..... 147894.472397: funcgraph_entry: | __f_unlock_pos(f=0xffff8881538df980) {
cat-43792 [006] ..... 147894.472397: funcgraph_entry: | mutex_unlock(lock=0xffff8881538dfa10) {
cat-43792 [006] ..... 147894.472397: funcgraph_entry: 0.434 us | __mutex_unlock_slowpath(lock=0xffff8881538dfa10, ip=0xffffffff812f2e30); (ret=0x0)
cat-43792 [006] ..... 147894.472398: funcgraph_exit: 1.216 us | } (ret=0x0)
cat-43792 [006] ..... 147894.472399: funcgraph_exit: 2.152 us | } (ret=0x0)
cat-43792 [006] d.... 147894.472399: funcgraph_entry: 0.360 us | fpregs_assert_state_consistent(); (ret=0x6)
cat-43792 [006] ..... 147894.472403: funcgraph_entry: | __x64_sys_execve(regs=0xffffc900029f3f58) {
cat-43792 [006] ..... 147894.472404: funcgraph_entry: | getname_flags(filename=0x7fff4a902080, flags=0) {
cat-43792 [006] ..... 147894.472404: funcgraph_entry: | getname_flags.part.0(7fff4a902080, 0, 0, 0, 0, 0) {
cat-43792 [006] ..... 147894.472405: funcgraph_entry: | kmem_cache_alloc_noprof(s=0xffff8881001d3800, gfpflags=0xcc0) {
cat-43792 [006] ..... 147894.472405: funcgraph_entry: 0.618 us | fs_reclaim_acquire(gfp_mask=0xcc0); (ret=0x0)
cat-43792 [006] ..... 147894.472406: funcgraph_entry: 0.380 us | fs_reclaim_release(gfp_mask=0xcc0); (ret=0x0)
cat-43792 [006] ..... 147894.472407: funcgraph_entry: | kmemleak_alloc(ptr=0xffff8881120b0000, size=0x1000, min_count=1, gfp=0xcc0) {
cat-43792 [006] ..... 147894.472408: funcgraph_entry: | __create_object(ptr=0xffff8881120b0000, size=0x1000, min_count=1, gfp=0xcc0, objflags=0x0) {
cat-43792 [006] ..... 147894.472408: funcgraph_entry: | __alloc_object(gfp=0xcc0) {
cat-43792 [006] ..... 147894.472408: funcgraph_entry: | kmem_cache_alloc_noprof(s=0xffff888100045700, gfpflags=0x92cc0) {
cat-43792 [006] ..... 147894.472409: funcgraph_entry: 0.570 us | fs_reclaim_acquire(gfp_mask=0x92cc0); (ret=0x0)
cat-43792 [006] ..... 147894.472410: funcgraph_entry: 0.370 us | fs_reclaim_release(gfp_mask=0x92cc0); (ret=0x0)
cat-43792 [006] ..... 147894.472411: funcgraph_exit: 2.226 us | } (ret=0xffff88814bbcf6a8)--- lib/trace-cmd/trace-ftrace.c | 41 ++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-)
lib/trace-cmd/trace-ftrace.c +35 -6
@@ -198,6 +198,31 @@ static void print_graph_duration(struct trace_seq *s, unsigned long long duratiotrace_seq_puts (s,"| " ); } +/* Returns true if it printed args, otherwise it returns false */ +static bool print_args (struct trace_seq *s,struct tep_event *event, +struct tep_record *record,const char *func) +{ +struct tep_format_field *field; +void *args; +int len; + + field =tep_find_field (event,"args" ); +if (!field) +return false; + + len = record->size - field->offset; + +/* todo make this tep long size */ +if (len <3 *sizeof (long )) +return false; + + args = record->data + field->offset; + +tep_btf_print_args (event->tep, s, args, len /sizeof (long ),sizeof (long ), func); + +return true; +} + static int print_graph_entry_leaf(struct trace_seq *s, struct tep_event *event,
@@ -247,9 +272,11 @@ print_graph_entry_leaf(struct trace_seq *s,return trace_seq_putc (s,'!' ); func =tep_find_function (pevent, val); -if (func) - ret =trace_seq_printf (s,"%s();" , func); -else +if (func) { + ret =trace_seq_printf (s,"%s(" , func); +print_args (s, event, record, func); + ret =trace_seq_puts (s,");" ); + }else ret =trace_seq_printf (s,"%llx();" , val);if (ret && fgraph_depth->set)
@@ -302,9 +329,11 @@ static int print_graph_nested(struct trace_seq *s, func =tep_find_function (pevent, val); -if (func) - ret =trace_seq_printf (s,"%s() {" , func); -else +if (func) { + ret =trace_seq_printf (s,"%s(" , func); +print_args (s, event, record, func); + ret =trace_seq_puts (s,") {" ); + }else ret =trace_seq_printf (s,"%llx() {" , val);if (ret && fgraph_depth->set)
Signature · 1 line
2.47.2
Quoted 5 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
If function tracer is recorded with func-args option set, or the
function_graphtracer is recorded with the funcgraph-args option set, then record the BTF file in a newBTF_FILEsection in the trace.dat file.
Would it be possible to also add an explicit CLI flag to collect the BTF blob ?
We may have some use for that downstream that are unrelated to function_graph tracer. One unrefined idea I had was to use BTF to get the enumerator names when converting events to parquet. With dict encoding, this would be just as efficient and much nicer for the end user.
Quoted 62 lines
This is compressed on disk, and when the trace.dat file is read, it is loaded into memory and sent to the libtraceevent
tep_load_btf()function.This will be used to show arguments of the function tracer:
# trace-cmd record -p function -O func-args cat /etc/passwd # trace-cmd reportcat-33501 [005] ..... 136155.767937: function: mutex_unlock(lock=0xffffffff831dbbe0) cat-33501 [005] ..... 136155.767939: function: __mutex_unlock_slowpath(lock=0xffffffff831dbbe0, ip=0xffffffff814a7154) cat-33501 [005] ..... 136155.767940: function: __f_unlock_pos(f=0xffff8881538de000) cat-33501 [005] ..... 136155.767940: function: mutex_unlock(lock=0xffff8881538de090) cat-33501 [005] ..... 136155.767940: function: __mutex_unlock_slowpath(lock=0xffff8881538de090, ip=0xffffffff816e8ed1) cat-33501 [005] ..... 136155.767941: function: mem_cgroup_handle_over_high(gfp_mask=0xcc0) cat-33501 [005] ..... 136155.767941: function: blkcg_maybe_throttle_current() cat-33501 [005] ..... 136155.767942: function: __rseq_handle_notify_resume(ksig=0x0, regs=0xffffc9000e3eff58) cat-33501 [005] d.... 136155.767943: function: fpregs_assert_state_consistent() cat-33501 [005] d.... 136155.767943: function: switch_fpu_return() cat-33501 [005] ..... 136155.767950: function: __x64_sys_execve(regs=0xffffc9000e3eff58) cat-33501 [005] ..... 136155.767951: function: getname_flags(filename=0x7ffe7d33f3d0, flags=0) cat-33501 [005] ..... 136155.767951: function: getname_flags.part.0(7ffe7d33f3d0, 0, 0, 0, 0, 0) cat-33501 [005] ..... 136155.767951: function: kmem_cache_alloc_noprof(s=0xffff8881001d3800, gfpflags=0xcc0)And the same for function graph tracer:
# trace-cmd record -p function_graph -O funcgraph-args cat /etc/passwd # trace-cmd reportcat-43792 [006] ..... 147894.472393: funcgraph_entry: | mutex_unlock(lock=0xffffffff831dbbe0) { cat-43792 [006] ..... 147894.472394: funcgraph_entry: 1.005 us | __mutex_unlock_slowpath(lock=0xffffffff831dbbe0, ip=0xffffffff812f2e30); (ret=0x0) cat-43792 [006] ..... 147894.472396: funcgraph_exit: 3.581 us | } (ret=0x0) cat-43792 [006] ..... 147894.472397: funcgraph_entry: | __f_unlock_pos(f=0xffff8881538df980) { cat-43792 [006] ..... 147894.472397: funcgraph_entry: | mutex_unlock(lock=0xffff8881538dfa10) { cat-43792 [006] ..... 147894.472397: funcgraph_entry: 0.434 us | __mutex_unlock_slowpath(lock=0xffff8881538dfa10, ip=0xffffffff812f2e30); (ret=0x0) cat-43792 [006] ..... 147894.472398: funcgraph_exit: 1.216 us | } (ret=0x0) cat-43792 [006] ..... 147894.472399: funcgraph_exit: 2.152 us | } (ret=0x0) cat-43792 [006] d.... 147894.472399: funcgraph_entry: 0.360 us | fpregs_assert_state_consistent(); (ret=0x6) cat-43792 [006] ..... 147894.472403: funcgraph_entry: | __x64_sys_execve(regs=0xffffc900029f3f58) { cat-43792 [006] ..... 147894.472404: funcgraph_entry: | getname_flags(filename=0x7fff4a902080, flags=0) { cat-43792 [006] ..... 147894.472404: funcgraph_entry: | getname_flags.part.0(7fff4a902080, 0, 0, 0, 0, 0) { cat-43792 [006] ..... 147894.472405: funcgraph_entry: | kmem_cache_alloc_noprof(s=0xffff8881001d3800, gfpflags=0xcc0) { cat-43792 [006] ..... 147894.472405: funcgraph_entry: 0.618 us | fs_reclaim_acquire(gfp_mask=0xcc0); (ret=0x0) cat-43792 [006] ..... 147894.472406: funcgraph_entry: 0.380 us | fs_reclaim_release(gfp_mask=0xcc0); (ret=0x0) cat-43792 [006] ..... 147894.472407: funcgraph_entry: | kmemleak_alloc(ptr=0xffff8881120b0000, size=0x1000, min_count=1, gfp=0xcc0) { cat-43792 [006] ..... 147894.472408: funcgraph_entry: | __create_object(ptr=0xffff8881120b0000, size=0x1000, min_count=1, gfp=0xcc0, objflags=0x0) { cat-43792 [006] ..... 147894.472408: funcgraph_entry: | __alloc_object(gfp=0xcc0) { cat-43792 [006] ..... 147894.472408: funcgraph_entry: | kmem_cache_alloc_noprof(s=0xffff888100045700, gfpflags=0x92cc0) { cat-43792 [006] ..... 147894.472409: funcgraph_entry: 0.570 us | fs_reclaim_acquire(gfp_mask=0x92cc0); (ret=0x0) cat-43792 [006] ..... 147894.472410: funcgraph_entry: 0.370 us | fs_reclaim_release(gfp_mask=0x92cc0); (ret=0x0) cat-43792 [006] ..... 147894.472411: funcgraph_exit: 2.226 us | } (ret=0xffff88814bbcf6a8)Steven Rostedt (Google) (5):
libtracecmd: Remove "compress" parameter fromsave_string_section()
libtracecmd: Remove "compress" parameter from tcmd_out_compress*()
functions
libtracecmd: Addwrite_compress_section_header()for writing compress
sections
trace-cmd record / report: Record BTF file if function arguments are
recorded
libtracecmd: Add printing of arguments for function graph tracer
Quoted 9 lines
.../include/private/trace-cmd-private.h | 3 + lib/trace-cmd/include/trace-cmd-local.h | 7 +- lib/trace-cmd/trace-compress.c | 26 ++ lib/trace-cmd/trace-ftrace.c | 41 +++- lib/trace-cmd/trace-input.c | 57 +++-- lib/trace-cmd/trace-output.c | 228 ++++++++++-------- tracecmd/trace-record.c | 42 +++- 7 files changed, 271 insertions(+), 133 deletions(-)
--
Douglas
Quoted 8 lines · On Mon, 4 Aug 2025 13:36:26 +0100 Douglas Raillard <[email protected]>…
Quoted 5 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
If function tracer is recorded with func-args option set, or the
function_graphtracer is recorded with the funcgraph-args option set, then record the BTF file in a newBTF_FILEsection in the trace.dat file.Would it be possible to also add an explicit CLI flag to collect the BTF blob ?
Sure, that shouldn't be to hard. We could add --btf /path/to/file for both the record and the report.
-- Steve
Quoted 6 lines · Steven Rostedt
Quoted 3 lines · On Mon, 4 Aug 2025 13:36:26 +0100 Douglas Raillard <[email protected]>…
Quoted 2 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
If function tracer is recorded with func-args option set, or the
function_graphtracer is recorded with the funcgraph-args option set, then record the BTF file in a newBTF_FILEsection in the trace.dat file.Would it be possible to also add an explicit CLI flag to collect the BTF blob ?
Sure, that shouldn't be to hard. We could add --btf /path/to/file for both the record and the report.
Sounds like a good idea. If you want to support passing BTF at report time to supplement a BTF-less trace.dat, it would make sense to also support getting BTF from the ELF section so that people can pass the real vmlinux file directly (not the BTF blob in sysfs, the actual ELF vmlinux from Kbuild).
It seems libbpf allows to do that with bpf_object__open_file():
https://docs.ebpf.io/ebpf-library/libbpf/userspace/bpf_object__open_file/
Quoted 1 line
-- Steve
Signature · 1 line
Douglas
Quoted 7 lines · On Mon, 4 Aug 2025 15:28:58 +0100 Douglas Raillard <[email protected]>…
Sounds like a good idea. If you want to support passing BTF at report time to supplement a BTF-less trace.dat, it would make sense to also support getting BTF from the ELF section so that people can pass the real vmlinux file directly (not the BTF blob in sysfs, the actual ELF vmlinux from
Kbuild).It seems libbpf allows to do that with
bpf_object__open_file():
https://docs.ebpf.io/ebpf-library/libbpf/userspace/bpf_object__open_file/
Yeah, but then it adds a dependency that I'm trying to limit.
Parsing elf files for sections is quite trivial. I've done that a lot. I may just add a: --btf-elf /path/to/elf-file
-- Steve