Skip to content

Commit

Permalink
sched_backtrace: fix when dump running thread in other-core
Browse files Browse the repository at this point in the history
Signed-off-by: buxiasen <[email protected]>
  • Loading branch information
jasonbu authored and hujun260 committed Oct 12, 2024
1 parent a2b129f commit 0bea0a0
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions sched/sched/sched_backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/sched.h>
#include <nuttx/init.h>

#include "sched.h"

Expand All @@ -45,16 +47,36 @@
#ifdef CONFIG_ARCH_HAVE_BACKTRACE
int sched_backtrace(pid_t tid, FAR void **buffer, int size, int skip)
{
FAR struct tcb_s *rtcb;
irqstate_t flags;
FAR struct tcb_s *tcb = this_task();
int ret = 0;
if (tid >= 0)

if (tcb->pid == tid)
{
ret = up_backtrace(tcb, buffer, size, skip);
}
else
{
flags = enter_critical_section();
rtcb = nxsched_get_tcb(tid);
if (rtcb != NULL)
irqstate_t flags = enter_critical_section();

tcb = nxsched_get_tcb(tid);
if (tcb != NULL)
{
ret = up_backtrace(rtcb, buffer, size, skip);
#ifdef CONFIG_SMP
if (tcb->task_state == TSTATE_TASK_RUNNING &&
g_nx_initstate != OSINIT_PANIC)
{
up_cpu_pause(tcb->cpu);
}
#endif

ret = up_backtrace(tcb, buffer, size, skip);
#ifdef CONFIG_SMP
if (tcb->task_state == TSTATE_TASK_RUNNING &&
g_nx_initstate != OSINIT_PANIC)
{
up_cpu_resume(tcb->cpu);
}
#endif
}

leave_critical_section(flags);
Expand Down

0 comments on commit 0bea0a0

Please sign in to comment.