byebug 3.5.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/.rubocop.yml +18 -1
  4. data/.travis.yml +21 -1
  5. data/CHANGELOG.md +356 -308
  6. data/CONTRIBUTING.md +31 -15
  7. data/GUIDE.md +859 -475
  8. data/Gemfile +8 -10
  9. data/LICENSE +1 -1
  10. data/README.md +41 -45
  11. data/Rakefile +30 -28
  12. data/byebug.gemspec +18 -18
  13. data/ext/byebug/breakpoint.c +88 -75
  14. data/ext/byebug/byebug.c +253 -252
  15. data/ext/byebug/byebug.h +53 -53
  16. data/ext/byebug/context.c +188 -159
  17. data/ext/byebug/extconf.rb +9 -6
  18. data/ext/byebug/locker.c +53 -11
  19. data/ext/byebug/threads.c +137 -39
  20. data/lib/byebug/attacher.rb +7 -2
  21. data/lib/byebug/breakpoint.rb +30 -0
  22. data/lib/byebug/command.rb +36 -32
  23. data/lib/byebug/commands/break.rb +49 -48
  24. data/lib/byebug/commands/catch.rb +64 -0
  25. data/lib/byebug/commands/condition.rb +13 -9
  26. data/lib/byebug/commands/continue.rb +8 -4
  27. data/lib/byebug/commands/delete.rb +10 -4
  28. data/lib/byebug/commands/display.rb +33 -25
  29. data/lib/byebug/commands/edit.rb +18 -13
  30. data/lib/byebug/commands/enable_disable.rb +26 -24
  31. data/lib/byebug/commands/eval.rb +77 -35
  32. data/lib/byebug/commands/finish.rb +9 -5
  33. data/lib/byebug/commands/frame.rb +66 -125
  34. data/lib/byebug/commands/help.rb +14 -21
  35. data/lib/byebug/commands/history.rb +5 -1
  36. data/lib/byebug/commands/info.rb +41 -106
  37. data/lib/byebug/commands/interrupt.rb +6 -2
  38. data/lib/byebug/commands/irb.rb +5 -2
  39. data/lib/byebug/commands/kill.rb +6 -2
  40. data/lib/byebug/commands/list.rb +21 -14
  41. data/lib/byebug/commands/method.rb +17 -9
  42. data/lib/byebug/commands/pry.rb +13 -3
  43. data/lib/byebug/commands/quit.rb +10 -5
  44. data/lib/byebug/commands/restart.rb +12 -19
  45. data/lib/byebug/commands/save.rb +10 -6
  46. data/lib/byebug/commands/set.rb +15 -14
  47. data/lib/byebug/commands/show.rb +8 -8
  48. data/lib/byebug/commands/source.rb +14 -8
  49. data/lib/byebug/commands/stepping.rb +15 -29
  50. data/lib/byebug/commands/threads.rb +73 -49
  51. data/lib/byebug/commands/tracevar.rb +56 -0
  52. data/lib/byebug/commands/undisplay.rb +8 -4
  53. data/lib/byebug/commands/untracevar.rb +38 -0
  54. data/lib/byebug/commands/var.rb +107 -0
  55. data/lib/byebug/context.rb +78 -42
  56. data/lib/byebug/core.rb +78 -40
  57. data/lib/byebug/helper.rb +58 -42
  58. data/lib/byebug/history.rb +12 -1
  59. data/lib/byebug/interface.rb +91 -11
  60. data/lib/byebug/interfaces/local_interface.rb +12 -19
  61. data/lib/byebug/interfaces/remote_interface.rb +12 -15
  62. data/lib/byebug/interfaces/script_interface.rb +14 -18
  63. data/lib/byebug/interfaces/test_interface.rb +54 -0
  64. data/lib/byebug/printers/base.rb +64 -0
  65. data/lib/byebug/printers/plain.rb +53 -0
  66. data/lib/byebug/processor.rb +20 -1
  67. data/lib/byebug/processors/command_processor.rb +57 -172
  68. data/lib/byebug/processors/control_command_processor.rb +16 -43
  69. data/lib/byebug/remote.rb +13 -7
  70. data/lib/byebug/runner.rb +102 -54
  71. data/lib/byebug/setting.rb +45 -68
  72. data/lib/byebug/settings/autoeval.rb +2 -0
  73. data/lib/byebug/settings/autoirb.rb +3 -0
  74. data/lib/byebug/settings/autolist.rb +3 -0
  75. data/lib/byebug/settings/autosave.rb +2 -0
  76. data/lib/byebug/settings/basename.rb +2 -0
  77. data/lib/byebug/settings/callstyle.rb +2 -0
  78. data/lib/byebug/settings/fullpath.rb +2 -0
  79. data/lib/byebug/settings/histfile.rb +2 -0
  80. data/lib/byebug/settings/histsize.rb +2 -0
  81. data/lib/byebug/settings/linetrace.rb +2 -0
  82. data/lib/byebug/settings/listsize.rb +2 -0
  83. data/lib/byebug/settings/post_mortem.rb +7 -2
  84. data/lib/byebug/settings/stack_on_error.rb +2 -0
  85. data/lib/byebug/settings/verbose.rb +2 -0
  86. data/lib/byebug/settings/width.rb +2 -0
  87. data/lib/byebug/state.rb +12 -0
  88. data/lib/byebug/states/control_state.rb +26 -0
  89. data/lib/byebug/states/regular_state.rb +178 -0
  90. data/lib/byebug/version.rb +1 -1
  91. metadata +24 -109
  92. data/lib/byebug/commands/catchpoint.rb +0 -53
  93. data/lib/byebug/commands/reload.rb +0 -29
  94. data/lib/byebug/commands/trace.rb +0 -50
  95. data/lib/byebug/commands/variables.rb +0 -206
  96. data/lib/byebug/options.rb +0 -46
  97. data/lib/byebug/settings/autoreload.rb +0 -12
  98. data/lib/byebug/settings/forcestep.rb +0 -14
  99. data/lib/byebug/settings/testing.rb +0 -12
  100. data/lib/byebug/settings/tracing_plus.rb +0 -11
  101. data/test/commands/break_test.rb +0 -364
  102. data/test/commands/condition_test.rb +0 -85
  103. data/test/commands/continue_test.rb +0 -47
  104. data/test/commands/delete_test.rb +0 -26
  105. data/test/commands/display_test.rb +0 -37
  106. data/test/commands/edit_test.rb +0 -52
  107. data/test/commands/eval_test.rb +0 -89
  108. data/test/commands/finish_test.rb +0 -74
  109. data/test/commands/frame_test.rb +0 -223
  110. data/test/commands/help_test.rb +0 -66
  111. data/test/commands/history_test.rb +0 -61
  112. data/test/commands/info_test.rb +0 -238
  113. data/test/commands/interrupt_test.rb +0 -45
  114. data/test/commands/irb_test.rb +0 -28
  115. data/test/commands/kill_test.rb +0 -50
  116. data/test/commands/list_test.rb +0 -174
  117. data/test/commands/method_test.rb +0 -52
  118. data/test/commands/post_mortem_test.rb +0 -71
  119. data/test/commands/pry_test.rb +0 -26
  120. data/test/commands/quit_test.rb +0 -53
  121. data/test/commands/reload_test.rb +0 -39
  122. data/test/commands/restart_test.rb +0 -46
  123. data/test/commands/save_test.rb +0 -67
  124. data/test/commands/set_test.rb +0 -140
  125. data/test/commands/show_test.rb +0 -76
  126. data/test/commands/source_test.rb +0 -46
  127. data/test/commands/stepping_test.rb +0 -192
  128. data/test/commands/thread_test.rb +0 -164
  129. data/test/commands/trace_test.rb +0 -71
  130. data/test/commands/undisplay_test.rb +0 -75
  131. data/test/commands/variables_test.rb +0 -105
  132. data/test/debugger_alias_test.rb +0 -7
  133. data/test/runner_test.rb +0 -150
  134. data/test/support/matchers.rb +0 -65
  135. data/test/support/test_interface.rb +0 -59
  136. data/test/support/utils.rb +0 -122
  137. data/test/test_helper.rb +0 -58
