perf probe: Fix to make offset to signed value
PATCH 1/2 perf probe: Fix to make offset to signed value
Fix to make dereference offset intmax_t from uintmax_t, because it can be minus value (e.g. local variable's offset from frame pointer).
---
tools/perf/util/probe-finder.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +2 -2
@@ -333,8 +333,8 @@ static void show_location(Dwarf_Op *op, struct probe_finder *pf)die ("%u exceeds max register number." , regn);if (deref) - ret =snprintf (pf->buf, pf->len," %s=+%ju(%s)" , - pf->var, (uintmax_t )offs, regs); + ret =snprintf (pf->buf, pf->len," %s=%+jd(%s)" , + pf->var, (intmax_t )offs, regs);else ret =snprintf (pf->buf, pf->len," %s=%s" , pf->var, regs);DIE_IF (ret <0 );
Signature · 2 lines
Masami Hiramatsu e-mail: [email protected]
PATCH 2/2 perf probe: Use origial address instead of CU-based address
Use original address for looking up the location of variables for dwarf_getlocation_addr() instead of CU-based address.
---
tools/perf/util/probe-finder.c | 11 ++--------- tools/perf/util/probe-finder.h | 1 - 2 files changed, 2 insertions(+), 10 deletions(-)
tools/perf/util/probe-finder.c +2 -9
@@ -352,8 +352,7 @@ static void show_variable(Dwarf_Die *vr_die, struct probe_finder *pf)if (dwarf_attr (vr_die, DW_AT_location, &attr) ==NULL ) goto error;/* TODO: handle more than 1 exprs */ - ret =dwarf_getlocation_addr (&attr, (pf->addr - pf->cu_base), - &expr, &nexpr,1 ); + ret =dwarf_getlocation_addr (&attr, pf->addr, &expr, &nexpr,1 );if (ret <=0 || nexpr ==0 ) goto error;
@@ -437,8 +436,7 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)/* Get the frame base attribute/ops */ dwarf_attr (sp_die, DW_AT_frame_base, &fb_attr); - ret =dwarf_getlocation_addr (&fb_attr, (pf->addr - pf->cu_base), - &pf->fb_ops, &nops,1 ); + ret =dwarf_getlocation_addr (&fb_attr, pf->addr, &pf->fb_ops, &nops,1 );if (ret <=0 || nops ==0 ) pf->fb_ops =NULL ;
@@ -644,7 +642,6 @@ static void find_probe_point_by_func(struct probe_finder *pf)int find_probe_point (int fd,struct probe_point *pp) {struct probe_finder pf = {.pp = pp}; -int ret;Dwarf_Off off, noff;size_t cuhl;Dwarf_Die *diep;
@@ -671,10 +668,6 @@ int find_probe_point(int fd, struct probe_point *pp) pf.fname =NULL ;if (!pp->file || pf.fname) { -/* Save CU base address (for frame_base) */ - ret =dwarf_lowpc (&pf.cu_die, &pf.cu_base); -if (ret !=0 ) - pf.cu_base =0 ;if (pp->function)find_probe_point_by_func (&pf);else if (pp->lazy_line)
tools/perf/util/probe-finder.h +0 -1
@@ -71,7 +71,6 @@ struct probe_finder {/* For variable searching */ Dwarf_Op *fb_ops;/* Frame base attribute */ -Dwarf_Addr cu_base;/* Current CU base address */ const char *var;/* Current variable name */ char *buf;/* Current output buffer */ int len;/* Length of output buffer */
Signature · 2 lines
Masami Hiramatsu e-mail: [email protected]
[tip:perf/urgent] perf probe: Use original address instead of CU-based address
Commit-ID: d0cb4260f899d07462d49fc67e29f2438dbaca2f Gitweb: http://git.kernel.org/tip/d0cb4260f899d07462d49fc67e29f2438dbaca2f Author: Masami Hiramatsu <[email protected]> AuthorDate: Mon, 15 Mar 2010 13:02:35 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 16 Mar 2010 10:02:19 +0100
perf probe: Use original address instead of CU-based address
Use original address for looking up the location of variables for dwarf_getlocation_addr() instead of CU-based address.
LKML-Reference: <[email protected]>
--- tools/perf/util/probe-finder.c | 11 ++--------- tools/perf/util/probe-finder.h | 1 - 2 files changed, 2 insertions(+), 10 deletions(-)
tools/perf/util/probe-finder.c +2 -9
@@ -352,8 +352,7 @@ static void show_variable(Dwarf_Die *vr_die, struct probe_finder *pf)if (dwarf_attr (vr_die, DW_AT_location, &attr) ==NULL ) goto error;/* TODO: handle more than 1 exprs */ - ret =dwarf_getlocation_addr (&attr, (pf->addr - pf->cu_base), - &expr, &nexpr,1 ); + ret =dwarf_getlocation_addr (&attr, pf->addr, &expr, &nexpr,1 );if (ret <=0 || nexpr ==0 ) goto error;
@@ -437,8 +436,7 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)/* Get the frame base attribute/ops */ dwarf_attr (sp_die, DW_AT_frame_base, &fb_attr); - ret =dwarf_getlocation_addr (&fb_attr, (pf->addr - pf->cu_base), - &pf->fb_ops, &nops,1 ); + ret =dwarf_getlocation_addr (&fb_attr, pf->addr, &pf->fb_ops, &nops,1 );if (ret <=0 || nops ==0 ) pf->fb_ops =NULL ;
@@ -644,7 +642,6 @@ static void find_probe_point_by_func(struct probe_finder *pf)int find_probe_point (int fd,struct probe_point *pp) {struct probe_finder pf = {.pp = pp}; -int ret;Dwarf_Off off, noff;size_t cuhl;Dwarf_Die *diep;
@@ -671,10 +668,6 @@ int find_probe_point(int fd, struct probe_point *pp) pf.fname =NULL ;if (!pp->file || pf.fname) { -/* Save CU base address (for frame_base) */ - ret =dwarf_lowpc (&pf.cu_die, &pf.cu_base); -if (ret !=0 ) - pf.cu_base =0 ;if (pp->function)find_probe_point_by_func (&pf);else if (pp->lazy_line)
tools/perf/util/probe-finder.h +0 -1
@@ -71,7 +71,6 @@ struct probe_finder {/* For variable searching */ Dwarf_Op *fb_ops;/* Frame base attribute */ -Dwarf_Addr cu_base;/* Current CU base address */ const char *var;/* Current variable name */ char *buf;/* Current output buffer */ int len;/* Length of output buffer */
[tip:perf/urgent] perf probe: Fix offset to allow signed value
In reply to Masami HiramatsuCommit-ID: 67c7ff7c56f38a8ab338fbbfe366621ce6303ba1 Gitweb: http://git.kernel.org/tip/67c7ff7c56f38a8ab338fbbfe366621ce6303ba1 Author: Masami Hiramatsu <[email protected]> AuthorDate: Mon, 15 Mar 2010 13:02:28 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 16 Mar 2010 10:02:18 +0100
perf probe: Fix offset to allow signed value
Fix dereference offset to intmax_t from uintmax_t, because it can have negative values (for example local variable's offset from frame pointer).
LKML-Reference: <[email protected]>
--- tools/perf/util/probe-finder.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +2 -2
@@ -333,8 +333,8 @@ static void show_location(Dwarf_Op *op, struct probe_finder *pf)die ("%u exceeds max register number." , regn);if (deref) - ret =snprintf (pf->buf, pf->len," %s=+%ju(%s)" , - pf->var, (uintmax_t )offs, regs); + ret =snprintf (pf->buf, pf->len," %s=%+jd(%s)" , + pf->var, (intmax_t )offs, regs);else ret =snprintf (pf->buf, pf->len," %s=%s" , pf->var, regs);DIE_IF (ret <0 );