Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf trace: Fix ')' placement in "interrupted" syscall lines

When we get the sys_enter for a syscall we check if the last one is
still waiting for its matching sys_exit, if so we print this:

468.753 ( ): firefox/32382 poll(ufds: 0x7f3988d3dd00, nfds: 7, timeout_msecs: 4294967295) ...
449.575 ( 0.004 ms): Softwar~cThrea/32434 futex(uaddr: 0x7f39a18a9b70, op: WAKE|PRIVATE_FLAG, val: 1) = 0

At some point we'll get that poll sys_exit event and will print a "[continued]" line.

While making the sizing of the alignment after the syscall arg list and
its result configurable, so that we can mimic strace, which uses a
smaller alingment by default, a bug was introduced where the closing
parens appeared before the syscall name and its arg list, fix it.

Fixes: 4b8a240ed5e0 ("perf trace: Add alignment spaces after the closing parens")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-oi45i54s59h1w1kmgpzrfuum@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+8 -2
+8 -2
tools/perf/builtin-trace.c
··· 1758 1758 { 1759 1759 struct thread_trace *ttrace; 1760 1760 size_t printed; 1761 + int len; 1761 1762 1762 1763 if (trace->failure_only || trace->current == NULL) 1763 1764 return 0; ··· 1769 1768 return 0; 1770 1769 1771 1770 printed = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output); 1772 - printed += fprintf(trace->output, ")%-*s ...\n", trace->args_alignment, ttrace->entry_str); 1773 - ttrace->entry_pending = false; 1771 + printed += len = fprintf(trace->output, "%s)", ttrace->entry_str); 1774 1772 1773 + if (len < trace->args_alignment - 4) 1774 + printed += fprintf(trace->output, "%-*s", trace->args_alignment - 4 - len, " "); 1775 + 1776 + printed += fprintf(trace->output, " ...\n"); 1777 + 1778 + ttrace->entry_pending = false; 1775 1779 ++trace->nr_events_printed; 1776 1780 1777 1781 return printed;