Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1236528 > unrolled thread

[PATCH perf/core 0/5] perf-probe bugfixes

Started byMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
First post2015-09-30 18:50 +0200
Last post2015-09-30 22:20 +0200
Articles 12 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH perf/core  0/5] perf-probe bugfixes Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-09-30 18:50 +0200
    [PATCH perf/core 5/5] perf-probe: Improve error message when  %return is on inlined function Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-09-30 18:50 +0200
      [tip:perf/core] perf probe:   Improve error message when %return is on inlined function tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-10-01 09:20 +0200
    [PATCH perf/core 3/5] [BUGFIX] perf-probe: Show correct source  lines of probes on kmodules Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-09-30 18:50 +0200
      [tip:perf/core] perf probe:   Show correct source lines of probes on kmodules tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-10-01 09:20 +0200
    [PATCH perf/core 4/5] [BUGFIX] perf-probe: Fix a segfault bug in  debuginfo_cache Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-09-30 18:50 +0200
      [tip:perf/core] perf probe: Fix a segfault bug in debuginfo_cache tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-10-01 09:20 +0200
    [PATCH perf/core 2/5] [BUGFIX] perf-probe: Fix to remove dot suffix  from second or latter events Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-09-30 18:50 +0200
      [tip:perf/core] perf probe:   Fix to remove dot suffix from second or latter events tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-10-01 09:20 +0200
    [PATCH perf/core 1/5] [BUGFIX] perf-probe: Begin and end report  session correctly Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-09-30 18:50 +0200
      [tip:perf/core] perf probe:   Begin and end libdwfl report session correctly tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-10-01 09:20 +0200
    Re: [PATCH perf/core  0/5] perf-probe bugfixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-30 22:20 +0200

#1236528 — [PATCH perf/core 0/5] perf-probe bugfixes

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-09-30 18:50 +0200
Subject[PATCH perf/core 0/5] perf-probe bugfixes
Message-ID<qesJQ-2eW-3@gated-at.bofh.it>
Hi,

Here is a bunch of bugfix patches for perf-probe.

- Begin and end report session correctly, which fixes
  a mistake of libdwfl usage.
- Fix to remove dot suffix from second or latter events
  which fixes a bug on multiple events on a dot suffixed
  symbol.
- Show correct source lines of probes on kmodules, which
  fixes a bug that perf-probe --list can not find probe
  points in kernel modules.
- Fix a segfault bug in debuginfo_cache, which fixes a
  segfault bug in debuginfo_cache__open.
- Improve error message when %return is on inlined function
  is not actual bugfix, but improve an error message.


Thank you,


---

Masami Hiramatsu (5):
      [BUGFIX] perf-probe: Begin and end report session correctly
      [BUGFIX] perf-probe: Fix to remove dot suffix from second or latter events
      [BUGFIX] perf-probe: Show correct source lines of probes on kmodules
      [BUGFIX] perf-probe: Fix a segfault bug in debuginfo_cache
      perf-probe: Improve error message when %return is on inlined function


 tools/perf/util/probe-event.c  |   89 +++++++++++++++++++++++++---------------
 tools/perf/util/probe-finder.c |   58 ++++++++++++++++++++++++--
 2 files changed, 109 insertions(+), 38 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1236529 — [PATCH perf/core 5/5] perf-probe: Improve error message when %return is on inlined function

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-09-30 18:50 +0200
Subject[PATCH perf/core 5/5] perf-probe: Improve error message when %return is on inlined function
Message-ID<qesJQ-2eW-11@gated-at.bofh.it>
In reply to#1236528
perf probe shows more precisely message when it finds given
%return target function is inlined.

Without this fix:
  ----
  # ./perf probe -V getname_flags%return
  Return probe must be on the head of a real function.
  Debuginfo analysis failed.
    Error: Failed to show vars.
  ----

With this fix:
  ----
  # ./perf probe -V getname_flags%return
  Failed to find "getname_flags%return",
   because getname_flags is an inlined function and has no return point.
  Debuginfo analysis failed.
    Error: Failed to show vars.
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
---
 tools/perf/util/probe-finder.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index f0708ff..bd8f03d 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -594,6 +594,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
 /* Convert subprogram DIE to trace point */
 static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
 				  Dwarf_Addr paddr, bool retprobe,
