Class: Trepan::BreakpointMgr
- Inherits:
-
Object
- Object
- Trepan::BreakpointMgr
- Defined in:
- app/brkptmgr.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#set ⇒ Object
readonly
Returns the value of attribute set.
Instance Method Summary collapse
- #<<(brkpt) ⇒ Object
- #[](index) ⇒ Object (also: #detect)
- #add(*args) ⇒ Object
- #clear ⇒ Object
- #delete(index) ⇒ Object
- #delete_by_brkpt(delete_bp) ⇒ Object
- #empty? ⇒ Boolean
-
#finalize ⇒ Object
Remove all breakpoints that we have recorded.
- #find(meth, ip) ⇒ Object
-
#initialize ⇒ BreakpointMgr
constructor
A new instance of BreakpointMgr.
- #line_breaks(cm) ⇒ Object
- #max ⇒ Object
- #reset ⇒ Object
-
#set_key(bp) ⇒ Object
Key used in @set to list unique instruction-sequence offsets.
- #size ⇒ Object
Constructor Details
#initialize ⇒ BreakpointMgr
Returns a new instance of BreakpointMgr.
11 12 13 |
# File 'app/brkptmgr.rb', line 11 def initialize clear end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
8 9 10 |
# File 'app/brkptmgr.rb', line 8 def list @list end |
#set ⇒ Object (readonly)
Returns the value of attribute set.
9 10 11 |
# File 'app/brkptmgr.rb', line 9 def set @set end |
Instance Method Details
#<<(brkpt) ⇒ Object
29 30 31 32 |
# File 'app/brkptmgr.rb', line 29 def <<(brkpt) @list << brkpt @set.add(set_key(brkpt)) end |
#[](index) ⇒ Object Also known as: detect
34 35 36 37 38 39 |
# File 'app/brkptmgr.rb', line 34 def [](index) raise TypeError, "index #{index} should be a Fixnum, is #{index.class}" unless index.is_a?(Fixnum) @list.detect {|bp| bp.id == index } end |
#add(*args) ⇒ Object
60 61 62 63 64 65 |
# File 'app/brkptmgr.rb', line 60 def add(*args) brkpt = Trepan::Breakpoint.new(*args) @list << brkpt @set.add(set_key(brkpt)) return brkpt end |
#clear ⇒ Object
15 16 17 18 |
# File 'app/brkptmgr.rb', line 15 def clear @list = [] @set = Set.new end |
#delete(index) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'app/brkptmgr.rb', line 43 def delete(index) bp = detect(index) if bp delete_by_brkpt(bp) return bp else return nil end end |
#delete_by_brkpt(delete_bp) ⇒ Object
53 54 55 56 57 58 |
# File 'app/brkptmgr.rb', line 53 def delete_by_brkpt(delete_bp) @list = @list.reject{|candidate| candidate == delete_bp} @set = Set.new(@list.map{|bp| set_key(bp)}) delete_bp.remove! unless @set.member?(set_key(delete_bp)) return delete_bp end |
#empty? ⇒ Boolean
67 68 69 |
# File 'app/brkptmgr.rb', line 67 def empty? @list.empty? end |
#finalize ⇒ Object
Remove all breakpoints that we have recorded
21 22 23 24 25 26 27 |
# File 'app/brkptmgr.rb', line 21 def finalize @list.each do |bp| bp..each { |bp| bp.remove! } bp.remove! end clear end |
#find(meth, ip) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'app/brkptmgr.rb', line 81 def find(meth, ip) @list.detect do |bp| if bp.enabled? && bp.ip == ip begin return bp ## if bp.condition?(bind) rescue end end end end |
#line_breaks(cm) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'app/brkptmgr.rb', line 71 def line_breaks(cm) result = {} @list.each do |bp| if bp.method == cm result[bp.line] = bp end end result end |
#max ⇒ Object
92 93 94 |
# File 'app/brkptmgr.rb', line 92 def max @list.map{|bp| bp.id}.max || 0 end |
#reset ⇒ Object
105 106 107 108 109 |
# File 'app/brkptmgr.rb', line 105 def reset @list.each{|bp| bp.remove!} @list = [] @set = Set.new end |
#set_key(bp) ⇒ Object
Key used in @set to list unique instruction-sequence offsets.
97 98 99 |
# File 'app/brkptmgr.rb', line 97 def set_key(bp) [bp.method, bp.ip] end |
#size ⇒ Object
101 102 103 |
# File 'app/brkptmgr.rb', line 101 def size @list.size end |