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