perf intel-pt: Support itrace d+o option to direct debug log to stdout
authorAdrian Hunter <adrian.hunter@intel.com>
Wed, 27 Oct 2021 08:03:34 +0000 (11:03 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 27 Oct 2021 19:21:01 +0000 (16:21 -0300)
It can be useful to see debug output in between normal output.

Add support for AUXTRACE_LOG_FLG_USE_STDOUT to Intel PT.

Reviewed-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20211027080334.365596-7-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-intel-pt.txt
tools/perf/util/intel-pt-decoder/intel-pt-log.c
tools/perf/util/intel-pt.c

index c792fa7b59d31ec6984eb2b0719de51b13f330d3..cbb920f5d056c62e033c0b0ea9fee998228736b7 100644 (file)
@@ -953,6 +953,7 @@ by flags which affect what debug messages will or will not be logged. Each flag
 must be preceded by either '+' or '-'. The flags support by Intel PT are:
                -a      Suppress logging of perf events
                +a      Log all perf events
+               +o      Output to stdout instead of "intel_pt.log"
 By default, logged perf events are filtered by any specified time ranges, but
 flag +a overrides that.
 
index 09feb5b07d324f01873c4432ff1017ace1176fbc..5f5dfc8753f3361686118df9b8793ece34dcf3e2 100644 (file)
@@ -82,10 +82,10 @@ static int intel_pt_log_open(void)
        if (f)
                return 0;
 
-       if (!log_name[0])
-               return -1;
-
-       f = fopen(log_name, "w+");
+       if (log_name[0])
+               f = fopen(log_name, "w+");
+       else
+               f = stdout;
        if (!f) {
                intel_pt_enable_logging = false;
                return -1;
index 0ee5005e9837ce805c6936ab5f618c27a15e378c..556a893508daeb9aca14806ba9779de982208771 100644 (file)
@@ -3736,8 +3736,6 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
        if (err)
                goto err_free;
 
-       intel_pt_log_set_name(INTEL_PT_PMU_NAME);
-
        if (session->itrace_synth_opts->set) {
                pt->synth_opts = *session->itrace_synth_opts;
        } else {
@@ -3752,6 +3750,9 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
                pt->synth_opts.thread_stack = opts->thread_stack;
        }
 
+       if (!(pt->synth_opts.log_plus_flags & AUXTRACE_LOG_FLG_USE_STDOUT))
+               intel_pt_log_set_name(INTEL_PT_PMU_NAME);
+
        pt->session = session;
        pt->machine = &session->machines.host; /* No kvm support */
        pt->auxtrace_type = auxtrace_info->type;