From 5d521765ac3fd463517d98967c7c0d6c8ce08955 Mon Sep 17 00:00:00 2001 From: Soumen Ghosh <soumeng@codeaurora.org> Date: Thu, 3 Aug 2017 10:13:11 +0530 Subject: [PATCH] lrdp-v2: vmlinux linux banner timestamp matching with ramdump Read the linux banner data from vmlinux rodata section. Also read the linux banner data from ramump. Do a matching of both the data. If success then ramparser will go ahead and proces further Change-Id: I1b9245f1a4fcc9cdff0a3bfb7293b2385981feba --- linux-ramdump-parser-v2/gdbmi.py | 14 ++++++++++++++ linux-ramdump-parser-v2/ramdump.py | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) mode change 100755 => 100644 linux-ramdump-parser-v2/gdbmi.py diff --git a/linux-ramdump-parser-v2/gdbmi.py b/linux-ramdump-parser-v2/gdbmi.py old mode 100755 new mode 100644 index 25bc112..5501c4d --- a/linux-ramdump-parser-v2/gdbmi.py +++ b/linux-ramdump-parser-v2/gdbmi.py @@ -291,6 +291,20 @@ class GdbMI(object): result = self._run_for_one('print /d {0}'.format(symbol)) return int(result.split(' ')[-1], 10) + + def get_value_of_string(self, symbol): + """Returns the value of a symbol (as a string)""" + cmd = 'print /s {0}'.format(symbol) + result = self._run(cmd) + if len(result.lines) == 0: + raise GdbMIException( + cmd, '\n'.join(result.lines + result.oob_lines)) + match = re.search(r'^[$]\d+ = \\"(.*)(\\\\n\\")', result.lines[0]) + if match: + return match.group(1) + return None + + if __name__ == '__main__': if len(sys.argv) != 3: print('Usage: gdbmi.py gdb_path elf') diff --git a/linux-ramdump-parser-v2/ramdump.py b/linux-ramdump-parser-v2/ramdump.py index 23d0a1c..07e3b56 100644 --- a/linux-ramdump-parser-v2/ramdump.py +++ b/linux-ramdump-parser-v2/ramdump.py @@ -831,7 +831,18 @@ class RamDump(): print_out_str('Linux Banner: ' + b.rstrip()) print_out_str('version = {0}'.format(self.version)) - return True + vm_v = self.gdbmi.get_value_of_string('linux_banner') + if vm_v is None: + print_out_str('!!! Could not read banner address from vmlinux!') + return False + if str(vm_v) in str(b): + print_out_str("Linux banner from vmlinux = %s" % vm_v) + print_out_str("Linux banner from dump = %s" % b) + return True + else: + print_out_str("Expected Linux banner = %s" % vm_v) + print_out_str("But Linux banner got = %s" % b) + return False else: print_out_str('!!! Could not lookup banner address') return False -- GitLab