gdbinit: add support for reporting total and used stack size

This checks if the required function is defined (when stack coloration
is enabled) and, if so, calls it to get used stack. Otherwise it just
reports zero used stack.
This commit is contained in:
Matias N 2021-01-17 00:18:04 -03:00 committed by Brennan Ashton
parent 328b7c06bc
commit a150e03e24
1 changed files with 11 additions and 2 deletions

View File

@ -67,6 +67,9 @@ define _examine_target
set $_target_max_tasks = sizeof(g_pidhash) / sizeof(struct pidhash_s)
python if (type(gdb.lookup_global_symbol("up_check_tcbstack")) is gdb.Symbol) : \
gdb.execute("set $_target_has_stack_coloration = 1")
printf "target examined \n"
python print("_target_arch.name=" + _target_arch.name())
@ -88,9 +91,15 @@ define _print_thread
printf " "
end
printf "%d Thread 0x%x (Name: %s, State: %s, Priority: %d) 0x%x in ", \
if ($_target_has_stack_coloration)
set $stack_used = up_check_tcbstack($tcb)
else
set $stack_used = 0
end
printf "%d Thread 0x%x (Name: %s, State: %s, Priority: %d, Stack: %d/%d) PC: 0x%x in ", \
$tcb->pid, $tcb, $tcb->name, g_statenames[$tcb->task_state], $tcb->sched_priority, \
$tcb->xcp.regs[$_pc_reg_idx]
$stack_used, $tcb->adj_stack_size, $tcb->xcp.regs[$_pc_reg_idx]
python _symbol = gdb.execute("info symbol $tcb->xcp.regs[$_pc_reg_idx]", to_string=True); \
print(_symbol.split()[0] + "()")
end