// TODO: // [Parameter( Mandatory = true, // Position = 0, // ValueFromPipeline = true, // ParameterSetName = c_FileParamSet )] // [ValidateNotNullOrEmpty] // public string File { get; set; } protected override void ProcessRecord() { base.ProcessRecord(); if (!String.IsNullOrEmpty(TypeName)) { string mod, template; ulong dontCare; DbgProvider.ParseSymbolName(TypeName, out mod, out template, out dontCare); if (0 != dontCare) { throw new ArgumentException("The TypeName parameter does not look like a type name.", "TypeName"); } DbgValueConversionManager.RemoveEntries(mod, template, !AllMatching); } else { Util.Fail("impossible"); } // else // { // Util.Assert( !String.IsNullOrEmpty( File ) ); // string fullpath = GetUnresolvedProviderPathFromPSPath( File ); // DbgValueConversionManager.RemoveAllEntriesFromFile( fullpath, !AllMatching ); // } } // end ProcessRecord()
protected override void ProcessRecord() { if (ParameterSetName.Equals("History")) { var powershell = PowerShell.Create(RunspaceMode.CurrentRunspace); powershell.AddCommand("Invoke-History"); powershell.AddParameter("Id", Id); powershell.Invoke(); } else { string path = this.CurrentProviderLocation(DbgProvider.ProviderId).ProviderPath; var regSet = DbgProvider.GetRegisterSetForPath(path); if (null != regSet) { SafeWriteObject(regSet); } else { // TODO: Need a "no register context exception" or something WriteError(new InvalidOperationException(Util.Sprintf("No register context for path: {0}", path)), "NoRegisterContext", ErrorCategory.InvalidOperation, path); } } } // end ProcessRecord()
protected override void ProcessRecord() { // Support relative paths in PS. string dumpFileResolved = SessionState.Path.GetUnresolvedProviderPathFromPSPath(DumpFile); // TODO: don't check this here... catch and write instead if (!File.Exists(dumpFileResolved)) { // It could be wildcarded... unfortunately attaching to multiple dumps // doesn't seem to work. But if it only resolves to one file... let's // allow it. ProviderInfo dontCare; var multi = SessionState.Path.GetResolvedProviderPathFromPSPath(DumpFile, out dontCare); if ((null == multi) || (0 == multi.Count)) { ThrowTerminatingError(new FileNotFoundException(), "NoSuchDumpFile", ErrorCategory.ObjectNotFound, DumpFile); return; } else if (multi.Count > 1) { ThrowTerminatingError(new NotSupportedException("Attaching to multiple dump files does not really work."), "AttachToMultipleDumpsNotsupported", ErrorCategory.OpenError, DumpFile); return; } else { dumpFileResolved = multi[0]; } } if (String.IsNullOrEmpty(TargetName)) { TargetName = Path.GetFileNameWithoutExtension(dumpFileResolved); } if (DbgProvider.IsTargetNameInUse(TargetName)) { ThrowTerminatingError(new ArgumentException(Util.Sprintf("The target name '{0}' is already in use. Please use -TargetName to specify a different target name.", TargetName), "TargetName"), "TargetNameInUse", ErrorCategory.ResourceExists, TargetName); } Debugger = DbgEngDebugger.NewDebugger(); using (Debugger.SetCurrentCmdlet(this)) { Debugger.LoadCrashDump(dumpFileResolved, TargetName); base.ProcessRecord(true); } // end using( psPipe ) } // end ProcessRecord()
} // end InterceptCtrlC() protected override void ProcessRecord() { if (!DbgProvider.IsInGuestMode) { throw new InvalidOperationException("This command is only intended to be used by the !dbgshell implementation."); } LogManager.Trace("WaitForBangDbgShellCommandCommand.ProcessRecord: DbgShell is going dormant."); using (var disposer = new ExceptionGuard()) { disposer.Protect(SetDebuggerAndContextAndUpdateCallbacks()); disposer.Protect(InterceptCtrlC()); disposer.Protect(Debugger.SuspendEventOutput()); // don't want our "modload" output etc. spewing while we are dormant base.ProcessRecord(); // We need to perform the wait on another thread, because we need to "pump" // on this thread, so that debug event callbacks can queue WriteObject calls // to this thread. _RegisterWaitForGuestModeEvent(disposer); // Give the user a hint about what's going on. var s = new ColorString(ConsoleColor.DarkGray, "(DbgShell will remain running in the background until you run !dbgshell again)").ToString(true); Host.UI.WriteLine(s); MsgLoop.Prepare(); // This will allow the extension command to return (it tells the dbgeng // thread that it can return). DbgProvider.GuestModePassivate(); MsgLoop.Run(); // This will complete when the guest mode event gets signaled. } // end using( disposer ) } // end ProcessRecord()
public ScriptColumn(string label, ScriptBlock script, ColumnAlignment alignment, int width, string tag, TrimLocation trimLocation, bool captureContext) : base(alignment, width, tag, trimLocation) { if (String.IsNullOrEmpty(label)) { throw new ArgumentException("You must supply a column label.", "label"); } if (null == script) { throw new ArgumentNullException("script"); } m_label = label; Script = script; if (captureContext) { Context = DbgProvider.CapturePsContext(); } } // end constructor
protected override void ProcessRecord() { base.ProcessRecord(); Debugger.SetEffectiveProcessorType(EffectiveProcessorType); Debugger.AdjustAddressColumnWidths(Host.UI.RawUI.BufferSize.Width); DbgProvider.ForceRebuildNamespace(); } // end ProcessRecord()
protected override void ProcessRecord() { base.ProcessRecord(); try { if (Increment) { var ctx = Debugger.GetCurrentDbgEngContext(); _Worker(ctx.FrameIndex + 1, "CannotIncrementPastTopOfStack"); DbgProvider.SetAutoRepeatCommand(".f+"); } else if (Decrement) { var ctx = Debugger.GetCurrentDbgEngContext(); _Worker(ctx.FrameIndex - 1, "CannotDecrementPastBottomOfStack"); DbgProvider.SetAutoRepeatCommand(".f-"); } else { _Worker(FrameNumber, "StackFrameOutsideOfActualStack"); } } catch (DbgProviderException dpe) { WriteError(dpe); } DbgProvider.SetLocationByDebuggerContext(); } // end ProcessRecord()
} // end _GuestModeMainWrapper() private static int _GuestModeCleanup() { if (null == sm_altMainThread) { // Nothing to do. (I guess we were never started.) Util.Fail("currently not possible, therefore not tested"); } else { // We already have an alternate main thread, which is "paused" (blocked), // waiting to resume. Before we unblock it, we'll set this bit to let it // know that it should actually exit. DbgProvider.GuestModeTimeToExitAllTheWay = true; DbgProvider.GuestModeResume(); LogManager.Trace("Waiting for the DbgShell main thread."); sm_altMainThread.Join(); LogManager.Trace("_AltMainThread finished."); // Calling GuestModeFinalCleanup works even though we don't fire up the // DbgEngThread because the current thread has already been marked as the // thread that DbgEngThread's pump runs on, so it just runs synchronously. DbgProvider.GuestModeFinalCleanup(); } return(sm_exitCode); } // end _GuestModeCleanup()
protected override void ProcessRecord() { base.ProcessRecord(); // WriteObject( "\u009b91mThis should be red.\u009bm This should not.\r\n" ); // WriteObject( "\u009b91;41mThis should be red on red.\u009bm This should not.\r\n" ); // WriteObject( "\u009b91;100mThis should be red on gray.\u009b" ); // WriteObject( "m This should not.\r\n" ); // WriteObject( "\u009b" ); // WriteObject( "9" ); // WriteObject( "1;10" ); // WriteObject( "6mThis should be red on cyan.\u009b" ); // WriteObject( "m This should \u009bm\u009bmnot.\r\n" ); // //WriteObject( "\u009b92mModLoad:\u009bm 758a0000 758ac000 \u009b97mCRYPTBASE\u009bm\r\n" ); // //WriteObject( "\u009b92mModLoad:\u009bm 758a0000 758ac000 \u009b30;107mCRYPTBASE\u009bm\r\n" ); PathInfo pi = this.CurrentProviderLocation(DbgProvider.ProviderId); var debugger = DbgProvider.GetDebugger(pi.ProviderPath); debugger.SetContextByPath(pi.ProviderPath); } // end ProcessRecord()
protected IDisposable SetDebuggerAndContextAndUpdateCallbacks(string contextPath) { if (String.IsNullOrEmpty(contextPath)) { PathInfo pi = this.CurrentProviderLocation(DbgProvider.ProviderId); contextPath = pi.ProviderPath; } else { contextPath = GetUnresolvedProviderPathFromPSPath(contextPath); } Debugger = DbgProvider.GetDebugger(contextPath); if ((null == Debugger) || Debugger.NoTarget) { throw new DbgProviderException("No target.", "NoTarget", ErrorCategory.InvalidOperation); } var inputCallbacks = Debugger.GetInputCallbacks() as DebugInputCallbacks; if (null != inputCallbacks) { inputCallbacks.UpdateCmdlet(this); } var disposable = Debugger.SetCurrentCmdlet(this); Debugger.SetContextByPath(contextPath); return(disposable); } // end SetDebuggerAndContextAndUpdateCallbacks()
protected override void ProcessRecord() { ulong addr; if (0 != Address) { addr = Address; Util.Assert((c_Address_ScriptBlockCommand_ParamSet == this.ParameterSetName) || (c_Address_DbgEngCommand_ParamSet == this.ParameterSetName)); Expression = DbgProvider.FormatAddress(Address, Debugger.TargetIs32Bit, true).ToString(false); } else { if (DbgProvider.TryParseHexOrDecimalNumber(Expression, out addr)) { // Oh... PowerShell might have interpreted a backtick as an escape... // Let's fix it. Expression = DbgProvider.FormatAddress(addr, Debugger.TargetIs32Bit, true).ToString(false); } } if (0 != addr) { _CreateBp(addr); return; } // // We have a symbolic expression. Dbgeng may or may not like it. // // For instance, if it resolves to a function that got inlined, even if // there is only a single match, dbgeng will complain and say "please use // bm instead". // // I hate that, so we're just going to try tohandle the symbol lookup // ourselves. Also, it seems there isn't actually a way to do a "bm" // breakpoint via the API. // IList <ulong> addrs = _TryResolveExpression(); if (null != addrs) { // We may not actually have been able to resolve the expression, but it // wasn't obviously bad, in which case we'll have to set a deferred // breakpoint. if (0 == addrs.Count) { _CreateDeferredBp(); } else { foreach (ulong bpAddr in addrs) { Util.Assert(0 != bpAddr); _CreateBp(bpAddr); } } } } // end ProcessRecord()
} // end WriteError() internal void WriteError(ErrorRecord er, bool alreadyLogged) { if (!alreadyLogged) { DbgProvider.LogError(er); } ((PSCmdlet)this).WriteError(er); } // end WriteError()
protected override void ProcessRecord() { base.ProcessRecord(); PathInfo pi = this.CurrentProviderLocation(DbgProvider.ProviderId); var debugger = DbgProvider.GetDebugger(pi.ProviderPath); debugger.SetContextByPath(pi.ProviderPath); WDebugSymbols ds = (WDebugSymbols)debugger.DebuggerInterface; } // end ProcessRecord()
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { object originalInputData = inputData; var pso = inputData as PSObject; if (null != pso) { inputData = pso.BaseObject; } if (inputData is DbgTypeInfo) { return(inputData); } string path = engineIntrinsics.SessionState.Path.CurrentProviderLocation(DbgProvider.ProviderId).ProviderPath; var debugger = DbgProvider.GetDebugger(path); Exception e = null; string str = inputData as string; if (null != str) { try { // TODO: Would be nice to ask the PowerShell team to plumb cancellation support // through parameter transformation. var types = debugger.GetTypeInfoByName(str, System.Threading.CancellationToken.None).ToList(); if (null != types) { if (types.Count > 1) { engineIntrinsics.InvokeCommand.InvokeScript(Util.Sprintf("Write-Warning 'Multiple types found for name \"{0}\".'", str)); LogManager.Trace("Warning: TypeTransformationAttribute: found multiple types for name '{0}'.", str); } else if (0 != types.Count) { return(types[0]); } } } catch (DbgProviderException dpe) { e = dpe; } } // end if( it's a string ) throw CreateRecoverableAtme(e, "Type not found. (Could not convert '{0}' to a type.)", originalInputData); } // end Transform()
protected override void ProcessRecord() { base.ProcessRecord(); string dir = DbgProvider._TryFindDebuggersDir(); if (!String.IsNullOrEmpty(dir)) { WriteObject(dir); } } // end ProcessRecord()
protected void SafeWriteError(ErrorRecord er) { DbgProvider.LogError(er); if (IsOnPipelineThread) { IgnorePipelineStopped(() => WriteError(er, true)); } else { m_msgLoop.Post(() => WriteError(er, true)); } }
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { object originalInputData = inputData; var pso = inputData as PSObject; if (null != pso) { inputData = pso.BaseObject; } if (inputData is string) { return(inputData); } if (inputData is DbgModuleInfo) { return(((DbgModuleInfo)inputData).ImageName); } string path = engineIntrinsics.SessionState.Path.CurrentProviderLocation(DbgProvider.ProviderId).ProviderPath; var debugger = DbgProvider.GetDebugger(path); Exception e = null; // Maybe it is an address? try { object addrObj = AddressTransformationAttribute.Transform( engineIntrinsics, null, true, // skipGlobalSymbolTest false, // throwOnFailure originalInputData); if (null != addrObj) { var mod = new DbgModuleInfo(debugger, (ulong)addrObj, debugger.GetCurrentTarget()); return(mod.Name); } } catch (DbgEngException dee) { e = dee; } throw CreateRecoverableAtme(e, "Could not convert '{0}' to a module name.", originalInputData); } // end Transform()
public AltSingleLineViewDefinition(ScriptBlock script, bool captureContext) { if (null == script) { throw new ArgumentNullException("script"); } Script = script; if (captureContext) { Context = DbgProvider.CapturePsContext(); } } // end constructor
public Footer(ColumnAlignment alignment, ScriptBlock script, bool captureContext) { if (null == script) { throw new ArgumentNullException("script"); } Alignment = alignment; Script = script; if (captureContext) { Context = DbgProvider.CapturePsContext(); } }
protected override void ProcessRecord() { if (String.IsNullOrEmpty(TargetName)) { TargetName = Util.Sprintf("{0} ({1})", Path.GetFileNameWithoutExtension(FilePath), processId); } if (DbgProvider.IsTargetNameInUse(TargetName)) { ThrowTerminatingError(new ArgumentException(Util.Sprintf("The target name '{0}' is already in use. Please use -TargetName to specify a different target name.", TargetName), "TargetName"), "TargetNameInUse", ErrorCategory.ResourceExists, TargetName); } Debugger = DbgEngDebugger.NewDebugger(); CheckCanAddNewTargetType(DbgEngDebugger.TargetType.UmLive); using (Debugger.SetCurrentCmdlet(this)) { Debugger.ProcessCreated += DebuggerOnProcessCreated; Debugger.CreateProcessAndAttach2(_BuildCommandline(), StartDirectory, TargetName, SkipInitialBreakpoint, SkipFinalBreakpoint, NoDebugHeap, DebugChildProcesses, ConsoleOption); //Debugger.SetInputCallbacks( new DebugInputCallbacks( this ) ); //Debugger.SetOutputCallbacks( new DebugOutputCallbacks( this ) ); try { // will call Debugger.WaitForEvent() base.ProcessRecord(); } finally { Debugger.ProcessCreated -= DebuggerOnProcessCreated; } } // end using( current cmdlet ) } // end ProcessRecord()
public AltTableViewDefinition(bool showIndex, IReadOnlyList <Column> columns, Footer footer, ScriptBlock produceGroupByHeader, object groupBy, bool captureContext, bool preserveHeaderContext) : this(_ProduceColumns(showIndex, columns), footer, produceGroupByHeader, groupBy, captureContext ? DbgProvider.CapturePsContext() : null, preserveHeaderContext) { } // end constructor
// NOTE: If a derived class needs to override BeginProcessing, it should be sure // to call base.BeginProcessing() /before/ calling any of the SafeWrite* methods. protected override void BeginProcessing() { base.BeginProcessing(); m_pipelineThread = Thread.CurrentThread; if (LogCmdletOutline) { LogManager.Trace("---------------------------"); LogManager.Trace("BeginProcessing for command {0}: {1}", this, GetCommand()); } // You might think that the host should be the one to clear the auto-repeat // command, and in general, you'd be right. But the host doesn't actually get // involved with EVERY command that is run--it is only involved with every // /input/. And that input could be a script, and that script could run some // commands that set up an auto-repeat command (like stepping), and then run // some other commands (like .detach, or anything), leaving the auto-repeat // command set up, but the user definitely does not expect pressing [enter] // to step again (or do whatever the auto-repeat command was). So, for non- // formatting commands, we'll always start out by clearing the auto-repeat // command. (We exclude formatting commands, because then auto-repeat commands // would never work, because formatting commands are always tacked on to the // end of pipelines.) // // Note that this does not completely solve the problem, because cmdlets that // derive from DbgBaseCommand are not the only commands that could be run // after an auto-repeat command. But it at least helps. // // A more complete alternative might be to hook the PreCommandLookupAction and // clear the auto-repeat command there, but it would have to be a lot // trickier, because we'd need to do things like exclude auto-repeat-command- // clearing during execution of the "prompt" command, the PSReadline command, // etc. (in addition to formatting commands). if (!typeof(Formatting.Commands.FormatBaseCommand).IsAssignableFrom(GetType()) && !typeof(Formatting.Commands.GetAltFormatViewDefCommand).IsAssignableFrom(GetType())) { DbgProvider.SetAutoRepeatCommand(null); } if (TrySetDebuggerContext) { // Need to set context based on current path. PathInfo pi = this.CurrentProviderLocation(DbgProvider.ProviderId); string curPath = pi.ProviderPath; // It's okay if it fails (maybe current dir is "Dbg:\")--some commands don't // need a context. Debugger.TrySetContextByPath(curPath); } } // end BeginProcessing()
protected override void ProcessRecord() { base.ProcessRecord(); string mod; const string whackFmsg = "The '/f' syntax does not work with PowerShell parameters. Use '-f' instead."; mod = Module; if (0 == Util.Strcmp_OI(mod, "/f")) { if ((null == Compat) || (0 == Compat.Length)) { WriteError(new ArgumentException(whackFmsg), "BadParamWhackF", ErrorCategory.InvalidArgument, null); return; } WriteWarning(whackFmsg); // Let's just hope this works. mod = Compat[0]; Force = true; } if ((null != Compat) && (0 != Compat.Length)) { if (0 == Util.Strcmp_OI(Compat[0], "/f")) { WriteWarning(whackFmsg); Force = true; } } SafeWriteVerbose("Reloading symbols for {0}", mod); Debugger.ReloadSymbols(mod, Literal, Address, Size, Timestamp, Force, IgnoreMismatched, OverwriteDownstream, Unload); // We want stacks to get re-generated if we got new symbols. DbgProvider.ForceRebuildNamespace(); } // end ProcessRecord()
protected void RebuildNamespaceAndSetLocationBasedOnDebuggerContext(bool outputRegisters, DbgRegisterSetBase baselineRegisters) { string newCurrentPath = DbgProvider.SetLocationByDebuggerContext(); if (outputRegisters && (null != newCurrentPath)) { // This basically just removes the leading whack. string providerPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(newCurrentPath); var regSet = DbgProvider.GetRegisterSetForPath(providerPath, baselineRegisters); if (null != regSet) { // TODO: Set ReadDbgAssemblyCommand.NextAddrToDisassemble here? (and the others) SafeWriteObject(regSet); } } } // end SetLocationBasedOnDebuggerContext()
private ColorString FormatRGB(uint numColumns, bool withAlpha) { var bytes = Memory.Bytes; bool is32Bit = Debugger.TargetIs32Bit; ulong startAddress = Memory.StartAddress; if (0 == numColumns) { numColumns = 64; } ColorString cs = new ColorString(); var bytesPerCharacter = withAlpha ? 4 : 3; int bytesPerRow = (int)numColumns * bytesPerCharacter + 3 & ~(3); //round up for (int rowStart = 0; rowStart + bytesPerCharacter < bytes.Count; rowStart += bytesPerRow) { if (rowStart != 0) { cs.AppendLine(); } cs.Append(DbgProvider.FormatAddress(startAddress + (uint)rowStart, is32Bit, true, true)).Append(" "); var rowLen = Math.Min(bytes.Count - rowStart, bytesPerRow); for (int colOffset = 0; colOffset + bytesPerCharacter < rowLen; colOffset += bytesPerCharacter) { byte b = bytes[rowStart + colOffset + 0]; byte g = bytes[rowStart + colOffset + 1]; byte r = bytes[rowStart + colOffset + 2]; string ch = "█"; if (withAlpha) { ch = AlphaChars[bytes[rowStart + colOffset + 3] >> 6]; } cs.AppendFgRgb(r, g, b, ch); } } return(cs.MakeReadOnly()); }
} // end ProcessRecord() private void _UnassembleInstructions(ulong addr, Func <ulong, bool> keepGoing) { ColorString csBlockId; try { ulong disp; var addrName = Debugger.GetNameByOffset(addr, out disp); csBlockId = DbgProvider.ColorizeSymbol(addrName); if (0 != disp) { csBlockId.Append(Util.Sprintf("+{0:x}", disp)); } } catch (DbgEngException) { // Ignore. We'll just use the address as the block id. If we really can't // get the memory there, we'll fail with a good error message later. csBlockId = new ColorString().Append(DbgProvider.FormatAddress(addr, Debugger.TargetIs32Bit, true)); } csBlockId.Append(":").MakeReadOnly(); bool hasCodeBytes = !Debugger.AssemblyOptions.HasFlag(DbgAssemblyOptions.NoCodeBytes); while (keepGoing(addr)) { ulong tmpAddr = addr; string disasm = Debugger.Disassemble(tmpAddr, out addr).Trim(); WriteObject(_ParseDisassembly(tmpAddr, disasm, csBlockId, hasCodeBytes)); } DbgProvider.SetAutoRepeatCommand(Util.Sprintf("{0} -Address 0x{1} -InstructionCount {2}", MyInvocation.InvocationName, addr.ToString("x"), InstructionCount)); NextAddrToDisassemble = addr; } // end _UnassembleInstructions()
public AltListViewDefinition(IReadOnlyList <ListItem> listItems, ScriptBlock produceGroupByHeader, object groupBy, bool captureContext, bool preserveHeaderContext) { if (null == listItems) { throw new ArgumentNullException("listItems"); } ListItems = listItems; ProduceGroupByHeader = produceGroupByHeader; GroupBy = groupBy; PreserveHeaderContext = preserveHeaderContext; if (captureContext) { Context = DbgProvider.CapturePsContext(); } } // end constructor
public ScriptListItem(string label, ScriptBlock script, bool captureContext) { if (String.IsNullOrEmpty(label)) { throw new ArgumentException("You must supply a label.", "label"); } if (null == script) { throw new ArgumentNullException("script"); } m_label = label; Script = script; if (captureContext) { Context = DbgProvider.CapturePsContext(); } else { Context = new PsContext(); } } // end constructor
public AltCustomViewDefinition(ScriptBlock script, ScriptBlock produceGroupByHeader, object groupBy, ScriptBlock end, bool captureContext, bool preserveHeaderContext, bool preserveScriptContext) { if (null == script) { throw new ArgumentNullException("script"); } Script = script; ProduceGroupByHeader = produceGroupByHeader; GroupBy = groupBy; End = end; PreserveHeaderContext = preserveHeaderContext; PreserveScriptContext = preserveScriptContext; if (captureContext) { Context = DbgProvider.CapturePsContext(); } } // end constructor
/// <summary> /// This method is "best effort"--it probably won't screen out all possible /// invalid breakpoints. But it should hopefully catch some obviously bad ones. /// </summary> private void _TryValidateBp(ref DbgBreakpointInfo bp) { bool bpIsActuallyBogus = false; if (bp.IsEnabled) { if (bp.IsDeferred) { try { Util.Assert(!String.IsNullOrEmpty(Expression)); // TODO: What if the expression is not a symbol?? string mod, bareSym; ulong offset; DbgProvider.ParseSymbolName(Expression, out mod, out bareSym, out offset); if ("*" == mod) { bpIsActuallyBogus = true; } else { var modInfos = Debugger.GetModuleByName(mod).ToArray(); if (modInfos.Length > 0) { // The module is loaded and yet the bp is deferred... the // expression is no good. // // Or there is more than one module with that name. bpIsActuallyBogus = true; } } } catch (ArgumentException ae) { LogManager.Trace("Failed to parse expression as a symbol: {0}", Util.GetExceptionMessages(ae)); } } // end if( bp is deferred ) else if (0 != bp.Offset) { // The address shouldn't be invalid, because that would indicate the // bp is deferred, but we already checked for that. Util.Assert(bp.Offset != DebuggerObject.InvalidAddress); MEMORY_BASIC_INFORMATION64 mbi; int hr = Debugger.TryQueryVirtual(bp.Offset, out mbi); if (hr != 0) { // iDNA targets don't yet handle QueryVirtual. if (hr != DebuggerObject.E_NOTIMPL) { LogManager.Trace("_TryValidateBp: TryQueryVirtual failed: {0}", Util.FormatErrorCode(hr)); bpIsActuallyBogus = true; } } else { if ((mbi.Protect != PAGE.EXECUTE) && (mbi.Protect != PAGE.EXECUTE_READ) && // <-- (mbi.Protect != PAGE.EXECUTE_READWRITE) && // <-- I don't actually know what these are (mbi.Protect != PAGE.EXECUTE_WRITECOPY)) // <-- { bpIsActuallyBogus = true; } } } } // end if( bp is enabled ) if (bpIsActuallyBogus) { ulong addr = 0; if ((bp.Offset != 0) && (bp.Offset != DebuggerObject.InvalidAddress)) { addr = bp.Offset; } Debugger.RemoveBreakpoint(ref bp); var dpe = new DbgProviderException(Util.Sprintf("Failed to set breakpoint at {0}.", addr != 0 ? DbgProvider.FormatAddress(addr, Debugger.TargetIs32Bit, true).ToString(false) : Expression), "BpEnabledButDeferredAndOrBad", ErrorCategory.InvalidArgument, addr != 0 ? (object)addr : (object)Expression); try { throw dpe; } catch { } // give it a stack WriteError(dpe); } } // end _TryValidateBp()