Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cosmetic changes.

svn path=/trunk/debugger/; revision=152395
  • Loading branch information...
commit bd963107f4d3c4d19fb554dc5b23d784d81e78a5 1 parent 4c4f667
authored February 24, 2010
125  backend/SingleSteppingEngine.cs
@@ -1367,6 +1367,44 @@ void update_current_frame (StackFrame new_frame)
1367 1367
 			current_frame = new_frame;
1368 1368
 		}
1369 1369
 
  1370
+		StackFrame compute_frame (TargetAddress address)
  1371
+		{
  1372
+			var method = Lookup (address);
  1373
+
  1374
+			var iframe = inferior.GetCurrentFrame ();
  1375
+			var registers = inferior.GetRegisters ();
  1376
+
  1377
+			if ((method != null) && method.HasLineNumbers) {
  1378
+				var source = method.LineNumberTable.Lookup (address);
  1379
+
  1380
+				if (source != null)
  1381
+					return new StackFrame (
  1382
+						thread, FrameType.Normal, iframe.Address, iframe.StackPointer,
  1383
+						iframe.FrameAddress, registers, method, source);
  1384
+				else
  1385
+					return new StackFrame (
  1386
+						thread, FrameType.Normal, iframe.Address, iframe.StackPointer,
  1387
+						iframe.FrameAddress, registers, method);
  1388
+			} else {
  1389
+				if (method != null)
  1390
+					return new StackFrame (
  1391
+						thread, FrameType.Normal, iframe.Address, iframe.StackPointer,
  1392
+						iframe.FrameAddress, registers, method);
  1393
+				else {
  1394
+					Symbol name;
  1395
+					try {
  1396
+						name = SimpleLookup (address, false);
  1397
+					} catch {
  1398
+						name = null;
  1399
+					}
  1400
+					return new StackFrame (
  1401
+						thread, FrameType.Normal, iframe.Address, iframe.StackPointer,
  1402
+						iframe.FrameAddress, registers, thread.NativeLanguage,
  1403
+						name);
  1404
+				}
  1405
+			}
  1406
+		}
  1407
+
1370 1408
 		TemporaryBreakpointData temp_breakpoint = null;
1371 1409
 
1372 1410
 		void insert_temporary_breakpoint (TargetAddress address)
@@ -2241,7 +2279,7 @@ public bool ManagedCallback (ManagedCallbackFunction func, CommandResult result)
2241 2279
 
2242 2280
 				AcquireThreadLock ();
2243 2281
 
2244  
-				if (do_managed_callback (data)) {
  2282
+				if (is_managed_frame ()) {
2245 2283
 					//
2246 2284
 					// We found a managed frame; now let's first check whether we can do
2247 2285
 					// all the work without starting an operation.
@@ -2258,13 +2296,17 @@ public bool ManagedCallback (ManagedCallbackFunction func, CommandResult result)
2258 2296
 					return true;
2259 2297
 				}
2260 2298
 
2261  
-				Report.Debug (DebugFlags.SSE, "{0} managed callback needs thread lock", this);
  2299
+				//
  2300
+				// Stop all threads and check whether one of them is in managed land.
  2301
+				//
  2302
+
  2303
+				Report.Debug (DebugFlags.SSE, "{0} managed callback needs global thread lock", this);
2262 2304
 
2263 2305
 				bool ok = false;
2264 2306
 				process.AcquireGlobalThreadLock (this);
2265 2307
 				foreach (SingleSteppingEngine engine in process.ThreadServants) {
2266 2308
 					try {
2267  
-						if (engine.do_managed_callback (data)) {
  2309
+						if (engine.is_managed_frame ()) {
2268 2310
 							ok = true;
2269 2311
 							break;
2270 2312
 						}
@@ -2274,39 +2316,14 @@ public bool ManagedCallback (ManagedCallbackFunction func, CommandResult result)
2274 2316
 				}
2275 2317
 
2276 2318
 				if (!ok) {
2277  
-					TargetAddress lmf_address = inferior.ReadAddress (LMFAddress);
2278  
-					StackFrame lmf_frame = Architecture.GetLMF (this, inferior, ref lmf_address);
2279  
-
2280  
-					Report.Debug (DebugFlags.SSE, "{0} requesting managed callback: {1}", this, lmf_frame);
2281  
-					process.MonoManager.AddManagedCallback (inferior, data);
2282  
-
2283  
-					/*
2284  
-					 * Prevent a race condition:
2285  
-					 * If we stopped just before returning from native code,
2286  
-					 * mono_thread_interruption_checkpoint_request() may not be called again
2287  
-					 * before returning back to managed code; it's called next time we're entering
2288  
-					 * native code again.
2289  
-					 *
2290  
-					 * This could lead to problems if the managed code does some CPU-intensive
2291  
-					 * before going unmanaged next time - or even loops forever.
2292  
-					 *
2293  
-					 * I have a test case where an icall contains a sleep() and the managed code
2294  
-					 * contains an infinite loop (`for (;;) ;) immediately after returning from
2295  
-					 * this icall.
2296  
-					 *
2297  
-					 * To prevent this from happening, we insert a breakpoint on the last managed
2298  
-					 * frame.
2299  
-					 */
2300  
-
2301  
-					if (lmf_frame != null)
2302  
-						insert_lmf_breakpoint (lmf_frame.TargetAddress);
2303  
-					else {
2304  
-						Report.Error ("{0} unable to compute LMF for managed callback: {1}",
2305  
-							      this, inferior.CurrentFrame);
2306  
-					}
  2319
+					//
  2320
+					// None of the threads is currently in managed land; request a managed
  2321
+					// callback.
  2322
+					//
  2323
+					request_managed_callback (data);
2307 2324
 				}
2308 2325
 
2309  
-				Report.Debug (DebugFlags.SSE, "{0} managed callback releasing thread lock", this);
  2326
+				Report.Debug (DebugFlags.SSE, "{0} managed callback releasing global thread lock", this);
2310 2327
 				process.ReleaseGlobalThreadLock (this);
2311 2328
 
2312 2329
 				ReleaseThreadLock ();
@@ -2391,7 +2408,7 @@ void remove_lmf_breakpoint ()
2391 2408
 			lmf_breakpoint = null;
2392 2409
 		}
2393 2410
 
2394  
-		bool do_managed_callback (ManagedCallbackData data)
  2411
+		bool is_managed_frame ()
2395 2412
 		{
2396 2413
 			Inferior.StackFrame sframe = inferior.GetCurrentFrame ();
2397 2414
 			Method method = Lookup (inferior.CurrentFrame);
@@ -2408,6 +2425,40 @@ bool do_managed_callback (ManagedCallbackData data)
2408 2425
 			return true;
2409 2426
 		}
2410 2427
 
  2428
+		void request_managed_callback (ManagedCallbackData data)
  2429
+		{
  2430
+			TargetAddress lmf_address = inferior.ReadAddress (LMFAddress);
  2431
+			StackFrame lmf_frame = Architecture.GetLMF (this, inferior, ref lmf_address);
  2432
+
  2433
+			Report.Debug (DebugFlags.SSE, "{0} requesting managed callback: {1}", this, lmf_frame);
  2434
+			process.MonoManager.AddManagedCallback (inferior, data);
  2435
+
  2436
+			/*
  2437
+			 * Prevent a race condition:
  2438
+			 * If we stopped just before returning from native code,
  2439
+			 * mono_thread_interruption_checkpoint_request() may not be called again
  2440
+			 * before returning back to managed code; it's called next time we're entering
  2441
+			 * native code again.
  2442
+			 *
  2443
+			 * This could lead to problems if the managed code does some CPU-intensive
  2444
+			 * before going unmanaged next time - or even loops forever.
  2445
+			 *
  2446
+			 * I have a test case where an icall contains a sleep() and the managed code
  2447
+			 * contains an infinite loop (`for (;;) ;) immediately after returning from
  2448
+			 * this icall.
  2449
+			 *
  2450
+			 * To prevent this from happening, we insert a breakpoint on the last managed
  2451
+			 * frame.
  2452
+			 */
  2453
+
  2454
+			if (lmf_frame != null)
  2455
+				insert_lmf_breakpoint (lmf_frame.TargetAddress);
  2456
+			else {
  2457
+				Report.Error ("{0} unable to compute LMF for managed callback: {1}",
  2458
+					      this, inferior.CurrentFrame);
  2459
+			}
  2460
+		}
  2461
+
2411 2462
 		LMFBreakpointData lmf_breakpoint = null;
2412 2463
 
2413 2464
 		internal bool OnManagedCallback (Queue<ManagedCallbackData> callbacks)
@@ -4459,7 +4510,7 @@ protected class OperationMonoTrampoline : Operation
4459 4510
 
4460 4511
 		protected override void DoExecute ()
4461 4512
 		{
4462  
-			if (sse.MonoDebuggerInfo.HasNewTrampolineNotification ()) {
  4513
+			if (sse.MonoDebuggerInfo.HasNewTrampolineNotification) {
4463 4514
 				sse.enable_extended_notification (NotificationType.Trampoline);
4464 4515
 				sse.do_continue (CallSite.Address + CallSite.InstructionSize);
4465 4516
 			} else {
@@ -4476,7 +4527,7 @@ public override bool ResumeOperation ()
4476 4527
 
4477 4528
 		protected void TrampolineCompiled (TargetAddress mono_method, TargetAddress code)
4478 4529
 		{
4479  
-			if (sse.MonoDebuggerInfo.HasNewTrampolineNotification ()) {
  4530
+			if (sse.MonoDebuggerInfo.HasNewTrampolineNotification) {
4480 4531
 				sse.disable_extended_notification (NotificationType.Trampoline);
4481 4532
 				sse.remove_temporary_breakpoint ();
4482 4533
 			} else {
5  backend/mono/MonoThreadManager.cs
@@ -578,9 +578,8 @@ public bool CheckRuntimeVersion (int major, int minor)
578 578
 			return MinorVersion >= minor;
579 579
 		}
580 580
 
581  
-		public bool HasNewTrampolineNotification ()
582  
-		{
583  
-			return CheckRuntimeVersion (80, 2) || CheckRuntimeVersion (81, 4);
  581
+		public bool HasNewTrampolineNotification {
  582
+			get { return CheckRuntimeVersion (80, 2) || CheckRuntimeVersion (81, 4); }
584 583
 		}
585 584
 
586 585
 		protected MonoDebuggerInfo (TargetMemoryAccess memory, TargetReader reader)
4  classes/StackFrame.cs
@@ -404,6 +404,10 @@ void compute_source ()
404 404
 			get { return exc_object; }
405 405
 		}
406 406
 
  407
+		public bool IsManaged {
  408
+			get { return (language != null) && language.IsManaged; }
  409
+		}
  410
+
407 411
 		internal void SetExceptionObject (TargetObject exc_object)
408 412
 		{
409 413
 			this.exc_object = exc_object;
2  frontend/Expression.cs
@@ -3070,6 +3070,8 @@ protected TargetObject DoInvoke (ScriptingContext context, bool debug)
3070 3070
 			} catch (TargetException ex) {
3071 3071
 				throw new ScriptingException (
3072 3072
 					"Invocation of `{0}' raised an exception: {1}", Name, ex.Message);
  3073
+			} catch (EvaluationTimeoutException ex) {
  3074
+				throw new ScriptingException ("Invocation of `{0}' timed out.", Name);
3073 3075
 			}
3074 3076
 		}
3075 3077
 

0 notes on commit bd96310

Please sign in to comment.
Something went wrong with that request. Please try again.