perf annotate: Fix perf data parsing
[safe/jmp/linux-2.6] / tools / perf / builtin-sched.c
index 807ca66..26b782f 100644 (file)
@@ -22,8 +22,6 @@
 
 static char                    const *input_name = "perf.data";
 
-static unsigned long           total_comm = 0;
-
 static struct perf_header      *header;
 static u64                     sample_type;
 
@@ -32,9 +30,6 @@ static char                   *sort_order = default_sort_order;
 
 static int                     profile_cpu = -1;
 
-static char                    *cwd;
-static int                     cwdlen;
-
 #define PR_SET_NAME            15               /* Set process name */
 #define MAX_CPUS               4096
 
@@ -225,7 +220,7 @@ static void calibrate_sleep_measurement_overhead(void)
 static struct sched_atom *
 get_new_event(struct task_desc *task, u64 timestamp)
 {
-       struct sched_atom *event = calloc(1, sizeof(*event));
+       struct sched_atom *event = zalloc(sizeof(*event));
        unsigned long idx = task->nr_events;
        size_t size;
 
@@ -293,7 +288,7 @@ add_sched_event_wakeup(struct task_desc *task, u64 timestamp,
                return;
        }
 
-       wakee_event->wait_sem = calloc(1, sizeof(*wakee_event->wait_sem));
+       wakee_event->wait_sem = zalloc(sizeof(*wakee_event->wait_sem));
        sem_init(wakee_event->wait_sem, 0, 0);
        wakee_event->specific_wait = 1;
        event->wait_sem = wakee_event->wait_sem;
@@ -323,7 +318,7 @@ static struct task_desc *register_pid(unsigned long pid, const char *comm)
        if (task)
                return task;
 
-       task = calloc(1, sizeof(*task));
+       task = zalloc(sizeof(*task));
        task->pid = pid;
        task->nr = nr_tasks;
        strcpy(task->comm, comm);
@@ -633,27 +628,6 @@ static void test_calibrations(void)
        printf("the sleep test took %Ld nsecs\n", T1-T0);
 }
 
-static int
-process_comm_event(event_t *event, unsigned long offset, unsigned long head)
-{
-       struct thread *thread = threads__findnew(event->comm.tid);
-
-       dump_printf("%p [%p]: perf_event_comm: %s:%d\n",
-               (void *)(offset + head),
-               (void *)(long)(event->header.size),
-               event->comm.comm, event->comm.pid);
-
-       if (thread == NULL ||
-           thread__set_comm(thread, event->comm.comm)) {
-               dump_printf("problem processing perf_event_comm, skipping event.\n");
-               return -1;
-       }
-       total_comm++;
-
-       return 0;
-}
-
-
 struct raw_event_sample {
        u32 size;
        char data[0];
@@ -962,9 +936,7 @@ __thread_latency_insert(struct rb_root *root, struct work_atoms *data,
 
 static void thread_atoms_insert(struct thread *thread)
 {
-       struct work_atoms *atoms;
-
-       atoms = calloc(sizeof(*atoms), 1);
+       struct work_atoms *atoms = zalloc(sizeof(*atoms));
        if (!atoms)
                die("No memory");
 
@@ -996,9 +968,7 @@ add_sched_out_event(struct work_atoms *atoms,
                    char run_state,
                    u64 timestamp)
 {
-       struct work_atom *atom;
-
-       atom = calloc(sizeof(*atom), 1);
+       struct work_atom *atom = zalloc(sizeof(*atom));
        if (!atom)
                die("Non memory");
 
@@ -1626,8 +1596,7 @@ process_raw_event(event_t *raw_event __used, void *more_data,
                process_sched_migrate_task_event(raw, event, cpu, timestamp, thread);
 }
 
-static int
-process_sample_event(event_t *event, unsigned long offset, unsigned long head)
+static int process_sample_event(event_t *event)
 {
        struct thread *thread;
        u64 ip = event->ip.ip;
@@ -1657,17 +1626,15 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
                more_data += sizeof(u64);
        }
 
-       dump_printf("%p [%p]: PERF_RECORD_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n",
-               (void *)(offset + head),
-               (void *)(long)(event->header.size),
+       dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
                event->header.misc,
                event->ip.pid, event->ip.tid,
                (void *)(long)ip,
                (long long)period);
 
        if (thread == NULL) {
-               eprintf("problem processing %d event, skipping it.\n",
-                       event->header.type);
+               pr_debug("problem processing %d event, skipping it.\n",
+                        event->header.type);
                return -1;
        }
 
@@ -1681,10 +1648,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
        return 0;
 }
 
-static int
-process_lost_event(event_t *event __used,
-                  unsigned long offset __used,
-                  unsigned long head __used)
+static int process_lost_event(event_t *event __used)
 {
        nr_lost_chunks++;
        nr_lost_events += event->lost.lost;
@@ -1708,7 +1672,7 @@ static int sample_type_check(u64 type)
 
 static struct perf_file_handler file_handler = {
        .process_sample_event   = process_sample_event,
-       .process_comm_event     = process_comm_event,
+       .process_comm_event     = event__process_comm,
        .process_lost_event     = process_lost_event,
        .sample_type_check      = sample_type_check,
 };
@@ -1718,7 +1682,8 @@ static int read_events(void)
        register_idle_thread();
        register_perf_file_handler(&file_handler);
 
-       return mmap_dispatch_perf_file(&header, input_name, 0, 0, &cwdlen, &cwd);
+       return mmap_dispatch_perf_file(&header, input_name, 0, 0,
+                                      &event__cwdlen, &event__cwd);
 }
 
 static void print_bad_events(void)
@@ -1937,7 +1902,7 @@ static int __cmd_record(int argc, const char **argv)
 
 int cmd_sched(int argc, const char **argv, const char *prefix __used)
 {
-       symbol__init();
+       symbol__init(0);
 
        argc = parse_options(argc, argv, sched_options, sched_usage,
                             PARSE_OPT_STOP_AT_NON_OPTION);