public SoftEvaluationContext(SoftDebuggerSession session, StackFrame frame, DC.EvaluationOptions options)
            : base(options)
        {
            Frame = frame;
            Thread = frame.Thread;
            Domain = frame.Domain;

            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, frame.ColumnNumber, frame.EndLineNumber, frame.EndColumnNumber, frame.Location.SourceFileHash);
            string language;

            if (frame.Method != null) {
                language = frame.IsNativeTransition ? "Transition" : "Managed";
            } else {
                language = "Native";
            }

            Evaluator = session.GetEvaluator (new DC.StackFrame (frame.ILOffset, location, language, session.IsExternalCode (frame), true));
            Adapter = session.Adaptor;
            this.session = session;
            stackVersion = session.StackVersion;
            sourceAvailable = !string.IsNullOrEmpty (frame.FileName) && System.IO.File.Exists (frame.FileName);
        }
        public SoftEvaluationContext(SoftDebuggerSession session, StackFrame frame, DC.EvaluationOptions options) : base(options)
        {
            Frame  = frame;
            Thread = frame.Thread;
            Domain = Thread.Domain;

            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, frame.ColumnNumber);
            string language;

            if (frame.Method != null)
            {
                language = frame.IsNativeTransition ? "Transition" : "Managed";
            }
            else
            {
                language = "Native";
            }

            Evaluator       = session.GetEvaluator(new DC.StackFrame(frame.ILOffset, location, language, session.IsExternalCode(frame), true));
            Adapter         = session.Adaptor;
            this.session    = session;
            stackVersion    = session.StackVersion;
            sourceAvailable = !string.IsNullOrEmpty(frame.FileName) && System.IO.File.Exists(frame.FileName);
        }
Example #3
0
		static string ResolveType (string identifier, SourceLocation location)
		{
			switch (identifier) {
			case "SomeClassInNamespace":
				return "MonoDevelop.Debugger.Tests.TestApp.SomeClassInNamespace";
			case "ParentNestedClass":
				return "MonoDevelop.Debugger.Tests.TestApp.TestEvaluationParent.ParentNestedClass";
			case "NestedClass":
				return "MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.NestedClass";
			case "TestEvaluation":
				return "MonoDevelop.Debugger.Tests.TestApp.TestEvaluation";
			case "NestedGenericClass`2":
				return "MonoDevelop.Debugger.Tests.TestApp.TestEvaluation.NestedGenericClass";
			case "Dictionary`2":
				return "System.Collections.Generic.Dictionary";
			case "Thing`1":
				return "Thing";
			case "A":
				return "A";
			case "B":
				return "B";
			case "C":
				return "C";
			case "System":
				return "System";
			case "MonoDevelop":
				return "MonoDevelop";
			case "SomeEnum":
				return "SomeEnum";
			}
			return null;
		}
		public StackFrame (long address, SourceLocation location, string language, bool isExternalCode, bool hasDebugInfo)
		{
			this.address = address;
			this.location = location;
			this.language = language;
			this.isExternalCode = isExternalCode;
			this.hasDebugInfo = hasDebugInfo;
		}
		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);
		}
