public DbgManagedFunction(DbgEngDebugger debugger, DbgEngContext context, ClrMethod method) : base(debugger, context, method.NativeCode, method.Name) { m_clrMethod = method; } // end constructor()
public static bool TryCreateFunction(DbgEngDebugger debugger, DbgEngContext context, DEBUG_STACK_FRAME_EX nativeStackFrame, out DbgFunction function, out ulong displacement) { function = null; displacement = 0; DbgSymbol sym = null; try { SymbolInfo si = DbgHelp.SymFromInlineContext(debugger.DebuggerInterface, nativeStackFrame.InstructionOffset, nativeStackFrame.InlineFrameContext, out displacement); sym = new DbgPublicSymbol(debugger, si, debugger.GetCurrentTarget()); function = new DbgNativeFunction(debugger, context, sym); return(true); } catch (DbgProviderException dpe) { // Sometimes the debugger doesn't know. E.g., frame 'e' here (from ntsd): // 0:000> kn // # Child-SP RetAddr Call Site // 00 00000000`0058dff8 00000000`76c02ef8 ntdll!NtRequestWaitReplyPort+0xa // 01 00000000`0058e000 00000000`76c352d1 kernel32!GetConsoleMode+0xf8 // 02 00000000`0058e030 00000000`76c4a60c kernel32!VerifyConsoleIoHandle+0x281 // 03 00000000`0058e180 000007fe`fae30fe1 kernel32!ReadConsoleW+0xbc // 04 00000000`0058e260 000007fe`fae1eb88 Microsoft_PowerShell_ConsoleHost_ni+0x70fe1 // 05 00000000`0058e390 000007fe`fae2a7e2 Microsoft_PowerShell_ConsoleHost_ni+0x5eb88 // 06 00000000`0058e410 000007fe`fae29fae Microsoft_PowerShell_ConsoleHost_ni+0x6a7e2 // 07 00000000`0058e4c0 000007fe`fae32bd1 Microsoft_PowerShell_ConsoleHost_ni+0x69fae // 08 00000000`0058e5b0 000007fe`fae235c6 Microsoft_PowerShell_ConsoleHost_ni+0x72bd1 // 09 00000000`0058e670 000007fe`fae23f27 Microsoft_PowerShell_ConsoleHost_ni+0x635c6 // 0a 00000000`0058e6d0 000007fe`fade5006 Microsoft_PowerShell_ConsoleHost_ni+0x63f27 // 0b 00000000`0058e760 000007fe`fade2c1a Microsoft_PowerShell_ConsoleHost_ni+0x25006 // 0c 00000000`0058e7e0 000007fe`fae33588 Microsoft_PowerShell_ConsoleHost_ni+0x22c1a // 0d 00000000`0058e890 000007fe`97f805de Microsoft_PowerShell_ConsoleHost_ni+0x73588 // 0e 00000000`0058e8f0 000007fe`f777dad3 0x000007fe`97f805de // 0f 00000000`0058ea80 000007fe`f777d7ae clr!PreBindAssemblyEx+0x13e07 // 10 00000000`0058eac0 000007fe`f777d830 clr!PreBindAssemblyEx+0x13ae2 // 11 00000000`0058eb00 000007fe`f76d0f3b clr!PreBindAssemblyEx+0x13b64 // 12 00000000`0058ecb0 000007fe`f76a9e5a clr!GetHistoryFileDirectory+0x945b // 13 00000000`0058ee80 000007fe`f76a9d54 clr!InitializeFusion+0x8b12 // 14 00000000`0058f170 000007fe`f76a98ce clr!InitializeFusion+0x8a0c // 15 00000000`0058f730 000007fe`f76a9826 clr!InitializeFusion+0x8586 // 16 00000000`0058f7a0 000007fe`f76aa078 clr!InitializeFusion+0x84de // 17 00000000`0058f830 000007fe`f8247b95 clr!CorExeMain+0x14 // 18 00000000`0058f870 000007fe`f82e5b21 mscoreei!CorExeMain+0x5d // 19 00000000`0058f8c0 00000000`76bf652d mscoree!CorExeMain+0x69 // 1a 00000000`0058f8f0 00000000`772ec521 kernel32!BaseThreadInitThunk+0xd // 1b 00000000`0058f920 00000000`00000000 ntdll!RtlUserThreadStart+0x21 LogManager.Trace("Could not get symbol for stack frame {0} on thread index {1}. Error: {2}", nativeStackFrame.FrameNumber, context.ThreadIndexOrAddress, Util.GetExceptionMessages(dpe)); } return(false); } // end TryCreateFunction()
public DbgNativeFunction(DbgEngDebugger debugger, DbgEngContext context, DbgSymbol symbol) : base(debugger, context, symbol.Address, symbol.Name) { m_sym = symbol; } // end constructor()
public DbgSymbolGroup(DbgEngDebugger debugger, DEBUG_SCOPE_GROUP scope, DbgStackFrameInfo frame, DbgEngContext context) : base(debugger) { if (null == context) { context = debugger.GetCurrentDbgEngContext(); } if (null == frame) { frame = debugger.GetCurrentScopeFrame(); } Context = context; Frame = frame; using (new DbgEngContextSaver(debugger, context)) { debugger.ExecuteOnDbgEngThread(() => { WDebugSymbols ds5 = (WDebugSymbols)debugger.DebuggerInterface; WDebugSymbolGroup symGroup; CheckHr(ds5.GetScopeSymbolGroup2(scope, null, out symGroup)); m_symGroup = symGroup; Target = debugger.GetCurrentTarget(); }); } } // end constructor
internal DbgUModeProcess(DbgEngDebugger debugger, DbgEngContext context, uint osProcessId, string targetFriendlyName) : base(debugger, context, targetFriendlyName) { m_osProcessId = osProcessId; } // end constructor
private DbgUnknownFunction(DbgEngDebugger debugger, DbgEngContext context, DEBUG_STACK_FRAME_EX nativeFrame, ulong address, string modName, string funcName) : base(debugger, context, address, funcName) { NativeFrameEx = nativeFrame; m_modName = modName; } // end constructor()
} // _SetContext() public SymbolIdentity(string name, ulong moduleBase, ulong offset, DbgNamedTypeInfo type, DbgEngContext processContext) { Name = name; ModuleBase = moduleBase; Offset = offset; Type = type; _SetContext(processContext); } // end constructor
internal DbgTarget(DbgEngDebugger debugger, DbgEngContext context, string targetFriendlyName) : base(debugger) { Context = context.AsTargetContext(); // We are currently assuming that the current context is the target context // (if it were not, the IsLive call below might be wrong). Util.Assert(Context == debugger.GetCurrentDbgEngContext().AsTargetContext()); IsLive = Debugger.IsLive; m_targetFriendlyName = targetFriendlyName; } // end constructor
} // end constructor private void _SetContext(DbgEngContext context) { if (null == context) { throw new ArgumentNullException("context"); } //ProcessContext = context.AsProcessContext(); // TODO: for symbols for a user-mode module in a kernel mode target, // do I want to keep the process portion of the context? //ProcessContext = context.AsTargetContext(); ProcessContext = context.WithoutThreadOrFrameIndex(); } // _SetContext()
} // end constructor() public static DbgUnknownFunction Create(DbgEngDebugger debugger, DbgEngContext context, DEBUG_STACK_FRAME_EX nativeFrame) { ulong address = nativeFrame.InstructionOffset; string modName = null; string funcName = null; ulong offset = 0; string fullname = null; // If our dbgeng has managed support (or support for whatever this is), let's // try that: if (0 != nativeFrame.InstructionOffset) { fullname = debugger.TryGetInfoFromFrame(nativeFrame, out modName, out funcName, out offset); if (String.IsNullOrEmpty(fullname)) { LogManager.Trace("DbgUnknownFunction.Create: dbgeng doesn't know, either."); } } else { LogManager.Trace("DbgUnknownFunction.Create: we have no chance with an InstructionOffset of zero."); } if (String.IsNullOrEmpty(fullname)) { funcName = DbgProvider.FormatUInt64(address, useTick: true); } else { address = address - offset; } return(new DbgUnknownFunction(debugger, context, nativeFrame, address, modName, funcName)); } // end static Create() factory
public DbgEngContextSaver(DbgEngDebugger debugger, DbgEngContext temporaryContext) { if (null == debugger) { throw new ArgumentNullException("debugger"); } if (null == temporaryContext) { throw new ArgumentNullException("temporaryContext"); } m_debugger = debugger; m_oldContext = debugger.GetCurrentDbgEngContext(); Context = temporaryContext; debugger.SetCurrentDbgEngContext(temporaryContext, true); } // end constructor
internal DbgTarget(DbgEngDebugger debugger, DbgEngContext context, string targetFriendlyName) : base(debugger) { if ((bool)context.IsKernelContext) { Context = context.AsSystemContext(); } else { Context = context.AsProcessContext(); } IsLive = Debugger.IsLive; m_targetFriendlyName = targetFriendlyName; } // end constructor
} // end constructor public SymbolIdentity(string name, DEBUG_SYMBOL_PARAMETERS nativeParams, DEBUG_SYMBOL_ENTRY?dse, DbgEngContext processContext) { Name = name; ModuleBase = nativeParams.Module; if (null == dse) { Offset = DebuggerObject.InvalidAddress; } else { Offset = ((DEBUG_SYMBOL_ENTRY)dse).Offset; } _SetContext(processContext); } // end constructor
private static DEBUG_MODULE_PARAMETERS _GetModParamsByAddress(DbgEngDebugger debugger, DbgEngContext ctx, WDebugSymbols ds, ulong addressInModule) { if (null == debugger) { throw new ArgumentNullException("debugger"); } if (0 == addressInModule) { throw new ArgumentException("You must supply a non-zero address.", "addressInModule"); } return(debugger.ExecuteOnDbgEngThread(() => { using (new DbgEngContextSaver(debugger, ctx)) { if (null == ds) { ds = (WDebugSymbols)debugger.DebuggerInterface; } uint index; ulong baseAddr; // TODO: If it's a managed module, this will fail. We could use // ClrMd to synthesize this DbgModule instead. // https://github.com/Microsoft/DbgShell/issues/35 StaticCheckHr(ds.GetModuleByOffset2(addressInModule, 0, // start index DEBUG_GETMOD.DEFAULT, out index, out baseAddr)); DEBUG_MODULE_PARAMETERS[] modParams; StaticCheckHr(ds.GetModuleParameters(1, null, index, out modParams)); Util.Assert(1 == modParams.Length); return modParams[0]; } })); } // end _GetModParamsByAddress()
internal DbgUModeThreadInfo(DbgEngDebugger debugger, DbgEngContext context, uint sysTid) : base(debugger) { if (null == context) { throw new ArgumentNullException("context"); } if ((context.SystemIndex < 0) || (context.ProcessIndexOrAddress < 0) || (context.ThreadIndexOrAddress < 0) || (context.FrameIndex != 0)) { throw new ArgumentException("You must specify the system, process, and thread index, and a frame index of 0.", "context"); } Context = context; Tid = sysTid; } // end constructor
protected DbgFunction(DbgEngDebugger debugger, DbgEngContext context, ulong address, string name) : base(debugger) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("You must specify a name.", "name"); } if (null == context) { throw new ArgumentNullException("context"); } // We don't actually want thread/frame info in the context, I think. We just // want enough to identify what address space it refers to. Context = context.AsProcessContext(); Address = address; Name = name; } // end constructor()
private static DEBUG_MODULE_PARAMETERS _GetModParamsByAddress(DbgEngDebugger debugger, DbgEngContext ctx, WDebugSymbols ds, ulong addressInModule) { if (null == debugger) { throw new ArgumentNullException("debugger"); } if (0 == addressInModule) { throw new ArgumentException("You must supply a non-zero address.", "addressInModule"); } return(debugger.ExecuteOnDbgEngThread(() => { using (new DbgEngContextSaver(debugger, ctx)) { if (null == ds) { ds = (WDebugSymbols)debugger.DebuggerInterface; } uint index; ulong baseAddr; StaticCheckHr(ds.GetModuleByOffset2(addressInModule, 0, // start index DEBUG_GETMOD.DEFAULT, out index, out baseAddr)); DEBUG_MODULE_PARAMETERS[] modParams; StaticCheckHr(ds.GetModuleParameters(1, null, index, out modParams)); Util.Assert(1 == modParams.Length); return modParams[0]; } })); } // end _GetModParamsByAddress()
internal DbgTarget(DbgEngDebugger debugger, DbgEngContext context) : this(debugger, context, null) { }
// N.B. This assumes that the current debugger context is what is being represented. // internal DbgUModeProcess( DbgEngDebugger debugger ) // : this( debugger, debugger.GetCurrentDbgEngContext() ) // { // } internal DbgUModeProcess(DbgEngDebugger debugger, DbgEngContext context) : this(debugger, context, DEBUG_ANY_ID) { }
internal DbgUModeProcess(DbgEngDebugger debugger, DbgEngContext context, uint osProcessId) : this(debugger, context, osProcessId, null) { }
internal DbgKModeTarget(DbgEngDebugger debugger, DbgEngContext context, string targetFriendlyName) : base(debugger, context, targetFriendlyName) { } // end constructor