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 2022/02/22 13:24:48 UTC

[GitHub] [incubator-nuttx] acassis commented on a change in pull request #5585: mm: Add memory dump function when enable CONFIG_DEBUG_MM

acassis commented on a change in pull request #5585:
URL: https://github.com/apache/incubator-nuttx/pull/5585#discussion_r811940896



##########
File path: fs/procfs/fs_procfsmeminfo.c
##########
@@ -382,6 +391,88 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
   return totalsize;
 }
 
+/****************************************************************************
+ * Name: memdump_read

Review comment:
       Please add Description

##########
File path: fs/procfs/fs_procfsmeminfo.c
##########
@@ -382,6 +391,88 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
   return totalsize;
 }
 
+/****************************************************************************
+ * Name: memdump_read
+ ****************************************************************************/
+
+#ifndef CONFIG_FS_PROCFS_EXCLUDE_MEMDUMP
+static ssize_t memdump_read(FAR struct file *filep, FAR char *buffer,
+                            size_t buflen)
+{
+  FAR struct meminfo_file_s *procfile;
+  size_t linesize;
+  size_t copysize;
+  size_t totalsize;
+  off_t offset;
+
+  finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
+
+  DEBUGASSERT(filep != NULL && buffer != NULL && buflen > 0);
+  offset = filep->f_pos;
+
+  /* Recover our private data from the struct file instance */
+
+  procfile = (FAR struct meminfo_file_s *)filep->f_priv;
+  DEBUGASSERT(procfile);
+
+  linesize  = procfs_snprintf(procfile->line, MEMINFO_LINELEN,
+                              "usage: <used/free>\n");
+
+  copysize  = procfs_memcpy(procfile->line, linesize, buffer, buflen,
+                            &offset);
+  totalsize = copysize;
+  buffer   += copysize;
+  buflen   -= copysize;
+  linesize  = procfs_snprintf(procfile->line, MEMINFO_LINELEN, "%s",
+                              "used: dump all allocated node\n"
+                              "free: dump all free node\n");
+
+  totalsize += procfs_memcpy(procfile->line, linesize, buffer, buflen,
+                             &offset);
+  filep->f_pos += totalsize;
+  return totalsize;
+}
+#endif
+
+/****************************************************************************
+ * Name: memdump_write

Review comment:
       Description




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

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