ruby-debug 0.7.5 → 0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 0.8
2
+ - Extract the base debugger API into a separate gem (ruby-debug-base), so it will be easier to add a new interface.
3
+ - Added 'set autoirb' setting.
4
+ - Bugfixes.
5
+
1
6
  0.7.5
2
7
  - Fixed 'reload on' command
3
8
  - 'reload on' command is removed in favor of 'set autoreload'
data/bin/rdebug CHANGED
@@ -45,6 +45,7 @@ EOB
45
45
  end
46
46
  end
47
47
  opts.on("--keep-frame-binding", "Keep frame bindings") {options.frame_bind = true}
48
+ opts.on("--emacs", "Activates emacs mode") {ENV['EMACS'] = '1'}
48
49
  opts.separator ""
49
50
  opts.separator "Common options:"
50
51
  opts.on_tail("--help", "Show this message") do
@@ -89,22 +90,22 @@ else
89
90
  trap('INT') { Debugger.interrupt_last }
90
91
 
91
92
  # set options
92
- Debugger.stop_on_connect = !options.nostop
93
93
  Debugger.wait_connection = options.wait
94
94
  Debugger.keep_frame_binding = options.frame_bind
95
95
 
96
96
  load_initrc = lambda do
97
97
  script_file = "#{ENV["HOME"] || ENV["HOMEPATH" || "."]}/.rdebugrc"
98
- Debugger.run_script script_file if File.exists?(script_file)
98
+ Debugger.run_script script_file, StringIO.new if File.exists?(script_file)
99
99
  end
100
100
 
101
101
  if options.server
102
102
  # start remote mode
103
- Debugger.start_remote(options.host, [options.port, options.cport], options.post_mortem)
104
- # load initrc script
105
- load_initrc.call
103
+ Debugger.start_remote(options.host, [options.port, options.cport], options.post_mortem) do
104
+ # load initrc script
105
+ load_initrc.call
106
+ end
106
107
  # load script
107
- Debugger.debug_load Debugger::PROG_SCRIPT
108
+ Debugger.debug_load Debugger::PROG_SCRIPT, !options.nostop
108
109
  else
109
110
  # activate debugger
110
111
  Debugger.start
@@ -120,12 +121,8 @@ else
120
121
  end
121
122
  # activate post-mortem
122
123
  Debugger.post_mortem if options.post_mortem
123
- if options.tracing
124
- Debugger.tracing = true
125
- else
126
- debugger 2 unless options.nostop
127
- end
124
+ Debugger.tracing = options.nostop = true if options.tracing
128
125
  # load script
129
- Debugger.debug_load Debugger::PROG_SCRIPT
126
+ Debugger.debug_load Debugger::PROG_SCRIPT, !options.nostop
130
127
  end
131
128
  end
