This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new f6dfd1d  system/trace: Fix trace output for the correct display in 
Trace Compass
f6dfd1d is described below

commit f6dfd1dbb2fdc6b9e28ff1cfefd739d279533175
Author: Nakamura, Yuuichi (ITDD) <[email protected]>
AuthorDate: Fri Jul 30 14:36:34 2021 +0900

    system/trace: Fix trace output for the correct display in Trace Compass
---
 system/trace/trace_dump.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/system/trace/trace_dump.c b/system/trace/trace_dump.c
index 224c7fe..a420724 100644
--- a/system/trace/trace_dump.c
+++ b/system/trace/trace_dump.c
@@ -62,7 +62,8 @@
 
 #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
@@ -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].pendingswitch = false;
       ctx->cpu[cpu].current_state = TSTATE_TASK_RUNNING;
-      ctx->cpu[cpu].current_pid = cpu;    /* Idle task */
-      ctx->cpu[cpu].next_pid = cpu;
+      ctx->cpu[cpu].current_pid = -1;
+      ctx->cpu[cpu].next_pid = -1;
     }
 
   ctx->task = NULL;
@@ -359,14 +360,7 @@ static int trace_dump_one(FAR FILE *out,
   cctx = &ctx->cpu[cpu];
   pid = note->nc_pid[0] + (note->nc_pid[1] << 8);
 
-  if (note->nc_type != NOTE_START &&
-      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
-     )
+  if (cctx->current_pid < 0)
     {
       cctx->current_pid = pid;
     }
@@ -396,13 +390,11 @@ static int trace_dump_one(FAR FILE *out,
 
       case NOTE_STOP:
         {
-          trace_dump_header(out, note, ctx);
-          fprintf(out, "sched_switch: "
-                       "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',
-                  get_task_name(cctx->current_pid, ctx),
-                  get_pid(cctx->current_pid));
+          /* This note informs the task to be stopped.
+           * Change current task state for the succeeding NOTE_RESUME.
+           */
+
+          cctx->current_state = 0;
         }
         break;
 

Reply via email to