]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Adding a command to show how symbols work in EFI
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 19 Feb 2010 23:49:51 +0000 (23:49 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 19 Feb 2010 23:49:51 +0000 (23:49 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10029 6f19259b-4bc3-4df7-8a09-765794883524

BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c
BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.inf

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