forked from M-Labs/artiq
Correctly display backtraces that contain inlined functions.
This commit is contained in:
parent
442673076f
commit
cf41890255
|
@ -151,20 +151,31 @@ class Target:
|
||||||
if addresses == []:
|
if addresses == []:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# Addresses point one instruction past the jump; offset them back by 1.
|
offset_addresses = [hex(addr) for addr in addresses]
|
||||||
offset_addresses = [hex(addr - 1) for addr in addresses]
|
with RunTool([self.triple + "-addr2line", "--addresses", "--functions", "--inlines",
|
||||||
with RunTool([self.triple + "-addr2line", "--functions", "--inlines",
|
|
||||||
"--exe={library}"] + offset_addresses,
|
"--exe={library}"] + offset_addresses,
|
||||||
library=library) \
|
library=library) \
|
||||||
as results:
|
as results:
|
||||||
lines = results["__stdout__"].rstrip().split("\n")
|
lines = iter(results["__stdout__"].rstrip().split("\n"))
|
||||||
backtrace = []
|
backtrace = []
|
||||||
for function_name, location, address in zip(lines[::2], lines[1::2], addresses):
|
while True:
|
||||||
|
try:
|
||||||
|
address_or_function = next(lines)
|
||||||
|
except StopIteration:
|
||||||
|
break
|
||||||
|
if address_or_function[:2] == "0x":
|
||||||
|
address = int(address_or_function[2:], 16)
|
||||||
|
function = next(lines)
|
||||||
|
else:
|
||||||
|
address = backtrace[-1][4] # inlined
|
||||||
|
function = address_or_function
|
||||||
|
location = next(lines)
|
||||||
|
|
||||||
filename, line = location.rsplit(":", 1)
|
filename, line = location.rsplit(":", 1)
|
||||||
if filename == "??":
|
if filename == "??" or filename == "<synthesized>":
|
||||||
continue
|
continue
|
||||||
# can't get column out of addr2line D:
|
# can't get column out of addr2line D:
|
||||||
backtrace.append((filename, int(line), -1, function_name, address))
|
backtrace.append((filename, int(line), -1, function, address))
|
||||||
return backtrace
|
return backtrace
|
||||||
|
|
||||||
class NativeTarget(Target):
|
class NativeTarget(Target):
|
||||||
|
|
|
@ -27,6 +27,7 @@ class CoreException:
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
lines = []
|
lines = []
|
||||||
lines.append("Core Device Traceback (most recent call last):")
|
lines.append("Core Device Traceback (most recent call last):")
|
||||||
|
last_address = 0
|
||||||
for (filename, line, column, function, address) in self.traceback:
|
for (filename, line, column, function, address) in self.traceback:
|
||||||
stub_globals = {"__name__": filename, "__loader__": source_loader}
|
stub_globals = {"__name__": filename, "__loader__": source_loader}
|
||||||
source_line = linecache.getline(filename, line, stub_globals)
|
source_line = linecache.getline(filename, line, stub_globals)
|
||||||
|
@ -34,8 +35,11 @@ class CoreException:
|
||||||
|
|
||||||
if address is None:
|
if address is None:
|
||||||
formatted_address = ""
|
formatted_address = ""
|
||||||
|
elif address == last_address:
|
||||||
|
formatted_address = " (inlined)"
|
||||||
else:
|
else:
|
||||||
formatted_address = " (RA=0x{:x})".format(address)
|
formatted_address = " (RA=0x{:x})".format(address)
|
||||||
|
last_address = address
|
||||||
|
|
||||||
filename = filename.replace(artiq_dir, "<artiq>")
|
filename = filename.replace(artiq_dir, "<artiq>")
|
||||||
if column == -1:
|
if column == -1:
|
||||||
|
|
Loading…
Reference in New Issue