summaryrefslogtreecommitdiff
path: root/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-06-11 02:15:11 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-06-11 02:15:11 +0000
commit93c0bdec2807cd968a89a0ac01a379a90fa50f93 (patch)
tree6d5fea7bf8312b2101fe64c295877e20047ed420 /SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug
parent44538ba5aa759c4039fc6c588d33a7fe03503c3f (diff)
downloadedk2-platforms-93c0bdec2807cd968a89a0ac01a379a90fa50f93.tar.xz
This revision can only work with Intel(c) UDK Debugger Tool version 1.2 or greater. Detailed change log is as below:
1. Define the transfer protocol revision mechanism. Increase the revision number to 0.2 and inform user to use the latest one when the HOST software is too old. New HOST software will implement logic to handle all other revision mismatch cases. 2. Define new debug message packet to print the debug agent trace information by debug port channel. 3. Add check sum mechanism in the communication protocol between TARGET/HOST. 4. Introduced one "try" mechanism to avoid Debug Agent crashed by some invalid HOST command. 5. Enable the late-attach feature: Change the break in from "!" to "\xFC". Add a new short symbol "\xFA" for attach and a new debug command for detach. 6. Support Terminal work on debug port by install EFI Serial IO protocol upon Debug Communication Library. 7. Enable CPUID feature. 8. Enable the hardware data breakpoint. 9. add handshake to improve usb debug cable identify stability issue. 10.Refine all the communication protocol packet to improve extensibility and debugging performance. a. Use 64bit for IO port address. b. Add additional Width field to READ_MEMORY/WRITE_MEMORY. c. Add SEARCH_SIGNATURE support to speed the symbol finding for late attach. d. Remove READ_GROUP register. e. Add READ_ALL_REGISTERS support (WinDbg always requests to read all registers). 11.Move AcquireDebugPortControl () in advance to fix resource collision on IpiSentByApFlag. 12.Fix IO break point does not work issue in PEI phase. 13.Avoid BSP/APs collision when they met break point at the same time. 14.Solve a bug of calculating debug handle in sec phase. 15.Use mailbox content at Dxe phase but not clear it and reinitialize again. 16.Fix FP/MMX/XMM/IO/MSR access issue in both Gdb and WinDbg. Signed-off-by: Jeff Fan <jeff.fan@intel.com> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Signed-off-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13437 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug')
-rw-r--r--SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c148
1 files changed, 37 insertions, 111 deletions
diff --git a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
index 0fbc2b81d6..7b551f20ed 100644
--- a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
+++ b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
@@ -1,7 +1,7 @@
/** @file
PE/Coff Extra Action library instances.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -47,18 +47,19 @@ IsDrxEnabled (
}
/**
- Performs additional actions after a PE/COFF image has been loaded and relocated.
+ Common routine to report the PE/COFF image loading/relocating or unloading event.
If ImageContext is NULL, then ASSERT().
-
+
@param ImageContext Pointer to the image context structure that describes the
- PE/COFF image that has already been loaded and relocated.
+ PE/COFF image.
+ @param Signature IMAGE_LOAD_SIGNATURE or IMAGE_UNLOAD_SIGNATURE.
**/
VOID
-EFIAPI
-PeCoffLoaderRelocateImageExtraAction (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+PeCoffLoaderExtraActionCommon (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Signature
)
{
BOOLEAN InterruptState;
@@ -94,7 +95,7 @@ PeCoffLoaderRelocateImageExtraAction (
Cr4 = AsmReadCr4 ();
//
- // DR0 = IMAGE_LOAD_SIGNATURE
+ // DR0 = Signature
// DR1 = The address of the Null-terminated ASCII string for the PE/COFF image's PDB file name
// DR2 = The pointer to the ImageContext structure
// DR3 = IO_PORT_BREAKPOINT_ADDRESS
@@ -102,9 +103,9 @@ PeCoffLoaderRelocateImageExtraAction (
// CR4 = Make sure DE(BIT3) is set
//
AsmWriteDr7 (0);
- AsmWriteDr0 (IMAGE_LOAD_SIGNATURE);
- AsmWriteDr1 ((UINTN)ImageContext->PdbPointer);
- AsmWriteDr2 ((UINTN)ImageContext);
+ AsmWriteDr0 (Signature);
+ AsmWriteDr1 ((UINTN) ImageContext->PdbPointer);
+ AsmWriteDr2 ((UINTN) ImageContext);
AsmWriteDr3 (IO_PORT_BREAKPOINT_ADDRESS);
LoadImageMethod = PcdGet8 (PcdDebugLoadImageMethod);
@@ -132,16 +133,20 @@ PeCoffLoaderRelocateImageExtraAction (
// in the above exception handler
//
NewDr7 = AsmReadDr7 ();
- if (!IsDrxEnabled (0, NewDr7)) {
+ if (!IsDrxEnabled (0, NewDr7) && (AsmReadDr0 () == 0 || AsmReadDr0 () == Signature)) {
+ //
+ // If user changed Dr3 (by setting HW bp in the above exception handler,
+ // we will not set Dr0 to 0 in GO/STEP handler because the break cause is not IMAGE_LOAD/_UNLOAD.
+ //
AsmWriteDr0 (Dr0);
}
- if (!IsDrxEnabled (1, NewDr7)) {
+ if (!IsDrxEnabled (1, NewDr7) && (AsmReadDr1 () == (UINTN) ImageContext->PdbPointer)) {
AsmWriteDr1 (Dr1);
}
- if (!IsDrxEnabled (2, NewDr7)) {
+ if (!IsDrxEnabled (2, NewDr7) && (AsmReadDr2 () == (UINTN) ImageContext)) {
AsmWriteDr2 (Dr2);
}
- if (!IsDrxEnabled (3, NewDr7)) {
+ if (!IsDrxEnabled (3, NewDr7) && (AsmReadDr3 () == IO_PORT_BREAKPOINT_ADDRESS)) {
AsmWriteDr3 (Dr3);
}
if (AsmReadCr4 () == (Cr4 | BIT3)) {
@@ -157,11 +162,25 @@ PeCoffLoaderRelocateImageExtraAction (
}
/**
+ Performs additional actions after a PE/COFF image has been loaded and relocated.
+
+ @param ImageContext Pointer to the image context structure that describes the
+ PE/COFF image that has already been loaded and relocated.
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderRelocateImageExtraAction (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ PeCoffLoaderExtraActionCommon (ImageContext, IMAGE_LOAD_SIGNATURE);
+}
+
+/**
Performs additional actions just before a PE/COFF image is unloaded. Any resources
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
- If ImageContext is NULL, then ASSERT().
-
@param ImageContext Pointer to the image context structure that describes the
PE/COFF image that is being unloaded.
@@ -172,98 +191,5 @@ PeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
- BOOLEAN InterruptState;
- UINTN Dr0;
- UINTN Dr1;
- UINTN Dr2;
- UINTN Dr3;
- UINTN Dr7;
- UINTN Cr4;
- UINTN NewDr7;
- UINT8 LoadImageMethod;
- UINT8 DebugAgentStatus;
-
- ASSERT (ImageContext != NULL);
-
- if (ImageContext->PdbPointer != NULL) {
- DEBUG((EFI_D_ERROR, " PDB = %a\n", ImageContext->PdbPointer));
- }
-
- //
- // Disable interrupts and save the current interrupt state
- //
- InterruptState = SaveAndDisableInterrupts ();
-
- //
- // Save Debug Register State
- //
- Dr0 = AsmReadDr0 ();
- Dr1 = AsmReadDr1 ();
- Dr2 = AsmReadDr2 ();
- Dr3 = AsmReadDr3 ();
- Dr7 = AsmReadDr7 ();
- Cr4 = AsmReadCr4 ();
-
- //
- // DR0 = IMAGE_UNLOAD_SIGNATURE
- // DR1 = The address of the Null-terminated ASCII string for the PE/COFF image's PDB file name
- // DR2 = The pointer to the ImageContext structure
- // DR3 = IO_PORT_BREAKPOINT_ADDRESS
- // DR7 = Disables all HW breakpoints except for DR3 I/O port access of length 1 byte
- // CR4 = Make sure DE(BIT3) is set
- //
- AsmWriteDr7 (0);
- AsmWriteDr0 (IMAGE_UNLOAD_SIGNATURE);
- AsmWriteDr1 ((UINTN)ImageContext->PdbPointer);
- AsmWriteDr2 ((UINTN)ImageContext);
- AsmWriteDr3 (IO_PORT_BREAKPOINT_ADDRESS);
-
- LoadImageMethod = PcdGet8 (PcdDebugLoadImageMethod);
- if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT) {
- AsmWriteDr7 (0x20000480);
- AsmWriteCr4 (Cr4 | BIT3);
- //
- // Do an IN from IO_PORT_BREAKPOINT_ADDRESS to generate a HW breakpoint until the port
- // returns a read value other than DEBUG_AGENT_IMAGE_WAIT
- //
- do {
- DebugAgentStatus = IoRead8 (IO_PORT_BREAKPOINT_ADDRESS);
- } while (DebugAgentStatus == DEBUG_AGENT_IMAGE_WAIT);
-
- } else if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
- //
- // Generate a software break point.
- //
- CpuBreakpoint ();
- }
-
- //
- // Restore Debug Register State only when Host didn't change it inside exception handler.
- // E.g.: User halts the target and sets the HW breakpoint while target is
- // in the above exception handler
- //
- NewDr7 = AsmReadDr7 ();
- if (!IsDrxEnabled (0, NewDr7)) {
- AsmWriteDr0 (Dr0);
- }
- if (!IsDrxEnabled (1, NewDr7)) {
- AsmWriteDr1 (Dr1);
- }
- if (!IsDrxEnabled (2, NewDr7)) {
- AsmWriteDr2 (Dr2);
- }
- if (!IsDrxEnabled (3, NewDr7)) {
- AsmWriteDr3 (Dr3);
- }
- if (AsmReadCr4 () == (Cr4 | BIT3)) {
- AsmWriteCr4 (Cr4);
- }
- if (NewDr7 == 0x20000480) {
- AsmWriteDr7 (Dr7);
- }
-
- //
- // Restore the interrupt state
- //
- SetInterruptState (InterruptState);
+ PeCoffLoaderExtraActionCommon (ImageContext, IMAGE_UNLOAD_SIGNATURE);
}