1
0
Fork 0
forked from nuttx/nuttx-update

gdb/thread.py:Remove dependence on g_current_regs

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-04-09 17:37:36 +08:00 committed by GUIDINGLI
parent 067ec7bab1
commit fb176c02ca
3 changed files with 25 additions and 14 deletions

View file

@ -176,6 +176,20 @@ static int tcbinfo_close(FAR struct file *filep)
return OK;
}
/****************************************************************************
* Name: tcbinfo_current_regs
*
* Description:
* A special version of up_current_regs() that is non-optimized.
*
****************************************************************************/
nooptimiziation_function
FAR static void *tcbinfo_current_regs(void)
{
return up_current_regs();
}
/****************************************************************************
* Name: tcbinfo_read
****************************************************************************/
@ -198,8 +212,9 @@ static ssize_t tcbinfo_read(FAR struct file *filep, FAR char *buffer,
if (filep->f_pos == 0)
{
linesize = procfs_snprintf(attr->line, TCBINFO_LINELEN,
"pointer %p size %zu\n", &g_tcbinfo,
sizeof(struct tcbinfo_s));
"pointer %p size %zu current regs %p\n",
&g_tcbinfo, sizeof(struct tcbinfo_s),
tcbinfo_current_regs());
/* Save the linesize in case we are re-entered with f_pos > 0 */

View file

@ -264,7 +264,11 @@
/* The nooptimiziation_function attribute no optimize */
# define nooptimiziation_function __attribute__((optimize(0)))
# if defined(__clang__)
# define nooptimiziation_function __attribute__((optnone))
# else
# define nooptimiziation_function __attribute__((optimize("O0")))
# endif
/* The nosanitize_address attribute informs GCC don't sanitize it */

View file

@ -82,7 +82,8 @@ class Nxsetregs(gdb.Command):
super(Nxsetregs, self).__init__("nxsetregs", gdb.COMMAND_USER)
def invoke(self, args, from_tty):
current_regs = gdb.parse_and_eval("g_current_regs")
gdb.execute("set $_current_regs=tcbinfo_current_regs()")
current_regs = gdb.parse_and_eval("$_current_regs")
tcbinfo = gdb.parse_and_eval("g_tcbinfo")
arg = args.split(" ")
@ -91,16 +92,7 @@ class Nxsetregs(gdb.Command):
gdb.lookup_type("char").pointer()
)
else:
if utils.is_target_smp():
gdb.execute("set $_index=up_cpu_index()")
index = gdb.parse_and_eval("$_index")
else:
index = 0
if current_regs[index] == 0:
return
regs = current_regs[index].cast(gdb.lookup_type("char").pointer())
regs = current_regs.cast(gdb.lookup_type("char").pointer())
if regs == 0:
gdb.write("regs is NULL\n")