Sometimes it needs to retrieve symbol info inside a script engine so
we need to pass the session pointer to find the symbol correctly as
with previous patch.

Signed-off-by: Namhyung Kim <namhy...@kernel.org>
---
 tools/perf/builtin-script.c                        | 23 ++++++++++++----------
 tools/perf/util/db-export.c                        |  6 ++++--
 tools/perf/util/db-export.h                        |  4 +++-
 tools/perf/util/event.c                            |  3 ++-
 tools/perf/util/event.h                            |  3 ++-
 .../perf/util/scripting-engines/trace-event-perl.c |  3 ++-
 .../util/scripting-engines/trace-event-python.c    |  5 +++--
 tools/perf/util/trace-event-scripting.c            |  3 ++-
 tools/perf/util/trace-event.h                      |  3 ++-
 9 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index ab920f8cded6..4a007110d2f7 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -377,9 +377,10 @@ static void print_sample_start(struct perf_sample *sample,
 }
 
 static void print_sample_addr(union perf_event *event,
-                         struct perf_sample *sample,
-                         struct thread *thread,
-                         struct perf_event_attr *attr)
+                             struct perf_sample *sample,
+                             struct thread *thread,
+                             struct perf_event_attr *attr,
+                             struct perf_session *session)
 {
        struct addr_location al;
 
@@ -388,7 +389,7 @@ static void print_sample_addr(union perf_event *event,
        if (!sample_addr_correlates_sym(attr))
                return;
 
-       perf_event__preprocess_sample_addr(event, sample, thread, &al);
+       perf_event__preprocess_sample_addr(event, sample, thread, &al, session);
 
        if (PRINT_FIELD(SYM)) {
                printf(" ");
@@ -409,7 +410,8 @@ static void print_sample_bts(union perf_event *event,
                             struct perf_sample *sample,
                             struct perf_evsel *evsel,
                             struct thread *thread,
-                            struct addr_location *al)
+                            struct addr_location *al,
+                            struct perf_session *session)
 {
        struct perf_event_attr *attr = &evsel->attr;
        bool print_srcline_last = false;
@@ -436,7 +438,7 @@ static void print_sample_bts(union perf_event *event,
            ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
             !output[attr->type].user_set)) {
                printf(" => ");
-               print_sample_addr(event, sample, thread, attr);
+               print_sample_addr(event, sample, thread, attr, session);
        }
 
        if (print_srcline_last)
@@ -447,7 +449,7 @@ static void print_sample_bts(union perf_event *event,
 
 static void process_event(union perf_event *event, struct perf_sample *sample,
                          struct perf_evsel *evsel, struct thread *thread,
-                         struct addr_location *al)
+                         struct addr_location *al, struct perf_session 
*session)
 {
        struct perf_event_attr *attr = &evsel->attr;
 
@@ -465,7 +467,7 @@ static void process_event(union perf_event *event, struct 
perf_sample *sample,
        }
 
        if (is_bts_event(attr)) {
-               print_sample_bts(event, sample, evsel, thread, al);
+               print_sample_bts(event, sample, evsel, thread, al, session);
                return;
        }
 
@@ -473,7 +475,7 @@ static void process_event(union perf_event *event, struct 
perf_sample *sample,
                event_format__print(evsel->tp_format, sample->cpu,
                                    sample->raw_data, sample->raw_size);
        if (PRINT_FIELD(ADDR))
-               print_sample_addr(event, sample, thread, attr);
+               print_sample_addr(event, sample, thread, attr, session);
 
        if (PRINT_FIELD(IP)) {
                if (!symbol_conf.use_callchain)
@@ -590,7 +592,8 @@ static int process_sample_event(struct perf_tool *tool,
        if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
                return 0;
 
-       scripting_ops->process_event(event, sample, evsel, thread, &al);
+       scripting_ops->process_event(event, sample, evsel, thread, &al,
+                                    script->session);
 
        return 0;
 }
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index c81dae399763..e9ad11fe2e16 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -282,7 +282,8 @@ int db_export__branch_type(struct db_export *dbe, u32 
branch_type,
 
 int db_export__sample(struct db_export *dbe, union perf_event *event,
                      struct perf_sample *sample, struct perf_evsel *evsel,
-                     struct thread *thread, struct addr_location *al)
+                     struct thread *thread, struct addr_location *al,
+                     struct perf_session *session)
 {
        struct export_sample es = {
                .event = event,
@@ -328,7 +329,8 @@ int db_export__sample(struct db_export *dbe, union 
perf_event *event,
            sample_addr_correlates_sym(&evsel->attr)) {
                struct addr_location addr_al;
 
-               perf_event__preprocess_sample_addr(event, sample, thread, 
&addr_al);
+               perf_event__preprocess_sample_addr(event, sample, thread,
+                                                  &addr_al, session);
                err = db_ids_from_al(dbe, &addr_al, &es.addr_dso_db_id,
                                     &es.addr_sym_db_id, &es.addr_offset);
                if (err)
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index adbd22d66798..b994f1041d19 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -29,6 +29,7 @@ struct addr_location;
 struct call_return_processor;
 struct call_path;
 struct call_return;
+struct perf_session;
 
 struct export_sample {
        union perf_event        *event;
@@ -97,7 +98,8 @@ int db_export__branch_type(struct db_export *dbe, u32 
branch_type,
                           const char *name);
 int db_export__sample(struct db_export *dbe, union perf_event *event,
                      struct perf_sample *sample, struct perf_evsel *evsel,
-                     struct thread *thread, struct addr_location *al);
+                     struct thread *thread, struct addr_location *al,
+                     struct perf_session *session);
 
 int db_export__branch_types(struct db_export *dbe);
 
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 704ef27cc7c8..510a308c2158 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -918,7 +918,8 @@ bool sample_addr_correlates_sym(struct perf_event_attr 
*attr)
 void perf_event__preprocess_sample_addr(union perf_event *event,
                                        struct perf_sample *sample,
                                        struct thread *thread,
-                                       struct addr_location *al)
+                                       struct addr_location *al,
+                                       struct perf_session *session 
__maybe_unused)
 {
        u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 19814f70292b..27261320249a 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -368,7 +368,8 @@ bool sample_addr_correlates_sym(struct perf_event_attr 
*attr);
 void perf_event__preprocess_sample_addr(union perf_event *event,
                                        struct perf_sample *sample,
                                        struct thread *thread,
-                                       struct addr_location *al);
+                                       struct addr_location *al,
+                                       struct perf_session *session);
 
 const char *perf_event__name(unsigned int id);
 
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c 
b/tools/perf/util/scripting-engines/trace-event-perl.c
index 22ebc46226e7..dd69fbaf03b8 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -356,7 +356,8 @@ static void perl_process_event(union perf_event *event,
                               struct perf_sample *sample,
                               struct perf_evsel *evsel,
                               struct thread *thread,
-                              struct addr_location *al __maybe_unused)
+                              struct addr_location *al __maybe_unused,
+                              struct perf_session *session __maybe_unused)
 {
        perl_process_tracepoint(sample, evsel, thread);
        perl_process_event_generic(event, sample, evsel);
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c 
b/tools/perf/util/scripting-engines/trace-event-python.c
index 0c815a40a6e8..802def46af7b 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -839,7 +839,8 @@ static void python_process_event(union perf_event *event,
                                 struct perf_sample *sample,
                                 struct perf_evsel *evsel,
                                 struct thread *thread,
-                                struct addr_location *al)
+                                struct addr_location *al,
+                                struct perf_session *session)
 {
        struct tables *tables = &tables_global;
 
@@ -851,7 +852,7 @@ static void python_process_event(union perf_event *event,
        default:
                if (tables->db_export_mode)
                        db_export__sample(&tables->dbe, event, sample, evsel,
-                                         thread, al);
+                                         thread, al, session);
                else
                        python_process_general_event(sample, evsel, thread, al);
        }
diff --git a/tools/perf/util/trace-event-scripting.c 
b/tools/perf/util/trace-event-scripting.c
index 5c9bdd1591a9..36ed50d71171 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -44,7 +44,8 @@ static void process_event_unsupported(union perf_event *event 
__maybe_unused,
                                      struct perf_sample *sample __maybe_unused,
                                      struct perf_evsel *evsel __maybe_unused,
                                      struct thread *thread __maybe_unused,
-                                     struct addr_location *al __maybe_unused)
+                                     struct addr_location *al __maybe_unused,
+                                     struct perf_session *session 
__maybe_unused)
 {
 }
 
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 356629a30ca9..40e19c2af606 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -73,7 +73,8 @@ struct scripting_ops {
                               struct perf_sample *sample,
                               struct perf_evsel *evsel,
                               struct thread *thread,
-                                  struct addr_location *al);
+                              struct addr_location *al,
+                              struct perf_session *session);
        int (*generate_script) (struct pevent *pevent, const char *outfile);
 };
 
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to