Skip to contentSkip to conversation

perf report: Fix a no annotate browser displayed issue

PATCH Superseded Jin Yao 2 participants 4 messages Dec 18, 2017 – Dec 25, 2017 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jin Yao

author
#0 lore raw

PATCH 1/1 perf report: Fix a no annotate browser displayed issue

When enabling '-b' option in perf record, for example,

perf record -b ...
perf report

and then browsing the annotate browser from perf report, it would be failed (annotate browser can't be displayed).

It's because the '.add_entry_cb' op of struct report is overwritten by hist_iter__branch_callback() in builtin-report.c. But this function doesn't do something like mapping symbols and sources. So next, do_annotate() will return directly.

	notes = symbol__annotation(act->ms.sym);
	if (!notes->src)
		return 0;

This patch adds the lost code to hist_iter__branch_callback ( refer to hist_iter__report_callback).

---
 tools/perf/builtin-report.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
tools/perf/builtin-report.c +14 -1
index eb9ce63..0bd0aef 100644
@@ -162,12 +162,25 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
 	struct hist_entry *he = iter->he;
 	struct report *rep = arg;
 	struct branch_info *bi;
+	struct perf_sample *sample = iter->sample;
+	struct perf_evsel *evsel = iter->evsel;
+	int err;
+
+	hist__account_cycles(sample->branch_stack, al, sample,
+			     rep->nonany_branch_mode);
 
 	bi = he->branch_info;
+	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+	if (err)
+		goto out;
+
+	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+
 	branch_type_count(&rep->brtype_stat, &bi->flags,
 			  bi->from.addr, bi->to.addr);
 
-	return 0;
+out:
+	return err;
 }
 
 static int process_sample_event(struct perf_tool *tool,
Signature · 1 line
2.7.4
author
#1 lore raw

Hi,

Any comments for this bug fix?

Thanks
Jin Yao

Quoted 57 lines · Jin Yao

When enabling '-b' option in perf record, for example,

perf record -b ...
perf report

and then browsing the annotate browser from perf report, it would be failed (annotate browser can't be displayed).

It's because the '.add_entry_cb' op of struct report is overwritten by hist_iter__branch_callback() in builtin-report.c. But this function doesn't do something like mapping symbols and sources. So next, do_annotate() will return directly.

	notes = symbol__annotation(act->ms.sym);
	if (!notes->src)
		return 0;

This patch adds the lost code to hist_iter__branch_callback ( refer to hist_iter__report_callback).

---
  tools/perf/builtin-report.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
tools/perf/builtin-report.c +14 -1
index eb9ce63..0bd0aef 100644
@@ -162,12 +162,25 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
  	struct hist_entry *he = iter->he;
  	struct report *rep = arg;
  	struct branch_info *bi;
+	struct perf_sample *sample = iter->sample;
+	struct perf_evsel *evsel = iter->evsel;
+	int err;
+
+	hist__account_cycles(sample->branch_stack, al, sample,
+			     rep->nonany_branch_mode);
 
  	bi = he->branch_info;
+	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+	if (err)
+		goto out;
+
+	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+
  	branch_type_count(&rep->brtype_stat, &bi->flags,
  			  bi->from.addr, bi->to.addr);
 
-	return 0;
+out:
+	return err;
  }
 
  static int process_sample_event(struct perf_tool *tool,
#2 lore raw
Quoted 3 lines · Yao

Hi,

Any comments for this bug fix?

getting segfault with this

[jolsa@krava perf]$ sudo ./perf record -b ls

[jolsa@krava perf]$ sudo ./perf report --stdio
Segmentation fault (core dumped)

jirka

Quoted 59 lines

Thanks
Jin Yao

Quoted 54 lines · Jin Yao

When enabling '-b' option in perf record, for example,

perf record -b ...
perf report

and then browsing the annotate browser from perf report, it would be failed (annotate browser can't be displayed).

It's because the '.add_entry_cb' op of struct report is overwritten by hist_iter__branch_callback() in builtin-report.c. But this function doesn't do something like mapping symbols and sources. So next, do_annotate() will return directly.

	notes = symbol__annotation(act->ms.sym);
	if (!notes->src)
		return 0;

This patch adds the lost code to hist_iter__branch_callback ( refer to hist_iter__report_callback).

---
  tools/perf/builtin-report.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
tools/perf/builtin-report.c +14 -1
index eb9ce63..0bd0aef 100644
@@ -162,12 +162,25 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
  	struct hist_entry *he = iter->he;
  	struct report *rep = arg;
  	struct branch_info *bi;
+	struct perf_sample *sample = iter->sample;
+	struct perf_evsel *evsel = iter->evsel;
+	int err;
+
+	hist__account_cycles(sample->branch_stack, al, sample,
+			     rep->nonany_branch_mode);
  	bi = he->branch_info;
+	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+	if (err)
+		goto out;
+
+	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+
  	branch_type_count(&rep->brtype_stat, &bi->flags,
  			  bi->from.addr, bi->to.addr);
-	return 0;
+out:
+	return err;
  }
  static int process_sample_event(struct perf_tool *tool,
 
author
#3 lore raw
Quoted 5 lines · Jiri Olsa
Quoted 3 lines · Yao

Hi,

Any comments for this bug fix?

Quoted 9 lines

getting segfault with this

[jolsa@krava perf]$ sudo ./perf record -b ls

[jolsa@krava perf]$ sudo ./perf report --stdio
Segmentation fault (core dumped)

jirka

Sorry about that. My fault, I will debug this issue.

Thanks
Jin Yao

Quoted 59 lines
Quoted 59 lines

Thanks
Jin Yao

Quoted 54 lines · Jin Yao

When enabling '-b' option in perf record, for example,

perf record -b ...
perf report

and then browsing the annotate browser from perf report, it would be failed (annotate browser can't be displayed).

It's because the '.add_entry_cb' op of struct report is overwritten by hist_iter__branch_callback() in builtin-report.c. But this function doesn't do something like mapping symbols and sources. So next, do_annotate() will return directly.

	notes = symbol__annotation(act->ms.sym);
	if (!notes->src)
		return 0;

This patch adds the lost code to hist_iter__branch_callback ( refer to hist_iter__report_callback).

---
   tools/perf/builtin-report.c | 15 ++++++++++++++-
   1 file changed, 14 insertions(+), 1 deletion(-)
tools/perf/builtin-report.c +14 -1
index eb9ce63..0bd0aef 100644
@@ -162,12 +162,25 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
   	struct hist_entry *he = iter->he;
   	struct report *rep = arg;
   	struct branch_info *bi;
+	struct perf_sample *sample = iter->sample;
+	struct perf_evsel *evsel = iter->evsel;
+	int err;
+
+	hist__account_cycles(sample->branch_stack, al, sample,
+			     rep->nonany_branch_mode);
   	bi = he->branch_info;
+	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+	if (err)
+		goto out;
+
+	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+
   	branch_type_count(&rep->brtype_stat, &bi->flags,
   			  bi->from.addr, bi->to.addr);
-	return 0;
+out:
+	return err;
   }
   static int process_sample_event(struct perf_tool *tool,