cc: Resolve symbols from external debuginfo
Adds support for resolving symbols using external debuginfo files,
which can be retrieved from two locations. First, check the build-id
of the desired binary and look in /usr/lib/debug/.build-id according
to the build-id structure. Second, check the debuglink section of
the desired binary and look in /usr/lib/debug or in the binary's
current directory. These are the rules applied by GDB as well, but
GDB lets the user reconfigure the debug directory path from
/usr/lib/debug to something else; we do not support this.
These changes are based on the following description of how GDB
resolves external debuginfo:
https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
diff --git a/tools/memleak.py b/tools/memleak.py
index e5034cf..80a1dc3 100755
--- a/tools/memleak.py
+++ b/tools/memleak.py
@@ -240,7 +240,7 @@
combined = []
for addr in stack:
combined.append(bpf_program.sym(addr, pid,
- show_module=True, show_address=True))
+ show_module=True, show_offset=True))
alloc_info[info.stack_id] = Allocation(combined,
info.size)
if args.show_allocs:
diff --git a/tools/old/memleak.py b/tools/old/memleak.py
index 0e42a4f..cb28460 100755
--- a/tools/old/memleak.py
+++ b/tools/old/memleak.py
@@ -11,7 +11,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
# Copyright (C) 2016 Sasha Goldshtein.
-from bcc import BPF, SymbolCache
+from bcc import BPF
from time import sleep
from datetime import datetime
import argparse
@@ -24,7 +24,7 @@
return "???"
for i in range(0, info.num_frames):
addr = info.callstack[i]
- stack += " %s ;" % bpf.sym(addr, pid, show_address=True)
+ stack += " %s ;" % bpf.sym(addr, pid, show_offset=True)
return stack
def run_command_get_output(command):
diff --git a/tools/old/stackcount.py b/tools/old/stackcount.py
index 28d25ce..108c800 100755
--- a/tools/old/stackcount.py
+++ b/tools/old/stackcount.py
@@ -145,7 +145,7 @@
print(" ", end="")
if verbose:
print("%-16x " % addr, end="")
- print(b.ksym(addr, show_address=offset))
+ print(b.ksym(addr, show_offset=offset))
# output
exiting = 0 if args.interval else 1
diff --git a/tools/old/stacksnoop.py b/tools/old/stacksnoop.py
index ae89468..9fcc12b 100755
--- a/tools/old/stacksnoop.py
+++ b/tools/old/stacksnoop.py
@@ -119,7 +119,7 @@
(task, pid, cpu, flags, ts, msg) = b.trace_fields()
if msg != "":
(reg, addr) = msg.split(" ")
- ip = b.ksym(int(addr, 16), show_address=offset)
+ ip = b.ksym(int(addr, 16), show_offset=offset)
msg = msg + " " + ip
if verbose:
print("%-18.9f %-12.12s %-6d %-3d %s" % (ts, task, pid, cpu, msg))
diff --git a/tools/stackcount.py b/tools/stackcount.py
index 506c94b..914e7ee 100755
--- a/tools/stackcount.py
+++ b/tools/stackcount.py
@@ -225,7 +225,7 @@
if self.args.verbose:
print("%-16x " % addr, end="")
if self.args.offset:
- print("%s" % self.probe.bpf.sym(addr, pid, show_address=True))
+ print("%s" % self.probe.bpf.sym(addr, pid, show_offset=True))
else:
print("%s" % self.probe.bpf.sym(addr, pid))
diff --git a/tools/stacksnoop.py b/tools/stacksnoop.py
index 52be79b..3cd7062 100755
--- a/tools/stacksnoop.py
+++ b/tools/stacksnoop.py
@@ -120,7 +120,7 @@
print("%-18.9f %s" % (ts, function))
for addr in stack_traces.walk(event.stack_id):
- sym = b.ksym(addr, show_address=offset)
+ sym = b.ksym(addr, show_offset=offset)
print("\t%s" % sym)
print()
diff --git a/tools/trace.py b/tools/trace.py
index 0c294ac..46bc97e 100755
--- a/tools/trace.py
+++ b/tools/trace.py
@@ -458,7 +458,7 @@
stack = list(bpf.get_table(self.stacks_name).walk(stack_id))
for addr in stack:
print(" %s" % (bpf.sym(addr, tgid,
- show_module=True, show_address=True)))
+ show_module=True, show_offset=True)))
def _format_message(self, bpf, tgid, values):
# Replace each %K with kernel sym and %U with user sym in tgid
@@ -467,10 +467,10 @@
user_placeholders = [i for i, t in enumerate(self.types)
if t == 'U']
for kp in kernel_placeholders:
- values[kp] = bpf.ksym(values[kp], show_address=True)
+ values[kp] = bpf.ksym(values[kp], show_offset=True)
for up in user_placeholders:
values[up] = bpf.sym(values[up], tgid,
- show_module=True, show_address=True)
+ show_module=True, show_offset=True)
return self.python_format % tuple(values)
def print_event(self, bpf, cpu, data, size):