Skip to content

Commit

Permalink
bugfix: don't crash when c++filt is not available in the toolchain
Browse files Browse the repository at this point in the history
The PIC xc16 toolchain does not include any c++ tools and puncover crashed while trying to open the elf file. This fixes it.
  • Loading branch information
sarfata committed Oct 7, 2019
1 parent bba9fb7 commit d810c45
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions puncover/gcc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def gcc_tool_path(self, name):
return path

def gcc_tool_lines(self, name, args, cwd=None):
proc = subprocess.Popen([self.gcc_tool_path(name)] + args, stdout=subprocess.PIPE, cwd=cwd)
proc = subprocess.Popen(
[self.gcc_tool_path(name)] + args, stdout=subprocess.PIPE, cwd=cwd)
return proc.stdout.readlines()

def get_assembly_lines(self, elf_file):
Expand All @@ -41,7 +42,12 @@ def chunks(l):
for i in range(0, len(l), chunk_size):
yield l[i:i + chunk_size]

lines_list = [self.gcc_tool_lines('c++filt', c) for c in chunks(symbol_names)]
lines_list = [c for c in chunks(symbol_names)]
try:
lines_list = [self.gcc_tool_lines(
'c++filt', c) for c in chunks(symbol_names)]
except Exception as e:
print("Unable to demangle C++ symbol names: {}".format(e))
lines = list(itertools.chain.from_iterable(lines_list))
demangled = list(s.rstrip() for s in lines)

Expand Down

0 comments on commit d810c45

Please sign in to comment.