gdb/register: register name sp, pc are always available
GDB provides four “standard” register names sp, pc, fp and ps. Those can be used in most of the cases. See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Registers.html Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
parent
73467989c5
commit
38b5dcd42c
2 changed files with 5 additions and 32 deletions
|
@ -137,10 +137,9 @@ def fetch_stacks():
|
|||
stacks = dict()
|
||||
|
||||
for tcb in utils.get_tcbs():
|
||||
if (
|
||||
tcb["task_state"] == gdb.parse_and_eval("TSTATE_TASK_RUNNING")
|
||||
and not utils.in_interrupt_context()
|
||||
):
|
||||
# We have no way to detect if we are in an interrupt context for now.
|
||||
# Originally we use `and not utils.in_interrupt_context()`
|
||||
if tcb["task_state"] == gdb.parse_and_eval("TSTATE_TASK_RUNNING"):
|
||||
sp = utils.get_sp()
|
||||
else:
|
||||
sp = utils.get_sp(tcb=tcb)
|
||||
|
|
|
@ -519,32 +519,6 @@ def in_interrupt_context(cpuid=0):
|
|||
return not g_current_regs or not g_current_regs[cpuid]
|
||||
|
||||
|
||||
def get_arch_sp_name():
|
||||
if is_target_arch("arm") or is_target_arch("aarch64"):
|
||||
# arm and arm variants
|
||||
return "sp"
|
||||
elif is_target_arch("i386", exact=True):
|
||||
return "esp"
|
||||
elif is_target_arch("i386:x86-64", exact=True):
|
||||
return "rsp"
|
||||
else:
|
||||
# Default to use sp, add more archs if needed
|
||||
return "sp"
|
||||
|
||||
|
||||
def get_arch_pc_name():
|
||||
if is_target_arch("arm") or is_target_arch("aarch64"):
|
||||
# arm and arm variants
|
||||
return "pc"
|
||||
elif is_target_arch("i386", exact=True):
|
||||
return "eip"
|
||||
elif is_target_arch("i386:x86-64", exact=True):
|
||||
return "rip"
|
||||
else:
|
||||
# Default to use pc, add more archs if needed
|
||||
return "pc"
|
||||
|
||||
|
||||
def get_register_byname(regname, tcb=None):
|
||||
frame = gdb.selected_frame()
|
||||
|
||||
|
@ -572,11 +546,11 @@ def get_register_byname(regname, tcb=None):
|
|||
|
||||
|
||||
def get_sp(tcb=None):
|
||||
return get_register_byname(get_arch_sp_name(), tcb)
|
||||
return get_register_byname("sp", tcb)
|
||||
|
||||
|
||||
def get_pc(tcb=None):
|
||||
return get_register_byname(get_arch_pc_name(), tcb)
|
||||
return get_register_byname("pc", tcb)
|
||||
|
||||
|
||||
def get_tcbs():
|
||||
|
|
Loading…
Reference in a new issue