~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Debugger/Debugger.Core/BreakpointCollection.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections.Generic;
 
6
using Debugger.Interop.CorDebug;
 
7
 
 
8
namespace Debugger
 
9
{
 
10
        public class BreakpointCollection: CollectionWithEvents<Breakpoint>
 
11
        {
 
12
                public event EventHandler<CollectionItemEventArgs<Breakpoint>> Hit;
 
13
                
 
14
                protected internal void OnHit(Breakpoint item)
 
15
                {
 
16
                        if (Hit != null) {
 
17
                                Hit(this, new CollectionItemEventArgs<Breakpoint>(item));
 
18
                        }
 
19
                }
 
20
                
 
21
                public BreakpointCollection(NDebugger debugger):base(debugger) { }
 
22
                
 
23
                internal Breakpoint this[ICorDebugBreakpoint corBreakpoint] {
 
24
                        get {
 
25
                                foreach (Breakpoint breakpoint in this) {
 
26
                                        if (breakpoint.IsOwnerOf(corBreakpoint)) {
 
27
                                                return breakpoint;
 
28
                                        }
 
29
                                }
 
30
                                return null;
 
31
                        }
 
32
                }
 
33
                
 
34
                public new void Add(Breakpoint breakpoint)
 
35
                {
 
36
                        base.Add(breakpoint);
 
37
                }
 
38
                
 
39
                public Breakpoint Add(string filename, int line)
 
40
                {
 
41
                        Breakpoint breakpoint = new Breakpoint(this.Debugger, filename, null, line, 0, true);
 
42
                        Add(breakpoint);
 
43
                        return breakpoint;
 
44
                }
 
45
                
 
46
                public Breakpoint Add(string fileName, byte[] checkSum, int line, int column, bool enabled)
 
47
                {
 
48
                        Breakpoint breakpoint = new Breakpoint(this.Debugger, fileName, checkSum, line, column, enabled);
 
49
                        Add(breakpoint);
 
50
                        return breakpoint;
 
51
                }
 
52
                
 
53
                protected override void OnAdded(Breakpoint breakpoint)
 
54
                {
 
55
                        foreach(Process process in this.Debugger.Processes) {
 
56
                                foreach(Module module in process.Modules) {
 
57
                                        breakpoint.SetBreakpoint(module);
 
58
                                }
 
59
                        }
 
60
                        
 
61
                        base.OnAdded(breakpoint);
 
62
                }
 
63
                
 
64
                public new void Remove(Breakpoint breakpoint)
 
65
                {
 
66
                        base.Remove(breakpoint);
 
67
                }
 
68
                
 
69
                protected override void OnRemoved(Breakpoint breakpoint)
 
70
                {
 
71
                        breakpoint.Deactivate();
 
72
                        
 
73
                        base.OnRemoved(breakpoint);
 
74
                }
 
75
                
 
76
                internal void SetInModule(Module module) 
 
77
                {
 
78
                        // This is in case that the client modifies the collection as a response to set breakpoint
 
79
                        // NB: If client adds new breakpoint, it will be set directly as a result of his call, not here (because module is already loaded)
 
80
                        List<Breakpoint> collection = new List<Breakpoint>();
 
81
                        collection.AddRange(this);
 
82
                        
 
83
                        foreach (Breakpoint b in collection) {
 
84
                                b.SetBreakpoint(module);
 
85
                        }
 
86
                }
 
87
        }
 
88
}