Re: [PATCH 2/7] perf script: Add an option to print the source linenumber

From: David Ahern
Date: Tue Dec 03 2013 - 11:10:51 EST


On 12/3/13, 12:23 AM, Adrian Hunter wrote:
@@ -348,6 +355,24 @@ static void print_sample_start(struct perf_sample *sample,
}
}

+static void print_sample_finish(struct perf_evsel *evsel,
+ struct addr_location *al)
+{
+ struct perf_event_attr *attr = &evsel->attr;
+
+ if (PRINT_FIELD(SRCLINE) && al->map && al->map->dso) {
+ char *srcline;
+
+ srcline = get_srcline(al->map->dso,
+ map__rip_2objdump(al->map, al->addr));
+ if (srcline != SRCLINE_UNKNOWN)
+ printf("\n %s", srcline);
+ free_srcline(srcline);
+ }
+
+ printf("\n");
+}
+
static bool is_bts_event(struct perf_event_attr *attr)
{
return ((attr->type == PERF_TYPE_HARDWARE) &&
@@ -438,7 +463,7 @@ static void print_sample_bts(union perf_event *event,
!output[attr->type].user_set))
print_sample_addr(event, sample, machine, thread, attr);

- printf("\n");
+ print_sample_finish(evsel, al);
}

static void process_event(union perf_event *event, struct perf_sample *sample,
@@ -480,7 +505,7 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
PERF_MAX_STACK_DEPTH);
}

- printf("\n");
+ print_sample_finish(evsel, al);
}

static int default_start_script(const char *script __maybe_unused,

What about callchains?

David

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