Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf probe: Fix to get the DW_AT_decl_file and DW_AT_call_file as unsinged data

DWARF version 5 standard Sec 2.14 says that

Any debugging information entry representing the declaration of an object,
module, subprogram or type may have DW_AT_decl_file, DW_AT_decl_line and
DW_AT_decl_column attributes, each of whose value is an unsigned integer
constant.

So it should be an unsigned integer data. Also, even though the standard
doesn't clearly say the DW_AT_call_file is signed or unsigned, the
elfutils (eu-readelf) interprets it as unsigned integer data and it is
natural to handle it as unsigned integer data as same as DW_AT_decl_file.
This changes the DW_AT_call_file as unsigned integer data too.

Fixes: 3f4460a28fb2f73d ("perf probe: Filter out redundant inline-instances")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/166761727445.480106.3738447577082071942.stgit@devnote3
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Masami Hiramatsu (Google) and committed by
Arnaldo Carvalho de Melo
a9dfc46c a9cd6c67

+4 -17
+4 -17
tools/perf/util/dwarf-aux.c
··· 315 315 return 0; 316 316 } 317 317 318 - /* Get attribute and translate it as a sdata */ 319 - static int die_get_attr_sdata(Dwarf_Die *tp_die, unsigned int attr_name, 320 - Dwarf_Sword *result) 321 - { 322 - Dwarf_Attribute attr; 323 - 324 - if (dwarf_attr_integrate(tp_die, attr_name, &attr) == NULL || 325 - dwarf_formsdata(&attr, result) != 0) 326 - return -ENOENT; 327 - 328 - return 0; 329 - } 330 - 331 318 /** 332 319 * die_is_signed_type - Check whether a type DIE is signed or not 333 320 * @tp_die: a DIE of a type ··· 454 467 /* Get the call file index number in CU DIE */ 455 468 static int die_get_call_fileno(Dwarf_Die *in_die) 456 469 { 457 - Dwarf_Sword idx; 470 + Dwarf_Word idx; 458 471 459 - if (die_get_attr_sdata(in_die, DW_AT_call_file, &idx) == 0) 472 + if (die_get_attr_udata(in_die, DW_AT_call_file, &idx) == 0) 460 473 return (int)idx; 461 474 else 462 475 return -ENOENT; ··· 465 478 /* Get the declared file index number in CU DIE */ 466 479 static int die_get_decl_fileno(Dwarf_Die *pdie) 467 480 { 468 - Dwarf_Sword idx; 481 + Dwarf_Word idx; 469 482 470 - if (die_get_attr_sdata(pdie, DW_AT_decl_file, &idx) == 0) 483 + if (die_get_attr_udata(pdie, DW_AT_decl_file, &idx) == 0) 471 484 return (int)idx; 472 485 else 473 486 return -ENOENT;