scripts/gdb: fix list_for_each
PATCH v2 1/1 scripts/gdb: fix list_for_each
If the list is uninitialized (next pointer is NULL), list_for_each gets stuck in an infinite loop. Print a message and treat list as empty.
---
scripts/gdb/linux/lists.py | 5 +++++
1 file changed, 5 insertions(+)
scripts/gdb/linux/lists.py +0 -0
@@ -27,6 +27,11 @@ def list_for_each(head):
raise TypeError("Must be struct list_head not {}" .format(head.type))
+ if head['next'] == 0:
+ gdb.write("list_for_each: Uninitialized list '{}' treated as empty\n" + .format(head.address))
+ return
+
node = head['next'].dereference()
while node.address != head.address:
yield node.address
Signature · 1 line
2.16.6
Quoted 16 lines · George Prekas
If the list is uninitialized (next pointer is NULL),
list_for_eachgets stuck in an infinite loop. Print a message and treat list as empty.Signed-off-by George Prekas <[email protected]>---
scripts/gdb/linux/lists.py | 5 +++++1 file changed, 5 insertions(+)scripts/gdb/linux/lists.py +0
-0@@ -27,6 +27,11 @@ def list_for_each(head):raise
TypeError("Must be struct list_head not {}" .format(head.type))
Quoted 9 lines
+ if head['next'] == 0:
+ gdb.write("list_for_each: Uninitialized list '{}' treated as empty\n"
+ .format(head.address))
+ return
+
node = head['next'].dereference()
while node.address != head.address:
yield node.address
Happy New Year!
Any updates on this?
Thanks,
George
Quoted 17 lines · George Prekas
Quoted 16 lines · George Prekas
If the list is uninitialized (next pointer is NULL),
list_for_eachgets stuck in an infinite loop. Print a message and treat list as empty.Signed-off-by George Prekas <[email protected]>---
scripts/gdb/linux/lists.py | 5 +++++1 file changed, 5 insertions(+)scripts/gdb/linux/lists.py +0
-0@@ -27,6 +27,11 @@ def list_for_each(head):raise
TypeError("Must be struct list_head not {}" .format(head.type))
Quoted 11 lines
Quoted 9 lines
+ if head['next'] == 0:
+ gdb.write("list_for_each: Uninitialized list '{}' treated as empty\n"
+ .format(head.address))
+ return
+
node = head['next'].dereference()
while node.address != head.address:
yield node.addressHappy New Year!
Same to you!
Quoted 3 lines
Any updates on this?
Sorry, slipped through.
Andrew, please pick this up.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux