byebug 3.2.0 → 3.3.0

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.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +125 -99
  4. data/CONTRIBUTING.md +4 -6
  5. data/GUIDE.md +42 -20
  6. data/Gemfile +5 -3
  7. data/README.md +2 -3
  8. data/Rakefile +11 -7
  9. data/bin/byebug +2 -252
  10. data/byebug.gemspec +7 -4
  11. data/ext/byebug/byebug.c +17 -18
  12. data/ext/byebug/byebug.h +4 -5
  13. data/ext/byebug/context.c +37 -39
  14. data/ext/byebug/threads.c +39 -18
  15. data/lib/byebug.rb +2 -110
  16. data/lib/byebug/attacher.rb +23 -0
  17. data/lib/byebug/breakpoint.rb +60 -0
  18. data/lib/byebug/command.rb +62 -70
  19. data/lib/byebug/commands/break.rb +24 -24
  20. data/lib/byebug/commands/catchpoint.rb +18 -10
  21. data/lib/byebug/commands/condition.rb +18 -17
  22. data/lib/byebug/commands/continue.rb +17 -9
  23. data/lib/byebug/commands/delete.rb +19 -13
  24. data/lib/byebug/commands/display.rb +19 -53
  25. data/lib/byebug/commands/edit.rb +7 -4
  26. data/lib/byebug/commands/enable_disable.rb +130 -0
  27. data/lib/byebug/commands/eval.rb +40 -22
  28. data/lib/byebug/commands/finish.rb +13 -4
  29. data/lib/byebug/commands/frame.rb +65 -45
  30. data/lib/byebug/commands/help.rb +17 -18
  31. data/lib/byebug/commands/history.rb +14 -8
  32. data/lib/byebug/commands/info.rb +160 -182
  33. data/lib/byebug/commands/interrupt.rb +4 -1
  34. data/lib/byebug/commands/irb.rb +30 -0
  35. data/lib/byebug/commands/kill.rb +7 -8
  36. data/lib/byebug/commands/list.rb +71 -66
  37. data/lib/byebug/commands/method.rb +14 -6
  38. data/lib/byebug/commands/pry.rb +35 -0
  39. data/lib/byebug/commands/quit.rb +9 -6
  40. data/lib/byebug/commands/reload.rb +5 -2
  41. data/lib/byebug/commands/restart.rb +13 -9
  42. data/lib/byebug/commands/save.rb +17 -17
  43. data/lib/byebug/commands/set.rb +16 -15
  44. data/lib/byebug/commands/show.rb +10 -11
  45. data/lib/byebug/commands/source.rb +11 -5
  46. data/lib/byebug/commands/stepping.rb +38 -24
  47. data/lib/byebug/commands/threads.rb +45 -31
  48. data/lib/byebug/commands/trace.rb +22 -9
  49. data/lib/byebug/commands/undisplay.rb +45 -0
  50. data/lib/byebug/commands/variables.rb +83 -27
  51. data/lib/byebug/context.rb +25 -22
  52. data/lib/byebug/core.rb +82 -0
  53. data/lib/byebug/helper.rb +37 -28
  54. data/lib/byebug/history.rb +8 -4
  55. data/lib/byebug/interface.rb +12 -17
  56. data/lib/byebug/interfaces/local_interface.rb +11 -8
  57. data/lib/byebug/interfaces/remote_interface.rb +11 -8
  58. data/lib/byebug/interfaces/script_interface.rb +9 -6
  59. data/lib/byebug/options.rb +46 -0
  60. data/lib/byebug/processor.rb +7 -1
  61. data/lib/byebug/processors/command_processor.rb +135 -125
  62. data/lib/byebug/processors/control_command_processor.rb +23 -23
  63. data/lib/byebug/remote.rb +17 -26
  64. data/lib/byebug/runner.rb +100 -0
  65. data/lib/byebug/setting.rb +33 -8
  66. data/lib/byebug/settings/autoeval.rb +5 -15
  67. data/lib/byebug/settings/autoirb.rb +4 -1
  68. data/lib/byebug/settings/autolist.rb +5 -2
  69. data/lib/byebug/settings/autoreload.rb +5 -2
  70. data/lib/byebug/settings/autosave.rb +6 -2
  71. data/lib/byebug/settings/basename.rb +7 -2
  72. data/lib/byebug/settings/callstyle.rb +4 -1
  73. data/lib/byebug/settings/forcestep.rb +6 -3
  74. data/lib/byebug/settings/fullpath.rb +5 -2
  75. data/lib/byebug/settings/histfile.rb +5 -3
  76. data/lib/byebug/settings/histsize.rb +5 -3
  77. data/lib/byebug/settings/linetrace.rb +4 -1
  78. data/lib/byebug/settings/listsize.rb +5 -1
  79. data/lib/byebug/settings/post_mortem.rb +21 -13
  80. data/lib/byebug/settings/stack_on_error.rb +6 -2
  81. data/lib/byebug/settings/testing.rb +6 -1
  82. data/lib/byebug/settings/tracing_plus.rb +5 -1
  83. data/lib/byebug/settings/verbose.rb +13 -2
  84. data/lib/byebug/settings/width.rb +4 -1
  85. data/lib/byebug/version.rb +1 -1
  86. data/test/{break_test.rb → commands/break_test.rb} +41 -53
  87. data/test/{condition_test.rb → commands/condition_test.rb} +14 -14
  88. data/test/{continue_test.rb → commands/continue_test.rb} +0 -0
  89. data/test/{delete_test.rb → commands/delete_test.rb} +2 -2
  90. data/test/commands/display_test.rb +37 -0
  91. data/test/{edit_test.rb → commands/edit_test.rb} +0 -0
  92. data/test/{eval_test.rb → commands/eval_test.rb} +1 -0
  93. data/test/{finish_test.rb → commands/finish_test.rb} +11 -1
  94. data/test/{frame_test.rb → commands/frame_test.rb} +12 -16
  95. data/test/{help_test.rb → commands/help_test.rb} +21 -4
  96. data/test/{history_test.rb → commands/history_test.rb} +0 -0
  97. data/test/{info_test.rb → commands/info_test.rb} +5 -55
  98. data/test/{interrupt_test.rb → commands/interrupt_test.rb} +0 -0
  99. data/test/commands/irb_test.rb +28 -0
  100. data/test/{kill_test.rb → commands/kill_test.rb} +1 -1
  101. data/test/{list_test.rb → commands/list_test.rb} +1 -1
  102. data/test/{method_test.rb → commands/method_test.rb} +0 -0
  103. data/test/{post_mortem_test.rb → commands/post_mortem_test.rb} +6 -10
  104. data/test/{pry_test.rb → commands/pry_test.rb} +4 -13
  105. data/test/{quit_test.rb → commands/quit_test.rb} +4 -4
  106. data/test/{reload_test.rb → commands/reload_test.rb} +0 -0
  107. data/test/{restart_test.rb → commands/restart_test.rb} +6 -0
  108. data/test/{save_test.rb → commands/save_test.rb} +2 -2
  109. data/test/{set_test.rb → commands/set_test.rb} +9 -2
  110. data/test/{show_test.rb → commands/show_test.rb} +1 -1
  111. data/test/{source_test.rb → commands/source_test.rb} +3 -3
  112. data/test/{stepping_test.rb → commands/stepping_test.rb} +44 -35
  113. data/test/{thread_test.rb → commands/thread_test.rb} +0 -0
  114. data/test/{trace_test.rb → commands/trace_test.rb} +0 -0
  115. data/test/{display_test.rb → commands/undisplay_test.rb} +7 -45
  116. data/test/{variables_test.rb → commands/variables_test.rb} +10 -1
  117. data/test/debugger_alias_test.rb +2 -2
  118. data/test/runner_test.rb +127 -0
  119. data/test/support/matchers.rb +27 -25
  120. data/test/support/test_interface.rb +9 -5
  121. data/test/support/utils.rb +96 -101
  122. data/test/test_helper.rb +32 -20
  123. metadata +93 -68
  124. data/lib/byebug/commands/enable.rb +0 -154
  125. data/lib/byebug/commands/repl.rb +0 -126
  126. data/test/irb_test.rb +0 -47
  127. data/test/support/breakpoint.rb +0 -13
