//this constructor is private because it should only be used internally to create children private VariableInformation(TupleValue results, VariableInformation parent) : this(parent._ctx, parent._engine, parent.Client) { TypeName = results.TryFindString("type"); Value = results.TryFindString("value"); Name = results.FindString("exp"); CountChildren = results.FindUint("numchild"); int index; if (!results.Contains("value") && (Name == TypeName || Name.Contains("::"))) { // base classes show up with no value and exp==type // (sometimes underlying debugger does not follow this convention, when using typedefs in templated types so look for "::" in the field name too) Name = "base"; Value = TypeName; VariableNodeType = NodeType.BaseClass; } else if (Int32.TryParse(this.Name, System.Globalization.NumberStyles.Integer, null, out index)) // array element { Name = '[' + this.Name + ']'; VariableNodeType = NodeType.ArrayElement; } else { _strippedName = Name; VariableNodeType = NodeType.Field; } _internalName = results.FindString("name"); IsChild = true; _format = parent._format; // inherit formatting _parent = parent.VariableNodeType == NodeType.AccessQualifier ? parent._parent : parent; }
//this constructor is private because it should only be used internally to create children private VariableInformation(TupleValue results, VariableInformation parent, string name = null) : this(parent._ctx, parent._engine, parent.Client) { TypeName = results.TryFindString("type"); Value = results.TryFindString("value"); Name = name ?? results.FindString("exp"); if (results.Contains("dynamic")) { CountChildren = 1; } else { CountChildren = results.FindUint("numchild"); } if (results.Contains("displayhint")) { DisplayHint = results.FindString("displayhint"); } if (results.Contains("attributes")) { if (results.FindString("attributes") == "noneditable") { _isReadonly = true; } _attribsFetched = true; } int index; if (!results.Contains("value") && (Name == TypeName || Name.Contains("::"))) { // base classes show up with no value and exp==type // (sometimes underlying debugger does not follow this convention, when using typedefs in templated types so look for "::" in the field name too) Name = TypeName + " (base)"; Value = TypeName; VariableNodeType = NodeType.BaseClass; } else if (Int32.TryParse(this.Name, System.Globalization.NumberStyles.Integer, null, out index)) // array element { Name = '[' + this.Name + ']'; VariableNodeType = NodeType.ArrayElement; } else if (this.Name.Length > 2 && this.Name[0] == '[' && this.Name[this.Name.Length - 1] == ']') { VariableNodeType = NodeType.ArrayElement; } else { _strippedName = Name; VariableNodeType = NodeType.Field; } _internalName = results.FindString("name"); IsChild = true; _format = parent._format; // inherit formatting _parent = parent.VariableNodeType == NodeType.AccessQualifier ? parent._parent : parent; this.PropertyInfoFlags = parent.PropertyInfoFlags; }
} // name as it appears in the debug symbols internal BoundBreakpoint(PendingBreakpoint parent, TupleValue bindinfo) { this.Addr = bindinfo.TryFindAddr("addr") ?? 0; this.FunctionName = bindinfo.TryFindString("func"); this.Enabled = bindinfo.TryFindString("enabled") == "n" ? false : true; this.HitCount = 0; this.CompiledFileName = bindinfo.Contains("fullname") ? bindinfo.FindString("fullname") : bindinfo.TryFindString("file"); this.Number = bindinfo.Contains("number") ? bindinfo.FindString("number") : parent.Number; _parent = parent; _textPosition = MITextPosition.TryParse(parent.DebuggedProcess, bindinfo); }
internal async Task <uint> ReadProcessMemory(ulong address, uint count, byte[] bytes) { string cmd = "-data-read-memory-bytes " + EngineUtils.AsAddr(address) + " " + count.ToString(); Results results = await CmdAsync(cmd, ResultClass.None); if (results.ResultClass == ResultClass.error) { return(uint.MaxValue); } ValueListValue mem = results.Find <ValueListValue>("memory"); if (mem.IsEmpty()) { return(0); } TupleValue res = mem.Content[0] as TupleValue; if (res == null) { return(0); } ulong start = res.FindAddr("begin"); ulong end = res.FindAddr("end"); ulong offset = res.FindAddr("offset"); // for some reason this is formatted as hex string content = res.FindString("contents"); uint toRead = (uint)content.Length / 2; if (toRead > count) { toRead = count; } // ensure the buffer contains the desired bytes. if (start + offset != address) { throw new MIException(Constants.E_FAIL); } for (int pos = 0; pos < toRead; ++pos) { // Decode one byte string strByte = content.Substring(pos * 2, 2); bytes[pos] = Convert.ToByte(strByte, 16); } return(toRead); }
private static BindResult EvalBindWatchResult(Results bindResult, AD7PendingBreakpoint pbreak, string address, uint size) { string errormsg = "Unknown error"; if (bindResult.ResultClass == ResultClass.error) { if (bindResult.Contains("msg")) { errormsg = bindResult.FindString("msg"); } if (String.IsNullOrWhiteSpace(errormsg)) { errormsg = "Unknown error"; } return(new BindResult(errormsg)); } else if (bindResult.ResultClass != ResultClass.done) { return(new BindResult(errormsg)); } TupleValue bkpt = null; if (bindResult.Contains("wpt")) { ResultValue b = bindResult.Find("wpt"); if (b is TupleValue) { bkpt = b as TupleValue; } } else { return(new BindResult(errormsg)); } string number = bkpt.FindString("number"); PendingBreakpoint bp = new PendingBreakpoint(pbreak, number, MIBreakpointState.Single); BoundBreakpoint bbp = new BoundBreakpoint(bp, MICore.Debugger.ParseAddr(address), size); return(new BindResult(bp, bbp)); }
private static BindResult EvalBindResult(Results bindResult, AD7PendingBreakpoint pbreak) { string errormsg = "Unknown error"; if (bindResult.ResultClass == ResultClass.error) { if (bindResult.Contains("msg")) { errormsg = bindResult.FindString("msg"); } if (String.IsNullOrWhiteSpace(errormsg)) { errormsg = "Unknown error"; } return(new BindResult(errormsg)); } else if (bindResult.ResultClass != ResultClass.done) { return(new BindResult(errormsg)); } TupleValue bkpt = null; ValueListValue list = null; if (bindResult.Contains("bkpt")) { ResultValue b = bindResult.Find("bkpt"); if (b is TupleValue) { bkpt = b as TupleValue; } else if (b is ValueListValue) { // "<MULTIPLE>" sometimes includes a list of bound breakpoints list = b as ValueListValue; bkpt = list.Content[0] as TupleValue; } } else { // If the source file is not found, "done" is the result without a binding // (the error is sent via an "&" string and hence lost) return(new BindResult(errormsg)); } Debug.Assert(bkpt.FindString("type") == "breakpoint"); string number = bkpt.FindString("number"); string warning = bkpt.TryFindString("warning"); string addr = bkpt.TryFindString("addr"); PendingBreakpoint bp; if (!string.IsNullOrEmpty(warning)) { Debug.Assert(string.IsNullOrEmpty(addr)); return(new BindResult(new PendingBreakpoint(pbreak, number, MIBreakpointState.Pending), warning)); } bp = new PendingBreakpoint(pbreak, number, StringToBreakpointState(addr)); if (list == null) // single breakpoint { BoundBreakpoint bbp = bp.GetBoundBreakpoint(bkpt); if (bbp == null) { return(new BindResult(bp, MICoreResources.Status_BreakpointPending)); } return(new BindResult(bp, bbp)); } else // <MULTIPLE> with list of addresses { BindResult res = new BindResult(bp); for (int i = 1; i < list.Content.Length; ++i) { BoundBreakpoint bbp = bp.GetBoundBreakpoint(list.Content[i] as TupleValue); res.BoundBreakpoints.Add(bbp); } return(res); } }
internal static async Task <BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak) { string basename = System.IO.Path.GetFileName(documentName); // get basename from Windows path Results bindResult = await process.MICommandFactory.BreakInsert(process.EscapePath(basename), line, condition, ResultClass.None); string errormsg = "Unknown error"; if (bindResult.ResultClass == ResultClass.error) { if (bindResult.Contains("msg")) { errormsg = bindResult.FindString("msg"); } if (String.IsNullOrWhiteSpace(errormsg)) { errormsg = "Unknown error"; } return(new BindResult(errormsg)); } else if (bindResult.ResultClass != ResultClass.done) { return(new BindResult(errormsg)); } TupleValue bkpt = null; ValueListValue list = null; if (bindResult.Contains("bkpt")) { ResultValue b = bindResult.Find("bkpt"); if (b is TupleValue) { bkpt = b as TupleValue; } else if (b is ValueListValue) { // "<MULTIPLE>" sometimes includes a list of bound breakpoints list = b as ValueListValue; bkpt = list.Content[0] as TupleValue; } } else { // If the source file is not found, "done" is the result without a binding // (the error is sent via an "&" string and hence lost) return(new BindResult(errormsg)); } Debug.Assert(bkpt.FindString("type") == "breakpoint"); string number = bkpt.FindString("number"); string addr = bkpt.TryFindString("addr"); PendingBreakpoint bp = new PendingBreakpoint(pbreak, number, StringToBreakpointState(addr)); if (list == null) // single breakpoint { BoundBreakpoint bbp = bp.GetBoundBreakpoint(bkpt); if (bbp == null) { return(new BindResult(bp, MICoreResources.Status_BreakpointPending)); } return(new BindResult(bp, bbp)); } else // <MULTIPLE> with list of addresses { BindResult res = new BindResult(bp); for (int i = 1; i < list.Content.Length; ++i) { BoundBreakpoint bbp = bp.GetBoundBreakpoint(list.Content[i] as TupleValue); res.BoundBreakpoints.Add(bbp); } return(res); } }