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

perf scripting: Add perf_session to scripting_context

This is preparation for allowing a script to set the itrace options
for the session if they have not already been set.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20210530192308.7382-5-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
67e50ce0 cac30400

+15 -6
+1 -1
tools/perf/builtin-script.c
··· 4017 4017 } 4018 4018 4019 4019 if (script_name) { 4020 - err = scripting_ops->start_script(script_name, argc, argv); 4020 + err = scripting_ops->start_script(script_name, argc, argv, session); 4021 4021 if (err) 4022 4022 goto out_delete; 4023 4023 pr_debug("perf script started with script %s\n\n", script_name);
+4 -1
tools/perf/util/scripting-engines/trace-event-perl.c
··· 473 473 /* 474 474 * Start trace script 475 475 */ 476 - static int perl_start_script(const char *script, int argc, const char **argv) 476 + static int perl_start_script(const char *script, int argc, const char **argv, 477 + struct perf_session *session) 477 478 { 478 479 const char **command_line; 479 480 int i, err = 0; 481 + 482 + scripting_context->session = session; 480 483 481 484 command_line = malloc((argc + 2) * sizeof(const char *)); 482 485 command_line[0] = "";
+3 -1
tools/perf/util/scripting-engines/trace-event-python.c
··· 1746 1746 /* 1747 1747 * Start trace script 1748 1748 */ 1749 - static int python_start_script(const char *script, int argc, const char **argv) 1749 + static int python_start_script(const char *script, int argc, const char **argv, 1750 + struct perf_session *session) 1750 1751 { 1751 1752 struct tables *tables = &tables_global; 1752 1753 #if PY_MAJOR_VERSION < 3 ··· 1763 1762 int i, err = 0; 1764 1763 FILE *fp; 1765 1764 1765 + scripting_context->session = session; 1766 1766 #if PY_MAJOR_VERSION < 3 1767 1767 command_line = malloc((argc + 1) * sizeof(const char *)); 1768 1768 command_line[0] = script;
+4 -2
tools/perf/util/trace-event-scripting.c
··· 66 66 67 67 static int python_start_script_unsupported(const char *script __maybe_unused, 68 68 int argc __maybe_unused, 69 - const char **argv __maybe_unused) 69 + const char **argv __maybe_unused, 70 + struct perf_session *session __maybe_unused) 70 71 { 71 72 print_python_unsupported_msg(); 72 73 ··· 132 131 133 132 static int perl_start_script_unsupported(const char *script __maybe_unused, 134 133 int argc __maybe_unused, 135 - const char **argv __maybe_unused) 134 + const char **argv __maybe_unused, 135 + struct perf_session *session __maybe_unused) 136 136 { 137 137 print_perl_unsupported_msg(); 138 138
+3 -1
tools/perf/util/trace-event.h
··· 73 73 struct scripting_ops { 74 74 const char *name; 75 75 const char *dirname; /* For script path .../scripts/<dirname>/... */ 76 - int (*start_script) (const char *script, int argc, const char **argv); 76 + int (*start_script)(const char *script, int argc, const char **argv, 77 + struct perf_session *session); 77 78 int (*flush_script) (void); 78 79 int (*stop_script) (void); 79 80 void (*process_event) (union perf_event *event, ··· 108 107 struct evsel *evsel; 109 108 struct addr_location *al; 110 109 struct addr_location *addr_al; 110 + struct perf_session *session; 111 111 }; 112 112 113 113 void scripting_context__update(struct scripting_context *scripting_context,