From 0b84f444de5b7d3f4224e728c9f2232742c0462d Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Tue, 24 Apr 2012 09:15:10 +0000 Subject: [PATCH] Add new extension PerformanceLib APIs to store ID info. Signed-off-by: Star Zeng Reviewed-by: Liming Gao git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13216 6f19259b-4bc3-4df7-8a09-765794883524 --- PerformancePkg/Dp_App/Dp.c | 10 +- PerformancePkg/Dp_App/Dp.h | 3 +- PerformancePkg/Dp_App/DpInternal.h | 3 +- PerformancePkg/Dp_App/DpStrings.uni | Bin 29764 -> 36606 bytes PerformancePkg/Dp_App/DpTrace.c | 213 +++++++++++++++++++--------- 5 files changed, 162 insertions(+), 67 deletions(-) diff --git a/PerformancePkg/Dp_App/Dp.c b/PerformancePkg/Dp_App/Dp.c index 5059892192..57144a8fb8 100644 --- a/PerformancePkg/Dp_App/Dp.c +++ b/PerformancePkg/Dp_App/Dp.c @@ -13,7 +13,7 @@ Dp uses this information to group records in different ways. It also uses timer information to calculate elapsed time for each measurement. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2012, 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 @@ -49,6 +49,7 @@ CHAR16 *mPrintTokenBuffer = NULL; CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; UINT64 mInterestThreshold; +BOOLEAN mShowId = FALSE; PERF_SUMMARY_DATA SummaryData = { 0 }; ///< Create the SummaryData structure and init. to ZERO. @@ -79,6 +80,7 @@ PARAM_ITEM_LIST ParamList[] = { {STRING_TOKEN (STR_DP_OPTION_UT), TypeFlag}, // -T Dump Trace Data #endif {STRING_TOKEN (STR_DP_OPTION_LX), TypeFlag}, // -x eXclude Cumulative Items + {STRING_TOKEN (STR_DP_OPTION_LI), TypeFlag}, // -i Display Identifier {STRING_TOKEN (STR_DP_OPTION_LN), TypeValue}, // -n # Number of records to display for A and R {STRING_TOKEN (STR_DP_OPTION_LT), TypeValue} // -t # Threshold of interest }; @@ -135,6 +137,7 @@ ShowHelp( void ) #endif // PROFILING_IMPLEMENTED PrintToken (STRING_TOKEN (STR_DP_HELP_THRESHOLD)); PrintToken (STRING_TOKEN (STR_DP_HELP_COUNT)); + PrintToken (STRING_TOKEN (STR_DP_HELP_ID)); PrintToken (STRING_TOKEN (STR_DP_HELP_HELP)); Print(L"\n"); } @@ -214,6 +217,7 @@ InitializeDp ( EFI_STRING StringDpOptionLx; EFI_STRING StringDpOptionLn; EFI_STRING StringDpOptionLt; + EFI_STRING StringDpOptionLi; SummaryMode = FALSE; VerboseMode = FALSE; @@ -236,6 +240,7 @@ InitializeDp ( StringDpOptionLx = NULL; StringDpOptionLn = NULL; StringDpOptionLt = NULL; + StringDpOptionLi = NULL; StringPtr = NULL; // Get DP's entry time as soon as possible. @@ -283,6 +288,7 @@ InitializeDp ( StringDpOptionLx = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LX), NULL); StringDpOptionLn = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LN), NULL); StringDpOptionLt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LT), NULL); + StringDpOptionLi = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LI), NULL); // Boolean Options // @@ -296,6 +302,7 @@ InitializeDp ( ProfileMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUp); #endif // PROFILING_IMPLEMENTED ExcludeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLx); + mShowId = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLi); // Options with Values CmdLineArg = ShellCommandLineGetValue (ParamPackage, StringDpOptionLn); @@ -447,6 +454,7 @@ InitializeDp ( SafeFreePool (StringDpOptionLx); SafeFreePool (StringDpOptionLn); SafeFreePool (StringDpOptionLt); + SafeFreePool (StringDpOptionLi); SafeFreePool (StringPtr); SafeFreePool (mPrintTokenBuffer); diff --git a/PerformancePkg/Dp_App/Dp.h b/PerformancePkg/Dp_App/Dp.h index 489c9684db..5fc3335279 100644 --- a/PerformancePkg/Dp_App/Dp.h +++ b/PerformancePkg/Dp_App/Dp.h @@ -1,7 +1,7 @@ /** @file Common declarations for the Dp Performance Reporting Utility. - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2012, 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 @@ -83,6 +83,7 @@ typedef struct { CONST CHAR8 *Module; ///< Module string name. UINT64 StartTimeStamp; ///< Start time point. UINT64 EndTimeStamp; ///< End time point. + UINT32 Identifier; ///< Identifier. } MEASUREMENT_RECORD; typedef struct { diff --git a/PerformancePkg/Dp_App/DpInternal.h b/PerformancePkg/Dp_App/DpInternal.h index 223feef9b8..eb4f274892 100644 --- a/PerformancePkg/Dp_App/DpInternal.h +++ b/PerformancePkg/Dp_App/DpInternal.h @@ -6,7 +6,7 @@ Dp application. In addition to global data, function declarations for DpUtilities.c, DpTrace.c, and DpProfile.c are included here. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2012, 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 @@ -28,6 +28,7 @@ extern CHAR16 *mPrintTokenBuffer; extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; extern UINT64 mInterestThreshold; +extern BOOLEAN mShowId; extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData structure and init. to ZERO. diff --git a/PerformancePkg/Dp_App/DpStrings.uni b/PerformancePkg/Dp_App/DpStrings.uni index 22925ba348c18d9ed5ef1d76160bd3e863ab18c7..eddc02c2b8536c63718b82040f9c0238e21d23ce 100644 GIT binary patch delta 1282 zcmbVMOH5Ny5S<5>wzL$&Cutu|+wijrHf^CTpB7pLV+}<7JnOz`PC*!s&_4tdxT3j4R&MJy;Q_x_hf5_&Y_sLzyu4669F^u_TfGX$f?ABo zRQS$jMuUULGJBrF0P&9{ThW}us9l9Iy9t-=Rpg__Zw>irK9q#Tm;0d`JkSYUcvs$p zjUJiJ00*EPs^K&o6k{^k4kr_`1uRLq6>6yo19{uJCV33~%&#?kA;6Z12~RO|=f7qF(^Yrf5}(4C+7dg!!#y-M%4Lp1Yd} zq(%ZrsTZpe`LP)fu9jNiFJ6h6cka}x3p~(DpC6iuhF!3SaAs62#%S1x7j(C9MyC|C zdY)qfYW3OZHt6tmcWP|9p7}IpGxj@s({+sPS$*s#@o4TlBw6F^W2q=5>N(#(D?wEt zCcFuJ&cL~W!Z=>~LPY>VQf>R+g-Z-{Es}*O%uf+Ye zVYWBp)JR-^aa7a`XOG7?(GWQiH;hJ@!OD5*mC}m@iVf$pSE}qx<_-wscvU$LjxS}Jvh!Eh delta 260 zcmex2m+8n0#t8w8h8qLFvQN(9l$cy2STy+-M;nm+2hRV+RRm-^Y~IGL!M|BZ#zAiL zKif0RjH;6hUE3!IIGF)i6BR8tC%LsTPJZTYHJQ&^YO;;TiOEc!7GQRm=Nx7;hT_TJ zJy$|$?a33IER-mKXEkr6B?*!dHv1SDnCb&L}z Y1%Z<{N-0m4>A3|~17vTO=zYcr0I?)t_W%F@ diff --git a/PerformancePkg/Dp_App/DpTrace.c b/PerformancePkg/Dp_App/DpTrace.c index a7c2049b85..1ba2b72ba4 100644 --- a/PerformancePkg/Dp_App/DpTrace.c +++ b/PerformancePkg/Dp_App/DpTrace.c @@ -1,7 +1,7 @@ /** @file Trace reporting for the Dp utility. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2012, 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 @@ -54,13 +54,14 @@ GatherStatistics( INTN TIndex; LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { ++SummaryData.NumTrace; // Count the number of TRACE Measurement records if (Measurement.EndTimeStamp == 0) { @@ -168,27 +169,31 @@ DumpAllTrace( // Display only records with Elapsed times >= mInterestThreshold // Display driver names in Module field for records with Handles. // - PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR) ); - PrintToken (STRING_TOKEN (STR_DP_DASHES) ); + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR2) ); + PrintToken (STRING_TOKEN (STR_DP_ALL_DASHES2) ); + } else { + PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR) ); + PrintToken (STRING_TOKEN (STR_DP_DASHES) ); + } LogEntryKey = 0; Count = 0; Index = 0; while ( WITHIN_LIMIT(Count, Limit) && - ((LogEntryKey = GetPerformanceMeasurement ( + ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) ) { ++Index; // Count every record. First record is 1. ElapsedTime = 0; - if (IncFlag != NULL) { - FreePool ((void *)IncFlag); - } + SafeFreePool ((VOID *) IncFlag); if (Measurement.EndTimeStamp != 0) { Duration = GetDuration (&Measurement); ElapsedTime = DurationInMicroSeconds ( Duration ); @@ -225,20 +230,32 @@ DumpAllTrace( mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; mUnicodeToken[13] = 0; - PrintToken( STRING_TOKEN (STR_DP_ALL_VARS), - Index, // 1 based, Which measurement record is being printed - IncFlag, - Measurement.Handle, - mGaugeString, - mUnicodeToken, - ElapsedTime - ); + if (mShowId) { + PrintToken( STRING_TOKEN (STR_DP_ALL_VARS2), + Index, // 1 based, Which measurement record is being printed + IncFlag, + Measurement.Handle, + mGaugeString, + mUnicodeToken, + ElapsedTime, + Measurement.Identifier + ); + } else { + PrintToken( STRING_TOKEN (STR_DP_ALL_VARS), + Index, // 1 based, Which measurement record is being printed + IncFlag, + Measurement.Handle, + mGaugeString, + mUnicodeToken, + ElapsedTime + ); + } } } if (HandleBuffer != &TempHandle) { FreePool (HandleBuffer); } - FreePool ((void *)IncFlag); + SafeFreePool ((VOID *) IncFlag); } /** @@ -282,20 +299,26 @@ DumpRawTrace( FreePool (StringPtr); FreePool (StringPtrUnknown); - PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR) ); - PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES) ); + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR2) ); + PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES2) ); + } else { + PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR) ); + PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES) ); + } LogEntryKey = 0; Count = 0; Index = 0; while ( WITHIN_LIMIT(Count, Limit) && - ((LogEntryKey = GetPerformanceMeasurement ( + ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) ) { ++Index; // Count every record. First record is 1. @@ -310,14 +333,27 @@ DumpRawTrace( continue; } ++Count; // Count the number of records printed - PrintToken (STRING_TOKEN (STR_DP_RAW_VARS), - Index, // 1 based, Which measurement record is being printed - Measurement.Handle, - Measurement.StartTimeStamp, - Measurement.EndTimeStamp, - Measurement.Token, - Measurement.Module - ); + + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_RAW_VARS2), + Index, // 1 based, Which measurement record is being printed + Measurement.Handle, + Measurement.StartTimeStamp, + Measurement.EndTimeStamp, + Measurement.Token, + Measurement.Module, + Measurement.Identifier + ); + } else { + PrintToken (STRING_TOKEN (STR_DP_RAW_VARS), + Index, // 1 based, Which measurement record is being printed + Measurement.Handle, + Measurement.StartTimeStamp, + Measurement.EndTimeStamp, + Measurement.Token, + Measurement.Module + ); + } } } @@ -363,13 +399,14 @@ ProcessPhases( FreePool (StringPtrUnknown); LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { if (AsciiStrnCmp (Measurement.Token, ALit_SHELL, PERF_TOKEN_LENGTH) == 0) { Measurement.EndTimeStamp = Ticker; @@ -512,18 +549,23 @@ ProcessHandles( Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0]))); #endif - PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION) ); + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION2) ); + } else { + PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION) ); + } PrintToken (STRING_TOKEN (STR_DP_DASHES) ); LogEntryKey = 0; Count = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { Count++; Duration = GetDuration (&Measurement); @@ -549,14 +591,26 @@ ProcessHandles( mUnicodeToken[11] = 0; if (mGaugeString[0] != 0) { // Display the record if it has a valid handle. - PrintToken ( - STRING_TOKEN (STR_DP_HANDLE_VARS), - Count, // 1 based, Which measurement record is being printed - Index + 1, // 1 based, Which handle is being printed - mGaugeString, - mUnicodeToken, - ElapsedTime - ); + if (mShowId) { + PrintToken ( + STRING_TOKEN (STR_DP_HANDLE_VARS2), + Count, // 1 based, Which measurement record is being printed + Index + 1, // 1 based, Which handle is being printed + mGaugeString, + mUnicodeToken, + ElapsedTime, + Measurement.Identifier + ); + } else { + PrintToken ( + STRING_TOKEN (STR_DP_HANDLE_VARS), + Count, // 1 based, Which measurement record is being printed + Index + 1, // 1 based, Which handle is being printed + mGaugeString, + mUnicodeToken, + ElapsedTime + ); + } } } } @@ -592,17 +646,22 @@ ProcessPeims( FreePool (StringPtr); FreePool (StringPtrUnknown); - PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION)); + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION2)); + } else { + PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION)); + } PrintToken (STRING_TOKEN (STR_DP_DASHES)); TIndex = 0; LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { TIndex++; if ((Measurement.EndTimeStamp == 0) || @@ -615,12 +674,22 @@ ProcessPeims( ElapsedTime = DurationInMicroSeconds ( Duration ); // Calculate elapsed time in microseconds if (ElapsedTime >= mInterestThreshold) { // PEIM FILE Handle is the start address of its FFS file that contains its file guid. - PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS), - TIndex, // 1 based, Which measurement record is being printed - Measurement.Handle, // base address - Measurement.Handle, // file guid - ElapsedTime - ); + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS2), + TIndex, // 1 based, Which measurement record is being printed + Measurement.Handle, // base address + Measurement.Handle, // file guid + ElapsedTime, + Measurement.Identifier + ); + } else { + PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS), + TIndex, // 1 based, Which measurement record is being printed + Measurement.Handle, // base address + Measurement.Handle, // file guid + ElapsedTime + ); + } } } } @@ -654,23 +723,28 @@ ProcessGlobal( FreePool (StringPtr); FreePool (StringPtrUnknown); - PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION)); + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION2)); + } else { + PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION)); + } PrintToken (STRING_TOKEN (STR_DP_DASHES)); Index = 1; LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { AsciiStrToUnicodeStr (Measurement.Module, mGaugeString); AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken); - mGaugeString[26] = 0; + mGaugeString[25] = 0; mUnicodeToken[31] = 0; if ( ! ( IsPhase( &Measurement) || (Measurement.Handle != NULL) || @@ -680,13 +754,24 @@ ProcessGlobal( Duration = GetDuration (&Measurement); ElapsedTime = DurationInMicroSeconds ( Duration ); if (ElapsedTime >= mInterestThreshold) { - PrintToken ( - STRING_TOKEN (STR_DP_GLOBAL_VARS), - Index, - mGaugeString, - mUnicodeToken, - ElapsedTime - ); + if (mShowId) { + PrintToken ( + STRING_TOKEN (STR_DP_GLOBAL_VARS2), + Index, + mGaugeString, + mUnicodeToken, + ElapsedTime, + Measurement.Identifier + ); + } else { + PrintToken ( + STRING_TOKEN (STR_DP_GLOBAL_VARS), + Index, + mGaugeString, + mUnicodeToken, + ElapsedTime + ); + } } } Index++; -- 2.39.2