This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
/
Interpreter.cs
1131 lines (914 loc) · 25.6 KB
/
Interpreter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Text;
using System.IO;
using System.Threading;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using Mono.Debugger;
using Mono.Debugger.Languages;
using Mono.GetOptions;
namespace Mono.Debugger.Frontend
{
public class Interpreter : DebuggerMarshalByRefObject, IDisposable
{
DebuggerConfiguration config;
DebuggerSession session;
DebuggerEngine engine;
SourceFileFactory source_factory;
Debugger debugger;
Process main_process;
Process current_process;
Hashtable styles;
StyleBase current_style;
bool is_interactive;
bool is_script;
int exit_code = 0;
int interrupt_level;
ExpressionParser parser;
ManualResetEvent interrupt_event;
ManualResetEvent process_event;
Thread current_thread;
internal static readonly string DirectorySeparatorStr;
static Interpreter ()
{
// FIXME: Why isn't this public in System.IO.Path ?
DirectorySeparatorStr = Path.DirectorySeparatorChar.ToString ();
}
public Interpreter (bool is_interactive, DebuggerConfiguration config,
DebuggerOptions options)
{
this.config = config;
this.is_interactive = is_interactive;
this.is_script = options.IsScript;
this.parser = new ExpressionParser (this);
this.session = new DebuggerSession (config, options, "main", parser);
this.engine = new DebuggerEngine (this);
source_factory = new SourceFileFactory ();
interrupt_event = new ManualResetEvent (false);
process_event = new ManualResetEvent (false);
styles = new Hashtable ();
styles.Add ("cli", new StyleCLI (this));
styles.Add ("emacs", new StyleEmacs (this));
current_style = (StyleBase) styles ["cli"];
}
AppDomain debugger_domain;
public void Exit ()
{
try {
Dispose ();
} catch (Exception ex) {
Console.WriteLine (ex);
} finally {
Environment.Exit (exit_code);
}
}
public StyleBase Style {
get { return current_style; }
set {
current_style = value;
current_style.Reset ();
}
}
public DebuggerConfiguration DebuggerConfiguration {
get { return config; }
}
public DebuggerEngine DebuggerEngine {
get { return engine; }
}
public SourceFileFactory SourceFileFactory {
get { return source_factory; }
}
public Process CurrentProcess {
get {
if (current_process == null)
throw new TargetException (TargetError.NoTarget);
return current_process;
}
set { current_process = value; }
}
public bool HasCurrentProcess {
get { return current_process != null; }
}
public DebuggerSession Session {
get {
if (session == null)
throw new TargetException (TargetError.NoTarget);
return session;
}
}
public StyleBase GetStyle (string name)
{
StyleBase style = (StyleBase) styles [name];
if (style == null)
throw new ScriptingException (
"No such user interface: `{0}'", name);
return style;
}
public string[] GetStyleNames ()
{
string[] names = new string[styles.Keys.Count];
styles.Keys.CopyTo (names, 0);
return names;
}
public ExpressionParser ExpressionParser {
get { return parser; }
}
public bool IsInteractive {
get { return is_interactive; }
set { is_interactive = value; }
}
public bool IsScript {
get { return is_script; }
set { is_script = value; }
}
public DebuggerOptions Options {
get { return session.Options; }
}
public int ExitCode {
get { return exit_code; }
set { exit_code = value; }
}
public void Abort ()
{
Print ("Caught fatal error while running non-interactively; exiting!");
Environment.Exit (-1);
}
public void Error (string message)
{
Report.Error ("ERROR: {0}", message);
}
public void Error (string format, params object[] args)
{
Error (String.Format (format, args));
}
public void Error (ScriptingException ex)
{
Error (ex.Message);
}
public void Error (TargetException ex)
{
Error (ex.Message);
}
public virtual void Print (string message)
{
Report.Print ("{0}\n", message);
}
public void Print (string format, params object[] args)
{
Print (String.Format (format, args));
}
public void Print (object obj)
{
Print (obj.ToString ());
}
public bool Query (string prompt) {
Report.Print (prompt);
Report.Print (" (y or n) ");
string result = Report.ReadLine ();
return (result == "y") || (result == "yes");
}
public void PrintInstruction (AssemblerLine line)
{
if (line.Label != null)
Print ("{0}:", line.Label);
Print ("{0:11x}\t{1}", line.Address, line.Text);
}
public TargetFunctionType QueryMethod (TargetFunctionType[] methods)
{
Report.Print ("More than one method matches your query:\n");
ArrayList list = new ArrayList ();
foreach (TargetFunctionType method in methods) {
list.Add (method);
Report.Print ("{0,4} {1}\n", list.Count, method.Name);
}
Report.Print ("Select a method or 0 to abort: ");
string result = Report.ReadLine ();
uint index;
try {
index = UInt32.Parse (result);
} catch {
Report.Print ("Invalid number.");
return null;
}
if (index == 0)
return null;
if (index > list.Count) {
Report.Print ("No such method.");
return null;
}
return (TargetFunctionType) list [(int) index];
}
public bool HasTarget {
get {
return debugger != null;
}
}
protected void CheckLastEvent (Thread thread)
{
if (thread == null)
return;
TargetEventArgs args = thread.GetLastTargetEvent ();
if (args == null)
return;
if ((args.Type == TargetEventType.TargetStopped) && ((int) args.Data == 0))
Style.TargetEvent (thread, args);
}
public Process Start ()
{
if ((debugger != null) || (main_process != null))
throw new TargetException (TargetError.AlreadyHaveTarget);
if (!IsScript)
Print ("Starting program: {0} {1}", Options.File,
String.Join (" ", Options.InferiorArgs));
try {
debugger = new Debugger (config);
new InterpreterEventSink (this, debugger);
new ThreadEventSink (this, debugger);
current_process = main_process = debugger.Run (session);
current_thread = current_process.MainThread;
current_thread = WaitAll (current_thread);
return current_process;
} catch (TargetException) {
debugger.Dispose ();
debugger = null;
throw;
}
}
public Process Attach (int pid)
{
if ((debugger != null) || (main_process != null))
throw new TargetException (TargetError.AlreadyHaveTarget);
if (!IsScript)
Print ("Attaching to {0}", pid);
try {
debugger = new Debugger (config);
new InterpreterEventSink (this, debugger);
new ThreadEventSink (this, debugger);
current_process = main_process = debugger.Attach (session, pid);
current_thread = current_process.MainThread;
current_thread = WaitAll (current_thread);
return current_process;
} catch (TargetException) {
debugger.Dispose ();
debugger = null;
throw;
}
}
public Process OpenCoreFile (string core_file)
{
if ((debugger != null) || (main_process != null))
throw new TargetException (TargetError.AlreadyHaveTarget);
Console.WriteLine ("Loading core file {0}", core_file);
try {
debugger = new Debugger (config);
new InterpreterEventSink (this, debugger);
new ThreadEventSink (this, debugger);
Thread[] threads;
current_process = main_process = debugger.OpenCoreFile (
session, core_file, out threads);
current_thread = current_process.MainThread;
return current_process;
} catch (TargetException) {
debugger.Dispose ();
debugger = null;
throw;
}
}
public void SaveSession (Stream stream)
{
session.SaveSession (stream);
}
public Process LoadSession (Stream stream)
{
if ((debugger != null) || (main_process != null))
throw new TargetException (TargetError.AlreadyHaveTarget);
try {
debugger = new Debugger (config);
session = new DebuggerSession (config, stream, parser);
new InterpreterEventSink (this, debugger);
new ThreadEventSink (this, debugger);
current_process = main_process = debugger.Run (session);
current_thread = current_process.MainThread;
current_thread = WaitAll (current_thread);
return current_process;
} catch (TargetException ex) {
Console.WriteLine ("FUCK: {0}", ex);
debugger.Dispose ();
debugger = null;
throw;
} catch (Exception ex) {
Console.WriteLine ("FUCK: {0}", ex);
debugger.Dispose ();
debugger = null;
throw;
}
}
public bool Wait (CommandResult result)
{
if (result == null)
return true;
ClearInterrupt ();
WaitHandle[] handles = new WaitHandle [2];
handles [0] = interrupt_event;
handles [1] = result.CompletedEvent;
int ret = WaitHandle.WaitAny (handles);
if (ret == 0) {
result.Abort ();
result.CompletedEvent.WaitOne ();
return false;
}
if (result.Result is Exception)
throw (Exception) result.Result;
return true;
}
public bool WaitOne (Thread thread)
{
ClearInterrupt ();
WaitHandle[] handles = new WaitHandle [2];
handles [0] = interrupt_event;
handles [1] = thread.WaitHandle;
int ret = WaitHandle.WaitAny (handles);
if (ret == 0) {
thread.Stop ();
thread.WaitHandle.WaitOne ();
return false;
}
CheckLastEvent (thread);
return true;
}
public Thread WaitAll (Thread thread)
{
return WaitAll (thread, thread.GetWaitHandle (), false);
}
public Thread WaitAll (Thread thread, CommandResult result, bool wait)
{
if (result == null)
return null;
ClearInterrupt ();
process_event.Reset ();
Thread stopped;
Hashtable seen_threads = new Hashtable ();
Hashtable wait_list = new Hashtable ();
do {
again:
Process[] processes = HasTarget ? debugger.Processes : new Process [0];
foreach (Process process in processes) {
foreach (Thread t in process.GetThreads ()) {
if ((t == thread) || seen_threads.Contains (t))
continue;
seen_threads.Add (t, null);
if (t.IsRunning)
wait_list.Add (t, false);
else if ((t.ThreadFlags & Thread.Flags.AutoRun) != 0) {
t.Continue ();
wait_list.Add (t, true);
}
}
}
WaitHandle[] handles = new WaitHandle [wait_list.Count + 3];
handles [0] = interrupt_event;
handles [1] = process_event;
handles [2] = result.CompletedEvent;
Thread[] threads = new Thread [wait_list.Count];
wait_list.Keys.CopyTo (threads, 0);
for (int i = 0; i < wait_list.Count; i++)
handles [i + 3] = threads [i].WaitHandle;
int ret = WaitHandle.WaitAny (handles);
if (ret == 0) {
stopped = null;
result.Abort ();
result.CompletedEvent.WaitOne ();
break;
} else if (ret == 1) {
process_event.Reset ();
goto again;
}
if (result.Result is Exception)
throw (Exception) result.Result;
if (ret == 2)
stopped = thread;
else
stopped = threads [ret - 3];
CheckLastEvent (stopped);
wait_list.Remove (stopped);
} while ((stopped != null) && (stopped != thread) && (wait || !stopped.IsAlive));
if (!HasTarget)
return stopped;
foreach (Process process in Processes) {
foreach (Thread t in process.GetThreads ()) {
if (t == stopped)
continue;
// Never touch immutable threads.
if (!t.IsRunning)
continue;
if ((t.ThreadFlags & Thread.Flags.Immutable) != 0)
continue;
// Background thread -> keep running.
if ((t.ThreadFlags & Thread.Flags.Background) != 0)
continue;
// Stop and set AutoRun.
t.AutoStop ();
}
}
return stopped;
}
protected void Wait (Thread thread)
{
if (thread == null)
return;
WaitHandle[] handles = new WaitHandle [2];
handles [0] = interrupt_event;
handles [1] = thread.WaitHandle;
WaitHandle.WaitAny (handles);
}
public RuntimeInvokeResult RuntimeInvoke (Thread thread,
TargetFunctionType function,
TargetStructObject object_argument,
TargetObject[] param_objects,
bool is_virtual, bool debug)
{
RuntimeInvokeResult result = thread.RuntimeInvoke (
function, object_argument, param_objects, is_virtual, debug);
if (DebuggerConfiguration.BrokenThreading) {
Thread ret = WaitAll (thread, result, false);
if (ret != thread) {
result.Abort ();
return null;
}
} else if (debug) {
Wait (thread);
CheckLastEvent (thread);
} else {
Wait (result);
}
return result;
}
public int Interrupt ()
{
interrupt_event.Set ();
return ++interrupt_level;
}
public void ClearInterrupt ()
{
interrupt_level = 0;
interrupt_event.Reset ();
}
public void ShowBreakpoints ()
{
Event[] events = Session.Events;
if (events.Length == 0) {
Print ("No breakpoints or catchpoints.");
return;
}
Print ("Breakpoints:");
Print ("{0,3} {1,6} {2,3} {3,4} {4,12} {5}", "Id", "Type", "En", "Act", "ThreadGroup", "What");
foreach (Event handle in events) {
string type;
if (handle is ExceptionCatchPoint)
type = "catch";
else
type = "break";
Print ("{0,3} {1,6} {2,3} {3,4} {4,12} {5}",
handle.Index, type,
handle.IsEnabled ? "y" : "n",
handle.IsActivated ? "y" : "n",
handle.ThreadGroup != null ? handle.ThreadGroup.Name : "global",
handle.Name);
}
}
public Event GetEvent (int index)
{
Event handle = Session.GetEvent (index);
if (handle == null)
throw new ScriptingException ("No such breakpoint/catchpoint.");
return handle;
}
protected virtual void OnThreadCreated (Thread thread)
{
process_event.Set ();
if (DebuggerConfiguration.NotifyUser_ThreadCreation)
Print ("Process #{0} created new thread @{1}.",
thread.Process.ID, thread.ID);
}
protected virtual void OnThreadExited (Thread thread)
{
if (DebuggerConfiguration.NotifyUser_ThreadCreation)
Print ("Thread @{0} exited.", thread.ID);
if (thread == current_thread)
current_thread = null;
}
protected virtual void OnMainProcessCreated (Process process)
{
new ProcessEventSink (this, process);
}
protected virtual void OnProcessReachedMain (Process process)
{ }
protected virtual void OnProcessCreated (Process process)
{
process_event.Set ();
new ProcessEventSink (this, process);
Print ("Created new process #{0}.", process.ID);
if (current_process == null) {
current_process = process;
current_thread = process.MainThread;
}
}
protected virtual void OnProcessExited (Process process)
{
Print ("Process #{0} exited.", process.ID);
if (process == main_process) {
current_process = main_process = null;
current_thread = null;
} else if (process == current_process) {
current_process = main_process;
current_thread = main_process.MainThread;
}
}
protected virtual void OnProcessExecd (Process process)
{
Print ("Process #{0} exec()'d: {1}", process.ID,
PrintCommandLineArgs (process));
}
protected virtual void OnTargetEvent (Thread thread, TargetEventArgs args)
{
if (args.Type == TargetEventType.TargetInterrupted) {
;
} else if ((args.Type != TargetEventType.TargetStopped) || ((int) args.Data != 0))
Style.TargetEvent (thread, args);
else if ((thread.ThreadFlags & Thread.Flags.Background) != 0)
Style.TargetEvent (thread, args);
}
protected virtual void OnTargetOutput (bool is_stderr, string line)
{
if (!IsScript) {
if (is_stderr)
Report.Print ("{0}", line);
else
Report.Print ("{0}", line);
}
}
protected virtual void OnTargetExited ()
{
debugger = null;
main_process = current_process = null;
current_thread = null;
Print ("Target exited.");
}
public Thread CurrentThread {
get {
if (current_thread == null)
throw new TargetException (TargetError.NoTarget);
return current_thread;
}
set {
current_thread = value;
current_process = value.Process;
}
}
public bool HasCurrentThread {
get { return current_thread != null; }
}
public Process GetProcess (int number)
{
if (number == -1)
return CurrentProcess;
foreach (Process process in Processes) {
if (process.ID == number)
return process;
}
throw new ScriptingException ("No such process: {0}", number);
}
public Thread GetThread (int number)
{
if (number == -1)
return CurrentThread;
foreach (Process process in Processes) {
foreach (Thread thread in process.GetThreads ())
if (thread.ID == number)
return thread;
}
throw new ScriptingException ("No such thread: {0}", number);
}
public Thread[] GetThreads (int[] indices)
{
Thread[] retval = new Thread [indices.Length];
for (int i = 0; i < indices.Length; i++)
retval [i] = GetThread (indices [i]);
return retval;
}
public void ShowThreadGroups ()
{
foreach (ThreadGroup group in Session.ThreadGroups) {
if (group.Name.StartsWith ("@"))
continue;
StringBuilder ids = new StringBuilder ();
foreach (int thread in group.Threads) {
ids.Append (" @");
ids.Append (thread);
}
Print ("{0}:{1}", group.Name, ids.ToString ());
}
}
public void CreateThreadGroup (string name)
{
if (Session.ThreadGroupExists (name))
throw new ScriptingException ("A thread group with that name already exists.");
Session.CreateThreadGroup (name);
}
public void DeleteThreadGroup (string name)
{
if (!Session.ThreadGroupExists (name))
throw new ScriptingException ("No such thread group.");
Session.DeleteThreadGroup (name);
}
public ThreadGroup GetThreadGroup (string name, bool writable)
{
if (name == null)
name = "main";
else if (name == "global")
return ThreadGroup.Global;
if (name.StartsWith ("@"))
throw new ScriptingException ("No such thread group.");
if (!Session.ThreadGroupExists (name))
throw new ScriptingException ("No such thread group.");
ThreadGroup group = Session.CreateThreadGroup (name);
if (writable && group.IsSystem)
throw new ScriptingException ("Cannot modify system-created thread group.");
return group;
}
public void AddToThreadGroup (string name, Thread[] threads)
{
ThreadGroup group = GetThreadGroup (name, true);
foreach (Thread thread in threads)
group.AddThread (thread.ID);
}
public void RemoveFromThreadGroup (string name, Thread[] threads)
{
ThreadGroup group = GetThreadGroup (name, true);
foreach (Thread thread in threads)
group.RemoveThread (thread.ID);
}
public int InsertExceptionCatchPoint (Thread target, ThreadGroup group,
TargetType exception)
{
Event handle = target.Process.Session.InsertExceptionCatchPoint (
target, group, exception);
return handle.Index;
}
public int InsertHardwareWatchPoint (Thread target, TargetAddress address)
{
Event handle = target.Process.Session.InsertHardwareWatchPoint (
target, address, HardwareWatchType.WatchWrite);
return handle.Index;
}
public void Kill ()
{
if (debugger != null) {
debugger.Kill ();
debugger = null;
}
}
public void Kill (Process process)
{
if (process == main_process)
Kill ();
else
process.Kill ();
}
public void Detach ()
{
debugger.Detach ();
}
public void Detach (Process process)
{
if (process == main_process)
Detach ();
else
process.Detach ();
}
public Module[] GetModules (int[] indices)
{
List<Module> retval = new List<Module> ();
Module[] modules = CurrentProcess.Modules;
foreach (int index in indices) {
bool found = false;
for (int i = 0; i < modules.Length; i++) {
if (modules [i].ID == index) {
retval.Add (modules [i]);
found = true;
break;
}
}
if (!found)
throw new ScriptingException ("No such module {0}.", index);
}
return retval.ToArray ();
}
public SourceFile[] GetSources (int[] indices)
{
Hashtable source_hash = new Hashtable ();
Module[] modules = CurrentProcess.Modules;
foreach (Module module in modules) {
if (!module.SymbolsLoaded)
continue;
foreach (SourceFile source in module.Sources)
source_hash.Add (source.ID, source);
}
int pos = 0;
SourceFile[] retval = new SourceFile [indices.Length];
foreach (int index in indices) {
SourceFile source = (SourceFile) source_hash [index];
if (source == null)
throw new ScriptingException (
"No such source file: {0}", index);
retval [pos++] = source;
}
return retval;
}
public SourceBuffer ReadFile (string filename)
{
return source_factory.FindFile (filename);
}
public void ModuleOperations (Module[] modules, ModuleOperation[] operations)
{
foreach (Module module in modules) {
foreach (ModuleOperation operation in operations) {
switch (operation) {
case ModuleOperation.Ignore:
module.LoadSymbols = false;
break;
case ModuleOperation.UnIgnore:
module.LoadSymbols = true;
break;
case ModuleOperation.Step:
module.StepInto = true;
break;
case ModuleOperation.DontStep:
module.StepInto = false;
break;
default:
throw new InternalError ();
}
}
}
}
public Process[] Processes {
get {
if (debugger == null)
throw new TargetException (TargetError.NoTarget);
return debugger.Processes;
}
}
public string PrintCommandLineArgs (Process process)
{
StringBuilder sb = new StringBuilder ();
string[] args = process.CommandLineArguments;
int start = 0;
if ((args.Length > 1) && (args [0] == BuildInfo.mono)) {
if (args [1] == "--inside-mdb")
start = 2;
else
start = 1;
}
for (int i = start; i < args.Length; i++) {
if (i > start)
sb.Append (" ");
sb.Append (args [i]);
}
return sb.ToString ();
}
public string PrintProcess (Process process)
{
string command_line = PrintCommandLineArgs (process);
if (command_line.Length > 70) {
command_line = command_line.Substring (0, 70);
command_line += " ...";
}
return String.Format ("#{0} ({1}:{2})", process.ID,
process.MainThread.PID, command_line);
}
public void ShowDisplays (StackFrame frame)
{
ScriptingContext context = new ScriptingContext (this);
context.CurrentFrame = frame;
foreach (Display d in Session.Displays)
context.ShowDisplay (d);
}
//
// IDisposable
//
private bool disposed = false;