public void SetUp() { var breakpointFactory = new RemoteBreakpointFactory(); mockBreakpoint = Substitute.For <SbBreakpoint>(); remoteBreakpoint = breakpointFactory.Create(mockBreakpoint); mockTarget = Substitute.For <SbTarget>(); remoteTarget = new RemoteTargetFactory(breakpointFactory).Create(mockTarget); mockFunction = Substitute.For <SbFunction>(); }
public BreakpointErrorPair CreateFunctionOffsetBreakpoint(string symbolName, uint offset) { RemoteBreakpoint functionBreakpoint = BreakpointCreateByName(symbolName); if (functionBreakpoint.GetNumLocations() < 1) { return(new BreakpointErrorPair(null, BreakpointError.NoFunctionLocation)); } // At the moment if there are two functions with the same offset will be applied only // for one of them. In base VS 2017 the breakpoint is created only for one // function if there are overloaded functions. SbFunction function = functionBreakpoint.GetLocationAtIndex(0).GetAddress().GetFunction(); // Delete the breakpoint as we don't need it anymore and don't want it to linger _sbTarget.BreakpointDelete(functionBreakpoint.GetId()); if (function == null) { return(new BreakpointErrorPair(null, BreakpointError.NoFunctionFound)); } SbLineEntry startLineEntry = function.GetStartAddress().GetLineEntry(); uint startLine = startLineEntry.GetLine(); // EndAddress points to the first address after the function so we // subtract one from that address and get the corresponding lineEntry. SbAddress endAddress = function.GetEndAddress(); ulong address = endAddress.GetLoadAddress(_sbTarget); endAddress = ResolveLoadAddress(address - 1); uint endLine = endAddress.GetLineEntry().GetLine(); uint newPosition = startLine + offset + 1; if (newPosition > endLine) { return(new BreakpointErrorPair(null, BreakpointError.PositionNotAvailable)); } string fileName = startLineEntry.GetFileName(); string directory = startLineEntry.GetDirectory(); string path = Path.Combine(directory, fileName); RemoteBreakpoint breakpoint = BreakpointCreateByLocation(path, newPosition); return(new BreakpointErrorPair(breakpoint, BreakpointError.Success)); }
public void SetUp() { mockTarget = Substitute.For <SbTarget>(); remoteTarget = new RemoteTargetFactory(new RemoteBreakpointFactory()) .Create(mockTarget); mockAddress = Substitute.For <SbAddress>(); mockProcess = Substitute.For <SbProcess>(); mockMemoryRegion = Substitute.For <SbMemoryRegionInfo>(); mockError = Substitute.For <SbError>(); mockBreakpoint = Substitute.For <SbBreakpoint>(); remoteBreakpoint = new RemoteBreakpointFactory().Create(mockBreakpoint); mockFunction = Substitute.For <SbFunction>(); mockTarget.GetProcess().Returns(mockProcess); }
public override Task <GetFunctionResponse> GetFunction(GetFunctionRequest request, ServerCallContext context) { RemoteFrame frame = frameStore.GetObject(request.Frame.Id); SbFunction function = frame.GetFunction(); var response = new GetFunctionResponse(); if (function != null) { response.Function = new GrpcSbFunction { Id = functionStore.AddObject(function) }; } return(Task.FromResult(response)); }
string GetArguments(FrameInfoFlags fields) { SbFunction frameFunction = _sbFrame.GetFunction(); SbTypeList typeList = frameFunction?.GetType()?.GetFunctionArgumentTypes(); if (typeList == null || typeList.GetSize() == 0) { return(""); } List <SbValue> valueList = null; if ((fields & FrameInfoFlags.FIF_FUNCNAME_ARGS_VALUES) != 0) { valueList = _sbFrame.GetVariables(true, false, false, false); } // We should skip the "this" argument. Ideally we would query if // a function is a method, but there is no such query. Instead, // we literally skip the "this" argument. uint argBase = frameFunction.GetArgumentName(0) == "this" ? 1u : 0u; var result = new StringBuilder(); uint argumentCount = typeList.GetSize(); for (uint i = 0; i < argumentCount; i++) { if (i > 0) { result.Append(", "); } if ((fields & FrameInfoFlags.FIF_FUNCNAME_ARGS_TYPES) != 0) { result.Append(typeList.GetTypeAtIndex(i).GetName()); } if ((fields & FrameInfoFlags.FIF_FUNCNAME_ARGS_NAMES) != 0) { // If we are showing types and names, add a space between them. if ((fields & FrameInfoFlags.FIF_FUNCNAME_ARGS_TYPES) != 0) { result.Append(" "); } result.Append(frameFunction.GetArgumentName(argBase + i)); } if ((fields & FrameInfoFlags.FIF_FUNCNAME_ARGS_VALUES) != 0) { // In some cases the values are missing (e.g., with incomplete debug info // when doing Debug.ListCallStack in VS's Command Window on crash dump). // Let us handle that case gracefully. int index = (int)(argBase + i); if (index < valueList.Count) { // If we are showing types or names and values, show an equals sign // between them. if ((fields & FrameInfoFlags.FIF_FUNCNAME_ARGS_TYPES) != 0 || (fields & FrameInfoFlags.FIF_FUNCNAME_ARGS_NAMES) != 0) { result.Append(" = "); } result.Append(valueList[index].GetValue()); } } } return(result.ToString()); }