data/cli/ruby-debug.rb ADDED
@@ -0,0 +1,117 @@
1
+ require 'pp'
2
+ require 'stringio'
3
+ require 'socket'
4
+ require 'thread'
5
+ require 'ruby-debug-base'
6
+ require 'ruby-debug/processor'
7
+
8
+ module Debugger
9
+ self.handler = CommandProcessor.new
10
+
11
+ # the port number used for remote debugging
12
+ PORT = 8989
13
+
14
+ class << self
15
+ # in remote mode, wait for the remote connection
16
+ attr_accessor :wait_connection
17
+
18
+ attr_reader :thread, :control_thread
19
+
20
+ def interface=(value) # :nodoc:
21
+ processor.interface = value
22
+ end
23
+
24
+ #
25
+ # Starts a remote debugger.
26
+ #
27
+ def start_remote(host = nil, port = PORT, post_mortem = false)
28
+ return if @thread
29
+ return if started?
30
+
31
+ self.interface = nil
32
+ start
33
+ self.post_mortem if post_mortem
34
+
35
+ if port.kind_of?(Array)
36
+ cmd_port, ctrl_port = port
37
+ else
38
+ cmd_port, ctrl_port = port, port + 1
39
+ end
40
+
41
+ start_control(host, ctrl_port)
42
+
43
+ yield if block_given?
44
+
45
+ mutex = Mutex.new
46
+ proceed = ConditionVariable.new
47
+
48
+ @thread = DebugThread.new do
49
+ server = TCPServer.new(host, cmd_port)
50
+ while (session = server.accept)
51
+ self.interface = RemoteInterface.new(session)
52
+ if wait_connection
53
+ mutex.synchronize do
54
+ proceed.signal
55
+ end
56
+ end
57
+ end
58
+ end
59
+ if wait_connection
60
+ mutex.synchronize do
61
+ proceed.wait(mutex)
62
+ end
63
+ end
64
+ end
65
+ alias start_server start_remote
66
+
67
+ def start_control(host = nil, ctrl_port = PORT + 1)
68
+ raise "Debugger is not started" unless started?
69
+ return if @control_thread
70
+ @control_thread = DebugThread.new do
71
+ server = TCPServer.new(host, ctrl_port)
72
+ while (session = server.accept)
73
+ interface = RemoteInterface.new(session)
74
+ processor = ControlCommandProcessor.new(interface)
75
+ processor.process_commands
76
+ end
77
+ end
78
+ end
79
+
80
+ #
81
+ # Connects to the remote debugger
82
+ #
83
+ def start_client(host = 'localhost', port = PORT)
84
+ require "socket"
85
+ interface = Debugger::LocalInterface.new
86
+ socket = TCPSocket.new(host, port)
87
+ puts "Connected."
88
+
89
+ catch(:exit) do
90
+ while (line = socket.gets)
91
+ case line
92
+ when /^PROMPT (.*)$/
93
+ input = interface.read_command($1)
94
+ throw :exit unless input
95
+ socket.puts input
96
+ when /^CONFIRM (.*)$/
97
+ input = interface.confirm($1)
98
+ throw :exit unless input
99
+ socket.puts input
100
+ else
101
+ print line
102
+ end
103
+ end
104
+ end
105
+ socket.close
106
+ end
107
+
108
+ #
109
+ # Runs a script file
110
+ #
111
+ def run_script(file, out = processor.interface)
112
+ interface = ScriptInterface.new(file, out)
113
+ processor = ControlCommandProcessor.new(interface)
114
+ processor.process_commands
115
+ end
116
+ end
117
+ end
@@ -18,7 +18,7 @@ module Debugger
18
18
  klass.options[o] = v if klass.options[o].nil?
19
19
  end
20
20
  commands << klass
21
- end
21
+ end
22
22
 
23
23
  def load_commands
24
24
  dir = File.dirname(__FILE__)
@@ -89,19 +89,8 @@ module Debugger
89
89
  end
90
90
  end
91
91
 
92
- def hbinding(hash)
93
- code = hash.keys.map{|k| "#{k} = hash['#{k}']"}.join(';') + ';binding'
94
- if obj = @state.context.frame_self(@state.frame_pos)
95
- obj.instance_eval code
96
- else
97
- eval code
98
- end
99
- end
100
- private :hbinding
101
-
102
92
  def get_binding
103
- binding = @state.context.frame_binding(@state.frame_pos)
104
- binding || hbinding(@state.context.frame_locals(@state.frame_pos))
93
+ @state.context.frame_binding(@state.frame_pos)
105
94
  end
106
95
 
107
96
  def line_at(file, line)
File without changes
File without changes
@@ -53,6 +53,8 @@ module Debugger
53
53
  cmd = Debugger::RDEBUG_SCRIPT + " " + args
54
54
  print "Re exec'ing:\n\t#{cmd}\n"
55
55
  exec cmd
56
+ rescue Errno::EOPNOTSUPP
57
+ print "Restart command is not available at this time.\n"
56
58
  end
57
59
 
58
60
  class << self
File without changes
@@ -31,6 +31,7 @@ module Debugger
31
31
  %{
32
32
  e[val] expression\tevaluate expression and print its value,
33
33
  \t\t\talias for p.
34
+ * NOTE - to turn on autoeval, use 'set autoeval'
34
35
  }
