]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
ARM Packages: Removed trailing spaces
[mirror_edk2.git] / ArmPkg / Library / DebugPeCoffExtraActionLib / DebugPeCoffExtraActionLib.c
CommitLineData
5b792f1a 1/**@file\r
2\r
d6ebcab7
HT
3Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
4Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
96a8bc11 5Portions copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>\r
6\r
d6ebcab7 7This program and the accompanying materials\r
5b792f1a 8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include <PiDxe.h>\r
18#include <Library/PeCoffLib.h>\r
19\r
20#include <Library/BaseLib.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/BaseMemoryLib.h>\r
23#include <Library/PeCoffExtraActionLib.h>\r
24#include <Library/PrintLib.h>\r
25\r
26\r
27/**\r
3402aac7 28 If the build is done on cygwin the paths are cygpaths.\r
5b792f1a 29 /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert\r
30 them to work with RVD commands\r
31\r
32 @param Name Path to convert if needed\r
33\r
34**/\r
35CHAR8 *\r
36DeCygwinPathIfNeeded (\r
1bfda055 37 IN CHAR8 *Name,\r
38 IN CHAR8 *Temp,\r
39 IN UINTN Size\r
5b792f1a 40 )\r
41{\r
42 CHAR8 *Ptr;\r
43 UINTN Index;\r
1bfda055 44 UINTN Index2;\r
3402aac7 45\r
5b792f1a 46 Ptr = AsciiStrStr (Name, "/cygdrive/");\r
47 if (Ptr == NULL) {\r
48 return Name;\r
49 }\r
3402aac7 50\r
1bfda055 51 for (Index = 9, Index2 = 0; (Index < (Size + 9)) && (Ptr[Index] != '\0'); Index++, Index2++) {\r
52 Temp[Index2] = Ptr[Index];\r
53 if (Temp[Index2] == '/') {\r
54 Temp[Index2] = '\\' ;\r
5b792f1a 55 }\r
56\r
1bfda055 57 if (Index2 == 1) {\r
58 Temp[Index2 - 1] = Ptr[Index];\r
59 Temp[Index2] = ':';\r
5b792f1a 60 }\r
61 }\r
62\r
1bfda055 63 return Temp;\r
5b792f1a 64}\r
65\r
66\r
67/**\r
68 Performs additional actions after a PE/COFF image has been loaded and relocated.\r
69\r
70 If ImageContext is NULL, then ASSERT().\r
71\r
72 @param ImageContext Pointer to the image context structure that describes the\r
73 PE/COFF image that has already been loaded and relocated.\r
74\r
75**/\r
76VOID\r
77EFIAPI\r
78PeCoffLoaderRelocateImageExtraAction (\r
79 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
80 )\r
81{\r
3402aac7 82#if !defined(MDEPKG_NDEBUG)\r
e862cd50 83 CHAR8 Temp[512];\r
84#endif\r
1bfda055 85\r
28929e20 86 if (ImageContext->PdbPointer) {\r
5b792f1a 87#ifdef __CC_ARM\r
96a8bc11 88#if (__ARMCC_VERSION < 500000)\r
28929e20 89 // Print out the command for the RVD debugger to load symbols for this image\r
893e5532 90 DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
96a8bc11 91#else\r
28929e20 92 // Print out the command for the DS-5 to load symbols for this image\r
893e5532 93 DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
96a8bc11 94#endif\r
5b792f1a 95#elif __GNUC__\r
28929e20 96 // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
893e5532 97 DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%p\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
5b792f1a 98#else\r
28929e20 99 DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));\r
5b792f1a 100#endif\r
28929e20 101 } else {\r
102 DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));\r
103 }\r
5b792f1a 104}\r
105\r
106\r
107\r
108/**\r
109 Performs additional actions just before a PE/COFF image is unloaded. Any resources\r
110 that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r
3402aac7 111\r
5b792f1a 112 If ImageContext is NULL, then ASSERT().\r
3402aac7 113\r
5b792f1a 114 @param ImageContext Pointer to the image context structure that describes the\r
115 PE/COFF image that is being unloaded.\r
116\r
117**/\r
118VOID\r
119EFIAPI\r
120PeCoffLoaderUnloadImageExtraAction (\r
121 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
122 )\r
123{\r
e862cd50 124#if !defined(MDEPKG_NDEBUG)\r
1bfda055 125 CHAR8 Temp[512];\r
e862cd50 126#endif\r
3402aac7 127\r
28929e20 128 if (ImageContext->PdbPointer) {\r
5b792f1a 129#ifdef __CC_ARM\r
28929e20 130 // Print out the command for the RVD debugger to load symbols for this image\r
e7482298 131 DEBUG ((EFI_D_ERROR, "unload symbols_only %a\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp))));\r
5b792f1a 132#elif __GNUC__\r
28929e20 133 // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
134 DEBUG ((EFI_D_ERROR, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
5b792f1a 135#else\r
28929e20 136 DEBUG ((EFI_D_ERROR, "Unloading %a\n", ImageContext->PdbPointer));\r
5b792f1a 137#endif\r
28929e20 138 } else {\r
139 DEBUG ((EFI_D_ERROR, "Unloading driver at 0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress));\r
140 }\r
5b792f1a 141}\r