From 333199e1666105b3b0cc44279840b9e465e8dbb7 Mon Sep 17 00:00:00 2001 From: Patrick Daly <pdaly@codeaurora.org> Date: Mon, 13 Oct 2014 12:58:21 -0700 Subject: [PATCH] lrdp-v2: Support kernel 3.14 log format Kernel change 62e32ac3505a0cab1c5ef8ea2c0eab3b26ed855f renamed 'struct log' to 'struct printk_log'. Detect which kernel version is being parsed and use the appropriate struct name. Change-Id: I1a92623e8b4167f390d09051a52e6411ae3901ee --- linux-ramdump-parser-v2/dmesglib.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/linux-ramdump-parser-v2/dmesglib.py b/linux-ramdump-parser-v2/dmesglib.py index d480ae7..a9d00e5 100644 --- a/linux-ramdump-parser-v2/dmesglib.py +++ b/linux-ramdump-parser-v2/dmesglib.py @@ -20,9 +20,13 @@ class DmesgLib(object): self.ramdump = ramdump self.wrap_cnt = 0 self.outfile = outfile + if (self.ramdump.sizeof('struct printk_log') is None): + self.struct_name = 'struct log' + else: + self.struct_name = 'struct printk_log' def log_from_idx(self, idx, logbuf): - len_offset = self.ramdump.field_offset('struct log', 'len') + len_offset = self.ramdump.field_offset(self.struct_name, 'len') msg = logbuf + idx msg_len = self.ramdump.read_u16(msg + len_offset) @@ -32,7 +36,7 @@ class DmesgLib(object): return msg def log_next(self, idx, logbuf): - len_offset = self.ramdump.field_offset('struct log', 'len') + len_offset = self.ramdump.field_offset(self.struct_name, 'len') msg = idx msg_len = self.ramdump.read_u16(msg + len_offset) @@ -52,10 +56,10 @@ class DmesgLib(object): first_idx_addr = self.ramdump.addr_lookup('log_first_idx') last_idx_addr = self.ramdump.addr_lookup('log_next_idx') logbuf_addr = self.ramdump.read_word(self.ramdump.addr_lookup('log_buf')) - time_offset = self.ramdump.field_offset('struct log', 'ts_nsec') - len_offset = self.ramdump.field_offset('struct log', 'len') - text_len_offset = self.ramdump.field_offset('struct log', 'text_len') - log_size = self.ramdump.sizeof('struct log') + time_offset = self.ramdump.field_offset(self.struct_name, 'ts_nsec') + len_offset = self.ramdump.field_offset(self.struct_name, 'len') + text_len_offset = self.ramdump.field_offset(self.struct_name, 'text_len') + log_size = self.ramdump.sizeof(self.struct_name) first_idx = self.ramdump.read_u32(first_idx_addr) last_idx = self.ramdump.read_u32(last_idx_addr) @@ -77,5 +81,7 @@ class DmesgLib(object): self.extract_dmesg_binary() elif re.search('3\.10\.\d', self.ramdump.version) is not None: self.extract_dmesg_binary() + elif re.search('3\.14\.\d', self.ramdump.version) is not None: + self.extract_dmesg_binary() else: self.extract_dmesg_flat() -- GitLab