193
195
public static void ShowValueVisualizer (ObjectValue val)
195
ValueVisualizerDialog dlg = new ValueVisualizerDialog ();
197
var dlg = new ValueVisualizerDialog ();
199
MessageService.ShowCustomDialog (dlg);
204
202
public static bool ShowBreakpointProperties (Breakpoint bp, bool editNew)
284
282
ExceptionInfo val = CurrentFrame.GetException ();
285
283
if (val != null) {
286
284
ExceptionCaughtDialog dlg = new ExceptionCaughtDialog (val);
285
dlg.TransientFor = IdeApp.Workbench.RootWindow;
286
MessageService.PlaceDialog (dlg, IdeApp.Workbench.RootWindow);
305
305
session.TypeResolverHandler = ResolveType;
306
306
session.BreakpointTraceHandler = BreakpointTraceHandler;
307
307
session.GetExpressionEvaluator = OnGetExpressionEvaluator;
308
session.ConnectionDialogCreator = delegate {
309
return new GtkConnectionDialog ();
309
312
console.CancelRequested += OnCancelRequested;
311
if (DebugSessionStarted != null)
312
DebugSessionStarted (null, EventArgs.Empty);
314
DispatchService.GuiDispatch (delegate {
315
if (DebugSessionStarted != null)
316
DebugSessionStarted (null, EventArgs.Empty);
317
NotifyLocationChanged ();
314
NotifyLocationChanged ();
317
322
static void Cleanup ()
324
if (oldLayout != null) {
325
string layout = oldLayout;
327
// Dispatch asynchronously to avoid start/stop races
328
DispatchService.GuiSyncDispatch (delegate {
329
if (IdeApp.Workbench.CurrentLayout == "Debug")
330
IdeApp.Workbench.CurrentLayout = layout;
319
334
currentBacktrace = null;
321
336
if (!IsDebugging)
339
354
// Dispose the session at the end, since it may take a while.
340
355
DebuggerSession oldSession = session;
343
if (StoppedEvent != null)
344
StoppedEvent (null, new EventArgs ());
358
DispatchService.GuiDispatch (delegate {
359
if (StoppedEvent != null)
360
StoppedEvent (null, new EventArgs ());
346
363
if (console != null) {
347
364
console.Dispose ();
454
477
throw new InvalidOperationException ("Unsupported command: " + cmd);
481
throw new InvalidOperationException ("A debugger session is already started");
457
483
DebuggerStartInfo startInfo = factory.CreateDebuggerStartInfo (cmd);
458
484
startInfo.UseExternalConsole = c is ExternalConsole;
459
485
startInfo.CloseExternalConsoleOnExit = c.CloseOnDispose;
460
486
currentEngine = factory;
461
487
session = factory.CreateSession ();
462
488
session.ExceptionHandler = ExceptionHandler;
463
session.Initialize ();
490
// When using an external console, create a new internal console which will be used
491
// to show the debugger log
492
if (startInfo.UseExternalConsole)
493
console = (IConsole) IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor ();
499
// Dispatch synchronously to avoid start/stop races
500
DispatchService.GuiSyncDispatch (delegate {
501
oldLayout = IdeApp.Workbench.CurrentLayout;
502
IdeApp.Workbench.CurrentLayout = "Debug";
469
506
session.Run (startInfo, GetUserOptions ());
476
513
static bool ExceptionHandler (Exception ex)
515
LoggingService.LogError ("Error in debugger", ex);
478
516
Gtk.Application.Invoke (delegate {
479
517
if (ex is DebuggerException)
480
518
MessageService.ShowError (ex.Message);
548
586
Console.WriteLine ("OnTargetEvent, type - {0}", args.Type);
549
if (args.Type != TargetEventType.TargetExited) {
550
SetCurrentBacktrace (args.Backtrace);
553
588
switch (args.Type) {
554
589
case TargetEventType.TargetExited:
557
592
case TargetEventType.TargetSignaled:
558
593
case TargetEventType.TargetStopped:
559
case TargetEventType.TargetRunning:
560
594
case TargetEventType.TargetHitBreakpoint:
561
595
case TargetEventType.TargetInterrupted:
562
596
case TargetEventType.UnhandledException:
563
597
case TargetEventType.ExceptionThrown:
598
SetCurrentBacktrace (args.Backtrace);
565
600
NotifyException (args);
734
769
if (currentBacktrace != null) {
735
770
var sf = GetCurrentVisibleFrame ();
736
if (!string.IsNullOrEmpty (sf.SourceLocation.Filename) && System.IO.File.Exists (sf.SourceLocation.Filename) && sf.SourceLocation.Line != -1) {
737
Document document = IdeApp.Workbench.OpenDocument (sf.SourceLocation.Filename, sf.SourceLocation.Line, 1, true, false);
771
if (!string.IsNullOrEmpty (sf.SourceLocation.FileName) && System.IO.File.Exists (sf.SourceLocation.FileName) && sf.SourceLocation.Line != -1) {
772
Document document = IdeApp.Workbench.OpenDocument (sf.SourceLocation.FileName, sf.SourceLocation.Line, 1, OpenDocumentOptions.BringToFront);
738
773
OnDisableConditionalCompilation (new DocumentEventArgs (document));
838
873
static string ResolveType (string identifier, SourceLocation location)
840
Document doc = IdeApp.Workbench.GetDocument (location.Filename);
875
Document doc = IdeApp.Workbench.GetDocument (location.FileName);
841
876
if (doc != null) {
842
877
ITextEditorResolver textEditorResolver = doc.GetContent <ITextEditorResolver> ();
843
878
if (textEditorResolver != null) {
844
ResolveResult rr = textEditorResolver.GetLanguageItem (doc.TextEditor.GetPositionFromLineColumn (location.Line, 1), identifier);
879
ResolveResult rr = textEditorResolver.GetLanguageItem (doc.Editor.Document.LocationToOffset (location.Line, 1), identifier);
845
880
NamespaceResolveResult ns = rr as NamespaceResolveResult;
847
882
return ns.Namespace;
907
942
return h.Execute (command, console);
946
internal class GtkConnectionDialog : IConnectionDialog
952
public event EventHandler UserCancelled;
954
string DefaultListenMessage {
955
get { return GettextCatalog.GetString ("Waiting for debugger to connect..."); }
958
public void SetMessage (DebuggerStartInfo dsi, string message, bool listening, int attemptNumber)
963
if (string.IsNullOrEmpty (message))
964
message = DefaultListenMessage;
966
if (dialog == null) {
967
Gtk.Application.Invoke (delegate {
973
Gtk.Application.Invoke (delegate {
977
label.Text = message;
982
void RunDialog (string message)
987
dialog = new Gtk.Dialog () {
988
Title = "Waiting for debugger"
991
var label = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f) {
992
Child = new Gtk.Label (message),
995
dialog.VBox.PackStart (label);
998
dialog.AddButton ("Cancel", Gtk.ResponseType.Cancel);
1000
int response = MonoDevelop.Ide.MessageService.ShowCustomDialog (dialog);
1004
if (!disposed && response != (int) Gtk.ResponseType.Ok && UserCancelled != null) {
1005
UserCancelled (null, null);
1009
public void Dispose ()
1015
if (dialog != null) {
1016
Gtk.Application.Invoke (delegate {
1018
dialog.Respond (Gtk.ResponseType.Ok);