Example #6
0
		public StackFrame (long address, string addressSpace, SourceLocation location, string language, bool isExternalCode, bool hasDebugInfo, string fullModuleName, string fullTypeName)
		{
			this.address = address;
			this.addressSpace = addressSpace;
			this.location = location;
			this.language = language;
			this.isExternalCode = isExternalCode;
			this.hasDebugInfo = hasDebugInfo;
			this.fullModuleName = fullModuleName;
			this.fullTypeName = fullTypeName;
		}
		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);
		}
        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));
        }
        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));
        }
		public SoftEvaluationContext (SoftDebuggerSession session, StackFrame frame, DC.EvaluationOptions options): base (options)
		{
			Frame = frame;
			Thread = frame.Thread;

			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";
			
			Evaluator = session.GetEvaluator (new DC.StackFrame (frame.ILOffset, location, lang, session.IsExternalCode (frame), true));
			Adapter = session.Adaptor;
			this.session = session;
			this.stackVersion = session.StackVersion;
			sourceAvailable = !string.IsNullOrEmpty (frame.FileName) && System.IO.File.Exists (frame.FileName);
		}
        public SoftEvaluationContext(SoftDebuggerSession session, StackFrame frame, DC.EvaluationOptions options) : base(options)
        {
            Frame  = frame;
            Thread = frame.Thread;


            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";

            Evaluator         = session.GetResolver(new DC.StackFrame(frame.ILOffset, location, lang, session.IsExternalCode(frame), true));
            Adapter           = session.Adaptor;
            this.session      = session;
            this.stackVersion = session.StackVersion;
        }
Example #12
0
		public static void SetNextStatement (string fileName, int line, int column)
		{
			if (!IsDebugging || IsRunning || CheckIsBusy ())
				return;

			session.SetNextStatement (fileName, line, column);

			var location = new SourceLocation (CurrentFrame.SourceLocation.MethodName, fileName, line);
			nextStatementLocations[session.ActiveThread.Id] = location;
			NotifyLocationChanged ();
		}
		internal static StackFrame CreateFrame (CorDebuggerSession session, CorFrame frame)
		{
			uint address = 0;
			string file = "";
			int line = 0;
			string method = "";
			string lang = "";
			string module = "";
			string type = "";

			if (frame.FrameType == CorFrameType.ILFrame) {
				if (frame.Function != null) {
					module = frame.Function.Module.Name;
					CorMetadataImport importer = new CorMetadataImport (frame.Function.Module);
					MethodInfo mi = importer.GetMethodInfo (frame.Function.Token);
					method = mi.DeclaringType.FullName + "." + mi.Name;
					type = mi.DeclaringType.FullName;
					ISymbolReader reader = session.GetReaderForModule (frame.Function.Module.Name);
					if (reader != null) {
						ISymbolMethod met = reader.GetMethod (new SymbolToken (frame.Function.Token));
						if (met != null) {
							uint offset;
							CorDebugMappingResult mappingResult;
							frame.GetIP (out offset, out mappingResult);
							SequencePoint prevSp = null;
							foreach (SequencePoint sp in met.GetSequencePoints ()) {
								if (sp.Offset > offset)
									break;
								prevSp = sp;
							}
							if (prevSp != null) {
								line = prevSp.Line;
								file = prevSp.Document.URL;
							}
						}
					}
				}
				lang = "Managed";
			}
			else if (frame.FrameType == CorFrameType.NativeFrame) {
				frame.GetNativeIP (out address);
				method = "<Unknown>";
				lang = "Native";
			}
			else if (frame.FrameType == CorFrameType.InternalFrame) {
				switch (frame.InternalFrameType) {
					case CorDebugInternalFrameType.STUBFRAME_M2U: method = "[Managed to Native Transition]"; break;
					case CorDebugInternalFrameType.STUBFRAME_U2M: method = "[Native to Managed Transition]"; break;
					case CorDebugInternalFrameType.STUBFRAME_LIGHTWEIGHT_FUNCTION: method = "[Lightweight Method Call]"; break;
					case CorDebugInternalFrameType.STUBFRAME_APPDOMAIN_TRANSITION: method = "[Application Domain Transition]"; break;
					case CorDebugInternalFrameType.STUBFRAME_FUNC_EVAL: method = "[Function Evaluation]"; break;
				}
			}
			if (method == null)
				method = "<Unknown>";
			var loc = new SourceLocation (method, file, line);
			return new StackFrame ((long) address, loc, lang);
		}
