append the breakpoint to #hash_owner + #hash_shared
# File metasm/debug.rb, line 40 def add(owner=@hash_owner) @hash_owner = owner @hash_key ||= @address return add_bpm if @type == :bpm if pv = owner[@hash_key] @hash_shared = pv.hash_shared @internal ||= pv.internal @emul_instr ||= pv.emul_instr else owner[@hash_key] = self @hash_shared = [] end @hash_shared << self end
register a bpm: add references to all page start covered in @hash_owner
# File metasm/debug.rb, line 56 def add_bpm m = @address + @internal[:len] a = @address & -0x1000 @hash_shared = [self] @internal ||= {} @internal[:orig_prot] ||= {} while a < m if pv = @hash_owner[a] if not pv.hash_shared.include?(self) pv.hash_shared.concat @hash_shared-pv.hash_shared @hash_shared.each { |bpm| bpm.hash_shared = pv.hash_shared } end @internal[:orig_prot][a] = pv.internal[:orig_prot][a] else @hash_owner[a] = self end a += 0x1000 end end
delete the breakpoint from #hash_shared, and #hash_owner if empty
# File metasm/debug.rb, line 78 def del return del_bpm if @type == :bpm @hash_shared.delete self if @hash_shared.empty? @hash_owner.delete @hash_key elsif @hash_owner[@hash_key] == self @hash_owner[@hash_key] = @hash_shared.first end end
unregister a bpm
# File metasm/debug.rb, line 89 def del_bpm m = @address + @internal[:len] a = @address & -0x1000 @hash_shared.delete self while a < m pv = @hash_owner[a] if pv == self if opv = @hash_shared.find { |bpm| bpm.address < a + 0x1000 and bpm.address + bpm.internal[:len] > a } @hash_owner[a] = opv else @hash_owner.delete a # split hash_shared on disjoint ranges prev_shared = @hash_shared.find_all { |bpm| bpm.address < a + 0x1000 and bpm.address + bpm.internal[:len] <= a } prev_shared.each { |bpm| bpm.hash_shared = prev_shared @hash_shared.delete bpm } end end a += 0x1000 end end