data/Gemfile CHANGED
@@ -6,10 +6,12 @@ gem 'rake', '~> 10.3'
6
6
 
7
7
  group :development do
8
8
  gem 'rake-compiler', '~> 0.9'
9
- gem 'mocha', '~> 1.1'
10
- gem 'minitest', '~> 5.4'
9
+ gem 'rubocop', '~> 0.25'
11
10
  end
12
11
 
13
12
  group :test do
14
- gem 'codeclimate-test-reporter', '~> 0.4', require: nil
13
+ gem 'mocha', '~> 1.1'
14
+ gem 'minitest', '~> 5.4'
15
+ gem 'simplecov', '~> 0.9', require: false
16
+ gem 'codeclimate-test-reporter', '~> 0.4', require: false
15
17
  end
data/README.md CHANGED
@@ -71,7 +71,7 @@ both rails and rspec have deprecated these flags in their latest versions.
71
71
  `frame` | |
72
72
  `help` | |
73
73
  `history` | |
74
- `info` | | `args` `breakpoints` `catch` `display` `file` `files` `global_variables` `instance_variables` `line` `locals` `program` `variables`
74
+ `info` | | `args` `breakpoints` `catch` `display` `file` `files` `line` `program`
75
75
  `irb` | |
76
76
  `kill` | |