35
36
  end
36
37
  end
File without changes
@@ -21,7 +21,7 @@ module Debugger
21
21
  cmds.each do |cmd|
22
22
  if buf.length + cmd.length > 70
23
23
  print "%s\n", buf
24
- buf = ""
24
+ buf = "#{cmd} "
25
25
  else
26
26
  buf << cmd << ' '
27
27
  end
File without changes
@@ -40,7 +40,7 @@ module Debugger
40
40
  l[ist] -\tlist backward
41
41
  l[ist] =\tlist current line
42
42
  l[ist] nn-mm\tlist given lines
43
- l[ist] on/off\tprint listing on every stop
43
+ * NOTE - to turn on autolist, use 'set autolist'
44
44
  }
45
45
  end
46
46
  end
@@ -66,7 +66,7 @@ module Debugger
66
66
  end
67
67
  end
68
68
 
69
- class ReloadCommand < Command # :nodoc
69
+ class ReloadCommand < Command # :nodoc:
70
70
  self.control = true
71
71
 
72
72
  def regexp
File without changes
File without changes
@@ -20,6 +20,9 @@ module Debugger
20
20
  when /^(no)?autoreload$/
21
21
  Debugger.reload_source_on_change = $1.nil?
22
22
  print "autoreload is #{$1.nil? ? 'on' : 'off'}.\n"
23
+ when /^(no)?autoirb$/
24
+ IRBCommand.always_run = $1.nil?
25
+ print "autoirb is #{$1.nil? ? 'on' : 'off'}.\n"
23
26
  else
24
27
  print "Unknown setting.\n"
25
28
  end
@@ -36,6 +39,7 @@ module Debugger
36
39
  autolist - execute 'list' command on every breakpoint
37
40
  autoeval - evaluate every unrecognized command
38
41
  autoreload - enables automatic source code reloading
42
+ autoirb - debugger invokes IRB on every stop
39
43
  trace - display stack trace when 'eval' raises exception
40
44
  To disable setting, use 'no' prefix, like 'noautolist'
41
45
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -62,7 +62,7 @@ module Debugger
62
62
  protect :at_tracing
63
63
 
64
64
  def at_line(context, file, line)
65
- print "%s:%d: %s", file, line, Debugger.line_at(file, line)
65
+ print "#{"\032\032" if ENV['EMACS']}%s:%d %s", file, line, Debugger.line_at(file, line)
66
66
  process_commands(context, file, line)
67
67
  end
68
68
  protect :at_line
@@ -92,9 +92,11 @@ module Debugger
92
92
  s.interface = interface
93
93
  s.commands = event_cmds
94
94
  end
95
+ @interface.state = state if @interface.respond_to?('state=')
96
+
95
97
  commands = event_cmds.map{|cmd| cmd.new(state) }
96
98
  commands.select{|cmd| cmd.class.always_run }.each{|cmd| cmd.execute }
97
-
99
+
98
100
  splitter = lambda do |str|
99
101
  str.split(/;/).inject([]) do |m, v|
100
102
  if m.empty?
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.1
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ruby-debug
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.5
7
- date: 2007-02-09 02:00:27 -05:00
8
- summary: Fast Ruby debugger
6
+ version: "0.8"
7
+ date: 2007-03-14 22:59:58 -04:00
8
+ summary: Command line interface (CLI) for ruby-debug
9
9
  require_paths:
10
- - lib
10
+ - cli
11
11
  email: ksibilev@yahoo.com
12
12
  homepage: http://rubyforge.org/projects/ruby-debug/
13
13
  rubyforge_project: ruby-debug
14
- description: ruby-debug is a fast implementation of the standard Ruby debugger debug.rb. It's implemented by utilizing a new hook Ruby C API.
14
+ description: A generic command line interface for ruby-debug.
15
15
  autorequire: ruby-debug
16
16
  default_executable:
17
17
  bindir: bin
@@ -29,49 +29,53 @@ post_install_message:
29
29
  authors:
30
30
  - Kent Sibilev
31
31
  files:
32
- - Rakefile
33
32
  - README
34
33
  - LICENSE
35
34
  - CHANGES
36
35
  - AUTHORS
37
- - lib/ruby-debug
38
- - lib/ruby-debug.rb
39
- - lib/ruby-debug/commands
40
- - lib/ruby-debug/command.rb
41
- - lib/ruby-debug/processor.rb
42
- - lib/ruby-debug/interface.rb
43
- - lib/ruby-debug/commands/breakpoints.rb
44
- - lib/ruby-debug/commands/method.rb
45
- - lib/ruby-debug/commands/control.rb
46
- - lib/ruby-debug/commands/stepping.rb
47
- - lib/ruby-debug/commands/eval.rb
48
- - lib/ruby-debug/commands/help.rb
49
- - lib/ruby-debug/commands/catchpoint.rb
50
- - lib/ruby-debug/commands/threads.rb
51
- - lib/ruby-debug/commands/frame.rb
52
- - lib/ruby-debug/commands/script.rb
53
- - lib/ruby-debug/commands/trace.rb
54
- - lib/ruby-debug/commands/display.rb
55
- - lib/ruby-debug/commands/variables.rb
56
- - lib/ruby-debug/commands/tmate.rb
57
- - lib/ruby-debug/commands/list.rb
58
- - lib/ruby-debug/commands/irb.rb
59
- - lib/ruby-debug/commands/settings.rb
60
- - ext/win32
61
- - ext/extconf.rb
62
- - ext/ruby_debug.c
63
36
  - bin/rdebug
37
+ - cli/ruby-debug
38
+ - cli/ruby-debug/command.rb
39
+ - cli/ruby-debug/commands
40
+ - cli/ruby-debug/commands/breakpoints.rb
41
+ - cli/ruby-debug/commands/catchpoint.rb
42
+ - cli/ruby-debug/commands/control.rb
43
+ - cli/ruby-debug/commands/display.rb
44
+ - cli/ruby-debug/commands/eval.rb
45
+ - cli/ruby-debug/commands/frame.rb
46
+ - cli/ruby-debug/commands/help.rb
47
+ - cli/ruby-debug/commands/irb.rb
48
+ - cli/ruby-debug/commands/list.rb
49
+ - cli/ruby-debug/commands/method.rb
50
+ - cli/ruby-debug/commands/script.rb
51
+ - cli/ruby-debug/commands/settings.rb
52
+ - cli/ruby-debug/commands/stepping.rb
53
+ - cli/ruby-debug/commands/threads.rb
54
+ - cli/ruby-debug/commands/tmate.rb
55
+ - cli/ruby-debug/commands/trace.rb
56
+ - cli/ruby-debug/commands/variables.rb
57
+ - cli/ruby-debug/interface.rb
58
+ - cli/ruby-debug/processor.rb
59
+ - cli/ruby-debug.rb
64
60
  test_files: []
65
61
 
66
62
  rdoc_options: []
67
63
 
68
- extra_rdoc_files: []
69
-
64
+ extra_rdoc_files:
65
+ - README
70
66
  executables:
71
67
  - rdebug
72
- extensions:
73
- - ext/extconf.rb
74
- requirements: []
68
+ extensions: []
75
69
 
76
- dependencies: []
70
+ requirements: []
77
71
 