Example #14
0
		public virtual string ResolveExpression (string expression, SourceLocation location)
		{
			if (TypeResolverHandler == null)
				return expression;
			else {
				string key = expression + " " + location;
				string resolved;
				if (!resolvedExpressionCache.TryGetValue (key, out resolved)) {
					try {
						resolved = OnResolveExpression (expression, location);
					} catch (Exception ex) {
						OnDebuggerOutput (true, "Error while resolving expression: " + ex.Message);
					}
					resolvedExpressionCache [key] = resolved;
				}
				return resolved ?? expression;
			}
		}
Example #15
0
		protected void Start (string test)
		{
			TargetRuntime runtime;

			switch (EngineId) {
			case "MonoDevelop.Debugger.Win32":
				runtime = Runtime.SystemAssemblyService.GetTargetRuntime ("MS.NET");
				break;
			case "Mono.Debugger.Soft":
				runtime = Runtime.SystemAssemblyService.GetTargetRuntimes ()
					.OfType<MonoTargetRuntime> ()
					.OrderByDescending(o => o.Version)
					.FirstOrDefault ();
				break;
			default:
				runtime = Runtime.SystemAssemblyService.DefaultRuntime;
				break;
			}

			if (runtime == null) {
				Assert.Ignore ("Runtime not found for: {0}", EngineId);
				return;
			}

			Console.WriteLine ("Target Runtime: " + runtime.DisplayRuntimeName + " " + runtime.Version);

			// main/build/tests
			FilePath path = Path.GetDirectoryName (GetType ().Assembly.Location);
			var exe = Path.Combine (path, "MonoDevelop.Debugger.Tests.TestApp.exe");

			var cmd = new DotNetExecutionCommand ();
			cmd.TargetRuntime = runtime;
			cmd.Command = exe;
			cmd.Arguments = test;

			if (Platform.IsWindows) {
				var monoRuntime = runtime as MonoTargetRuntime;
				if (monoRuntime != null) {
					var psi = new System.Diagnostics.ProcessStartInfo (Path.Combine (monoRuntime.Prefix, "bin", "pdb2mdb.bat"), cmd.Command);
					psi.UseShellExecute = false;
					psi.CreateNoWindow = true;
					System.Diagnostics.Process.Start (psi).WaitForExit ();
				}
			}

			var dsi = engine.CreateDebuggerStartInfo (cmd);
			var soft = dsi as SoftDebuggerStartInfo;

			if (soft != null) {
				var assemblyName = AssemblyName.GetAssemblyName (exe);

				soft.UserAssemblyNames = new List<AssemblyName> ();
				soft.UserAssemblyNames.Add (assemblyName);
			}

			Session = engine.CreateSession ();
			var ops = new DebuggerSessionOptions ();
			ops.EvaluationOptions = EvaluationOptions.DefaultOptions;
			ops.EvaluationOptions.AllowTargetInvoke = AllowTargetInvokes;
			ops.EvaluationOptions.EvaluationTimeout = 100000;

			path = path.ParentDirectory.ParentDirectory.Combine ("src", "addins", "MonoDevelop.Debugger", "MonoDevelop.Debugger.Tests.TestApp", test + ".cs").FullPath;
			SourceFile = TextFile.ReadFile (path);
			TestName = test;
			AddBreakpoint ("break");
			
			var done = new ManualResetEvent (false);
			
			Session.OutputWriter = (isStderr, text) => Console.WriteLine ("PROC:" + text);

			Session.TargetHitBreakpoint += (sender, e) => {
				done.Set ();
				Frame = e.Backtrace.GetFrame (0);
				lastStoppedPosition = Frame.SourceLocation;
				targetStoppedEvent.Set ();
			};

			Session.TargetExceptionThrown += (sender, e) => {
				Frame = e.Backtrace.GetFrame (0);
				for (int i = 0; i < e.Backtrace.FrameCount; i++) {
					if (!e.Backtrace.GetFrame (i).IsExternalCode) {
						Frame = e.Backtrace.GetFrame (i);
						break;
					}
				}
				lastStoppedPosition = Frame.SourceLocation;
				targetStoppedEvent.Set ();
			};

			Session.TargetStopped += (sender, e) => {
				Frame = e.Backtrace.GetFrame (0);
				lastStoppedPosition = Frame.SourceLocation;
				targetStoppedEvent.Set ();
			};

			var targetExited = new ManualResetEvent (false);
			Session.TargetExited += delegate {
				targetExited.Set ();
			};

			Session.Run (dsi, ops);
			switch (WaitHandle.WaitAny (new WaitHandle[]{ done, targetExited }, 30000)) {
			case 0:
				//Breakpoint is hit good... run tests now
				break;
			case 1:
				throw new Exception ("Test application exited before hitting breakpoint");
			default:
				throw new Exception ("Timeout while waiting for initial breakpoint");
			}
		}
		private StoppedEvent CreateStoppedEvent(string reason, SourceLocation sl, ThreadInfo ti, string text = null)
		{
			return new StoppedEvent(reason, new Source(ConvertDebuggerPathToClient(sl.FileName)), ConvertDebuggerLineToClient(sl.Line), sl.Column, text, (int)ti.Id);
		}
