@@ -65,6 +65,7 @@ internal class UnityDebugSession : DebugSession
65
65
66
66
public UnityDebugSession ( )
67
67
{
68
+ Log . Write ( "Constructing UnityDebugSession" ) ;
68
69
m_ResumeEvent = new AutoResetEvent ( false ) ;
69
70
m_Breakpoints = new SourceBreakpoint [ 0 ] ;
70
71
m_VariableHandles = new Handles < ObjectValue [ ] > ( ) ;
@@ -176,6 +177,8 @@ public UnityDebugSession()
176
177
m_Session . OutputWriter = ( isStdErr , text ) => {
177
178
SendOutput ( isStdErr ? "stderr" : "stdout" , text ) ;
178
179
} ;
180
+
181
+ Log . Write ( "Done constructing UnityDebugSession" ) ;
179
182
}
180
183
181
184
public StackFrame Frame { get ; set ; }
@@ -224,15 +227,18 @@ public override void Launch(Response response, dynamic args)
224
227
225
228
public override void Attach ( Response response , dynamic args )
226
229
{
230
+ Log . Write ( $ "UnityDebug: Attach: { response } ; { args } ") ;
227
231
string name = GetString ( args , "name" ) ;
228
232
229
233
SetExceptionBreakpoints ( args . __exceptionOptions ) ;
230
234
235
+ Log . Write ( $ "UnityDebug: Searching for Unity process '{ name } '") ;
231
236
SendOutput ( "stdout" , "UnityDebug: Searching for Unity process '" + name + "'" ) ;
232
237
233
238
var processes = UnityAttach . GetAttachableProcesses ( name ) . ToArray ( ) ;
234
239
235
240
if ( processes . Length == 0 ) {
241
+ Log . Write ( $ "Could not find target name '{ name } '.") ;
236
242
SendErrorResponse ( response , 8001 , "Could not find target name '{_name}'. Is it running?" , new { _name = name } ) ;
237
243
return ;
238
244
}
@@ -266,24 +272,31 @@ public override void Attach(Response response, dynamic args)
266
272
267
273
Connect ( attachInfo . Address , attachInfo . Port ) ;
268
274
275
+ Log . Write ( $ "UnityDebug: Attached to Unity process '{ process . Name } ' ({ process . Id } )") ;
269
276
SendOutput ( "stdout" , "UnityDebug: Attached to Unity process '" + process . Name + "' (" + process . Id + ")\n " ) ;
270
277
SendResponse ( response ) ;
271
278
}
272
279
273
280
void TooManyInstances ( Response response , string name , UnityProcessInfo [ ] processes )
274
281
{
282
+ Log . Write ( $ "Multiple targets with name '{ name } ' running. Unable to connect.") ;
275
283
SendErrorResponse ( response , 8002 , "Multiple targets with name '{_name}' running. Unable to connect.\n " +
276
284
"Use \" Unity Attach Debugger\" from the command palette (View > Command Palette...) to specify which process to attach to." , new { _name = name } ) ;
277
285
286
+ Log . Write ( $ "UnityDebug: Multiple targets with name '{ name } ' running. Unable to connect.)") ;
278
287
SendOutput ( "stdout" , "UnityDebug: Multiple targets with name '" + name + "' running. Unable to connect.\n " +
279
288
"Use \" Unity Attach Debugger\" from the command palette (View > Command Palette...) to specify which process to attach to." ) ;
280
289
281
290
foreach ( var p in processes )
291
+ {
292
+ Log . Write ( $ "UnityDebug: Found Unity process '{ p . Name } ' ({ p . Id } )") ;
282
293
SendOutput ( "stdout" , "UnityDebug: Found Unity process '" + p . Name + "' (" + p . Id + ")\n " ) ;
294
+ }
283
295
}
284
296
285
297
void Connect ( IPAddress address , int port )
286
298
{
299
+ Log . Write ( $ "UnityDebug: Connect to: { address } :{ port } ") ;
287
300
lock ( m_Lock ) {
288
301
289
302
var args0 = new SoftDebuggerConnectArgs ( string . Empty , address , port ) {
@@ -300,6 +313,7 @@ void Connect(IPAddress address, int port)
300
313
//---- private ------------------------------------------
301
314
void SetExceptionBreakpoints ( dynamic exceptionOptions )
302
315
{
316
+ Log . Write ( $ "UnityDebug: SetExceptionBreakpoints: { exceptionOptions } ") ;
303
317
if ( exceptionOptions == null )
304
318
{
305
319
return ;
@@ -338,6 +352,8 @@ void SetExceptionBreakpoints(dynamic exceptionOptions)
338
352
339
353
public override void Disconnect ( Response response , dynamic args )
340
354
{
355
+ Log . Write ( $ "UnityDebug: Disconnect: { args } ") ;
356
+ Log . Write ( $ "UnityDebug: Disconnect: { response } ") ;
341
357
if ( unityDebugConnector != null ) {
342
358
unityDebugConnector . OnDisconnect ( ) ;
343
359
unityDebugConnector = null ;
@@ -361,12 +377,14 @@ public override void Disconnect(Response response, dynamic args)
361
377
362
378
public override void SetFunctionBreakpoints ( Response response , dynamic arguments )
363
379
{
380
+ Log . Write ( $ "UnityDebug: SetFunctionBreakpoints: { response } ; { arguments } ") ;
364
381
var breakpoints = new List < ResponseBreakpoint > ( ) ;
365
382
SendResponse ( response , new SetFunctionBreakpointsResponse ( breakpoints ) ) ;
366
383
}
367
384
368
- public override void Continue ( Response response , dynamic args )
385
+ public override void Continue ( Response response , dynamic arguments )
369
386
{
387
+ Log . Write ( $ "UnityDebug: Continue: { response } ; { arguments } ") ;
370
388
WaitForSuspend ( ) ;
371
389
SendResponse ( response , new ContinueResponseBody ( ) ) ;
372
390
lock ( m_Lock ) {
@@ -377,16 +395,9 @@ public override void Continue(Response response, dynamic args)
377
395
}
378
396
}
379
397
380
- void WaitForSuspend ( )
381
- {
382
- if ( ! m_DebuggeeExecuting ) return ;
383
-
384
- m_ResumeEvent . WaitOne ( ) ;
385
- m_DebuggeeExecuting = false ;
386
- }
387
-
388
- public override void Next ( Response response , dynamic args )
398
+ public override void Next ( Response response , dynamic arguments )
389
399
{
400
+ Log . Write ( $ "UnityDebug: Next: { response } ; { arguments } ") ;
390
401
WaitForSuspend ( ) ;
391
402
SendResponse ( response ) ;
392
403
lock ( m_Lock ) {
@@ -397,8 +408,9 @@ public override void Next(Response response, dynamic args)
397
408
}
398
409
}
399
410
400
- public override void StepIn ( Response response , dynamic args )
411
+ public override void StepIn ( Response response , dynamic arguments )
401
412
{
413
+ Log . Write ( $ "UnityDebug: StepIn: { response } ; { arguments } ") ;
402
414
WaitForSuspend ( ) ;
403
415
SendResponse ( response ) ;
404
416
lock ( m_Lock ) {
@@ -409,8 +421,9 @@ public override void StepIn(Response response, dynamic args)
409
421
}
410
422
}
411
423
412
- public override void StepOut ( Response response , dynamic args )
424
+ public override void StepOut ( Response response , dynamic arguments )
413
425
{
426
+ Log . Write ( $ "UnityDebug: StepIn: { response } ; { arguments } ") ;
414
427
WaitForSuspend ( ) ;
415
428
SendResponse ( response ) ;
416
429
lock ( m_Lock ) {
@@ -421,8 +434,9 @@ public override void StepOut(Response response, dynamic args)
421
434
}
422
435
}
423
436
424
- public override void Pause ( Response response , dynamic args )
437
+ public override void Pause ( Response response , dynamic arguments )
425
438
{
439
+ Log . Write ( $ "UnityDebug: StepIn: { response } ; { arguments } ") ;
426
440
SendResponse ( response ) ;
427
441
PauseDebugger ( ) ;
428
442
}
@@ -435,15 +449,15 @@ void PauseDebugger()
435
449
}
436
450
}
437
451
438
- protected override void SetVariable ( Response response , object args )
452
+ protected override void SetVariable ( Response response , object arguments )
439
453
{
440
- var reference = GetInt ( args , "variablesReference" , - 1 ) ;
454
+ var reference = GetInt ( arguments , "variablesReference" , - 1 ) ;
441
455
if ( reference == - 1 ) {
442
456
SendErrorResponse ( response , 3009 , "variables: property 'variablesReference' is missing" , null , false , true ) ;
443
457
return ;
444
458
}
445
459
446
- var value = GetString ( args , "value" ) ;
460
+ var value = GetString ( arguments , "value" ) ;
447
461
if ( m_VariableHandles . TryGet ( reference , out var children ) ) {
448
462
if ( children != null && children . Length > 0 ) {
449
463
if ( children . Length > MAX_CHILDREN ) {
@@ -455,7 +469,7 @@ protected override void SetVariable(Response response, object args)
455
469
continue ;
456
470
v . WaitHandle . WaitOne ( ) ;
457
471
var variable = CreateVariable ( v ) ;
458
- if ( variable . name == GetString ( args , "name" ) )
472
+ if ( variable . name == GetString ( arguments , "name" ) )
459
473
{
460
474
v . Value = value ;
461
475
SendResponse ( response , new SetVariablesResponseBody ( value , variable . type , variable . variablesReference ) ) ;
@@ -465,17 +479,19 @@ protected override void SetVariable(Response response, object args)
465
479
}
466
480
}
467
481
468
- public override void SetExceptionBreakpoints ( Response response , dynamic args )
482
+ public override void SetExceptionBreakpoints ( Response response , dynamic arguments )
469
483
{
470
- SetExceptionBreakpoints ( args . exceptionOptions ) ;
484
+ Log . Write ( $ "UnityDebug: StepIn: { response } ; { arguments } ") ;
485
+ SetExceptionBreakpoints ( arguments . exceptionOptions ) ;
471
486
SendResponse ( response ) ;
472
487
}
473
488
474
- public override void SetBreakpoints ( Response response , dynamic args )
489
+ public override void SetBreakpoints ( Response response , dynamic arguments )
475
490
{
491
+ Log . Write ( $ "UnityDebug: SetBreakpoints: { response } ; { arguments } ") ;
476
492
string path = null ;
477
- if ( args . source != null ) {
478
- var p = ( string ) args . source . path ;
493
+ if ( arguments . source != null ) {
494
+ var p = ( string ) arguments . source . path ;
479
495
if ( p != null && p . Trim ( ) . Length > 0 ) {
480
496
path = p ;
481
497
}
@@ -491,7 +507,7 @@ public override void SetBreakpoints(Response response, dynamic args)
491
507
return ;
492
508
}
493
509
494
- SourceBreakpoint [ ] newBreakpoints = getBreakpoints ( args , "breakpoints" ) ;
510
+ SourceBreakpoint [ ] newBreakpoints = getBreakpoints ( arguments , "breakpoints" ) ;
495
511
var lines = newBreakpoints . Select ( bp => bp . line ) ;
496
512
var breakpointsToRemove = m_Breakpoints . Where ( bp => ! lines . Contains ( bp . line ) ) . ToArray ( ) ;
497
513
foreach ( Breakpoint breakpoint in m_Session . Breakpoints . GetBreakpoints ( ) )
@@ -524,10 +540,11 @@ public override void SetBreakpoints(Response response, dynamic args)
524
540
SendResponse ( response , new SetBreakpointsResponseBody ( responseBreakpoints ) ) ;
525
541
}
526
542
527
- public override void StackTrace ( Response response , dynamic args )
543
+ public override void StackTrace ( Response response , dynamic arguments )
528
544
{
529
- int maxLevels = GetInt ( args , "levels" , 10 ) ;
530
- int threadReference = GetInt ( args , "threadId" , 0 ) ;
545
+ Log . Write ( $ "UnityDebug: StackTrace: { response } ; { arguments } ") ;
546
+ int maxLevels = GetInt ( arguments , "levels" , 10 ) ;
547
+ int threadReference = GetInt ( arguments , "threadId" , 0 ) ;
531
548
532
549
WaitForSuspend ( ) ;
533
550
@@ -849,5 +866,13 @@ void DebuggerKill()
849
866
}
850
867
}
851
868
}
869
+
870
+ void WaitForSuspend ( )
871
+ {
872
+ if ( ! m_DebuggeeExecuting ) return ;
873
+
874
+ m_ResumeEvent . WaitOne ( ) ;
875
+ m_DebuggeeExecuting = false ;
876
+ }
852
877
}
853
878
}
0 commit comments