aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrlando Cazalet-Hyams <orlando.hyams@sony.com>2024-06-10 08:47:39 +0100
committerGitHub <noreply@github.com>2024-06-10 08:47:39 +0100
commit832b91fcb9fd42d92a741129c6e085ef15ab385b (patch)
treea4902c4909e6f56881cbc0e6218947ece46eef28
parente4790ce2096c805b7598c353f9e7fa513701f843 (diff)
downloadllvm-832b91fcb9fd42d92a741129c6e085ef15ab385b.zip
llvm-832b91fcb9fd42d92a741129c6e085ef15ab385b.tar.gz
llvm-832b91fcb9fd42d92a741129c6e085ef15ab385b.tar.bz2
[dexter] Correctly identify stop-reason while driving VisualStudio (#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. No test added as there are no VisualStudio tests (tested locally).
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py42
1 files changed, 37 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 0e20cfb..17587b3f 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
@@ -10,6 +10,7 @@ import abc
import imp
import os
import sys
+from enum import IntEnum
from pathlib import PurePath, Path
from collections import defaultdict, namedtuple
@@ -37,6 +38,26 @@ def _load_com_module():
VSBreakpoint = namedtuple("VSBreakpoint", "path, line, col, cond")
+# Visual Studio events.
+# https://learn.microsoft.com/en-us/dotnet/api/envdte.dbgeventreason?view=visualstudiosdk-2022
+class DbgEvent(IntEnum):
+ dbgEventReasonNone = 1
+ dbgEventReasonGo = 2
+ dbgEventReasonAttachProgram = 3
+ dbgEventReasonDetachProgram = 4
+ dbgEventReasonLaunchProgram = 5
+ dbgEventReasonEndProgram = 6
+ dbgEventReasonStopDebugging = 7
+ dbgEventReasonStep = 8
+ dbgEventReasonBreakpoint = 9
+ dbgEventReasonExceptionThrown = 10
+ dbgEventReasonExceptionNotHandled = 11
+ dbgEventReasonUserBreak = 12
+ dbgEventReasonContextSwitch = 13
+
+ first = dbgEventReasonNone
+ last = dbgEventReasonContextSwitch
+
class VisualStudio(
DebuggerBase, metaclass=abc.ABCMeta
): # pylint: disable=abstract-method
@@ -307,6 +328,20 @@ class VisualStudio(
)
)
+ def _translate_stop_reason(self, reason):
+ if reason == DbgEvent.dbgEventReasonNone:
+ return None
+ if reason == DbgEvent.dbgEventReasonBreakpoint:
+ return StopReason.BREAKPOINT
+ if reason == DbgEvent.dbgEventReasonStep:
+ return StopReason.STEP
+ if reason == DbgEvent.dbgEventReasonEndProgram:
+ return StopReason.PROGRAM_EXIT
+ if reason == DbgEvent.dbgEventReasonExceptionNotHandled:
+ return StopReason.ERROR
+ assert reason <= DbgEvent.last and reason >= DbgEvent.first
+ return StopReason.OTHER
+
def _get_step_info(self, watches, step_index):
thread = self._debugger.CurrentThread
stackframes = thread.StackFrames
@@ -347,16 +382,13 @@ class VisualStudio(
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,
)