77
77
  `list` | |
@@ -95,7 +95,7 @@ both rails and rspec have deprecated these flags in their latest versions.
95
95
  `tracevar` | |
96
96
  `undisplay` | |
97
97
  `up` | |
98
- `var` | | `class` `constant` `global` `instance` `local`
98
+ `var` | | `all` `class` `constant` `global` `instance` `local`
99
99
 
100
100
 
101
101
  ## Semantic Versioning
@@ -130,7 +130,6 @@ for ruby debugging on Sublime Text.
130
130
 
131
131
  * Write tests for remote debugging support.
132
132
  * Add printers support.
133
- * Libify and test byebug's executable.
134
133
  * Support rubies other than MRI.
135
134
 
136
135
  ## Credits
data/Rakefile CHANGED
@@ -6,10 +6,14 @@ Rake::ExtensionTask.new('byebug') do |ext|
6
6
  ext.lib_dir = 'lib/byebug'
7
7
  end
8
8
 
9
- # Override default rake tests loader
10
- class Rake::TestTask
11
- def rake_loader
12
- 'test/test_helper.rb'
9
+ module Rake
10
+ #
11
+ # Overrides default rake tests loader
12
+ #
13
+ class TestTask
14
+ def rake_loader
15
+ 'test/test_helper.rb'
16
+ end
13
17
  end
14
18
  end
15
19
 
@@ -18,7 +22,7 @@ task :test do
18
22
  Rake::TestTask.new do |t|
19
23
  t.verbose = true
20
24
  t.warning = true
21
- t.pattern = 'test/*_test.rb'
25
+ t.pattern = 'test/**/*_test.rb'
22
26
  end
23
27
  end
24
28
 
@@ -26,8 +30,8 @@ task default: :test
26
30
 
27
31
  desc 'Run a test in looped mode so that you can look for memory leaks'
28
32
  task 'test_loop' do
29
- code = %Q[loop{ require '#{$*[1]}' }]
30
- cmd = %Q[ruby -Itest -e "#{ code }"]
33
+ code = %(loop{ require '#{$ARGV[1]}' })
34
+ cmd = %(ruby -Itest -e "#{ code }")
31
35
  system cmd
32
36
  end
33
37
 
