]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - tools/perf/builtin-trace.c
perf trace: Fixup thread refcounting
[karo-tx-linux.git] / tools / perf / builtin-trace.c
index 40ef9b293d1b4ffa0213108ca3ec391621c1267d..60053d49539bd98767f787796eba807eeba89576 100644 (file)
@@ -1399,7 +1399,7 @@ static struct syscall *trace__syscall_info(struct trace *trace,
        return &trace->syscalls.table[id];
 
 out_cant_read:
-       if (verbose) {
+       if (verbose > 0) {
                fprintf(trace->output, "Problems reading syscall %d", id);
                if (id <= trace->syscalls.max && trace->syscalls.table[id].name != NULL)
                        fprintf(trace->output, "(%s)", trace->syscalls.table[id].name);
@@ -1653,15 +1653,17 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel,
 
        ttrace = thread__priv(thread);
        if (!ttrace)
-               goto out;
+               goto out_put;
 
        filename_len = strlen(filename);
+       if (filename_len == 0)
+               goto out_put;
 
        if (ttrace->filename.namelen < filename_len) {
                char *f = realloc(ttrace->filename.name, filename_len + 1);
 
                if (f == NULL)
-                               goto out;
+                       goto out_put;
 
                ttrace->filename.namelen = filename_len;
                ttrace->filename.name = f;
@@ -1671,12 +1673,12 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel,
        ttrace->filename.pending_open = true;
 
        if (!ttrace->filename.ptr)
-               goto out;
+               goto out_put;
 
        entry_str_len = strlen(ttrace->entry_str);
        remaining_space = trace__entry_str_size - entry_str_len - 1; /* \0 */
        if (remaining_space <= 0)
-               goto out;
+               goto out_put;
 
        if (filename_len > (size_t)remaining_space) {
                filename += filename_len - remaining_space;
@@ -1690,6 +1692,8 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel,
 
        ttrace->filename.ptr = 0;
        ttrace->filename.entry_str_pos = 0;
+out_put:
+       thread__put(thread);
 out:
        return 0;
 }
@@ -1710,6 +1714,7 @@ static int trace__sched_stat_runtime(struct trace *trace, struct perf_evsel *evs
 
        ttrace->runtime_ms += runtime_ms;
        trace->runtime_ms += runtime_ms;
+out_put:
        thread__put(thread);
        return 0;
 
@@ -1720,8 +1725,7 @@ out_dump:
               (pid_t)perf_evsel__intval(evsel, sample, "pid"),
               runtime,
               perf_evsel__intval(evsel, sample, "vruntime"));
-       thread__put(thread);
-       return 0;
+       goto out_put;
 }
 
 static void bpf_output__printer(enum binary_printer_ops op,
@@ -1801,10 +1805,10 @@ static void print_location(FILE *f, struct perf_sample *sample,
                           bool print_dso, bool print_sym)
 {
 
-       if ((verbose || print_dso) && al->map)
+       if ((verbose > 0 || print_dso) && al->map)
                fprintf(f, "%s@", al->map->dso->long_name);
 
-       if ((verbose || print_sym) && al->sym)
+       if ((verbose > 0 || print_sym) && al->sym)
                fprintf(f, "%s+0x%" PRIx64, al->sym->name,
                        al->addr - al->sym->start);
        else if (al->map)
@@ -1920,7 +1924,7 @@ static int trace__process_sample(struct perf_tool *tool,
 
        thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
        if (thread && thread__is_filtered(thread))
-               return 0;
+               goto out;
 
        trace__set_base_time(trace, evsel, sample);
 
@@ -1928,7 +1932,8 @@ static int trace__process_sample(struct perf_tool *tool,
                ++trace->nr_events;
                handler(trace, evsel, event, sample);
        }
-
+out:
+       thread__put(thread);
        return err;
 }
 
@@ -2415,8 +2420,9 @@ static int trace__replay(struct trace *trace)
        trace->tool.exit          = perf_event__process_exit;
        trace->tool.fork          = perf_event__process_fork;
        trace->tool.attr          = perf_event__process_attr;
-       trace->tool.tracing_data = perf_event__process_tracing_data;
+       trace->tool.tracing_data  = perf_event__process_tracing_data;
        trace->tool.build_id      = perf_event__process_build_id;
+       trace->tool.namespaces    = perf_event__process_namespaces;
 
        trace->tool.ordered_events = true;
        trace->tool.ordering_requires_timestamps = true;