From 7b0aaff3c67d71857c88fa684cc600bd6329b7c8 Mon Sep 17 00:00:00 2001 From: Aditya Degwekar <adityad@codeaurora.org> Date: Wed, 28 Jan 2015 18:54:33 -0800 Subject: [PATCH] linux-ramdump-parser-v2: Parse socinfo only if needed If user specified --force-hardware, then skip the socinfo parsing to determine the hardware/board information. The user is warned about using the force-hardware option any way. Checking for valid swapper_pg_dir in the vmlinux also ensures that the parsing doesn't trip over when --force-hardware is used along with a bad or stripped vmlinux. Change-Id: Icce1556b39a7533418668a7f38af30f4463c32e5 --- linux-ramdump-parser-v2/ramdump.py | 35 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/linux-ramdump-parser-v2/ramdump.py b/linux-ramdump-parser-v2/ramdump.py index 681daa0..05193f9 100644 --- a/linux-ramdump-parser-v2/ramdump.py +++ b/linux-ramdump-parser-v2/ramdump.py @@ -1,4 +1,4 @@ -# Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. +# Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 and @@ -500,7 +500,14 @@ class RamDump(): # extra 4k is needed for LPAE. If it's 0x5000 below # PAGE_OFFSET + TEXT_OFFSET then we know we're using LPAE. For # non-LPAE it should be 0x4000 below PAGE_OFFSET + TEXT_OFFSET - self.swapper_pg_dir_addr = self.addr_lookup('swapper_pg_dir') - self.page_offset + swapper_pg_dir = self.addr_lookup('swapper_pg_dir') + if swapper_pg_dir is None: + print_out_str('!!! Could not get the swapper page directory!') + print_out_str( + '!!! Your vmlinux is probably wrong for these dumps') + print_out_str('!!! Exiting now') + sys.exit(1) + self.swapper_pg_dir_addr = swapper_pg_dir - self.page_offset self.kernel_text_offset = self.addr_lookup('stext') - self.page_offset pg_dir_size = self.kernel_text_offset - self.swapper_pg_dir_addr if self.arm64: @@ -845,18 +852,6 @@ class RamDump(): return self.read_word(self.tz_addr, False) def get_hw_id(self, add_offset=True): - heap_toc_offset = self.field_offset('struct smem_shared', 'heap_toc') - if heap_toc_offset is None: - print_out_str( - '!!!! Could not get a necessary offset for auto detection!') - print_out_str( - '!!!! Please check the gdb path which is used for offsets!') - print_out_str('!!!! Also check that the vmlinux is not stripped') - print_out_str('!!!! Exiting...') - sys.exit(1) - - smem_heap_entry_size = self.sizeof('struct smem_heap_entry') - offset_offset = self.field_offset('struct smem_heap_entry', 'offset') socinfo_format = -1 socinfo_id = -1 socinfo_version = 0 @@ -866,6 +861,18 @@ class RamDump(): boards = get_supported_boards() if (self.hw_id is None): + heap_toc_offset = self.field_offset('struct smem_shared', 'heap_toc') + if heap_toc_offset is None: + print_out_str( + '!!!! Could not get a necessary offset for auto detection!') + print_out_str( + '!!!! Please check the gdb path which is used for offsets!') + print_out_str('!!!! Also check that the vmlinux is not stripped') + print_out_str('!!!! Exiting...') + sys.exit(1) + + smem_heap_entry_size = self.sizeof('struct smem_heap_entry') + offset_offset = self.field_offset('struct smem_heap_entry', 'offset') for board in boards: trace = board.trace_soc if trace: -- GitLab