Skip to content

Commit a9ffd04

Browse files
mhiramatacmel
authored andcommitted
perf probe: Change function definition check due to broken DWARF
Since some gcc generates a broken DWARF which lacks DW_AT_declaration attribute from the subprogram DIE of function prototype. (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97060) So, in addition to the DW_AT_declaration check, we also check the subprogram DIE has DW_AT_inline or actual entry pc. Committer testing: # cat /etc/fedora-release Fedora release 33 (Thirty Three) # Before: # perf test vfs_getname 78: Use vfs_getname probe to get syscall args filenames : FAILED! 79: Check open filename arg using perf trace + vfs_getname : FAILED! 81: Add vfs_getname probe to get syscall args filenames : FAILED! # After: # perf test vfs_getname 78: Use vfs_getname probe to get syscall args filenames : Ok 79: Check open filename arg using perf trace + vfs_getname : Ok 81: Add vfs_getname probe to get syscall args filenames : Ok # Reported-by: Thomas Richter <tmricht@linux.ibm.com> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Sumanth Korikkar <sumanthk@linux.ibm.com> Link: http://lore.kernel.org/lkml/160645613571.2824037.7441351537890235895.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent ab4200c commit a9ffd04

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

tools/perf/util/dwarf-aux.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,25 @@ bool die_is_signed_type(Dwarf_Die *tp_die)
356356
bool die_is_func_def(Dwarf_Die *dw_die)
357357
{
358358
Dwarf_Attribute attr;
359+
Dwarf_Addr addr = 0;
360+
361+
if (dwarf_tag(dw_die) != DW_TAG_subprogram)
362+
return false;
363+
364+
if (dwarf_attr(dw_die, DW_AT_declaration, &attr))
365+
return false;
359366

360-
return (dwarf_tag(dw_die) == DW_TAG_subprogram &&
361-
dwarf_attr(dw_die, DW_AT_declaration, &attr) == NULL);
367+
/*
368+
* DW_AT_declaration can be lost from function declaration
369+
* by gcc's bug #97060.
370+
* So we need to check this subprogram DIE has DW_AT_inline
371+
* or an entry address.
372+
*/
373+
if (!dwarf_attr(dw_die, DW_AT_inline, &attr) &&
374+
die_entrypc(dw_die, &addr) < 0)
375+
return false;
376+
377+
return true;
362378
}
363379

364380
/**

tools/perf/util/probe-finder.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,8 +1885,7 @@ static int line_range_search_cb(Dwarf_Die *sp_die, void *data)
18851885
if (lr->file && strtailcmp(lr->file, dwarf_decl_file(sp_die)))
18861886
return DWARF_CB_OK;
18871887

1888-
if (die_is_func_def(sp_die) &&
1889-
die_match_name(sp_die, lr->function)) {
1888+
if (die_match_name(sp_die, lr->function) && die_is_func_def(sp_die)) {
18901889
lf->fname = dwarf_decl_file(sp_die);
18911890
dwarf_decl_line(sp_die, &lr->offset);
18921891
pr_debug("fname: %s, lineno:%d\n", lf->fname, lr->offset);

0 commit comments

Comments
 (0)