From 9d06c7dd5e76ed51df70bcbbe94139a68d3a7725 Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Tue, 31 Jan 2023 18:20:42 +0100 Subject: [PATCH] (WIP) Backtrace command now only needs to print the stack --- gdb-port/commands.py | 11 ++++++----- gdb-port/parser.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gdb-port/commands.py b/gdb-port/commands.py index c792d50..92c242b 100644 --- a/gdb-port/commands.py +++ b/gdb-port/commands.py @@ -32,17 +32,18 @@ class HammerParserBacktrace(gdb.Command): maxsize = len(parserstack) print("Argument must be a positive integer") - parser_name = top_level_parse.h_do_parse_parser.name or "(Parser type resolution pending)" # TODO: should we just look at the vtable and name the parser in h_do_parse? - - print("[" + str(hex(top_level_parse.h_do_parse_parser.address)) + "] " + parser_name + " [current]") #TODO: GUI widget should reflect this - print(" ") depth = min(len(parserstack), maxsize) if depth > 0: # if stack not empty # unsure what the idiomatic python is for handling negative indices starting with -1, # but this addition is to avoid off-by-one errors index = -(depth+1) + top = True for p in parserstack[-1:index:-1]: - print("[" + str(hex(p.address)) + "] " + p.name) # TODO: errors in perform_lowlevel_parse, if p.name is None + if not top: + print("[" + str(hex(p.address)) + "] " + p.get_name_or_placeholder()) + else: + print("[" + str(hex(p.address)) + "] " + p.get_name_or_placeholder(), "[current]") + top = False if depth < len(parserstack): print("[...]") diff --git a/gdb-port/parser.py b/gdb-port/parser.py index 56b1a55..ad69b29 100644 --- a/gdb-port/parser.py +++ b/gdb-port/parser.py @@ -11,10 +11,10 @@ class Parser: def name_parser(self, name): self.name = name - # TODO: remove + # TODO: The parser could be named in h_do_parse by deducing from the vtable def get_name_or_placeholder(self): if self.name is None: - return "Wait for it... (if you're reading this, you found a bug)" + return "(Type resolution pending)" else: return self.name -- GitLab