Clear EFLAGS.IF before executing Stepping command and save original value in 
DEBUG_AGENT_FLAG. It could avoid pending interrupt issued during executing 
Stepping command.
Restore EFLAGS.IF after Stepping command execution finished.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff....@intel.com>
---
 .../DebugAgent/DebugAgentCommon/DebugAgent.c       | 53 ++++++++++++++++++----
 1 file changed, 44 insertions(+), 9 deletions(-)

diff --git 
a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c 
b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
index f51ad4b..72309f3 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
@@ -785,7 +785,7 @@ CommandGo (
 }
 
 /**
-  Exectue Stepping command.
+  Execute Stepping command.
 
   @param[in] CpuContext        Pointer to saved CPU context.
 
@@ -800,6 +800,39 @@ CommandStepping (
   Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;
   Eflags->Bits.TF = 1;
   Eflags->Bits.RF = 1;
+  //
+  // Save and clear EFLAGS.IF to avoid interrupt happen when executing Stepping
+  //
+  SetDebugFlag (DEBUG_AGENT_FLAG_INTERRUPT_FLAG, Eflags->Bits.IF);
+  Eflags->Bits.IF = 0;
+  //
+  // Set Stepping Flag
+  //
+  SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 1);
+}
+
+/**
+  Do some cleanup after Stepping command done.
+
+  @param[in] CpuContext        Pointer to saved CPU context.
+
+**/
+VOID
+CommandSteppingCleanup (
+  IN DEBUG_CPU_CONTEXT          *CpuContext
+  )
+{
+  IA32_EFLAGS32                *Eflags;
+
+  Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;
+  //
+  // Restore EFLAGS.IF
+  //
+  Eflags->Bits.IF = GetDebugFlag (DEBUG_AGENT_FLAG_INTERRUPT_FLAG);
+  //
+  // Clear Stepping flag
+  //
+  SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 0);
 }
 
 /**
@@ -2066,10 +2099,6 @@ CommandCommunication (
       }
 
       mDebugMpContext.BreakAtCpuIndex = (UINT32) (-1);
-      //
-      // Set Stepping Flag
-      //
-      SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 1);
       ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
       //
       // Executing stepping command directly without sending ACK packet,
@@ -2405,11 +2434,11 @@ InterruptProcess (
       if (MultiProcessorDebugSupport()) {
         mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
       }
-      SendAckPacket (DEBUG_COMMAND_OK);
       //
-      // Clear Stepping Flag
+      // Clear Stepping Flag and restore EFLAGS.IF
       //
-      SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 0);
+      CommandSteppingCleanup (CpuContext);
+      SendAckPacket (DEBUG_COMMAND_OK);
       CommandCommunication (Vector, CpuContext, BreakReceived);
       break;
 
@@ -2577,11 +2606,17 @@ InterruptProcess (
     if (Vector <= DEBUG_EXCEPT_SIMD) {
       if (BreakCause == DEBUG_DATA_BREAK_CAUSE_STEPPING) {
         //
-        // Stepping is finished, send Ack package.
+        // If exception happened when executing Stepping,
+        // Clear Stepping Flag and send Ack package. HOST consider 
+        // Stepping command was finished.
         //
         if (MultiProcessorDebugSupport()) {
           mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
         }
+        //
+        // Clear Stepping flag and restore EFLAGS.IF
+        //
+        CommandSteppingCleanup (CpuContext);
         SendAckPacket (DEBUG_COMMAND_OK);
       } else {
         //
-- 
1.9.5.msysgit.0



------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to