Example #17
0
		/// <summary>
		/// Called when an expression needs to be resolved
		/// </summary>
		/// <param name='expression'>
		/// The expression
		/// </param>
		/// <param name='location'>
		/// The source code location
		/// </param>
		/// <returns>
		/// The resolved expression
		/// </returns>
		protected virtual string OnResolveExpression (string expression, SourceLocation location)
		{
			return defaultResolver.Resolve (this, location, expression);
		}
		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);
		}
        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));
        }
		internal static StackFrame CreateFrame (MicroFrameworkDebuggerSession session, CorDebugFrame frame)
		{
			string file = "";
			int line = 0;
			string method = "";
			string lang = "";

			if (frame.FrameType == CorFrameType.ILFrame) {
				if (frame.Function != null) {
					uint tk = TinyCLR_TypeSystem.SymbollessSupport.TinyCLRTokenFromMethodDefToken (frame.Function.Token);
					uint md = TinyCLR_TypeSystem.ClassMemberIndexFromTinyCLRToken (tk, frame.Function.Assembly);
					method = session.Engine.GetMethodName (md, true);
					var reader = frame.Function.Assembly.DebugData;
					if (reader != null) {
						var sim = new MethodSymbols (new Mono.Cecil.MetadataToken (frame.Function.Token));
						//Ugliest hack ever
						if(reader is Mono.Cecil.Mdb.MdbReader) {
							for(int i = 0; i < 100; i++)
								sim.Variables.Add(new VariableDefinition(null));
						}
						reader.Read (sim);
						InstructionSymbol prevSp = new InstructionSymbol (-1, null);
						foreach (var sp in sim.Instructions) {
							if (sp.Offset > frame.IP)
								break;
							prevSp = sp;
						}
						if (prevSp.Offset != -1) {
							line = prevSp.SequencePoint.StartLine;
							file = prevSp.SequencePoint.Document.Url;
						}
					}
				}
				lang = "Managed";
			}
//			else if(frame.FrameType == CorFrameType.NativeFrame)
//			{
//				frame.GetNativeIP(out address);
//				method = "<Unknown>";
//				lang = "Native";
//			}
			else if (frame.FrameType == CorFrameType.InternalFrame) {
				switch (((CorDebugInternalFrame)frame).FrameInternalType) {
				case CorDebugInternalFrameType.STUBFRAME_M2U:
					method = "[Managed to Native Transition]";
					break;
				case CorDebugInternalFrameType.STUBFRAME_U2M:
					method = "[Native to Managed Transition]";
					break;
				case CorDebugInternalFrameType.STUBFRAME_LIGHTWEIGHT_FUNCTION:
					method = "[Lightweight Method Call]";
					break;
				case CorDebugInternalFrameType.STUBFRAME_APPDOMAIN_TRANSITION:
					method = "[Application Domain Transition]";
					break;
				case CorDebugInternalFrameType.STUBFRAME_FUNC_EVAL:
					method = "[Function Evaluation]";
					break;
				}
			}
			if (method == null)
				method = "<Unknown>";
			var loc = new SourceLocation (method, file, line);
			return new StackFrame ((long)0, loc, lang);
		}
