X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=contrib%2Fgdb-iterate-dll.py;h=2132b5e345f363f2107c14ce079e33ea533057b7;hb=45efbb2efbaa11a25e7e53592ee41f971ce6babd;hp=23b4b5fc7d92bd71eeda2d03f7b689cb207f8625;hpb=86bfb1ddbff2bd7b45d9927b24e50f5afb063feb;p=oweals%2Fgnunet.git diff --git a/contrib/gdb-iterate-dll.py b/contrib/gdb-iterate-dll.py index 23b4b5fc7..2132b5e34 100644 --- a/contrib/gdb-iterate-dll.py +++ b/contrib/gdb-iterate-dll.py @@ -1,8 +1,8 @@ from gdb import * -def iterate_dll (head, field, match, pfield): +def search_dll (head, field, match, pfield): """ - Iterates over a DLL data structure + Search in a DLL by iterates over it. head: name of the symbol denoting the head of the DLL field: the field that should be search for match @@ -14,14 +14,28 @@ def iterate_dll (head, field, match, pfield): (symbol, _) = lookup_symbol (head) if symbol is None: print "Can't find symbol: " + head - return - while not symbol: - symbol_val = symbol.value().derefence - if match == symbol_val[field]: + return + symbol_val = symbol.value() + while symbol_val: + symbol_val_def = symbol_val.dereference() + field_val = symbol_val_def[field] + if field_val.type.code == gdb.TYPE_CODE_INT: + val = int(field_val) + res = (match == val) + elif (field_val.type.code == gdb.TYPE_CODE_STRING) or (field_val.type.code == gdb.TYPE_CODE_ARRAY): + val = str (field_val) + res = (match == val) + elif (field_val.type.code == gdb.TYPE_CODE_TYPEDEF): + val = str (field_val) + res = match in val + else: + continue + + if res: if pfield is None: - print symbol_val + print symbol_val_def else: - print symbol_val[pfield] - symbol = symbol_val["next"] + print symbol_val_def[pfield] + symbol_val = symbol_val_def["next"]