data/bin/byebug CHANGED
@@ -1,255 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- #=== Summary
4
- #
5
- #A command-line front-end to <tt>byebug</tt>
6
- #
7
- #Command invocation:
8
- #
9
- # byebug [options] [--] [script-options] ruby-script-to-debug
10
- # byebug [options] [script-options]
11
- # byebug [--version | --help]
12
- #
13
- #=== Options
14
- #
15
- #<tt>-d | --debug</tt>::
16
- # Set $DEBUG true.
17
- #
18
- #<tt>--help</tt>::
19
- # Show invocation help and exit.
20
- #
21
- #<tt>-I | --include</tt> <i>path</i>
22
- # Add <i>path</i> to <tt>$LOAD_PATH</tt>. Like the <tt>ruby -I</tt> command,
23
- # it supports multiple load paths separated by colons.
24
- #
25
- #<tt>--post-mortem</tt>::
26
- # Activate post-mortem mode.
27
- #
28
- #<tt>--no-quit</tt>::
29
- # Do not quit when script terminates. Instead rerun the program.
30
- #
31
- #<tt>--no-stop</tt>::
32
- # Do not stop when script is loaded.
33
- #
34
- #<tt>--nx</tt>::
35
- # Don’t execute commands found in any initialization files like
36
- # <tt>.byebugrc</tt>.
37
- #
38
- #<tt>-r | --require</tt><i>script</i>::
39
- # Require the library, before executing your script.
40
- #
41
- #<tt>--script</tt>=<i>file</i>::
42
- # Run script file <i>file</i>
43
- #
44
- #<tt>--v</tt>::
45
- # Print the version number, then turn on verbose mode if a script name is
46
- # given. If no script name is given just exit after printing the version
47
- # number.
48
- #
49
- #<tt>--verbose</tt>::
50
- # Turn on verbose mode.
51
- #
52
- #<tt>--version</tt>::
53
- # Show the version number and exit.
54
- #
55
- #<tt>-x | --trace</tt>::
56
- # Show lines before executing them.
57
- #
3
+ require 'byebug/runner'
58
4
 
