Esempio n. 1
0
        protected override void Update(CommandInfo info)
        {
            var breakpoints = DebuggingService.Breakpoints;

            info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Breakpoints);
            if (IdeApp.Workbench.ActiveDocument != null &&
                IdeApp.Workbench.ActiveDocument.Editor != null &&
                IdeApp.Workbench.ActiveDocument.FileName != FilePath.Null &&
                !breakpoints.IsReadOnly)
            {
                lock (breakpoints)
                    info.Enabled = breakpoints.GetBreakpointsAtFileLine(IdeApp.Workbench.ActiveDocument.FileName, IdeApp.Workbench.ActiveDocument.Editor.CaretLine).Count > 0;
            }
            else
            {
                info.Enabled = false;
            }
        }
Esempio n. 2
0
        void OnFrameChanged(object s, EventArgs a)
        {
            bool disassemblyCurrent = false;

            if (disassemblyDoc != null && DebuggingService.IsFeatureSupported(DebuggerFeatures.Disassembly))
            {
                disassemblyView.Update();
                if (IdeApp.Workbench.ActiveDocument == disassemblyDoc)
                {
                    disassemblyCurrent = true;
                }
            }

            var frame = DebuggingService.CurrentFrame;

            if (frame == null)
            {
                return;
            }

            FilePath file = frame.SourceLocation.Filename;
            int      line = frame.SourceLocation.Line;

            if (!file.IsNullOrEmpty && System.IO.File.Exists(file) && line != -1)
            {
                Document doc = IdeApp.Workbench.OpenDocument(file, line, 1, !disassemblyCurrent, null, false);
                if (doc != null)
                {
                    return;
                }
            }
            if (!DebuggingService.CurrentSessionSupportsFeature(DebuggerFeatures.Disassembly))
            {
                return;
            }
            if (disassemblyDoc == null)
            {
                OnShowDisassembly(null, null);
            }
            else
            {
                disassemblyDoc.Select();
            }
        }
Esempio n. 3
0
		protected override void Update (CommandInfo info)
		{
			info.Visible = true;

			if (!IdeApp.Workspace.IsOpen || !DebuggingService.IsDebuggingSupported || !DebuggingService.IsFeatureSupported (DebuggerFeatures.Breakpoints) || DebuggingService.Breakpoints.IsReadOnly) {
				info.Enabled = false;
				return;
			}

			var doc = IdeApp.Workbench.ActiveDocument;

			if (doc?.GetContent<ITextView> (true) != null && doc.FileName != FilePath.Null) {
				var target = DebugHandler.GetRunTarget ();
				if (target != null && IdeApp.ProjectOperations.CanDebug (target)) {
					info.Enabled = true;
					return;
				}
			}
			info.Enabled = false;
		}
Esempio n. 4
0
		protected override void Update (CommandInfo info)
		{
			var breakpoints = DebuggingService.Breakpoints;

			lock (breakpoints) {
				info.Enabled = !breakpoints.IsReadOnly && breakpoints.Count > 0;
				bool enable = false;
				foreach (BreakEvent bp in breakpoints) {
					if (!bp.Enabled) {
						enable = true;
						break;
					}
				}
				if (enable)
					info.Text = GettextCatalog.GetString ("Enable All Breakpoints");
				else
					info.Text = GettextCatalog.GetString ("Disable All Breakpoints");
			}
			info.Visible = DebuggingService.IsFeatureSupported (DebuggerFeatures.Breakpoints);
		}
