Пример #1
0
		DC.StackFrame CreateStackFrame (MDB.StackFrame frame)
		{
			string method = frame.Method.Name;
			if (frame.Method.DeclaringType != null)
				method = frame.Method.DeclaringType.FullName + "." + method;
			var location = new DC.SourceLocation (method, frame.FileName, frame.LineNumber);
			var lang = frame.Method != null? "Managed" : "Native";
			return new DC.StackFrame (frame.ILOffset, frame.Method.FullName, location, lang, session.IsExternalCode (frame), true);
		}
Пример #2
0
		public SoftDebuggerBacktrace (SoftDebuggerSession session, MDB.ThreadMirror thread): base (session.Adaptor)
		{
			this.session = session;
			this.thread = thread;
			stackVersion = session.StackVersion;
			if (thread != null)
				this.frames = thread.GetFrames ();
			else
				this.frames = new MDB.StackFrame[0];
		}
		DC.StackFrame CreateStackFrame (MDB.StackFrame frame)
		{
			MDB.MethodMirror method = frame.Method;
			MDB.TypeMirror type = method.DeclaringType;
			string methodName = method.Name;
			if (type != null)
				methodName = type.FullName + "." + methodName;
			var location = new DC.SourceLocation (methodName, SoftDebuggerSession.NormalizePath (frame.FileName), frame.LineNumber);
			var lang = frame.Method != null ? "Managed" : "Native";
			return new DC.StackFrame (frame.ILOffset, method.FullName, location, lang, session.IsExternalCode (frame), true, type.Module.FullyQualifiedName, type.FullName);
		}
Пример #4
0
 public EventRequest(MDS.EventRequest sdbRequest)
     : base(sdbRequest)
 {
 }
Пример #5
0
		DC.StackFrame CreateStackFrame (MDB.StackFrame frame, int frameIndex)
		{
			MDB.MethodMirror method = frame.Method;
			MDB.TypeMirror type = method.DeclaringType;
			string fileName = frame.FileName;
			string typeFullName = null;
			string typeFQN = null;
			string methodName;
			
			if (fileName != null)
				fileName = SoftDebuggerSession.NormalizePath (fileName);
			
			if (method.VirtualMachine.Version.AtLeast (2, 12) && method.IsGenericMethod) {
				StringBuilder name = new StringBuilder (method.Name);
				
				name.Append ('<');
				
				if (method.VirtualMachine.Version.AtLeast (2, 15)) {
					bool first = true;
					
					foreach (var argumentType in method.GetGenericArguments ()) {
						if (!first)
							name.Append (", ");
						
						name.Append (session.Adaptor.GetDisplayTypeName (argumentType.FullName));
						first = false;
					}
				}
				
				name.Append ('>');
				
				methodName = name.ToString ();
			} else {
				methodName = method.Name;
			}
			
			// Compiler generated anonymous/lambda methods
			bool special_method = false;
			if (methodName [0] == '<' && methodName.Contains (">m__")) {
				int nidx = methodName.IndexOf (">m__", StringComparison.Ordinal) + 2;
				methodName = "AnonymousMethod" + methodName.Substring (nidx, method.Name.Length - nidx);
				special_method = true;
			}
			
			if (type != null) {
				string typeDisplayName = session.Adaptor.GetDisplayTypeName (type.FullName);
				
				if (SoftDebuggerAdaptor.IsGeneratedType (type)) {
					// The user-friendly method name is embedded in the generated type name
					var mn = SoftDebuggerAdaptor.GetNameFromGeneratedType (type);
					
					// Strip off the generated type name
					int dot = typeDisplayName.LastIndexOf ('.');
					var tname = typeDisplayName.Substring (0, dot);

					// Keep any type arguments
					int targs = typeDisplayName.LastIndexOf ('<');
					if (targs > dot + 1)
						mn += typeDisplayName.Substring (targs, typeDisplayName.Length - targs);

					typeDisplayName = tname;
					
					if (special_method)
						typeDisplayName += "." + mn;
					else
						methodName = mn;
				}
				
				methodName = typeDisplayName + "." + methodName;
				
				typeFQN = type.Module.FullyQualifiedName;
				typeFullName = type.FullName;
			}

			bool hidden = false;
			if (session.VirtualMachine.Version.AtLeast (2, 21)) {
				var ctx = GetEvaluationContext (frameIndex, session.EvaluationOptions);
				var hiddenAttr = session.Adaptor.GetType (ctx, "System.Diagnostics.DebuggerHiddenAttribute") as MDB.TypeMirror;
			
				hidden = method.GetCustomAttributes (hiddenAttr, true).Any ();
			}

			var location = new DC.SourceLocation (methodName, fileName, frame.LineNumber, frame.ColumnNumber);
			var external = session.IsExternalCode (frame);
			string addressSpace = string.Empty;
			string language;

			if (frame.Method != null) {
				if (frame.IsNativeTransition) {
					language = "Transition";
				} else {
					addressSpace = method.FullName;
					language = "Managed";
				}
			} else {
				language = "Native";
			}

			return new SoftDebuggerStackFrame (frame, addressSpace, location, language, external, true, hidden, typeFQN, typeFullName);
		}
		static bool IsPropertyOrOperatorMethod (MDB.MethodMirror method)
		{
			string name = method.Name;
			
			return method.IsSpecialName && name.StartsWith ("get_") || name.StartsWith ("set_") || name.StartsWith ("op_");
		}
