Re: [PATCH 09/10] perf script: Add support for dumping symbols

From: David Ahern
Date: Wed Mar 09 2011 - 19:21:27 EST




On 03/09/11 16:30, Frederic Weisbecker wrote:
> On Wed, Mar 09, 2011 at 03:31:30PM -0300, Arnaldo Carvalho de Melo wrote:
>> @@ -868,6 +892,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
>> exit(-1);
>> }
>>
>> + symbol_conf.use_callchain = no_callchain ? false : true;
>> +
>
> That also depend on (sample_type & PERF_SAMPLE_CALLCHAIN)...
>
>> if (rec_script_path)
>> script_path = rec_script_path;
>> if (rep_script_path)
>> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
>> index f642615..51fac44 100644
>> --- a/tools/perf/util/session.c
>> +++ b/tools/perf/util/session.c
>> @@ -1145,3 +1145,64 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
>>
>> return ret;
>> }
>> +
>> +void perf_session__print_symbols(union perf_event *event,
>> + struct perf_sample *sample,
>> + struct perf_session *session)
>> +{
>> + struct addr_location al;
>> + const char *symname, *dsoname;
>> + struct callchain_cursor *cursor = &session->callchain_cursor;
>> + struct callchain_cursor_node *node;
>> +
>> + if (perf_event__preprocess_sample(event, session, &al, sample,
>> + NULL) < 0) {
>> + error("problem processing %d event, skipping it.\n",
>> + event->header.type);
>> + return;
>> + }
>> +
>> + if (symbol_conf.use_callchain && sample->callchain) {
>
> ...otherwise you may deref some crap there. sample->callchain is
> random when there is actually no callchain.

Doh. I'll add a check to perf_session__check_attr for
PERF_SAMPLE_CALLCHAIN and reset use_callchain if necessary.

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/