Esempio n. 5
0
		protected override void Update (CommandInfo info)
		{
			var breakpoints = DebuggingService.Breakpoints;

			info.Visible = DebuggingService.IsFeatureSupported (DebuggerFeatures.Breakpoints);
			if (IdeApp.Workbench.ActiveDocument != null && 
			    IdeApp.Workbench.ActiveDocument.GetContent<ITextView> (true) != null &&
			    IdeApp.Workbench.ActiveDocument.FileName != FilePath.Null &&
			    !breakpoints.IsReadOnly) {
				lock (breakpoints) {
					var bpInLine = breakpoints.GetBreakpointsAtFileLine (IdeApp.Workbench.ActiveDocument.FileName, IdeApp.Workbench.ActiveDocument.GetContent<ITextView> (true).MDCaretLine());
					info.Enabled = bpInLine.Count > 0;
					info.Text = GettextCatalog.GetString ("Disable Breakpoint");
					foreach (var bp in bpInLine) {
						if (!bp.Enabled)
							info.Text = GettextCatalog.GetString ("Enable Breakpoint");
						break;
					}
				}
			} else {
				info.Enabled = false;
			}
		}
Esempio n. 6
0
		protected override void Update (CommandInfo info)
		{
			var breakpoints = DebuggingService.Breakpoints;

			lock (breakpoints) {
				if (!breakpoints.IsReadOnly) {
					foreach (var be in breakpoints) {
						if (be is Breakpoint bp) {
							if (!bp.NonUserBreakpoint) {
								info.Enabled = true;
								break;
							}
						} else {
							info.Enabled = true;
							break;
						}
					}
				} else {
					info.Enabled = false;
				}
			}

			info.Visible = DebuggingService.IsFeatureSupported (DebuggerFeatures.Breakpoints);
		}
