summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/scripting-engines/trace-event-python.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:17:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:17:46 +0000
commit7f3a4257159dea8e7ef66d1a539dc6df708b8ed3 (patch)
treebcc69b5f4609f348fac49e2f59e210b29eaea783 /tools/perf/util/scripting-engines/trace-event-python.c
parentAdding upstream version 6.9.12. (diff)
downloadlinux-7f3a4257159dea8e7ef66d1a539dc6df708b8ed3.tar.xz
linux-7f3a4257159dea8e7ef66d1a539dc6df708b8ed3.zip
Adding upstream version 6.10.3.upstream/6.10.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index b4f0f60e60..fb00f3ad68 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -45,6 +45,7 @@
#include "../thread.h"
#include "../comm.h"
#include "../machine.h"
+#include "../mem-info.h"
#include "../db-export.h"
#include "../thread-stack.h"
#include "../trace-event.h"
@@ -393,10 +394,10 @@ static const char *get_dsoname(struct map *map)
struct dso *dso = map ? map__dso(map) : NULL;
if (dso) {
- if (symbol_conf.show_kernel_path && dso->long_name)
- dsoname = dso->long_name;
+ if (symbol_conf.show_kernel_path && dso__long_name(dso))
+ dsoname = dso__long_name(dso);
else
- dsoname = dso->name;
+ dsoname = dso__name(dso);
}
return dsoname;
@@ -720,15 +721,20 @@ static void set_sample_read_in_dict(PyObject *dict_sample,
}
static void set_sample_datasrc_in_dict(PyObject *dict,
- struct perf_sample *sample)
+ struct perf_sample *sample)
{
- struct mem_info mi = { .data_src.val = sample->data_src };
+ struct mem_info *mi = mem_info__new();
char decode[100];
+ if (!mi)
+ Py_FatalError("couldn't create mem-info");
+
pydict_set_item_string_decref(dict, "datasrc",
PyLong_FromUnsignedLongLong(sample->data_src));
- perf_script__meminfo_scnprintf(decode, 100, &mi);
+ mem_info__data_src(mi)->val = sample->data_src;
+ perf_script__meminfo_scnprintf(decode, 100, mi);
+ mem_info__put(mi);
pydict_set_item_string_decref(dict, "datasrc_decode",
_PyUnicode_FromString(decode));
@@ -799,8 +805,9 @@ static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
if (al->map) {
struct dso *dso = map__dso(al->map);
- pydict_set_item_string_decref(dict, dso_field, _PyUnicode_FromString(dso->name));
- build_id__sprintf(&dso->bid, sbuild_id);
+ pydict_set_item_string_decref(dict, dso_field,
+ _PyUnicode_FromString(dso__name(dso)));
+ build_id__sprintf(dso__bid(dso), sbuild_id);
pydict_set_item_string_decref(dict, dso_bid_field,
_PyUnicode_FromString(sbuild_id));
pydict_set_item_string_decref(dict, dso_map_start,
@@ -1246,14 +1253,14 @@ static int python_export_dso(struct db_export *dbe, struct dso *dso,
char sbuild_id[SBUILD_ID_SIZE];
PyObject *t;
- build_id__sprintf(&dso->bid, sbuild_id);
+ build_id__sprintf(dso__bid(dso), sbuild_id);
t = tuple_new(5);
- tuple_set_d64(t, 0, dso->db_id);
+ tuple_set_d64(t, 0, dso__db_id(dso));
tuple_set_d64(t, 1, machine->db_id);
- tuple_set_string(t, 2, dso->short_name);
- tuple_set_string(t, 3, dso->long_name);
+ tuple_set_string(t, 2, dso__short_name(dso));
+ tuple_set_string(t, 3, dso__long_name(dso));
tuple_set_string(t, 4, sbuild_id);
call_object(tables->dso_handler, t, "dso_table");
@@ -1273,7 +1280,7 @@ static int python_export_symbol(struct db_export *dbe, struct symbol *sym,
t = tuple_new(6);
tuple_set_d64(t, 0, *sym_db_id);
- tuple_set_d64(t, 1, dso->db_id);
+ tuple_set_d64(t, 1, dso__db_id(dso));
tuple_set_d64(t, 2, sym->start);
tuple_set_d64(t, 3, sym->end);
tuple_set_s32(t, 4, sym->binding);
@@ -1699,13 +1706,15 @@ static void python_process_stat(struct perf_stat_config *config,
{
struct perf_thread_map *threads = counter->core.threads;
struct perf_cpu_map *cpus = counter->core.cpus;
- int cpu, thread;
- for (thread = 0; thread < perf_thread_map__nr(threads); thread++) {
- for (cpu = 0; cpu < perf_cpu_map__nr(cpus); cpu++) {
- process_stat(counter, perf_cpu_map__cpu(cpus, cpu),
+ for (int thread = 0; thread < perf_thread_map__nr(threads); thread++) {
+ int idx;
+ struct perf_cpu cpu;
+
+ perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
+ process_stat(counter, cpu,
perf_thread_map__pid(threads, thread), tstamp,
- perf_counts(counter->counts, cpu, thread));
+ perf_counts(counter->counts, idx, thread));
}
}
}