]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
Sync up ArmPkg with patch from mailing list. Changed name of BdsLib.h to BdsUnixLib...
[mirror_edk2.git] / ArmPkg / Library / DebugPeCoffExtraActionLib / DebugPeCoffExtraActionLib.c
index a1d3c06f2a2221ea80e7cc4effecc0a1bbb2d796..5bd1a9d1883d058a83aedb74d37e8aa57859b903 100755 (executable)
@@ -1,8 +1,8 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation\r
-Portions copyright (c) 2008-2010 Apple Inc. All rights reserved.\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\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
 http://opensource.org/licenses/bsd-license.php\r
@@ -32,37 +32,33 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 CHAR8 *\r
 DeCygwinPathIfNeeded (\r
-  IN  CHAR8   *Name\r
+  IN  CHAR8   *Name,\r
+  IN  CHAR8   *Temp,\r
+  IN  UINTN   Size\r
   )\r
 {\r
   CHAR8   *Ptr;\r
   UINTN   Index;\r
-  UINTN   Len;\r
+  UINTN   Index2;\r
   \r
   Ptr = AsciiStrStr (Name, "/cygdrive/");\r
   if (Ptr == NULL) {\r
     return Name;\r
   }\r
   \r
-  Len = AsciiStrLen (Ptr);\r
-  \r
-  // convert "/cygdrive" to spaces\r
-  for (Index = 0; Index < 9; Index++) {\r
-    Ptr[Index] = ' ';\r
+  for (Index = 9, Index2 = 0; (Index < (Size + 9)) && (Ptr[Index] != '\0'); Index++, Index2++) {\r
+    Temp[Index2] = Ptr[Index];\r
+    if (Temp[Index2] == '/') {\r
+      Temp[Index2] = '\\' ;\r
   }\r
 \r
-  // convert /c to c:\r
-  Ptr[9]  = Ptr[10];\r
-  Ptr[10] = ':';\r
-  \r
-  // switch path seperators\r
-  for (Index = 11; Index < Len; Index++) {\r
-    if (Ptr[Index] == '/') {\r
-      Ptr[Index] = '\\' ;\r
+    if (Index2 == 1) {\r
+      Temp[Index2 - 1] = Ptr[Index];\r
+      Temp[Index2] = ':';\r
     }\r
   }\r
 \r
-  return Name;\r
+  return Temp;\r
 }\r
 \r
 \r
@@ -81,12 +77,14 @@ PeCoffLoaderRelocateImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
+    CHAR8 Temp[512];\r
+\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), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\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
 #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), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\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
 #endif\r
@@ -110,12 +108,16 @@ PeCoffLoaderUnloadImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
+  CHAR8 Temp[512];\r
+  \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)));\r
+    DEBUG ((EFI_D_ERROR, "unload symbols_only %a", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp))));\r
+  }\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), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\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
 #endif\r