59
- require 'optparse'
60
- require 'ostruct'
61
- require File.dirname(__FILE__) + "/../lib/byebug"
62
-
63
- def debug_program(options)
64
- # Make sure Ruby script syntax checks okay.
65
- output = `ruby -c "#{Byebug::PROG_SCRIPT}" 2>&1`
66
- if $?.exitstatus != 0
67
- puts output
68
- exit $?.exitstatus
69
- end
70
- if bt = Byebug.debug_load(Byebug::PROG_SCRIPT, options.stop)
71
- p bt, bt.backtrace
72
- end
73
- end
74
-
75
- #
76
- # Do a shell-like path lookup for prog_script and return the results. If we
77
- # can't find anything return prog_script.
78
- #
79
- def whence_file(prog_script)
80
- if prog_script.index(File::SEPARATOR)
81
- # Don't search since this name has path separator components
82
- return prog_script
83
- end
84
-
85
- for dirname in ENV['PATH'].split(File::PATH_SEPARATOR) do
86
- prog_script_try = File.join(dirname, prog_script)
87
- return prog_script_try if File.exist?(prog_script_try)
88
- end
89
-
90
- # Failure
91
- return prog_script
92
- end
93
-
94
- options = OpenStruct.new(
95
- 'nx' => false,
96
- 'post_mortem' => false,
97
- 'quit' => true,
98
- 'restart_script' => nil,
99
- 'script' => nil,
100
- 'server' => nil,
101
- 'stop' => true,
102
- 'tracing' => false,
103
- )
104
-
105
- def process_options(options)
106
- program = File.basename($0)
107
- opts = OptionParser.new do |opts|
108
- opts.banner = <<EOB
109
- #{program} #{Byebug::VERSION}
110
- Usage: #{program} [options] <script.rb> -- <script.rb parameters>
111
- EOB
112
- opts.separator ""
113
- opts.separator "Options:"
114
-
115
- opts.on("-d", "--debug", "Set $DEBUG=true") {
116
- $DEBUG = true }
117
- opts.on('-I', '--include PATH', String,
118
- 'Add PATH (single or multiple:path:list) to $LOAD_PATH.') {
119
- |path| $LOAD_PATH.unshift(*path.split(':')) }
120
- opts.on('--no-quit', 'Do not quit when script finishes') {
121
- options.quit = false }
122
- opts.on('--no-stop', 'Do not stop when script is loaded') {
123
- options.stop = false }
124
- opts.on('-nx', 'Don\'t run any byebug initialization files') {
125
- options.nx = true }
126
- opts.on('--post-mortem', 'Run byebug in post-mortem mode') {
127
- options.post_mortem = true }
128
- opts.on('-r', '--require SCRIPT', String, 'Require library before script') {
129
- |name| if name == 'debug'
130
- puts 'byebug not compatible with Ruby\'s \'debug\' lib, option ignored'
131
- else
132
- require name
133
- end }
134
- opts.on('-R', '--remote HOST[:PORT]', String, 'Specify byebug server spec') {
135
- |server| host, port = server.split(':', 2)
136
- host = 'localhost' if host.empty?
137
- port = nil if port && port.empty?
138
- port &&= port.to_i
139
- options.server = [host, port].compact
140
- }
141
- opts.on('--restart-script FILE', String,
142
- 'Name of the script file to run. Erased after read') do
143
- |restart_script|
144
- options.restart_script = restart_script
145
- unless File.exist?(options.restart_script)
146
- puts "Script file '#{options.restart_script}' is not found"
147
- exit
148
- end
149
- end
150
- opts.on('--script FILE', String, 'Name of the script file to run') do
151
- |script|
152
- options.script = script
153
- unless File.exist?(options.script)
154
- puts "Script file '#{options.script}' is not found"
155
- exit
156
- end
157
- end
158
- opts.on('-x', '--trace', 'Turn on line tracing') {
159
- options.tracing = true }
160
-
161
- opts.separator ''
162
- opts.separator 'Common options:'
163
- opts.on_tail('--help', 'Show this message') do
164
- puts opts
165
- exit
166
- end
167
- opts.on_tail('--version', 'Print program version') do
168
- puts "byebug #{Byebug::VERSION}"
169
- exit
170
- end
171
- opts.on_tail('-v', 'Print version number, then turn on verbose mode') do
172
- puts "byebug #{Byebug::VERSION}"
173
- $VERBOSE = true
174
- end
175
- end
176
- return opts
177
- end
178
-
179
- # What file is used for byebug startup commands.
180
- unless defined?(OPTS_INITFILE)
181
- OPTS_INITFILE = '.byebugoptrc'
182
- HOME_DIR = ENV['HOME'].to_s
183
- end
184
-
185
- begin
186
- initfile = File.join(HOME_DIR, OPTS_INITFILE)
187
- eval(File.read(initfile)) if File.exist?(initfile)
188
- rescue
189
- end
190
-
191
- opts = process_options(options)
192
-
193
- begin
194
- Byebug::BYEBUG_SCRIPT = File.expand_path(__FILE__)
195
- Byebug::IGNORED_FILES << Byebug::BYEBUG_SCRIPT
196
- opts.parse! ARGV
197
- rescue StandardError => e
198
- puts opts
199
- puts
200
- puts e.message
201
- exit(-1)
202
- end
203
-
204
- if options.server
205
- puts "Connecting to byebug server #{options.server.join(':')}"
206
- Byebug.start_client(*options.server)
207
- exit
208
- end
209
-
210
- if ARGV.empty?
211
- puts opts
212
- puts
213
- puts 'Must specify a script to run'
214
- exit(-1)
215
- end
216
-
217
- # Save debugged program
218
- prog_script = ARGV.shift
219
- prog_script = whence_file(prog_script) unless File.exist?(prog_script)
220
- Byebug::PROG_SCRIPT = File.expand_path prog_script
221
-
222
- # Set up trace hook for byebug
223
- Byebug.start
224
-
225
- # load initrc script (e.g. .byebugrc)
226
- Byebug.run_init_script(StringIO.new) unless options.nx
227
-
228
- Byebug::Setting[:post_mortem] = options.post_mortem
229
-
230
- # run restore-settings startup script if specified
231
- if options.restart_script
232
- require 'fileutils'
233
- Byebug.run_script(options.restart_script)
234
- FileUtils.rm(options.restart_script)
235
- end
236
-
237
- # run startup script if specified
238
- if options.script
239
- Byebug.run_script(options.script)
240
- end
241
-
242
- options.stop = false if options.tracing
243
- Byebug::Setting[:linetrace] = options.tracing
244
-
245
- loop do
246
- debug_program(options)
247
-
248
- break if options.quit
249
-
250
- interface = Byebug::LocalInterface.new
251
- # Not sure if ControlCommandProcessor is really the right
252
- # thing to use. CommandProcessor requires a state.
253
- processor = Byebug::ControlCommandProcessor.new(interface)
254
- processor.process_commands
255
- end
5
+ Byebug::Runner.new.run
@@ -7,22 +7,25 @@ Gem::Specification.new do |s|
7
7
  s.email = 'deivid.rodriguez@mail.com'