data/Gemfile CHANGED
@@ -2,16 +2,14 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rake', '~> 10.3'
5
+ gem 'rake', '~> 10.4'
6
6
 
7
- group :development do
8
- gem 'rake-compiler', '~> 0.9'
9
- gem 'rubocop', '~> 0.25'
10
- end
11
-
12
- group :test do
7
+ group :development, :test do
8
+ gem 'rake-compiler', '0.9.5'
9
+ gem 'rubocop', '0.29.1'
13
10
  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
11
+ gem 'minitest', '~> 5.5'
12
+ gem 'simplecov', '0.9.2', require: false
13
+ gem 'codeclimate-test-reporter', '0.4.7', require: false
14
+ gem 'pry', '0.10.1', require: false
17
15
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) David Rodríguez <deivid.rodriguez@gmail.com>
1
+ Copyright (c) David Rodríguez <deivid.rodriguez@gmail.com>
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -1,10 +1,22 @@
1
1
  # Byebug
2
- [![Version][VersionBadge]][VersionURL]
3
- [![Build][TravisBadge]][TravisURL]
4
- [![Climate][CodeClimateBadge]][CodeClimateURL]
5
- [![Dependencies][GemnasiumBadge]][GemnasiumURL]
6
- [![Coverage][CoverageBadge]][CoverageURL]
7
- [![Gittip][GittipBadge]][GittipURL]
2
+
3
+ [![Ver][gem]][gem_url]
4
+ [![Gpa][gpa]][gpa_url]
5
+ [![Dep][dep]][dep_url]
6
+ [![Cov][cov]][cov_url]
7
+ [![Git][tip]][tip_url]
8
+
9
+ [gem]: https://img.shields.io/gem/v/byebug.svg
10
+ [gpa]: https://img.shields.io/codeclimate/github/deivid-rodriguez/byebug.svg
11
+ [dep]: https://img.shields.io/gemnasium/deivid-rodriguez/byebug.svg
12
+ [cov]: https://img.shields.io/codeclimate/coverage/github/deivid-rodriguez/byebug.svg
13
+ [tip]: https://img.shields.io/gittip/deivid-rodriguez.svg
14
+
15
+ [gem_url]: https://rubygems.org/gems/byebug
16
+ [gpa_url]: https://codeclimate.com/github/deivid-rodriguez/byebug
17
+ [dep_url]: https://gemnasium.com/deivid-rodriguez/byebug
18
+ [cov_url]: https://codeclimate.com/github/deivid-rodriguez/byebug
19
+ [tip_url]: https://www.gittip.com/deivid-rodriguez
8
20
 
