]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add a PcdEmulatorLazyLoadSymbols that allows non-lazy symbol loading. The problem...
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 15 Dec 2011 22:26:15 +0000 (22:26 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 15 Dec 2011 22:26:15 +0000 (22:26 +0000)
Added arguments to SecGdbScriptBreak() to enable lldb python symbol load/unload script.

signed-off-by:andrewfish

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12879 6f19259b-4bc3-4df7-8a09-765794883524

EmulatorPkg/EmulatorPkg.dec
EmulatorPkg/Unix/Host/Host.c
EmulatorPkg/Unix/Host/Host.inf

index f005c792cc9b9ff4dc0c4f2c6b0b7fc6feca5f64..b3d461de375bb70d81d138150d9303e6105ad4a2 100644 (file)
   gEmuVirtualDisksGuid       = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
   gEmuPhysicalDisksGuid      = { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
 \r
+[PcdsFeatureFlag]\r
+  ## If TRUE, if symbols only load on breakpoints and gdb entry\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmulatorLazyLoadSymbols|TRUE|BOOLEAN|0x00020000\r
+\r
 [PcdsFixedAtBuild]\r
   gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014\r
   gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|0x0|UINT64|0x00001015\r
index 17130168f0e511912a1815d53ed5b30695366f9d..8e1272d4e3a786bf05bcd8931b97c2a55a81b457 100644 (file)
@@ -1113,6 +1113,18 @@ DlLoadImage (
 }
 
 
+VOID
+SecGdbScriptBreak (
+  char                *FileName,
+  int                 FileNameLength,
+  long unsigned int   LoadAddress,
+  int                 AddSymbolFlag
+  )
+{
+  return;
+}
+
+
 /**
   Adds the image to a gdb script so it's symbols can be loaded.
   The AddFirmwareSymbolFile helper macro is used.
@@ -1130,20 +1142,41 @@ GdbScriptAddImage (
 
   if (ImageContext->PdbPointer != NULL && !IsPdbFile (ImageContext->PdbPointer)) {
     FILE  *GdbTempFile;
-    GdbTempFile = fopen (gGdbWorkingFileName, "a");
-    if (GdbTempFile != NULL) {
-      long unsigned int SymbolsAddr = (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders);
-      mScriptSymbolChangesCount++;
-      fprintf (
-        GdbTempFile,
-        "AddFirmwareSymbolFile 0x%x %s 0x%08lx\n",
-        mScriptSymbolChangesCount,
-        ImageContext->PdbPointer,
-        SymbolsAddr
-        );
-      fclose (GdbTempFile);
+    if (FeaturePcdGet (PcdEmulatorLazyLoadSymbols)) {    
+      GdbTempFile = fopen (gGdbWorkingFileName, "a");
+      if (GdbTempFile != NULL) {
+        long unsigned int SymbolsAddr = (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders);
+        mScriptSymbolChangesCount++;
+        fprintf (
+          GdbTempFile,
+          "AddFirmwareSymbolFile 0x%x %s 0x%08lx\n",
+          mScriptSymbolChangesCount,
+          ImageContext->PdbPointer,
+          SymbolsAddr
+          );
+        fclose (GdbTempFile);
+      } else {
+        ASSERT (FALSE);
+      }
     } else {
-      ASSERT (FALSE);
+      GdbTempFile = fopen (gGdbWorkingFileName, "w");
+      if (GdbTempFile != NULL) {
+        fprintf (
+          GdbTempFile, 
+          "add-symbol-file %s 0x%08lx\n", 
+          ImageContext->PdbPointer, 
+          (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)
+          );
+        fclose (GdbTempFile);
+  
+        //
+        // Target for gdb breakpoint in a script that uses gGdbWorkingFileName to set a breakpoint.
+        // Hey what can you say scripting in gdb is not that great....
+        //
+        SecGdbScriptBreak (ImageContext->PdbPointer, strlen (ImageContext->PdbPointer), (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders), 1);
+      } else {
+        ASSERT (FALSE);
+      }
     }
   }
 }
@@ -1182,21 +1215,37 @@ GdbScriptRemoveImage (
     return;
   }
 
-  //
-  // Write the file we need for the gdb script
-  //
-  GdbTempFile = fopen (gGdbWorkingFileName, "a");
-  if (GdbTempFile != NULL) {
-    mScriptSymbolChangesCount++;
-    fprintf (
-      GdbTempFile,
-      "RemoveFirmwareSymbolFile 0x%x %s\n",
-      mScriptSymbolChangesCount,
-      ImageContext->PdbPointer
-      );
-    fclose (GdbTempFile);
+  if (FeaturePcdGet (PcdEmulatorLazyLoadSymbols)) {    
+    //
+    // Write the file we need for the gdb script
+    //
+    GdbTempFile = fopen (gGdbWorkingFileName, "a");
+    if (GdbTempFile != NULL) {
+      mScriptSymbolChangesCount++;
+      fprintf (
+        GdbTempFile,
+        "RemoveFirmwareSymbolFile 0x%x %s\n",
+        mScriptSymbolChangesCount,
+        ImageContext->PdbPointer
+        );
+      fclose (GdbTempFile);
+    } else {
+      ASSERT (FALSE);
+    }
   } else {
-    ASSERT (FALSE);
+    GdbTempFile = fopen (gGdbWorkingFileName, "w");
+    if (GdbTempFile != NULL) {
+      fprintf (GdbTempFile, "remove-symbol-file %s\n", ImageContext->PdbPointer);
+      fclose (GdbTempFile);
+
+      //
+      // Target for gdb breakpoint in a script that uses gGdbWorkingFileName to set a breakpoint.
+      // Hey what can you say scripting in gdb is not that great....
+      //
+      SecGdbScriptBreak (ImageContext->PdbPointer, strlen (ImageContext->PdbPointer), 0, 0);
+    } else {
+      ASSERT (FALSE);
+    }  
   }
 }
 
index 018ed8673f2897138cbc68482584f21b3731a102..496bd770b397e264f2989911543ccc6901090d2b 100644 (file)
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
   gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
 \r
+[FeaturePcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmulatorLazyLoadSymbols\r
+\r
 \r
 [BuildOptions]\r
    GCC:*_*_IA32_DLINK_FLAGS == -o $(BIN_DIR)/Host -m elf_i386 -dynamic-linker $(HOST_DLINK_PATHS) -L/usr/X11R6/lib -lXext -lX11\r