Пример #7
0
		DC.StackFrame CreateStackFrame (MDB.StackFrame frame)
		{
			MDB.MethodMirror method = frame.Method;
			MDB.TypeMirror type = method.DeclaringType;
			string fileName = frame.FileName;
			string typeFullName = null;
			string typeFQN = null;
			string methodName;
			
			if (fileName != null)
				fileName = SoftDebuggerSession.NormalizePath (fileName);
			
			if (method.VirtualMachine.Version.AtLeast (2, 12) && method.IsGenericMethod) {
				StringBuilder name = new StringBuilder (method.Name);
				
				name.Append ('<');
				
				if (method.VirtualMachine.Version.AtLeast (2, 15)) {
					bool first = true;
					
					foreach (var argumentType in method.GetGenericArguments ()) {
						if (!first)
							name.Append (", ");
						
						name.Append (session.Adaptor.GetDisplayTypeName (argumentType.FullName));
						first = false;
					}
				}
				
				name.Append ('>');
				
				methodName = name.ToString ();
			} else {
				methodName = method.Name;
			}
			
			// Compiler generated anonymous/lambda methods
			bool special_method = false;
			if (methodName [0] == '<' && methodName.Contains (">m__")) {
				int nidx = methodName.IndexOf (">m__") + 2;
				methodName = "AnonymousMethod" + methodName.Substring (nidx, method.Name.Length - nidx);
				special_method = true;
			}
			
			if (type != null) {
				string typeDisplayName = session.Adaptor.GetDisplayTypeName (type.FullName);
				
				if (SoftDebuggerAdaptor.IsGeneratedType (type)) {
					// The user-friendly method name is embedded in the generated type name
					var mn = SoftDebuggerAdaptor.GetNameFromGeneratedType (type);
					
					// Strip off the generated type name
					int dot = typeDisplayName.LastIndexOf ('.');
					var tname = typeDisplayName.Substring (0, dot);

					// Keep any type arguments
					int targs = typeDisplayName.LastIndexOf ('<');
					if (targs > dot + 1)
						mn += typeDisplayName.Substring (targs, typeDisplayName.Length - targs);
					
					typeDisplayName = tname;
					
					if (special_method)
						typeDisplayName += "." + mn;
					else
						methodName = mn;
				}
				
				methodName = typeDisplayName + "." + methodName;
				
				typeFQN = type.Module.FullyQualifiedName;
				typeFullName = type.FullName;
			}
			
			var location = new DC.SourceLocation (methodName, fileName, frame.LineNumber);
			var external = session.IsExternalCode (frame);
			
			return new SoftDebuggerStackFrame (frame, method.FullName, location, "Managed", external, true, typeFQN, typeFullName);
		}
Пример #8
0
        private bool HandleEvent(MDS.Event e, MDS.SuspendPolicy policy)
        {
            LogProvider.Log ("Received Event: " + e.GetType ());

            bool exit = false;
            lock (vm)
            {
                exit = exited;
            }
            if (exit)
                return false;

            bool ret = running;

            //if (VMSuspended != null && policy != MDS.SuspendPolicy.None)
            //{
            //    switch (e.EventType)
            //    {
            //        case MDS.EventType.VMStart:
            //        case MDS.EventType.VMDeath:
            //        case MDS.EventType.VMDisconnect:
            //        case MDS.EventType.AppDomainCreate:
            //        case MDS.EventType.AppDomainUnload:
            //        case MDS.EventType.ThreadStart:
            //        case MDS.EventType.ThreadDeath:
            //        case MDS.EventType.AssemblyLoad:
            //        case MDS.EventType.AssemblyUnload:
            //        case MDS.EventType.TypeLoad:
            //            break;
            //        default:
            //            LogProvider.Log (e.EventType.ToString ());
            //            OnVMSuspended (new Event (e, State.Suspend));
            //            break;
            //    }
            //}

            switch (e.EventType)
            {
                case MDS.EventType.VMStart:
                    if (VMStateChanged != null)
                        VMStateChanged (new Event (e, State.Start));
                    break;
                case MDS.EventType.VMDeath:
                    if (VMStateChanged != null)
                        VMStateChanged (new Event (e, State.Stop));
                    ret = false;
                    break;
                case MDS.EventType.VMDisconnect:
                    if (VMStateChanged != null)
                        VMStateChanged (new Event (e, State.Disconnect));
                    ret = false;
                    break;
                case MDS.EventType.AppDomainCreate:
                    if (AppDomainLoaded != null)
                        AppDomainLoaded (new Event (e));
                    appdomains.Add (((MDS.AppDomainCreateEvent)e).Domain);
                    break;
                case MDS.EventType.AppDomainUnload:
                    if (AppDomainUnloaded != null)
                        AppDomainUnloaded (new Event (e));
                    if (appdomains.Contains (((MDS.AppDomainUnloadEvent)e).Domain))
                        appdomains.Remove (((MDS.AppDomainUnloadEvent)e).Domain);
                    break;
                case MDS.EventType.ThreadStart:
                    if (ThreadStarted != null)
                        ThreadStarted (new Event (e));
                    break;
                case MDS.EventType.ThreadDeath:
                    if (ThreadStopped != null)
                        ThreadStopped (new Event (e));
                    break;
                case MDS.EventType.AssemblyLoad:
                    if (AssemblyLoaded != null) {
                        var ev = new AssemblyEvent (e);
                        AssemblyLoaded (ev);
                        if (!ev.Cancel && !filteredAssemblies.Contains (((MDS.AssemblyLoadEvent)e).Assembly.Id))
                        {
                            var tr = vm.CreateTypeLoadRequest ();
                            tr.AssemblyFilter = new MDS.AssemblyMirror [] {((MDS.AssemblyLoadEvent)e).Assembly};
                            tr.Enable ();
                            filteredAssemblies.Add (((MDS.AssemblyLoadEvent)e).Assembly.Id);
                        }
                    }
                    break;
                case MDS.EventType.AssemblyUnload:
                    if (AssemblyUnloaded != null)
                        AssemblyUnloaded (new AssemblyEvent (e));
                    break;
                case MDS.EventType.TypeLoad:
                    if (TypeLoaded != null)
                        TypeLoaded (new TypeEvent (e));
                    break;
                case MDS.EventType.Breakpoint:
                    if (BreakpointHit != null)
                        BreakpointHit (new BreakpointEvent (e));
                    break;
                case MDS.EventType.Step:
                    if (Stepped != null)
                        Stepped (new Event (e));
                    break;
                case MDS.EventType.MethodEntry:
                    LogProvider.Log (((MDS.MethodEntryEvent)e).Method.FullName);
                    break;
                default:
                    LogProvider.Log ("Unknown event: " + e.GetType ());
                    break;
            }
            if (policy != MDS.SuspendPolicy.None)
                Resume ();

            return ret;
        }
Пример #9
0
 public BreakpointEvent(MDS.Event ev)
     : base(ev)
 {
 }
Пример #10
0
 public TypeEvent(MDS.Event ev)
     : base(ev)
 {
 }
Пример #11
0
 public SdbValue(MDS.Value value)
     : base(value)
 {
 }
Пример #12
0
 private static ILocation SdbLocationFor(MDS.Location l)
 {
     return Cache.Lookup<SdbLocation> (l);
 }
Пример #13
0
 public SdbMethodMirror(MDS.MethodMirror methodMirror)
     : base(methodMirror)
 {
     locations = new List<ILocation> (this.methodMirror.Locations.Select (SdbLocationFor));
 }
Пример #14
0
 public Event(MDS.Event ev, State state = State.None)
     : base(ev)
 {
     State = state;
 }
Пример #15
0
 public SdbVariable(MDS.LocalVariable variable)
     : base(variable)
 {
 }
Пример #16
0
 public SdbStackFrame(MDS.StackFrame obj)
     : base(obj)
 {
 }
Пример #17
0
 public SdbThreadMirror(MDS.ThreadMirror threadMirror)
     : base(threadMirror)
 {
 }
Пример #18
0
 public AssemblyEvent(MDS.Event ev)
     : base(ev)
 {
 }