Esempio n. 7
0
        public BreakpointPropertiesDialog(Breakpoint bp, bool isNew)
        {
            this.Build();

            this.isNew = isNew;
            this.bp    = bp;

            spinColumn.Adjustment.Upper = int.MaxValue;
            spinColumn.Adjustment.Lower = 1;
            spinLine.Adjustment.Upper   = int.MaxValue;
            spinLine.Adjustment.Lower   = 1;

            if (bp is FunctionBreakpoint)
            {
                FunctionBreakpoint fb = (FunctionBreakpoint)bp;

                labelFileFunction.LabelProp = GettextCatalog.GetString("Function:");

                if (fb.ParamTypes != null)
                {
                    // FIXME: support non-C# syntax based on fb.Language
                    entryFileFunction.Text = fb.FunctionName + " (" + string.Join(", ", fb.ParamTypes) + ")";
                }
                else
                {
                    entryFileFunction.Text = fb.FunctionName;
                }

                if (!isNew)
                {
                    // We don't use ".Sensitive = false" because we want the user to be able to select & copy the text.
                    entryFileFunction.ModifyBase(Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                    entryFileFunction.ModifyBase(Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                    entryFileFunction.IsEditable = false;
                }

                // Function breakpoints only support breaking on the first line
                hboxLineColumn.Destroy();
                labelLine.Destroy();
                table1.NRows--;
            }
            else
            {
                labelFileFunction.LabelProp = GettextCatalog.GetString("File:");
                entryFileFunction.Text      = ((Breakpoint)bp).FileName;

                // We don't use ".Sensitive = false" because we want the user to be able to select & copy the text.
                entryFileFunction.ModifyBase(Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryFileFunction.ModifyBase(Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryFileFunction.IsEditable = false;

                spinColumn.Value = bp.Column;
                spinLine.Value   = bp.Line;

                if (!isNew)
                {
                    spinColumn.IsEditable = false;
                    spinColumn.Sensitive  = false;
                    spinLine.IsEditable   = false;
                    spinLine.Sensitive    = false;
                }
            }

            if (string.IsNullOrEmpty(bp.ConditionExpression))
            {
                radioBreakAlways.Active = true;
            }
            else
            {
                entryCondition.Text = bp.ConditionExpression;
                if (bp.BreakIfConditionChanges)
                {
                    radioBreakChange.Active = true;
                }
                else
                {
                    radioBreakTrue.Active = true;
                }
            }

            spinHitCount.Value = bp.HitCount;

            if (bp.HitAction == HitAction.Break)
            {
                radioActionBreak.Active = true;
            }
            else
            {
                radioActionTrace.Active = true;
                entryTraceExpr.Text     = bp.TraceExpression;
            }

            Project project = null;

            if (!string.IsNullOrEmpty(bp.FileName))
            {
                project = IdeApp.Workspace.GetProjectContainingFile(bp.FileName);
            }

            if (project != null)
            {
                // Check the startup project of the solution too, since the current project may be a library
                SolutionEntityItem startup = project.ParentSolution.StartupItem;
                boxConditionOptions.Sensitive = DebuggingService.IsFeatureSupported(project, DebuggerFeatures.ConditionalBreakpoints) ||
                                                DebuggingService.IsFeatureSupported(startup, DebuggerFeatures.ConditionalBreakpoints);
                boxAction.Sensitive = DebuggingService.IsFeatureSupported(project, DebuggerFeatures.Tracepoints) ||
                                      DebuggingService.IsFeatureSupported(startup, DebuggerFeatures.Tracepoints);
            }

            UpdateControls();
        }
Esempio n. 8
0
        async void OnFrameChanged(object s, EventArgs a)
        {
            if (changingFrame)
            {
                return;
            }

            changingFrame = true;

            try {
                if (disassemblyDoc != null && DebuggingService.IsFeatureSupported(DebuggerFeatures.Disassembly))
                {
                    disassemblyView.Update();
                }

                var frame = DebuggingService.CurrentFrame;
                if (frame == null)
                {
                    return;
                }

                var      debuggerOptions = DebuggingService.GetUserOptions();
                FilePath file            = frame.SourceLocation.FileName;
                int      line            = frame.SourceLocation.Line;

                if (line != -1)
                {
                    if (!file.IsNullOrEmpty && File.Exists(file))
                    {
                        var doc = await IdeApp.Workbench.OpenDocument(file, null, line, 1, OpenDocumentOptions.Debugger);

                        if (doc != null)
                        {
                            return;
                        }
                    }

                    if (frame.SourceLocation.FileHash != null)
                    {
                        var newFilePath = SourceCodeLookup.FindSourceFile(file, frame.SourceLocation.FileHash);
                        if (newFilePath != null && File.Exists(newFilePath))
                        {
                            frame.UpdateSourceFile(newFilePath);
                            var doc = await IdeApp.Workbench.OpenDocument(newFilePath, null, line, 1, OpenDocumentOptions.Debugger);

                            if (doc != null)
                            {
                                return;
                            }
                        }
                    }

                    var automaticSourceDownload = debuggerOptions.AutomaticSourceLinkDownload;

                    var sourceLink = frame.SourceLocation.SourceLink;
                    if (sourceLink != null && automaticSourceDownload != AutomaticSourceDownload.Never)
                    {
                        var      downloadLocation = sourceLink.GetDownloadLocation(symbolCachePath);
                        Document doc = null;
                        // ~/Library/Caches/VisualStudio/8.0/Symbols/org/projectname/git-sha/path/to/file.cs
                        if (!File.Exists(downloadLocation))
                        {
                            if (automaticSourceDownload == AutomaticSourceDownload.Always)
                            {
                                doc = await NoSourceView.DownloadAndOpenAsync(frame);
                            }
                        }
                        else
                        {
                            // The file has previously been downloaded for a different solution.
                            // We need to map the cached location
                            frame.UpdateSourceFile(downloadLocation);
                            doc = await IdeApp.Workbench.OpenDocument(downloadLocation, null, line, 1, OpenDocumentOptions.Debugger);
                        }
                        if (doc != null)
                        {
                            return;
                        }
                    }
                }

                bool disassemblySupported = !string.IsNullOrEmpty(frame.AddressSpace) &&
                                            DebuggingService.CurrentSessionSupportsFeature(DebuggerFeatures.Disassembly);

                if (!disassemblySupported && disassemblyDoc != null)
                {
                    disassemblyDoc.Close().Ignore();
                    disassemblyDoc  = null;
                    disassemblyView = null;
                }

                // If disassembly is open don't show NoSourceView
                if (disassemblyDoc == null)
                {
                    if (noSourceDoc == null)
                    {
                        noSourceView = new NoSourceView();
                        noSourceView.Update(debuggerOptions, frame, disassemblySupported);
                        noSourceDoc = await IdeApp.Workbench.OpenDocument(noSourceView, true);

                        noSourceDoc.Closed += delegate {
                            noSourceDoc  = null;
                            noSourceView = null;
                        };
                    }
                    else
                    {
                        noSourceView.Update(debuggerOptions, frame, disassemblySupported);
                        noSourceDoc.Select();
                    }
                }
                else
                {
                    disassemblyDoc.Select();
                }
            } finally {
                changingFrame = false;
            }
        }
Esempio n. 9
0
 protected override void Update(CommandInfo info)
 {
     info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Disassembly);
     info.Enabled = IdeApp.Workspace.IsOpen;
 }
 protected override void Update(CommandInfo info)
 {
     info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Catchpoints);
 }
Esempio n. 11
0
        public BreakpointPropertiesDialog(Breakpoint bp, bool isNew)
        {
            this.Build();
            this.bp = bp;

            entryFile.Text = bp.FileName;
            entryLine.Text = bp.Line.ToString();

            if (!isNew)
            {
                entryFile.IsEditable = false;
                entryLine.IsEditable = false;
                entryFile.ModifyBase(Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryFile.ModifyBase(Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryLine.ModifyBase(Gtk.StateType.Normal, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
                entryLine.ModifyBase(Gtk.StateType.Active, Style.Backgrounds [(int)Gtk.StateType.Insensitive]);
            }

            if (string.IsNullOrEmpty(bp.ConditionExpression))
            {
                radioBreakAlways.Active = true;
            }
            else
            {
                entryCondition.Text = bp.ConditionExpression;
                if (bp.BreakIfConditionChanges)
                {
                    radioBreakChange.Active = true;
                }
                else
                {
                    radioBreakTrue.Active = true;
                }
            }

            spinHitCount.Value = bp.HitCount;

            if (bp.HitAction == HitAction.Break)
            {
                radioActionBreak.Active = true;
            }
            else
            {
                radioActionTrace.Active = true;
                entryTraceExpr.Text     = bp.TraceExpression;
            }

            Project project = IdeApp.Workspace.GetProjectContainingFile(bp.FileName);

            if (project != null)
            {
                // Check the startup project of the solution too, since the current project may be a library
                SolutionEntityItem startup = project.ParentSolution.StartupItem;
                boxConditionOptions.Sensitive = DebuggingService.IsFeatureSupported(project, DebuggerFeatures.ConditionalBreakpoints) ||
                                                DebuggingService.IsFeatureSupported(startup, DebuggerFeatures.ConditionalBreakpoints);
                boxAction.Sensitive = DebuggingService.IsFeatureSupported(project, DebuggerFeatures.Tracepoints) ||
                                      DebuggingService.IsFeatureSupported(startup, DebuggerFeatures.Tracepoints);
            }

            UpdateControls();
        }
Esempio n. 12
0
 protected override void Update(CommandInfo info)
 {
     info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Disassembly);
 }
Esempio n. 13
0
 protected override void Update(CommandInfo info)
 {
     info.Enabled = DebuggingService.IsPaused;
     info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Stepping);
 }
Esempio n. 14
0
 protected override void Update(CommandInfo info)
 {
     info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Breakpoints);
     info.Enabled = !DebuggingService.Breakpoints.IsReadOnly && IdeApp.Workspace.IsOpen;
 }
Esempio n. 15
0
 protected override void Update(CommandInfo info)
 {
     info.Enabled = info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Attaching);
 }
Esempio n. 16
0
 protected override void Update(CommandInfo info)
 {
     info.Enabled = DebuggingService.IsDebugging && DebuggingService.DebuggerSession.AttachedToProcess;
     info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Attaching);
 }
Esempio n. 17
0
        async void OnFrameChanged(object s, EventArgs a)
        {
            if (changingFrame)
            {
                return;
            }
            try {
                changingFrame = true;
                if (disassemblyDoc != null && DebuggingService.IsFeatureSupported(DebuggerFeatures.Disassembly))
                {
                    disassemblyView.Update();
                }

                var frame = DebuggingService.CurrentFrame;
                if (frame == null)
                {
                    return;
                }

                FilePath file = frame.SourceLocation.FileName;

                int line = frame.SourceLocation.Line;
                if (line != -1)
                {
                    if (!file.IsNullOrEmpty && File.Exists(file))
                    {
                        var doc = await IdeApp.Workbench.OpenDocument(file, null, line, 1, OpenDocumentOptions.Debugger);

                        if (doc != null)
                        {
                            return;
                        }
                    }
                    bool alternateLocationExists = false;
                    if (frame.SourceLocation.FileHash != null)
                    {
                        var newFilePath = SourceCodeLookup.FindSourceFile(file, frame.SourceLocation.FileHash);
                        if (newFilePath != null && File.Exists(newFilePath))
                        {
                            frame.UpdateSourceFile(newFilePath);
                            var doc = await IdeApp.Workbench.OpenDocument(newFilePath, null, line, 1, OpenDocumentOptions.Debugger);

                            if (doc != null)
                            {
                                return;
                            }
                        }
                    }
                    var debuggerOptions         = DebuggingService.GetUserOptions();
                    var automaticSourceDownload = debuggerOptions.AutomaticSourceLinkDownload;

                    var sourceLink = frame.SourceLocation.SourceLink;
                    if (sourceLink != null && automaticSourceDownload != AutomaticSourceDownload.Never)
                    {
                        var      downloadLocation = sourceLink.GetDownloadLocation(symbolCachePath);
                        Document doc = null;
                        // ~/Library/Caches/VisualStudio/8.0/Symbols/org/projectname/git-sha/path/to/file.cs
                        if (!File.Exists(downloadLocation))
                        {
                            if (automaticSourceDownload == AutomaticSourceDownload.Always)
                            {
                                doc = await DownloadAndOpenFileAsync(frame, line, sourceLink);
                            }
                            else
                            {
                                var hyperlink      = $"<a href='{ sourceLink.Uri }'>{  Path.GetFileName (sourceLink.RelativeFilePath) }</a>";
                                var stackframeText = $"<b>{frame.FullStackframeText}</b>";

                                var text = GettextCatalog.GetString
                                               ("{0} is a call to external source code. Would you like to get '{1}' and view it?", stackframeText, hyperlink);
                                var message = new Ide.GenericMessage {
                                    Text          = GettextCatalog.GetString("External source code available"),
                                    SecondaryText = text
                                };
                                message.AddOption(nameof(automaticSourceDownload), GettextCatalog.GetString("Always get source code automatically"), false);
                                message.Buttons.Add(AlertButton.Cancel);
                                message.Buttons.Add(new AlertButton(GettextCatalog.GetString("Get and Open")));
                                message.DefaultButton = 1;

                                var didNotCancel = MessageService.GenericAlert(message) != AlertButton.Cancel;
                                if (didNotCancel)
                                {
                                    if (message.GetOptionValue(nameof(automaticSourceDownload)))
                                    {
                                        debuggerOptions.AutomaticSourceLinkDownload = AutomaticSourceDownload.Always;
                                        DebuggingService.SetUserOptions(debuggerOptions);
                                    }
                                    doc = await DownloadAndOpenFileAsync(frame, line, sourceLink);
                                }
                            }
                        }
                        else
                        {
                            // The file has previously been downloaded for a different solution.
                            // We need to map the cached location
                            frame.UpdateSourceFile(downloadLocation);
                            doc = await IdeApp.Workbench.OpenDocument(downloadLocation, null, line, 1, OpenDocumentOptions.Debugger);
                        }
                        if (doc != null)
                        {
                            return;
                        }
                    }
                }

                bool disassemblyNotSupported = false;
                // If we don't have an address space, we can't disassemble
                if (string.IsNullOrEmpty(frame.AddressSpace))
                {
                    disassemblyNotSupported = true;
                }

                if (!DebuggingService.CurrentSessionSupportsFeature(DebuggerFeatures.Disassembly))
                {
                    disassemblyNotSupported = true;
                }

                if (disassemblyNotSupported && disassemblyDoc != null)
                {
                    disassemblyDoc.Close().Ignore();
                    disassemblyDoc  = null;
                    disassemblyView = null;
                }

                // If disassembly is open don't show NoSourceView
                if (disassemblyDoc == null)
                {
                    if (noSourceDoc == null)
                    {
                        noSourceView = new NoSourceView();
                        noSourceView.Update(disassemblyNotSupported);
                        noSourceDoc = await IdeApp.Workbench.OpenDocument(noSourceView, true);

                        noSourceDoc.Closed += delegate {
                            noSourceDoc  = null;
                            noSourceView = null;
                        };
                    }
                    else
                    {
                        noSourceView.Update(disassemblyNotSupported);
                        noSourceDoc.Select();
                    }
                }
                else
                {
                    disassemblyDoc.Select();
                }
            } finally {
                changingFrame = false;
            }
        }
