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

perf trace: Add alignment spaces after the closing parens

To use strace's style, helping in comparing the output of 'perf trace'
with the one from 'strace', to help in upcoming regression tests.

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-mw6peotz4n84rga0fk78buff@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+26 -11
+26 -11
tools/perf/builtin-trace.c
··· 1741 1741 return 0; 1742 1742 1743 1743 printed = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output); 1744 - printed += fprintf(trace->output, "%-*s) ...\n", trace->args_alignment, ttrace->entry_str); 1744 + printed += fprintf(trace->output, ")%-*s ...\n", trace->args_alignment, ttrace->entry_str); 1745 1745 ttrace->entry_pending = false; 1746 1746 1747 1747 ++trace->nr_events_printed; ··· 1798 1798 { 1799 1799 char *msg; 1800 1800 void *args; 1801 - size_t printed = 0; 1801 + int printed = 0; 1802 1802 struct thread *thread; 1803 1803 int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1; 1804 1804 int augmented_args_size = 0; ··· 1847 1847 1848 1848 if (sc->is_exit) { 1849 1849 if (!(trace->duration_filter || trace->summary_only || trace->failure_only || trace->min_stack)) { 1850 + int alignment = 0; 1851 + 1850 1852 trace__fprintf_entry_head(trace, thread, 0, false, ttrace->entry_time, trace->output); 1851 - fprintf(trace->output, "%-*s)\n", trace->args_alignment, ttrace->entry_str); 1853 + printed = fprintf(trace->output, "%s)", ttrace->entry_str); 1854 + if (trace->args_alignment > printed) 1855 + alignment = trace->args_alignment - printed; 1856 + fprintf(trace->output, "%*s= ?\n", alignment, " "); 1852 1857 } 1853 1858 } else { 1854 1859 ttrace->entry_pending = true; ··· 1948 1943 u64 duration = 0; 1949 1944 bool duration_calculated = false; 1950 1945 struct thread *thread; 1951 - int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0; 1946 + int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0, printed = 0; 1947 + int alignment = trace->args_alignment; 1952 1948 struct syscall *sc = trace__syscall_info(trace, evsel, id); 1953 1949 struct thread_trace *ttrace; 1954 1950 ··· 1997 1991 trace__fprintf_entry_head(trace, thread, duration, duration_calculated, ttrace->entry_time, trace->output); 1998 1992 1999 1993 if (ttrace->entry_pending) { 2000 - fprintf(trace->output, "%-*s", trace->args_alignment, ttrace->entry_str); 1994 + printed = fprintf(trace->output, "%s", ttrace->entry_str); 2001 1995 } else { 2002 1996 fprintf(trace->output, " ... ["); 2003 1997 color_fprintf(trace->output, PERF_COLOR_YELLOW, "continued"); 2004 1998 fprintf(trace->output, "]: %s()", sc->name); 2005 1999 } 2006 2000 2001 + printed++; /* the closing ')' */ 2002 + 2003 + if (alignment > printed) 2004 + alignment -= printed; 2005 + else 2006 + alignment = 0; 2007 + 2008 + fprintf(trace->output, ")%*s= ", alignment, " "); 2009 + 2007 2010 if (sc->fmt == NULL) { 2008 2011 if (ret < 0) 2009 2012 goto errno_print; 2010 2013 signed_print: 2011 - fprintf(trace->output, ") = %ld", ret); 2014 + fprintf(trace->output, "%ld", ret); 2012 2015 } else if (ret < 0) { 2013 2016 errno_print: { 2014 2017 char bf[STRERR_BUFSIZE]; 2015 2018 const char *emsg = str_error_r(-ret, bf, sizeof(bf)), 2016 2019 *e = errno_to_name(evsel, -ret); 2017 2020 2018 - fprintf(trace->output, ") = -1 %s %s", e, emsg); 2021 + fprintf(trace->output, "-1 %s %s", e, emsg); 2019 2022 } 2020 2023 } else if (ret == 0 && sc->fmt->timeout) 2021 - fprintf(trace->output, ") = 0 Timeout"); 2024 + fprintf(trace->output, "0 Timeout"); 2022 2025 else if (ttrace->ret_scnprintf) { 2023 2026 char bf[1024]; 2024 2027 struct syscall_arg arg = { ··· 2037 2022 }; 2038 2023 ttrace->ret_scnprintf(bf, sizeof(bf), &arg); 2039 2024 ttrace->ret_scnprintf = NULL; 2040 - fprintf(trace->output, ") = %s", bf); 2025 + fprintf(trace->output, "%s", bf); 2041 2026 } else if (sc->fmt->hexret) 2042 - fprintf(trace->output, ") = %#lx", ret); 2027 + fprintf(trace->output, "%#lx", ret); 2043 2028 else if (sc->fmt->errpid) { 2044 2029 struct thread *child = machine__find_thread(trace->host, ret, ret); 2045 2030 2046 2031 if (child != NULL) { 2047 - fprintf(trace->output, ") = %ld", ret); 2032 + fprintf(trace->output, "%ld", ret); 2048 2033 if (child->comm_set) 2049 2034 fprintf(trace->output, " (%s)", thread__comm_str(child)); 2050 2035 thread__put(child);