Class: Ragweed::Debuggertux::Breakpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/ragweed/debuggertux.rb

Overview

Class to handle installing/uninstalling breakpoints

Constant Summary collapse

INT3 =
0xCC

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip, callable, p, name = "") ⇒ Breakpoint

ip: insertion point callable: lambda to be called when breakpoint is hit p: process ID name: name of breakpoint



30
31
32
33
34
35
36
37
38
# File 'lib/ragweed/debuggertux.rb', line 30

def initialize(ip, callable, p, name = "")
	  @bppid = p
  @function = name
  @addr = ip
  @callable = callable
  @installed = false
  @exited = false
  @orig = 0
end

Instance Attribute Details

#addrObject (readonly)

Returns the value of attribute addr.



24
25
26
# File 'lib/ragweed/debuggertux.rb', line 24

def addr
  @addr
end

#bppidObject

Returns the value of attribute bppid.



23
24
25
# File 'lib/ragweed/debuggertux.rb', line 23

def bppid
  @bppid
end

#functionObject

Returns the value of attribute function.



23
24
25
# File 'lib/ragweed/debuggertux.rb', line 23

def function
  @function
end

#installedObject

Returns the value of attribute installed.



23
24
25
# File 'lib/ragweed/debuggertux.rb', line 23

def installed
  @installed
end

#origObject

Returns the value of attribute orig.



23
24
25
# File 'lib/ragweed/debuggertux.rb', line 23

def orig
  @orig
end

Instance Method Details

#call(*args) ⇒ Object



59
# File 'lib/ragweed/debuggertux.rb', line 59

def call(*args); @callable.call(*args) if @callable != nil; end

#installObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/ragweed/debuggertux.rb', line 40

def install
  @orig = Ragweed::Wraptux::ptrace(Ragweed::Wraptux::Ptrace::PEEK_TEXT, @bppid, @addr, 0)
  if @orig != -1
    n = (@orig & ~0xff) | INT3;
    Ragweed::Wraptux::ptrace(Ragweed::Wraptux::Ptrace::POKE_TEXT, @bppid, @addr, n)
    @installed = true
  else
    @installed = false
  end
end

#installed?Boolean

Returns:

  • (Boolean)


58
# File 'lib/ragweed/debuggertux.rb', line 58

def installed?; @installed; end

#uninstallObject



51
52
53
54
55
56
# File 'lib/ragweed/debuggertux.rb', line 51

def uninstall
  if @orig != INT3
    a = Ragweed::Wraptux::ptrace(Ragweed::Wraptux::Ptrace::POKE_TEXT, @bppid, @addr, @orig)
    @installed = false
  end
end