sample->type = type;
sample->next = c->samples;
sample->cpu = cpu;
- sample->backtrace = backtrace;
+ sample->backtrace = backtrace ? strdup(backtrace) : NULL;
c->samples = sample;
if (sample->type == TYPE_RUNNING && end > start && start > 0) {
we->time = timestamp;
we->waker = waker;
- we->backtrace = backtrace;
+ we->backtrace = backtrace ? strdup(backtrace) : NULL;
if ((flags & TRACE_FLAG_HARDIRQ) || (flags & TRACE_FLAG_SOFTIRQ))
we->waker = -1;
}
}
-static const char *cat_backtrace(union perf_event *event,
- struct perf_sample *sample,
- struct machine *machine)
+static char *cat_backtrace(union perf_event *event,
+ struct perf_sample *sample,
+ struct machine *machine)
{
struct addr_location al;
unsigned int i;
{
struct timechart *tchart = container_of(tool, struct timechart, tool);
struct evsel *evsel = sample->evsel;
+ int ret = 0;
if (evsel->core.attr.sample_type & PERF_SAMPLE_TIME) {
if (!tchart->first_time || tchart->first_time > sample->time)
if (evsel->handler != NULL) {
tracepoint_handler f = evsel->handler;
+ char *backtrace = cat_backtrace(event, sample, machine);
- return f(tchart, sample, cat_backtrace(event, sample, machine));
+ ret = f(tchart, sample, backtrace);
+ free(backtrace);
}
- return 0;
+ return ret;
}
static int