lkml.org 
[lkml]   [2013]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC/PATCH 2/3] perf script: Print comm, fork and exit events also
On 11/17/13, 8:00 PM, Namhyung Kim wrote:
> @@ -578,6 +579,106 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
> return perf_evsel__check_attr(evsel, scr->session);
> }
>
> +static int process_comm_event(struct perf_tool *tool,
> + union perf_event *event,
> + struct perf_sample *sample,
> + struct machine *machine)
> +{
> + struct thread *thread;
> + struct perf_script *script = container_of(tool, struct perf_script, tool);
> + struct perf_session *session = script->session;
> + struct perf_evsel *evsel = perf_evlist__first(session->evlist);
> + char *oldname;
> +
> + thread = machine__findnew_thread(machine, event->comm.pid, event->comm.tid);
> + if (thread == NULL) {
> + pr_debug("problem processing COMM event, skipping it.\n");
> + return -1;
> + }
> +
> + oldname = strdup(thread__comm_str(thread));
> + if (oldname == NULL) {
> + pr_debug("problem processing COMM event, skipping it.\n");
> + return -1;
> + }
> +
> + if (perf_event__process_comm(tool, event, sample, machine) < 0)
> + return -1;
> +
> + if (!evsel->attr.sample_id_all) {
> + sample->cpu = 0;
> + sample->time = 0;
> + sample->tid = event->comm.tid;
> + sample->pid = event->comm.pid;
> + }
> + print_sample_start(sample, thread, evsel);
> + printf("comm: %s --> %s\n", oldname, event->comm.comm);

free(oldname)

David


\
 
 \ /
  Last update: 2013-11-18 06:01    [W:0.321 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site