diff options
author | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-02-19 23:49:51 +0000 |
---|---|---|
committer | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-02-19 23:49:51 +0000 |
commit | b2a73e21621d6d96194fc44d871da92bb85ec885 (patch) | |
tree | 7dbbf34368c33aae4d91de6a9524cf1a0dd85ff5 /BeagleBoardPkg | |
parent | 37b91c49fc9a25310a970762ac9fc6d11cb9f4dc (diff) | |
download | edk2-platforms-b2a73e21621d6d96194fc44d871da92bb85ec885.tar.xz |
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
Diffstat (limited to 'BeagleBoardPkg')
-rw-r--r-- | BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c | 82 | ||||
-rw-r--r-- | BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.inf | 4 |
2 files changed, 81 insertions, 5 deletions
diff --git a/BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c b/BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c index c69b28904b..01d7984193 100644 --- a/BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c +++ b/BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c @@ -1,7 +1,7 @@ /** @file
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
are licensed and made available under the terms and conditions of the BSD License
@@ -26,13 +26,81 @@ #include <Library/PcdLib.h>
#include <Library/EfiFileLib.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 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",
NULL,
EblDisassembler
+ },
+ {
+ "symboltable [\"format string\"] [TRUE]",
+ " show symbol table commands for debugger",
+ NULL,
+ EblSymbolTable
}
};
diff --git a/BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.inf b/BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.inf index 3590351517..9273aa92e4 100644 --- a/BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.inf +++ b/BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.inf @@ -43,7 +43,9 @@ ArmDisassemblerLib
[Protocols]
+ gEfiDebugSupportProtocolGuid
+ gEfiLoadedImageProtocolGuid
[Guids]
+ gEfiDebugImageInfoTableGuid
-[Pcd]
|