diff mbox series

[V9,1/2] Add map_pgoff to python dictionary

Message ID c0ca69f04ba93f1d05d753a3adc28ad9a09d34fe.1728599785.git.scclevenger@os.amperecomputing.com (mailing list archive)
State New, archived
Headers show
Series arm-cs-trace-disasm.py/perf must accommodate non-zero DSO text offset | expand

Commit Message

Steve Clevenger Oct. 11, 2024, 5:17 p.m. UTC
Add map_pgoff parameter to python dictionary so it can be seen by the
python script.

Signed-off-by: Steve Clevenger <scclevenger@os.amperecomputing.com>
---
 tools/perf/util/scripting-engines/trace-event-python.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Leo Yan Oct. 17, 2024, 10:43 a.m. UTC | #1
On 10/11/24 18:17, Steve Clevenger wrote:> 
> Add map_pgoff parameter to python dictionary so it can be seen by the
> python script.
> 
> Signed-off-by: Steve Clevenger <scclevenger@os.amperecomputing.com>

Sorry for late replying. LGTM:

Reviewed-by: Leo Yan <leo.yan@arm.com>

> ---
>   tools/perf/util/scripting-engines/trace-event-python.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index d7183134b669..367132b3a51a 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -793,7 +793,8 @@ static int set_regs_in_dict(PyObject *dict,
>   static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
>                              const char *dso_field, const char *dso_bid_field,
>                              const char *dso_map_start, const char *dso_map_end,
> -                           const char *sym_field, const char *symoff_field)
> +                           const char *sym_field, const char *symoff_field,
> +                           const char *map_pgoff)
>   {
>          char sbuild_id[SBUILD_ID_SIZE];
> 
> @@ -809,6 +810,8 @@ static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
>                          PyLong_FromUnsignedLong(map__start(al->map)));
>                  pydict_set_item_string_decref(dict, dso_map_end,
>                          PyLong_FromUnsignedLong(map__end(al->map)));
> +               pydict_set_item_string_decref(dict, map_pgoff,
> +                       PyLong_FromUnsignedLongLong(al->map->pgoff));
>          }
>          if (al->sym) {
>                  pydict_set_item_string_decref(dict, sym_field,
> @@ -895,7 +898,7 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
>          pydict_set_item_string_decref(dict, "comm",
>                          _PyUnicode_FromString(thread__comm_str(al->thread)));
>          set_sym_in_dict(dict, al, "dso", "dso_bid", "dso_map_start", "dso_map_end",
> -                       "symbol", "symoff");
> +                       "symbol", "symoff", "map_pgoff");
> 
>          pydict_set_item_string_decref(dict, "callchain", callchain);
> 
> @@ -920,7 +923,7 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
>                          PyBool_FromLong(1));
>                  set_sym_in_dict(dict_sample, addr_al, "addr_dso", "addr_dso_bid",
>                                  "addr_dso_map_start", "addr_dso_map_end",
> -                               "addr_symbol", "addr_symoff");
> +                               "addr_symbol", "addr_symoff", "addr_map_pgoff");
>          }
> 
>          if (sample->flags)
> --
> 2.44.0
>
Leo Yan Oct. 17, 2024, 11:03 a.m. UTC | #2
On 10/17/24 11:43, Leo Yan wrote:
> Warning: EXTERNAL SENDER, use caution when opening links or attachments.
> 
> 
> On 10/11/24 18:17, Steve Clevenger wrote:>
>> Add map_pgoff parameter to python dictionary so it can be seen by the
>> python script.
>>
>> Signed-off-by: Steve Clevenger <scclevenger@os.amperecomputing.com>
> 
> Sorry for late replying. LGTM:

For this patch, please consider to add prefix in subject:

   perf script python: Add map_pgoff to python dictionary

With this, please feel free to add my reviewed tag.
  
> Reviewed-by: Leo Yan <leo.yan@arm.com>
diff mbox series

Patch

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index d7183134b669..367132b3a51a 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -793,7 +793,8 @@  static int set_regs_in_dict(PyObject *dict,
 static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
 			    const char *dso_field, const char *dso_bid_field,
 			    const char *dso_map_start, const char *dso_map_end,
-			    const char *sym_field, const char *symoff_field)
+			    const char *sym_field, const char *symoff_field,
+			    const char *map_pgoff)
 {
 	char sbuild_id[SBUILD_ID_SIZE];
 
@@ -809,6 +810,8 @@  static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
 			PyLong_FromUnsignedLong(map__start(al->map)));
 		pydict_set_item_string_decref(dict, dso_map_end,
 			PyLong_FromUnsignedLong(map__end(al->map)));
+		pydict_set_item_string_decref(dict, map_pgoff,
+			PyLong_FromUnsignedLongLong(al->map->pgoff));
 	}
 	if (al->sym) {
 		pydict_set_item_string_decref(dict, sym_field,
@@ -895,7 +898,7 @@  static PyObject *get_perf_sample_dict(struct perf_sample *sample,
 	pydict_set_item_string_decref(dict, "comm",
 			_PyUnicode_FromString(thread__comm_str(al->thread)));
 	set_sym_in_dict(dict, al, "dso", "dso_bid", "dso_map_start", "dso_map_end",
-			"symbol", "symoff");
+			"symbol", "symoff", "map_pgoff");
 
 	pydict_set_item_string_decref(dict, "callchain", callchain);
 
@@ -920,7 +923,7 @@  static PyObject *get_perf_sample_dict(struct perf_sample *sample,
 			PyBool_FromLong(1));
 		set_sym_in_dict(dict_sample, addr_al, "addr_dso", "addr_dso_bid",
 				"addr_dso_map_start", "addr_dso_map_end",
-				"addr_symbol", "addr_symoff");
+				"addr_symbol", "addr_symoff", "addr_map_pgoff");
 	}
 
 	if (sample->flags)