diff --git a/gdb-port/parser-name-instrumentation-gdb.py b/gdb-port/parser-name-instrumentation-gdb.py index d9687433442a191c3623f22ee4a88b4ddc6c607e..e13d1133550eac2b796601427e23bf940ef15920 100644 --- a/gdb-port/parser-name-instrumentation-gdb.py +++ b/gdb-port/parser-name-instrumentation-gdb.py @@ -394,7 +394,7 @@ class HammerParserBacktrace(gdb.Command): # but this addition is to avoid off-by-one errors index = -(depth+1) for p in parserstack[-1:index:-1]: - print("[" + str(hex(p.address)) + "] " + p.name) + print("[" + str(hex(p.address)) + "] " + p.name) # TODO: errors in perform_lowlevel_parse, if p.name is None if depth < len(parserstack): print("[...]") diff --git a/gdb-port/parser-type-instrumentation-gdb.py b/gdb-port/parser-type-instrumentation-gdb.py index 787cae597c00b02247b8e7a3c3df70462810eebc..c2978777f44736c4e560c5c1826d963d2453cef7 100644 --- a/gdb-port/parser-type-instrumentation-gdb.py +++ b/gdb-port/parser-type-instrumentation-gdb.py @@ -51,17 +51,6 @@ class VTTypes: #vt_types = VTTypes() -# Helper function to get a field from a struct via the gdb.Value interface -# TODO: test type checks through the Value API - -#def get_field_of_gdb_val(val, field): - # TODO: throw exception if field is not a string - # TODO: throw exception val's type doesn't have fields (==is not a struct?) - # for f in val: - # if f == field: - # return f - # return None - # TODO: maybe save vtable type here on init, or potentially in Parser class HParserEnv: @@ -74,11 +63,12 @@ class HParserEnv: # TODO: do this without passing a string to gdb.parse_and_eval() # perhaps using gdb.Value would be the best - # Something like: - # parser_val = gdb.Value(parser_addr) - # parser_val.type = gdb.Type("HParser*") - # for field in parser_val: - # ... + # turns out subscripting is allowed if the pointer is de referenced first, so this should work: + # p_object = gdb.parse_and_eval("*parser") + # p_env = p_object['env'] + + # or: + # p_env = gdb.parse_and_eval("parser").dereference()['env'] vtable_p = gdb.parse_and_eval("((HParser*) " + str(parser_addr) + ")->vtable") try: