forked from M-Labs/artiq
compiler: demangle symbols.
In future commits we'll add Itanium C++ ABI style mangling to ARTIQ emitted function names.
This commit is contained in:
parent
8bff8075de
commit
c94c411fd5
|
@ -196,7 +196,7 @@ class Target:
|
||||||
# the backtrace entry should point at.
|
# the backtrace entry should point at.
|
||||||
offset_addresses = [hex(addr - 1) 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", "--addresses", "--functions", "--inlines",
|
||||||
"--exe={library}"] + offset_addresses,
|
"--demangle", "--exe={library}"] + offset_addresses,
|
||||||
library=library) \
|
library=library) \
|
||||||
as results:
|
as results:
|
||||||
lines = iter(results["__stdout__"].rstrip().split("\n"))
|
lines = iter(results["__stdout__"].rstrip().split("\n"))
|
||||||
|
@ -221,6 +221,10 @@ class Target:
|
||||||
backtrace.append((filename, int(line), -1, function, address))
|
backtrace.append((filename, int(line), -1, function, address))
|
||||||
return backtrace
|
return backtrace
|
||||||
|
|
||||||
|
def demangle(self, names):
|
||||||
|
with RunTool([self.triple + "-c++filt"] + names) as results:
|
||||||
|
return results["__stdout__"].rstrip().split("\n")
|
||||||
|
|
||||||
class NativeTarget(Target):
|
class NativeTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
|
@ -504,7 +504,7 @@ class CommGeneric:
|
||||||
|
|
||||||
self._write_flush()
|
self._write_flush()
|
||||||
|
|
||||||
def _serve_exception(self, object_map, symbolizer):
|
def _serve_exception(self, object_map, symbolizer, demangler):
|
||||||
name = self._read_string()
|
name = self._read_string()
|
||||||
message = self._read_string()
|
message = self._read_string()
|
||||||
params = [self._read_int64() for _ in range(3)]
|
params = [self._read_int64() for _ in range(3)]
|
||||||
|
@ -517,7 +517,7 @@ class CommGeneric:
|
||||||
backtrace = [self._read_int32() for _ in range(self._read_int32())]
|
backtrace = [self._read_int32() for _ in range(self._read_int32())]
|
||||||
|
|
||||||
traceback = list(reversed(symbolizer(backtrace))) + \
|
traceback = list(reversed(symbolizer(backtrace))) + \
|
||||||
[(filename, line, column, function, None)]
|
[(filename, line, column, *demangler([function]), None)]
|
||||||
core_exn = exceptions.CoreException(name, message, params, traceback)
|
core_exn = exceptions.CoreException(name, message, params, traceback)
|
||||||
|
|
||||||
if core_exn.id == 0:
|
if core_exn.id == 0:
|
||||||
|
@ -529,13 +529,13 @@ class CommGeneric:
|
||||||
python_exn.artiq_core_exception = core_exn
|
python_exn.artiq_core_exception = core_exn
|
||||||
raise python_exn
|
raise python_exn
|
||||||
|
|
||||||
def serve(self, object_map, symbolizer):
|
def serve(self, object_map, symbolizer, demangler):
|
||||||
while True:
|
while True:
|
||||||
self._read_header()
|
self._read_header()
|
||||||
if self._read_type == _D2HMsgType.RPC_REQUEST:
|
if self._read_type == _D2HMsgType.RPC_REQUEST:
|
||||||
self._serve_rpc(object_map)
|
self._serve_rpc(object_map)
|
||||||
elif self._read_type == _D2HMsgType.KERNEL_EXCEPTION:
|
elif self._read_type == _D2HMsgType.KERNEL_EXCEPTION:
|
||||||
self._serve_exception(object_map, symbolizer)
|
self._serve_exception(object_map, symbolizer, demangler)
|
||||||
elif self._read_type == _D2HMsgType.WATCHDOG_EXPIRED:
|
elif self._read_type == _D2HMsgType.WATCHDOG_EXPIRED:
|
||||||
raise exceptions.WatchdogExpired
|
raise exceptions.WatchdogExpired
|
||||||
elif self._read_type == _D2HMsgType.CLOCK_FAILURE:
|
elif self._read_type == _D2HMsgType.CLOCK_FAILURE:
|
||||||
|
|
|
@ -92,7 +92,8 @@ class Core:
|
||||||
stripped_library = target.strip(library)
|
stripped_library = target.strip(library)
|
||||||
|
|
||||||
return stitcher.object_map, stripped_library, \
|
return stitcher.object_map, stripped_library, \
|
||||||
lambda addresses: target.symbolize(library, addresses)
|
lambda addresses: target.symbolize(library, addresses), \
|
||||||
|
lambda symbols: target.demangle(symbols)
|
||||||
except diagnostic.Error as error:
|
except diagnostic.Error as error:
|
||||||
raise CompileError(error.diagnostic) from error
|
raise CompileError(error.diagnostic) from error
|
||||||
|
|
||||||
|
@ -102,7 +103,8 @@ class Core:
|
||||||
nonlocal result
|
nonlocal result
|
||||||
result = new_result
|
result = new_result
|
||||||
|
|
||||||
object_map, kernel_library, symbolizer = self.compile(function, args, kwargs, set_result)
|
object_map, kernel_library, symbolizer, demangler = \
|
||||||
|
self.compile(function, args, kwargs, set_result)
|
||||||
|
|
||||||
if self.first_run:
|
if self.first_run:
|
||||||
self.comm.check_ident()
|
self.comm.check_ident()
|
||||||
|
@ -111,7 +113,7 @@ class Core:
|
||||||
|
|
||||||
self.comm.load(kernel_library)
|
self.comm.load(kernel_library)
|
||||||
self.comm.run()
|
self.comm.run()
|
||||||
self.comm.serve(object_map, symbolizer)
|
self.comm.serve(object_map, symbolizer, demangler)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue