Ejemplo n.º 1
0
		public CorDebugBacktrace (CorDebugThread thread, MicroFrameworkDebuggerSession session) : base (session.ObjectAdapter)
		{
			this.session = session;
			this.thread = thread;
			threadId = thread.Id;
			frames = new List<CorDebugFrame> (GetFrames (thread));
			evalTimestamp = MicroFrameworkDebuggerSession.EvaluationTimestamp;
		}
		internal CorEvaluationContext (MicroFrameworkDebuggerSession session, CorDebugBacktrace backtrace, int index, DC.EvaluationOptions ops) : base (ops)
		{
			Session = session;
			base.Adapter = session.ObjectAdapter;
			frameIndex = index;
			this.backtrace = backtrace;
			evalTimestamp = MicroFrameworkDebuggerSession.EvaluationTimestamp;
			Evaluator = session.GetEvaluator (CorDebugBacktrace.CreateFrame (session, Frame));
		}
Ejemplo n.º 3
0
 internal CorEvaluationContext(MicroFrameworkDebuggerSession session, CorDebugBacktrace backtrace, int index, DC.EvaluationOptions ops) : base(ops)
 {
     Session        = session;
     base.Adapter   = session.ObjectAdapter;
     frameIndex     = index;
     this.backtrace = backtrace;
     evalTimestamp  = MicroFrameworkDebuggerSession.EvaluationTimestamp;
     Evaluator      = session.GetEvaluator(CorDebugBacktrace.CreateFrame(session, Frame));
 }
Ejemplo n.º 4
0
		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);
		}
Ejemplo n.º 5
0
		public MethodSymbols GetMethodSymbols (MicroFrameworkDebuggerSession session)
		{
			if (Assembly.DebugData == null)
				return null;
			var methodSymols = new MethodSymbols (new MetadataToken (PdbxMethod.Token.CLR));
			//Ugliest hack ever
			if(Assembly.DebugData is Mono.Cecil.Mdb.MdbReader) {
				for(int i = 0; i < 100; i++)
					methodSymols.Variables.Add(new VariableDefinition(null));
			}
			Assembly.DebugData.Read (methodSymols);
			return methodSymols;
		}
Ejemplo n.º 6
0
		public MethodDefinition GetMethodInfo (MicroFrameworkDebuggerSession session)
		{
			return Assembly.MetaData != null ? Assembly.MetaData.LookupToken ((int)Token) as MethodDefinition : null;
		}
Ejemplo n.º 7
0
		public void StartDebugging (MicroFrameworkDebuggerSession corDebug, bool fLaunch)
		{
			try {
				if (m_pid == 0)
					throw new Exception (DiagnosticStrings.BogusCorDebugProcess);

				this.Init (corDebug, fLaunch);

				m_threadDispatch = new Thread (delegate() {
					try {
						VsPackage.MessageCentre.StartProgressMsg (DiagnosticStrings.DebuggingStarting);
						this.StartClr ();
						this.DispatchEvents ();
					} catch (Exception ex) {
						VsPackage.MessageCentre.StopProgressMsg ();
						VsPackage.MessageCentre.DeploymentMsg (String.Format (DiagnosticStrings.DebuggerThreadTerminated, ex.Message));
						Terminate (0);
					} finally {
						DebugAssert (ShuttingDown);

						m_eventProcessExited.Set ();

						if (m_fTerminating) {
							ManagedCallbacks.ManagedCallbackProcess mc = new ManagedCallbacks.ManagedCallbackProcess (this, ManagedCallbacks.ManagedCallbackProcess.EventType.ExitProcess);
							mc.Dispatch (corDebug.ManagedCallback);
						}

						StopDebugging ();
					}
				});
				m_threadDispatch.Start ();
			} catch (Exception) {
				Terminate (0);
				throw;
			}
		}
Ejemplo n.º 8
0
		private void UnInit ()
		{
			if (m_assemblies != null) {
				foreach (CorDebugAssembly assembly in m_assemblies) {
					((IDisposable)assembly).Dispose ();
				}

				m_assemblies = null;
			}

			if (m_port != null)
			{
				m_port.RemoveProcess(PortDefinition);
				m_port = null;
			}

			m_appDomains = null;
			m_events = null;
			m_threads = null;
			m_assemblyPaths = null;
			m_breakpoints = null;
			m_fExecutionPaused = false;
			m_eventDispatch = null;
			m_fUpdateBreakpoints = false;
			m_cStopped = 0;
			m_fLaunched = false;
			m_fTerminating = false;
			m_fDetaching = false;
			m_cEvalThreads = 0;
			m_tdBuiltin = null;
			m_scratchPad = null;

			m_threadDispatch = null;

			if (m_corDebug != null) {
				m_corDebug.UnregisterProcess (this);
				m_corDebug = null;
			}
		}
Ejemplo n.º 9
0
		private void Init (MicroFrameworkDebuggerSession corDebug, bool fLaunch)
		{
			try {
				if (IsDebugging)
					throw new Exception ("CorDebugProcess is already in debugging mode before Init() has run");

				m_corDebug = corDebug;
				m_fLaunched = fLaunch;

				m_events = Queue.Synchronized (new Queue ());
				m_threads = new ArrayList ();
				m_assemblies = new ArrayList ();
				m_appDomains = new ArrayList ();
				m_breakpoints = ArrayList.Synchronized (new ArrayList ());
				m_fExecutionPaused = true;
				m_eventDispatch = new AutoResetEvent (false);
				m_eventExecutionPaused = new ManualResetEvent (true);
				m_eventProcessExited = new ManualResetEvent (false);
				m_eventsStopped = new EventWaitHandle[] {
					m_eventExecutionPaused,
					m_eventProcessExited
				};
				m_fUpdateBreakpoints = false;
				m_cStopped = 0;
				m_fTerminating = false;
				m_cEvalThreads = 0;
				m_tdBuiltin = null;
				m_scratchPad = new ScratchPadArea (this);
				m_fakeAssemblyAddressNext = c_fakeAddressStart;
				m_threadDispatch = null;
				m_corDebug.RegisterProcess (this);
			} catch (Exception) {
				VsPackage.MessageCentre.DeploymentMsg (DiagnosticStrings.DeploymentErrorDeviceErrors);
				throw;
			}
		}
Ejemplo n.º 10
0
		public TypeDefinition GetTypeInfo (MicroFrameworkDebuggerSession session)
		{
			return Class.Assembly.MetaData != null ? Class.Assembly.MetaData.LookupToken ((int)Class.PdbxClass.Token.CLR) as TypeDefinition : null;
		}