On 15/10/25 23:12, Pierrick Bouvier wrote:
On 10/15/25 2:02 PM, Pierrick Bouvier wrote:
On 10/15/25 1:40 PM, Philippe Mathieu-Daudé wrote:
On 13/10/25 23:39, Pierrick Bouvier wrote:
Enhance uftrace_symbols.py to generate .dbg files, containing
source location for every symbol present in .sym file.
It allows to use uftrace {replay,dump} --srcline and show origin of

`uftrace {replay,dump} --srcline`

functions, connecting trace to original source code.

It was first implemented with pyelftools DWARF parser, which was way
to slow (~minutes) to get locations for every symbol in the linux

s/to/too/

kernel. Thus, we use addr2line instead, which runs in seconds.

As well, there were some bugs with latest pyelftools release,
requiring to run master version, which is not installable with pip.
Thus, since we now require binutils (addr2line), we can ditch pyelftools
based implementation and simply rely on nm to get symbols information,

`nm`

which is faster and better.

Signed-off-by: Pierrick Bouvier <[email protected]>
---
    contrib/plugins/uftrace_symbols.py | 108 ++++++++++++++++++ +----------
    1 file changed, 72 insertions(+), 36 deletions(-)


+def get_symbols(elf_file):
+    symbols=[]
+    try:
+        out = subprocess.check_output(['nm', '--print-size', elf_file],
+                                      stderr=subprocess.STDOUT,
+                                      text=True)

Nitpicking, we might be using cross-compiled `nm`, so maybe not hardcode
the binary name.


No blocking comments:
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>


Thanks Philippe.

For the cross compiled tools, I'm not really sure it's worth making this
more complex. Having tooling for a cross architecture is an advanced
setup, and I think it's fair to expect someone to have binutils
installed if they have any cross compiler and cross binutils.
Plus, they can always create a symlink if needed.


As well, nm and addr2line are architecture agnostic, as they just access ELF symtab and DWARF information, so you don't need an aarch64-*-{nm, addr2line} to extract information from an aarch64 binary.

Right, good point.


Reply via email to