Skip to content
Snippets Groups Projects
Commit 6a61e3dd authored by Liam Mark's avatar Liam Mark
Browse files

linux-ramdump-parser-v2: support empty lists

Allow empty lists to identified and successfully iterated.

Change-Id: Ifa13e3a8acffa2672163bd4d4ba1cb71a5c189fd
parent 9d2d1113
No related branches found
No related tags found
No related merge requests found
...@@ -32,12 +32,26 @@ class ListWalker(object): ...@@ -32,12 +32,26 @@ class ListWalker(object):
self.last_node = node_addr self.last_node = node_addr
self.seen_nodes = [] self.seen_nodes = []
def is_empty(self):
"""Return True if the list is empty, False otherwise.
"""
next_node_addr = self.last_node + self.ram_dump.field_offset('struct list_head', 'next')
next_node = self.ram_dump.read_word(next_node_addr)
if next_node == self.last_node:
return True
else:
return False
def walk(self, node_addr, func, *args): def walk(self, node_addr, func, *args):
"""Walk the linked list starting at `node_addr', calling `func' on """Walk the linked list starting at `node_addr', calling `func' on
each node. `func' will be passed the current node and *args, each node. `func' will be passed the current node and *args,
if given. if given.
""" """
if self.is_empty() == True:
return
while True: while True:
if node_addr == 0: if node_addr == 0:
...@@ -65,6 +79,9 @@ class ListWalker(object): ...@@ -65,6 +79,9 @@ class ListWalker(object):
if given. if given.
""" """
if self.is_empty() == True:
return
node_addr = self.ram_dump.read_word(node_addr + self.ram_dump.field_offset('struct list_head', 'prev')) node_addr = self.ram_dump.read_word(node_addr + self.ram_dump.field_offset('struct list_head', 'prev'))
while True: while True:
if node_addr == 0: if node_addr == 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment