/// <summary> /// Constructor /// </summary> /// <param name="location">Location</param> /// <param name="span">Text view span</param> public DbgTextViewBreakpointLocationResult(DbgCodeLocation location, VirtualSnapshotSpan span) { if (span.Snapshot == null) { throw new ArgumentException(); } Locations = new[] { location ?? throw new ArgumentNullException(nameof(location)) };
public override DbgEvaluationContext CreateContext(DbgRuntime runtime, DbgCodeLocation location, DbgEvaluationContextOptions options, TimeSpan funcEvalTimeout, CancellationToken cancellationToken) { if (runtime == null) { throw new ArgumentNullException(nameof(runtime)); } if (runtime.RuntimeKindGuid != RuntimeKindGuid) { throw new ArgumentException(); } if (funcEvalTimeout == TimeSpan.Zero) { funcEvalTimeout = DefaultFuncEvalTimeout; } var context = new DbgEvaluationContextImpl(this, runtime, funcEvalTimeout, options); try { engineLanguage.InitializeContext(context, location, cancellationToken); } catch { context.Close(); throw; } return(context); }
public override void Serialize(ISettingsSection section, DbgCodeLocation location) { var loc = (DbgDotNetCodeLocation)location; section.Attribute("Token", loc.Token); section.Attribute("Offset", loc.Offset); section.Attribute("AssemblyFullName", loc.Module.AssemblyFullName); section.Attribute("ModuleName", loc.Module.ModuleName); if (loc.Module.IsDynamic) { section.Attribute("IsDynamic", loc.Module.IsDynamic); } if (loc.Module.IsInMemory) { section.Attribute("IsInMemory", loc.Module.IsInMemory); } if (loc.Module.ModuleNameOnly) { section.Attribute("ModuleNameOnly", loc.Module.ModuleNameOnly); } if (!loc.Module.IsInMemory && !loc.Module.IsDynamic) { var state = location.GetOrCreateData <SerializedState>(); if (!state.Initialized) { state.MethodAsString = GetMethodAsString(loc.Module, loc.Token); state.Initialized = true; } if (state.MethodAsString is not null) { section.Attribute("Method", state.MethodAsString); } } }
public override void InitializeContext(DbgEvaluationContext context, DbgCodeLocation location, CancellationToken cancellationToken) { Debug.Assert(context.Runtime.GetDotNetRuntime() != null); IDebuggerDisplayAttributeEvaluatorUtils.Initialize(context, debuggerDisplayAttributeEvaluator); // Needed by DebuggerRuntimeImpl (calls expressionCompiler.TryGetAliasInfo()) context.GetOrCreateData(() => expressionCompiler); var loc = location as IDbgDotNetCodeLocation; if (loc == null) { // Could be a special frame, eg. managed to native frame return; } var state = StateWithKey <RuntimeState> .GetOrCreate(context.Runtime, decompiler); var debugInfo = GetOrCreateDebugInfo(state, loc, cancellationToken); if (debugInfo == null) { return; } DbgLanguageDebugInfoExtensions.SetLanguageDebugInfo(context, debugInfo); }
public override void Serialize(ISettingsSection section, DbgCodeLocation location) { var loc = (DbgDotNetCodeLocation)location; section.Attribute("Token", loc.Token); section.Attribute("Offset", loc.Offset); section.Attribute("AssemblyFullName", loc.Module.AssemblyFullName); section.Attribute("ModuleName", loc.Module.ModuleName); if (loc.Module.IsDynamic) { section.Attribute("IsDynamic", loc.Module.IsDynamic); } if (loc.Module.IsInMemory) { section.Attribute("IsInMemory", loc.Module.IsInMemory); } if (loc.Module.ModuleNameOnly) { section.Attribute("ModuleNameOnly", loc.Module.ModuleNameOnly); } if (!loc.Module.IsInMemory && !loc.Module.IsDynamic) { var s = GetMethodAsString(loc.Module, loc.Token); if (s != null) { section.Attribute("Method", s); } } }
public SpecialDbgEngineStackFrame(string name, DbgCodeLocation location, DbgModule module, uint functionOffset, uint functionToken) { this.name = name ?? throw new ArgumentNullException(nameof(name)); Location = location; Module = module; FunctionOffset = functionOffset; FunctionToken = functionToken; }
public override DbgEngineStackFrame CreateSpecialStackFrame(string name, DbgCodeLocation location, DbgModule module, uint functionOffset, uint functionToken) { if (name == null) { throw new ArgumentNullException(nameof(name)); } return(new SpecialDbgEngineStackFrame(name, location, module, functionOffset, functionToken)); }
/// <summary> /// Constructor /// </summary> /// <param name="location">Location</param> /// <param name="module">Module or null if none</param> /// <param name="address">Address or <see cref="NoAddress"/> if it's not known</param> /// <param name="message">Warning/error message or null if none</param> /// <param name="data">Data to add to the <see cref="DbgBoundCodeBreakpoint"/> or null if nothing gets added. /// If the data implements <see cref="IDisposable"/>, it gets disposed when the bound breakpoint gets deleted.</param> public DbgBoundCodeBreakpointInfo(DbgCodeLocation location, DbgModule module, ulong address, DbgEngineBoundCodeBreakpointMessage message, T data) { Location = location ?? throw new ArgumentNullException(nameof(location)); Module = module; Address = address; Message = message; Data = data; }
public override DbgCodeBreakpoint? TryGetBreakpoint(DbgCodeLocation location) { if (location is null) throw new ArgumentNullException(nameof(location)); lock (lockObj) { if (locationToBreakpoint.TryGetValue(location, out var bp)) return bp; } return null; }
public override bool ShowNativeCode(DbgRuntime runtime, DbgCodeLocation location, string title) { if (!dbgNativeCodeProvider.Value.TryGetNativeCode(runtime, location, GetNativeCodeOptions(), out var result)) { return(false); } Show(result, title); return(true); }
public override DbgCodeBreakpoint TryGetBreakpoint(DbgCodeLocation location) { if (location == null) { throw new ArgumentNullException(nameof(location)); } lock (lockObj) { if (locationToBreakpoint.TryGetValue(location, out var bp)) { return(bp); } } return(null); }
public override void InitializeContext(DbgEvaluationContext context, DbgCodeLocation location, CancellationToken cancellationToken) { Debug.Assert(context.Runtime.GetDotNetRuntime() != null); IDebuggerDisplayAttributeEvaluatorUtils.Initialize(context, debuggerDisplayAttributeEvaluator); // Needed by DebuggerRuntimeImpl (calls expressionCompiler.TryGetAliasInfo()) context.GetOrCreateData(() => expressionCompiler); if ((context.Options & DbgEvaluationContextOptions.NoMethodBody) == 0 && location is IDbgDotNetCodeLocation loc) { var state = StateWithKey <RuntimeState> .GetOrCreate(context.Runtime, decompiler); var debugInfo = GetOrCreateDebugInfo(context, state, loc, cancellationToken); if (debugInfo != null) { DbgLanguageDebugInfoExtensions.SetLanguageDebugInfo(context, debugInfo); } } }
public override void InitializeContext(DbgEvaluationContext context, DbgCodeLocation location, CancellationToken cancellationToken) { Debug.Assert(context.Runtime.GetDotNetRuntime() != null); var loc = location as IDbgDotNetCodeLocation; if (loc == null) { // Could be a special frame, eg. managed to native frame return; } var state = StateWithKey <RuntimeState> .GetOrCreate(context.Runtime, decompiler); var debugInfo = GetOrCreateDebugInfo(state, loc, cancellationToken); if (debugInfo == null) { return; } DbgLanguageDebugInfoExtensions.SetLanguageDebugInfo(context, debugInfo); }
public override bool CanGetNativeCode(DbgRuntime runtime, DbgCodeLocation location) { if (runtime == null) { throw new ArgumentNullException(nameof(runtime)); } if (location == null) { throw new ArgumentNullException(nameof(location)); } foreach (var provider in GetProviders(runtime)) { if (provider.CanGetNativeCode(runtime, location)) { return(true); } } return(false); }
public override bool TryGetNativeCode(DbgRuntime runtime, DbgCodeLocation location, DbgNativeCodeOptions options, out GetNativeCodeResult result) { if (runtime == null) { throw new ArgumentNullException(nameof(runtime)); } if (location == null) { throw new ArgumentNullException(nameof(location)); } foreach (var provider in GetProviders(runtime)) { if (provider.TryGetNativeCode(runtime, location, options, out result)) { return(true); } } result = default; return(false); }
public override DbgTextViewBreakpointLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position) { var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null) { return(null); } var methodDebugService = documentViewer.GetMethodDebugService(); if (methodDebugService == null) { return(null); } var methodStatements = methodDebugService.FindByTextPosition(position.Position, FindByTextPositionOptions.None); if (methodStatements.Count == 0) { return(null); } var textSpan = methodStatements[0].Statement.TextSpan; var snapshot = textView.TextSnapshot; if (textSpan.End > snapshot.Length) { return(null); } var span = new VirtualSnapshotSpan(new SnapshotSpan(snapshot, new Span(textSpan.Start, textSpan.Length))); var locations = new DbgCodeLocation[methodStatements.Count]; for (int i = 0; i < methodStatements.Count; i++) { var statement = methodStatements[i]; var moduleId = moduleIdProvider.Create(statement.Method.Module); locations[i] = dbgDotNetCodeLocationFactory.Value.Create(moduleId, statement.Method.MDToken.Raw, statement.Statement.ILSpan.Start); } return(new DbgTextViewBreakpointLocationResult(locations, span)); }
/// <summary> /// Creates a special stack frame that's displayed as [name], eg. [Managed to Native Transition] /// </summary> /// <param name="name">Name, eg. "Managed to Native Transition"</param> /// <param name="location">Location or null</param> /// <param name="module">Module or null</param> /// <param name="functionOffset">Function offset</param> /// <param name="functionToken">Function token</param> /// <returns></returns> public abstract DbgEngineStackFrame CreateSpecialStackFrame(string name, DbgCodeLocation location = null, DbgModule module = null, uint functionOffset = 0, uint functionToken = DbgEngineStackFrame.InvalidFunctionToken);
/// <summary> /// Creates a bound breakpoint. This method returns null if there was no breakpoint matching <paramref name="location"/>. /// /// To get notified when a bound breakpoint gets deleted, add custom data that implements <see cref="IDisposable"/>. /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="location">Breakpoint location</param> /// <param name="module">Module or null if none</param> /// <param name="address">Address or <see cref="BoundBreakpointNoAddress"/> if unknown</param> /// <param name="message">Warning/error message or null if none</param> /// <param name="data">Data to add to the <see cref="DbgEngineBoundCodeBreakpoint"/> or null if nothing gets added</param> /// <returns></returns> public DbgEngineBoundCodeBreakpoint Create <T>(DbgCodeLocation location, DbgModule module, ulong address, DbgEngineBoundCodeBreakpointMessage message, T data) where T : class => Create(new[] { new DbgBoundCodeBreakpointInfo <T>(location, module, address, message, data) }).FirstOrDefault();
/// <summary> /// Creates a bound breakpoint. This method returns null if there was no breakpoint matching <paramref name="location"/>. /// /// To get notified when a bound breakpoint gets deleted, add custom data that implements <see cref="IDisposable"/>. /// </summary> /// <param name="location">Breakpoint location</param> /// <param name="module">Module or null if none</param> /// <param name="address">Address or <see cref="BoundBreakpointNoAddress"/> if unknown</param> /// <param name="message">Warning/error message or null if none</param> /// <returns></returns> public DbgEngineBoundCodeBreakpoint Create(DbgCodeLocation location, DbgModule module, ulong address, DbgEngineBoundCodeBreakpointMessage message) => Create(new[] { new DbgBoundCodeBreakpointInfo <object>(location, module, address, message, null) }).FirstOrDefault();
/// <summary> /// Constructor /// </summary> /// <param name="location">Breakpoint location. If you don't own this location instance, you must call <see cref="DbgCodeLocation.Clone"/></param> /// <param name="settings">Breakpoint settings</param> /// <param name="options">Breakpoint options</param> public DbgCodeBreakpointInfo(DbgCodeLocation location, DbgCodeBreakpointSettings settings, DbgCodeBreakpointOptions options) { Location = location ?? throw new ArgumentNullException(nameof(location)); Settings = settings; Options = options; }
void SetIP_DbgThread(DbgThreadImpl thread, DbgCodeLocation location) { Dispatcher.VerifyAccess(); OnBeforeContinuing_DbgThread(); Engine.SetIP(thread, location); }
public abstract bool CanSerialize(DbgCodeLocation location);
/// <summary> /// Initializes an evaluation context /// </summary> /// <param name="context">Context</param> /// <param name="location">Location or null</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns></returns> public abstract void InitializeContext(DbgEvaluationContext context, DbgCodeLocation location, CancellationToken cancellationToken);
/// <summary> /// Returns a formatter or null /// </summary> /// <param name="location">Breakpoint location</param> /// <returns></returns> public abstract DbgBreakpointLocationFormatter Create(DbgCodeLocation location);
/// <summary> /// Checks if <see cref="SetIP(DbgCodeLocation)"/> can be called /// </summary> /// <param name="location">New location</param> /// <returns></returns> public abstract bool CanSetIP(DbgCodeLocation location);
/// <summary> /// Sets a new instruction pointer /// </summary> /// <param name="location">New location</param> public abstract void SetIP(DbgCodeLocation location);
public abstract void Serialize(ISettingsSection section, DbgCodeLocation location);
internal void SetIP(DbgThreadImpl thread, DbgCodeLocation location) => Dispatcher.BeginInvoke(() => SetIP_DbgThread(thread, location));
internal bool CanSetIP(DbgThreadImpl thread, DbgCodeLocation location) => Engine.CanSetIP(thread, location);
public override void InitializeContext(DbgEvaluationContext context, DbgCodeLocation location, CancellationToken cancellationToken) { }