+				  const char *function,
 				  struct probe_trace_point *tp)
 {
 	Dwarf_Addr eaddr, highaddr;
@@ -637,8 +638,10 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
 	/* Return probe must be on the head of a subprogram */
 	if (retprobe) {
 		if (eaddr != paddr) {
-			pr_warning("Return probe must be on the head of"
-				   " a real function.\n");
+			pr_warning("Failed to find \"%s%%return\",\n"
+				   " because %s is an inlined function and"
+				   " has no return point.\n", function,
+				   function);
 			return -EINVAL;
 		}
 		tp->retprobe = true;
@@ -1178,6 +1181,7 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 {
 	struct trace_event_finder *tf =
 			container_of(pf, struct trace_event_finder, pf);
+	struct perf_probe_point *pp = &pf->pev->point;
 	struct probe_trace_event *tev;
 	struct perf_probe_arg *args;
 	int ret, i;
@@ -1192,7 +1196,7 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 
 	/* Trace point should be converted from subprogram DIE */
 	ret = convert_to_trace_point(&pf->sp_die, tf->mod, pf->addr,
-				     pf->pev->point.retprobe, &tev->point);
+				     pp->retprobe, pp->function, &tev->point);
 	if (ret < 0)
 		return ret;
 
@@ -1322,6 +1326,7 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
 {
 	struct available_var_finder *af =
 			container_of(pf, struct available_var_finder, pf);
+	struct perf_probe_point *pp = &pf->pev->point;
 	struct variable_list *vl;
 	Dwarf_Die die_mem;
 	int ret;
@@ -1335,7 +1340,7 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
 
 	/* Trace point should be converted from subprogram DIE */
 	ret = convert_to_trace_point(&pf->sp_die, af->mod, pf->addr,
-				     pf->pev->point.retprobe, &vl->point);
+				     pp->retprobe, pp->function, &vl->point);
 	if (ret < 0)
 		return ret;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237065 — [tip:perf/core] perf probe: Improve error message when %return is on inlined function

Fromtip-bot for Masami Hiramatsu <tipbot@zytor.com>
Date2015-10-01 09:20 +0200
Subject[tip:perf/core] perf probe: Improve error message when %return is on inlined function
Message-ID<qeGjM-58Q-17@gated-at.bofh.it>
In reply to#1236529
Commit-ID:  6cca13bdf5a5d561a855259689874e0c7266eec3
Gitweb:     http://git.kernel.org/tip/6cca13bdf5a5d561a855259689874e0c7266eec3
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 1 Oct 2015 01:41:37 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 30 Sep 2015 18:34:37 -0300

perf probe: Improve error message when %return is on inlined function

perf probe shows more precisely message when it finds given
%return target function is inlined.

Without this fix:
  ----
  # ./perf probe -V getname_flags%return
  Return probe must be on the head of a real function.
  Debuginfo analysis failed.
    Error: Failed to show vars.
  ----

With this fix:
  ----
  # ./perf probe -V getname_flags%return
  Failed to find "getname_flags%return",
   because getname_flags is an inlined function and has no return point.
  Debuginfo analysis failed.
    Error: Failed to show vars.
  ----

Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20150930164137.3733.55055.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-finder.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index f0708ff..bd8f03d 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -594,6 +594,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
 /* Convert subprogram DIE to trace point */
 static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
 				  Dwarf_Addr paddr, bool retprobe,
+				  const char *function,
 				  struct probe_trace_point *tp)
 {
 	Dwarf_Addr eaddr, highaddr;
@@ -637,8 +638,10 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
 	/* Return probe must be on the head of a subprogram */
 	if (retprobe) {
 		if (eaddr != paddr) {
-			pr_warning("Return probe must be on the head of"
-				   " a real function.\n");
+			pr_warning("Failed to find \"%s%%return\",\n"
+				   " because %s is an inlined function and"
+				   " has no return point.\n", function,
+				   function);
 			return -EINVAL;
 		}
 		tp->retprobe = true;
@@ -1178,6 +1181,7 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 {
 	struct trace_event_finder *tf =
 			container_of(pf, struct trace_event_finder, pf);
+	struct perf_probe_point *pp = &pf->pev->point;
 	struct probe_trace_event *tev;
 	struct perf_probe_arg *args;
 	int ret, i;
@@ -1192,7 +1196,7 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 
 	/* Trace point should be converted from subprogram DIE */
 	ret = convert_to_trace_point(&pf->sp_die, tf->mod, pf->addr,
-				     pf->pev->point.retprobe, &tev->point);
+				     pp->retprobe, pp->function, &tev->point);
 	if (ret < 0)
 		return ret;
 
@@ -1322,6 +1326,7 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
 {
 	struct available_var_finder *af =
 			container_of(pf, struct available_var_finder, pf);
+	struct perf_probe_point *pp = &pf->pev->point;
 	struct variable_list *vl;
 	Dwarf_Die die_mem;
 	int ret;
@@ -1335,7 +1340,7 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
 
 	/* Trace point should be converted from subprogram DIE */
 	ret = convert_to_trace_point(&pf->sp_die, af->mod, pf->addr,
-				     pf->pev->point.retprobe, &vl->point);
+				     pp->retprobe, pp->function, &vl->point);
 	if (ret < 0)
 		return ret;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1236531 — [PATCH perf/core 3/5] [BUGFIX] perf-probe: Show correct source lines of probes on kmodules

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-09-30 18:50 +0200
Subject[PATCH perf/core 3/5] [BUGFIX] perf-probe: Show correct source lines of probes on kmodules
Message-ID<qesJQ-2eW-13@gated-at.bofh.it>
In reply to#1236528
Perf probe always failed to find appropriate line numbers
because of failing to find .text start address offset from
debuginfo.

e.g.
  ----
  # ./perf probe -m pcspkr pcspkr_event:5
  Added new events:
    probe:pcspkr_event   (on pcspkr_event:5 in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event:5 in pcspkr)

  You can now use it in all perf tools, such as:

          perf record -e probe:pcspkr_event_1 -aR sleep 1

  # ./perf probe -l
  Failed to find debug information for address ffffffffa031f006
  Failed to find debug information for address ffffffffa031f016
    probe:pcspkr_event   (on pcspkr_event+6 in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event+22 in pcspkr)
  ----

This fixes the above issue as below.
1. Get the relative address of the symbol in .text by using
   map->start.
2. Adjust the address by adding the offset of .text section
   in the kernel module binary.

With this fix, perf probe -l shows lines correctly.
  ----
  # ./perf probe -l
    probe:pcspkr_event   (on pcspkr_event:5@drivers/input/misc/pcspkr.c
  in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event:5@drivers/input/misc/pcspkr.c
  in pcspkr)
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
---
 tools/perf/util/probe-event.c  |   35 ++++++++++++++++++++++-----------
 tools/perf/util/probe-finder.c |   42 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7eb0239..57a8cad 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -136,7 +136,8 @@ static struct ref_reloc_sym *kernel_get_ref_reloc_sym(void)
 	return kmap->ref_reloc_sym;
 }
 
-static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
+static int kernel_get_symbol_address_by_name(const char *name, u64 *addr,
+					     bool reloc, bool reladdr)
 {
 	struct ref_reloc_sym *reloc_sym;
 	struct symbol *sym;
@@ -145,12 +146,14 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
 	/* ref_reloc_sym is just a label. Need a special fix*/
 	reloc_sym = kernel_get_ref_reloc_sym();
 	if (reloc_sym && strcmp(name, reloc_sym->name) == 0)
-		return (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;
+		*addr = (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;
 	else {
 		sym = __find_kernel_function_by_name(name, &map);
-		if (sym)
-			return map->unmap_ip(map, sym->start) -
-				((reloc) ? 0 : map->reloc);
+		if (!sym)
+			return -ENOENT;
+		*addr = map->unmap_ip(map, sym->start) -
+			((reloc) ? 0 : map->reloc) -
+			((reladdr) ? map->start : 0);
 	}
 	return 0;
 }
@@ -244,12 +247,14 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
 static bool kprobe_blacklist__listed(unsigned long address);
 static bool kprobe_warn_out_range(const char *symbol, unsigned long address)
 {
-	u64 etext_addr;
+	u64 etext_addr = 0;
+	int ret;
 
 	/* Get the address of _etext for checking non-probable text symbol */
-	etext_addr = kernel_get_symbol_address_by_name("_etext", false);
+	ret = kernel_get_symbol_address_by_name("_etext", &etext_addr,
+						false, false);
 
-	if (etext_addr != 0 && etext_addr < address)
+	if (ret == 0 && etext_addr < address)
 		pr_warning("%s is out of .text, skip it.\n", symbol);
 	else if (kprobe_blacklist__listed(address))
 		pr_warning("%s is blacklisted function, skip it.\n", symbol);
@@ -516,8 +521,10 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp,
 			goto error;
 		addr += stext;
 	} else if (tp->symbol) {
-		addr = kernel_get_symbol_address_by_name(tp->symbol, false);
-		if (addr == 0)
+		/* If the module is given, this returns relative address */
+		ret = kernel_get_symbol_address_by_name(tp->symbol, &addr,
+							false, !!tp->module);
+		if (ret != 0)
 			goto error;
 		addr += tp->offset;
 	}
@@ -1883,8 +1890,12 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
 			goto out;
 		sym = map__find_symbol(map, addr, NULL);
 	} else {
-		if (tp->symbol)
-			addr = kernel_get_symbol_address_by_name(tp->symbol, true);
+		if (tp->symbol && !addr) {
+			ret = kernel_get_symbol_address_by_name(tp->symbol,
+							&addr, true, false);
+			if (ret < 0)
+				goto out;
+		}
 		if (addr) {
 			addr += tp->offset;
 			sym = __find_kernel_function(addr, &map);
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 35f905f..f0708ff 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1402,6 +1402,41 @@ int debuginfo__find_available_vars_at(struct debuginfo *dbg,
 	return (ret < 0) ? ret : af.nvls;
 }
 
+/* For the kernel module, we need a special code to get a DIE */
+static int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs)
+{
+	int n, i;
+	Elf32_Word shndx;
+	Elf_Scn *scn;
+	Elf *elf;
+	GElf_Shdr mem, *shdr;
+	const char *p;
+
+	elf = dwfl_module_getelf(dbg->mod, &dbg->bias);
+	if (!elf)
+		return -EINVAL;
+
+	/* Get the number of relocations */
+	n = dwfl_module_relocations(dbg->mod);
+	if (n < 0)
+		return -ENOENT;
+	/* Search the relocation related .text section */
+	for (i = 0; i < n; i++) {
+		p = dwfl_module_relocation_info(dbg->mod, i, &shndx);
+		if (strcmp(p, ".text") == 0) {
+			/* OK, get the section header */
+			scn = elf_getscn(elf, shndx);
+			if (!scn)
+				return -ENOENT;
+			shdr = gelf_getshdr(scn, &mem);
+			if (!shdr)
+				return -ENOENT;
+			*offs = shdr->sh_addr;
+		}
+	}
+	return 0;
+}
+
 /* Reverse search */
 int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
 				struct perf_probe_point *ppt)
@@ -1410,9 +1445,16 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
 	Dwarf_Addr _addr = 0, baseaddr = 0;
 	const char *fname = NULL, *func = NULL, *basefunc = NULL, *tmp;
 	int baseline = 0, lineno = 0, ret = 0;
+	bool reloc = false;
 
+retry:
 	/* Find cu die */
 	if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr, &cudie)) {
+		if (!reloc && debuginfo__get_text_offset(dbg, &baseaddr) == 0) {
+			addr += baseaddr;
+			reloc = true;
+			goto retry;
+		}
 		pr_warning("Failed to find debug information for address %lx\n",
 			   addr);
 		ret = -EINVAL;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237060 — [tip:perf/core] perf probe: Show correct source lines of probes on kmodules

Fromtip-bot for Masami Hiramatsu <tipbot@zytor.com>
Date2015-10-01 09:20 +0200
Subject[tip:perf/core] perf probe: Show correct source lines of probes on kmodules
Message-ID<qeGjM-58Q-7@gated-at.bofh.it>
In reply to#1236531
Commit-ID:  9b239a12bc872f212cefbaee4d028c838abe6ff3
Gitweb:     http://git.kernel.org/tip/9b239a12bc872f212cefbaee4d028c838abe6ff3
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 1 Oct 2015 01:41:33 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 30 Sep 2015 18:34:35 -0300

perf probe: Show correct source lines of probes on kmodules

Perf probe always failed to find appropriate line numbers because of
failing to find .text start address offset from debuginfo.

e.g.
  ----
  # ./perf probe -m pcspkr pcspkr_event:5
  Added new events:
    probe:pcspkr_event   (on pcspkr_event:5 in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event:5 in pcspkr)

  You can now use it in all perf tools, such as:

          perf record -e probe:pcspkr_event_1 -aR sleep 1

  # ./perf probe -l
  Failed to find debug information for address ffffffffa031f006
  Failed to find debug information for address ffffffffa031f016
    probe:pcspkr_event   (on pcspkr_event+6 in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event+22 in pcspkr)
  ----

This fixes the above issue as below.
1. Get the relative address of the symbol in .text by using
   map->start.
2. Adjust the address by adding the offset of .text section
   in the kernel module binary.

With this fix, perf probe -l shows lines correctly.
  ----
  # ./perf probe -l
    probe:pcspkr_event   (on pcspkr_event:5@drivers/input/misc/pcspkr.c in pcspkr)
    probe:pcspkr_event_1 (on pcspkr_event:5@drivers/input/misc/pcspkr.c in pcspkr)
  ----

Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20150930164132.3733.24643.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c  | 35 +++++++++++++++++++++++------------
 tools/perf/util/probe-finder.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 5d68f68..65be284 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -137,7 +137,8 @@ static struct ref_reloc_sym *kernel_get_ref_reloc_sym(void)
 	return kmap->ref_reloc_sym;
 }
 
-static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
+static int kernel_get_symbol_address_by_name(const char *name, u64 *addr,
+					     bool reloc, bool reladdr)
 {
 	struct ref_reloc_sym *reloc_sym;
 	struct symbol *sym;
@@ -146,12 +147,14 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
 	/* ref_reloc_sym is just a label. Need a special fix*/
 	reloc_sym = kernel_get_ref_reloc_sym();
 	if (reloc_sym && strcmp(name, reloc_sym->name) == 0)
-		return (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;
+		*addr = (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;
 	else {
 		sym = __find_kernel_function_by_name(name, &map);
-		if (sym)
-			return map->unmap_ip(map, sym->start) -
-				((reloc) ? 0 : map->reloc);
+		if (!sym)
+			return -ENOENT;
+		*addr = map->unmap_ip(map, sym->start) -
+			((reloc) ? 0 : map->reloc) -
+			((reladdr) ? map->start : 0);
 	}
 	return 0;
 }
@@ -245,12 +248,14 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
 static bool kprobe_blacklist__listed(unsigned long address);
 static bool kprobe_warn_out_range(const char *symbol, unsigned long address)
 {
-	u64 etext_addr;
+	u64 etext_addr = 0;
+	int ret;
 
 	/* Get the address of _etext for checking non-probable text symbol */
-	etext_addr = kernel_get_symbol_address_by_name("_etext", false);
+	ret = kernel_get_symbol_address_by_name("_etext", &etext_addr,
+						false, false);
 
-	if (etext_addr != 0 && etext_addr < address)
+	if (ret == 0 && etext_addr < address)
 		pr_warning("%s is out of .text, skip it.\n", symbol);
 	else if (kprobe_blacklist__listed(address))
 		pr_warning("%s is blacklisted function, skip it.\n", symbol);
@@ -517,8 +522,10 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp,
 			goto error;
 		addr += stext;
 	} else if (tp->symbol) {
-		addr = kernel_get_symbol_address_by_name(tp->symbol, false);
-		if (addr == 0)
+		/* If the module is given, this returns relative address */
+		ret = kernel_get_symbol_address_by_name(tp->symbol, &addr,
+							false, !!tp->module);
+		if (ret != 0)
 			goto error;
 		addr += tp->offset;
 	}
@@ -1884,8 +1891,12 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
 			goto out;
 		sym = map__find_symbol(map, addr, NULL);
 	} else {
-		if (tp->symbol)
-			addr = kernel_get_symbol_address_by_name(tp->symbol, true);
+		if (tp->symbol && !addr) {
+			ret = kernel_get_symbol_address_by_name(tp->symbol,
+							&addr, true, false);
+			if (ret < 0)
+				goto out;
+		}
 		if (addr) {
 			addr += tp->offset;
 			sym = __find_kernel_function(addr, &map);
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 35f905f..f0708ff 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1402,6 +1402,41 @@ int debuginfo__find_available_vars_at(struct debuginfo *dbg,
 	return (ret < 0) ? ret : af.nvls;
 }
 
+/* For the kernel module, we need a special code to get a DIE */
+static int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs)
+{
+	int n, i;
+	Elf32_Word shndx;
+	Elf_Scn *scn;
+	Elf *elf;
+	GElf_Shdr mem, *shdr;
+	const char *p;
+
+	elf = dwfl_module_getelf(dbg->mod, &dbg->bias);
+	if (!elf)
+		return -EINVAL;
+
+	/* Get the number of relocations */
+	n = dwfl_module_relocations(dbg->mod);
+	if (n < 0)
+		return -ENOENT;
+	/* Search the relocation related .text section */
+	for (i = 0; i < n; i++) {
+		p = dwfl_module_relocation_info(dbg->mod, i, &shndx);
+		if (strcmp(p, ".text") == 0) {
+			/* OK, get the section header */
+			scn = elf_getscn(elf, shndx);
+			if (!scn)
+				return -ENOENT;
+			shdr = gelf_getshdr(scn, &mem);
+			if (!shdr)
+				return -ENOENT;
+			*offs = shdr->sh_addr;
+		}
+	}
+	return 0;
+}
+
 /* Reverse search */
 int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
 				struct perf_probe_point *ppt)
@@ -1410,9 +1445,16 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
 	Dwarf_Addr _addr = 0, baseaddr = 0;
 	const char *fname = NULL, *func = NULL, *basefunc = NULL, *tmp;
 	int baseline = 0, lineno = 0, ret = 0;
+	bool reloc = false;
 
+retry:
 	/* Find cu die */
 	if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr, &cudie)) {
+		if (!reloc && debuginfo__get_text_offset(dbg, &baseaddr) == 0) {
+			addr += baseaddr;
+			reloc = true;
+			goto retry;
+		}
 		pr_warning("Failed to find debug information for address %lx\n",
 			   addr);
 		ret = -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1236533 — [PATCH perf/core 4/5] [BUGFIX] perf-probe: Fix a segfault bug in debuginfo_cache

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-09-30 18:50 +0200
Subject[PATCH perf/core 4/5] [BUGFIX] perf-probe: Fix a segfault bug in debuginfo_cache
Message-ID<qesJQ-2eW-19@gated-at.bofh.it>
In reply to#1236528
perf probe --list will get a segfault if the first kprobe
event is on a module and the second or latter one on
the kernel.

e.g.
  ----
  # ./perf probe -q -m pcspkr pcspkr_event
  # ./perf probe -q vfs_read
  # ./perf probe -l
  Segmentation fault (core dumped)
  ----

This is because the debuginfo_cache fails to handle NULL
module name, which causes segfault on strcmp. (Note that
strcmp("something", NULL) always causes segfault)

To fix this debuginfo_cache__open always translates the
NULL module name to "kernel" (this is correct, because
NULL module name means opening the debuginfo for the kernel)

  ----
  # ./perf probe -l
    probe:pcspkr_event   (on pcspkr_event@drivers/input/misc/pcspkr.c
    in pcspkr)
    probe:vfs_read       (on vfs_read@ksrc/linux-3/fs/read_write.c)
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/util/probe-event.c |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 57a8cad..bb7766ea 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -440,19 +440,22 @@ static char *debuginfo_cache_path;
 
 static struct debuginfo *debuginfo_cache__open(const char *module, bool silent)
 {
-	if ((debuginfo_cache_path && !strcmp(debuginfo_cache_path, module)) ||
-	    (!debuginfo_cache_path && !module && debuginfo_cache))
+	const char *path = module;
+
+	/* If the module is NULL, it should be the kernel. */
+	if (!module)
+		path = "kernel";
+
+	if (debuginfo_cache_path && !strcmp(debuginfo_cache_path, path))
 		goto out;
 
 	/* Copy module path */
 	free(debuginfo_cache_path);
-	if (module) {
-		debuginfo_cache_path = strdup(module);
-		if (!debuginfo_cache_path) {
-			debuginfo__delete(debuginfo_cache);
-			debuginfo_cache = NULL;
-			goto out;
-		}
+	debuginfo_cache_path = strdup(path);
+	if (!debuginfo_cache_path) {
+		debuginfo__delete(debuginfo_cache);
+		debuginfo_cache = NULL;
+		goto out;
 	}
 
 	debuginfo_cache = open_debuginfo(module, silent);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237059 — [tip:perf/core] perf probe: Fix a segfault bug in debuginfo_cache

Fromtip-bot for Masami Hiramatsu <tipbot@zytor.com>
Date2015-10-01 09:20 +0200
Subject[tip:perf/core] perf probe: Fix a segfault bug in debuginfo_cache
Message-ID<qeGjM-58Q-5@gated-at.bofh.it>
In reply to#1236533
Commit-ID:  20f49859c785183d5296670a10dace454131274b
Gitweb:     http://git.kernel.org/tip/20f49859c785183d5296670a10dace454131274b
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 1 Oct 2015 01:41:35 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 30 Sep 2015 18:34:36 -0300

perf probe: Fix a segfault bug in debuginfo_cache

perf probe --list will get a segfault if the first kprobe event is on a
module and the second or latter one is on the kernel.

e.g.
  ----
  # ./perf probe -q -m pcspkr pcspkr_event
  # ./perf probe -q vfs_read
  # ./perf probe -l
  Segmentation fault (core dumped)
  ----

This is because the debuginfo_cache fails to handle NULL module name,
which causes segfault on strcmp. (Note that strcmp("something", NULL)
always causes segfault)

To fix this debuginfo_cache__open always translates the NULL module name
to "kernel" (this is correct, because NULL module name means opening the
debuginfo for the kernel)

  ----
  # ./perf probe -l
    probe:pcspkr_event   (on pcspkr_event@drivers/input/misc/pcspkr.c
    in pcspkr)
    probe:vfs_read       (on vfs_read@ksrc/linux-3/fs/read_write.c)
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20150930164135.3733.23993.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 65be284..3010abc 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -441,19 +441,22 @@ static char *debuginfo_cache_path;
 
 static struct debuginfo *debuginfo_cache__open(const char *module, bool silent)
 {
-	if ((debuginfo_cache_path && !strcmp(debuginfo_cache_path, module)) ||
-	    (!debuginfo_cache_path && !module && debuginfo_cache))
+	const char *path = module;
+
+	/* If the module is NULL, it should be the kernel. */
+	if (!module)
+		path = "kernel";
+
+	if (debuginfo_cache_path && !strcmp(debuginfo_cache_path, path))
 		goto out;
 
 	/* Copy module path */
 	free(debuginfo_cache_path);
-	if (module) {
-		debuginfo_cache_path = strdup(module);
-		if (!debuginfo_cache_path) {
-			debuginfo__delete(debuginfo_cache);
-			debuginfo_cache = NULL;
-			goto out;
-		}
+	debuginfo_cache_path = strdup(path);
+	if (!debuginfo_cache_path) {
+		debuginfo__delete(debuginfo_cache);
+		debuginfo_cache = NULL;
+		goto out;
 	}
 
 	debuginfo_cache = open_debuginfo(module, silent);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1236539 — [PATCH perf/core 2/5] [BUGFIX] perf-probe: Fix to remove dot suffix from second or latter events

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-09-30 18:50 +0200
Subject[PATCH perf/core 2/5] [BUGFIX] perf-probe: Fix to remove dot suffix from second or latter events
Message-ID<qesJR-2eW-39@gated-at.bofh.it>
In reply to#1236528
Fix to remove dot suffix (e.g. .const, .isra) from
the second or latter events which has suffix numbers.

Since the previous commit 35a23ff928b0 ("perf probe: Cut
 off the gcc optimization postfixes from function name")
didn't care about the suffix numbered events, therefore
we'll have an error when we add additional events on the
same dot suffix functions.

e.g.
  ----
  # ./perf probe -f -a get_sigframe.isra.2.constprop.3 \
   -a get_sigframe.isra.2.constprop.3
  Failed to write event: Invalid argument
    Error: Failed to add events.
  ----

This fixes above issue as below:
  ----
  # ./perf probe -f -a get_sigframe.isra.2.constprop.3 \
   -a get_sigframe.isra.2.constprop.3
  Added new events:
    probe:get_sigframe   (on get_sigframe.isra.2.constprop.3)
    probe:get_sigframe_1 (on get_sigframe.isra.2.constprop.3)

  You can now use it in all perf tools, such as:

          perf record -e probe:get_sigframe_1 -aR sleep 1

  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/util/probe-event.c |   33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7fb0533..7eb0239 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2288,36 +2288,41 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
 			      struct strlist *namelist, bool allow_suffix)
 {
 	int i, ret;
-	char *p;
+	char *p, *nbase;
 
 	if (*base == '.')
 		base++;
+	nbase = strdup(base);
+	if (!nbase)
+		return -ENOMEM;
+
+	/* Cut off the dot suffixes (e.g. .const, .isra)*/
+	p = strchr(nbase, '.');
+	if (p && p != nbase)
+		*p = '\0';
 
-	/* Try no suffix */
-	ret = e_snprintf(buf, len, "%s", base);
+	/* Try no suffix number */
+	ret = e_snprintf(buf, len, "%s", nbase);
 	if (ret < 0) {
 		pr_debug("snprintf() failed: %d\n", ret);
-		return ret;
+		goto out;
 	}
-	/* Cut off the postfixes (e.g. .const, .isra)*/
-	p = strchr(buf, '.');
-	if (p && p != buf)
-		*p = '\0';
 	if (!strlist__has_entry(namelist, buf))
-		return 0;
+		goto out;
 
 	if (!allow_suffix) {
 		pr_warning("Error: event \"%s\" already exists. "
-			   "(Use -f to force duplicates.)\n", base);
-		return -EEXIST;
+			   "(Use -f to force duplicates.)\n", buf);
+		ret = -EEXIST;
+		goto out;
 	}
 
 	/* Try to add suffix */
 	for (i = 1; i < MAX_EVENT_INDEX; i++) {
-		ret = e_snprintf(buf, len, "%s_%d", base, i);
+		ret = e_snprintf(buf, len, "%s_%d", nbase, i);
 		if (ret < 0) {
 			pr_debug("snprintf() failed: %d\n", ret);
-			return ret;
+			goto out;
 		}
 		if (!strlist__has_entry(namelist, buf))
 			break;
@@ -2327,6 +2332,8 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
 		ret = -ERANGE;
 	}
 
+out:
+	free(nbase);
 	return ret;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237074 — [tip:perf/core] perf probe: Fix to remove dot suffix from second or latter events

Fromtip-bot for Masami Hiramatsu <tipbot@zytor.com>
Date2015-10-01 09:20 +0200
Subject[tip:perf/core] perf probe: Fix to remove dot suffix from second or latter events
Message-ID<qeGjN-58Q-47@gated-at.bofh.it>
In reply to#1236539
Commit-ID:  663b1151f2d674e2004c015cbe9995749033c49a
Gitweb:     http://git.kernel.org/tip/663b1151f2d674e2004c015cbe9995749033c49a
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 1 Oct 2015 01:41:30 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 30 Sep 2015 18:34:33 -0300

perf probe: Fix to remove dot suffix from second or latter events

Fix to remove dot suffix (e.g. .const, .isra) from the second or latter
events which has suffix numbers.

Since the previous commit 35a23ff928b0 ("perf probe: Cut off the gcc
optimization postfixes from function name") didn't care about the suffix
numbered events, therefore we'll have an error when we add additional
events on the same dot suffix functions.

e.g.
  ----
  # ./perf probe -f -a get_sigframe.isra.2.constprop.3 \
   -a get_sigframe.isra.2.constprop.3
  Failed to write event: Invalid argument
    Error: Failed to add events.
  ----

This fixes above issue as below:
  ----
  # ./perf probe -f -a get_sigframe.isra.2.constprop.3 \
   -a get_sigframe.isra.2.constprop.3
  Added new events:
    probe:get_sigframe   (on get_sigframe.isra.2.constprop.3)
    probe:get_sigframe_1 (on get_sigframe.isra.2.constprop.3)

  You can now use it in all perf tools, such as:

          perf record -e probe:get_sigframe_1 -aR sleep 1

  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20150930164130.3733.26573.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 8b9a680..5d68f68 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2289,36 +2289,41 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
 			      struct strlist *namelist, bool allow_suffix)
 {
 	int i, ret;
-	char *p;
+	char *p, *nbase;
 
 	if (*base == '.')
 		base++;
+	nbase = strdup(base);
+	if (!nbase)
+		return -ENOMEM;
+
+	/* Cut off the dot suffixes (e.g. .const, .isra)*/
+	p = strchr(nbase, '.');
+	if (p && p != nbase)
+		*p = '\0';
 
-	/* Try no suffix */
-	ret = e_snprintf(buf, len, "%s", base);
+	/* Try no suffix number */
+	ret = e_snprintf(buf, len, "%s", nbase);
 	if (ret < 0) {
 		pr_debug("snprintf() failed: %d\n", ret);
-		return ret;
+		goto out;
 	}
-	/* Cut off the postfixes (e.g. .const, .isra)*/
-	p = strchr(buf, '.');
-	if (p && p != buf)
-		*p = '\0';
 	if (!strlist__has_entry(namelist, buf))
-		return 0;
+		goto out;
 
 	if (!allow_suffix) {
 		pr_warning("Error: event \"%s\" already exists. "
-			   "(Use -f to force duplicates.)\n", base);
-		return -EEXIST;
+			   "(Use -f to force duplicates.)\n", buf);
+		ret = -EEXIST;
+		goto out;
 	}
 
 	/* Try to add suffix */
 	for (i = 1; i < MAX_EVENT_INDEX; i++) {
-		ret = e_snprintf(buf, len, "%s_%d", base, i);
+		ret = e_snprintf(buf, len, "%s_%d", nbase, i);
 		if (ret < 0) {
 			pr_debug("snprintf() failed: %d\n", ret);
-			return ret;
+			goto out;
 		}
 		if (!strlist__has_entry(namelist, buf))
 			break;
@@ -2328,6 +2333,8 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
 		ret = -ERANGE;
 	}
 
+out:
+	free(nbase);
 	return ret;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1236541 — [PATCH perf/core 1/5] [BUGFIX] perf-probe: Begin and end report session correctly

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-09-30 18:50 +0200
Subject[PATCH perf/core 1/5] [BUGFIX] perf-probe: Begin and end report session correctly
Message-ID<qesJR-2eW-43@gated-at.bofh.it>
In reply to#1236528
Fix a trival bug about libdwfl usage of the report session,
it should be explicitly do begin and end report session around
report_offline.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/util/probe-finder.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 29c43c068..35f905f 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -70,6 +70,7 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *dbg,
 	if (!dbg->dwfl)
 		goto error;
 
+	dwfl_report_begin(dbg->dwfl);
 	dbg->mod = dwfl_report_offline(dbg->dwfl, "", "", fd);
 	if (!dbg->mod)
 		goto error;
@@ -78,6 +79,8 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *dbg,
 	if (!dbg->dbg)
 		goto error;
 
+	dwfl_report_end(dbg->dwfl, NULL, NULL);
+
 	return 0;
 error:
 	if (dbg->dwfl)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237072 — [tip:perf/core] perf probe: Begin and end libdwfl report session correctly

Fromtip-bot for Masami Hiramatsu <tipbot@zytor.com>
Date2015-10-01 09:20 +0200
Subject[tip:perf/core] perf probe: Begin and end libdwfl report session correctly
Message-ID<qeGjN-58Q-35@gated-at.bofh.it>
In reply to#1236541
Commit-ID:  9135949ddd9d0d8d73a2f441912508d25a4a82a2
Gitweb:     http://git.kernel.org/tip/9135949ddd9d0d8d73a2f441912508d25a4a82a2
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 1 Oct 2015 01:41:28 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 30 Sep 2015 18:34:34 -0300

perf probe: Begin and end libdwfl report session correctly

Fix a trival bug about libdwfl usage of the report session, it should
explicitly begin and end a report session around dwfl_report_offline().

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20150930164128.3733.59876.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-finder.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 29c43c068..35f905f 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -70,6 +70,7 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *dbg,
 	if (!dbg->dwfl)
 		goto error;
 
+	dwfl_report_begin(dbg->dwfl);
 	dbg->mod = dwfl_report_offline(dbg->dwfl, "", "", fd);
 	if (!dbg->mod)
 		goto error;
@@ -78,6 +79,8 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *dbg,
 	if (!dbg->dbg)
 		goto error;
 
+	dwfl_report_end(dbg->dwfl, NULL, NULL);
+
 	return 0;
 error:
 	if (dbg->dwfl)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1236728

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-09-30 22:20 +0200
Message-ID<qew13-758-7@gated-at.bofh.it>
In reply to#1236528
Em Thu, Oct 01, 2015 at 01:41:26AM +0900, Masami Hiramatsu escreveu:
> Hi,
> 
> Here is a bunch of bugfix patches for perf-probe.
> 
> - Begin and end report session correctly, which fixes
>   a mistake of libdwfl usage.
> - Fix to remove dot suffix from second or latter events
>   which fixes a bug on multiple events on a dot suffixed
>   symbol.
> - Show correct source lines of probes on kmodules, which
>   fixes a bug that perf-probe --list can not find probe
>   points in kernel modules.
> - Fix a segfault bug in debuginfo_cache, which fixes a
>   segfault bug in debuginfo_cache__open.
> - Improve error message when %return is on inlined function
>   is not actual bugfix, but improve an error message.

Thanks, did a really quick review, tested and applied.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web