2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

compiler: demangle symbols.

In future commits we'll add Itanium C++ ABI style mangling to ARTIQ
emitted function names.
This commit is contained in:
whitequark 2016-05-14 12:52:28 +00:00
parent 8bff8075de
commit c94c411fd5
3 changed files with 14 additions and 8 deletions

View File

@ -196,7 +196,7 @@ class Target:
# the backtrace entry should point at.
offset_addresses = [hex(addr - 1) for addr in addresses]
with RunTool([self.triple + "-addr2line", "--addresses", "--functions", "--inlines",
"--exe={library}"] + offset_addresses,
"--demangle", "--exe={library}"] + offset_addresses,
library=library) \
as results:
lines = iter(results["__stdout__"].rstrip().split("\n"))
@ -221,6 +221,10 @@ class Target:
backtrace.append((filename, int(line), -1, function, address))
return backtrace
def demangle(self, names):
with RunTool([self.triple + "-c++filt"] + names) as results:
return results["__stdout__"].rstrip().split("\n")
class NativeTarget(Target):
def __init__(self):
super().__init__()

View File

@ -504,7 +504,7 @@ class CommGeneric:
self._write_flush()
def _serve_exception(self, object_map, symbolizer):
def _serve_exception(self, object_map, symbolizer, demangler):
name = self._read_string()
message = self._read_string()
params = [self._read_int64() for _ in range(3)]
@ -517,7 +517,7 @@ class CommGeneric:
backtrace = [self._read_int32() for _ in range(self._read_int32())]
traceback = list(reversed(symbolizer(backtrace))) + \
[(filename, line, column, function, None)]
[(filename, line, column, *demangler([function]), None)]
core_exn = exceptions.CoreException(name, message, params, traceback)
if core_exn.id == 0:
@ -529,13 +529,13 @@ class CommGeneric:
python_exn.artiq_core_exception = core_exn
raise python_exn
def serve(self, object_map, symbolizer):
def serve(self, object_map, symbolizer, demangler):
while True:
self._read_header()
if self._read_type == _D2HMsgType.RPC_REQUEST:
self._serve_rpc(object_map)
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:
raise exceptions.WatchdogExpired
elif self._read_type == _D2HMsgType.CLOCK_FAILURE:

View File

@ -92,7 +92,8 @@ class Core:
stripped_library = target.strip(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:
raise CompileError(error.diagnostic) from error
@ -102,7 +103,8 @@ class Core:
nonlocal 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:
self.comm.check_ident()
@ -111,7 +113,7 @@ class Core:
self.comm.load(kernel_library)
self.comm.run()
self.comm.serve(object_map, symbolizer)
self.comm.serve(object_map, symbolizer, demangler)
return result