9
21
  _Debugging in Ruby 2_
10
22
 
@@ -25,19 +37,28 @@ that.
25
37
  different lines executed by your program.
26
38
 
27
39
 
28
- ## Ruby Version Support
40
+ ## Build Status
41
+
42
+ Linux & OSX [![Tra][tra]][tra_url]
43
+
44
+ Windows [![Vey][vey]][vey_url]
45
+
46
+ [tra]: https://img.shields.io/travis/deivid-rodriguez/byebug.svg?branch=master
47
+ [vey]: https://ci.appveyor.com/api/projects/status/github/deivid-rodriguez/byebug?svg=true
29
48
 
30
- Byebug works only for Ruby 2.0.0 or newer. For debugging ruby 1.9.3 or older,
31
- use [debugger][].
49
+ [tra_url]: https://travis-ci.org/deivid-rodriguez/byebug
50
+ [vey_url]: https://ci.appveyor.com/project/deivid-rodriguez/byebug
32
51
 
33
- Furthermore, Byebug uses the TracePoint API which was just first developed for
34
- Ruby 2.0.0. Since it was released, a lot of bugs directly impacting Byebug have
35
- been corrected, so for the best debugging experience, the following Ruby
36
- versions are recommended:
37
52
 
38
- * Ruby 2.0.0-p576 or higher.
39
- * Ruby 2.1.3 or higher.
40
- * Ruby 2.2.0-preview1 or higher.
53
+ ## Requirements
54
+
55
+ * Required: MRI 2.0.0 or higher. For debugging ruby 1.9.3 or older, use
56
+ [debugger][].
57
+
58
+ * Recommended:
59
+ - MRI 2.0.0-p576 or higher.
60
+ - MRI 2.1.3 or higher.
61
+ - MRI 2.2.1 or higher.
41
62
 
42
63
 
43
64
  ## Install
@@ -55,15 +76,6 @@ wherever you want to start debugging and the execution will stop there. If you
55
76
  are debugging rails, start the server and once the execution gets to your
56
77
  `byebug` command you will get a debugging prompt.
57
78
 
58
- Former [debugger][] or [ruby-debug][] users, notice:
59
-
60
- * Some gems (rails, rspec) implement debugging flags (-d, --debugger) that early
61
- require and start the debugger. These flags are a performance penalty and byebug
62
- doesn't need them anymore so my recommendation is not to use them. In any case,
63
- both rails and rspec have deprecated these flags in their latest versions.
64
- * The startup configuration file is now called `.byebugrc` instead of
65
- `.rdebugrc`.
66
-
67
79
 
68
80
  ## Byebug's commands
69
81
 
@@ -80,6 +92,7 @@ both rails and rspec have deprecated these flags in their latest versions.
80
92
  `down` | |
81
93
  `edit` | |
82
94
  `enable` | | `breakpoints` `display`
95
+ `eval` | |
83
96
  `finish` | |
84
97
  `frame` | |
85
98
  `help` | |
@@ -90,25 +103,22 @@ both rails and rspec have deprecated these flags in their latest versions.
90
103
  `list` | |
91
104
  `method` | | `instance`
92
105
  `next` | |
93
- `p` | `eval` |
94
106
  `pp` | |
95
107
  `pry` | |
96
108
  `ps` | |
97
109
  `putl` | |
98
110
  `quit` | `exit` |
99
- `reload` | |
100
111
  `restart` | |
101
112
  `save` | |
102
- `set` | | `autoeval` `autoirb` `autolist` `autoreload` `autosave` `basename` `callstyle` `forcestep` `fullpath` `histfile` `histsize` `linetrace` `tracing_plus` `listsize` `post_mortem` `stack_on_error` `testing` `verbose` `width`
103
- `show` | | `autoeval` `autoirb` `autolist` `autoreload` `autosave` `basename` `callstyle` `forcestep` `fullpath` `histfile` `histsize` `linetrace` `tracing_plus` `listsize` `post_mortem` `stack_on_error` `testing` `verbose` `width`
104
- `skip` | |
113
+ `set` | | `autoeval` `autoirb` `autolist` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `stack_on_error` `verbose` `width`
114
+ `show` | | `autoeval` `autoirb` `autolist` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `stack_on_error` `verbose` `width`
105
115
  `source` | |
106
116
  `step` | |
107
117
  `thread` | | `current` `list` `resume` `stop` `switch`
108
118
  `tracevar` | |
109
119
  `undisplay` | |
110
120
  `up` | |
