Re: [BUG] libtraceevent: perf script -g python segfaults
From: Steven Rostedt
Date: Thu Oct 17 2019 - 14:38:46 EST
On Thu, 17 Oct 2019 12:42:05 -0300
Arnaldo Carvalho de Melo <arnaldo.melo@xxxxxxxxx> wrote:
> I'll try and continue later, but if you guys can take a look...
Does this fix it for you?
-- Steve
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index ad74be1f0e42..227629796e32 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -193,30 +193,32 @@ int parse_event_file(struct tep_handle *pevent,
struct tep_event *trace_find_next_event(struct tep_handle *pevent,
struct tep_event *event)
{
+ static struct tep_event **all_events;
static int idx;
int events_count;
- struct tep_event *all_events;
- all_events = tep_get_first_event(pevent);
events_count = tep_get_events_count(pevent);
if (!pevent || !all_events || events_count < 1)
return NULL;
if (!event) {
idx = 0;
- return all_events;
+ all_events = tep_list_events(pevent, TEP_EVENT_SORT_ID);
+ if (all_events)
+ return all_events[0];
+ return NULL;
}
- if (idx < events_count && event == (all_events + idx)) {
+ if (idx < events_count && event == all_events[idx]) {
idx++;
if (idx == events_count)
return NULL;
- return (all_events + idx);
+ return all_events[idx];
}
for (idx = 1; idx < events_count; idx++) {
- if (event == (all_events + (idx - 1)))
- return (all_events + idx);
+ if (event == all_events[idx - 1])
+ return all_events[idx];
}
return NULL;
}