[rtems commit] shell: Add PROFREPORT command

Sebastian Huber sebh at rtems.org
Fri Mar 6 15:20:09 UTC 2015


Module:    rtems
Branch:    master
Commit:    2bd71d95b6bf2dba738ea95b4fa73d8942f21bee
Changeset: http://git.rtems.org/rtems/commit/?id=2bd71d95b6bf2dba738ea95b4fa73d8942f21bee

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Mar  6 14:41:24 2015 +0100

shell: Add PROFREPORT command

---

 cpukit/libmisc/Makefile.am             |   1 +
 cpukit/libmisc/shell/main_profreport.c |  43 +++++++++++++
 cpukit/libmisc/shell/shellconfig.h     |   6 ++
 doc/shell/rtems.t                      | 108 +++++++++++++++++++++++++++++++++
 4 files changed, 158 insertions(+)

diff --git a/cpukit/libmisc/Makefile.am b/cpukit/libmisc/Makefile.am
index 5f61042..f09b69d 100644
--- a/cpukit/libmisc/Makefile.am
+++ b/cpukit/libmisc/Makefile.am
@@ -113,6 +113,7 @@ libshell_a_SOURCES = shell/cat_file.c shell/cmds.c shell/internal.h \
 libshell_a_SOURCES += shell/main_cmdls.c
 libshell_a_SOURCES += shell/main_cmdchown.c
 libshell_a_SOURCES += shell/main_cmdchmod.c
+libshell_a_SOURCES += shell/main_profreport.c
 
 if LIBNETWORKING
 libshell_a_SOURCES += \
diff --git a/cpukit/libmisc/shell/main_profreport.c b/cpukit/libmisc/shell/main_profreport.c
new file mode 100644
index 0000000..d6e4c5a
--- /dev/null
+++ b/cpukit/libmisc/shell/main_profreport.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include <rtems/profiling.h>
+#include <rtems/shell.h>
+#include <rtems/shellconfig.h>
+
+static int rtems_shell_main_profreport(int argc, char **argv)
+{
+  rtems_profiling_report_xml(
+    "Shell",
+    (rtems_profiling_printf) fprintf,
+    stdout,
+    0,
+    "  "
+  );
+
+  return 0;
+}
+
+rtems_shell_cmd_t rtems_shell_PROFREPORT_Command = {
+  .name = "profreport",
+  .usage = "profreport",
+  .topic = "rtems",
+  .command = rtems_shell_main_profreport
+};
diff --git a/cpukit/libmisc/shell/shellconfig.h b/cpukit/libmisc/shell/shellconfig.h
index cc2165b..2e52a92 100644
--- a/cpukit/libmisc/shell/shellconfig.h
+++ b/cpukit/libmisc/shell/shellconfig.h
@@ -84,6 +84,7 @@ extern rtems_shell_cmd_t rtems_shell_CPUUSE_Command;
 extern rtems_shell_cmd_t rtems_shell_TOP_Command;
 extern rtems_shell_cmd_t rtems_shell_STACKUSE_Command;
 extern rtems_shell_cmd_t rtems_shell_PERIODUSE_Command;
+extern rtems_shell_cmd_t rtems_shell_PROFREPORT_Command;
 extern rtems_shell_cmd_t rtems_shell_WKSPACE_INFO_Command;
 extern rtems_shell_cmd_t rtems_shell_MALLOC_INFO_Command;
 #if RTEMS_NETWORKING
@@ -443,6 +444,11 @@ extern rtems_shell_alias_t * const rtems_shell_Initial_aliases[];
       &rtems_shell_PERIODUSE_Command,
     #endif
     #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \
+         !defined(CONFIGURE_SHELL_NO_COMMAND_PROFREPORT)) || \
+        defined(CONFIGURE_SHELL_COMMAND_PROFREPORT)
+      &rtems_shell_PROFREPORT_Command,
+    #endif
+    #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \
          !defined(CONFIGURE_SHELL_NO_COMMAND_WKSPACE_INFO)) || \
         defined(CONFIGURE_SHELL_COMMAND_WKSPACE_INFO)
       &rtems_shell_WKSPACE_INFO_Command,
diff --git a/doc/shell/rtems.t b/doc/shell/rtems.t
index 5ebead3..b31696e 100644
--- a/doc/shell/rtems.t
+++ b/doc/shell/rtems.t
@@ -15,6 +15,7 @@ The RTEMS shell has the following rtems commands:
 @item @code{cpuuse} - print or reset per thread cpu usage
 @item @code{stackuse} - print per thread stack usage
 @item @code{perioduse} - print or reset per period usage
+ at item @code{profreport} - print a profiling report
 @item @code{wkspace} - Display information on Executive Workspace
 @item @code{config} - Show the system configuration.
 @item @code{itask} - List init tasks for the system
@@ -383,6 +384,113 @@ extern rtems_shell_cmd_t rtems_shell_PERIODUSE_Command;
 @c
 @c
 @page