111
- `var` | | `all` `class` `constant` `global` `instance` `local`
121
+ `var` | | `all` `constant` `global` `instance` `local`
112
122
 
113
123
 
114
124
  ## Semantic Versioning
@@ -152,22 +162,8 @@ software, specially:
152
162
  * @kevjames3 for testing, bug reports and the interest in the project.
153
163
  * @FooBarWidget for working and helping with remote debugging.
154
164
 
155
- [VersionBadge]: https://badge.fury.io/rb/byebug.svg
156
- [VersionURL]: http://badge.fury.io/rb/byebug
157
- [TravisBadge]: https://travis-ci.org/deivid-rodriguez/byebug.svg
158
- [TravisURL]: http://travis-ci.org/deivid-rodriguez/byebug
159
- [CodeClimateBadge]: https://img.shields.io/codeclimate/github/deivid-rodriguez/byebug.svg
160
- [CodeClimateURL]: https://codeclimate.com/github/deivid-rodriguez/byebug
161
- [GemnasiumBadge]: https://gemnasium.com/deivid-rodriguez/byebug.svg
162
- [GemnasiumURL]: https://gemnasium.com/deivid-rodriguez/byebug
163
- [CoverageBadge]: https://codeclimate.com/github/deivid-rodriguez/byebug/badges/coverage.svg
164
- [CoverageURL]: https://codeclimate.com/github/deivid-rodriguez/byebug
165
- [GittipBadge]: http://img.shields.io/gittip/deivid-rodriguez.svg
166
- [GittipURL]: https://www.gittip.com/deivid-rodriguez
167
-
168
165
  [debugger]: https://github.com/cldwalker/debugger
169
166
  [pry]: https://github.com/pry/pry
170
- [ruby-debug]: https://github.com/mark-moseley/ruby-debug
171
167
  [debase]: https://github.com/denofevil/debase
172
168
  [pry-byebug]: https://github.com/deivid-rodriguez/pry-byebug
173
169
  [ruby-debug-passenger]: https://github.com/davejamesmiller/ruby-debug-passenger
data/Rakefile CHANGED
@@ -1,41 +1,43 @@
1
- require 'rake/testtask'
2
- require 'rake/extensiontask'
1
+ #
2
+ # For the `rake release` task
3
+ #
3
4
  require 'bundler/gem_tasks'
4
5
 
5
- Rake::ExtensionTask.new('byebug') do |ext|
6
- ext.lib_dir = 'lib/byebug'
7
- end
6
+ #
7
+ # Prepend DevKit into compilation phase
8
+ #
9
+ task compile: :devkit if RUBY_PLATFORM =~ /mingw/
8
10
 
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
17
- end
11
+ require 'rake/extensiontask'
12
+
13
+ spec = Gem::Specification.load('byebug.gemspec')
14
+ Rake::ExtensionTask.new('byebug', spec) do |ext|
15
+ ext.lib_dir = 'lib/byebug'
18
16
  end
19
17
 
20
18
  desc 'Run the test suite'
21
19
  task :test do
22
- Rake::TestTask.new do |t|
23
- t.verbose = true
24
- t.warning = true
25
- t.pattern = 'test/**/*_test.rb'
20
+ files = Dir.glob('test/**/*_test.rb').join(' ')
21
+ system("ruby -w -Ilib test/test_helper.rb #{files}") || exit(false)
22
+ end
23
+
24
+ desc 'Activates DevKit'
25
+ task :devkit do
26
+ begin
27
+ require 'devkit'
28
+ rescue LoadError
29
+ abort "Failed to activate RubyInstaller's DevKit required for compilation."
26
30
  end
27
31
  end
28
32
 
29
- task default: :test
33
+ require 'rubocop/rake_task'
30
34
 
31
- desc 'Run a test in looped mode so that you can look for memory leaks'
32
- task 'test_loop' do
33
- code = %(loop{ require '#{$ARGV[1]}' })
34
- cmd = %(ruby -Itest -e "#{ code }")
35
- system cmd
35
+ desc 'Run RuboCop'
36
+ task :rubocop do
37
+ RuboCop::RakeTask.new
36
38
  end
37
39
 
38
- desc 'Watch memory use of a looping test'
39
- task 'test_loop_mem' do
40
- system "watch \"ps aux | grep -v 'sh -c r' | grep [I]test\""
41
- end
40
+ require_relative 'tasks/ccop.rb'
41
+ require_relative 'tasks/dev_utils.rb'
42
+
43
+ task default: [:compile, :test, :rubocop, :ccop]
@@ -1,13 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/lib/byebug/version'
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = 'byebug'
5
- s.version = Byebug::VERSION
6
- s.authors = ['David Rodriguez', 'Kent Sibilev', 'Mark Moseley']
7
- s.email = 'deivid.rodriguez@mail.com'
8
- s.license = 'BSD'
9
- s.homepage = 'http://github.com/deivid-rodriguez/byebug'
10
- s.summary = 'Ruby 2.0 fast debugger - base + CLI'
4
+ s.name = 'byebug'
5
+ s.version = Byebug::VERSION
6
+ s.authors = ['David Rodriguez', 'Kent Sibilev', 'Mark Moseley']
7
+ s.email = 'deivid.rodriguez@mail.com'
8
+ s.license = 'BSD'
9
+ s.homepage = 'http://github.com/deivid-rodriguez/byebug'
10
+ s.summary = 'Ruby 2.0 fast debugger - base + CLI'
11
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
@@ -15,17 +15,17 @@ Gem::Specification.new do |s|
15
15
  stack frames among other things and it comes with an easy to use command
16
16
  line interface."
17
17
 
18
- s.required_ruby_version = '>= 2.0.0'
18
+ s.required_ruby_version = '>= 2.0.0'
19
19
 
20
- s.files = `git ls-files`.split("\n")
21
- s.test_files = `git ls-files -- test/*`.split("\n")
22
- s.bindir = 'bin'
23
- s.executables = ['byebug']
24
- s.extra_rdoc_files = %w(README.md GUIDE.md)
25
- s.extensions = ['ext/byebug/extconf.rb']
26
- s.require_path = 'lib'
20
+ s.files = Dir['lib/**/*.rb', 'ext/**/*.[ch]', '.gitignore', 'LICENSE']
21
+ s.files += %w(.rubocop.yml .travis.yml byebug.gemspec Gemfile Rakefile)
22
+ s.bindir = 'bin'
23
+ s.executables = ['byebug']
24
+ s.extra_rdoc_files = %w(CHANGELOG.md CONTRIBUTING.md README.md GUIDE.md)
25
+ s.extensions = ['ext/byebug/extconf.rb']
26
+ s.require_path = 'lib'
27
27
 
28
- s.add_dependency 'columnize', '~> 0.8'
29
- s.add_dependency 'slop', '~> 3.6'
30
- s.add_dependency 'debugger-linecache', '~> 1.2'
28
+ s.add_dependency 'columnize', '0.9.0'
29
+
30
+ s.add_development_dependency 'bundler', '~> 1.7'
31
31
  end
@@ -45,10 +45,10 @@ brkpt_enabled(VALUE self)
45
45
  static VALUE
46
46
  brkpt_set_enabled(VALUE self, VALUE bool)
47
47
  {
48
- breakpoint_t *breakpoint;
48
+ breakpoint_t *breakpoint;
49
49
 
50
- Data_Get_Struct(self, breakpoint_t, breakpoint);
51
- return breakpoint->enabled = bool;
50
+ Data_Get_Struct(self, breakpoint_t, breakpoint);
51
+ return breakpoint->enabled = bool;
52
52
  }
53
53
 