8
8
  s.license = 'BSD'
9
9
  s.homepage = 'http://github.com/deivid-rodriguez/byebug'
10
- s.summary = %q{Ruby 2.0 fast debugger - base + cli}
11
- s.description = %q{Byebug is a Ruby 2 debugger. It's implemented using the
10
+ s.summary = 'Ruby 2.0 fast debugger - base + CLI'
11
+ s.description = "Byebug is a Ruby 2 debugger. It's implemented using the
12
12
  Ruby 2 TracePoint C API for execution control and the Debug Inspector C API
13
13
  for call stack navigation. The core component provides support that
14
14
  front-ends can build on. It provides breakpoint handling and bindings for
15
15
  stack frames among other things and it comes with an easy to use command
16
- line interface.}
16
+ line interface."
17
17
 
18
18
  s.required_ruby_version = '>= 2.0.0'
19
19
 
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- test/*`.split("\n")
22
+ s.bindir = 'bin'
22
23
  s.executables = ['byebug']
23
- s.extra_rdoc_files = ['README.md']
24
+ s.extra_rdoc_files = %w(README.md GUIDE.md)
24
25
  s.extensions = ['ext/byebug/extconf.rb']
26
+ s.require_path = 'lib'
25
27
 
26
28
  s.add_dependency 'columnize', '~> 0.8'
29
+ s.add_dependency 'slop', '~> 3.6'
27
30
  s.add_dependency 'debugger-linecache', '~> 1.2'
28
31
  end
@@ -12,12 +12,11 @@ static VALUE tracepoints = Qnil;
12
12
 
13
13
  static VALUE raised_exception = Qnil;
14
14
 
15
- /* Implements thread syncronization, we must stop threads when debugging */
15
+ /* To allow thread syncronization, we must stop threads when debugging */
16
16
  VALUE locker = Qnil;
17
17
 
18
- /* Threads table */
18
+ /* Hash table with active threads and their associated contexts */
19
19
  VALUE threads = Qnil;
20
- VALUE cThreadsTable;
21
20
 
22
21
  #define IS_STARTED (catchpoints != Qnil)
23
22
  static void