+ at subsection profreport - print a profiling report
+
+ at pgindex profreport
+
+ at subheading SYNOPSYS:
+
+ at example
+profreport
+ at end example
+
+ at subheading DESCRIPTION:
+
+This command may be used to print a profiling report.
+
+ at subheading EXIT STATUS:
+
+This command returns 0.
+
+ at subheading NOTES:
+
+Profiling must be enabled at build configuration time to get profiling
+information.
+
+ at subheading EXAMPLES:
+
+The following is an example of how to use @code{profreport}:
+
+ at smallexample
+SHLL [/] $ profreport
+<ProfilingReport name="Shell">
+  <PerCPUProfilingReport processorIndex="0">
+    <MaxThreadDispatchDisabledTime unit="ns">10447</MaxThreadDispatchDisabledTime>
+    <MeanThreadDispatchDisabledTime unit="ns">2</MeanThreadDispatchDisabledTime>
+    <TotalThreadDispatchDisabledTime unit="ns">195926627</TotalThreadDispatchDisabledTime>
+    <ThreadDispatchDisabledCount>77908688</ThreadDispatchDisabledCount>
+    <MaxInterruptDelay unit="ns">0</MaxInterruptDelay>
+    <MaxInterruptTime unit="ns">688</MaxInterruptTime>
+    <MeanInterruptTime unit="ns">127</MeanInterruptTime>
+    <TotalInterruptTime unit="ns">282651157</TotalInterruptTime>
+    <InterruptCount>2215855</InterruptCount>
+  </PerCPUProfilingReport>
+  <PerCPUProfilingReport processorIndex="1">
+    <MaxThreadDispatchDisabledTime unit="ns">9053</MaxThreadDispatchDisabledTime>
+    <MeanThreadDispatchDisabledTime unit="ns">41</MeanThreadDispatchDisabledTime>
+    <TotalThreadDispatchDisabledTime unit="ns">3053830335</TotalThreadDispatchDisabledTime>
+    <ThreadDispatchDisabledCount>73334202</ThreadDispatchDisabledCount>
+    <MaxInterruptDelay unit="ns">0</MaxInterruptDelay>
+    <MaxInterruptTime unit="ns">57</MaxInterruptTime>
+    <MeanInterruptTime unit="ns">35</MeanInterruptTime>
+    <TotalInterruptTime unit="ns">76980203</TotalInterruptTime>
+    <InterruptCount>2141179</InterruptCount>
+  </PerCPUProfilingReport>
+  <SMPLockProfilingReport name="SMP lock stats">
+    <MaxAcquireTime unit="ns">608</MaxAcquireTime>
+    <MaxSectionTime unit="ns">1387</MaxSectionTime>
+    <MeanAcquireTime unit="ns">112</MeanAcquireTime>
+    <MeanSectionTime unit="ns">338</MeanSectionTime>
+    <TotalAcquireTime unit="ns">119031</TotalAcquireTime>
+    <TotalSectionTime unit="ns">357222</TotalSectionTime>
+    <UsageCount>1055</UsageCount>
+    <ContentionCount initialQueueLength="0">1055</ContentionCount>
+    <ContentionCount initialQueueLength="1">0</ContentionCount>
+    <ContentionCount initialQueueLength="2">0</ContentionCount>
+    <ContentionCount initialQueueLength="3">0</ContentionCount>
+  </SMPLockProfilingReport>
+  <SMPLockProfilingReport name="Giant">
+    <MaxAcquireTime unit="ns">4186</MaxAcquireTime>
+    <MaxSectionTime unit="ns">7575</MaxSectionTime>
+    <MeanAcquireTime unit="ns">160</MeanAcquireTime>
+    <MeanSectionTime unit="ns">183</MeanSectionTime>
+    <TotalAcquireTime unit="ns">1772793111</TotalAcquireTime>
+    <TotalSectionTime unit="ns">2029733879</TotalSectionTime>
+    <UsageCount>11039140</UsageCount>
+    <ContentionCount initialQueueLength="0">11037655</ContentionCount>
+    <ContentionCount initialQueueLength="1">1485</ContentionCount>
+    <ContentionCount initialQueueLength="2">0</ContentionCount>
+    <ContentionCount initialQueueLength="3">0</ContentionCount>
+  </SMPLockProfilingReport>
+</ProfilingReport>
+ at end smallexample
+
+ at subheading CONFIGURATION:
+
+ at findex CONFIGURE_SHELL_NO_COMMAND_PROFREPORT
+ at findex CONFIGURE_SHELL_COMMAND_PROFREPORT
+
+When building a custom command set, define
+ at code{CONFIGURE_SHELL_COMMAND_PROFREPORT} to have this
+command included.
+
+This command can be excluded from the shell command set by
+defining @code{CONFIGURE_SHELL_NO_COMMAND_PROFREPORT} when all
+shell commands have been configured.
+
+ at subheading PROGRAMMING INFORMATION:
+
+The configuration structure for the @code{profreport} has the
+following prototype:
+
+ at example
+extern rtems_shell_cmd_t rtems_shell_PROFREPORT_Command;
+ at end example
+
+ at c
+ at c
+ at c
+ at page
 @subsection wkspace - display information on executive workspace
 
 @pgindex wkspace



More information about the vc mailing list