31 while (TempFileName !=
NULL) {
32 FileName = TempFileName;
57 if (FileName != FullPath) {
85 DirPathSize =
StrLen (DirPath);
86 *(DirPath + DirPathSize) = L
'\\';
87 StrnCatS (DirPath, DirPathSize + Size + 1, FilePath, Size);
89 *(DirPath + DirPathSize + Size + 1) = 0;
94CHAR16 *mSymbolTypeStr[] = {
112 IN EFI_DEBUGGER_SYMBOL_TYPE Type
115 if ((Type < 0) || (Type >= EfiDebuggerSymbolTypeMax)) {
119 return mSymbolTypeStr[Type];
140 UINTN CandidateAddress;
145 CandidateAddress =
EbdFindSymbolAddress (Address, EdbMatchSymbolTypeNearestAddress, &Object, &Entry);
146 if ((CandidateAddress == 0) || (CandidateAddress == (
UINTN)-1) || (Entry ==
NULL)) {
147 EDBPrint (L
"Symbole at Address not found!\n");
148 return EFI_DEBUG_CONTINUE;
149 }
else if (Address != CandidateAddress) {
150 EDBPrint (L
"Symbole at Address not found, print nearest one!\n");
156 EDBPrint (L
"Symbol File Name: %s\n", Object->Name);
157 if (
sizeof (
UINTN) ==
sizeof (UINT64)) {
158 EDBPrint (L
" Address Type Symbol\n");
159 EDBPrint (L
" ================== ==== ========\n");
162 L
" 0x%016lx %s %a\n",
163 (UINT64)Entry->Rva + Object->BaseAddress,
168 EDBPrint (L
" Address Type Symbol\n");
169 EDBPrint (L
" ========== ==== ========\n");
173 Entry->Rva + Object->BaseAddress,
182 return EFI_DEBUG_CONTINUE;
198 IN CHAR16 *SymbolFileName,
199 IN CHAR16 *SymbolName,
208 if (DebuggerPrivate->DebuggerSymbolContext.ObjectCount == 0) {
210 return EFI_DEBUG_CONTINUE;
216 Object = DebuggerPrivate->DebuggerSymbolContext.Object;
217 for (Index = 0; Index < DebuggerPrivate->DebuggerSymbolContext.ObjectCount; Index++, Object++) {
218 if ((SymbolFileName !=
NULL) &&
219 (
StriCmp (SymbolFileName, Object->Name) != 0))
233 EDBPrint (L
"Symbol File Name: %s\n", Object->Name);
234 if (Object->EntryCount == 0) {
239 Entry = Object->Entry;
240 if (
sizeof (
UINTN) ==
sizeof (UINT64)) {
241 EDBPrint (L
" Address Type Symbol\n");
242 EDBPrint (L
" ================== ==== ========\n");
245 EDBPrint (L
" Address Type Symbol\n");
246 EDBPrint (L
" ========== ==== ========\n");
253 for (SubIndex = 0; SubIndex < Object->EntryCount; SubIndex++, Entry++) {
254 if ((SymbolName !=
NULL) &&
263 if (((SubIndex % EFI_DEBUGGER_LINE_NUMBER_IN_PAGE) == 0) &&
271 if (
sizeof (
UINTN) ==
sizeof (UINT64)) {
273 L
" 0x%016lx %s %a (%a)\n",
274 (UINT64)Entry->Rva + Object->BaseAddress,
281 L
" 0x%08x %s %a (%a)\n",
282 Entry->Rva + Object->BaseAddress,
294 return EFI_DEBUG_CONTINUE;
311 IN CHAR16 *CommandArg,
317 CHAR16 *SymbolFileName;
322 SymbolFileName =
NULL;
324 CommandStr = CommandArg;
329 if (CommandStr !=
NULL) {
330 if ((
StriCmp (CommandStr, L
"F") != 0) &&
331 (
StriCmp (CommandStr, L
"S") != 0))
333 Address =
Xtoi (CommandStr);
341 if (CommandStr !=
NULL) {
342 if (
StriCmp (CommandStr, L
"F") == 0) {
344 if (CommandStr ==
NULL) {
345 EDBPrint (L
"Symbol File Name missing!\n");
346 return EFI_DEBUG_CONTINUE;
348 SymbolFileName = CommandStr;
357 if (CommandStr !=
NULL) {
358 if (
StriCmp (CommandStr, L
"S") == 0) {
360 if (CommandStr ==
NULL) {
361 EDBPrint (L
"Symbol Name missing!\n");
362 return EFI_DEBUG_CONTINUE;
364 SymbolName = CommandStr;
370 if (CommandStr !=
NULL) {
372 return EFI_DEBUG_CONTINUE;
395 IN CHAR16 *CommandArg,
408 CHAR16 CodFile[EFI_DEBUGGER_SYMBOL_NAME_MAX];
415 if (CommandArg ==
NULL) {
416 EDBPrint (L
"SymbolFile not found!\n");
417 return EFI_DEBUG_CONTINUE;
422 if (CommandArg2 !=
NULL) {
423 if (
StriCmp (CommandArg2, L
"a") == 0) {
427 return EFI_DEBUG_CONTINUE;
431 if (
StrLen (CommandArg) <= 4) {
432 EDBPrint (L
"SymbolFile name error!\n");
433 return EFI_DEBUG_CONTINUE;
436 if (
StriCmp (CommandArg + (
StrLen (CommandArg) - 4), L
".map") != 0) {
437 EDBPrint (L
"SymbolFile name error!\n");
438 return EFI_DEBUG_CONTINUE;
445 if (EFI_ERROR (Status)) {
446 EDBPrint (L
"SymbolFile read error!\n");
447 return EFI_DEBUG_CONTINUE;
454 Status =
EdbLoadSymbol (DebuggerPrivate, FileName, BufferSize, Buffer);
455 if (EFI_ERROR (Status)) {
457 gBS->FreePool (Buffer);
458 return EFI_DEBUG_CONTINUE;
461 gBS->FreePool (Buffer);
466 Status =
EdbPatchSymbolRVA (DebuggerPrivate, FileName, EdbEbcImageRvaSearchTypeLast);
467 if (EFI_ERROR (Status)) {
468 EDBPrint (L
"PatchSymbol RVA - %r! Using the RVA in symbol file.\n", Status);
470 DEBUG ((DEBUG_ERROR,
"PatchSymbol RVA successfully!\n"));
474 return EFI_DEBUG_CONTINUE;
481 ZeroMem (CodFile,
sizeof (CodFile));
482 if (
StrCmp (DirName, L
"") != 0) {
483 StrCpyS (CodFile,
sizeof (CodFile), DirName);
493 while (CodFileName !=
NULL) {
494 ZeroMem (CodFile,
sizeof (CodFile));
495 if (
StrCmp (DirName, L
"\\") != 0) {
496 StrCpyS (CodFile,
sizeof (CodFile), DirName);
503 if (EFI_ERROR (Status)) {
504 EDBPrint (L
"CodeFile read error!\n");
512 Status =
EdbLoadCode (DebuggerPrivate, FileName, CodFileName, BufferSize, Buffer);
513 if (EFI_ERROR (Status)) {
515 gBS->FreePool (Buffer);
523 Status =
EdbAddCodeBuffer (DebuggerPrivate, FileName, CodFileName, BufferSize, Buffer);
524 if (EFI_ERROR (Status)) {
525 EDBPrint (L
"AddCodeBuffer error!\n");
526 gBS->FreePool (Buffer);
540 return EFI_DEBUG_CONTINUE;
557 IN CHAR16 *CommandArg,
566 CHAR16 CodFile[EFI_DEBUGGER_SYMBOL_NAME_MAX];
574 if (CommandArg ==
NULL) {
575 EDBPrint (L
"SymbolFile not found!\n");
576 return EFI_DEBUG_CONTINUE;
585 ZeroMem (CodFile,
sizeof (CodFile));
586 if (
StrCmp (DirName, L
"") != 0) {
587 StrCpyS (CodFile,
sizeof (CodFile), DirName);
597 while (CodFileName !=
NULL) {
598 ZeroMem (CodFile,
sizeof (CodFile));
599 if (
StrCmp (DirName, L
"\\") != 0) {
600 StrCpyS (CodFile,
sizeof (CodFile), DirName);
606 Status =
EdbUnloadCode (DebuggerPrivate, FileName, CodFileName, &BufferPtr);
607 if (EFI_ERROR (Status)) {
617 if (EFI_ERROR (Status)) {
618 EDBPrint (L
"DeleteCodeBuffer error!\n");
633 if (EFI_ERROR (Status)) {
634 EDBPrint (L
"UnloadSymbol error!\n");
640 return EFI_DEBUG_CONTINUE;
657 IN CHAR16 *CommandArg,
663 if (CommandArg ==
NULL) {
664 DebuggerPrivate->DebuggerSymbolContext.DisplaySymbol = !DebuggerPrivate->DebuggerSymbolContext.DisplaySymbol;
666 }
else if (
StriCmp (CommandArg, L
"on") == 0) {
667 DebuggerPrivate->DebuggerSymbolContext.DisplaySymbol =
TRUE;
669 }
else if (
StriCmp (CommandArg, L
"off") == 0) {
670 DebuggerPrivate->DebuggerSymbolContext.DisplaySymbol =
FALSE;
673 EDBPrint (L
"DisplaySymbol - argument error\n");
676 return EFI_DEBUG_CONTINUE;
693 IN CHAR16 *CommandArg,
709 if (CommandArg ==
NULL) {
710 EDBPrint (L
"CodeFile not found!\n");
711 return EFI_DEBUG_CONTINUE;
715 if (CommandArg2 ==
NULL) {
716 EDBPrint (L
"SymbolFile not found!\n");
717 return EFI_DEBUG_CONTINUE;
720 if (
StrLen (CommandArg) <= 4) {
721 EDBPrint (L
"CodeFile name error!\n");
722 return EFI_DEBUG_CONTINUE;
725 if (
StriCmp (CommandArg + (
StrLen (CommandArg) - 4), L
".cod") != 0) {
726 EDBPrint (L
"CodeFile name error!\n");
727 return EFI_DEBUG_CONTINUE;
730 if (
StrLen (CommandArg2) <= 4) {
731 EDBPrint (L
"SymbolFile name error!\n");
732 return EFI_DEBUG_CONTINUE;
735 if (
StriCmp (CommandArg2 + (
StrLen (CommandArg2) - 4), L
".map") != 0) {
736 EDBPrint (L
"SymbolFile name error!\n");
737 return EFI_DEBUG_CONTINUE;
744 if (EFI_ERROR (Status)) {
745 EDBPrint (L
"CodeFile read error!\n");
746 return EFI_DEBUG_CONTINUE;
754 Status =
EdbLoadCode (DebuggerPrivate, MapFileName, FileName, BufferSize, Buffer);
755 if (EFI_ERROR (Status)) {
757 gBS->FreePool (Buffer);
758 return EFI_DEBUG_CONTINUE;
764 Status =
EdbAddCodeBuffer (DebuggerPrivate, MapFileName, FileName, BufferSize, Buffer);
765 if (EFI_ERROR (Status)) {
766 EDBPrint (L
"AddCodeBuffer error!\n");
767 gBS->FreePool (Buffer);
768 return EFI_DEBUG_CONTINUE;
774 return EFI_DEBUG_CONTINUE;
791 IN CHAR16 *CommandArg,
806 if (CommandArg ==
NULL) {
807 EDBPrint (L
"CodeFile not found!\n");
808 return EFI_DEBUG_CONTINUE;
812 if (CommandArg2 ==
NULL) {
813 EDBPrint (L
"SymbolFile not found!\n");
814 return EFI_DEBUG_CONTINUE;
823 Status =
EdbUnloadCode (DebuggerPrivate, MapFileName, FileName, &BufferPtr);
824 if (EFI_ERROR (Status)) {
826 return EFI_DEBUG_CONTINUE;
833 if (EFI_ERROR (Status)) {
834 EDBPrint (L
"DeleteCodeBuffer error!\n");
840 return EFI_DEBUG_CONTINUE;
857 IN CHAR16 *CommandArg,
863 if (CommandArg ==
NULL) {
864 DebuggerPrivate->DebuggerSymbolContext.DisplayCodeOnly = !DebuggerPrivate->DebuggerSymbolContext.DisplayCodeOnly;
866 }
else if (
StriCmp (CommandArg, L
"on") == 0) {
867 DebuggerPrivate->DebuggerSymbolContext.DisplayCodeOnly =
TRUE;
869 }
else if (
StriCmp (CommandArg, L
"off") == 0) {
870 DebuggerPrivate->DebuggerSymbolContext.DisplayCodeOnly =
FALSE;
873 EDBPrint (L
"DisplayCode - argument error\n");
876 return EFI_DEBUG_CONTINUE;
EFI_STATUS ReadFileToBuffer(IN CHAR16 *FileName, OUT UINTN *BufferSize, OUT VOID **Buffer)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
RETURN_STATUS EFIAPI StrnCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_DEBUG_STATUS DebuggerListSymbol(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
EFI_DEBUG_STATUS DebuggerLoadCode(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
EFI_DEBUG_STATUS DebuggerDisplaySymbolAccrodingToAddress(IN UINTN Address, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate)
EFI_DEBUG_STATUS DebuggerDisplaySymbolAccrodingToName(IN CHAR16 *SymbolFileName, IN CHAR16 *SymbolName, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate)
EFI_DEBUG_STATUS DebuggerUnloadCode(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
EFI_DEBUG_STATUS DebuggerUnloadSymbol(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
CHAR16 * GetDirNameFromFullPath(IN CHAR16 *FullPath)
EFI_DEBUG_STATUS DebuggerDisplayCode(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
EFI_DEBUG_STATUS DebuggerDisplaySymbol(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
CHAR16 * ConstructFullPath(IN CHAR16 *DirPath, IN CHAR16 *FilePath, IN UINTN Size)
CHAR16 * EdbSymbolTypeToStr(IN EFI_DEBUGGER_SYMBOL_TYPE Type)
EFI_DEBUG_STATUS DebuggerLoadSymbol(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
CHAR16 * GetFileNameFromFullPath(IN CHAR16 *FullPath)
EFI_STATUS EdbShowDisasm(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_SYSTEM_CONTEXT SystemContext)
CHAR16 *EFIAPI StrGetNewTokenLine(IN CHAR16 *String, IN CHAR16 *CharSet)
UINTN EFIAPI Xtoi(CHAR16 *Str)
BOOLEAN EFIAPI SetPageBreak(VOID)
CHAR16 *EFIAPI StrGetNextTokenLine(IN CHAR16 *CharSet)
UINTN EFIAPI EDBPrint(IN CONST CHAR16 *Format,...)
INTN EFIAPI StrCmpUnicodeAndAscii(IN CHAR16 *String, IN CHAR8 *String2)
VOID EFIAPI PatchForStrTokenBefore(IN CHAR16 *Buffer, IN CHAR16 Patch)
INTN EFIAPI StriCmp(IN CHAR16 *String, IN CHAR16 *String2)
CHAR16 *EFIAPI GetFileNameUnderDir(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *DirName, IN CHAR16 *FileName, IN OUT UINTN *Index)
EFI_STATUS EdbLoadSymbol(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS EdbLoadCode(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *FileName, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS EdbUnloadSymbol(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName)
EFI_STATUS EdbAddCodeBuffer(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *CodeFileName, IN UINTN SourceBufferSize, IN VOID *SourceBuffer)
EFI_STATUS EdbUnloadCode(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *FileName, OUT VOID **Buffer)
EFI_STATUS EdbPatchSymbolRVA(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName, IN EDB_EBC_IMAGE_RVA_SEARCH_TYPE SearchType)
UINTN EbdFindSymbolAddress(IN UINTN Address, IN EDB_MATCH_SYMBOL_TYPE Type, OUT EFI_DEBUGGER_SYMBOL_OBJECT **RetObject, OUT EFI_DEBUGGER_SYMBOL_ENTRY **RetEntry)
EFI_STATUS EdbDeleteCodeBuffer(IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *MapFileName, IN CHAR16 *CodeFileName, IN VOID *SourceBuffer)
#define DEBUG(Expression)