public int GetCodeContext(ulong codeLocationId, out IDebugCodeContext2 codeContext) { // The codeContext is used, among other things, to link assembly instructions and // source code. The "Go To Source Code" functionality in disassembly view needs this // to be properly implemented. IDebugDocumentContext2 documentContext = null; if (_lineEntryCache.TryGetValue(codeLocationId, out LineEntryInfo lineEntry)) { documentContext = _documentContextFactory.Create(lineEntry); } else { SbAddress address = _target.ResolveLoadAddress(codeLocationId); if (address != null) { lineEntry = address.GetLineEntry(); documentContext = _documentContextFactory.Create(lineEntry); } } string AddressToFuncName() => _target.ResolveLoadAddress(codeLocationId)?.GetFunction()?.GetName() ?? _codeContextName; codeContext = _codeContextFactory.Create(codeLocationId, new Lazy <string>(AddressToFuncName), documentContext, Guid.Empty); return(VSConstants.S_OK); }
IDebugDocumentContext2 CreateDocumentContext() { LineEntryInfo lineEntry = lldbFrame.GetLineEntry(); return(lineEntry != null ? debugDocumentContextFactory.Create(lineEntry) : null); }
// Constructor with factories for tests. DebugBoundBreakpoint(DebugDocumentContext.Factory documentContextFactory, DebugCodeContext.Factory codeContextFactory, DebugBreakpointResolution.Factory breakpointResolutionFactory, IDebugPendingBreakpoint2 pendingBreakpoint, SbBreakpointLocation breakpointLocation, IDebugProgram2 program, Guid languageGuid) { _pendingBreakpoint = pendingBreakpoint; _breakpointLocation = breakpointLocation; _enabled = true; _deleted = false; _disabledByPassCount = false; SbAddress address = breakpointLocation.GetAddress(); if (address != null) { LineEntryInfo lineEntry = address.GetLineEntry(); IDebugDocumentContext2 documentContext = null; string name = ""; // |lineEntry| is null if the breakpoint is set on an external function. if (lineEntry != null) { documentContext = documentContextFactory.Create(lineEntry); documentContext.GetName(enum_GETNAME_TYPE.GN_NAME, out name); } IDebugCodeContext2 codeContext = codeContextFactory.Create( breakpointLocation.GetLoadAddress(), name, documentContext, languageGuid); _breakpointResolution = breakpointResolutionFactory.Create(codeContext, program); } else { Trace.WriteLine("Warning: Unable to obtain address from breakpoint location." + " No breakpoint resolution created."); } }