public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch V2 1/3] ShellPkg/Dp: make sure memory is freed before exit
@ 2018-06-11  8:32 Dandan Bi
  2018-06-11  8:32 ` [patch V2 2/3] ShellPkg/Dp: Initialize summary date when run DP Dandan Bi
  2018-06-11  8:32 ` [patch V2 3/3] ShellPkg/Dp: Make the help info align with code Dandan Bi
  0 siblings, 2 replies; 5+ messages in thread
From: Dandan Bi @ 2018-06-11  8:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Ruiyu Ni, Jaben Carsey

Run dp command now:
Firstly it will get performance records from FPDT and then
parse the DP command. And if encounter invalid parameters,
it will exit directly. Thus the performance records got before
are invalid. And what's worse is that the memory allocated in
getting performance records phase is not freed.

This patch update the code to parse the command firstly and
then get the performance records. And make sure that all the
clean work has been done before exiting.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 70 ++++++++++++++-------------
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index aa9c2cdf7a8..fe85937f557 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -390,11 +390,11 @@ BuildCachedGuidHandleTable (
   }
   if (HandleBuffer != NULL) {
     FreePool (HandleBuffer);
     HandleBuffer = NULL;
   }
-  return Status;
+  return EFI_SUCCESS;
 }
 
 /**
   Get Measurement form Fpdt records.
 
@@ -729,39 +729,10 @@ RunDp (
   // initialize the shell lib (we must be in non-auto-init...)
   //
   Status = ShellInitialize();
   ASSERT_EFI_ERROR(Status);
 
-  //
-  // DP dump performance data by parsing FPDT table in ACPI table.
-  // Folloing 3 steps are to get the measurement form the FPDT table.
-  //
-
-  //
-  //1. Get FPDT from ACPI table.
-  //
-  Status = GetBootPerformanceTable ();
-  if (EFI_ERROR(Status)) {
-    return Status;
-  }
-
-  //
-  //2. Cache the ModuleGuid and hanlde mapping table.
-  //
-  Status = BuildCachedGuidHandleTable();
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  //3. Build the measurement array form the FPDT records.
-  //
-  Status = BuildMeasurementList ();
-  if (EFI_ERROR(Status)) {
-    return Status;
-  }
-
   //
   // Process Command Line arguments
   //
   Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
   if (EFI_ERROR(Status)) {
@@ -809,10 +780,42 @@ RunDp (
 #if PROFILING_IMPLEMENTED
     ProfileMode = TRUE;
 #endif  // PROFILING_IMPLEMENTED
   }
 
+  //
+  // DP dump performance data by parsing FPDT table in ACPI table.
+  // Folloing 3 steps are to get the measurement form the FPDT table.
+  //
+
+  //
+  //1. Get FPDT from ACPI table.
+  //
+  Status = GetBootPerformanceTable ();
+  if (EFI_ERROR (Status)) {
+    ShellStatus = Status;
+    goto Done;
+  }
+
+  //
+  //2. Cache the ModuleGuid and hanlde mapping table.
+  //
+  Status = BuildCachedGuidHandleTable();
+  if (EFI_ERROR (Status)) {
+    ShellStatus = Status;
+    goto Done;
+  }
+
+  //
+  //3. Build the measurement array form the FPDT records.
+  //
+  Status = BuildMeasurementList ();
+  if (EFI_ERROR (Status)) {
+    ShellStatus = SHELL_OUT_OF_RESOURCES;
+    goto Done;
+  }
+
   //
   // Initialize the pre-defined cumulative data.
   //
   InitCumulativeData ();
 
@@ -821,21 +824,22 @@ RunDp (
   //
   CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");
   if (CustomCumulativeToken != NULL) {
     CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));
     if (CustomCumulativeData == NULL) {
-      return SHELL_OUT_OF_RESOURCES;
+      ShellStatus = SHELL_OUT_OF_RESOURCES;
+      goto Done;
     }
     CustomCumulativeData->MinDur = PERF_MAXDUR;
     CustomCumulativeData->MaxDur = 0;
     CustomCumulativeData->Count  = 0;
     CustomCumulativeData->Duration = 0;
     NameSize = StrLen (CustomCumulativeToken) + 1;
     CustomCumulativeData->Name   = AllocateZeroPool (NameSize);
     if (CustomCumulativeData->Name == NULL) {
-      FreePool (CustomCumulativeData);
-      return SHELL_OUT_OF_RESOURCES;
+      ShellStatus = SHELL_OUT_OF_RESOURCES;
+      goto Done;
     }
     UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);
   }
 
   //
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [patch V2 2/3] ShellPkg/Dp: Initialize summary date when run DP
  2018-06-11  8:32 [patch V2 1/3] ShellPkg/Dp: make sure memory is freed before exit Dandan Bi
@ 2018-06-11  8:32 ` Dandan Bi
  2018-06-12  8:10   ` Ni, Ruiyu
  2018-06-11  8:32 ` [patch V2 3/3] ShellPkg/Dp: Make the help info align with code Dandan Bi
  1 sibling, 1 reply; 5+ messages in thread
From: Dandan Bi @ 2018-06-11  8:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Ruiyu Ni, Jaben Carsey

Issue:
When run "dp -s" or ("dp -v") command in shell several times,
the summary reuslts are different each time.

The root cause is that the previous global data "SummaryData"
is not cleaned when the dp command is callled next time.
This patch initializes the global data "SummaryData"
when the dp dymanic command is called.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index fe85937f557..d8451dbf59f 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -672,10 +672,28 @@ InitCumulativeData (
     CumData[Index].MaxDur = 0;
     CumData[Index].Duration = 0;
   }
 }
 
+/**
+  Initialize the Summary data.
+
+**/
+VOID
+InitSummaryData (
+  VOID
+  )
+{
+  SummaryData.NumTrace      = 0;
+  SummaryData.NumProfile    = 0 ;
+  SummaryData.NumIncomplete = 0;
+  SummaryData.NumSummary    = 0;
+  SummaryData.NumHandles    = 0;
+  SummaryData.NumPEIMs      = 0;
+  SummaryData.NumGlobal     = 0;
+}
+
 /**
   Dump performance data.
   
   @param[in]  ImageHandle     The image handle.
   @param[in]  SystemTable     The system table.
@@ -817,10 +835,15 @@ RunDp (
   //
   // Initialize the pre-defined cumulative data.
   //
   InitCumulativeData ();
 
+  //
+  // Initialize the Summary data.
+  //
+  InitSummaryData ();
+
   //
   // Init the custom cumulative data.
   //
   CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");
   if (CustomCumulativeToken != NULL) {
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [patch V2 3/3] ShellPkg/Dp: Make the help info align with code
  2018-06-11  8:32 [patch V2 1/3] ShellPkg/Dp: make sure memory is freed before exit Dandan Bi
  2018-06-11  8:32 ` [patch V2 2/3] ShellPkg/Dp: Initialize summary date when run DP Dandan Bi
@ 2018-06-11  8:32 ` Dandan Bi
  2018-06-12  4:21   ` Gao, Liming
  1 sibling, 1 reply; 5+ messages in thread
From: Dandan Bi @ 2018-06-11  8:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Ruiyu Ni, Jaben Carsey

Currently in DP, the Trace mode is enabled by default.
And the profile mode is not implemented. but the help info
of DP tool doesn't match current implementation. Which will
make user confused. So now remove the unused source code
related to the profile mode and update the help information
of DP tool.

V2: Remove the unused code related to profile mode.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c      |  96 ++++++--------------
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h      |   7 --
 ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni    |   6 +-
 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf |   1 -
 .../DpDynamicCommand/DpDynamicCommand.inf          |   1 -
 .../DynamicCommand/DpDynamicCommand/DpInternal.h   |  48 ----------
 .../DynamicCommand/DpDynamicCommand/DpProfile.c    | 100 ---------------------
 7 files changed, 26 insertions(+), 233 deletions(-)
 delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index d8451dbf59f..38766613175 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -82,14 +82,10 @@ UINT32 const      NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-v", TypeFlag},   // -v   Verbose Mode
   {L"-A", TypeFlag},   // -A   All, Cooked
   {L"-R", TypeFlag},   // -R   RAW All
   {L"-s", TypeFlag},   // -s   Summary
-#if PROFILING_IMPLEMENTED
-  {L"-P", TypeFlag},   // -P   Dump Profile Data
-  {L"-T", TypeFlag},   // -T   Dump Trace Data
-#endif // PROFILING_IMPLEMENTED
   {L"-x", TypeFlag},   // -x   eXclude Cumulative Items
   {L"-i", TypeFlag},   // -i   Display Identifier
   {L"-c", TypeValue},  // -c   Display cumulative data.
   {L"-n", TypeValue},  // -n # Number of records to display for A and R
   {L"-t", TypeValue},  // -t # Threshold of interest
@@ -114,13 +110,10 @@ DumpStatistics( void )
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle,     SummaryData.NumSummary);
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), mDpHiiHandle,    SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), mDpHiiHandle,      SummaryData.NumPEIMs);
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle,    SummaryData.NumGlobal);
-#if PROFILING_IMPLEMENTED
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), mDpHiiHandle,    SummaryData.NumProfile);
-#endif // PROFILING_IMPLEMENTED
   SHELL_FREE_NON_NULL (StringPtr);
   SHELL_FREE_NON_NULL (StringPtrUnknown);
 }
 
 /**
@@ -682,11 +675,10 @@ VOID
 InitSummaryData (
   VOID
   )
 {
   SummaryData.NumTrace      = 0;
-  SummaryData.NumProfile    = 0 ;
   SummaryData.NumIncomplete = 0;
   SummaryData.NumSummary    = 0;
   SummaryData.NumHandles    = 0;
   SummaryData.NumPEIMs      = 0;
   SummaryData.NumGlobal     = 0;
@@ -719,12 +711,10 @@ RunDp (
   EFI_STRING                StringPtr;
   BOOLEAN                   SummaryMode;
   BOOLEAN                   VerboseMode;
   BOOLEAN                   AllMode;
   BOOLEAN                   RawMode;
-  BOOLEAN                   TraceMode;
-  BOOLEAN                   ProfileMode;
   BOOLEAN                   ExcludeMode;
   BOOLEAN                   CumulativeMode;
   CONST CHAR16              *CustomCumulativeToken;
   PERF_CUM_DATA             *CustomCumulativeData;
   UINTN                     NameSize;
@@ -734,12 +724,10 @@ RunDp (
   StringPtr   = NULL;
   SummaryMode = FALSE;
   VerboseMode = FALSE;
   AllMode     = FALSE;
   RawMode     = FALSE;
-  TraceMode   = FALSE;
-  ProfileMode = FALSE;
   ExcludeMode = FALSE;
   CumulativeMode = FALSE;
   CustomCumulativeData = NULL;
   ShellStatus = SHELL_SUCCESS;
 
@@ -763,14 +751,10 @@ RunDp (
   //
   VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");
   SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));
   AllMode     = ShellCommandLineGetFlag (ParamPackage, L"-A");
   RawMode     = ShellCommandLineGetFlag (ParamPackage, L"-R");
-#if PROFILING_IMPLEMENTED
-  TraceMode   = ShellCommandLineGetFlag (ParamPackage, L"-T");
-  ProfileMode = ShellCommandLineGetFlag (ParamPackage, L"-P");
-#endif  // PROFILING_IMPLEMENTED
   ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");
   mShowId     = ShellCommandLineGetFlag (ParamPackage, L"-i");
   CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");
 
   // Options with Values
@@ -789,18 +773,10 @@ RunDp (
     mInterestThreshold = DEFAULT_THRESHOLD;  // 1ms := 1,000 us
   } else {
     mInterestThreshold = StrDecimalToUint64(CmdLineArg);
   }
 
-  // Handle Flag combinations and default behaviors
-  // If both TraceMode and ProfileMode are FALSE, set them both to TRUE
-  if ((! TraceMode) && (! ProfileMode)) {
-    TraceMode   = TRUE;
-#if PROFILING_IMPLEMENTED
-    ProfileMode = TRUE;
-#endif  // PROFILING_IMPLEMENTED
-  }
 
   //
   // DP dump performance data by parsing FPDT table in ACPI table.
   // Folloing 3 steps are to get the measurement form the FPDT table.
   //
@@ -917,71 +893,49 @@ RunDp (
 ****    n Number2Display  Used by All and Raw mode.  Otherwise ignored.
 ****    A All         --  R and S options are ignored
 ****    R Raw         --  S option is ignored
 ****    s Summary     --  Modifies "Cooked" output only
 ****    Cooked (Default)
-****
-****  The All, Raw, and Cooked modes are modified by the Trace and Profile
-****  options.
-****    !T && !P  := (0) Default, Both are displayed
-****     T && !P  := (1) Only Trace records are displayed
-****    !T &&  P  := (2) Only Profile records are displayed
-****     T &&  P  := (3) Same as Default, both are displayed
 ****************************************************************************/
   GatherStatistics (CustomCumulativeData);
   if (CumulativeMode) {                       
     ProcessCumulative (CustomCumulativeData);
   } else if (AllMode) {
-    if (TraceMode) {
-      Status = DumpAllTrace( Number2Display, ExcludeMode);
+    Status = DumpAllTrace( Number2Display, ExcludeMode);
+    if (Status == EFI_ABORTED) {
+      ShellStatus = SHELL_ABORTED;
+      goto Done;
+    }
+  } else if (RawMode) {
+    Status = DumpRawTrace( Number2Display, ExcludeMode);
+    if (Status == EFI_ABORTED) {
+      ShellStatus = SHELL_ABORTED;
+      goto Done;
+    }
+  } else {
+    //------------- Begin Cooked Mode Processing
+    ProcessPhases ();
+    if ( ! SummaryMode) {
+      Status = ProcessHandles ( ExcludeMode);
       if (Status == EFI_ABORTED) {
         ShellStatus = SHELL_ABORTED;
         goto Done;
       }
-    }
-    if (ProfileMode) {
-      DumpAllProfile( Number2Display, ExcludeMode);
-    }
-  } else if (RawMode) {
-    if (TraceMode) {
-      Status = DumpRawTrace( Number2Display, ExcludeMode);
+
+      Status = ProcessPeims ();
       if (Status == EFI_ABORTED) {
         ShellStatus = SHELL_ABORTED;
         goto Done;
       }
-    }
-    if (ProfileMode) {
-      DumpRawProfile( Number2Display, ExcludeMode);
-    }
-  } else {
-    //------------- Begin Cooked Mode Processing
-    if (TraceMode) {
-      ProcessPhases ();
-      if ( ! SummaryMode) {
-        Status = ProcessHandles ( ExcludeMode);
-        if (Status == EFI_ABORTED) {
-          ShellStatus = SHELL_ABORTED;
-          goto Done;
-        }
-
-        Status = ProcessPeims ();
-        if (Status == EFI_ABORTED) {
-          ShellStatus = SHELL_ABORTED;
-          goto Done;
-        }
-
-        Status = ProcessGlobal ();
-        if (Status == EFI_ABORTED) {
-          ShellStatus = SHELL_ABORTED;
-          goto Done;
-        }
-
-        ProcessCumulative (NULL);
+
+      Status = ProcessGlobal ();
+      if (Status == EFI_ABORTED) {
+        ShellStatus = SHELL_ABORTED;
+        goto Done;
       }
-    }
-    if (ProfileMode) {
-      DumpAllProfile( Number2Display, ExcludeMode);
+
+       ProcessCumulative (NULL);
     }
   } //------------- End of Cooked Mode Processing
   if ( VerboseMode || SummaryMode) {
     DumpStatistics();
   }
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
index 9fd88578720..aae021334d6 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
@@ -51,16 +51,10 @@ extern EFI_HANDLE mDpHiiHandle;
   * The value assigned to DP_DEBUG controls which debug output
   * is generated.  Set it to ZERO to disable.
 **/
 #define DP_DEBUG                0
 
-/**
-  * Set to 1 once Profiling has been implemented in order to enable
-  * profiling related options and report output.
-**/
-#define PROFILING_IMPLEMENTED   0
-
 #define DEFAULT_THRESHOLD       1000    ///< One millisecond.
 #define DEFAULT_DISPLAYCOUNT    50
 #define MAXIMUM_DISPLAYCOUNT    999999  ///< Arbitrary maximum reasonable number.
 
 #define PERF_MAXDUR             0xFFFFFFFFFFFFFFFFULL
@@ -95,11 +89,10 @@ typedef struct {
   UINT32  Count;        ///< Total number of measurements accumulated.
 } PERF_CUM_DATA;
 
 typedef struct {
   UINT32                NumTrace;         ///< Number of recorded TRACE performance measurements.
-  UINT32                NumProfile;       ///< Number of recorded PROFILE performance measurements.
   UINT32                NumIncomplete;    ///< Number of measurements with no END value.
   UINT32                NumSummary;       ///< Number of summary section measurements.
   UINT32                NumHandles;       ///< Number of measurements with handles.
   UINT32                NumPEIMs;         ///< Number of measurements of PEIMs.
   UINT32                NumGlobal;        ///< Number of measurements with END value and NULL handle.
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
index c7eb0fbd71e..ced8a487428 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
@@ -70,19 +70,17 @@
 #string STR_DP_STATS_NUMPHASES         #language en-US  "%,8d are major execution phases.\n"
 #string STR_DP_STATS_NUMHANDLES        #language en-US  "%,8d have non-NULL handles, %d are NULL.\n"
 #string STR_DP_STATS_NUMPEIMS          #language en-US  "%,8d are PEIMs.\n"
 #string STR_DP_STATS_NUMGLOBALS        #language en-US  "%,8d are general measurements.\n"
 #string STR_DP_STATS_NUMPROFILE        #language en-US  "%,8d are profiling records.\n"
-#string STR_DP_SECTION_PROFILE         #language en-US  "Sequential Profile Records"
 #string STR_DP_SECTION_ALL             #language en-US  "Sequential Trace Records"
 #string STR_DP_ALL_HEADR               #language en-US  "\nIndex      Handle                 Module                      Token    Time(us)\n"
 #string STR_DP_ALL_VARS                #language en-US  "%5d:%3s0x%08p %36s %13s %L8d\n"
 #string STR_DP_ALL_DASHES2             #language en-US  "-------------------------------------------------------------------------------------\n"
 #string STR_DP_ALL_HEADR2              #language en-US  "\nIndex      Handle                 Module                      Token    Time(us)    ID\n"
 #string STR_DP_ALL_VARS2               #language en-US  "%5d:%3s0x%08p %36s %13s %L8d %5d\n"
 #string STR_DP_SECTION_RAWTRACE        #language en-US  "RAW Trace"
-#string STR_DP_SECTION_RAWPROFILE      #language en-US  "RAW Profile"
 #string STR_DP_RAW_DASHES              #language en-US  "---------------------------------------------------------------------------------------------------------------------------\n"
 #string STR_DP_RAW_VARS                #language en-US  "%5d: %16LX %16LX %16LX  %31a  %31a\n"
 #string STR_DP_RAW_HEADR               #language en-US  "\nIndex       Handle        Start Count       End Count                  Token                          Module\n"
 #string STR_DP_RAW_DASHES2             #language en-US  "---------------------------------------------------------------------------------------------------------------------------------\n"
 #string STR_DP_RAW_VARS2               #language en-US  "%5d: %16LX %16LX %16LX  %31a  %31a %5d\n"
@@ -96,21 +94,19 @@
 #string STR_GET_HELP_DP         #language en-US ""
 ".TH dp 0 "Display performance metrics"\r\n"
 ".SH NAME\r\n"
 "Displays performance metrics that are stored in memory.\r\n"
 ".SH SYNOPSIS\r\n"
-"DP [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]][-i] [-h | -?]\r\n"
+"DP [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]][-i] [-?]\r\n"
 ".SH OPTIONS\r\n"
 " \r\n"
 "  -b       - Displays on multiple pages\r\n"
 "  -v       - Displays additional information\r\n"
 "  -x       - Prevents display of individual measurements for cumulative items\r\n"
 "  -s       - Displays summary information only\r\n"
 "  -A       - Displays all measurements in a list\r\n"
 "  -R       - Displays all measurements in raw format\r\n"
-"  -T       - Displays trace measurements only\r\n"
-"  -P       - Displays profile measurements only\r\n"
 "  -t VALUE - Sets display threshold to VALUE microseconds\r\n"
 "  -n COUNT - Limits display to COUNT lines in All and Raw modes\r\n"
 "  -i       - Displays identifier\r\n"
 "  -c TOKEN - Display pre-defined and custom cumulative data\r\n" 
 "             Pre-defined cumulative token are:\r\n"
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
index 54fe0017541..cedb333b285 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
@@ -31,11 +31,10 @@
   Literals.h
   Literals.c
   DpInternal.h
   DpUtilities.c
   DpTrace.c
-  DpProfile.c
   DpApp.c
 
 [Packages]
   MdePkg/MdePkg.dec
   ShellPkg/ShellPkg.dec
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
index e906870bd5e..8fd3bbd5df8 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
@@ -32,11 +32,10 @@
   Literals.h
   Literals.c
   DpInternal.h
   DpUtilities.c
   DpTrace.c
-  DpProfile.c
   DpDynamicCommand.c
 
 [Packages]
   MdePkg/MdePkg.dec
   ShellPkg/ShellPkg.dec
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
index eedc377cded..8dd3076cc71 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
@@ -302,54 +302,6 @@ ProcessGlobal(
 VOID
 ProcessCumulative(
   IN PERF_CUM_DATA                  *CustomCumulativeData OPTIONAL
   );
 
-/** 
-  Gather and print ALL Profiling Records.
-  
-  Displays all "interesting" Profile measurements in order.
-  The number of records displayed is controlled by:
-     - records with a duration less than mInterestThreshold microseconds are not displayed.
-     - No more than Limit records are displayed.  A Limit of zero will not limit the output.
-     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
-       displayed.
-  
-  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
-           The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
-           They must not be in use by a calling function.
-  
-  @param[in]    Limit         The number of records to print.  Zero is ALL.
-  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
-  
-**/
-VOID
-DumpAllProfile(
-  IN UINTN          Limit,
-  IN BOOLEAN        ExcludeFlag
-  );
-
-/** 
-  Gather and print Raw Profile Records.
-  
-  All Profile measurements with a duration greater than or equal to
-  mInterestThreshold are printed without interpretation.
-  
-  The number of records displayed is controlled by:
-     - records with a duration less than mInterestThreshold microseconds are not displayed.
-     - No more than Limit records are displayed.  A Limit of zero will not limit the output.
-     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
-       displayed.
-  
-  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
-  
-  @param[in]    Limit         The number of records to print.  Zero is ALL.
-  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
-  
-**/
-VOID
-DumpRawProfile(
-  IN UINTN          Limit,
-  IN BOOLEAN        ExcludeFlag
-  );
-
 #endif
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
deleted file mode 100644
index af25217daef..00000000000
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/** @file
-  Measured Profiling reporting for the Dp utility.
-
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-  This program and the accompanying materials
-  are licensed and made available under the terms and conditions of the BSD License
-  which accompanies this distribution.  The full text of the license may be found at
-  http://opensource.org/licenses/bsd-license.php
-
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/PerformanceLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HiiLib.h>
-#include <Library/PcdLib.h>
-
-#include <Guid/Performance.h>
-
-#include "Dp.h"
-#include "Literals.h"
-#include "DpInternal.h"
-
-/**
-  Gather and print ALL Profiling Records.
-
-  Displays all "interesting" Profile measurements in order.
-  The number of records displayed is controlled by:
-     - records with a duration less than mInterestThreshold microseconds are not displayed.
-     - No more than Limit records are displayed.  A Limit of zero will not limit the output.
-     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
-       displayed.
-
-  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
-           The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
-           They must not be in use by a calling function.
-
-  @param[in]    Limit         The number of records to print.  Zero is ALL.
-  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpAllProfile(
-  IN UINTN      Limit,
-  IN BOOLEAN    ExcludeFlag
-  )
-{
-  EFI_STRING    StringPtr;
-  EFI_STRING    StringPtrUnknown;
-
-  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
-  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
-
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
-              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
-  FreePool (StringPtr);
-  FreePool (StringPtrUnknown);
-}
-
-/**
-  Gather and print Raw Profile Records.
-
-  All Profile measurements with a duration greater than or equal to
-  mInterestThreshold are printed without interpretation.
-
-  The number of records displayed is controlled by:
-     - records with a duration less than mInterestThreshold microseconds are not displayed.
-     - No more than Limit records are displayed.  A Limit of zero will not limit the output.
-     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
-       displayed.
-
-  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
-
-  @param[in]    Limit         The number of records to print.  Zero is ALL.
-  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
-
-**/
-VOID
-DumpRawProfile(
-  IN UINTN      Limit,
-  IN BOOLEAN    ExcludeFlag
-  )
-{
-  EFI_STRING    StringPtr;
-  EFI_STRING    StringPtrUnknown;
-
-  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
-  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
-              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
-  FreePool (StringPtr);
-  FreePool (StringPtrUnknown);
-}
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch V2 3/3] ShellPkg/Dp: Make the help info align with code
  2018-06-11  8:32 ` [patch V2 3/3] ShellPkg/Dp: Make the help info align with code Dandan Bi
@ 2018-06-12  4:21   ` Gao, Liming
  0 siblings, 0 replies; 5+ messages in thread
From: Gao, Liming @ 2018-06-12  4:21 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu, Carsey, Jaben

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Bi, Dandan
> Sent: Monday, June 11, 2018 4:32 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [patch V2 3/3] ShellPkg/Dp: Make the help info align with code
> 
> Currently in DP, the Trace mode is enabled by default.
> And the profile mode is not implemented. but the help info
> of DP tool doesn't match current implementation. Which will
> make user confused. So now remove the unused source code
> related to the profile mode and update the help information
> of DP tool.
> 
> V2: Remove the unused code related to profile mode.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c      |  96 ++++++--------------
>  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h      |   7 --
>  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni    |   6 +-
>  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf |   1 -
>  .../DpDynamicCommand/DpDynamicCommand.inf          |   1 -
>  .../DynamicCommand/DpDynamicCommand/DpInternal.h   |  48 ----------
>  .../DynamicCommand/DpDynamicCommand/DpProfile.c    | 100 ---------------------
>  7 files changed, 26 insertions(+), 233 deletions(-)
>  delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
> 
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> index d8451dbf59f..38766613175 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> @@ -82,14 +82,10 @@ UINT32 const      NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
>  STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
>    {L"-v", TypeFlag},   // -v   Verbose Mode
>    {L"-A", TypeFlag},   // -A   All, Cooked
>    {L"-R", TypeFlag},   // -R   RAW All
>    {L"-s", TypeFlag},   // -s   Summary
> -#if PROFILING_IMPLEMENTED
> -  {L"-P", TypeFlag},   // -P   Dump Profile Data
> -  {L"-T", TypeFlag},   // -T   Dump Trace Data
> -#endif // PROFILING_IMPLEMENTED
>    {L"-x", TypeFlag},   // -x   eXclude Cumulative Items
>    {L"-i", TypeFlag},   // -i   Display Identifier
>    {L"-c", TypeValue},  // -c   Display cumulative data.
>    {L"-n", TypeValue},  // -n # Number of records to display for A and R
>    {L"-t", TypeValue},  // -t # Threshold of interest
> @@ -114,13 +110,10 @@ DumpStatistics( void )
>    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);
>    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle,     SummaryData.NumSummary);
>    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), mDpHiiHandle,    SummaryData.NumHandles,
> SummaryData.NumTrace - SummaryData.NumHandles);
>    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), mDpHiiHandle,      SummaryData.NumPEIMs);
>    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle,    SummaryData.NumGlobal);
> -#if PROFILING_IMPLEMENTED
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), mDpHiiHandle,    SummaryData.NumProfile);
> -#endif // PROFILING_IMPLEMENTED
>    SHELL_FREE_NON_NULL (StringPtr);
>    SHELL_FREE_NON_NULL (StringPtrUnknown);
>  }
> 
>  /**
> @@ -682,11 +675,10 @@ VOID
>  InitSummaryData (
>    VOID
>    )
>  {
>    SummaryData.NumTrace      = 0;
> -  SummaryData.NumProfile    = 0 ;
>    SummaryData.NumIncomplete = 0;
>    SummaryData.NumSummary    = 0;
>    SummaryData.NumHandles    = 0;
>    SummaryData.NumPEIMs      = 0;
>    SummaryData.NumGlobal     = 0;
> @@ -719,12 +711,10 @@ RunDp (
>    EFI_STRING                StringPtr;
>    BOOLEAN                   SummaryMode;
>    BOOLEAN                   VerboseMode;
>    BOOLEAN                   AllMode;
>    BOOLEAN                   RawMode;
> -  BOOLEAN                   TraceMode;
> -  BOOLEAN                   ProfileMode;
>    BOOLEAN                   ExcludeMode;
>    BOOLEAN                   CumulativeMode;
>    CONST CHAR16              *CustomCumulativeToken;
>    PERF_CUM_DATA             *CustomCumulativeData;
>    UINTN                     NameSize;
> @@ -734,12 +724,10 @@ RunDp (
>    StringPtr   = NULL;
>    SummaryMode = FALSE;
>    VerboseMode = FALSE;
>    AllMode     = FALSE;
>    RawMode     = FALSE;
> -  TraceMode   = FALSE;
> -  ProfileMode = FALSE;
>    ExcludeMode = FALSE;
>    CumulativeMode = FALSE;
>    CustomCumulativeData = NULL;
>    ShellStatus = SHELL_SUCCESS;
> 
> @@ -763,14 +751,10 @@ RunDp (
>    //
>    VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");
>    SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage,
> L"-s"));
>    AllMode     = ShellCommandLineGetFlag (ParamPackage, L"-A");
>    RawMode     = ShellCommandLineGetFlag (ParamPackage, L"-R");
> -#if PROFILING_IMPLEMENTED
> -  TraceMode   = ShellCommandLineGetFlag (ParamPackage, L"-T");
> -  ProfileMode = ShellCommandLineGetFlag (ParamPackage, L"-P");
> -#endif  // PROFILING_IMPLEMENTED
>    ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");
>    mShowId     = ShellCommandLineGetFlag (ParamPackage, L"-i");
>    CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");
> 
>    // Options with Values
> @@ -789,18 +773,10 @@ RunDp (
>      mInterestThreshold = DEFAULT_THRESHOLD;  // 1ms := 1,000 us
>    } else {
>      mInterestThreshold = StrDecimalToUint64(CmdLineArg);
>    }
> 
> -  // Handle Flag combinations and default behaviors
> -  // If both TraceMode and ProfileMode are FALSE, set them both to TRUE
> -  if ((! TraceMode) && (! ProfileMode)) {
> -    TraceMode   = TRUE;
> -#if PROFILING_IMPLEMENTED
> -    ProfileMode = TRUE;
> -#endif  // PROFILING_IMPLEMENTED
> -  }
> 
>    //
>    // DP dump performance data by parsing FPDT table in ACPI table.
>    // Folloing 3 steps are to get the measurement form the FPDT table.
>    //
> @@ -917,71 +893,49 @@ RunDp (
>  ****    n Number2Display  Used by All and Raw mode.  Otherwise ignored.
>  ****    A All         --  R and S options are ignored
>  ****    R Raw         --  S option is ignored
>  ****    s Summary     --  Modifies "Cooked" output only
>  ****    Cooked (Default)
> -****
> -****  The All, Raw, and Cooked modes are modified by the Trace and Profile
> -****  options.
> -****    !T && !P  := (0) Default, Both are displayed
> -****     T && !P  := (1) Only Trace records are displayed
> -****    !T &&  P  := (2) Only Profile records are displayed
> -****     T &&  P  := (3) Same as Default, both are displayed
>  ****************************************************************************/
>    GatherStatistics (CustomCumulativeData);
>    if (CumulativeMode) {
>      ProcessCumulative (CustomCumulativeData);
>    } else if (AllMode) {
> -    if (TraceMode) {
> -      Status = DumpAllTrace( Number2Display, ExcludeMode);
> +    Status = DumpAllTrace( Number2Display, ExcludeMode);
> +    if (Status == EFI_ABORTED) {
> +      ShellStatus = SHELL_ABORTED;
> +      goto Done;
> +    }
> +  } else if (RawMode) {
> +    Status = DumpRawTrace( Number2Display, ExcludeMode);
> +    if (Status == EFI_ABORTED) {
> +      ShellStatus = SHELL_ABORTED;
> +      goto Done;
> +    }
> +  } else {
> +    //------------- Begin Cooked Mode Processing
> +    ProcessPhases ();
> +    if ( ! SummaryMode) {
> +      Status = ProcessHandles ( ExcludeMode);
>        if (Status == EFI_ABORTED) {
>          ShellStatus = SHELL_ABORTED;
>          goto Done;
>        }
> -    }
> -    if (ProfileMode) {
> -      DumpAllProfile( Number2Display, ExcludeMode);
> -    }
> -  } else if (RawMode) {
> -    if (TraceMode) {
> -      Status = DumpRawTrace( Number2Display, ExcludeMode);
> +
> +      Status = ProcessPeims ();
>        if (Status == EFI_ABORTED) {
>          ShellStatus = SHELL_ABORTED;
>          goto Done;
>        }
> -    }
> -    if (ProfileMode) {
> -      DumpRawProfile( Number2Display, ExcludeMode);
> -    }
> -  } else {
> -    //------------- Begin Cooked Mode Processing
> -    if (TraceMode) {
> -      ProcessPhases ();
> -      if ( ! SummaryMode) {
> -        Status = ProcessHandles ( ExcludeMode);
> -        if (Status == EFI_ABORTED) {
> -          ShellStatus = SHELL_ABORTED;
> -          goto Done;
> -        }
> -
> -        Status = ProcessPeims ();
> -        if (Status == EFI_ABORTED) {
> -          ShellStatus = SHELL_ABORTED;
> -          goto Done;
> -        }
> -
> -        Status = ProcessGlobal ();
> -        if (Status == EFI_ABORTED) {
> -          ShellStatus = SHELL_ABORTED;
> -          goto Done;
> -        }
> -
> -        ProcessCumulative (NULL);
> +
> +      Status = ProcessGlobal ();
> +      if (Status == EFI_ABORTED) {
> +        ShellStatus = SHELL_ABORTED;
> +        goto Done;
>        }
> -    }
> -    if (ProfileMode) {
> -      DumpAllProfile( Number2Display, ExcludeMode);
> +
> +       ProcessCumulative (NULL);
>      }
>    } //------------- End of Cooked Mode Processing
>    if ( VerboseMode || SummaryMode) {
>      DumpStatistics();
>    }
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
> index 9fd88578720..aae021334d6 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
> @@ -51,16 +51,10 @@ extern EFI_HANDLE mDpHiiHandle;
>    * The value assigned to DP_DEBUG controls which debug output
>    * is generated.  Set it to ZERO to disable.
>  **/
>  #define DP_DEBUG                0
> 
> -/**
> -  * Set to 1 once Profiling has been implemented in order to enable
> -  * profiling related options and report output.
> -**/
> -#define PROFILING_IMPLEMENTED   0
> -
>  #define DEFAULT_THRESHOLD       1000    ///< One millisecond.
>  #define DEFAULT_DISPLAYCOUNT    50
>  #define MAXIMUM_DISPLAYCOUNT    999999  ///< Arbitrary maximum reasonable number.
> 
>  #define PERF_MAXDUR             0xFFFFFFFFFFFFFFFFULL
> @@ -95,11 +89,10 @@ typedef struct {
>    UINT32  Count;        ///< Total number of measurements accumulated.
>  } PERF_CUM_DATA;
> 
>  typedef struct {
>    UINT32                NumTrace;         ///< Number of recorded TRACE performance measurements.
> -  UINT32                NumProfile;       ///< Number of recorded PROFILE performance measurements.
>    UINT32                NumIncomplete;    ///< Number of measurements with no END value.
>    UINT32                NumSummary;       ///< Number of summary section measurements.
>    UINT32                NumHandles;       ///< Number of measurements with handles.
>    UINT32                NumPEIMs;         ///< Number of measurements of PEIMs.
>    UINT32                NumGlobal;        ///< Number of measurements with END value and NULL handle.
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
> index c7eb0fbd71e..ced8a487428 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
> @@ -70,19 +70,17 @@
>  #string STR_DP_STATS_NUMPHASES         #language en-US  "%,8d are major execution phases.\n"
>  #string STR_DP_STATS_NUMHANDLES        #language en-US  "%,8d have non-NULL handles, %d are NULL.\n"
>  #string STR_DP_STATS_NUMPEIMS          #language en-US  "%,8d are PEIMs.\n"
>  #string STR_DP_STATS_NUMGLOBALS        #language en-US  "%,8d are general measurements.\n"
>  #string STR_DP_STATS_NUMPROFILE        #language en-US  "%,8d are profiling records.\n"
> -#string STR_DP_SECTION_PROFILE         #language en-US  "Sequential Profile Records"
>  #string STR_DP_SECTION_ALL             #language en-US  "Sequential Trace Records"
>  #string STR_DP_ALL_HEADR               #language en-US  "\nIndex      Handle                 Module
> Token    Time(us)\n"
>  #string STR_DP_ALL_VARS                #language en-US  "%5d:%3s0x%08p %36s %13s %L8d\n"
>  #string STR_DP_ALL_DASHES2             #language en-US
> "-------------------------------------------------------------------------------------\n"
>  #string STR_DP_ALL_HEADR2              #language en-US  "\nIndex      Handle                 Module
> Token    Time(us)    ID\n"
>  #string STR_DP_ALL_VARS2               #language en-US  "%5d:%3s0x%08p %36s %13s %L8d %5d\n"
>  #string STR_DP_SECTION_RAWTRACE        #language en-US  "RAW Trace"
> -#string STR_DP_SECTION_RAWPROFILE      #language en-US  "RAW Profile"
>  #string STR_DP_RAW_DASHES              #language en-US
> "---------------------------------------------------------------------------------------------------------------------------\n"
>  #string STR_DP_RAW_VARS                #language en-US  "%5d: %16LX %16LX %16LX  %31a  %31a\n"
>  #string STR_DP_RAW_HEADR               #language en-US  "\nIndex       Handle        Start Count       End Count
> Token                          Module\n"
>  #string STR_DP_RAW_DASHES2             #language en-US
> "---------------------------------------------------------------------------------------------------------------------------------\n"
>  #string STR_DP_RAW_VARS2               #language en-US  "%5d: %16LX %16LX %16LX  %31a  %31a %5d\n"
> @@ -96,21 +94,19 @@
>  #string STR_GET_HELP_DP         #language en-US ""
>  ".TH dp 0 "Display performance metrics"\r\n"
>  ".SH NAME\r\n"
>  "Displays performance metrics that are stored in memory.\r\n"
>  ".SH SYNOPSIS\r\n"
> -"DP [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]][-i] [-h | -?]\r\n"
> +"DP [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]][-i] [-?]\r\n"
>  ".SH OPTIONS\r\n"
>  " \r\n"
>  "  -b       - Displays on multiple pages\r\n"
>  "  -v       - Displays additional information\r\n"
>  "  -x       - Prevents display of individual measurements for cumulative items\r\n"
>  "  -s       - Displays summary information only\r\n"
>  "  -A       - Displays all measurements in a list\r\n"
>  "  -R       - Displays all measurements in raw format\r\n"
> -"  -T       - Displays trace measurements only\r\n"
> -"  -P       - Displays profile measurements only\r\n"
>  "  -t VALUE - Sets display threshold to VALUE microseconds\r\n"
>  "  -n COUNT - Limits display to COUNT lines in All and Raw modes\r\n"
>  "  -i       - Displays identifier\r\n"
>  "  -c TOKEN - Display pre-defined and custom cumulative data\r\n"
>  "             Pre-defined cumulative token are:\r\n"
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> index 54fe0017541..cedb333b285 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> @@ -31,11 +31,10 @@
>    Literals.h
>    Literals.c
>    DpInternal.h
>    DpUtilities.c
>    DpTrace.c
> -  DpProfile.c
>    DpApp.c
> 
>  [Packages]
>    MdePkg/MdePkg.dec
>    ShellPkg/ShellPkg.dec
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
> index e906870bd5e..8fd3bbd5df8 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
> @@ -32,11 +32,10 @@
>    Literals.h
>    Literals.c
>    DpInternal.h
>    DpUtilities.c
>    DpTrace.c
> -  DpProfile.c
>    DpDynamicCommand.c
> 
>  [Packages]
>    MdePkg/MdePkg.dec
>    ShellPkg/ShellPkg.dec
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
> index eedc377cded..8dd3076cc71 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
> @@ -302,54 +302,6 @@ ProcessGlobal(
>  VOID
>  ProcessCumulative(
>    IN PERF_CUM_DATA                  *CustomCumulativeData OPTIONAL
>    );
> 
> -/**
> -  Gather and print ALL Profiling Records.
> -
> -  Displays all "interesting" Profile measurements in order.
> -  The number of records displayed is controlled by:
> -     - records with a duration less than mInterestThreshold microseconds are not displayed.
> -     - No more than Limit records are displayed.  A Limit of zero will not limit the output.
> -     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
> -       displayed.
> -
> -  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
> -           The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
> -           They must not be in use by a calling function.
> -
> -  @param[in]    Limit         The number of records to print.  Zero is ALL.
> -  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
> -
> -**/
> -VOID
> -DumpAllProfile(
> -  IN UINTN          Limit,
> -  IN BOOLEAN        ExcludeFlag
> -  );
> -
> -/**
> -  Gather and print Raw Profile Records.
> -
> -  All Profile measurements with a duration greater than or equal to
> -  mInterestThreshold are printed without interpretation.
> -
> -  The number of records displayed is controlled by:
> -     - records with a duration less than mInterestThreshold microseconds are not displayed.
> -     - No more than Limit records are displayed.  A Limit of zero will not limit the output.
> -     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
> -       displayed.
> -
> -  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
> -
> -  @param[in]    Limit         The number of records to print.  Zero is ALL.
> -  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
> -
> -**/
> -VOID
> -DumpRawProfile(
> -  IN UINTN          Limit,
> -  IN BOOLEAN        ExcludeFlag
> -  );
> -
>  #endif
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
> deleted file mode 100644
> index af25217daef..00000000000
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
> +++ /dev/null
> @@ -1,100 +0,0 @@
> -/** @file
> -  Measured Profiling reporting for the Dp utility.
> -
> -  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
> -  This program and the accompanying materials
> -  are licensed and made available under the terms and conditions of the BSD License
> -  which accompanies this distribution.  The full text of the license may be found at
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> -**/
> -
> -#include <Library/BaseLib.h>
> -#include <Library/BaseMemoryLib.h>
> -#include <Library/MemoryAllocationLib.h>
> -#include <Library/DebugLib.h>
> -#include <Library/UefiBootServicesTableLib.h>
> -#include <Library/PeCoffGetEntryPointLib.h>
> -#include <Library/PerformanceLib.h>
> -#include <Library/PrintLib.h>
> -#include <Library/HiiLib.h>
> -#include <Library/PcdLib.h>
> -
> -#include <Guid/Performance.h>
> -
> -#include "Dp.h"
> -#include "Literals.h"
> -#include "DpInternal.h"
> -
> -/**
> -  Gather and print ALL Profiling Records.
> -
> -  Displays all "interesting" Profile measurements in order.
> -  The number of records displayed is controlled by:
> -     - records with a duration less than mInterestThreshold microseconds are not displayed.
> -     - No more than Limit records are displayed.  A Limit of zero will not limit the output.
> -     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
> -       displayed.
> -
> -  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
> -           The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
> -           They must not be in use by a calling function.
> -
> -  @param[in]    Limit         The number of records to print.  Zero is ALL.
> -  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
> -
> -**/
> -VOID
> -DumpAllProfile(
> -  IN UINTN      Limit,
> -  IN BOOLEAN    ExcludeFlag
> -  )
> -{
> -  EFI_STRING    StringPtr;
> -  EFI_STRING    StringPtrUnknown;
> -
> -  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
> -
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
> -              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
> -  FreePool (StringPtr);
> -  FreePool (StringPtrUnknown);
> -}
> -
> -/**
> -  Gather and print Raw Profile Records.
> -
> -  All Profile measurements with a duration greater than or equal to
> -  mInterestThreshold are printed without interpretation.
> -
> -  The number of records displayed is controlled by:
> -     - records with a duration less than mInterestThreshold microseconds are not displayed.
> -     - No more than Limit records are displayed.  A Limit of zero will not limit the output.
> -     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
> -       displayed.
> -
> -  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
> -
> -  @param[in]    Limit         The number of records to print.  Zero is ALL.
> -  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
> -
> -**/
> -VOID
> -DumpRawProfile(
> -  IN UINTN      Limit,
> -  IN BOOLEAN    ExcludeFlag
> -  )
> -{
> -  EFI_STRING    StringPtr;
> -  EFI_STRING    StringPtrUnknown;
> -
> -  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
> -              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
> -  FreePool (StringPtr);
> -  FreePool (StringPtrUnknown);
> -}
> --
> 2.14.3.windows.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch V2 2/3] ShellPkg/Dp: Initialize summary date when run DP
  2018-06-11  8:32 ` [patch V2 2/3] ShellPkg/Dp: Initialize summary date when run DP Dandan Bi
@ 2018-06-12  8:10   ` Ni, Ruiyu
  0 siblings, 0 replies; 5+ messages in thread
From: Ni, Ruiyu @ 2018-06-12  8:10 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming, Carsey, Jaben

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Thanks/Ray

> -----Original Message-----
> From: Bi, Dandan
> Sent: Monday, June 11, 2018 4:32 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [patch V2 2/3] ShellPkg/Dp: Initialize summary date when run DP
> 
> Issue:
> When run "dp -s" or ("dp -v") command in shell several times, the summary
> reuslts are different each time.
> 
> The root cause is that the previous global data "SummaryData"
> is not cleaned when the dp command is callled next time.
> This patch initializes the global data "SummaryData"
> when the dp dymanic command is called.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> ---
>  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 23
> +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> index fe85937f557..d8451dbf59f 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> @@ -672,10 +672,28 @@ InitCumulativeData (
>      CumData[Index].MaxDur = 0;
>      CumData[Index].Duration = 0;
>    }
>  }
> 
> +/**
> +  Initialize the Summary data.
> +
> +**/
> +VOID
> +InitSummaryData (
> +  VOID
> +  )
> +{
> +  SummaryData.NumTrace      = 0;
> +  SummaryData.NumProfile    = 0 ;
> +  SummaryData.NumIncomplete = 0;
> +  SummaryData.NumSummary    = 0;
> +  SummaryData.NumHandles    = 0;
> +  SummaryData.NumPEIMs      = 0;
> +  SummaryData.NumGlobal     = 0;
> +}
> +
>  /**
>    Dump performance data.
> 
>    @param[in]  ImageHandle     The image handle.
>    @param[in]  SystemTable     The system table.
> @@ -817,10 +835,15 @@ RunDp (
>    //
>    // Initialize the pre-defined cumulative data.
>    //
>    InitCumulativeData ();
> 
> +  //
> +  // Initialize the Summary data.
> +  //
> +  InitSummaryData ();
> +
>    //
>    // Init the custom cumulative data.
>    //
>    CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage,
> L"-c");
>    if (CustomCumulativeToken != NULL) {
> --
> 2.14.3.windows.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-12  8:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-11  8:32 [patch V2 1/3] ShellPkg/Dp: make sure memory is freed before exit Dandan Bi
2018-06-11  8:32 ` [patch V2 2/3] ShellPkg/Dp: Initialize summary date when run DP Dandan Bi
2018-06-12  8:10   ` Ni, Ruiyu
2018-06-11  8:32 ` [patch V2 3/3] ShellPkg/Dp: Make the help info align with code Dandan Bi
2018-06-12  4:21   ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox