GetBacktrace() public method

public GetBacktrace ( ) : Backtrace
return Backtrace
示例#1
0
		void UpdateThread (Thread thread)
		{
			RemoteTreeNode node = (RemoteTreeNode)threadToTreeNode[thread];

			if (node == null) {
				node = RootNode.AppendNode();
				threadToTreeNode.Add(thread, node);
			}
			
			bool current = interpreter.HasCurrentThread && interpreter.CurrentThread.ID == thread.ID;
			
			string location;
			if (thread.IsStopped) {
				try {
					location = thread.GetBacktrace().Frames[0].SourceAddress.Name;
				} catch {
					location = "";
				}
			} else {
				location = "";
			}
			
			node.SetValue(ColumnSelected, current ? Pixmaps.Arrow : Pixmaps.Empty);
			node.SetValue(ColumnID, thread.ID);
			node.SetValue(ColumnPID, thread.PID);
			node.SetValue(ColumnTID, String.Format("{0:x}", thread.TID));
			node.SetValue(ColumnName, thread.Name);
			node.SetValue(ColumnState, thread.State.ToString());
			node.SetValue(ColumnLocation, location);
		}
示例#2
0
        DL.Backtrace CreateBacktrace(MD.Thread thread, ML.TargetObject exception)
        {
            List <MD.StackFrame> frames = new List <MD.StackFrame> ();
            DateTime             t      = DateTime.Now;

            if (!thread.CurrentFrame.Language.IsManaged)
            {
                MD.Backtrace bt = thread.GetBacktrace(MD.Backtrace.Mode.Native, max_frames);
                if (bt != null)
                {
                    Console.WriteLine("GetBacktrace native time: {0} ms n:{1}", (DateTime.Now - t).TotalMilliseconds, bt.Count);
                    frames.AddRange(bt.Frames);
                }
            }
            else
            {
                t = DateTime.Now;
                MD.Backtrace backtrace = thread.GetBacktrace(MD.Backtrace.Mode.Managed, max_frames);
                if (backtrace != null)
                {
                    Console.WriteLine("GetBacktrace managed time: {0} ms n:{1}", (DateTime.Now - t).TotalMilliseconds, backtrace.Count);
                    frames.AddRange(backtrace.Frames);
                }
            }
            if (frames.Count > 0)
            {
                BacktraceWrapper wrapper = new BacktraceWrapper(frames.ToArray(), exception);
                return(new DL.Backtrace(wrapper));
            }
            else if (thread.CurrentBacktrace != null)
            {
                BacktraceWrapper wrapper = new BacktraceWrapper(thread.CurrentBacktrace.Frames, exception);
                return(new DL.Backtrace(wrapper));
            }
            return(null);
        }
示例#3
0
        protected override bool DoResolve(ScriptingContext context)
        {
            // set whole method in a try-catch block: if anything goes wrong, an invalid breakpoint
            // number is set and the semaphore is released.
            try {
                if (global)
                {
                    if (local)
                    {
                        throw new ScriptingException(
                                  "Cannot use both -local and -global.");
                    }

                    if (Group != null)
                    {
                        throw new ScriptingException(
                                  "Cannot use both -group and -global.");
                    }

                    tgroup = ThreadGroup.Global;
                }
                else if (local)
                {
                    if (Group != null)
                    {
                        throw new ScriptingException(
                                  "Cannot use both -group and -local.");
                    }

                    tgroup = context.Interpreter.GetThreadGroup(Group, false);
                }
                else if (Group != null)
                {
                    tgroup = context.Interpreter.GetThreadGroup(Group, false);
                }
                else
                {
                    tgroup = ThreadGroup.Global;
                }

                if (context.Interpreter.HasTarget)
                {
                    context.CurrentProcess = context.Interpreter.GetProcess(p_index);
                    context.CurrentThread  = context.Interpreter.GetThread(t_index);

                    Mono.Debugger.Thread thread = context.CurrentThread;
                    if (!thread.IsStopped)
                    {
                        throw new Mono.Debugger.TargetException(TargetError.NotStopped);
                    }

                    Backtrace backtrace = thread.GetBacktrace();

                    StackFrame frame;
                    if (f_index == -1)
                    {
                        frame = backtrace.CurrentFrame;
                    }
                    else
                    {
                        if (f_index >= backtrace.Count)
                        {
                            throw new ScriptingException(
                                      "No such frame: {0}", f_index);
                        }

                        frame = backtrace [f_index];
                    }

                    context.CurrentFrame = frame;

                    if (ExpressionParser.ParseLocation(
                            thread, thread.CurrentFrame, Argument, out location))
                    {
                        return(true);
                    }
                }

                if (Argument.IndexOf(':') > 0)
                {
                    return(true);
                }

                try {
                    UInt32.Parse(Argument);
                    return(true);
                } catch {
                }

                Expression expr = context.Interpreter.ExpressionParser.Parse(Argument);
                if (expr == null)
                {
                    throw new ScriptingException("Cannot resolve expression `{0}'.", Argument);
                }

                if (expr is PointerExpression)
                {
                    address = ((PointerExpression)expr).EvaluateAddress(context);
                    return(true);
                }

                if (!context.Interpreter.HasTarget)
                {
                    return(true);
                }

                MethodExpression mexpr;
                try {
                    mexpr = expr.ResolveMethod(context, type);
                } catch {
                    if (lazy)
                    {
                        return(true);
                    }
                    throw new ScriptingException("No such method: `{0}'.", Argument);
                }

                if (mexpr != null)
                {
                    location = mexpr.EvaluateSource(context);
                }
                else
                {
                    location = context.FindMethod(Argument);
                }

                if (lazy)
                {
                    return(true);
                }

                if (location == null)
                {
                    throw new ScriptingException("No such method: `{0}'.", Argument);
                }

                return(true);
            } catch {
                EmonicInterpreter.breakpointNumber = -1;
                EmonicInterpreter.breakpointSem.Release();
                throw;
            }
        }