@@ -66,12 +66,21 @@ internal bool IsEnum (string type, int frameId)
66
66
67
67
protected override void OnContinue ( )
68
68
{
69
- protocolClient . SendRequestSync ( new ContinueRequest ( currentThreadId ) ) ;
69
+ try {
70
+ protocolClient . SendRequestSync ( new ContinueRequest ( currentThreadId ) ) ;
71
+ } catch ( Exception ex ) {
72
+ if ( ! HandleException ( ex ) )
73
+ OnDebuggerOutput ( true , ex . ToString ( ) ) ;
74
+ }
70
75
}
71
76
72
77
protected override void OnDetach ( )
73
78
{
74
- protocolClient . SendRequestSync ( new DisconnectRequest ( ) ) ;
79
+ try {
80
+ protocolClient . SendRequestSync ( new DisconnectRequest ( ) ) ;
81
+ } catch ( Exception ex ) {
82
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] Error detaching debugger session" , ex ) ;
83
+ }
75
84
}
76
85
77
86
protected override void OnEnableBreakEvent ( BreakEventInfo eventInfo , bool enable )
@@ -85,13 +94,18 @@ protected override void OnExit ()
85
94
try {
86
95
HasExited = true ;
87
96
protocolClient . SendRequestSync ( new DisconnectRequest ( ) ) ;
88
- } catch {
97
+ } catch ( Exception ex ) {
98
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] Error closing debugger session" , ex ) ;
89
99
}
90
100
}
91
101
92
102
protected override void OnFinish ( )
93
103
{
94
- protocolClient . SendRequestSync ( new StepOutRequest ( currentThreadId ) ) ;
104
+ try {
105
+ protocolClient . SendRequestSync ( new StepOutRequest ( currentThreadId ) ) ;
106
+ } catch ( Exception ex ) {
107
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] StepOut request failed" , ex ) ;
108
+ }
95
109
}
96
110
97
111
List < ProcessInfo > processInfo = new List < ProcessInfo > ( ) ;
@@ -107,14 +121,22 @@ protected override Backtrace OnGetThreadBacktrace (long processId, long threadId
107
121
108
122
protected override ThreadInfo [ ] OnGetThreads ( long processId )
109
123
{
110
- var threadsResponse = protocolClient . SendRequestSync ( new ThreadsRequest ( ) ) ;
111
- var threads = new ThreadInfo [ threadsResponse . Threads . Count ] ;
124
+ ThreadsResponse response ;
125
+
126
+ try {
127
+ response = protocolClient . SendRequestSync ( new ThreadsRequest ( ) ) ;
128
+ } catch ( Exception ex ) {
129
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] Error getting threads" , ex ) ;
130
+ return new ThreadInfo [ 0 ] ;
131
+ }
132
+
133
+ var threads = new ThreadInfo [ response . Threads . Count ] ;
112
134
for ( int i = 0 ; i < threads . Length ; i ++ ) {
113
- threads [ i ] = new ThreadInfo ( processId ,
114
- threadsResponse . Threads [ i ] . Id ,
115
- threadsResponse . Threads [ i ] . Name ,
116
- null ) ;
135
+ var thread = response . Threads [ i ] ;
136
+
137
+ threads [ i ] = new ThreadInfo ( processId , thread . Id , thread . Name , null ) ;
117
138
}
139
+
118
140
return threads ;
119
141
}
120
142
@@ -126,9 +148,16 @@ protected override void OnSetNextStatement (long threadId, string fileName, int
126
148
{
127
149
var source = new Source { Name = Path . GetFileName ( fileName ) , Path = fileName } ;
128
150
var request = new GotoTargetsRequest ( source , line ) { Column = column } ;
129
- var response = protocolClient . SendRequestSync ( request ) ;
151
+ GotoTargetsResponse response ;
130
152
GotoTarget target = null ;
131
153
154
+ try {
155
+ response = protocolClient . SendRequestSync ( request ) ;
156
+ } catch ( Exception ex ) {
157
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] Requesting target locations failed" , ex ) ;
158
+ throw new NotSupportedException ( ex . Message ) ;
159
+ }
160
+
132
161
foreach ( var location in response . Targets ) {
133
162
if ( location . Line <= line && location . EndLine >= line && location . Column <= column && location . EndColumn >= column ) {
134
163
// exact match for location
@@ -143,9 +172,15 @@ protected override void OnSetNextStatement (long threadId, string fileName, int
143
172
}
144
173
145
174
if ( target == null )
146
- throw new NotImplementedException ( ) ;
175
+ throw new NotSupportedException ( ) ;
176
+
177
+ try {
178
+ protocolClient . SendRequestSync ( new GotoRequest ( ( int ) threadId , target . Id ) ) ;
179
+ } catch ( Exception ex ) {
180
+ DebuggerLoggingService . LogMessage ( "[VSCodeDebugger] Setting next statement failed" , ex ) ;
181
+ throw new NotSupportedException ( ex . Message ) ;
182
+ }
147
183
148
- protocolClient . SendRequestSync ( new GotoRequest ( ( int ) threadId , target . Id ) ) ;
149
184
RaiseStopEvent ( ) ;
150
185
}
151
186
@@ -194,12 +229,20 @@ void UpdateExceptions ()
194
229
195
230
protected override void OnNextInstruction ( )
196
231
{
197
- protocolClient . SendRequestSync ( new NextRequest ( currentThreadId ) ) ;
232
+ try {
233
+ protocolClient . SendRequestSync ( new NextRequest ( currentThreadId ) ) ;
234
+ } catch ( Exception ex ) {
235
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] NextInstruction request failed" , ex ) ;
236
+ }
198
237
}
199
238
200
239
protected override void OnNextLine ( )
201
240
{
202
- protocolClient . SendRequestSync ( new NextRequest ( currentThreadId ) ) ;
241
+ try {
242
+ protocolClient . SendRequestSync ( new NextRequest ( currentThreadId ) ) ;
243
+ } catch ( Exception ex ) {
244
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] StepOver request failed" , ex ) ;
245
+ }
203
246
}
204
247
205
248
protected override void OnRemoveBreakEvent ( BreakEventInfo eventInfo )
@@ -216,7 +259,8 @@ void DebugAgentProcess_Exited (object sender, EventArgs e)
216
259
HasExited = true ;
217
260
protocolClient . RequestReceived -= OnDebugAdaptorRequestReceived ;
218
261
protocolClient . Stop ( ) ;
219
- } catch {
262
+ } catch ( Exception ex ) {
263
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] Stop request failed" , ex ) ;
220
264
}
221
265
protocolClient = null ;
222
266
}
@@ -575,12 +619,20 @@ protected override void OnSetActiveThread (long processId, long threadId)
575
619
576
620
protected override void OnStepInstruction ( )
577
621
{
578
- protocolClient . SendRequestSync ( new StepInRequest ( currentThreadId ) ) ;
622
+ try {
623
+ protocolClient . SendRequestSync ( new StepInRequest ( currentThreadId ) ) ;
624
+ } catch ( Exception ex ) {
625
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] StepInstruction request failed" , ex ) ;
626
+ }
579
627
}
580
628
581
629
protected override void OnStepLine ( )
582
630
{
583
- protocolClient . SendRequestSync ( new StepInRequest ( currentThreadId ) ) ;
631
+ try {
632
+ protocolClient . SendRequestSync ( new StepInRequest ( currentThreadId ) ) ;
633
+ } catch ( Exception ex ) {
634
+ DebuggerLoggingService . LogError ( "[VSCodeDebugger] StepIn request failed" , ex ) ;
635
+ }
584
636
}
585
637
586
638
protected override void OnStop ( )
0 commit comments