]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiDpLib/Dp.c
ShellPkg/UefiDpLib: Support dumping cumulative data
[mirror_edk2.git] / ShellPkg / Library / UefiDpLib / Dp.c
index 62a4e7b57782722c3efe0e618c85692b63456cba..4d109d037c1b38f255a03e3cb06c9cd00ad403a8 100644 (file)
@@ -79,6 +79,7 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
 #endif // PROFILING_IMPLEMENTED\r
   {L"-x", TypeFlag},   // -x   eXclude Cumulative Items\r
   {L"-i", TypeFlag},   // -i   Display Identifier\r
+  {L"-c", TypeValue},  // -c   Display cumulative data.\r
   {L"-n", TypeValue},  // -n # Number of records to display for A and R\r
   {L"-t", TypeValue},  // -t # Threshold of interest\r
   {NULL, TypeMax}\r
@@ -164,6 +165,9 @@ ShellCommandRunDp (
   BOOLEAN                   TraceMode;\r
   BOOLEAN                   ProfileMode;\r
   BOOLEAN                   ExcludeMode;\r
+  BOOLEAN                   CumulativeMode;\r
+  CONST CHAR16              *CustomCumulativeToken;\r
+  PERF_CUM_DATA             *CustomCumulativeData;\r
 \r
   StringPtr   = NULL;\r
   SummaryMode = FALSE;\r
@@ -173,6 +177,8 @@ ShellCommandRunDp (
   TraceMode   = FALSE;\r
   ProfileMode = FALSE;\r
   ExcludeMode = FALSE;\r
+  CumulativeMode = FALSE;\r
+  CustomCumulativeData = NULL;\r
 \r
   // Get DP's entry time as soon as possible.\r
   // This is used as the Shell-Phase end time.\r
@@ -210,6 +216,7 @@ ShellCommandRunDp (
 #endif  // PROFILING_IMPLEMENTED\r
   ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");\r
   mShowId     = ShellCommandLineGetFlag (ParamPackage, L"-i");\r
+  CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");\r
 \r
   // Options with Values\r
   CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-n");\r
@@ -243,6 +250,20 @@ ShellCommandRunDp (
   //\r
   InitCumulativeData ();\r
 \r
+  //\r
+  // Init the custom cumulative data.\r
+  //\r
+  CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");\r
+  if (CustomCumulativeToken != NULL) {\r
+    CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));\r
+    CustomCumulativeData->MinDur = 0;\r
+    CustomCumulativeData->MaxDur = 0;\r
+    CustomCumulativeData->Count  = 0;\r
+    CustomCumulativeData->Duration = 0;\r
+    CustomCumulativeData->Name   = AllocateZeroPool (StrLen (CustomCumulativeToken) + 1);\r
+    UnicodeStrToAsciiStr (CustomCumulativeToken, CustomCumulativeData->Name);\r
+  }\r
+\r
   //\r
   // Timer specific processing\r
   //\r
@@ -302,8 +323,10 @@ ShellCommandRunDp (
 ****    !T &&  P  := (2) Only Profile records are displayed\r
 ****     T &&  P  := (3) Same as Default, both are displayed\r
 ****************************************************************************/\r
-  GatherStatistics();\r
-  if (AllMode) {\r
+  GatherStatistics (CustomCumulativeData);\r
+  if (CumulativeMode) {                       \r
+    ProcessCumulative (CustomCumulativeData);\r
+  } else if (AllMode) {\r
     if (TraceMode) {\r
       DumpAllTrace( Number2Display, ExcludeMode);\r
     }\r
@@ -326,7 +349,7 @@ ShellCommandRunDp (
         if ( ! EFI_ERROR( Status)) {\r
           ProcessPeims ();\r
           ProcessGlobal ();\r
-          ProcessCumulative ();\r
+          ProcessCumulative (NULL);\r
         }\r
       }\r
     }\r
@@ -339,6 +362,10 @@ ShellCommandRunDp (
   }\r
 \r
   SHELL_FREE_NON_NULL (StringPtr);\r
+  if (CustomCumulativeData != NULL) {\r
+    SHELL_FREE_NON_NULL (CustomCumulativeData->Name);\r
+  }\r
+  SHELL_FREE_NON_NULL (CustomCumulativeData);\r
 \r
   return SHELL_SUCCESS;\r
 }\r