Pad the DSO name in --call-trace so we don't have the indent screwed by
different DSO name lengths, as now for kernel there's also BPF code
displayed.
# perf-with-kcore record pt -e intel_pt//ku -- sleep 1
# perf-core/perf-with-kcore script pt --call-trace
Before:
sleep 3660 [16] 57036.
806464404: ([kernel.kallsyms]) kretprobe_perf_func
sleep 3660 [16] 57036.
806464404: ([kernel.kallsyms]) trace_call_bpf
sleep 3660 [16] 57036.
806464404: ([kernel.kallsyms]) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806464404: ([kernel.kallsyms]) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_get_current_pid_tgid
sleep 3660 [16] 57036.
806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_ktime_get_ns
sleep 3660 [16] 57036.
806464725: ([kernel.kallsyms]) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806464725: ([kernel.kallsyms]) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806465045: (bpf_prog_da4fe6b3d2c29b25_trace_return) __htab_map_lookup_elem
sleep 3660 [16] 57036.
806465366: ([kernel.kallsyms]) memcmp
sleep 3660 [16] 57036.
806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_probe_read
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms]) probe_kernel_read
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms]) __check_object_size
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms]) check_stack_object
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms]) copy_user_enhanced_fast_string
sleep 3660 [16] 57036.
806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_probe_read
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms]) probe_kernel_read
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms]) __check_object_size
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms]) check_stack_object
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms]) copy_user_enhanced_fast_string
sleep 3660 [16] 57036.
806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_get_current_uid_gid
sleep 3660 [16] 57036.
806466008: ([kernel.kallsyms]) from_kgid
sleep 3660 [16] 57036.
806466008: ([kernel.kallsyms]) from_kuid
sleep 3660 [16] 57036.
806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_perf_event_output
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms]) perf_event_output
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms]) perf_prepare_sample
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms]) perf_misc_flags
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms]) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms]) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806466328: ([kvm]) kvm_is_in_guest
sleep 3660 [16] 57036.
806466649: ([kernel.kallsyms]) __perf_event_header__init_id.isra.0
sleep 3660 [16] 57036.
806466649: ([kernel.kallsyms]) perf_output_begin
After:
sleep 3660 [16] 57036.
806464404: ([kernel.kallsyms] ) kretprobe_perf_func
sleep 3660 [16] 57036.
806464404: ([kernel.kallsyms] ) trace_call_bpf
sleep 3660 [16] 57036.
806464404: ([kernel.kallsyms] ) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806464404: ([kernel.kallsyms] ) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_get_current_pid_tgid
sleep 3660 [16] 57036.
806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_ktime_get_ns
sleep 3660 [16] 57036.
806464725: ([kernel.kallsyms] ) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806464725: ([kernel.kallsyms] ) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806465045: (bpf_prog_da4fe6b3d2c29b25_trace_return ) __htab_map_lookup_elem
sleep 3660 [16] 57036.
806465366: ([kernel.kallsyms] ) memcmp
sleep 3660 [16] 57036.
806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_probe_read
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms] ) probe_kernel_read
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms] ) __check_object_size
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms] ) check_stack_object
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms] ) copy_user_enhanced_fast_string
sleep 3660 [16] 57036.
806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_probe_read
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms] ) probe_kernel_read
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms] ) __check_object_size
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms] ) check_stack_object
sleep 3660 [16] 57036.
806465687: ([kernel.kallsyms] ) copy_user_enhanced_fast_string
sleep 3660 [16] 57036.
806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_get_current_uid_gid
sleep 3660 [16] 57036.
806466008: ([kernel.kallsyms] ) from_kgid
sleep 3660 [16] 57036.
806466008: ([kernel.kallsyms] ) from_kuid
sleep 3660 [16] 57036.
806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_perf_event_output
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms] ) perf_event_output
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms] ) perf_prepare_sample
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms] ) perf_misc_flags
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms] ) __x86_indirect_thunk_rax
sleep 3660 [16] 57036.
806466328: ([kernel.kallsyms] ) __x86_indirect_thunk_rax
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stanislav Fomichev <sdf@google.com>
Link: http://lkml.kernel.org/r/20190508132010.14512-8-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
int scnprintf(char * buf, size_t size, const char * fmt, ...);
+int scnprintf_pad(char * buf, size_t size, const char * fmt, ...);
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
return (i >= ssize) ? (ssize - 1) : i;
}
+
+int scnprintf_pad(char * buf, size_t size, const char * fmt, ...)
+{
+ ssize_t ssize = size;
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i = vscnprintf(buf, size, fmt, args);
+ va_end(args);
+
+ if (i < (int) size) {
+ for (; i < (int) size; i++)
+ buf[i] = ' ';
+ buf[i] = 0x0;
+ }
+
+ return (i >= ssize) ? (ssize - 1) : i;
+}
parse_output_fields(NULL, "-ip,-addr,-event,-period,+callindent", 0);
itrace_parse_synth_opts(opt, "cewp", 0);
symbol_conf.nanosecs = true;
+ symbol_conf.pad_output_len_dso = 50;
return 0;
}
size_t map__fprintf_dsoname(struct map *map, FILE *fp)
{
+ char buf[symbol_conf.pad_output_len_dso + 1];
const char *dsoname = "[unknown]";
if (map && map->dso) {
dsoname = map->dso->name;
}
+ if (symbol_conf.pad_output_len_dso) {
+ scnprintf_pad(buf, symbol_conf.pad_output_len_dso, "%s", dsoname);
+ dsoname = buf;
+ }
+
return fprintf(fp, "%s", dsoname);
}
*tid_list;
const char *symfs;
int res_sample;
+ int pad_output_len_dso;
};
extern struct symbol_conf symbol_conf;