1 from __future__ import print_function
2 from __future__ import unicode_literals
3 from builtins import str
7 def search_dll(head, field, match, pfield):
9 Search in a DLL by iterates over it.
11 head: name of the symbol denoting the head of the DLL
12 field: the field that should be search for match
13 match: the mathing value for field
14 pfield: the field whose value is to be printed for matched elements; None to
15 print all fields of the matched elemented
18 (symbol, _) = lookup_symbol(head)
20 print("Can't find symbol: " + head)
22 symbol_val = symbol.value()
24 symbol_val_def = symbol_val.dereference()
25 field_val = symbol_val_def[field]
26 if field_val.type.code == gdb.TYPE_CODE_INT:
29 elif (field_val.type.code == gdb.TYPE_CODE_STRING) or (field_val.type.code == gdb.TYPE_CODE_ARRAY):
32 elif (field_val.type.code == gdb.TYPE_CODE_TYPEDEF):
42 print(symbol_val_def[pfield])
43 symbol_val = symbol_val_def["next"]