You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/11/03 13:49:15 UTC

[GitHub] [incubator-nuttx] YuuichiNakamura commented on a change in pull request #2142: Add task name record for task trace

YuuichiNakamura commented on a change in pull request #2142:
URL: https://github.com/apache/incubator-nuttx/pull/2142#discussion_r515798152



##########
File path: drivers/note/noteram_driver.c
##########
@@ -107,6 +132,183 @@ static volatile spinlock_t g_noteram_lock;
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: noteram_find_taskname
+ *
+ * Description:
+ *   Find task name info corresponding to the specified PID
+ *
+ * Input Parameters:
+ *   PID - Task ID
+ *
+ * Returned Value:
+ *   Pointer to the task name info
+ *   If the corresponding info doesn't exist in the buffer, NULL is returned.
+ *
+ ****************************************************************************/
+
+#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0
+static FAR struct noteram_taskname_info_s *noteram_find_taskname(pid_t pid)
+{
+  int n;
+  FAR struct noteram_taskname_info_s *ti;
+
+  for (n = 0; n < g_noteram_taskname.buffer_used; )
+    {
+      ti = (FAR struct noteram_taskname_info_s *)
+            &g_noteram_taskname.buffer[n];
+      if (ti->pid[0] + (ti->pid[1] << 8) == pid)
+        {
+          return ti;
+        }
+
+      n += ti->size;
+    }
+
+  return NULL;
+}
+#endif
+
+/****************************************************************************
+ * Name: noteram_record_taskname
+ *
+ * Description:
+ *   Record the task name info of the current task
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#if CONFIG_DRIVER_NOTERAM_TASKNAME_BUFSIZE > 0
+static void noteram_record_taskname(void)

Review comment:
       I understand your intension that only incoming NOTE_START and overwritten NOTE_STOP should be used to update the task name buffer.
   But I still concern that it supposes that the trace is always enabled and all task creations are reported as notes.
   I tried to add the fallback case - If NOTERAM_GETTASKNAME ioctl cannot find the given pid in the name buffer, try to find existing task which has the given pid to get the name.
   I wonder that it is good idea or not, but I think it can support some cases.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org