summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-07-27 21:14:01 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-07-27 21:14:01 +0000
commitbfdf9a36d97932f14cceb58d2d0d712f6f1e9d6d (patch)
tree57cc7972a50326acc68a9883fd2e68c6741ae2e6 /lldb
parent03f56d9de6d4620bc42c0ead65d4f33beb178c80 (diff)
downloadbcm5719-llvm-bfdf9a36d97932f14cceb58d2d0d712f6f1e9d6d.tar.gz
bcm5719-llvm-bfdf9a36d97932f14cceb58d2d0d712f6f1e9d6d.zip
The SBValue.linked_list_iter() API failed for an empty list.
Fix the bug and add a test case. llvm-svn: 136265
Diffstat (limited to 'lldb')
-rw-r--r--lldb/scripts/Python/modify-python-lldb.py4
-rw-r--r--lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py18
-rw-r--r--lldb/test/python_api/value/linked_list/main.cpp8
3 files changed, 25 insertions, 5 deletions
diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py
index 3cd312638bf..9f5f8c95a32 100644
--- a/lldb/scripts/Python/modify-python-lldb.py
+++ b/lldb/scripts/Python/modify-python-lldb.py
@@ -129,12 +129,10 @@ linked_list_iter_def = '''
"""
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
diff --git a/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py b/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py
index 6456a2ea380..f07ed1b1de2 100644
--- a/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py
+++ b/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py
@@ -91,6 +91,10 @@ class ValueAsLinkedListTestCase(TestBase):
# 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 @@ class ValueAsLinkedListTestCase(TestBase):
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()
diff --git a/lldb/test/python_api/value/linked_list/main.cpp b/lldb/test/python_api/value/linked_list/main.cpp
index 772d5ed5d1b..db0e249cc91 100644
--- a/lldb/test/python_api/value/linked_list/main.cpp
+++ b/lldb/test/python_api/value/linked_list/main.cpp
@@ -33,7 +33,7 @@ int main (int argc, char const *argv[])
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 @@ int main (int argc, char const *argv[])
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
}
OpenPOWER on IntegriCloud