tools/gdb: catch exception when there's no selected frame

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang 2024-08-11 11:52:56 +08:00 committed by Xiang Xiao
parent bbf51ba071
commit ad1be85be7

View file

@ -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 frames 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)