From 26a2fa618f42b99b299ab1dab508d49f3914b126 Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Thu, 23 Jun 2022 18:57:41 +0200 Subject: [PATCH] Fix AST getting captured/printed without prompting --- gdb-port/ast.py | 3 +++ gdb-port/commands.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/gdb-port/ast.py b/gdb-port/ast.py index ea2ab1c..f661cf6 100644 --- a/gdb-port/ast.py +++ b/gdb-port/ast.py @@ -17,6 +17,9 @@ class HParseResult: # AST is not null # Some combinators, such as h_ignore(), return a ParseResult with no AST def read_AST_not_null(self): + if self.address == 0: + return False + if not __class__.HParseResult_t_p: __class__.HParseResult_t_p = gdb.lookup_type("HParseResult").pointer() res = gdb.Value(self.address).cast(__class__.HParseResult_t_p) diff --git a/gdb-port/commands.py b/gdb-port/commands.py index 8d906f2..90502da 100644 --- a/gdb-port/commands.py +++ b/gdb-port/commands.py @@ -195,6 +195,8 @@ class HammerParseStepToResult(FlowControlWithPrint): if gdb.selected_inferior().pid > 0: gdb.execute("continue") + top_level_parse.clear_ast_stack_index() + self.conditionally_print_backtrace() HammerParseStepToResult() -- GitLab