54
54
  /*
@@ -80,7 +80,7 @@ brkpt_set_expr(VALUE self, VALUE expr)
80
80
  breakpoint_t *breakpoint;
81
81
 
82
82
  Data_Get_Struct(self, breakpoint_t, breakpoint);
83
- breakpoint->expr = NIL_P(expr) ? expr: StringValue(expr);
83
+ breakpoint->expr = NIL_P(expr) ? expr : StringValue(expr);
84
84
  return expr;
85
85
  }
86
86
 
@@ -97,7 +97,7 @@ brkpt_hit_condition(VALUE self)
97
97
  breakpoint_t *breakpoint;
98
98
 
99
99
  Data_Get_Struct(self, breakpoint_t, breakpoint);
100
- switch(breakpoint->hit_condition)
100
+ switch (breakpoint->hit_condition)
101
101
  {
102
102
  case HIT_COND_GE:
103
103
  return ID2SYM(rb_intern("greater_or_equal"));
@@ -130,11 +130,11 @@ brkpt_set_hit_condition(VALUE self, VALUE value)
130
130
  Data_Get_Struct(self, breakpoint_t, breakpoint);
131
131
  id_value = rb_to_id(value);
132
132
 
133
- if(rb_intern("greater_or_equal") == id_value || rb_intern("ge") == id_value)
133
+ if (rb_intern("greater_or_equal") == id_value || rb_intern("ge") == id_value)
134
134
  breakpoint->hit_condition = HIT_COND_GE;
135
- else if(rb_intern("equal") == id_value || rb_intern("eq") == id_value)
135
+ else if (rb_intern("equal") == id_value || rb_intern("eq") == id_value)
136
136
  breakpoint->hit_condition = HIT_COND_EQ;
137
- else if(rb_intern("modulo") == id_value || rb_intern("mod") == id_value)
137
+ else if (rb_intern("modulo") == id_value || rb_intern("mod") == id_value)
138
138
  breakpoint->hit_condition = HIT_COND_MOD;
139
139
  else
140
140
  rb_raise(rb_eArgError, "Invalid condition parameter");
@@ -166,10 +166,10 @@ brkpt_hit_count(VALUE self)
166
166
  static VALUE
167
167
  brkpt_hit_value(VALUE self)
168
168
  {
169
- breakpoint_t *breakpoint;
169
+ breakpoint_t *breakpoint;
170
170
 
171
- Data_Get_Struct(self, breakpoint_t, breakpoint);
172
- return INT2FIX(breakpoint->hit_value);
171
+ Data_Get_Struct(self, breakpoint_t, breakpoint);
172
+ return INT2FIX(breakpoint->hit_value);
173
173
  }
174
174
 
175
175
  /*
@@ -182,11 +182,11 @@ brkpt_hit_value(VALUE self)
182
182
  static VALUE
183
183
  brkpt_set_hit_value(VALUE self, VALUE value)
184
184
  {
185
- breakpoint_t *breakpoint;
185
+ breakpoint_t *breakpoint;
186
186
 
187
- Data_Get_Struct(self, breakpoint_t, breakpoint);
188
- breakpoint->hit_value = FIX2INT(value);
189
- return value;
187
+ Data_Get_Struct(self, breakpoint_t, breakpoint);
188
+ breakpoint->hit_value = FIX2INT(value);
189
+ return value;
190
190
  }
191
191
 
192
192
  /*
@@ -239,7 +239,7 @@ brkpt_source(VALUE self)
239
239
  }
240
240
 
241
241
  static void
242
- mark_breakpoint(breakpoint_t *breakpoint)
242
+ mark_breakpoint(breakpoint_t * breakpoint)
243
243
  {
244
244
  rb_gc_mark(breakpoint->source);
245
245
  rb_gc_mark(breakpoint->expr);
@@ -261,10 +261,10 @@ brkpt_initialize(VALUE self, VALUE source, VALUE pos, VALUE expr)
261
261
  Data_Get_Struct(self, breakpoint_t, breakpoint);
262
262
 
263
263
  breakpoint->type = FIXNUM_P(pos) ? BP_POS_TYPE : BP_METHOD_TYPE;
264
- if(breakpoint->type == BP_POS_TYPE)
265
- breakpoint->pos.line = FIX2INT(pos);
264
+ if (breakpoint->type == BP_POS_TYPE)
265
+ breakpoint->pos.line = FIX2INT(pos);
266
266
  else
267
- breakpoint->pos.mid = SYM2ID(pos);
267
+ breakpoint->pos.mid = SYM2ID(pos);
268
268
 
269
269
  breakpoint->id = ++breakpoint_max;
270
270
  breakpoint->source = StringValue(source);
@@ -282,7 +282,7 @@ filename_cmp_impl(VALUE source, char *file)
282
282
  {
283
283
  char *source_ptr, *file_ptr;
284
284
  long s_len, f_len, min_len;
285
- long s,f;
285
+ long s, f;
286
286
  int dirsep_flag = 0;
287
287
 
288
288
  s_len = RSTRING_LEN(source);
@@ -290,19 +290,20 @@ filename_cmp_impl(VALUE source, char *file)
290
290
  min_len = s_len < f_len ? s_len : f_len;
291
291
 
292
292
  source_ptr = RSTRING_PTR(source);
293
- file_ptr = file;
293
+ file_ptr = file;
294
294
 
295
- for( s = s_len - 1, f = f_len - 1; s >= s_len - min_len && f >= f_len - min_len; s--, f-- )
295
+ for (s = s_len - 1, f = f_len - 1;
296
+ s >= s_len - min_len && f >= f_len - min_len; s--, f--)
296
297
  {
297
- if((source_ptr[s] == '.' || file_ptr[f] == '.') && dirsep_flag)
298
+ if ((source_ptr[s] == '.' || file_ptr[f] == '.') && dirsep_flag)
298
299
  return 1;
299
- if(isdirsep(source_ptr[s]) && isdirsep(file_ptr[f]))
300
+ if (isdirsep(source_ptr[s]) && isdirsep(file_ptr[f]))
300
301
  dirsep_flag = 1;
301
302
  #ifdef DOSISH_DRIVE_LETTER
302
303
  else if (s == 0)
303
- return(toupper(source_ptr[s]) == toupper(file_ptr[f]));
304
+ return (toupper(source_ptr[s]) == toupper(file_ptr[f]));
304
305
  #endif
305
- else if(source_ptr[s] != file_ptr[f])
306
+ else if (source_ptr[s] != file_ptr[f])
306
307
  return 0;
307
308
  }
308
309
  return 1;
@@ -316,11 +317,13 @@ filename_cmp(VALUE source, char *file)
316
317
  #else
317
318
  #ifdef PATH_MAX
318
319
  char path[PATH_MAX + 1];
320
+
319
321
  path[PATH_MAX] = 0;
320
322
  return filename_cmp_impl(source, realpath(file, path) != NULL ? path : file);
321
323
  #else
322
324
  char *path;
323
325
  int result;
326
+
324
327
  path = realpath(file, NULL);
325
328
  result = filename_cmp_impl(source, path == NULL ? file : path);
326
329
  free(path);
@@ -329,15 +332,28 @@ filename_cmp(VALUE source, char *file)
329
332
  #endif
330
333
  }
331
334
 
335
+ int
336
+ classname_cmp(VALUE name, VALUE klass)
337
+ {
338
+ VALUE mod_name;
339
+ VALUE class_name = NIL_P(name) ? rb_str_new2("main") : name;
340
+
341
+ if (NIL_P(klass))
342
+ return 0;
343
+
344
+ mod_name = rb_mod_name(klass);
345
+ return (mod_name != Qnil && rb_str_cmp(class_name, mod_name) == 0);
346
+ }
347
+
332
348
  static int
333
- check_breakpoint_by_hit_condition(VALUE breakpoint_object)
349
+ check_breakpoint_by_hit_condition(VALUE rb_breakpoint)
334
350
  {
335
351
  breakpoint_t *breakpoint;
336
352
 
337
- if (breakpoint_object == Qnil)
353
+ if (NIL_P(rb_breakpoint))
338
354
  return 0;
339
355
 
340
- Data_Get_Struct(breakpoint_object, breakpoint_t, breakpoint);
356
+ Data_Get_Struct(rb_breakpoint, breakpoint_t, breakpoint);
341
357
  breakpoint->hit_count++;
342
358
 
343
359
  if (Qtrue != breakpoint->enabled)
@@ -370,74 +386,71 @@ check_breakpoint_by_hit_condition(VALUE breakpoint_object)
370
386
  }
371
387
 
372
388
  static int
373
- check_breakpoint_by_pos(VALUE breakpoint_object, char *file, int line)
389
+ check_breakpoint_by_pos(VALUE rb_breakpoint, char *file, int line)
374
390
  {
375
391
  breakpoint_t *breakpoint;
376
392
 
377
- if (breakpoint_object == Qnil)
393
+ if (NIL_P(rb_breakpoint))
378
394
  return 0;
379
395
 
380
- Data_Get_Struct(breakpoint_object, breakpoint_t, breakpoint);
396
+ Data_Get_Struct(rb_breakpoint, breakpoint_t, breakpoint);
381
397
 
382
- if ( (Qtrue != breakpoint->enabled) ||
383
- (breakpoint->type != BP_POS_TYPE) ||
384
- (breakpoint->pos.line != line) )
398
+ if (Qfalse == breakpoint->enabled || breakpoint->type != BP_POS_TYPE
399
+ || breakpoint->pos.line != line)
385
400
  return 0;
386
401
 
387
402
  return filename_cmp(breakpoint->source, file);
388
403
  }
389
404
 
390
405
  static int
391
- check_breakpoint_by_method(VALUE breakpoint_object, VALUE klass, ID mid,
392
- VALUE self)
406
+ check_breakpoint_by_method(VALUE rb_breakpoint, VALUE klass, ID mid, VALUE self)
393
407
  {
394
408
  breakpoint_t *breakpoint;
395
409
 
396
- if (breakpoint_object == Qnil)
410
+ if (NIL_P(rb_breakpoint))
397
411
  return 0;
398
412
 
399
- Data_Get_Struct(breakpoint_object, breakpoint_t, breakpoint);
413
+ Data_Get_Struct(rb_breakpoint, breakpoint_t, breakpoint);
400
414
 
401
- if ( (Qfalse == breakpoint->enabled) ||
402
- (breakpoint->type != BP_METHOD_TYPE) ||
403
- (breakpoint->pos.mid != mid) )
415
+ if (Qfalse == breakpoint->enabled || breakpoint->type != BP_METHOD_TYPE
416
+ || breakpoint->pos.mid != mid)
404
417
  return 0;
405
418
 
406
- if ( (classname_cmp(breakpoint->source, klass)) ||
407
- ((rb_type(self) == T_CLASS) && classname_cmp(breakpoint->source, self)) )
419
+ if (classname_cmp(breakpoint->source, klass)
420
+ || ((rb_type(self) == T_CLASS || rb_type(self) == T_MODULE)
421
+ && classname_cmp(breakpoint->source, self)))
408
422
  return 1;
409
423
 
410
424
  return 0;
411
425
  }
412
426
 
413
427
  static int
414
- check_breakpoint_by_expr(VALUE breakpoint_object, VALUE binding)
428
+ check_breakpoint_by_expr(VALUE rb_breakpoint, VALUE bind)
415
429
  {
416
430
  breakpoint_t *breakpoint;
417
431
  VALUE args, expr_result;
418
432
 
419
- if (NIL_P(breakpoint_object))
433
+ if (NIL_P(rb_breakpoint))
420
434
  return 0;
421
435
 
422
- Data_Get_Struct(breakpoint_object, breakpoint_t, breakpoint);
436
+ Data_Get_Struct(rb_breakpoint, breakpoint_t, breakpoint);
423
437
 
424
- if (Qtrue != breakpoint->enabled)
438
+ if (Qfalse == breakpoint->enabled)
425
439
  return 0;
426
440
 
427
441
  if (NIL_P(breakpoint->expr))
428
442
  return 1;
429
443
 
430
- args = rb_ary_new3(2, breakpoint->expr, binding);
444
+ args = rb_ary_new3(2, breakpoint->expr, bind);
431
445
  expr_result = rb_protect(eval_expression, args, 0);
432
446
 
433
447
  return RTEST(expr_result);
434
448
  }
435
449
 
436
450
  extern VALUE
437
- find_breakpoint_by_pos(VALUE breakpoints, VALUE source, VALUE pos,
438
- VALUE binding)
451
+ find_breakpoint_by_pos(VALUE breakpoints, VALUE source, VALUE pos, VALUE bind)
439
452
  {
440
- VALUE breakpoint_object;
453
+ VALUE breakpoint;
441
454
  char *file;
442
455
  int line;
443
456
  int i;
@@ -446,32 +459,32 @@ find_breakpoint_by_pos(VALUE breakpoints, VALUE source, VALUE pos,
446
459
  line = FIX2INT(pos);
447
460
  for (i = 0; i < RARRAY_LENINT(breakpoints); i++)
448
461
  {
449
- breakpoint_object = rb_ary_entry(breakpoints, i);
450
- if (check_breakpoint_by_pos(breakpoint_object, file, line) &&
451
- check_breakpoint_by_expr(breakpoint_object, binding) &&
452
- check_breakpoint_by_hit_condition(breakpoint_object))
462
+ breakpoint = rb_ary_entry(breakpoints, i);
463
+ if (check_breakpoint_by_pos(breakpoint, file, line)
464
+ && check_breakpoint_by_expr(breakpoint, bind)
465
+ && check_breakpoint_by_hit_condition(breakpoint))
453
466
  {
454
- return breakpoint_object;
467
+ return breakpoint;
455
468
  }
456
469
  }
457
470
  return Qnil;
458
471
  }
459
472
 
460
473
  extern VALUE
461
- find_breakpoint_by_method(VALUE breakpoints, VALUE klass, ID mid, VALUE binding,
474
+ find_breakpoint_by_method(VALUE breakpoints, VALUE klass, ID mid, VALUE bind,
462
475
  VALUE self)
463
476
  {
464
- VALUE breakpoint_object;
477
+ VALUE breakpoint;
465
478
  int i;
466
479
 
467
480
  for (i = 0; i < RARRAY_LENINT(breakpoints); i++)
468
481
  {
469
- breakpoint_object = rb_ary_entry(breakpoints, i);
470
- if (check_breakpoint_by_method(breakpoint_object, klass, mid, self) &&
471
- check_breakpoint_by_expr(breakpoint_object, binding) &&
472
- check_breakpoint_by_hit_condition(breakpoint_object))
482
+ breakpoint = rb_ary_entry(breakpoints, i);
483
+ if (check_breakpoint_by_method(breakpoint, klass, mid, self)
484
+ && check_breakpoint_by_expr(breakpoint, bind)
485
+ && check_breakpoint_by_hit_condition(breakpoint))
473
486
  {
474
- return breakpoint_object;
487
+ return breakpoint;
475
488
  }
476
489
  }
477
490
  return Qnil;
@@ -487,18 +500,18 @@ Init_breakpoint(VALUE mByebug)
487
500
  rb_define_alloc_func(cBreakpoint, brkpt_create);
488
501
  rb_define_method(cBreakpoint, "initialize", brkpt_initialize, 3);
489
502
 
490
- rb_define_method(cBreakpoint, "enabled?" , brkpt_enabled , 0);
491
- rb_define_method(cBreakpoint, "enabled=" , brkpt_set_enabled , 1);
492
- rb_define_method(cBreakpoint, "expr" , brkpt_expr , 0);
493
- rb_define_method(cBreakpoint, "expr=" , brkpt_set_expr , 1);
494
- rb_define_method(cBreakpoint, "hit_count" , brkpt_hit_count , 0);
495
- rb_define_method(cBreakpoint, "hit_condition" , brkpt_hit_condition , 0);
503
+ rb_define_method(cBreakpoint, "enabled?", brkpt_enabled, 0);
504
+ rb_define_method(cBreakpoint, "enabled=", brkpt_set_enabled, 1);
505
+ rb_define_method(cBreakpoint, "expr", brkpt_expr, 0);
506
+ rb_define_method(cBreakpoint, "expr=", brkpt_set_expr, 1);
507
+ rb_define_method(cBreakpoint, "hit_count", brkpt_hit_count, 0);
508
+ rb_define_method(cBreakpoint, "hit_condition", brkpt_hit_condition, 0);
496
509
  rb_define_method(cBreakpoint, "hit_condition=", brkpt_set_hit_condition, 1);
497
- rb_define_method(cBreakpoint, "hit_value" , brkpt_hit_value , 0);
498
- rb_define_method(cBreakpoint, "hit_value=" , brkpt_set_hit_value , 1);
499
- rb_define_method(cBreakpoint, "id" , brkpt_id , 0);
500
- rb_define_method(cBreakpoint, "pos" , brkpt_pos , 0);
501
- rb_define_method(cBreakpoint, "source" , brkpt_source , 0);
510
+ rb_define_method(cBreakpoint, "hit_value", brkpt_hit_value, 0);
511
+ rb_define_method(cBreakpoint, "hit_value=", brkpt_set_hit_value, 1);
512
+ rb_define_method(cBreakpoint, "id", brkpt_id, 0);
513
+ rb_define_method(cBreakpoint, "pos", brkpt_pos, 0);
514
+ rb_define_method(cBreakpoint, "source", brkpt_source, 0);
502
515
 
503
516
  idEval = rb_intern("eval");
504
517
  }