[llvm] [dexter] Correctly identify stop-reason while driving VisualStudio (PR #94754)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 06:21:19 PDT 2024


https://github.com/OCHyams created https://github.com/llvm/llvm-project/pull/94754

Prior to this patch VisualStudio._get_step_info incorrectly identifies the reason the debugger has stopped. e.g., stepping through a program would be reported as a StopReason.Breakpoint rather than StopReason.Step.

Fix. Not test added as there are no VisualStudio tests (tested locally).

>From bbb546a4fd6b31c8dbe4d273e5438d565e36259b Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Fri, 7 Jun 2024 14:16:10 +0100
Subject: [PATCH] [dexter] Correctly identify stop-reason

Prior to this patch VisualStudio._get_step_info incorrectly identifies the
reason the debugger has stopped. e.g., stepping through a program would be
reported as a StopReason.Breakpoint rather than StopReason.Step.

Fix. Not test added as there are no VisualStudio tests (tested locally).
---
 .../dex/debugger/visualstudio/VisualStudio.py | 31 ++++++++++++++++---
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
index 0e20cfbbd264b..894a59b1824e4 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
@@ -307,6 +307,30 @@ def set_current_stack_frame(self, idx: int = 0):
                 )
             )
 
+    def _translate_stop_reason(self, reason):
+        # https://learn.microsoft.com/en-us/dotnet/api/envdte.dbgeventreason?view=visualstudiosdk-2022
+        if reason == 1: # dbgEventReasonNone
+            return None
+        if reason == 9: # dbgEventReasonBreakpoint
+            return StopReason.BREAKPOINT
+        if reason == 8: # dbgEventReasonStep
+            return StopReason.STEP
+        if reason == 6: # dbgEventReasonEndProgram
+            return StopReason.PROGRAM_EXIT
+        if reason == 11: # dbgEventReasonExceptionNotHandled
+            return StopReason.ERROR
+        # Others:
+        # dbgEventReasonNone = 1
+        # dbgEventReasonGo = 2
+        # dbgEventReasonAttachProgram = 3
+        # dbgEventReasonDetachProgram = 4
+        # dbgEventReasonLaunchProgram = 5
+        # dbgEventReasonStopDebugging = 7
+        # dbgEventReasonExceptionThrown = 10
+        # dbgEventReasonUserBreak = 12
+        # dbgEventReasonContextSwitch = 13
+        return StopReason.OTHER
+
     def _get_step_info(self, watches, step_index):
         thread = self._debugger.CurrentThread
         stackframes = thread.StackFrames
@@ -347,16 +371,13 @@ def _get_step_info(self, watches, step_index):
             frames[0].loc = loc
             state_frames[0].location = SourceLocation(**self._location)
 
-        reason = StopReason.BREAKPOINT
-        if loc.path is None:  # pylint: disable=no-member
-            reason = StopReason.STEP
-
+        stop_reason = self._translate_stop_reason(self._debugger.LastBreakReason)
         program_state = ProgramState(frames=state_frames)
 
         return StepIR(
             step_index=step_index,
             frames=frames,
-            stop_reason=reason,
+            stop_reason=stop_reason,
             program_state=program_state,
         )
 



More information about the llvm-commits mailing list