Example #21
0
		internal protected string ResolveIdentifierAsType (string identifier, SourceLocation location)
		{
			if (TypeResolverHandler != null)
				return TypeResolverHandler (identifier, location);
			else
				return null;
		}
 public NRefactoryExpressionResolverVisitor(DebuggerSession session, SourceLocation location, string expression)
 {
     this.expression = expression.Replace ("\n", "").Replace ("\r", "");
     this.session = session;
     this.location = location;
 }
		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);
		}
		public SoftDebuggerStackFrame (Mono.Debugger.Soft.StackFrame frame, string addressSpace, SourceLocation location, string language, bool isExternalCode, bool hasDebugInfo, bool isDebuggerHidden, string fullModuleName, string fullTypeName)
			: base (frame.ILOffset, addressSpace, location, language, isExternalCode, hasDebugInfo, isDebuggerHidden, fullModuleName, fullTypeName)
		{
			StackFrame = frame;
		}
Example #25
0
		public abstract string Resolve (DebuggerSession session, SourceLocation location, string exp);
Example #26
0
 public StackFrame(long address, SourceLocation location, string language)
     : this(address, "", location, language, string.IsNullOrEmpty(location.FileName), true, "", "")
 {
 }
		SourceLocation CheckLocationIsInFile (SourceLocation location)
		{
			if (!string.IsNullOrEmpty (ContentName) && location != null && !string.IsNullOrEmpty (location.FileName)
				&& ((FilePath)location.FileName).FullPath == ((FilePath)ContentName).FullPath)
				return location;
			return null;
		}
Example #28
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;
            }

            if (string.IsNullOrEmpty(methodName))
            {
                methodName = "[Function Without 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 external = false;
            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();
            }
            if (hidden)
            {
                external = true;
            }
            else
            {
                external = session.IsExternalCode(frame);
                if (!external && session.Options.ProjectAssembliesOnly && session.VirtualMachine.Version.AtLeast(2, 21))
                {
                    var ctx             = GetEvaluationContext(frameIndex, session.EvaluationOptions);
                    var nonUserCodeAttr = session.Adaptor.GetType(ctx, "System.Diagnostics.DebuggerNonUserCodeAttribute") as MDB.TypeMirror;
                    external = method.GetCustomAttributes(nonUserCodeAttr, true).Any();
                }
            }

            var location = new DC.SourceLocation(methodName, fileName, frame.LineNumber, frame.ColumnNumber, frame.Location.EndLineNumber, frame.Location.EndColumnNumber, frame.Location.SourceFileHash);

            string addressSpace = string.Empty;
            bool   hasDebugInfo = false;
            string language;

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

            return(new SoftDebuggerStackFrame(frame, addressSpace, location, language, external, hasDebugInfo, hidden, typeFQN, typeFullName));
        }
Example #29
0
		static string ResolveType (string identifier, SourceLocation location)
		{
			Document doc = IdeApp.Workbench.GetDocument (location.FileName);
			if (doc != null) {
				ITextEditorResolver textEditorResolver = doc.GetContent <ITextEditorResolver> ();
				if (textEditorResolver != null) {
					var rr = textEditorResolver.GetLanguageItem (doc.Editor.Document.LocationToOffset (location.Line, 1), identifier);
					var ns = rr as NamespaceResolveResult;
					if (ns != null)
						return ns.NamespaceName;
					var result = rr as TypeResolveResult;
					if (result != null && !result.IsError)
						return result.Type.FullName;
				}
			}
			return null;
		}
