string GetProgramDisplay(IGgpDebugProgram program) { if (program.GetName(out string programDisplay) != VSConstants.S_OK) { programDisplay = program.ToString(); } if (program.GetProgramId(out Guid programId) == VSConstants.S_OK) { programDisplay += " id:" + programId; } return(programDisplay); }
LldbEventManager(IDebugEngineHandler debugEngineHandler, IBreakpointManager breakpointManager, BoundBreakpointEnumFactory boundBreakpointEnumFactory, IGgpDebugProgram program, SbProcess process, LldbListenerSubscriber listenerSubscriber, JoinableTaskContext taskContext) { _debugEngineHandler = debugEngineHandler; _lldbBreakpointManager = breakpointManager; _boundBreakpointEnumFactory = boundBreakpointEnumFactory; _program = program; _lldbProcess = process; _lldbListenerSubscriber = listenerSubscriber; _taskContext = taskContext; }
public void SetUp() { _remoteThread = Substitute.For <RemoteThread>(); _debugProgram = Substitute.For <IGgpDebugProgram>(); _ad7FrameInfoCreator = Substitute.For <AD7FrameInfoCreator>( Substitute.For <IDebugModuleCache>()); _ad7FrameInfoCreator .Create(Arg.Any <IDebugStackFrame>(), Arg.Any <FrameInfo <SbModule> >(), _debugProgram) .ReturnsForAnyArgs(args => CreateFRAMEINFO((IDebugStackFrame)args[0], (FrameInfo <SbModule>)args[1])); _debugThread = Substitute.For <IDebugThread>(); _stackFramesProvider = new StackFramesProvider(_remoteThread, CreateStackFrame, _debugProgram, _ad7FrameInfoCreator, _debugProgram); }
/// <summary> /// Creates an AD7 FRAMEINFO based on a FrameInfo value. /// </summary> public virtual FRAMEINFO Create(IDebugStackFrame frame, FrameInfo <SbModule> info, IGgpDebugProgram program) => new FRAMEINFO { m_addrMax = info.AddrMax, m_addrMin = info.AddrMin, m_bstrArgs = info.Args, m_bstrFuncName = info.FuncName, m_bstrLanguage = info.Language, m_bstrModule = info.ModuleName, m_bstrReturnType = info.ReturnType, m_dwFlags = info.Flags, m_dwValidFields = (enum_FRAMEINFO_FLAGS)info.ValidFields, m_fHasDebugInfo = info.HasDebugInfo, m_pModule = info.Module != null?_debugModuleCache.GetOrCreate(info.Module, program) : null, m_pFrame = (FrameInfoFlags.FIF_FRAME & info.ValidFields) != 0 ? frame : null };
async Task <int> SendEventAsync(DebugEvent evnt, IGgpDebugProgram program, IDebugThread2 thread) { await _taskContext.Factory.SwitchToMainThreadAsync(); if (((IDebugEvent2)evnt).GetAttributes(out uint attributes) != VSConstants.S_OK) { Trace.WriteLine($"Could not get event attributes of event ({evnt})"); return(VSConstants.E_FAIL); } Guid eventIid = evnt.Iid; DebugLogSend(evnt, program, thread, attributes); return(_eventCallback.Event(_debugEngine, null, program, thread, evnt, ref eventIid, attributes)); }
public void SetUp() { lineEntry = new LineEntryInfo(); mockDocumentContext = Substitute.For <IDebugDocumentContext2>(); mockThread = Substitute.For <IDebugThread>(); mockDocumentContextFactory = Substitute.For <DebugDocumentContext.Factory>(); mockDocumentContextFactory.Create(lineEntry).Returns(mockDocumentContext); mockDebuggerStackFrame = Substitute.For <RemoteFrame>(); mockDebuggerStackFrame.GetLineEntry().Returns(lineEntry); mockDebuggerStackFrame.GetPC().Returns(TEST_PC); mockDebuggerStackFrame.GetFunctionName().Returns(NAME); mockDebuggerStackFrame.GetFunctionNameWithSignature().Returns(NAME); mockCodeContextFactory = Substitute.For <DebugCodeContext.Factory>(); mockExpressionFactory = Substitute.For <DebugExpression.Factory>(); mockModuleCache = Substitute.For <IDebugModuleCache>(); mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>(); mockProgram = Substitute.For <IGgpDebugProgram>(); taskExecutor = new TaskExecutor(new JoinableTaskContext().Factory); var childAdapterFactory = new RemoteValueChildAdapter.Factory(); var varInfoFactory = new LLDBVariableInformationFactory(childAdapterFactory); var varInfoEnumFactory = new VariableInformationEnum.Factory(taskExecutor); var childrenProviderFactory = new ChildrenProvider.Factory(); var propertyFactory = new DebugProperty.Factory(varInfoEnumFactory, childrenProviderFactory, Substitute.For <DebugCodeContext.Factory>(), new VsExpressionCreator(), taskExecutor); childrenProviderFactory.Initialize(propertyFactory.Create); var registerSetsBuilderFactory = new RegisterSetsBuilder.Factory(varInfoFactory); stackFrame = new DebugStackFrame.Factory(mockDocumentContextFactory, childrenProviderFactory, mockCodeContextFactory, mockExpressionFactory.Create, varInfoFactory, varInfoEnumFactory, registerSetsBuilderFactory, taskExecutor) .Create(new AD7FrameInfoCreator(mockModuleCache), mockDebuggerStackFrame, mockThread, mockDebugEngineHandler, mockProgram); stackFrameAsync = new DebugStackFrameAsync.Factory(mockDocumentContextFactory, childrenProviderFactory, mockCodeContextFactory, mockExpressionFactory.Create, varInfoFactory, varInfoEnumFactory, registerSetsBuilderFactory, taskExecutor) .Create(new AD7FrameInfoCreator(mockModuleCache), mockDebuggerStackFrame, mockThread, mockDebugEngineHandler, mockProgram); }
public void SetUp() { _mockDebuggerStackFrame = Substitute.For <RemoteFrame>(); var childAdapterFactory = new RemoteValueChildAdapter.Factory(); var varInfoFactory = new LLDBVariableInformationFactory(childAdapterFactory); _vsExpressionCreator = new VsExpressionCreator(); _metrics = Substitute.For <IMetrics>(); var eventScheduler = new EventSchedulerFake(); var eventSchedulerFactory = Substitute.For <IEventSchedulerFactory>(); eventSchedulerFactory.Create(Arg.Do <System.Action>(a => eventScheduler.Callback = a)) .Returns(eventScheduler); var timer = new TimerFake(); const int minimumBatchSeparationMilliseconds = 1; var batchEventAggregator = new BatchEventAggregator <ExpressionEvaluationBatch, ExpressionEvaluationBatchParams, ExpressionEvaluationBatchSummary>(minimumBatchSeparationMilliseconds, eventSchedulerFactory, timer); _expressionEvaluationRecorder = new ExpressionEvaluationRecorder(batchEventAggregator, _metrics); _timeSource = new MonotonicTimeSource(); _taskExecutor = Substitute.ForPartsOf <FakeTaskExecutor>(); var enumFactory = new VariableInformationEnum.Factory(_taskExecutor); var childrenProviderFactory = new ChildrenProvider.Factory(); var debugPropertyFactory = new DebugProperty.Factory( enumFactory, childrenProviderFactory, null, _vsExpressionCreator, _taskExecutor); _createPropertyDelegate = debugPropertyFactory.Create; childrenProviderFactory.Initialize(_createPropertyDelegate); _varInfoBuilder = new VarInfoBuilder(varInfoFactory); varInfoFactory.SetVarInfoBuilder(_varInfoBuilder); _engineCommandsMock = Substitute.For <IDebugEngineCommands>(); _mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>(); _mockProgram = Substitute.For <IGgpDebugProgram>(); _mockThread = Substitute.For <IDebugThread2>(); }
DebugModule(CancelableTask.Factory cancelableTaskFactory, ActionRecorder actionRecorder, ModuleFileLoadMetricsRecorder.Factory moduleFileLoadRecorderFactory, ILldbModuleUtil moduleUtil, IModuleFileLoader moduleFileLoader, IModuleSearchLogHolder moduleSearchLogHolder, SbModule lldbModule, uint loadOrder, IDebugEngineHandler engineHandler, IGgpDebugProgram program, ISymbolSettingsProvider symbolSettingsProvider) { _cancelableTaskFactory = cancelableTaskFactory; _actionRecorder = actionRecorder; _moduleFileLoadRecorderFactory = moduleFileLoadRecorderFactory; _moduleUtil = moduleUtil; _moduleFileLoader = moduleFileLoader; _moduleSearchLogHolder = moduleSearchLogHolder; _lldbModule = lldbModule; _loadOrder = loadOrder; _engineHandler = engineHandler; _program = program; _symbolSettingsProvider = symbolSettingsProvider; }
DebugStackFrameAsync(DebugDocumentContext.Factory debugDocumentContextFactory, IChildrenProviderFactory childrenProviderFactory, DebugCodeContext.Factory debugCodeContextFactory, CreateDebugExpressionDelegate createExpressionDelegate, IVariableInformationFactory varInfoFactory, IVariableInformationEnumFactory varInfoEnumFactory, AD7FrameInfoCreator ad7FrameInfoCreator, IRegisterSetsBuilder registerSetsBuilder, IDebugEngineHandler debugEngineHandler, RemoteFrame frame, IDebugThread2 thread, IGgpDebugProgram debugProgram, ITaskExecutor taskExecutor) : base(debugDocumentContextFactory, childrenProviderFactory, debugCodeContextFactory, createExpressionDelegate, varInfoFactory, varInfoEnumFactory, ad7FrameInfoCreator, registerSetsBuilder, debugEngineHandler, frame, thread, debugProgram, taskExecutor) { }
public void SetUp() { _mockSbListener = Substitute.For <SbListener>(); _mockSbProcess = Substitute.For <SbProcess>(); _mockSbEvent = Substitute.For <SbEvent>(); _mockRemoteThread = Substitute.For <RemoteThread>(); _mockBreakpointManager = Substitute.For <IBreakpointManager>(); _mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>(); _mockPendingBreakpoint1 = Substitute.For <IPendingBreakpoint>(); _mockPendingBreakpoint2 = Substitute.For <IPendingBreakpoint>(); _mockBoundBreakpoint1 = Substitute.For <IBoundBreakpoint>(); _mockBoundBreakpoint2 = Substitute.For <IBoundBreakpoint>(); _mockBoundBreakpoint3 = Substitute.For <IBoundBreakpoint>(); _mockWatchpoint = Substitute.For <IWatchpoint>(); _mockProgram = Substitute.For <IGgpDebugProgram>(); MockEvent(EventType.STATE_CHANGED, StateType.STOPPED, false); MockListener(_mockSbEvent, true); MockThread(_mockRemoteThread, StopReason.BREAKPOINT, _breakpointStopData); MockProcess(new List <RemoteThread> { _mockRemoteThread }); MockBreakpointManager(); _mockListenerSubscriber = Substitute.For <LldbListenerSubscriber>(_mockSbListener); var threadContext = new FakeMainThreadContext(); _eventManager = new LldbEventManager .Factory(new BoundBreakpointEnumFactory(), threadContext.JoinableTaskContext) .Create(_mockDebugEngineHandler, _mockBreakpointManager, _mockProgram, _mockSbProcess, _mockListenerSubscriber); var lldbEventManager = _eventManager as LldbEventManager; lldbEventManager?.SubscribeToChanges(); }
public void SetUp() { _mockCancelableTaskFactory = Substitute.For <CancelableTask.Factory>(); _mockModuleUtil = Substitute.For <ILldbModuleUtil>(); _mockModuleUtil.HasSymbolsLoaded(Arg.Any <SbModule>()).Returns(false); _mockModuleFileLoader = Substitute.For <IModuleFileLoader>(); _mockModuleSearchLogHolder = Substitute.For <IModuleSearchLogHolder>(); _mockModule = Substitute.For <SbModule>(); _mockActionRecorder = Substitute.For <ActionRecorder>(null, null); var mockModuleFileLoadRecorderFactory = Substitute.For <ModuleFileLoadMetricsRecorder.Factory>(); _mockEngineHandler = Substitute.For <IDebugEngineHandler>(); _mockDebugProgram = Substitute.For <IGgpDebugProgram>(); _mockSymbolSettingsProvider = Substitute.For <ISymbolSettingsProvider>(); _debugModule = new DebugModule .Factory(_mockCancelableTaskFactory, _mockActionRecorder, mockModuleFileLoadRecorderFactory, _mockModuleUtil, _mockSymbolSettingsProvider) .Create(_mockModuleFileLoader, _mockModuleSearchLogHolder, _mockModule, _testLoadOrder, _mockEngineHandler, _mockDebugProgram); }
public void SetUp() { taskContext = new JoinableTaskContext(); mockBreakpointRequest = Substitute.For <IDebugBreakpointRequest2>(); mockTarget = Substitute.For <RemoteTarget>(); mockProgram = Substitute.For <IGgpDebugProgram>(); mockPendingBreakpoint = Substitute.For <IPendingBreakpoint>(); mockPendingBreakpoint.GetId().Returns(ID); mockWatchpoint = Substitute.For <IWatchpoint>(); mockWatchpoint.GetId().Returns(ID); mockPendingBreakpointFactory = Substitute.For <DebugPendingBreakpoint.Factory>(); mockWatchpointFactory = Substitute.For <DebugWatchpoint.Factory>(); var mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>(); breakpointManager = new LldbBreakpointManager.Factory(taskContext, mockPendingBreakpointFactory, mockWatchpointFactory).Create(mockDebugEngineHandler, mockProgram); mockPendingBreakpointFactory.Create(breakpointManager, mockProgram, mockBreakpointRequest, mockTarget).ReturnsForAnyArgs(mockPendingBreakpoint); mockWatchpointFactory.Create(breakpointManager, mockBreakpointRequest, mockTarget, mockProgram).ReturnsForAnyArgs(mockWatchpoint); }
public LldbAttachedProgram(IBreakpointManager breakpointManager, IEventManager eventManager, ILLDBShell lldbShell, IModuleFileLoader moduleFileLoader, IDebugEngineHandler debugEngineHandler, ITaskExecutor taskExecutor, IGgpDebugProgram debugProgram, SbDebugger debugger, RemoteTarget target, SbProcess process, IExceptionManager exceptionManager, IDebugModuleCache debugModuleCache, ILldbListenerSubscriber listenerSubscriber, uint remotePid) { _debugProgram = debugProgram; _breakpointManager = breakpointManager; _eventManager = eventManager; _lldbShell = lldbShell; _moduleFileLoader = moduleFileLoader; _debugEngineHandler = debugEngineHandler; _taskExecutor = taskExecutor; _debugger = debugger; _target = target; _process = process; _exceptionManager = exceptionManager; _debugModuleCache = debugModuleCache; _listenerSubscriber = listenerSubscriber; RemotePid = remotePid; }
/// <summary> /// Send a module load or unload event to the SDM. /// </summary> public static void OnModuleLoad(this IDebugEngineHandler handler, IDebugModule2 module, IGgpDebugProgram program) => handler.SendEvent(new DebugModuleLoadEvent(module, true), program);
public void SetUp() { debugEngineHandler = Substitute.For <IDebugEngineHandler>(); program = Substitute.For <IGgpDebugProgram>(); }
public static int OnEvaluationComplete(this IDebugEngineHandler handler, IDebugExpression2 expr, IDebugProperty2 result, IGgpDebugProgram program, IDebugThread2 thread) => handler.SendEvent(new DebugExpressionEvaluationCompleteEvent(expr, result), program, thread);
// Uses the callback to send a debug event to the SDM. // The callback is provided to us when the SDM calls LaunchSuspended. // Certain events require, allow, or do not allow program or thread objects // to be sent with them. Reference: // https://docs.microsoft.com/en-us/visualstudio/extensibility/debugger/supported-event-types public int SendEvent(DebugEvent evnt, IGgpDebugProgram program, IDebugThread2 thread) => _taskContext.Factory.Run(async() => await SendEventAsync(evnt, program, thread));
public int SendEvent(DebugEvent evnt, IGgpDebugProgram program, RemoteThread thread) => SendEvent(evnt, program, program.GetDebugThread(thread));
/// <summary> /// Called to send a DebugEvent with no associated thread to the Visual Studio SDM. /// </summary> public static int SendEvent(this IDebugEngineHandler handler, DebugEvent evnt, IGgpDebugProgram program) => handler.SendEvent(evnt, program, (IDebugThread2)null);
void DebugLogSend(IDebugEvent2 eventObject, IGgpDebugProgram program, IDebugThread2 thread, uint attributes) => Trace.WriteLine("Sending event " + eventObject + " with attribute " + Enum.GetName(typeof(enum_EVENTATTRIBUTES), attributes) + ", program " + GetProgramDisplay(program) + ", and thread " + GetThreadDisplay(thread));
/// <summary> /// Called to abort the debug engine. /// </summary> public static void Abort(this IDebugEngineHandler handler, IGgpDebugProgram program, ExitInfo exitInfo) => handler.SendEvent(new ProgramDestroyEvent(exitInfo), program);
/// <summary> /// Send a breakpoint error event to the SDM. /// </summary> public static void OnBreakpointError(this IDebugEngineHandler handler, DebugBreakpointError breakpointError, IGgpDebugProgram program) => handler.SendEvent(new BreakpointErrorEvent(breakpointError), program);
public virtual IDebugAsyncExpression Create(RemoteFrame frame, string text, IDebugEngineHandler debugEngineHandler, IGgpDebugProgram debugProgram, IDebugThread2 thread) { IAsyncExpressionEvaluator evaluator = asyncEvaluatorFactory.Create(frame, text); return(new DebugAsyncExpression(debugEngineHandler, evaluator, taskExecutor, debugProgram, thread)); }
public virtual IDebugExpression Create(RemoteFrame frame, string text, IDebugEngineHandler debugEngineHandler, IGgpDebugProgram debugProgram, IDebugThread2 thread) => new DebugExpression(debugEngineHandler, asyncEvaluatorFactory.Create(frame, text), taskExecutor, debugProgram, thread);
/// <summary> /// Send a watchpoint bound event to the SDM. /// </summary> public static void OnWatchpointBound(this IDebugEngineHandler handler, IWatchpoint pendingWatchpoint, IGgpDebugProgram program) => handler.SendEvent(new BreakpointBoundEvent(pendingWatchpoint), program);
private DebugExpression(IDebugEngineHandler debugEngineHandler, IAsyncExpressionEvaluator asyncEvaluator, ITaskExecutor taskExecutor, IGgpDebugProgram program, IDebugThread2 thread) : base(debugEngineHandler, asyncEvaluator, taskExecutor, program, thread) { }
/// <summary> /// Send a symbols loaded event. /// </summary> public static void OnSymbolsLoaded(this IDebugEngineHandler handler, IDebugModule3 module, string moduleName, string errorMessage, bool loaded, IGgpDebugProgram program) => handler.SendEvent(new DebugSymbolSearchEvent(module, moduleName, errorMessage, loaded), program);
public virtual IBreakpointManager Create(IDebugEngineHandler debugEngineHandler, IGgpDebugProgram debugProgram) { return(new LldbBreakpointManager(taskContext, pendingBreakpointFactory, watchpointFactory, debugEngineHandler, debugProgram)); }
IDebugStackFrame CreateStackFrame(RemoteFrame frame, IDebugThread thread, IGgpDebugProgram debugProgram) { return(Substitute.For <IDebugStackFrame>()); }