diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-08-11 01:19:46 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-08-11 01:19:46 +0000 |
commit | e1894cf97cc1f264ad3469e06f122cd8d995c3c8 (patch) | |
tree | d904f1d89d152a3bbac6c083fb35244f0f5da824 /lldb/scripts/Python/modify-python-lldb.py | |
parent | e6d0c86297aef47267262c34696ead2b7928bcd8 (diff) | |
download | llvm-e1894cf97cc1f264ad3469e06f122cd8d995c3c8.zip llvm-e1894cf97cc1f264ad3469e06f122cd8d995c3c8.tar.gz llvm-e1894cf97cc1f264ad3469e06f122cd8d995c3c8.tar.bz2 |
Add logic to SBValue.linked_list_iter() to detect infinite loop and to bail out early.
Add code to test case to create an evil linked list with:
task_evil -> task_2 -> task_3 -> task_evil ...
and to check that the linked list iterator only iterates 3 times.
llvm-svn: 137291
Diffstat (limited to 'lldb/scripts/Python/modify-python-lldb.py')
-rw-r--r-- | lldb/scripts/Python/modify-python-lldb.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py index a6e86c2..3825090 100644 --- a/lldb/scripts/Python/modify-python-lldb.py +++ b/lldb/scripts/Python/modify-python-lldb.py @@ -112,6 +112,8 @@ linked_list_iter_def = ''' end-of-list test function which takes an SBValue for an item and returns True if EOL is reached and False if not. + linked_list_iter() also detects infinite loop and bails out early. + The end_of_list_test arg, if omitted, defaults to the __eol_test__ function above. @@ -130,8 +132,10 @@ linked_list_iter_def = ''' if end_of_list_test(self): return item = self + visited = set() try: - while not end_of_list_test(item): + while not end_of_list_test(item) and not item.GetValueAsUnsigned() in visited: + visited.add(item.GetValueAsUnsigned()) yield item # Prepare for the next iteration. item = item.GetChildMemberWithName(next_item_name) |