system/trace: Fix trace output for the correct display in Trace Compass

This commit is contained in:
Nakamura, Yuuichi (ITDD) 2021-07-30 14:36:34 +09:00 committed by Xiang Xiao
parent 54d94d21b8
commit f6dfd1dbb2

View File

@ -62,7 +62,8 @@
#define get_pid(pid) ((pid) < NCPUS ? 0 : (pid)) #define get_pid(pid) ((pid) < NCPUS ? 0 : (pid))
#define get_task_state(s) ((s) <= LAST_READY_TO_RUN_STATE ? 'R' : 'S') #define get_task_state(s) ((s) == 0 ? 'X' : \
((s) <= LAST_READY_TO_RUN_STATE ? 'R' : 'S'))
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
@ -140,8 +141,8 @@ static void trace_dump_init_context(FAR struct trace_dump_context_s *ctx,
ctx->cpu[cpu].intr_nest = 0; ctx->cpu[cpu].intr_nest = 0;
ctx->cpu[cpu].pendingswitch = false; ctx->cpu[cpu].pendingswitch = false;
ctx->cpu[cpu].current_state = TSTATE_TASK_RUNNING; ctx->cpu[cpu].current_state = TSTATE_TASK_RUNNING;
ctx->cpu[cpu].current_pid = cpu; /* Idle task */ ctx->cpu[cpu].current_pid = -1;
ctx->cpu[cpu].next_pid = cpu; ctx->cpu[cpu].next_pid = -1;
} }
ctx->task = NULL; ctx->task = NULL;
@ -359,14 +360,7 @@ static int trace_dump_one(FAR FILE *out,
cctx = &ctx->cpu[cpu]; cctx = &ctx->cpu[cpu];
pid = note->nc_pid[0] + (note->nc_pid[1] << 8); pid = note->nc_pid[0] + (note->nc_pid[1] << 8);
if (note->nc_type != NOTE_START && if (cctx->current_pid < 0)
note->nc_type != NOTE_STOP &&
note->nc_type != NOTE_RESUME
#ifdef CONFIG_SMP
&& !(note->nc_type >= NOTE_CPU_START &&
note->nc_type <= NOTE_CPU_RESUMED)
#endif
)
{ {
cctx->current_pid = pid; cctx->current_pid = pid;
} }
@ -396,13 +390,11 @@ static int trace_dump_one(FAR FILE *out,
case NOTE_STOP: case NOTE_STOP:
{ {
trace_dump_header(out, note, ctx); /* This note informs the task to be stopped.
fprintf(out, "sched_switch: " * Change current task state for the succeeding NOTE_RESUME.
"prev_comm=%s prev_pid=%u prev_state=%c ==> " */
"next_comm=%s next_pid=%u\n",
get_task_name(pid, ctx), get_pid(pid), 'X', cctx->current_state = 0;
get_task_name(cctx->current_pid, ctx),
get_pid(cctx->current_pid));
} }
break; break;