diff options
author | Jerome Forissier <jerome@forissier.org> | 2020-02-12 14:48:03 +0100 |
---|---|---|
committer | Jérôme Forissier <jerome@forissier.org> | 2020-02-13 12:58:39 +0100 |
commit | 24778dedd4c2ed35390d491c9f3538de7d2daf47 (patch) | |
tree | 22929608ab7ce357ff4c75e8fe87b6723776b15a /scripts | |
parent | ba84a3f5c136f3ed3fefe782c9666928b729bb52 (diff) |
symbolize.py: fix analysis of mixed 32/64 bit ftrace dumps
When an ftrace file that contains both user space and kernel space
calls is analyzed by symbolize.py, any address can be 32 or 64 bits.
For each address, the resolve() function first obtains the path to the
proper ELF file, then calls spawn_addr2line() to make sure we have a
process that is capable of resolving the address (i.e., either
arm-linux-gnueabihf-addr2line or aarch64-linux-gnu-addr2line).
spawn_addr2line() then calls arch_prefix() to obtain the tool's prefix.
Unfortunately, the ELF file is not supplied, so arch_prefix() assumes
that the first entry in the global list of files is suitable. While this
is true when symbolizing homogeneous dumps (i.e., kernel stacks or
TA + multiple libraries), it does not work for mixed ftrace logs.
This patch addresses the issue by adding the ELF file as an argument to
spawn_addr2line().
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/symbolize.py | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/scripts/symbolize.py b/scripts/symbolize.py index a6224755..88eac58c 100755 --- a/scripts/symbolize.py +++ b/scripts/symbolize.py @@ -125,17 +125,11 @@ class Symbolizer(object): if elf: return elf[0] - def set_arch(self): - if self._arch: - return + def set_arch(self, elf): self._arch = os.getenv('CROSS_COMPILE') if self._arch: return - elf = self.get_elf(self._elfs[0][0]) - if elf is None: - return - p = subprocess.Popen(['file', self.get_elf(self._elfs[0][0])], - stdout=subprocess.PIPE) + p = subprocess.Popen(['file', elf], stdout=subprocess.PIPE) output = p.stdout.readlines() p.terminate() if b'ARM aarch64,' in output[0]: @@ -143,8 +137,8 @@ class Symbolizer(object): elif b'ARM,' in output[0]: self._arch = 'arm-linux-gnueabihf-' - def arch_prefix(self, cmd): - self.set_arch() + def arch_prefix(self, cmd, elf): + self.set_arch(elf) if self._arch is None: return '' return self._arch + cmd @@ -160,7 +154,7 @@ class Symbolizer(object): elf = self.get_elf(elf_name) if not elf: return - cmd = self.arch_prefix('addr2line') + cmd = self.arch_prefix('addr2line', elf) if not cmd: return self._addr2line = self.my_Popen([cmd, '-f', '-p', '-e', elf]) @@ -229,7 +223,7 @@ class Symbolizer(object): if elf_name is None: return '' elf = self.get_elf(elf_name) - cmd = self.arch_prefix('nm') + cmd = self.arch_prefix('nm', elf) if not reladdr or not elf or not cmd: return '' ireladdr = int(reladdr, 16) @@ -270,7 +264,7 @@ class Symbolizer(object): if elf_name is None: return '' elf = self.get_elf(elf_name) - cmd = self.arch_prefix('objdump') + cmd = self.arch_prefix('objdump', elf) if not reladdr or not elf or not cmd: return '' iaddr = int(reladdr, 16) @@ -317,7 +311,7 @@ class Symbolizer(object): if elf_name in self._sections: return elf = self.get_elf(elf_name) - cmd = self.arch_prefix('objdump') + cmd = self.arch_prefix('objdump', elf) if not elf or not cmd: return self._sections[elf_name] = [] |