From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 986C781FF1 for ; Sun, 4 Dec 2016 21:28:00 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 04 Dec 2016 21:28:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,303,1477983600"; d="scan'208";a="13634189" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga002.jf.intel.com with ESMTP; 04 Dec 2016 21:27:59 -0800 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Jiewen Yao , Pete Batard Date: Mon, 5 Dec 2016 13:27:21 +0800 Message-Id: <1480915641-59136-6-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1480915641-59136-1-git-send-email-dandan.bi@intel.com> References: <1480915641-59136-1-git-send-email-dandan.bi@intel.com> Subject: [patch 5/5] MdeModulePkg/EbcDxe: Add comments for functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Dec 2016 05:28:00 -0000 Cc: Jiewen Yao Cc: Pete Batard Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../EbcDxe/EbcDebugger/EbcDebuggerConfig.c | 21 ++ .../EbcDxe/EbcDebugger/EdbDisasmSupport.h | 338 +++++++++++++++++++++ .../Universal/EbcDxe/EbcDebugger/EdbHook.c | 9 +- .../Universal/EbcDxe/EbcDebugger/EdbSupport.h | 251 ++++++++++++++- .../EbcDxe/EbcDebugger/EdbSupportString.c | 108 ++++++- .../Universal/EbcDxe/EbcDebugger/EdbSupportUI.c | 71 +++++ .../Universal/EbcDxe/EbcDebugger/EdbSymbol.h | 128 ++++++++ MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c | 117 +++++++ MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h | 129 +++++++- 9 files changed, 1157 insertions(+), 15 deletions(-) diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c index 248b1fc..2a123bf 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c @@ -16,10 +16,15 @@ #include #include "EdbCommon.h" #include "EdbSupport.h" +/** + + The function that displays the utility usage message. + +**/ VOID PrintUsage ( VOID ) { @@ -36,19 +41,35 @@ PrintUsage ( L"\n" ); return; } +/** + + The function is to show some information. + + @param DebuggerConfiguration Point to the EFI_DEBUGGER_CONFIGURATION_PROTOCOL. + +**/ VOID EdbShowInfo ( EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration ) { Print (L"Not supported!\n"); return ; } +/** + + EdbConfigBreak function. + + @param DebuggerConfiguration Point to the EFI_DEBUGGER_CONFIGURATION_PROTOCOL. + @param Command Point to the command. + @param CommandArg The argument for this command. + +**/ VOID EdbConfigBreak ( EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration, CHAR16 *Command, CHAR16 *CommandArg diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h index 702673b..801cbc1 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h @@ -31,203 +31,541 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define EDB_INSTRUCTION_NAME_MAX_LENGTH 10 #define EDB_INSTRUCTION_NAME_MAX_SIZE (EDB_INSTRUCTION_NAME_MAX_LENGTH * sizeof(CHAR16)) #define EDB_INSTRUCTION_CONTENT_MAX_LENGTH 30 #define EDB_INSTRUCTION_CONTENT_MAX_SIZE (EDB_INSTRUCTION_CONTENT_MAX_LENGTH * sizeof(CHAR16)) +/** + + Set offset for Instruction name and content. + + @param InstructionNameOffset - Instruction name offset + @param InstructionContentOffset - Instruction content offset + +**/ VOID EdbSetOffset ( IN UINTN InstructionNameOffset, IN UINTN InstructionContentOffset ); +/** + + Pre instruction string construction. + + @return Instruction string + +**/ CHAR16 * EdbPreInstructionString ( VOID ); +/** + + Post instruction string construction. + + @return Instruction string + +**/ CHAR16 * EdbPostInstructionString ( VOID ); +/** + + Print the instruction name. + + @param Name - instruction name + + @return Instruction name offset + +**/ UINTN EdbPrintInstructionName ( IN CHAR16 *Name ); +/** + + Get Sign, NaturalUnits, and ConstantUnits of the WORD data. + + @param Data16 - WORD data + @param NaturalUnits - Natural Units of the WORD + @param ConstantUnits - Constant Units of the WORD + + @return Sign value of WORD + +**/ BOOLEAN EdbGetNaturalIndex16 ( IN UINT16 Data16, OUT UINTN *NaturalUnits, OUT UINTN *ConstantUnits ); +/** + + Get Sign, NaturalUnits, and ConstantUnits of the DWORD data. + + @param Data32 - DWORD data + @param NaturalUnits - Natural Units of the DWORD + @param ConstantUnits - Constant Units of the DWORD + + @return Sign value of DWORD + +**/ BOOLEAN EdbGetNaturalIndex32 ( IN UINT32 Data32, OUT UINTN *NaturalUnits, OUT UINTN *ConstantUnits ); +/** + + Get Sign, NaturalUnits, and ConstantUnits of the QWORD data. + + @param Data64 - QWORD data + @param NaturalUnits - Natural Units of the QWORD + @param ConstantUnits - Constant Units of the QWORD + + @return Sign value of QWORD + +**/ BOOLEAN EdbGetNaturalIndex64 ( IN UINT64 Data64, OUT UINT64 *NaturalUnits, OUT UINT64 *ConstantUnits ); +/** + + Print the hexical WORD raw index data to instruction content. + + @param Data16 - WORD data + + @return Instruction content offset + +**/ UINTN EdbPrintRawIndexData16 ( IN UINT16 Data16 ); +/** + + Print the hexical DWORD raw index data to instruction content. + + @param Data32 - DWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintRawIndexData32 ( IN UINT32 Data32 ); +/** + + Print the hexical QWORD raw index data to instruction content. + + @param Data64 - QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintRawIndexData64 ( IN UINT64 Data64 ); +/** + + Print register 1 in operands. + + @param Operands - instruction operands + + @return Instruction content offset + +**/ UINTN EdbPrintRegister1 ( IN UINT8 Operands ); +/** + + Print register 2 in operands. + + @param Operands - instruction operands + + @return Instruction content offset + +**/ UINTN EdbPrintRegister2 ( IN UINT8 Operands ); +/** + + Print dedicated register 1 in operands. + + @param Operands - instruction operands + + @return Instruction content offset + +**/ UINTN EdbPrintDedicatedRegister1 ( IN UINT8 Operands ); +/** + + Print dedicated register 2 in operands. + + @param Operands - instruction operands + + @return Instruction content offset + +**/ UINTN EdbPrintDedicatedRegister2 ( IN UINT8 Operands ); +/** + + Print the hexical UINTN index data to instruction content. + + @param Sign - Signed bit of UINTN data + @param NaturalUnits - natural units of UINTN data + @param ConstantUnits - natural units of UINTN data + + @return Instruction content offset + +**/ UINTN EdbPrintIndexData ( IN BOOLEAN Sign, IN UINTN NaturalUnits, IN UINTN ConstantUnits ); +/** + + Print the hexical QWORD index data to instruction content. + + @param Sign - Signed bit of QWORD data + @param NaturalUnits - natural units of QWORD data + @param ConstantUnits - natural units of QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintIndexData64 ( IN BOOLEAN Sign, IN UINT64 NaturalUnits, IN UINT64 ConstantUnits ); +/** + + Print the hexical BYTE immediate data to instruction content. + + @param Data - BYTE data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData8 ( IN UINT8 Data ); +/** + + Print the hexical WORD immediate data to instruction content. + + @param Data - WORD data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData16 ( IN UINT16 Data ); +/** + + Print the hexical DWORD immediate data to instruction content. + + @param Data - DWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData32 ( IN UINT32 Data ); +/** + + Print the hexical QWORD immediate data to instruction content. + + @param Data - QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData64 ( IN UINT64 Data ); +/** + + Print the decimal UINTN immediate data to instruction content. + + @param Data - UINTN data + + @return Instruction content offset + +**/ UINTN EdbPrintImmDatan ( IN UINTN Data ); +/** + + Print the decimal QWORD immediate data to instruction content. + + @param Data64 - QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData64n ( IN UINT64 Data64 ); +/** + + Print the hexical BYTE to instruction content. + + @param Data8 - BYTE data + + @return Instruction content offset + +**/ UINTN EdbPrintData8 ( IN UINT8 Data8 ); +/** + + Print the hexical WORD to instruction content. + + @param Data16 - WORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData16 ( IN UINT16 Data16 ); +/** + + Print the hexical DWORD to instruction content. + + @param Data32 - DWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData32 ( IN UINT32 Data32 ); +/** + + Print the hexical QWORD to instruction content. + + @param Data64 - QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData64 ( IN UINT64 Data64 ); +/** + + Print the decimal unsigned UINTN to instruction content. + + @param Data - unsigned UINTN data + + @return Instruction content offset + +**/ UINTN EdbPrintDatan ( IN UINTN Data ); +/** + + Print the decimal unsigned QWORD to instruction content. + + @param Data64 - unsigned QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData64n ( IN UINT64 Data64 ); +/** + + Print the decimal signed BYTE to instruction content. + + @param Data8 - signed BYTE data + + @return Instruction content offset + +**/ UINTN EdbPrintData8s ( IN UINT8 Data8 ); +/** + + Print the decimal signed WORD to instruction content. + + @param Data16 - signed WORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData16s ( IN UINT16 Data16 ); +/** + + Print the decimal signed DWORD to instruction content. + + @param Data32 - signed DWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData32s ( IN UINT32 Data32 ); +/** + + Print the decimal signed QWORD to instruction content. + + @param Data64 - signed QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData64s ( IN UINT64 Data64 ); +/** + + Print the comma to instruction content. + + @return Instruction content offset + +**/ UINTN EdbPrintComma ( VOID ); +/** + + Find the symbol string according to address, then print it. + + @param Address - instruction address + + @retval 1 - symbol string is found and printed + @retval 0 - symbol string not found + +**/ UINTN EdbFindAndPrintSymbol ( IN UINTN Address ); +/** + + Print the EBC byte code. + + @param InstructionAddress - instruction address + @param InstructionNumber - instruction number + +**/ VOID EdbPrintRaw ( IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN UINTN InstructionNumber ); +/** + + Print the EBC asm code. + + @param DebuggerPrivate - EBC Debugger private data structure + @param SystemContext - EBC system context. + + @retval EFI_SUCCESS - show disasm successfully + +**/ EFI_STATUS EdbShowDisasm ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_SYSTEM_CONTEXT SystemContext ); +/** + + Get register value accroding to the system context, and register index. + + @param SystemContext - EBC system context. + @param Index - EBC register index + + @return register value + +**/ UINT64 GetRegisterValue ( IN EFI_SYSTEM_CONTEXT SystemContext, IN UINT8 Index ); diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c index 322dd25..7592def 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c @@ -276,10 +276,18 @@ EbcDebuggerPushStepEntry ( mDebuggerPrivate.StepContext.FramePointer = FramePtr; mDebuggerPrivate.FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOUT; } } + +/** + Notify the callback function when an event is triggered. + + @param Event Indicates the event that invoke this function. + @param Context Indicates the calling context. + +**/ VOID EFIAPI EbcDebuggerBreakEventFunc ( IN EFI_EVENT Event, IN VOID *Context @@ -465,11 +473,10 @@ EbcDebuggerHookUnload ( Currently do nothing here. @param Handle - The EbcImage handle. **/ - VOID EbcDebuggerHookEbcUnloadImage ( IN EFI_HANDLE Handle ) { diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h index 8908718..68becd6 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h @@ -23,207 +23,456 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define EFI_DEBUGGER_LINE_NUMBER_IN_PAGE 0x10 #define EFI_DEBUG_MAX_PRINT_BUFFER (80 * 4) +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINTN EFIAPI Xtoi ( CHAR16 *Str ); +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINT64 EFIAPI LXtoi ( CHAR16 *Str ); +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINTN EFIAPI Atoi ( CHAR16 *Str ); +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINTN EFIAPI AsciiXtoi ( CHAR8 *Str ); +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINTN EFIAPI AsciiAtoi ( CHAR8 *Str ); +/** + Compare the Unicode and Ascii string pointed by String to the string pointed by String2. + + @param String - Unicode String to process + + @param String2 - Ascii string to process + + @return Return a positive integer if String is lexicall greater than String2; Zero if + the two strings are identical; and a negative interger if String is lexically + less than String2. + +**/ INTN EFIAPI StrCmpUnicodeAndAscii ( IN CHAR16 *String, IN CHAR8 *String2 ); +/** + + Compare the Unicode string pointed by String to the string pointed by String2. + + @param String - Unicode String to process + @param String2 - Unicode string to process + + @return Return a positive integer if String is lexically greater than String2; Zero if + the two strings are identical; and a negative integer if String is lexically + less than String2. + +**/ INTN EFIAPI StriCmp ( IN CHAR16 *String, IN CHAR16 *String2 ); +/** + + Compare the Unicode and Ascii string pointed by String to the string pointed by String2. + + @param String - Unicode String to process + @param String2 - Ascii string to process + + @return Return a positive integer if String is lexically greater than String2; Zero if + the two strings are identical; and a negative integer if String is lexically + less than String2. + +**/ INTN EFIAPI StriCmpUnicodeAndAscii ( IN CHAR16 *String, IN CHAR8 *String2 ); +/** + + Verify if the string is end with the sub string. + + @param Str - The string where to search the sub string + @param SubStr - The substring. + +**/ BOOLEAN EFIAPI StrEndWith ( IN CHAR16 *Str, IN CHAR16 *SubStr ); +/** + Duplicate a string. + + @param Src The string to be duplicated. + +**/ CHAR16 * EFIAPI StrDuplicate ( IN CHAR16 *Src ); +/** + + Find the next token after one or more specified characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNewTokenLine ( IN CHAR16 *String, IN CHAR16 *CharSet ); +/** + + Find the next token after one or more specified characters. + + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNextTokenLine ( IN CHAR16 *CharSet ); +/** + + Find the next token after one specificed characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNewTokenField ( IN CHAR16 *String, IN CHAR16 *CharSet ); +/** + + Find the next token after one specificed characters. + + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNextTokenField ( IN CHAR16 *CharSet ); +/** + + Patch a character to the end of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForStrTokenAfter ( IN CHAR16 *Buffer, IN CHAR16 Patch ); +/** + Patch a character at the beginning of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForStrTokenBefore ( IN CHAR16 *Buffer, IN CHAR16 Patch ); +/** + + Find the next token after one or more specified characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNewTokenLine ( IN CHAR8 *String, IN CHAR8 *CharSet ); +/** + + Find the next token after one or more specified characters. + + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNextTokenLine ( IN CHAR8 *CharSet ); +/** + + Find the next token after one specificed characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNewTokenField ( IN CHAR8 *String, IN CHAR8 *CharSet ); +/** + + Find the next token after one specificed characters. + + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNextTokenField ( IN CHAR8 *CharSet ); +/** + + Patch a character to the end of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForAsciiStrTokenAfter ( IN CHAR8 *Buffer, IN CHAR8 Patch ); +/** + Patch a character at the beginning of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForAsciiStrTokenBefore ( IN CHAR8 *Buffer, IN CHAR8 Patch ); /** -Shell Library. + + Shell Library. + Get user input. + + @param Prompt The prompt string. + @param InStr Point to the input string. + @param StrLen The max length of string user can input. + **/ VOID EFIAPI Input ( IN CHAR16 *Prompt OPTIONAL, OUT CHAR16 *InStr, IN UINTN StrLen ); +/** + + SetPageBreak. + +**/ BOOLEAN EFIAPI SetPageBreak ( VOID ); +/** + Print a Unicode string to the output device. + + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBPrint ( IN CONST CHAR16 *Format, ... ); +/** + Print a Unicode string to the output buffer. + + @param Buffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBSPrint ( OUT CHAR16 *Buffer, IN INTN BufferSize, IN CONST CHAR16 *Format, ... ); +/** + Print a Unicode string to the output buffer with specified offset.. + + @param Buffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param Offset The offset of the buffer. + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBSPrintWithOffset ( OUT CHAR16 *Buffer, IN INTN BufferSize, IN UINTN Offset, IN CONST CHAR16 *Format, ... ); +/** + + Read a file. + If ScanFs is FLASE, it will use DebuggerPrivate->Vol as default Fs. + If ScanFs is TRUE, it will scan all FS and check the file. + If there is only one file match the name, it will be read. + If there is more than one file match the name, it will return Error. + + @param DebuggerPrivate - EBC Debugger private data structure + @param FileName - The file to be read. + @param BufferSize - The file buffer size + @param Buffer - The file buffer + @param ScanFs - Need Scan all FS + + @retval EFI_SUCCESS - read file successfully + @retval EFI_NOT_FOUND - file not found + @retval EFI_NO_MAPPING - there is duplicated files found + +**/ EFI_STATUS EFIAPI ReadFileToBuffer ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName, OUT UINTN *BufferSize, OUT VOID **Buffer, IN BOOLEAN ScanFs ); +/** + + Get file name under this dir with index + + @param DebuggerPrivate - EBC Debugger private data structure + @param DirName - The dir to be read. + @param FileName - The file name pattern under this dir + @param Index - The file index under this dir + + @return File Name which match the pattern and index. + +**/ CHAR16 * EFIAPI GetFileNameUnderDir ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *DirName, diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c index bb0626f..0a49d2f 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c @@ -83,11 +83,10 @@ Xtoi ( Convert hex string to uint. @param Str - The string **/ - UINT64 EFIAPI LXtoi ( CHAR16 *Str ) @@ -306,19 +305,33 @@ AsciiAtoi ( } return RetVal; } +/** + + Convert the character to upper case. + + @param Chr the character to be converted. + +**/ STATIC CHAR16 UnicodeToUpper ( IN CHAR16 Chr ) { return (Chr >= L'a' && Chr <= L'z') ? Chr - (L'a' - L'A') : Chr; } +/** + + Convert the character to upper case. + + @param Chr the character to be converted. + +**/ STATIC CHAR8 AsciiToUpper ( IN CHAR8 Chr ) @@ -518,11 +531,10 @@ StrSpn ( @param String Point to the string where to find the substring. @param CharSet Point to the string to be found. **/ - CHAR16 * EFIAPI StrBrk ( IN CHAR16 *String, IN CHAR16 *CharSet @@ -587,11 +599,10 @@ StrTokenLine ( @param String Point to the string where to find the substring. @param CharSet Point to the string to be found. **/ - CHAR16 * EFIAPI StrTokenField ( IN CHAR16 *String OPTIONAL, IN CHAR16 *CharSet @@ -619,48 +630,86 @@ StrTokenField ( mFieldBuffer = End; return Begin; } +/** + + Find the next token after one or more specified characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNewTokenLine ( IN CHAR16 *String, IN CHAR16 *CharSet ) { return StrTokenLine (String, CharSet); } +/** + + Find the next token after one or more specified characters. + + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNextTokenLine ( IN CHAR16 *CharSet ) { return StrTokenLine (NULL, CharSet); } +/** + + Find the next token after one specificed characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNewTokenField ( IN CHAR16 *String, IN CHAR16 *CharSet ) { return StrTokenField (String, CharSet); } +/** + + Find the next token after one specificed characters. + + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNextTokenField ( IN CHAR16 *CharSet ) { return StrTokenField (NULL, CharSet); } +/** + + Patch a character to the end of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForStrTokenAfter ( IN CHAR16 *Buffer, IN CHAR16 Patch @@ -687,10 +736,17 @@ PatchForStrTokenAfter ( } return ; } +/** + Patch a character at the beginning of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForStrTokenBefore ( IN CHAR16 *Buffer, IN CHAR16 Patch @@ -829,11 +885,10 @@ AsciiStrTokenLine ( @param String Point to the string where to find the substring. @param CharSet Point to the string to be found. **/ - CHAR8 * EFIAPI AsciiStrTokenField ( IN CHAR8 *String OPTIONAL, IN CHAR8 *CharSet @@ -861,48 +916,86 @@ AsciiStrTokenField ( mAsciiFieldBuffer = End; return Begin; } +/** + + Find the next token after one or more specified characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNewTokenLine ( IN CHAR8 *String, IN CHAR8 *CharSet ) { return AsciiStrTokenLine (String, CharSet); } +/** + + Find the next token after one or more specified characters. + + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNextTokenLine ( IN CHAR8 *CharSet ) { return AsciiStrTokenLine (NULL, CharSet); } +/** + + Find the next token after one specificed characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNewTokenField ( IN CHAR8 *String, IN CHAR8 *CharSet ) { return AsciiStrTokenField (String, CharSet); } +/** + + Find the next token after one specificed characters. + + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNextTokenField ( IN CHAR8 *CharSet ) { return AsciiStrTokenField (NULL, CharSet); } +/** + + Patch a character to the end of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForAsciiStrTokenAfter ( IN CHAR8 *Buffer, IN CHAR8 Patch @@ -929,10 +1022,17 @@ PatchForAsciiStrTokenAfter ( } return ; } +/** + Patch a character at the beginning of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForAsciiStrTokenBefore ( IN CHAR8 *Buffer, IN CHAR8 Patch diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c index 21d0dc9..14f8627 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c @@ -12,10 +12,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "Edb.h" +/** + Set the current coordinates of the cursor position. + + @param ConOut Point to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. + @param Column The position to set the cursor to. + @param Row The position to set the cursor to. + @param LineLength Length of a line. + @param TotalRow Total row of a screen. + @param Str Point to the string. + @param StrPos The position of the string. + @param Len The length of the string. + +**/ VOID EFIAPI SetCursorPosition ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut, IN UINTN Column, @@ -164,10 +177,19 @@ ConMoveCursorForward ( } CHAR16 mBackupSpace[EFI_DEBUG_INPUS_BUFFER_SIZE]; CHAR16 mInputBufferHistory[EFI_DEBUG_INPUS_BUFFER_SIZE]; +/** + + Get user input. + + @param Prompt The prompt string. + @param InStr Point to the input string. + @param StrLength The max length of string user can input. + +**/ VOID EFIAPI Input ( IN CHAR16 *Prompt OPTIONAL, OUT CHAR16 *InStr, @@ -512,10 +534,23 @@ Input ( // Return the data to the caller // return ; } +/** + Set the current coordinates of the cursor position. + + @param ConOut Point to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. + @param Column The position to set the cursor to. + @param Row The position to set the cursor to. + @param LineLength Length of a line. + @param TotalRow Total row of a screen. + @param Str Point to the string. + @param StrPos The position of the string. + @param Len The length of the string. + +**/ VOID EFIAPI SetCursorPosition ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut, IN UINTN Column, @@ -549,10 +584,15 @@ SetCursorPosition ( } ConOut->SetCursorPosition (ConOut, 0, 0); } +/** + + SetPageBreak. + +**/ BOOLEAN EFIAPI SetPageBreak ( VOID ) @@ -618,10 +658,18 @@ SetPageBreak ( } return OmitPrint; } +/** + Print a Unicode string to the output device. + + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBPrint ( IN CONST CHAR16 *Format, ... @@ -643,10 +691,21 @@ EDBPrint ( } return Return; } +/** + Print a Unicode string to the output buffer. + + @param Buffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBSPrint ( OUT CHAR16 *Buffer, IN INTN BufferSize, @@ -664,10 +723,22 @@ EDBSPrint ( VA_END (Marker); return Return; } +/** + Print a Unicode string to the output buffer with specified offset.. + + @param Buffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param Offset The offset of the buffer. + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBSPrintWithOffset ( OUT CHAR16 *Buffer, IN INTN BufferSize, diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h index c4c2858..2e8c5e2 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h @@ -37,84 +37,212 @@ typedef enum { EdbEbcImageRvaSearchTypeFirst, EdbEbcImageRvaSearchTypeLast, EdbEbcImageRvaSearchTypeMax, } EDB_EBC_IMAGE_RVA_SEARCH_TYPE; +/** + + Find symbol by address. + + @param Address - Symbol address + @param Type - Search type + @param RetObject - Symbol object + @param RetEntry - Symbol entry + + @return Nearest symbol address + +**/ UINTN EbdFindSymbolAddress ( IN UINTN Address, IN EDB_MATCH_SYMBOL_TYPE Type, OUT EFI_DEBUGGER_SYMBOL_OBJECT **Object, OUT EFI_DEBUGGER_SYMBOL_ENTRY **Entry ); +/** + + Load symbol file by name. + + @param DebuggerPrivate - EBC Debugger private data structure + @param FileName - Symbol file name + @param BufferSize - Symbol file buffer size + @param Buffer - Symbol file buffer + + @retval EFI_SUCCESS - load symbol successfully + +**/ EFI_STATUS EdbLoadSymbol ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName, IN UINTN BufferSize, IN VOID *Buffer ); +/** + + Unload symbol file by name. + + @param DebuggerPrivate - EBC Debugger private data structure + @param FileName - Symbol file name + + @retval EFI_SUCCESS - unload symbol successfully + +**/ EFI_STATUS EdbUnloadSymbol ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName ); +/** + + Patch symbol RVA. + + @param DebuggerPrivate - EBC Debugger private data structure + @param FileName - Symbol file name + @param SearchType - Search type for Object + + @retval EFI_SUCCESS - Patch symbol RVA successfully + @retval EFI_NOT_FOUND - Symbol RVA base not found + +**/ EFI_STATUS EdbPatchSymbolRVA ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName, IN EDB_EBC_IMAGE_RVA_SEARCH_TYPE SearchType ); +/** + + Load code. + + @param DebuggerPrivate - EBC Debugger private data structure + @param MapFileName - Symbol file name + @param FileName - Code file name + @param BufferSize - Code file buffer size + @param Buffer - Code file buffer + + @retval EFI_SUCCESS - Code loaded successfully + +**/ EFI_STATUS EdbLoadCode ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *FileName, IN UINTN BufferSize, IN VOID *Buffer ); +/** + + Unload code. + + @param DebuggerPrivate - EBC Debugger private data structure + @param MapFileName - Symbol file name + @param FileName - Code file name + @param Buffer - Code file buffer + + @retval EFI_SUCCESS - Code unloaded successfully + +**/ EFI_STATUS EdbUnloadCode ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *FileName, OUT VOID **Buffer ); +/** + + Add code buffer. + + @param DebuggerPrivate - EBC Debugger private data structure + @param MapFileName - Symbol file name + @param CodeFileName - Code file name + @param SourceBufferSize- Code buffer size + @param SourceBuffer - Code buffer + + @retval EFI_SUCCESS - CodeBuffer added successfully + +**/ EFI_STATUS EdbAddCodeBuffer ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *CodeFileName, IN UINTN SourceBufferSize, IN VOID *SourceBuffer ); +/** + + Delete code buffer. + + @param DebuggerPrivate - EBC Debugger private data structure + @param MapFileName - Symbol file name + @param CodeFileName - Code file name + @param SourceBuffer - Code buffer + + @retval EFI_SUCCESS - CodeBuffer deleted successfully + +**/ EFI_STATUS EdbDeleteCodeBuffer ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *CodeFileName, IN VOID *SourceBuffer ); +/** + + Find the symbol string according to address. + + @param Address - Symbol address + + @return Symbol string + +**/ CHAR8 * FindSymbolStr ( IN UINTN Address ); +/** + + Print source. + + @param Address - Instruction address + @param IsPrint - Whether need to print + + @retval 1 - find the source + @retval 0 - not find the source + +**/ UINTN EdbPrintSource ( IN UINTN Address, IN BOOLEAN IsPrint ); +/** + + Convert a symbol to an address. + + @param Symbol - Symbol name + @param Address - Symbol address + + @retval EFI_SUCCESS - symbol found and address returned. + @retval EFI_NOT_FOUND - symbol not found + @retval EFI_NO_MAPPING - duplicated symbol not found + +**/ EFI_STATUS Symboltoi ( IN CHAR16 *Symbol, OUT UINTN *Address ); diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c index 1594cec..c5a1934 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c @@ -16,139 +16,256 @@ **/ #include "EbcDebuggerHook.h" +/** + + The hook in InitializeEbcDriver. + + @param Handle - The EbcDebugProtocol handle. + @param EbcDebugProtocol - The EbcDebugProtocol interface. + +**/ VOID EbcDebuggerHookInit ( IN EFI_HANDLE Handle, IN EFI_DEBUG_SUPPORT_PROTOCOL *EbcDebugProtocol ) { return; } +/** + +The hook in UnloadImage for EBC Interpreter. + +**/ VOID EbcDebuggerHookUnload ( VOID ) { return; } +/** + + The hook in EbcUnloadImage. + Currently do nothing here. + + @param Handle The EbcImage handle. + +**/ VOID EbcDebuggerHookEbcUnloadImage ( IN EFI_HANDLE Handle ) { return; } +/** + + The hook in ExecuteEbcImageEntryPoint. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteEbcImageEntryPoint ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteEbcImageEntryPoint. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookEbcInterpret ( IN VM_CONTEXT *VmPtr ) { return; } +/** + The hook in EbcExecute, before ExecuteFunction. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteStart ( IN VM_CONTEXT *VmPtr ) { return; } +/** + The hook in EbcExecute, after ExecuteFunction. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteEnd ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteCALL, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLStart ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteCALL, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEnd ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteCALL, before call EbcLLCALLEX. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEXStart ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteCALL, after call EbcLLCALLEX. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEXEnd ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteRET, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookRETStart ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteRET, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookRETEnd ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteJMP, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMPStart ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteJMP, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMPEnd ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteJMP8, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMP8Start ( IN VM_CONTEXT *VmPtr ) { return; } +/** + + The hook in ExecuteJMP8, after move IP.. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMP8End ( IN VM_CONTEXT *VmPtr ) { diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h index ad93fd7..cf81b4a 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h @@ -36,100 +36,211 @@ EbcDebugSignalException ( IN EFI_EXCEPTION_TYPE ExceptionType, IN EXCEPTION_FLAGS ExceptionFlags, IN VM_CONTEXT *VmPtr ); -// -// Hooks in EbcInt.c -// +/** + + The hook in InitializeEbcDriver. + + @param Handle - The EbcDebugProtocol handle. + @param EbcDebugProtocol - The EbcDebugProtocol interface. + +**/ VOID EbcDebuggerHookInit ( IN EFI_HANDLE Handle, IN EFI_DEBUG_SUPPORT_PROTOCOL *EbcDebugProtocol ); +/** + +The hook in UnloadImage for EBC Interpreter. + +**/ VOID EbcDebuggerHookUnload ( VOID ); +/** + + The hook in EbcUnloadImage. + Currently do nothing here. + + @param Handle The EbcImage handle. + +**/ VOID EbcDebuggerHookEbcUnloadImage ( IN EFI_HANDLE Handle ); -// -// Hooks in EbcSupport.c -// + +/** + + Hooks in EbcSupport.c + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteEbcImageEntryPoint ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteEbcImageEntryPoint. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookEbcInterpret ( IN VM_CONTEXT *VmPtr ); -// -// Hooks in EbcExecute.c -// + +/** + The hook in EbcExecute, before ExecuteFunction. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteStart ( IN VM_CONTEXT *VmPtr ); +/** + The hook in EbcExecute, after ExecuteFunction. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteEnd ( IN VM_CONTEXT *VmPtr ); +/** + The hook in ExecuteCALL, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLStart ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteCALL, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEnd ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteCALL, before call EbcLLCALLEX. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEXStart ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteCALL, after call EbcLLCALLEX. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEXEnd ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteRET, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookRETStart ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteRET, after move IP. + It will record trace information. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookRETEnd ( IN VM_CONTEXT *VmPtr ); + +/** + + The hook in ExecuteJMP, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMPStart ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteJMP, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMPEnd ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteJMP8, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMP8Start ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteJMP8, after move IP.. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMP8End ( IN VM_CONTEXT *VmPtr ); -- 1.9.5.msysgit.1