diff options
author | Brian J. Johnson <bjohnson@sgi.com> | 2015-03-25 01:51:23 +0000 |
---|---|---|
committer | vanjeff <vanjeff@Edk2> | 2015-03-25 01:51:23 +0000 |
commit | 602adebbe6291c3b92532ccee5c38dc4c42d8959 (patch) | |
tree | 399eeb1fdf887415055b835aef8286d110e63be2 /SourceLevelDebugPkg/Library | |
parent | e29fc5022042f7c86b07673741749cf3de5f3816 (diff) | |
download | edk2-platforms-602adebbe6291c3b92532ccee5c38dc4c42d8959.tar.xz |
PeCoffExtraActionLibDebug: Restore debug registers in PeCoffExtraActionLibDebug
PeCoffExtraActionLibDebug uses the debug registers to pass module load information to the
DebugAgent, then restores the old register values.
However, it was missing code to restore Dr7 in the
DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3 case. This broke hardware breakpoints and watchpoints.
It could also lose modifications the debugger made to Cr4.
Restore the Dr7 and Cr4 values correctly in the
DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3 case, as well as the
DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT case.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brian J. Johnson <bjohnson@sgi.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17071 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SourceLevelDebugPkg/Library')
-rw-r--r-- | SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c index 9bf76bfb22..84cfe19efc 100644 --- a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c +++ b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c @@ -104,7 +104,7 @@ PeCoffLoaderExtraActionCommon ( Dr1 = AsmReadDr1 ();
Dr2 = AsmReadDr2 ();
Dr3 = AsmReadDr3 ();
- Dr7 = AsmReadDr7 ();
+ Dr7 = AsmReadDr7 () | BIT10; // H/w sets bit 10, some simulators don't
Cr4 = AsmReadCr4 ();
//
@@ -115,7 +115,7 @@ PeCoffLoaderExtraActionCommon ( // 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);
+ AsmWriteDr7 (BIT10);
AsmWriteDr0 (Signature);
AsmWriteDr1 ((UINTN) ImageContext->PdbPointer);
AsmWriteDr2 ((UINTN) ImageContext);
@@ -144,7 +144,7 @@ PeCoffLoaderExtraActionCommon ( // E.g.: User halts the target and sets the HW breakpoint while target is
// in the above exception handler
//
- NewDr7 = AsmReadDr7 ();
+ NewDr7 = AsmReadDr7 () | BIT10; // H/w sets bit 10, some simulators don't
if (!IsDrxEnabled (0, NewDr7) && (AsmReadDr0 () == 0 || AsmReadDr0 () == Signature)) {
//
// If user changed Dr3 (by setting HW bp in the above exception handler,
@@ -161,11 +161,17 @@ PeCoffLoaderExtraActionCommon ( if (!IsDrxEnabled (3, NewDr7) && (AsmReadDr3 () == IO_PORT_BREAKPOINT_ADDRESS)) {
AsmWriteDr3 (Dr3);
}
- if (AsmReadCr4 () == (Cr4 | BIT3)) {
- AsmWriteCr4 (Cr4);
- }
- if (NewDr7 == 0x20000480) {
- AsmWriteDr7 (Dr7);
+ if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT) {
+ if (AsmReadCr4 () == (Cr4 | BIT3)) {
+ AsmWriteCr4 (Cr4);
+ }
+ if (NewDr7 == 0x20000480) {
+ AsmWriteDr7 (Dr7);
+ }
+ } else if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
+ if (NewDr7 == BIT10) {
+ AsmWriteDr7 (Dr7);
+ }
}
//
// Restore original IDT entry for INT1 if it was hooked.
|