ShellPkg/dp: Update dp tool to parse new Perf record

Since performance library instances have been updated
to create new FPDT records for new Perf macros.
So enhance dp tool to parse the new FPDT records.
Enhancement mainly includes:
1. parse the single records for PERF_EVENT macro
2. Parse the new added FPDT_DUAL_GUID_STRING_EVENT_RECORD

Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Bi, Dandan 2018-06-22 16:56:20 +08:00 committed by Liming Gao
parent 6b4d58a10c
commit f45dd2dd4f
5 changed files with 113 additions and 12 deletions

View File

@ -430,11 +430,25 @@ GetMeasurementInfo (
ASSERT(FALSE);
}
if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
Measurement->Handle = &(((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Guid);
if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
} else {
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle;
Measurement->Handle = StartHandle;
//
// When no perf entry to record the PEI and DXE phase,
// For start image, we need detect the PEIM and non PEIM here.
//
if (Measurement->Token == NULL) {
if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
Measurement->Token = ALit_PEIM;
Measurement->Module = ALit_PEIM;
Measurement->Handle = ModuleGuid;
} else {
Measurement->Token = ALit_START_IMAGE;
Measurement->Module = ALit_START_IMAGE;
}
}
}
break;
@ -483,11 +497,23 @@ GetMeasurementInfo (
Measurement->Module = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;
if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
} else {
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle;
//
// When no perf entry to record the PEI and DXE phase,
// For start image, we need detect the PEIM and non PEIM here.
//
if (Measurement->Token == NULL && (Measurement->Identifier == MODULE_START_ID || Measurement->Identifier == MODULE_END_ID)) {
if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
Measurement->Token = ALit_PEIM;
Measurement->Handle = ModuleGuid;
} else {
Measurement->Token = ALit_START_IMAGE;
}
}
}
break;
@ -553,6 +579,20 @@ GetMeasurementInfo (
Measurement->Handle = StartHandle;
break;
case FPDT_DUAL_GUID_STRING_EVENT_TYPE:
ModuleGuid = &(((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Guid1);
Measurement->Identifier = ((UINT32)((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
if (IsStart) {
Measurement->StartTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
} else {
Measurement->EndTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
}
Measurement->Token = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
Measurement->Module = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
Measurement->Handle = StartHandle;
break;
default:
break;
}
@ -580,6 +620,14 @@ SearchMeasurement (
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
break;
}
} else if (EndMeasureMent->Identifier == PERF_CROSSMODULE_END_ID) {
if (mMeasurementList[Index].EndTimeStamp == 0 &&
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0) &&
mMeasurementList[Index].Identifier == PERF_CROSSMODULE_START_ID) {
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
break;
}
} else {
if (mMeasurementList[Index].EndTimeStamp == 0 && mMeasurementList[Index].Handle == EndMeasureMent->Handle &&
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
@ -620,25 +668,32 @@ BuildMeasurementList (
StartProgressId = ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->ProgressID;
//
// If the record with ProgressId 0, the record doesn't appear in pairs. The timestamp in the record is the EndTimeStamp, its StartTimeStamp is 0.
// If the record is the start record, fill the info to the measurement in the mMeasurementList.
// If the record is the end record, find the related start measurement in the mMeasurementList and fill the EndTimeStamp.
//
if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) ||
if (StartProgressId == 0) {
GetMeasurementInfo (RecordHeader, FALSE, &(mMeasurementList[mMeasurementNum]));
mMeasurementNum ++;
} else if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) ||
(StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x0001) != 0)))) {
//
// Since PEIM and StartImage has same Type and ID when PCD PcdEdkiiFpdtStringRecordEnableOnly = FALSE
// So we need to identify these two kinds of record through different phase.
//
if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) {
mPeiPhase = TRUE;
} else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) {
mDxePhase = TRUE;
mPeiPhase = FALSE;
if(StartProgressId == PERF_CROSSMODULE_START_ID ){
if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) {
mPeiPhase = TRUE;
} else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) {
mDxePhase = TRUE;
mPeiPhase = FALSE;
}
}
// Get measurement info form the start record to the mMeasurementList.
GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurementNum]));
mMeasurementNum ++;
} else {
ZeroMem(&MeasureMent, sizeof(MEASUREMENT_RECORD));
GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent);
SearchMeasurement (&MeasureMent);
}

View File

@ -41,6 +41,7 @@
#include <Library/HiiLib.h>
#include <Library/FileHandleLib.h>
#include <Library/UefiHiiServicesLib.h>
#include <Library/Performancelib.h>
extern EFI_HANDLE mDpHiiHandle;

View File

@ -85,6 +85,20 @@ IsPhase(
IN MEASUREMENT_RECORD *Measurement
);
/**
Determine whether the Measurement record is for core code.
@param[in] Measurement A pointer to the Measurement record to test.
@retval TRUE The measurement record is used for core.
@retval FALSE The measurement record is NOT used for core.
**/
BOOLEAN
IsCorePerf(
IN MEASUREMENT_RECORD *Measurement
);
/**
Get the file name portion of the Pdb File Name.

View File

@ -604,7 +604,7 @@ ProcessHandles(
ElapsedTime = DurationInMicroSeconds ( Duration );
if ((ElapsedTime < mInterestThreshold) ||
(Measurement.EndTimeStamp == 0) ||
(Measurement.Handle == NULL) ||
(!IsCorePerf (&Measurement)) ||
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
) { // Ignore "uninteresting" or excluded records
continue;
@ -794,7 +794,7 @@ ProcessGlobal(
mGaugeString[25] = 0;
mUnicodeToken[31] = 0;
if ( ! ( IsPhase( &Measurement) ||
(Measurement.Handle != NULL) ||
IsCorePerf (&Measurement) ||
(Measurement.EndTimeStamp == 0)
))
{

View File

@ -108,6 +108,37 @@ IsPhase(
return RetVal;
}
/**
Determine whether the Measurement record is for core code.
@param[in] Measurement A pointer to the Measurement record to test.
@retval TRUE The measurement record is used for core.
@retval FALSE The measurement record is NOT used for core.
**/
BOOLEAN
IsCorePerf(
IN MEASUREMENT_RECORD *Measurement
)
{
BOOLEAN RetVal;
RetVal = (BOOLEAN)(
((Measurement->Identifier == MODULE_START_ID) ||
(Measurement->Identifier == MODULE_END_ID) ||
(Measurement->Identifier == MODULE_LOADIMAGE_START_ID) ||
(Measurement->Identifier == MODULE_LOADIMAGE_END_ID) ||
(Measurement->Identifier == MODULE_DB_START_ID) ||
(Measurement->Identifier == MODULE_DB_END_ID) ||
(Measurement->Identifier == MODULE_DB_SUPPORT_START_ID) ||
(Measurement->Identifier == MODULE_DB_SUPPORT_END_ID) ||
(Measurement->Identifier == MODULE_DB_STOP_START_ID) ||
(Measurement->Identifier == MODULE_DB_STOP_START_ID))
);
return RetVal;
}
/**
Get the file name portion of the Pdb File Name.