[Lldb-commits] [lldb] r136265 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/value/linked_list/TestValueAPILinkedList.py test/python_api/value/linked_list/main.cpp
Johnny Chen
johnny.chen at apple.com
Wed Jul 27 14:14:01 PDT 2011
Author: johnny
Date: Wed Jul 27 16:14:01 2011
New Revision: 136265
URL: http://llvm.org/viewvc/llvm-project?rev=136265&view=rev
Log:
The SBValue.linked_list_iter() API failed for an empty list.
Fix the bug and add a test case.
Modified:
lldb/trunk/scripts/Python/modify-python-lldb.py
lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py
lldb/trunk/test/python_api/value/linked_list/main.cpp
Modified: lldb/trunk/scripts/Python/modify-python-lldb.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=136265&r1=136264&r2=136265&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/modify-python-lldb.py (original)
+++ lldb/trunk/scripts/Python/modify-python-lldb.py Wed Jul 27 16:14:01 2011
@@ -129,12 +129,10 @@
"""
try:
item = self.GetChildMemberWithName(next_item_name)
- while item:
+ while not end_of_list_test(item):
yield item
# Prepare for the next iteration.
item = item.GetChildMemberWithName(next_item_name)
- if end_of_list_test(item):
- break
except:
# Exception occurred. Stop the generator.
pass
Modified: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py?rev=136265&r1=136264&r2=136265&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py (original)
+++ lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Wed Jul 27 16:14:01 2011
@@ -91,6 +91,10 @@
# or it corresponds to a null pointer.
if not val or int(val.GetValue(), 16) == 0:
return True
+ # Also check the "id" for correct semantics. If id <= 0, the item
+ # is corrupted, let's return True to signify end of list.
+ if int(val.GetChildMemberWithName("id").GetValue(), 0) <= 0:
+ return True
# Otherwise, return False.
return False
@@ -109,6 +113,20 @@
print "visited IDs:", list
self.assertTrue(visitedIDs == list)
+ # Get variable 'empty_task_head'.
+ empty_task_head = frame0.FindVariable('empty_task_head')
+ self.assertTrue(empty_task_head, VALID_VARIABLE)
+ self.DebugSBValue(empty_task_head)
+
+ list = []
+ # There is no iterable item from empty_task_head.linked_list_iter().
+ for t in empty_task_head.linked_list_iter('next', eol):
+ if self.TraceOn():
+ print cvf.format(t)
+ list.append(int(t.GetChildMemberWithName("id").GetValue()))
+
+ self.assertTrue(len(list) == 0)
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
Modified: lldb/trunk/test/python_api/value/linked_list/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/main.cpp?rev=136265&r1=136264&r2=136265&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/linked_list/main.cpp (original)
+++ lldb/trunk/test/python_api/value/linked_list/main.cpp Wed Jul 27 16:14:01 2011
@@ -33,7 +33,7 @@
task2->next = task4;
task4->next = task5;
- int total = 0; // Break at this line
+ int total = 0;
Task *t = task_head;
while (t != NULL) {
if (t->id >= 0)
@@ -41,5 +41,9 @@
t = t->next;
}
printf("We have a total number of %d tasks\n", total);
- return 0;
+
+ // This corresponds to an empty task list.
+ Task *empty_task_head = new Task(-1, NULL);
+
+ return 0; // Break at this line
}
More information about the lldb-commits
mailing list