Skip to content
Snippets Groups Projects
Commit 9d06c7dd authored by pompolic's avatar pompolic
Browse files

(WIP) Backtrace command now only needs to print the stack

parent bf0f12c8
No related branches found
No related tags found
No related merge requests found
......@@ -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("[...]")
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment