From 11dd03e58c387e79be286a7ad01c798a5fb51134 Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Fri, 17 Sep 2021 20:35:32 +0200 Subject: [PATCH] Bugfix: ManyEnv passed an address to name_from_vtable instead of a parser object - Commented out messages for memory allocations outside a parser context - Commented out fallback for when a parser vtable can't be found in the dictionary, as that should be an error - Added debug line printing the address that was not found in the vtable name->address dictionary --- gdb-port/parser-name-instrumentation-gdb.py | 4 ++-- gdb-port/parser-type-instrumentation-gdb.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gdb-port/parser-name-instrumentation-gdb.py b/gdb-port/parser-name-instrumentation-gdb.py index 8903c1f..a07c51b 100644 --- a/gdb-port/parser-name-instrumentation-gdb.py +++ b/gdb-port/parser-name-instrumentation-gdb.py @@ -181,10 +181,10 @@ class TopLevelParse: # Caveat: parser_stack is assumed not to be None if we could get a parser_obj parser_obj.add_mem_use(parser_stack.parse_state, alloc_size) elif parser_stack is not None: - print("Allocation of " + str(alloc_size) + " bytes without a parser on the stack. (Happens before first call perform_lowlevel_parse to or after return from that call)") + #print("Allocation of " + str(alloc_size) + " bytes without a parser on the stack. (Happens before first call perform_lowlevel_parse to or after return from that call)") parser_stack.unclaimed_mem_use += alloc_size else: - print("Allocation of " + str(alloc_size) + " bytes without a parser stack. (This happens before and after parse)") + #print("Allocation of " + str(alloc_size) + " bytes without a parser stack. (This happens before and after parse)") self.unclaimed_mem_use += alloc_size def parse_virtual(self, parser_name): diff --git a/gdb-port/parser-type-instrumentation-gdb.py b/gdb-port/parser-type-instrumentation-gdb.py index 7a17887..6dc9b88 100644 --- a/gdb-port/parser-type-instrumentation-gdb.py +++ b/gdb-port/parser-type-instrumentation-gdb.py @@ -47,6 +47,7 @@ class VTTypes: try: return self.vt_symbols[int(address)] except KeyError: + print("Lookup fail for VT address " + str(hex(address))) return None #vt_types = VTTypes() @@ -83,10 +84,11 @@ class HParserEnv: try: name = parser_name_defaults[self.top_level_parse.vt_types.lookup_by_address(vtable_p).name] # if lookup_by_address() returns None - except AttributeError: - name = "(Unknown parser type (vtable symbol not found in lookup)" - print("Lookup fail for: " + str(hex(parser_addr))) # DEBUG - print("vt_types: " + str(self.top_level_parse.vt_types)) # DEBUG + # TODO: these exceptions just sweep issues under the rug. it should fail instead + #except AttributeError: + # name = "(Unknown parser type (vtable symbol not found in lookup)" + # print("Lookup fail for: " + str(hex(parser_addr))) # DEBUG + #print("vt_types: " + str({hex(k):v.name for k,v in self.top_level_parse.vt_types.vt_symbols.items()})) # DEBUG except KeyError: name = "(Unknown parser type (vtable exists but has no default name associated)" @@ -488,7 +490,7 @@ class ManyEnv(HParserEnv): p_ptr = parser_env['p'] p_obj = top_level_parse.add_or_get_parser(p_ptr) if p_obj.name is None: - p_obj.name_parser( self.name_from_vtable(p_ptr) ) + p_obj.name_parser( self.name_from_vtable(p_obj) ) self.p = p_obj def __str__(self): -- GitLab