From ad1be85be7b4dd42552088c326fce54b6af02398 Mon Sep 17 00:00:00 2001 From: xuxingliang Date: Sun, 11 Aug 2024 11:52:56 +0800 Subject: [PATCH] tools/gdb: catch exception when there's no selected frame Signed-off-by: xuxingliang --- tools/gdb/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/gdb/utils.py b/tools/gdb/utils.py index 42dc150096..22599d1f2b 100644 --- a/tools/gdb/utils.py +++ b/tools/gdb/utils.py @@ -141,9 +141,12 @@ def get_symbol_value(name, locspec="nx_start", cacheable=True): # If there is a current stack frame, GDB uses the macros in scope at that frame’s source code line. # Otherwise, GDB uses the macros in scope at the current listing location. # Reference: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Macros.html#Macros - if not gdb.selected_frame(): - gdb.execute(f"list {locspec}", to_string=True) - return gdb_eval_or_none(name) + try: + if not gdb.selected_frame(): + gdb.execute(f"list {locspec}", to_string=True) + return gdb_eval_or_none(name) + except gdb.error: + pass # Try current frame value = gdb_eval_or_none(name)