~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        {
49
49
                InternalDebuggerSession frontend;
50
50
                Dictionary<BreakEvent,BreakEventInfo> breakpoints = new Dictionary<BreakEvent,BreakEventInfo> ();
51
 
                bool isRunning;
52
 
                bool started;
53
51
                BreakpointStore breakpointStore;
54
52
                OutputWriterDelegate outputWriter;
55
53
                OutputWriterDelegate logWriter;
250
248
                                        ownedBreakpointStore = false;
251
249
                                        
252
250
                                        if (breakpointStore != null) {
253
 
                                                if (started) {
 
251
                                                if (IsConnected) {
254
252
                                                        foreach (BreakEvent bp in breakpointStore)
255
253
                                                                AddBreakEvent (bp);
256
254
                                                }
267
265
                void Dispatch (Action action)
268
266
                {
269
267
                        if (UseOperationThread) {
270
 
                                System.Threading.ThreadPool.QueueUserWorkItem (delegate {
 
268
                                ThreadPool.QueueUserWorkItem (delegate {
271
269
                                        lock (slock) {
272
270
                                                action ();
273
271
                                        }
503
501
                /// </summary>
504
502
                public BreakEventStatus GetBreakEventStatus (BreakEvent be)
505
503
                {
506
 
                        if (started) {
 
504
                        if (IsConnected) {
507
505
                                BreakEventInfo binfo;
508
506
                                lock (breakpoints) {
509
507
                                        if (breakpoints.TryGetValue (be, out binfo))
512
510
                        }
513
511
                        return BreakEventStatus.NotBound;
514
512
                }
515
 
                
 
513
 
516
514
                /// <summary>
517
515
                /// Returns a status message of a breakpoint for this debugger session.
518
516
                /// </summary>
519
517
                public string GetBreakEventStatusMessage (BreakEvent be)
520
518
                {
521
 
                        if (started) {
 
519
                        if (IsConnected) {
522
520
                                BreakEventInfo binfo;
523
521
                                lock (breakpoints) {
524
522
                                        if (breakpoints.TryGetValue (be, out binfo)) {
573
571
                                        try {
574
572
                                                OnRemoveBreakEvent (binfo);
575
573
                                        } catch (Exception ex) {
576
 
                                                if (started)
 
574
                                                if (IsConnected)
577
575
                                                        OnDebuggerOutput (false, ex.Message);
578
576
                                                HandleException (ex);
579
577
                                                return false;
592
590
                                        try {
593
591
                                                OnEnableBreakEvent (binfo, be.Enabled);
594
592
                                        } catch (Exception ex) {
595
 
                                                if (started)
 
593
                                                if (IsConnected)
596
594
                                                        OnDebuggerOutput (false, ex.Message);
597
595
                                                HandleException (ex);
598
596
                                        }
616
614
                                        return;
617
615
                        }
618
616
                        lock (slock) {
619
 
                                if (started)
 
617
                                if (IsConnected)
620
618
                                        AddBreakEvent (args.BreakEvent);
621
619
                        }
622
620
                }
628
626
                                        return;
629
627
                        }
630
628
                        lock (slock) {
631
 
                                if (started)
 
629
                                if (IsConnected)
632
630
                                        RemoveBreakEvent (args.BreakEvent);
633
631
                        }
634
632
                }
636
634
                void OnBreakpointModified (object s, BreakEventArgs args)
637
635
                {
638
636
                        lock (slock) {
639
 
                                if (started)
 
637
                                if (IsConnected)
640
638
                                        UpdateBreakEvent (args.BreakEvent);
641
639
                        }
642
640
                }
644
642
                void OnBreakpointStatusChanged (object s, BreakEventArgs args)
645
643
                {
646
644
                        lock (slock) {
647
 
                                if (started)
 
645
                                if (IsConnected)
648
646
                                        UpdateBreakEventStatus (args.BreakEvent);
649
647
                        }
650
648
                }
728
726
                                }
729
727
                        });
730
728
                }
 
729
 
 
730
                /// <summary>
 
731
                /// Gets a value indicating whether the debuggee is currently connected
 
732
                /// </summary>
 
733
                public bool IsConnected {
 
734
                        get; private set;
 
735
                }
731
736
                
732
737
                /// <summary>
733
738
                /// Gets a value indicating whether the debuggee is currently running (not paused by the debugger)
734
739
                /// </summary>
735
740
                public bool IsRunning {
736
 
                        get {
737
 
                                return isRunning;
738
 
                        }
 
741
                        get; private set;
 
742
                }
 
743
 
 
744
                /// <summary>
 
745
                /// Gets a value indicating whether the debuggee has exited.
 
746
                /// </summary>
 
747
                public bool HasExited {
 
748
                        get; protected set;
739
749
                }
740
750
                
741
751
                /// <summary>
863
873
                {
864
874
                }
865
875
                
866
 
                Mono.Debugging.Evaluation.ExpressionEvaluator defaultResolver = new Mono.Debugging.Evaluation.NRefactoryEvaluator ();
 
876
                Mono.Debugging.Evaluation.ExpressionEvaluator defaultResolver = new Mono.Debugging.Evaluation.NRefactoryExpressionEvaluator ();
867
877
                Dictionary <string, IExpressionEvaluator> evaluators = new Dictionary <string, IExpressionEvaluator> ();
868
878
 
869
879
                internal IExpressionEvaluator FindExpressionEvaluator (StackFrame frame)
917
927
                {
918
928
                        if (TypeResolverHandler != null)
919
929
                                return TypeResolverHandler (identifier, location);
920
 
                        else
921
 
                                return null;
 
930
 
 
931
                        return null;
922
932
                }
923
933
                
924
934
                internal ThreadInfo[] GetThreads (long processId)
964
974
                                activeThread = args.Thread;
965
975
                        }
966
976
                        if (args.Backtrace != null)
967
 
                                args.Backtrace.Attach (this);
968
 
 
 
977
                                args.Backtrace.Attach (this);
 
978
 
969
979
                        EventHandler<TargetEventArgs> evnt = null;
970
980
                        switch (args.Type) {
971
 
                                case TargetEventType.ExceptionThrown:
972
 
                                        lock (slock) {
973
 
                                                isRunning = false;
974
 
                                                args.IsStopEvent = true;
975
 
                                        }
976
 
                                        evnt = TargetExceptionThrown;
977
 
                                        break;
978
 
                                case TargetEventType.TargetExited:
979
 
                                        lock (slock) {
980
 
                                                isRunning = false;
981
 
                                                started = false;
982
 
                                        }
983
 
                                        EventHandler exited = TargetExited;
984
 
                                        if (exited != null)
985
 
                                                exited (this, args);
986
 
                                        break;
987
 
                                case TargetEventType.TargetHitBreakpoint:
988
 
                                        lock (slock) {
989
 
                                                isRunning = false;
990
 
                                                args.IsStopEvent = true;
991
 
                                        }
992
 
                                        evnt = TargetHitBreakpoint;
993
 
                                        break;
994
 
                                case TargetEventType.TargetInterrupted:
995
 
                                        lock (slock) {
996
 
                                                isRunning = false;
997
 
                                                args.IsStopEvent = true;
998
 
                                        }
999
 
                                        evnt = TargetInterrupted;
1000
 
                                        break;
1001
 
                                case TargetEventType.TargetSignaled:
1002
 
                                        lock (slock) {
1003
 
                                                isRunning = false;
1004
 
                                                args.IsStopEvent = true;
1005
 
                                        }
1006
 
                                        evnt = TargetSignaled;
1007
 
                                        break;
1008
 
                                case TargetEventType.TargetStopped:
1009
 
                                        lock (slock) {
1010
 
                                                isRunning = false;
1011
 
                                                args.IsStopEvent = true;
1012
 
                                        }
1013
 
                                        evnt = TargetStopped;
1014
 
                                        break;
1015
 
                                case TargetEventType.UnhandledException:
1016
 
                                        lock (slock) {
1017
 
                                                isRunning = false;
1018
 
                                                args.IsStopEvent = true;
1019
 
                                        }
1020
 
                                        evnt = TargetUnhandledException;
1021
 
                                        break;
1022
 
                                case TargetEventType.TargetReady:
1023
 
                                        evnt = TargetReady;
1024
 
                                        break;
1025
 
                                case TargetEventType.ThreadStarted:
1026
 
                                        evnt = TargetThreadStarted;
1027
 
                                        break;
1028
 
                                case TargetEventType.ThreadStopped:
1029
 
                                        evnt = TargetThreadStopped;
1030
 
                                        break;
1031
 
                        }
1032
 
                        
1033
 
                        if (evnt != null)
1034
 
                                evnt (this, args);
1035
 
 
 
981
                        case TargetEventType.ExceptionThrown:
 
982
                                lock (slock) {
 
983
                                        IsRunning = false;
 
984
                                        args.IsStopEvent = true;
 
985
                                }
 
986
                                evnt = TargetExceptionThrown;
 
987
                                break;
 
988
                        case TargetEventType.TargetExited:
 
989
                                lock (slock) {
 
990
                                        IsRunning = false;
 
991
                                        IsConnected = false;
 
992
                                        HasExited = true;
 
993
                                }
 
994
                                EventHandler handler = TargetExited;
 
995
                                if (handler != null)
 
996
                                        handler (this, args);
 
997
                                break;
 
998
                        case TargetEventType.TargetHitBreakpoint:
 
999
                                lock (slock) {
 
1000
                                        IsRunning = false;
 
1001
                                        args.IsStopEvent = true;
 
1002
                                }
 
1003
                                evnt = TargetHitBreakpoint;
 
1004
                                break;
 
1005
                        case TargetEventType.TargetInterrupted:
 
1006
                                lock (slock) {
 
1007
                                        IsRunning = false;
 
1008
                                        args.IsStopEvent = true;
 
1009
                                }
 
1010
                                evnt = TargetInterrupted;
 
1011
                                break;
 
1012
                        case TargetEventType.TargetSignaled:
 
1013
                                lock (slock) {
 
1014
                                        IsRunning = false;
 
1015
                                        args.IsStopEvent = true;
 
1016
                                }
 
1017
                                evnt = TargetSignaled;
 
1018
                                break;
 
1019
                        case TargetEventType.TargetStopped:
 
1020
                                lock (slock) {
 
1021
                                        IsRunning = false;
 
1022
                                        args.IsStopEvent = true;
 
1023
                                }
 
1024
                                evnt = TargetStopped;
 
1025
                                break;
 
1026
                        case TargetEventType.UnhandledException:
 
1027
                                lock (slock) {
 
1028
                                        IsRunning = false;
 
1029
                                        args.IsStopEvent = true;
 
1030
                                }
 
1031
                                evnt = TargetUnhandledException;
 
1032
                                break;
 
1033
                        case TargetEventType.TargetReady:
 
1034
                                evnt = TargetReady;
 
1035
                                break;
 
1036
                        case TargetEventType.ThreadStarted:
 
1037
                                evnt = TargetThreadStarted;
 
1038
                                break;
 
1039
                        case TargetEventType.ThreadStopped:
 
1040
                                evnt = TargetThreadStopped;
 
1041
                                break;
 
1042
                        }
 
1043
 
 
1044
                        if (evnt != null)
 
1045
                                evnt (this, args);
 
1046
 
1036
1047
                        EventHandler<TargetEventArgs> targetEvent = TargetEvent;
1037
1048
                        if (targetEvent != null)
1038
1049
                                targetEvent (this, args);
1040
1051
                
1041
1052
                internal void OnRunning ()
1042
1053
                {
1043
 
                        isRunning = true;
 
1054
                        IsRunning = true;
1044
1055
                        if (TargetStarted != null)
1045
1056
                                TargetStarted (this, EventArgs.Empty);
1046
1057
                }
1052
1063
                
1053
1064
                internal protected virtual void OnStarted (ThreadInfo t)
1054
1065
                {
 
1066
                        if (HasExited)
 
1067
                                return;
 
1068
 
1055
1069
                        OnTargetEvent (new TargetEventArgs (TargetEventType.TargetReady) { Thread = t });
 
1070
 
1056
1071
                        lock (slock) {
1057
 
                                started = true;
1058
 
                                foreach (BreakEvent bp in breakpointStore)
1059
 
                                        AddBreakEvent (bp);
 
1072
                                if (!HasExited) {
 
1073
                                        IsConnected = true;
 
1074
                                        foreach (BreakEvent bp in breakpointStore)
 
1075
                                                AddBreakEvent (bp);
 
1076
                                }
1060
1077
                        }
1061
1078
                }
1062
1079
                
1199
1216
                {
1200
1217
                        if (exceptionHandler != null)
1201
1218
                                return exceptionHandler (ex);
1202
 
                        else
1203
 
                                return false;
 
1219
 
 
1220
                        return false;
1204
1221
                }
1205
1222
                
1206
 
                internal void AdjustBreakpointLocation (Breakpoint b, int newLine)
 
1223
                internal void AdjustBreakpointLocation (Breakpoint b, int newLine, int newColumn)
1207
1224
                {
1208
1225
                        lock (breakpoints) {
1209
1226
                                try {
1210
1227
                                        adjustingBreakpoints = true;
1211
 
                                        Breakpoints.AdjustBreakpointLine (b, newLine);
 
1228
                                        Breakpoints.AdjustBreakpointLine (b, newLine, newColumn);
1212
1229
                                } finally {
1213
1230
                                        adjustingBreakpoints = false;
1214
1231
                                }