public DGdbBacktrace (GdbSession session, long threadId, int count, ResultData firstFrame) : base(session, threadId, count, firstFrame) { BacktraceHelper = new DLocalExamBacktrace(this); //Variables = new VariableValueExamination (this); //DebuggingService.CurrentFrameChanged += FrameChanged; }
public GdbBacktrace (GdbSession session, long threadId, int count, ResultData firstFrame) { fcount = count; this.threadId = threadId; if (firstFrame != null) this.firstFrame = CreateFrame (firstFrame); this.session = session; }
void FireTargetEvent (TargetEventType type, ResultData curFrame) { UpdateHitCountData (); TargetEventArgs args = new TargetEventArgs (type); if (type != TargetEventType.TargetExited) { GdbCommandResult res = RunCommand ("-stack-info-depth"); int fcount = int.Parse (res.GetValue ("depth")); GdbBacktrace bt = new GdbBacktrace (this, activeThread, fcount, curFrame); args.Backtrace = new Backtrace (bt); args.Thread = GetThread (activeThread); } OnTargetEvent (args); }
ResultData ReadArray (string str, ref int pos) { ArrayList list = new ArrayList (); while (pos < str.Length && str [pos] != ']') { object val = ReadValue (str, ref pos); list.Add (val); TryReadChar (str, ref pos, ','); } TryReadChar (str, ref pos, ']'); ResultData arr = new ResultData (); arr.array = list.ToArray (); return arr; }
void ReadTuple (string str, ref int pos, ResultData data) { if (data.props == null) data.props = new Hashtable (); while (pos < str.Length && str [pos] != '}') { string name; object val; ReadResult (str, ref pos, out name, out val); if (data.props.ContainsKey (name)) { object ob = data.props [name]; ResultData rd = ob as ResultData; if (rd != null && rd.isArrayProperty) { object[] newArr = new object [rd.array.Length + 1]; Array.Copy (rd.array, newArr, rd.array.Length); newArr [rd.array.Length] = val; rd.array = newArr; } else { rd = new ResultData (); rd.isArrayProperty = true; rd.array = new object [2]; rd.array [0] = ob; rd.array [1] = val; data.props [name] = rd; } } else { data.props [name] = val; } TryReadChar (str, ref pos, ','); } TryReadChar (str, ref pos, '}'); }
object ReadValue (string str, ref int pos) { if (str [pos] == '"') { pos++; string ret = ReadString (str, '"', ref pos); pos++; return ret; } if (str [pos] == '{') { pos++; ResultData data = new ResultData (); ReadTuple (str, ref pos, data); return data; } if (str [pos] == '[') { pos++; return ReadArray (str, ref pos); } // Single value tuple string name; object val; ReadResult (str, ref pos, out name, out val); ResultData sdata = new ResultData (); sdata.props = new Hashtable (); sdata.props [name] = val; return sdata; }
StackFrame CreateFrame (ResultData frameData) { string lang = "Native"; string func = frameData.GetValue ("func"); string sadr = frameData.GetValue ("addr"); if (func == "??" && session.IsMonoProcess) { // Try to get the managed func name try { ResultData data = session.RunCommand ("-data-evaluate-expression", "mono_pmip(" + sadr + ")"); string val = data.GetValue ("value"); if (val != null) { int i = val.IndexOf ('"'); if (i != -1) { func = val.Substring (i).Trim ('"',' '); lang = "Mono"; } } } catch { } } int line = -1; string sline = frameData.GetValue ("line"); if (sline != null) line = int.Parse (sline); string sfile = frameData.GetValue ("fullname"); if (sfile == null) sfile = frameData.GetValue ("file"); if (sfile == null) sfile = frameData.GetValue ("from"); SourceLocation loc = new SourceLocation (func ?? "?", sfile, line); long addr; if (!string.IsNullOrEmpty (sadr)) addr = long.Parse (sadr.Substring (2), NumberStyles.HexNumber); else addr = 0; return new StackFrame (addr, loc, lang); }
ObjectValue CreateObjectValue (string name, ResultData data) { string vname = data.GetValue ("name"); string typeName = data.GetValue ("type"); string value = data.GetValue ("value"); int nchild = data.GetInt ("numchild"); ObjectValue val; ObjectValueFlags flags = ObjectValueFlags.Variable; // There can be 'public' et al children for C++ structures if (typeName == null) typeName = "none"; if (typeName.EndsWith ("]")) { val = ObjectValue.CreateArray (this, new ObjectPath (vname), typeName, nchild, flags, null); } else if (value == "{...}" || typeName.EndsWith ("*") || nchild > 0) { val = ObjectValue.CreateObject (this, new ObjectPath (vname), typeName, value, flags, null); } else { val = ObjectValue.CreatePrimitive (this, new ObjectPath (vname), typeName, new EvaluationResult (value), flags); } val.Name = name; return val; }
protected override StackFrame CreateFrame(ResultData frameData) { string lang = "D"; string func = frameData.GetValueString("func"); string sadr = frameData.GetValueString("addr"); int line; int.TryParse(frameData.GetValueString("line"),out line); string sfile = frameData.GetValueString("fullname"); if (sfile == null) sfile = frameData.GetValueString("file"); if (sfile == null) sfile = frameData.GetValueString("from"); if (sfile != null) { var m = mixinInlineRegex.Match (sfile); if (m.Success) { sfile = sfile.Substring (0, m.Index); int.TryParse (m.Groups ["line"].Value, out line); } } // demangle D function/method name stored in func var typeDecl = Demangler.DemangleQualifier(func); if (typeDecl != null) func = typeDecl.ToString(); long addr = 0; if (!string.IsNullOrEmpty(sadr)) addr = long.Parse(sadr.Substring(2), System.Globalization.NumberStyles.HexNumber); return new StackFrame(addr, new SourceLocation(func ?? "<undefined>", sfile, line), lang); }