private void Callback(object state) { var result = DebuggerService.TryGetElementUnderCursor(); if (!result.HasValue) { return; } var value = result.Value; var selectedItem = SelectionManager.GetSelectedItem(); if (selectedItem == null || selectedItem.Id.Equals(value)) { return; } selectedItem = ElementCache.Get(value); if (selectedItem == null) { return; } SelectionManager.Replace(selectedItem); }
public void Execute(int line) { if (DebugInformation.CodeMappings != null && DebugInformation.CodeMappings.Count > 0) { // check if the codemappings exists for this line var storage = DebugInformation.CodeMappings; int token = 0; foreach (var key in storage.Keys) { var instruction = storage[key].GetInstructionByLineNumber(line, out token); if (instruction == null) { continue; } // no bookmark on the line: create a new breakpoint DebuggerService.ToggleBreakpointAt( instruction.MemberMapping.MemberReference, line, token, instruction.ILInstructionOffset, DebugInformation.Language); break; } if (token == 0) { MessageBox.Show(string.Format("Missing code mappings at line {0}.", line), "Code mappings", MessageBoxButton.OK, MessageBoxImage.Information); return; } } }
/// <summary> /// Open the source code at the current location. /// </summary> public void JumpToCurrentLine() { DebuggerService.RemoveCurrentLineMarker(); var process = CurrentProcess; if (process == null) { return; } // Activate the main window WorkbenchSingleton.MainWindow.Activate(); // Get the current frame var frame = CurrentStackFrame; if (frame == null) { return; } // Get the document location var location = frame.GetDocumentLocationAsync().Await(DalvikProcess.VmTimeout); if (location != null && location.SourceCode != null) { DebuggerService.RemoveCurrentLineMarker(); var p = location.SourceCode.Position; #if DEBUG Debug.WriteLine(string.Format("Current location: ({0},{1})-({2},{3}) {4:X4}", p.Start.Line, p.Start.Column, p.End.Line, p.End.Column, frame.Location.Index)); #endif DebuggerService.JumpToCurrentLine(location.SourceCode.Document.Path, p.Start.Line, p.Start.Column, p.End.Line, p.End.Column); } }
public GlobalsViewModel( StoryService storyService, DebuggerService debuggerService, VariableViewService variableViewService) : base("GlobalsView") { this.storyService = storyService; this.debuggerService = debuggerService; this.debuggerService.MachineCreated += DebuggerService_MachineCreated; this.debuggerService.MachineDestroyed += DebuggerService_MachineDestroyed; this.debuggerService.StateChanged += DebuggerService_StateChanged; this.debuggerService.Stepped += DebuggerService_ProcessorStepped; this.variableViewService = variableViewService; variableViewService.GlobalViewChanged += VariableViewService_GlobalViewChanged; this.globals = new IndexedVariableViewModel[240]; for (int i = 0; i < 240; i++) { var newGlobal = new IndexedVariableViewModel(i, 0); newGlobal.Visible = false; globals[i] = newGlobal; } SetVariableViewCommand = RegisterCommand <KeyValuePair <VariableViewModel, VariableView> >( text: "Set Variable View", name: "SetVariableView", executed: SetVariableViewExecuted, canExecute: CanSetVariableViewExecute); }
public override void Run() { var viewContent = WorkbenchSingleton.Workbench.ActiveContent; ITextEditorProvider provider = viewContent as ITextEditorProvider; ITextEditor editor = null; if (provider != null) { editor = provider.TextEditor; if (!string.IsNullOrEmpty(editor.FileName)) { DebuggerService.ToggleBreakpointAt(editor, editor.Caret.Line, typeof(BreakpointBookmark)); } } else { var view = viewContent as AbstractViewContentWithoutFile; if (view != null) { editor = view.GetService(typeof(ITextEditor)) as ITextEditor; if (editor != null) { DebuggerService.ToggleBreakpointAt(editor, editor.Caret.Line, typeof(DecompiledBreakpointBookmark)); } } } }
public App() { var cmdArgs = Environment.GetCommandLineArgs().Skip(1); App.CommandLineArguments = new CommandLineArguments(cmdArgs); if (App.CommandLineArguments.SingleInstance ?? true) { cmdArgs = cmdArgs.Select(FullyQualifyPath); string message = string.Join(Environment.NewLine, cmdArgs); if (SendToPreviousInstance("ILSpy:\r\n" + message, !App.CommandLineArguments.NoActivate)) { Environment.Exit(0); } } InitializeComponent(); var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(typeof(App).Assembly)); // Don't use DirectoryCatalog, that causes problems if the plugins are from the Internet zone // see http://stackoverflow.com/questions/8063841/mef-loading-plugins-from-a-network-shared-folder string appPath = Path.GetDirectoryName(typeof(App).Module.FullyQualifiedName); foreach (string plugin in Directory.GetFiles(appPath, "*.Plugin.dll")) { string shortName = Path.GetFileNameWithoutExtension(plugin); try { var asm = Assembly.Load(shortName); asm.GetTypes(); catalog.Catalogs.Add(new AssemblyCatalog(asm)); } catch (Exception ex) { // Cannot show MessageBox here, because WPF would crash with a XamlParseException // Remember and show exceptions in text output, once MainWindow is properly initialized StartupExceptions.Add(new ExceptionData { Exception = ex, PluginName = shortName }); } } compositionContainer = new CompositionContainer(catalog); Languages.Initialize(compositionContainer); if (!System.Diagnostics.Debugger.IsAttached) { AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; Dispatcher.CurrentDispatcher.UnhandledException += Dispatcher_UnhandledException; } EventManager.RegisterClassHandler(typeof(Window), Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(Window_RequestNavigate)); try { DebuggerService.SetDebugger(compositionContainer.GetExport <IDebugger>()); } catch { // unable to find a IDebugger } }
public InsightService(CodeEditor editor, LanguageContext languageContext, DebuggerService debuggerService) { _editor = editor; _languageContext = languageContext; _debuggerService = debuggerService; AttachEvents(); }
public MessageLogViewModel(DebuggerService debuggerService) : base("MessageLogView") { this.debuggerService = debuggerService; this.debuggerService.MachineCreated += DebuggerService_MachineCreated; this.debuggerService.MachineDestroyed += DebuggerService_MachineDestroyed; this.messages = new BulkObservableCollection <MessageViewModel>(); }
public static bool isExceptionThrown() { DebuggerService debuggerService = new DebuggerService(); DBGMODE dBGMODE = VsShellUtilities.GetDebugMode(debuggerService); if (DBGMODE.DBGMODE_Break == dBGMODE) { return(true); } return(false); }
public ManagedHotReloadLanguageService( VisualStudioWorkspace workspace, IManagedHotReloadService hotReloadService, IDiagnosticAnalyzerService diagnosticService, EditAndContinueDiagnosticUpdateSource diagnosticUpdateSource) { _proxy = new RemoteEditAndContinueServiceProxy(workspace); _debuggerService = new DebuggerService(hotReloadService); _diagnosticService = diagnosticService; _diagnosticUpdateSource = diagnosticUpdateSource; }
void OnMouseHover(MouseEventArgs e) { ToolTipRequestEventArgs args = new ToolTipRequestEventArgs(editor); var pos = editor.GetPositionFromPoint(e.GetPosition(editor)); args.InDocument = pos.HasValue; if (pos.HasValue) { args.LogicalPosition = new TextLocation(pos.Value.Line, pos.Value.Column); } else { return; } DebuggerService.HandleToolTipRequest(args); if (args.ContentToShow != null) { var contentToShowITooltip = args.ContentToShow as ITooltip; if (contentToShowITooltip != null && contentToShowITooltip.ShowAsPopup) { if (!(args.ContentToShow is UIElement)) { throw new NotSupportedException("Content to show in Popup must be UIElement: " + args.ContentToShow); } if (popup == null) { popup = CreatePopup(); } if (TryCloseExistingPopup(false)) { // when popup content decides to close, close the popup contentToShowITooltip.Closed += delegate { popup.IsOpen = false; }; popup.Child = (UIElement)args.ContentToShow; //ICSharpCode.SharpDevelop.Debugging.DebuggerService.CurrentDebugger.IsProcessRunningChanged SetPopupPosition(popup, e); popup.IsOpen = true; } e.Handled = true; } } else { // close popup if mouse hovered over empty area if (popup != null) { e.Handled = true; } TryCloseExistingPopup(false); } }
public ManagedHotReloadLanguageService( Lazy <IHostWorkspaceProvider> workspaceProvider, Lazy <IManagedHotReloadService> hotReloadService, IDiagnosticAnalyzerService diagnosticService, EditAndContinueDiagnosticUpdateSource diagnosticUpdateSource) { _workspaceProvider = workspaceProvider; _debuggerService = new DebuggerService(hotReloadService); _diagnosticService = diagnosticService; _diagnosticUpdateSource = diagnosticUpdateSource; }
public override void Run() { IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; if (window == null || !(window.ViewContent is ITextEditorControlProvider)) { return; } TextEditorControl textEditor = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl; DebuggerService.ToggleBreakpointAt(textEditor.Document, textEditor.FileName, textEditor.ActiveTextAreaControl.Caret.Line); }
/// <summary> /// Fire the IsProcessRunningChanged event. /// This method must be called on the main thread. /// </summary> private void OnDebugProcessIsSuspendedChangedOnMainThread(bool isProcessRunning) { this.IsProcessRunningChanged.Fire(this); if (isProcessRunning) { DebuggerService.RemoveCurrentLineMarker(); } else { JumpToCurrentLine(); } }
public void JumpToCurrentLine() { DebuggerService.RemoveCurrentLineMarker(); if (debuggedProcess != null) { SourcecodeSegment nextStatement = debuggedProcess.NextStatement; if (nextStatement != null) { DebuggerService.JumpToCurrentLine(nextStatement.Filename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn); } } }
protected override void OnMouseUp(MouseButtonEventArgs e) { base.OnMouseUp(e); int line = GetLineFromMousePosition(e); if (!e.Handled && dragDropBookmark != null) { if (dragStarted) { if (line != 0) { dragDropBookmark.Drop(line); } e.Handled = true; } CancelDragDrop(); } if (!e.Handled && line != 0) { IBookmark bm = GetBookmarkFromLine(line); if (bm != null) { bm.MouseUp(e); if (e.Handled) { return; } } if (e.ChangedButton == MouseButton.Left && TextView != null) { // no bookmark on the line: create a new breakpoint ITextEditor textEditor = TextView.Services.GetService(typeof(ITextEditor)) as ITextEditor; if (textEditor != null) { DebuggerService.ToggleBreakpointAt(textEditor, line, typeof(BreakpointBookmark)); return; } // create breakpoint for the other posible active contents var viewContent = WorkbenchSingleton.Workbench.ActiveContent as AbstractViewContentWithoutFile; if (viewContent != null) { textEditor = viewContent.Services.GetService(typeof(ITextEditor)) as ITextEditor; if (textEditor != null) { DebuggerService.ToggleBreakpointAt(textEditor, line, typeof(DecompiledBreakpointBookmark)); return; } } } } }
public KeystrokeService(ICodeViewModel codeViewModel, TextArea textArea, ICompletionProvider completionProvider, LanguageContext languageContext, DebuggerService debuggerService, BookmarkManager bookmarkManager) { _completionProvider = completionProvider; _completionProvider.OnCompletionCompleted += OnCompletionResultRetrieved; _languageContext = languageContext; _debuggerService = debuggerService; _bookmarkManager = bookmarkManager; _codeViewModel = codeViewModel; _textArea = textArea; _textArea.KeyUp += OnKeyReleased; _textArea.TextEntered += OnTextEntered; }
public OutputViewModel(StoryService storyService, DebuggerService debuggerService, GameScriptService gameScriptService) : base("OutputView") { this.storyService = storyService; this.storyService.StoryClosing += StoryService_StoryClosing; this.debuggerService = debuggerService; this.debuggerService.MachineCreated += DebuggerService_MachineCreated; this.gameScriptService = gameScriptService; }
public override void Run() { ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorControlProvider; if (provider != null) { TextEditorControl textEditor = provider.TextEditorControl; if (!string.IsNullOrEmpty(textEditor.FileName)) { DebuggerService.ToggleBreakpointAt(textEditor.Document, textEditor.FileName, textEditor.ActiveTextAreaControl.Caret.Line); } } }
public override void Run() { ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorProvider; if (provider != null) { ITextEditor editor = provider.TextEditor; if (!string.IsNullOrEmpty(editor.FileName)) { DebuggerService.ToggleBreakpointAt(editor, editor.Caret.Line); } } }
public VisualTracking(WorkflowDesigner workflowDesigner) { _workflowDesigner = workflowDesigner; _debuggerService = _workflowDesigner.DebugManagerView as DebuggerService; var trakcingProfile = new TrackingProfile(); trakcingProfile.Queries.Add(new ActivityStateQuery { ActivityName = "*", States = { ActivityStates.Executing }, Variables = { "*" }, Arguments = { "*" } }); TrackingProfile = trakcingProfile; _sourceLocationMaps = GetSourceLocationMap(); _idActivityMaps = GetIdActivityMaps(); }
public void JumpToCurrentLine() { WorkbenchSingleton.MainForm.Activate(); DebuggerService.RemoveCurrentLineMarker(); if (debuggedProcess != null) { SourcecodeSegment nextStatement = debuggedProcess.NextStatement; if (nextStatement != null) { string fileName = GetFileName(nextStatement); DebuggerService.JumpToCurrentLine(fileName, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn); } } }
public MemoryViewModel( StoryService storyService, DebuggerService debuggerService) : base("MemoryView") { this.storyService = storyService; this.storyService.StoryOpened += StoryService_StoryOpened; this.storyService.StoryClosing += StoryService_StoryClosing; this.debuggerService = debuggerService; this.debuggerService.StateChanged += DebuggerService_StateChanged; this.lines = new BulkObservableCollection <MemoryLineViewModel>(); }
/// <summary> /// Recreates breakpoints after change of source code. /// </summary> private void updateBreakpoints() { BreakpointBookmark[] markers = new BreakpointBookmark[DebuggerService.Breakpoints.Count]; DebuggerService.Breakpoints.CopyTo(markers, 0); foreach (BreakpointBookmark item in markers) { ITextEditor editor = findEditor(item); if (editor != null) { DebuggerService.ToggleBreakpointAt(editor, item.LineNumber, typeof(BreakpointBookmark)); DebuggerService.ToggleBreakpointAt(editor, item.LineNumber, typeof(BreakpointBookmark)); } } }
void JumpToDecompiledCode(Debugger.StackFrame frame) { if (frame == null) { LoggingService.Error("No stack frame!"); return; } if (debuggerDecompilerService == null) { LoggingService.Warn("No IDebuggerDecompilerService found!"); return; } // check for options - if these options are enabled, debugging decompiled code should not continue if (!debuggedProcess.Options.DecompileCodeWithoutSymbols) { LoggingService.Info("Decompiled code debugging is disabled!"); return; } DebuggerService.RemoveCurrentLineMarker(); // get external data int typeToken = frame.MethodInfo.DeclaringType.MetadataToken; int methodToken = frame.MethodInfo.MetadataToken; int ilOffset = frame.IP; int[] ilRanges = null; int line = -1; bool isMatch = false; var debugType = (DebugType)frame.MethodInfo.DeclaringType; debuggerDecompilerService.DebugStepInformation = Tuple.Create(methodToken, ilOffset); if (debuggerDecompilerService.GetILAndLineNumber(typeToken, methodToken, ilOffset, out ilRanges, out line, out isMatch)) { // update marker & navigate to line NavigationService.NavigateTo(debugType.DebugModule.FullPath, debugType.FullNameWithoutGenericArguments, IDStringProvider.GetIDString(frame.MethodInfo), line); } else { // no line => do decompilation NavigationService.NavigateTo(debugType.DebugModule.FullPath, debugType.FullNameWithoutGenericArguments, IDStringProvider.GetIDString(frame.MethodInfo)); } }
public CallStackViewModel( DebuggerService debuggerService, RoutineService routineService) : base("CallStackView") { this.debuggerService = debuggerService; this.debuggerService.MachineCreated += DebuggerService_MachineCreated; this.debuggerService.MachineDestroyed += new System.EventHandler <MachineDestroyedEventArgs>(DebuggerService_MachineDestroyed); this.debuggerService.StateChanged += DebuggerService_StateChanged; this.debuggerService.Stepped += DebuggerService_ProcessorStepped; this.routineService = routineService; this.stackFrames = new BulkObservableCollection <StackFrameViewModel>(); }
void JumpToSourceCode() { if (debuggedProcess == null || debuggedProcess.SelectedThread == null) { return; } SourcecodeSegment nextStatement = debuggedProcess.NextStatement; if (nextStatement != null) { DebuggerService.RemoveCurrentLineMarker(); DebuggerService.JumpToCurrentLine(nextStatement.Filename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn); } }
void UpdateDebugUI(bool isDecompilationOk) { // sync bookmarks iconMargin.SyncBookmarks(); if (isDecompilationOk) { if (DebugInformation.DebugStepInformation != null && DebuggerService.CurrentDebugger != null) { // repaint bookmarks iconMargin.InvalidateVisual(); // show the currentline marker int token = DebugInformation.DebugStepInformation.Item1; int ilOffset = DebugInformation.DebugStepInformation.Item2; int line; MemberReference member; if (DebugInformation.CodeMappings == null || !DebugInformation.CodeMappings.ContainsKey(token)) { return; } if (!DebugInformation.CodeMappings[token].GetInstructionByTokenAndOffset(ilOffset, out member, out line)) { return; } // update marker DebuggerService.JumpToCurrentLine(member, line, 0, line, 0, ilOffset); var bm = CurrentLineBookmark.Instance; DocumentLine docline = textEditor.Document.GetLineByNumber(line); bm.Marker = bm.CreateMarker(textMarkerService, docline.Offset + 1, docline.Length); UnfoldAndScroll(line); } } else { // remove currentline marker CurrentLineBookmark.Remove(); } }
public DisassemblyViewModel( StoryService storyService, DebuggerService debuggerService, BreakpointService breakpointService, // TODO: I haven't found a better way of enforcing this to be filled in time yet LabelService labelService, RoutineService routineService, NavigationService navigationService, EditRoutineNameDialogViewModel editRoutineNameDialogViewModel) : base("DisassemblyView") { this.storyService = storyService; this.debuggerService = debuggerService; this.debuggerService.MachineCreated += DebuggerService_MachineCreated; this.debuggerService.MachineDestroyed += DebuggerService_MachineDestroyed; this.debuggerService.StateChanged += DebuggerService_StateChanged; this.debuggerService.Stepped += DebuggerService_Stepped; this.breakpointService = breakpointService; this.breakpointService.Added += BreakpointService_Added; this.breakpointService.Removed += BreakpointService_Removed; this.routineService = routineService; this.routineService.RoutineNameChanged += RoutineService_RoutineNameChanged; this.navigationService = navigationService; this.navigationService.NavigationRequested += NavigationService_NavigationRequested; this.editRoutineNameDialogViewModel = editRoutineNameDialogViewModel; lines = new BulkObservableCollection <DisassemblyLineViewModel>(); addressToLineMap = new IntegerMap <DisassemblyLineViewModel>(); routineAddressAndIndexList = new List <AddressAndIndex>(); stackLines = new List <DisassemblyLineViewModel>(); this.EditNameCommand = RegisterCommand <int>( text: "EditName", name: "Edit Name", executed: EditNameExecuted, canExecute: CanEditNameExecute); }
public App() { var cmdArgs = Environment.GetCommandLineArgs().Skip(1); App.CommandLineArguments = new CommandLineArguments(cmdArgs); if (App.CommandLineArguments.SingleInstance ?? true) { cmdArgs = cmdArgs.Select(FullyQualifyPath); string message = string.Join(Environment.NewLine, cmdArgs); if (SendToPreviousInstance("ILSpy:\r\n" + message, !App.CommandLineArguments.NoActivate)) { Environment.Exit(0); } } InitializeComponent(); var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(typeof(App).Assembly)); catalog.Catalogs.Add(new DirectoryCatalog(".", "*.Plugin.dll")); compositionContainer = new CompositionContainer(catalog); Languages.Initialize(compositionContainer); if (!System.Diagnostics.Debugger.IsAttached) { AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; Dispatcher.CurrentDispatcher.UnhandledException += Dispatcher_UnhandledException; } EventManager.RegisterClassHandler(typeof(Window), Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(Window_RequestNavigate)); try { DebuggerService.SetDebugger(compositionContainer.GetExport <IDebugger>()); } catch { // unable to find a IDebugger } }