S
Sys Ppp
ruby-1.8.6-p369
ruby-debug-0.10.3
How to set breakpoints at class-methods without editing source of
library files? And without line numbers?
$ cat test.rb
require 'ruby-debug'
class Aaa
def self.cl_aaa
puts 'A A A'
end
def initialize
@aaa = 'a a a'
end
def aaa
puts @aaa
end
end
debugger
a = Aaa.new
Aaa.cl_aaa
a.aaa
$ ruby test.rb
< or >
$ rdebug test.rb
test.rb:<lineno of debugger>
a = Aaa.new
(rdb:1) b Aaa:cl_aaa
Breakpoint 1 at Aaa::cl_aaa
(rdb:1) b Aaa:aaa
Breakpoint 2 at Aaa::aaa
(rdb:1) i b
Num Enb What
1 y at Aaa:cl_aaa
2 y at Aaa:aaa
(rdb:1) cont
A A A
Breakpoint 2 at Aaa:aaa
test.rb:<lineno of 'def aaa'>
def aaa
(rdb:1) i b
Num Enb What
1 y at Aaa:cl_aaa
2 y at Aaa:aaa
breakpoint already hit 1 time
(rdb:1) cont
a a a
$
The same result if it was used '#' or '.' instead of ':', i.e.
'Class#method' or 'Class.method'.
ruby-debug-0.10.3
How to set breakpoints at class-methods without editing source of
library files? And without line numbers?
$ cat test.rb
require 'ruby-debug'
class Aaa
def self.cl_aaa
puts 'A A A'
end
def initialize
@aaa = 'a a a'
end
def aaa
puts @aaa
end
end
debugger
a = Aaa.new
Aaa.cl_aaa
a.aaa
$ ruby test.rb
< or >
$ rdebug test.rb
test.rb:<lineno of debugger>
a = Aaa.new
(rdb:1) b Aaa:cl_aaa
Breakpoint 1 at Aaa::cl_aaa
(rdb:1) b Aaa:aaa
Breakpoint 2 at Aaa::aaa
(rdb:1) i b
Num Enb What
1 y at Aaa:cl_aaa
2 y at Aaa:aaa
(rdb:1) cont
A A A
Breakpoint 2 at Aaa:aaa
test.rb:<lineno of 'def aaa'>
def aaa
(rdb:1) i b
Num Enb What
1 y at Aaa:cl_aaa
2 y at Aaa:aaa
breakpoint already hit 1 time
(rdb:1) cont
a a a
$
The same result if it was used '#' or '.' instead of ':', i.e.
'Class#method' or 'Class.method'.