Skip to content

Commit

Permalink
scripts/symbolize.py: print path of ELF files
Browse files Browse the repository at this point in the history
Show which file corresponds to each ELF binary in a TA. Symbolic links
are followed, so that dynamic libraries are likely shown with their
user-friendly name (libfoo.so) rather than their UUID (<uuid>.elf) --
see commit 01b8b5c ("TA dev kit: when building a shared library,
create symlink with UUID").

Signed-off-by: Jerome Forissier <[email protected]>
Reviewed-by: Joakim Bech <[email protected]>
  • Loading branch information
jforissier committed May 30, 2018
1 parent 4bca302 commit 095567e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions scripts/symbolize.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,13 @@ def reset(self):
self._regions = [] # [[addr, size, elf_idx, saved line], ...]
self._elfs = {0: ["tee.elf", 0]} # {idx: [uuid, load_addr], ...}


def pretty_print_path(self, path):
if self._strip_path:
return re.sub(re.escape(self._strip_path) + '/*', '', path)
return path


def write(self, line):
if self._call_stack_found:
match = re.search(STACK_ADDR_RE, line)
Expand All @@ -339,9 +346,7 @@ def write(self, line):
self._out.write(line[:pre])
self._out.write(addr)
res = self.resolve(addr)
if self._strip_path:
res = re.sub(re.escape(self._strip_path) + '/*', '',
res)
res = self.pretty_print_path(res)
self._out.write(' ' + res)
self._out.write(line[post:])
return
Expand Down Expand Up @@ -385,7 +390,13 @@ def write(self, line):
for k in self._elfs:
e = self._elfs[k]
if (len(e) >= 3):
self._out.write(e[2])
self._out.write(e[2].strip())
elf = self.get_elf(e[0])
if elf:
rpath = os.path.realpath(elf)
path = self.pretty_print_path(rpath)
self._out.write(' (' + path + ')')
self._out.write('\n')
# Here is a good place to resolve the abort address because we
# have all the information we need
if self._saved_abort_line:
Expand Down

0 comments on commit 095567e

Please sign in to comment.