Example #30
0
 public void UpdateSourceFile(string newFilePath)
 {
     location = new SourceLocation (location.MethodName, newFilePath, location.Line, location.Column, location.EndLine, location.EndColumn, location.FileHash);
 }
		public override string Resolve (DebuggerSession session, SourceLocation location, string exp)
		{
			return Resolve (session, location, exp, false);
		}
Example #32
0
 public StackFrame(long address, string addressSpace, SourceLocation location, string language)
     : this(address, addressSpace, location, language, string.IsNullOrEmpty (location.FileName), true, "", "")
 {
 }
Example #33
0
 public StackFrame(long address, SourceLocation location, string language, bool isExternalCode, bool hasDebugInfo)
     : this(address, "", location, language, string.IsNullOrEmpty (location.FileName) || isExternalCode, hasDebugInfo, "", "")
 {
 }
		string Resolve (DebuggerSession session, SourceLocation location, string exp, bool tryTypeOf)
		{
			exp = exp.TrimStart ();
			if (exp.StartsWith ("?"))
				return "?" + Resolve (session, location, exp.Substring (1).Trim ());
			if (exp.StartsWith ("var "))
				return "var " + Resolve (session, location, exp.Substring (4).Trim (' ','\t'));

			exp = ReplaceExceptionTag (exp, session.Options.EvaluationOptions.CurrentExceptionTag);

			StringReader codeStream = new StringReader (exp);
			IParser parser = ParserFactory.CreateParser (SupportedLanguage.CSharp, codeStream);
			Expression expObj = parser.ParseExpression ();
			if (expObj == null)
				return exp;
			NRefactoryResolverVisitor ev = new NRefactoryResolverVisitor (session, location, exp);
			expObj.AcceptVisitor (ev, null);
			string r = ev.GetResolvedExpression ();
			if (r == exp && !tryTypeOf && (expObj is BinaryOperatorExpression) && IsTypeName (exp)) {
				// This is a hack to be able to parse expressions such as "List<string>". The NRefactory parser
				// can parse a single type name, so a solution is to wrap it around a typeof(). We do it if
				// the evaluation fails.
				string res = Resolve (session, location, "typeof(" + exp + ")", true);
				return res.Substring (7, res.Length - 8);
			}
			return r;
		}
Example #35
0
 public StackFrame(long address, string addressSpace, SourceLocation location, string language, bool isExternalCode, bool hasDebugInfo, string fullModuleName, string fullTypeName)
     : this(address, addressSpace, location, language, isExternalCode, hasDebugInfo, false, fullModuleName, fullTypeName)
 {
 }
		public StackFrame (long address, SourceLocation location, string language)
			: this (address, location, language, string.IsNullOrEmpty (location.Filename), true)
		{
		}
Example #37
0
		static string ResolveType (string identifier, SourceLocation location)
		{
			Document doc = IdeApp.Workbench.GetDocument (location.FileName);
			if (doc != null) {
				ITextEditorResolver textEditorResolver = doc.GetContent <ITextEditorResolver> ();
				if (textEditorResolver != null) {
					ResolveResult rr = textEditorResolver.GetLanguageItem (doc.Editor.Document.LocationToOffset (location.Line, 1), identifier);
					NamespaceResolveResult ns = rr as NamespaceResolveResult;
					if (ns != null)
						return ns.Namespace;
					MemberResolveResult result = rr as MemberResolveResult;
					if (result != null && (result.ResolvedMember == null || result.ResolvedMember is IType) && result.ResolvedType != null)
						return result.ResolvedType.FullName;
				}
			}
			return null;
		}
Example #38
0
 public StackFrame(long address, SourceLocation location, string language, bool isExternalCode, bool hasDebugInfo)
     : this(address, "", location, language, string.IsNullOrEmpty(location.FileName), true, "", "")
 {
 }