@@ -34,15 +33,13 @@ trace_print(rb_trace_arg_t *trace_arg, debug_context_t *dc)
34
33
  {
35
34
  if (trace_arg)
36
35
  {
37
- int i = 0;
38
36
  const char *event = rb_id2name(SYM2ID(rb_tracearg_event(trace_arg)));
39
37
  char *path = RSTRING_PTR(rb_tracearg_path(trace_arg));
40
38
  int line = NUM2INT(rb_tracearg_lineno(trace_arg));
41
- VALUE v_mid = rb_tracearg_method_id(trace_arg);
42
- const char *mid = NIL_P(v_mid) ? "" : rb_id2name(SYM2ID(v_mid));
43
-
44
- for (i = 0; i < dc->calced_stack_size; i++) putc('-', stdout);
45
- printf("(%d)->[#%d] %s@%s:%d %s\n",
39
+ VALUE v_mid_sym = rb_tracearg_method_id(trace_arg);
40
+ VALUE v_mid_id = NIL_P(v_mid_sym) ? Qnil : SYM2ID(v_mid_sym);
41
+ const char *mid = NIL_P(v_mid_id) ? "" : rb_id2name(v_mid_id);
42
+ printf("%*s (%d)->[#%d] %s@%s:%d %s\n", dc->calced_stack_size, "",
46
43
  dc->calced_stack_size, dc->thnum, event, path, line, mid);
47
44
  }
48
45
  }
@@ -55,7 +52,7 @@ cleanup(debug_context_t *dc)
55
52
  dc->stop_reason = CTX_STOP_NONE;
56
53
 
57
54
  /* checks for dead threads */
58
- check_thread_contexts();
55
+ check_threads_table();
59
56
 
60
57
  /* release a lock */
61
58
  locker = Qnil;
@@ -72,9 +69,10 @@ cleanup(debug_context_t *dc)
72
69
  VALUE context; \
73
70
  thread_context_lookup(rb_thread_current(), &context); \
74
71
  Data_Get_Struct(context, debug_context_t, dc); \
75
- if (verbose == Qtrue) trace_print(trace_arg, dc); \
76
72
 
77
- #define EVENT_COMMON if (!trace_common(trace_arg, dc)) { return; }
73
+ #define EVENT_COMMON \
74
+ if (verbose == Qtrue) trace_print(trace_arg, dc); \
75
+ if (!trace_common(trace_arg, dc)) { return; } \
78
76
 
79
77
  static int
80
78
  trace_common(rb_trace_arg_t *trace_arg, debug_context_t *dc)
@@ -216,7 +214,7 @@ line_event(VALUE trace_point, void *data)
216
214
  if (dc->calced_stack_size < dc->dest_frame)
217
215
  {
218
216
  dc->dest_frame = dc->calced_stack_size;
219
- rb_funcall(mByebug, rb_intern("print"), 1,
217
+ rb_funcall(mByebug, rb_intern("puts"), 1,
220
218
  rb_str_new2("Next went up a frame because previous frame finished\n"));
221
219
  }
222
220
  }
@@ -458,8 +456,8 @@ bb_contexts(VALUE self)
458
456
  rb_ary_push(new_list, context);
459
457
  }
460
458
 
461
- threads_clear(threads);
462
459
  Data_Get_Struct(threads, threads_table_t, t_tbl);
460
+ st_clear(t_tbl->tbl);
463
461
 
464
462
  for (i = 0; i < RARRAY_LENINT(new_list); i++)
465
463
  {
@@ -569,7 +567,7 @@ bb_start(VALUE self)
569
567
  locker = Qnil;
570
568
  breakpoints = rb_ary_new();
571
569
  catchpoints = rb_hash_new();
572
- threads = threads_create();
570
+ threads = create_threads_table();
573
571
 
574
572
  register_tracepoints(self);
575
573
  result = Qtrue;
@@ -606,6 +604,8 @@ bb_load(int argc, VALUE *argv, VALUE self)
606
604
  context = bb_current_context(self);
607
605
  Data_Get_Struct(context, debug_context_t, dc);
608
606
 
607
+ dc->calced_stack_size = 1;
608
+
609
609
  if (RTEST(stop)) dc->steps = 1;
610
610
 
611
611
  /* Initializing $0 to the script's path */
@@ -709,7 +709,7 @@ bb_set_post_mortem(VALUE self, VALUE value)
709
709
  static VALUE
710
710
  bb_breakpoints(VALUE self)
711
711
  {
712
- return breakpoints;
712
+ return NIL_P(breakpoints) ? rb_ary_new() : breakpoints;
713
713
  }
714
714
 
715
715
  /*
@@ -783,8 +783,7 @@ Init_byebug()
783
783
  rb_define_module_function(mByebug, "verbose?" , bb_verbose , 0);
784
784
  rb_define_module_function(mByebug, "verbose=" , bb_set_verbose , 1);
785
785
 
786
- cThreadsTable = rb_define_class_under(mByebug, "ThreadsTable", rb_cObject);
787
-
786
+ Init_threads_table(mByebug);
788
787
  Init_context(mByebug);
789
788
  Init_breakpoint(mByebug);
790
789