[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 09:15:07 PDT 2024
https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/94754
>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 1/4] [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,
)
>From 79a8c423a2aaa104ec3bfa024a922ad7d110a4e7 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Fri, 7 Jun 2024 14:28:44 +0100
Subject: [PATCH 2/4] format with darker
---
.../dexter/dex/debugger/visualstudio/VisualStudio.py | 10 +++++-----
1 file changed, 5 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 894a59b1824e4..6aff82bbdebf7 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
@@ -309,15 +309,15 @@ 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
+ if reason == 1: # dbgEventReasonNone
return None
- if reason == 9: # dbgEventReasonBreakpoint
+ if reason == 9: # dbgEventReasonBreakpoint
return StopReason.BREAKPOINT
- if reason == 8: # dbgEventReasonStep
+ if reason == 8: # dbgEventReasonStep
return StopReason.STEP
- if reason == 6: # dbgEventReasonEndProgram
+ if reason == 6: # dbgEventReasonEndProgram
return StopReason.PROGRAM_EXIT
- if reason == 11: # dbgEventReasonExceptionNotHandled
+ if reason == 11: # dbgEventReasonExceptionNotHandled
return StopReason.ERROR
# Others:
# dbgEventReasonNone = 1
>From 6ad8a13d1f55c207a4dd58732f1f0bd9fe4e84e7 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Fri, 7 Jun 2024 17:09:42 +0100
Subject: [PATCH 3/4] use an EnumInt
---
.../dex/debugger/visualstudio/VisualStudio.py | 42 ++++++++++++-------
1 file changed, 26 insertions(+), 16 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 6aff82bbdebf7..02c63d4b038bc 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 imp
import os
import sys
+from enum import IntEnum
from pathlib import PurePath, Path
from collections import defaultdict, namedtuple
@@ -36,6 +37,25 @@ def _load_com_module():
# properties we set through dexter currently.
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
@@ -308,27 +328,17 @@ 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
+ if reason == DbgEvent.dbgEventReasonNone:
return None
- if reason == 9: # dbgEventReasonBreakpoint
+ if reason == DbgEvent.dbgEventReasonBreakpoint:
return StopReason.BREAKPOINT
- if reason == 8: # dbgEventReasonStep
+ if reason == DbgEvent.dbgEventReasonStep:
return StopReason.STEP
- if reason == 6: # dbgEventReasonEndProgram
+ if reason == DbgEvent.dbgEventReasonEndProgram:
return StopReason.PROGRAM_EXIT
- if reason == 11: # dbgEventReasonExceptionNotHandled
+ if reason == DbgEvent.dbgEventReasonExceptionNotHandled:
return StopReason.ERROR
- # Others:
- # dbgEventReasonNone = 1
- # dbgEventReasonGo = 2
- # dbgEventReasonAttachProgram = 3
- # dbgEventReasonDetachProgram = 4
- # dbgEventReasonLaunchProgram = 5
- # dbgEventReasonStopDebugging = 7
- # dbgEventReasonExceptionThrown = 10
- # dbgEventReasonUserBreak = 12
- # dbgEventReasonContextSwitch = 13
+ assert reason <= DbgEvent.last and reason >= DbgEvent.first
return StopReason.OTHER
def _get_step_info(self, watches, step_index):
>From 22dfabb22a9d0244afccfedcf0383d72f50e772c Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Fri, 7 Jun 2024 17:14:53 +0100
Subject: [PATCH 4/4] format
---
.../dexter/dex/debugger/visualstudio/VisualStudio.py | 1 +
1 file changed, 1 insertion(+)
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 02c63d4b038bc..17587b3f3e18d 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
@@ -37,6 +37,7 @@ def _load_com_module():
# properties we set through dexter currently.
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):
More information about the llvm-commits
mailing list