aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/gdb-iterate-dll.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/contrib/gdb-iterate-dll.py b/contrib/gdb-iterate-dll.py
index 728747363..2132b5e34 100644
--- a/contrib/gdb-iterate-dll.py
+++ b/contrib/gdb-iterate-dll.py
@@ -1,8 +1,8 @@
1from gdb import * 1from gdb import *
2 2
3def iterate_dll (head, field, match, pfield): 3def search_dll (head, field, match, pfield):
4 """ 4 """
5 Iterates over a DLL data structure 5 Search in a DLL by iterates over it.
6 6
7 head: name of the symbol denoting the head of the DLL 7 head: name of the symbol denoting the head of the DLL
8 field: the field that should be search for match 8 field: the field that should be search for match
@@ -14,26 +14,28 @@ def iterate_dll (head, field, match, pfield):
14 (symbol, _) = lookup_symbol (head) 14 (symbol, _) = lookup_symbol (head)
15 if symbol is None: 15 if symbol is None:
16 print "Can't find symbol: " + head 16 print "Can't find symbol: " + head
17 return 17 return
18 while symbol: 18 symbol_val = symbol.value()
19 symbol_val = symbol.value().derefence 19 while symbol_val:
20 field_val = symbol_val[field] 20 symbol_val_def = symbol_val.dereference()
21 field_val = symbol_val_def[field]
21 if field_val.type.code == gdb.TYPE_CODE_INT: 22 if field_val.type.code == gdb.TYPE_CODE_INT:
22 val = int(field_val) 23 val = int(field_val)
23 res = (match == val) 24 res = (match == val)
24 if (field_val.type.code == gdb.TYPE_CODE_STRING) 25 elif (field_val.type.code == gdb.TYPE_CODE_STRING) or (field_val.type.code == gdb.TYPE_CODE_ARRAY):
25 or (filed_val.type.code == gdb.TYPE_CODE_ARRAY):
26 val = str (field_val) 26 val = str (field_val)
27 res = (match == val) 27 res = (match == val)
28 if (field_val.type.code == gdb.TYPE_CODE_TYPEDEF): 28 elif (field_val.type.code == gdb.TYPE_CODE_TYPEDEF):
29 val = str (field_val) 29 val = str (field_val)
30 res = match in val 30 res = match in val
31 else:
32 continue
31 33
32 if res: 34 if res:
33 if pfield is None: 35 if pfield is None:
34 print symbol_val 36 print symbol_val_def
35 else: 37 else:
36 print symbol_val[pfield] 38 print symbol_val_def[pfield]
37 symbol = symbol_val["next"] 39 symbol_val = symbol_val_def["next"]
38 40
39 41