~ubuntu-branches/ubuntu/lucid/monodevelop/lucid

« back to all changes in this revision

Viewing changes to src/core/Mono.Debugging/Mono.Debugging.Client/DebuggerSession.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-02-02 11:39:59 UTC
  • mfrom: (1.2.6 upstream) (1.3.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100202113959-s4exdz7er7igylz2
Tags: 2.2.1+dfsg-1
* New upstream release
* debian/control:
  + Standards version 3.8.4 (no changes needed)
* debian/patches/remove_support_for_non_debian_functionality.patch,
  debian/patches/remove_support_for_soft_debugger.patch,
  debian/patches/remove_support_for_moonlight.patch,
  debian/rules:
  + Split patch into two pieces, to make it easier to enable either
    SDB or Moonlight support with a rebuild
* debian/monodevelop-moonlight.install,
  debian/monodevelop-debugger-sdb.install,
  debian/control:
  + Create packaging data for the Soft Debugger addin and Moonlight addin -
    and comment them out of debian/control as we can't provide them on
    Debian for now

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
using System.Collections.Generic;
32
32
using Mono.Debugging.Backend;
33
33
using System.Diagnostics;
 
34
using System.Threading;
34
35
 
35
36
namespace Mono.Debugging.Client
36
37
{
38
39
        public delegate void ProcessEventHandler(int process_id);
39
40
        public delegate void ThreadEventHandler(int thread_id);
40
41
        public delegate bool ExceptionHandler (Exception ex);
 
42
        public delegate string TypeResolverHandler (string identifier, SourceLocation location);
41
43
        
42
44
        public abstract class DebuggerSession: IDisposable
43
45
        {
56
58
                BreakEventHitHandler customBreakpointHitHandler;
57
59
                ExceptionHandler exceptionHandler;
58
60
                DebuggerSessionOptions options;
 
61
                Dictionary<string,string> resolvedExpressionCache = new Dictionary<string, string> ();
59
62
                
60
63
                ProcessInfo[] currentProcesses;
61
64
                
96
99
                        get { return exceptionHandler; }
97
100
                        set { exceptionHandler = value; }
98
101
                }
 
102
                
 
103
                public TypeResolverHandler TypeResolverHandler { get; set; }
99
104
 
100
105
                public BreakpointStore Breakpoints {
101
106
                        get {
461
466
 
462
467
                void BreakpointStoreCheckingReadOnly (object sender, ReadOnlyCheckEventArgs e)
463
468
                {
464
 
                        lock (slock) {
465
 
                                e.SetReadOnly (!AllowBreakEventChanges);
 
469
                        // When this used 'lock', it was a common cause of deadlocks, as it is called on a timeout from the GUI 
 
470
                        // thread, so if something else held the session lock, the GUI would deadlock. Instead we use TryEnter,
 
471
                        // so the worst that can happen is that users won't be able to modify breakpoints.
 
472
                        //FIXME: why do we always lock accesses to AllowBreakEventChanges? Only MonoDebuggerSession needs it locked.
 
473
                        bool entered = false;
 
474
                        try {
 
475
                                entered = Monitor.TryEnter (slock, TimeSpan.FromMilliseconds (10));
 
476
                                e.SetReadOnly (!entered || !AllowBreakEventChanges);
 
477
                        } finally {
 
478
                                if (entered)
 
479
                                        Monitor.Exit (slock);
466
480
                        }
467
481
                }
468
482
                
562
576
                        }
563
577
                }
564
578
                
 
579
                public string ResolveExpression (string expression, string file, int line, int column)
 
580
                {
 
581
                        return ResolveExpression (expression, new SourceLocation (null, file, line, column));
 
582
                }
 
583
                
 
584
                public virtual string ResolveExpression (string expression, SourceLocation location)
 
585
                {
 
586
                        if (TypeResolverHandler == null)
 
587
                                return expression;
 
588
                        else {
 
589
                                string key = expression + " " + location;
 
590
                                string resolved;
 
591
                                if (!resolvedExpressionCache.TryGetValue (key, out resolved)) {
 
592
                                        resolved = OnResolveExpression (expression, location);
 
593
                                        resolvedExpressionCache [key] = resolved;
 
594
                                }
 
595
                                return resolved;
 
596
                        }
 
597
                }
 
598
                
 
599
                Mono.Debugging.Evaluation.NRefactoryEvaluator defaultResolver = new Mono.Debugging.Evaluation.NRefactoryEvaluator ();
 
600
                
 
601
                protected virtual string OnResolveExpression (string expression, SourceLocation location)
 
602
                {
 
603
                        return defaultResolver.Resolve (this, location, expression);
 
604
                }
 
605
                
 
606
                internal protected string ResolveIdentifierAsType (string identifier, SourceLocation location)
 
607
                {
 
608
                        if (TypeResolverHandler != null)
 
609
                                return TypeResolverHandler (identifier, location);
 
610
                        else
 
611
                                return null;
 
612
                }
 
613
                
565
614
                internal ThreadInfo[] GetThreads (long processId)
566
615
                {
567
616
                        lock (slock) {