Adding a command to show how symbols work in EFI

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10029 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish 2010-02-19 23:49:51 +00:00
parent 37b91c49fc
commit b2a73e2162
2 changed files with 81 additions and 5 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Add custom commands for BeagleBoard development. Add custom commands for BeagleBoard development.
Copyright (c) 2008-2009, Apple Inc. All rights reserved. Copyright (c) 2008-2010, Apple Inc. All rights reserved.
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -26,13 +26,81 @@
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/EfiFileLib.h> #include <Library/EfiFileLib.h>
#include <Library/ArmDisassemblerLib.h> #include <Library/ArmDisassemblerLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
//PcdEmbeddedFdBaseAddress #include <Guid/DebugImageInfoTable.h>
#include <Protocol/DebugSupport.h>
#include <Protocol/LoadedImage.h>
/** /**
Fill Me In Simple arm disassembler via a library
Argv[0] - "%CommandName%" Argv[0] - symboltable
Argv[1] - Optional qoted format string
Argv[2] - Optional flag
@param Argc Number of command arguments in Argv
@param Argv Array of strings that represent the parsed command line.
Argv[0] is the comamnd name
@return EFI_SUCCESS
**/
EFI_STATUS
EblSymbolTable (
IN UINTN Argc,
IN CHAR8 **Argv
)
{
EFI_STATUS Status;
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugImageTableHeader = NULL;
EFI_DEBUG_IMAGE_INFO *DebugTable;
UINTN Entry;
CHAR8 *Format;
CHAR8 *Pdb;
UINT32 PeCoffSizeOfHeaders;
UINT32 ImageBase;
BOOLEAN Elf;
// Need to add lots of error checking on the passed in string
Format = (Argc > 1) ? Argv[1] : "load /a /ni /np %a & 0x%x\n";
Elf = (Argc > 2) ? FALSE : TRUE;
Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugImageTableHeader);
if (EFI_ERROR (Status)) {
return Status;
}
DebugTable = DebugImageTableHeader->EfiDebugImageInfoTable;
if (DebugTable == NULL) {
return EFI_SUCCESS;
}
for (Entry = 0; Entry < DebugImageTableHeader->TableSize; Entry++, DebugTable++) {
if (DebugTable->NormalImage != NULL) {
if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
ImageBase = (UINT32)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)ImageBase);
Pdb = PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
if (Elf) {
// ELF and Mach-O images don't include the header so the linked address does not include header
ImageBase += PeCoffSizeOfHeaders;
}
AsciiPrint (Format, Pdb, ImageBase);
}
}
}
return EFI_SUCCESS;
}
/**
Simple arm disassembler via a library
Argv[0] - disasm
Argv[1] - Address to start disassembling from
ARgv[2] - Number of instructions to disassembly (optional)
@param Argc Number of command arguments in Argv @param Argc Number of command arguments in Argv
@param Argv Array of strings that represent the parsed command line. @param Argv Array of strings that represent the parsed command line.
@ -80,6 +148,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] =
" disassemble count instructions", " disassemble count instructions",
NULL, NULL,
EblDisassembler EblDisassembler
},
{
"symboltable [\"format string\"] [TRUE]",
" show symbol table commands for debugger",
NULL,
EblSymbolTable
} }
}; };

View File

@ -43,7 +43,9 @@
ArmDisassemblerLib ArmDisassemblerLib
[Protocols] [Protocols]
gEfiDebugSupportProtocolGuid
gEfiLoadedImageProtocolGuid
[Guids] [Guids]
gEfiDebugImageInfoTableGuid
[Pcd]