72
+ dependencies:
73
+ - !ruby/object:Gem::Dependency
74
+ name: ruby-debug-base
75
+ version_requirement:
76
+ version_requirements: !ruby/object:Gem::Version::Requirement
77
+ requirements:
78
+ - - "="
79
+ - !ruby/object:Gem::Version
80
+ version: "0.8"
81
+ version:
data/Rakefile DELETED
@@ -1,120 +0,0 @@
1
- require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require 'rake/rdoctask'
4
-
5
- SO_NAME = "ruby_debug.so"
6
-
7
- # ------- Default Package ----------
8
- RUBY_DEBUG_VERSION = open("ext/ruby_debug.c"){|f| f.grep(/^#define DEBUG_VERSION/).first[/"(.+)"/,1]}
9
-
10
- FILES = FileList[
11
- 'Rakefile',
12
- 'README',
13
- 'LICENSE',
14
- 'CHANGES',
15
- 'AUTHORS',
16
- 'lib/**/*',
17
- 'ext/*',
18
- 'doc/*',
19
- 'bin/*'
20
- ]
21
-
22
- # Default GEM Specification
23
- default_spec = Gem::Specification.new do |spec|
24
- spec.name = "ruby-debug"
25
-
26
- spec.homepage = "http://rubyforge.org/projects/ruby-debug/"
27
- spec.summary = "Fast Ruby debugger"
28
- spec.description = <<-EOF
29
- ruby-debug is a fast implementation of the standard Ruby debugger debug.rb.
30
- It's implemented by utilizing a new hook Ruby C API.
31
- EOF
32
-
33
- spec.version = RUBY_DEBUG_VERSION
34
-
35
- spec.author = "Kent Sibilev"
36
- spec.email = "ksibilev@yahoo.com"
37
- spec.platform = Gem::Platform::RUBY
38
- spec.require_path = "lib"
39
- spec.bindir = "bin"
40
- spec.executables = ["rdebug"]
41
- spec.extensions = ["ext/extconf.rb"]
42
- spec.autorequire = "ruby-debug"
43
- spec.files = FILES.to_a
44
-
45
- spec.required_ruby_version = '>= 1.8.2'
46
- spec.date = DateTime.now
47
- spec.rubyforge_project = 'ruby-debug'
48
-
49
- # rdoc
50
- spec.has_rdoc = true
51
- end
52
-
53
- # Rake task to build the default package
54
- Rake::GemPackageTask.new(default_spec) do |pkg|
55
- pkg.need_tar = true
56
- pkg.need_tar = true
57
- end
58
-
59
- task :default => [:package]
60
-
61
- # Windows specification
62
- win_spec = default_spec.clone
63
- win_spec.extensions = []
64
- win_spec.platform = Gem::Platform::WIN32
65
- win_spec.files += ["lib/#{SO_NAME}"]
66
-
67
- desc "Create Windows Gem"
68
- task :win32_gem do
69
- # Copy the win32 extension the top level directory
70
- current_dir = File.expand_path(File.dirname(__FILE__))
71
- source = File.join(current_dir, "ext", "win32", SO_NAME)
72
- target = File.join(current_dir, "lib", SO_NAME)
73
- cp(source, target)
74
-
75
- # Create the gem, then move it to pkg
76
- Gem::Builder.new(win_spec).build
77
- gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
78
- mv(gem_file, "pkg/#{gem_file}")
79
-
80
- # Remove win extension fro top level directory
81
- rm(target)
82
- end
83
-
84
-
85
- desc "Publish ruby-debug to RubyForge."
86
- task :publish do
87
- require 'rake/contrib/sshpublisher'
88
-
89
- # Get ruby-debug path
90
- ruby_debug_path = File.expand_path(File.dirname(__FILE__))
91
-
92
- publisher = Rake::SshDirPublisher.new("kent@rubyforge.org",
93
- "/var/www/gforge-projects/ruby-debug", ruby_debug_path)
94
- end
95
-
96
- desc "Clear temp files"
97
- task :clean do
98
- cd "ext" do
99
- if File.exists?("Makefile")
100
- sh "make clean"
101
- rm "Makefile"
102
- end
103
- end
104
- end
105
-
106
- # --------- RDoc Documentation ------
107
- desc "Generate rdoc documentation"
108
- Rake::RDocTask.new("rdoc") do |rdoc|
109
- rdoc.rdoc_dir = 'doc'
110
- rdoc.title = "ruby-debug"
111
- # Show source inline with line numbers
112
- rdoc.options << "--inline-source" << "--line-numbers"
113
- # Make the readme file the start page for the generated html
114
- rdoc.options << '--main' << 'README'
115
- rdoc.rdoc_files.include('bin/**/*',
116
- 'lib/**/*.rb',
117
- 'ext/**/ruby_debug.c',
118
- 'README',
119
- 'LICENSE')
120
- end