summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c62
1 files changed, 23 insertions, 39 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 0da603b79b61..5ebd0c3b71b6 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -28,10 +28,8 @@
#include "util/hist.h"
#include "util/session.h"
#include "util/tool.h"
-#include "util/data.h"
#include "arch/common.h"
-#include <dlfcn.h>
#include <linux/bitmap.h>
struct perf_annotate {
@@ -65,11 +63,19 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return 0;
}
- he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0);
+ he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1);
if (he == NULL)
return -ENOMEM;
- ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
+ ret = 0;
+ if (he->ms.sym != NULL) {
+ struct annotation *notes = symbol__annotation(he->ms.sym);
+ if (notes->src == NULL && symbol__alloc_hist(he->ms.sym) < 0)
+ return -ENOMEM;
+
+ ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
+ }
+
evsel->hists.stats.total_period += sample->period;
hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
return ret;
@@ -110,11 +116,11 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
ann->print_line, ann->full_paths, 0, 0);
}
-static void hists__find_annotations(struct hists *hists,
+static void hists__find_annotations(struct hists *self,
struct perf_evsel *evsel,
struct perf_annotate *ann)
{
- struct rb_node *nd = rb_first(&hists->entries), *next;
+ struct rb_node *nd = rb_first(&self->entries), *next;
int key = K_RIGHT;
while (nd) {
@@ -136,18 +142,8 @@ find_next:
if (use_browser == 2) {
int ret;
- int (*annotate)(struct hist_entry *he,
- struct perf_evsel *evsel,
- struct hist_browser_timer *hbt);
-
- annotate = dlsym(perf_gtk_handle,
- "hist_entry__gtk_annotate");
- if (annotate == NULL) {
- ui__error("GTK browser not found!\n");
- return;
- }
- ret = annotate(he, evsel, NULL);
+ ret = hist_entry__gtk_annotate(he, evsel, NULL);
if (!ret || !ann->skip_missing)
return;
@@ -180,7 +176,8 @@ find_next:
* symbol, free he->ms.sym->src to signal we already
* processed this symbol.
*/
- zfree(&notes->src);
+ free(notes->src);
+ notes->src = NULL;
}
}
}
@@ -191,13 +188,9 @@ static int __cmd_annotate(struct perf_annotate *ann)
struct perf_session *session;
struct perf_evsel *pos;
u64 total_nr_samples;
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- .force = ann->force,
- };
- session = perf_session__new(&file, false, &ann->tool);
+ session = perf_session__new(input_name, O_RDONLY,
+ ann->force, false, &ann->tool);
if (session == NULL)
return -ENOMEM;
@@ -232,13 +225,13 @@ static int __cmd_annotate(struct perf_annotate *ann)
perf_session__fprintf_dsos(session, stdout);
total_nr_samples = 0;
- evlist__for_each(session->evlist, pos) {
+ list_for_each_entry(pos, &session->evlist->entries, node) {
struct hists *hists = &pos->hists;
u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
if (nr_samples > 0) {
total_nr_samples += nr_samples;
- hists__collapse_resort(hists, NULL);
+ hists__collapse_resort(hists);
hists__output_resort(hists);
if (symbol_conf.event_group &&
@@ -250,21 +243,12 @@ static int __cmd_annotate(struct perf_annotate *ann)
}
if (total_nr_samples == 0) {
- ui__error("The %s file has no samples!\n", file.path);
+ ui__error("The %s file has no samples!\n", session->filename);
goto out_delete;
}
- if (use_browser == 2) {
- void (*show_annotations)(void);
-
- show_annotations = dlsym(perf_gtk_handle,
- "perf_gtk__show_annotations");
- if (show_annotations == NULL) {
- ui__error("GTK browser not found!\n");
- goto out_delete;
- }
- show_annotations();
- }
+ if (use_browser == 2)
+ perf_gtk__show_annotations();
out_delete:
/*
@@ -364,7 +348,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
if (argc) {
/*
- * Special case: if there's an argument left then assume that
+ * Special case: if there's an argument left then assume tha
* it's a symbol filter:
*/
if (argc > 1)