]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
ArmPkg/DebugPeCoffExtraActionLib: Checked the ImageContext->PdbPointer is not null
[mirror_edk2.git] / ArmPkg / Library / DebugPeCoffExtraActionLib / DebugPeCoffExtraActionLib.c
index 5bd1a9d1883d058a83aedb74d37e8aa57859b903..6d0bb988ea3faa5639c86bc784577107e6c9e2ca 100755 (executable)
@@ -2,6 +2,8 @@
 \r
 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
+Portions copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>\r
+\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -77,17 +79,28 @@ PeCoffLoaderRelocateImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
-    CHAR8 Temp[512];\r
+#if !defined(MDEPKG_NDEBUG) \r
+  CHAR8 Temp[512];\r
+#endif\r
 \r
+  if (ImageContext->PdbPointer) {\r
 #ifdef __CC_ARM\r
-  // Print out the command for the RVD debugger to load symbols for this image\r
-  DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
+#if (__ARMCC_VERSION < 500000)\r
+    // Print out the command for the RVD debugger to load symbols for this image\r
+    DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
+#else\r
+    // Print out the command for the DS-5 to load symbols for this image\r
+    DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
+#endif\r
 #elif __GNUC__\r
-  // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
-  DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
+    // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
+    DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
 #else\r
-  DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));\r
+    DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));\r
 #endif\r
+  } else {\r
+    DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));\r
+  }\r
 }\r
 \r
 \r
@@ -108,17 +121,21 @@ PeCoffLoaderUnloadImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
+#if !defined(MDEPKG_NDEBUG)\r
   CHAR8 Temp[512];\r
+#endif\r
   \r
+  if (ImageContext->PdbPointer) {\r
 #ifdef __CC_ARM\r
-  {  \r
-  // Print out the command for the RVD debugger to load symbols for this image\r
-    DEBUG ((EFI_D_ERROR, "unload symbols_only %a", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp))));\r
-  }\r
+    // Print out the command for the RVD debugger to load symbols for this image\r
+    DEBUG ((EFI_D_ERROR, "unload symbols_only %a\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp))));\r
 #elif __GNUC__\r
-  // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
-  DEBUG ((EFI_D_ERROR, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
+    // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
+    DEBUG ((EFI_D_ERROR, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
 #else\r
-  DEBUG ((EFI_D_ERROR, "Unloading %a", ImageContext->PdbPointer));\r
+    DEBUG ((EFI_D_ERROR, "Unloading %a\n", ImageContext->PdbPointer));\r
 #endif\r
+  } else {\r
+    DEBUG ((EFI_D_ERROR, "Unloading driver at 0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress));\r
+  }\r
 }\r