Esempio n. 18
0
 protected override void Update(CommandInfo info)
 {
     info.Visible = DebuggingService.IsRunning;
     info.Enabled = DebuggingService.IsFeatureSupported(DebuggerFeatures.Pause) && DebuggingService.IsConnected;
 }
 protected override void Update(CommandInfo info)
 {
     info.Enabled = IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted;
     info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Attaching);
 }
Esempio n. 20
0
 protected override void Update(CommandInfo info)
 {
     info.Visible = DebuggingService.IsFeatureSupported(DebuggerFeatures.Catchpoints);
     info.Enabled = !DebuggingService.Breakpoints.IsReadOnly;
 }
Esempio n. 21
0
        async void OnFrameChanged(object s, EventArgs a)
        {
            if (disassemblyDoc != null && DebuggingService.IsFeatureSupported(DebuggerFeatures.Disassembly))
            {
                disassemblyView.Update();
            }

            var frame = DebuggingService.CurrentFrame;

            if (frame == null)
            {
                return;
            }

            FilePath file = frame.SourceLocation.FileName;
            int      line = frame.SourceLocation.Line;

            if (line != -1)
            {
                if (!file.IsNullOrEmpty && System.IO.File.Exists(file))
                {
                    var doc = await IdeApp.Workbench.OpenDocument(file, null, line, 1, OpenDocumentOptions.Debugger);

                    if (doc != null)
                    {
                        return;
                    }
                }
                if (frame.SourceLocation.FileHash != null)
                {
                    var newFilePath = SourceCodeLookup.FindSourceFile(file, frame.SourceLocation.FileHash);
                    if (newFilePath != null)
                    {
                        frame.UpdateSourceFile(newFilePath);
                        var doc = await IdeApp.Workbench.OpenDocument(newFilePath, null, line, 1, OpenDocumentOptions.Debugger);

                        if (doc != null)
                        {
                            return;
                        }
                    }
                }
            }

            bool disassemblyNotSupported = false;

            // If we don't have an address space, we can't disassemble
            if (string.IsNullOrEmpty(frame.AddressSpace))
            {
                disassemblyNotSupported = true;
            }

            if (!DebuggingService.CurrentSessionSupportsFeature(DebuggerFeatures.Disassembly))
            {
                disassemblyNotSupported = true;
            }

            if (disassemblyNotSupported && disassemblyDoc != null)
            {
                disassemblyDoc.Close().Ignore();
                disassemblyDoc  = null;
                disassemblyView = null;
            }

            // If disassembly is open don't show NoSourceView
            if (disassemblyDoc == null)
            {
                if (noSourceDoc == null)
                {
                    noSourceView = new NoSourceView();
                    noSourceView.Update(disassemblyNotSupported);
                    noSourceDoc = await IdeApp.Workbench.OpenDocument(noSourceView, true);

                    noSourceDoc.Closed += delegate {
                        noSourceDoc  = null;
                        noSourceView = null;
                    };
                }
                else
                {
                    noSourceView.Update(disassemblyNotSupported);
                    noSourceDoc.Select();
                }
            }
            else
            {
                disassemblyDoc.Select();
            }
        }