debug 1.0.0.beta2 → 1.0.0.beta7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0ed57ff87f1864d86d79c435081b12df6cb35bd4f24a3cb79f4a909887e5f41
4
- data.tar.gz: c342d515e9358e0cfdee353b5d5be1fbbb7bcf46cfdf3f925ace7a3acc2b6e90
3
+ metadata.gz: d545d212530685e0eaf7163bc0b2517befd0edfdc1b083c64ecab6bfcb6958b8
4
+ data.tar.gz: 6662febf1dccfbc0e7e4ec785578fb5eac2a076fa488a4a3a814582f80fa940f
5
5
  SHA512:
6
- metadata.gz: 112d49a60540e034752e1c3d3721c213549cae4653c63041c3f3da08cf7bf01624e8a45c0ee88ff31270eef337cf8db3ca8de7d403eea550aff82621050e9e14
7
- data.tar.gz: e6800fb760a734419ed43fa04720b0bc75a815f0de4511df7f76a44b9b864c002eb6c9503f74e1a9471d335f671f0db12636e852cc6bac0366ba00d051e29b0b
6
+ metadata.gz: 3173551c5ada6fb2f7f71656a5762b6a6a6cc541d80d371532abfe1e03188f81ffb397df1a2c8d743c34983e27c5abe6e33ae8d8188502960501801af3aa9ea3
7
+ data.tar.gz: 59c84ef76b01d8630b764784d68edb7b1e25e2c336cab56a74e23add5f606f14c3dfe2d6cdd9fe3779e328ca8873317d5d7b56a8e5a7951ecc3a081c20c309d8
@@ -0,0 +1,34 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0', 'head', 'debug']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby-version }}
32
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
33
+ - name: Run tests
34
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -6,4 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.bundle
9
10
  /Gemfile.lock
11
+ /lib/debug/debug.so
12
+ .ruby-version
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,336 @@
1
+ ## Set Up a Development Environment
2
+
3
+ 1. `$ git clone git@github.com:ruby/debug.git`
4
+ 2. `$ bundle install`
5
+ 3. `$ rake` - this will
6
+ - Compile the C extension locally (which can also be done solely with `rake compile`).
7
+ - Run tests.
8
+ - Re-generate `README.md`.
9
+
10
+ If you spot any problem, please open an issue.
11
+
12
+ ## Run Tests
13
+
14
+ ### Run all tests
15
+
16
+ ```bash
17
+ $ rake test
18
+ ```
19
+
20
+ ### Run specific test(s)
21
+
22
+
23
+ ```bash
24
+ $ ruby test/debug/bp_test.rb # run all tests in the specified file
25
+ $ ruby test/debug/bp_test.rb -h # to see all the test options
26
+ ```
27
+
28
+ ## Generate Tests
29
+ There is a test generator in `debug.rb` project to make it easier to write tests.
30
+ ### Quickstart
31
+ This section shows you how to create test file by test generator. For more advanced informations on creating tests, please take a look at [gentest options](#gentest-options). (You can also check by `$bin/gentest -h`)
32
+ #### 1. Create a target file for debuggee.
33
+ Let's say, we created `target.rb` which is located in top level directory of debugger.
34
+ ```ruby
35
+ module Foo
36
+ class Bar
37
+ def self.a
38
+ "hello"
39
+ end
40
+ end
41
+ Bar.a
42
+ bar = Bar.new
43
+ end
44
+ ```
45
+ #### 2. Run `gentest` as shown in the example below.
46
+ ```shell
47
+ $ bin/gentest target.rb
48
+ ```
49
+ #### 3. Debugger will be executed. You can type any debug commands.
50
+ ```shell
51
+ $ bin/gentest target.rb
52
+ [1, 9] in ~/workspace/debug/target.rb
53
+ => 1| module Foo
54
+ 2| class Bar
55
+ 3| def self.a
56
+ 4| "hello"
57
+ 5| end
58
+ 6| end
59
+ 7| Bar.a
60
+ 8| bar = Bar.new
61
+ 9| end
62
+ =>#0 <main> at ~/workspace/debug/target.rb:1
63
+ INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:1","line":1}
64
+
65
+ (rdbg)s
66
+ s
67
+ [1, 9] in ~/workspace/debug/target.rb
68
+ 1| module Foo
69
+ => 2| class Bar
70
+ 3| def self.a
71
+ 4| "hello"
72
+ 5| end
73
+ 6| end
74
+ 7| Bar.a
75
+ 8| bar = Bar.new
76
+ 9| end
77
+ =>#0 <module:Foo> at ~/workspace/debug/target.rb:2
78
+ #1 <main> at ~/workspace/debug/target.rb:1
79
+ INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:2","line":2}
80
+
81
+ (rdbg)n
82
+ n
83
+ [1, 9] in ~/workspace/debug/target.rb
84
+ 1| module Foo
85
+ 2| class Bar
86
+ => 3| def self.a
87
+ 4| "hello"
88
+ 5| end
89
+ 6| end
90
+ 7| Bar.a
91
+ 8| bar = Bar.new
92
+ 9| end
93
+ =>#0 <class:Bar> at ~/workspace/debug/target.rb:3
94
+ #1 <module:Foo> at ~/workspace/debug/target.rb:2
95
+ #2 <main> at ~/workspace/debug/target.rb:1
96
+ INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:3","line":3}
97
+
98
+ (rdbg)b 7
99
+ b 7
100
+ INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:3","line":3}
101
+
102
+ (rdbg)c
103
+ c
104
+ [2, 9] in ~/workspace/debug/target.rb
105
+ 2| class Bar
106
+ 3| def self.a
107
+ 4| "hello"
108
+ 5| end
109
+ 6| end
110
+ => 7| Bar.a
111
+ 8| bar = Bar.new
112
+ 9| end
113
+ =>#0 <module:Foo> at ~/workspace/debug/target.rb:7
114
+ #1 <main> at ~/workspace/debug/target.rb:1
115
+
116
+ Stop by #0 BP - Line /Users/naotto/workspace/debug/target.rb:7 (line)
117
+ INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:7","line":7}
118
+
119
+ (rdbg)q!
120
+ q!
121
+ ```
122
+ #### 4. The test file will be created as `test/debug/foo_test.rb`.
123
+ If the file already exists, **only method** will be added to it.
124
+ ```ruby
125
+ # frozen_string_literal: true
126
+
127
+ require_relative '../support/test_case'
128
+
129
+ module DEBUGGER__
130
+ class FooTest < TestCase
131
+ def program
132
+ <<~RUBY
133
+ 1| module Foo
134
+ 1| class Bar
135
+ 2| def self.a
136
+ 3| "hello"
137
+ 4| end
138
+ 5| end
139
+ 6| Bar.a
140
+ 7| bar = Bar.new
141
+ 8| end
142
+ RUBY
143
+ end
144
+
145
+ def test_foo
146
+ debug_code(program) do
147
+ type 's'
148
+ assert_line_num 2
149
+ assert_line_text([
150
+ /[1, 9] in .*/,
151
+ / 1| module Foo/,
152
+ /=> 2| class Bar/,
153
+ / 3| def self.a/,
154
+ / 4| "hello"/,
155
+ / 5| end/,
156
+ / 6| end/,
157
+ / 7| Bar.a/,
158
+ / 8| bar = Bar.new/,
159
+ / 9| end/,
160
+ /=>#0 <module:Foo> at .*/,
161
+ / #1 <main> at .*/
162
+ ])
163
+ type 'n'
164
+ assert_line_num 3
165
+ assert_line_text([
166
+ /[1, 9] in .*/,
167
+ / 1| module Foo/,
168
+ / 2| class Bar/,
169
+ /=> 3| def self.a/,
170
+ / 4| "hello"/,
171
+ / 5| end/,
172
+ / 6| end/,
173
+ / 7| Bar.a/,
174
+ / 8| bar = Bar.new/,
175
+ / 9| end/,
176
+ /=>#0 <class:Bar> at .*/,
177
+ / #1 <module:Foo> at .*/,
178
+ / #2 <main> at .*/
179
+ ])
180
+ type 'b 7'
181
+ assert_line_text(//)
182
+ type 'c'
183
+ assert_line_num 7
184
+ assert_line_text([
185
+ /[2, 9] in .*/,
186
+ / 2| class Bar/,
187
+ / 3| def self.a/,
188
+ / 4| "hello"/,
189
+ / 5| end/,
190
+ / 6| end/,
191
+ /=> 7| Bar.a/,
192
+ / 8| bar = Bar.new/,
193
+ / 9| end/,
194
+ /=>#0 <module:Foo> at .*/,
195
+ / #1 <main> at .*/,
196
+ //,
197
+ /Stop by #0 BP - Line .*/
198
+ ])
199
+ type 'q!'
200
+ end
201
+ end
202
+ end
203
+ end
204
+ ```
205
+
206
+ #### gentest options
207
+ You can get more information about `gentest` here.
208
+
209
+ The default method name is `test_foo` and the class name is `FooTest`. The file name will be `[Lowercase letters with "Test" removed from the class name]_test.rb`.
210
+ ```shell
211
+ # run without any options(test method name will be `test_foo`, class name will be `FooTest`, file name will be `foo_test.rb`)
212
+ $ bin/gentest target.rb
213
+ # specify the class name(test method name will be `test_foo`, class name will be `StepTest`, file name will be `step_test.rb`)
214
+ $ bin/gentest target.rb -c StepTest
215
+ # specify the method name(test method name will be `test_step`, class name will be `FooTest`, file name will be `foo_test.rb`)
216
+ $ bin/gentest target.rb -m test_step
217
+ # specify class name and method name(test method name will be `test_step`, class name will be `StepTest`, file name will be `step_test.rb`.)
218
+ $ bin/gentest target.rb -c StepTest -m test_step
219
+ ```
220
+
221
+ ## To Update README
222
+
223
+ This project generates `README.md` from the template `misc/README.md.erb`
224
+
225
+ So **do not** directly update `README.md`. Instead, you should update the template's source and run
226
+
227
+ ```bash
228
+ $ rake
229
+ ```
230
+
231
+ to reflect the changes on `README.md`.
232
+
233
+
234
+ ### When to re-generate `README.md`
235
+
236
+ - After updating `misc/README.md.erb`.
237
+ - After updating `rdbg` executable's options.
238
+ - After updating comments of debugger's commands.
239
+
240
+ ## Manually Test Your Changes
241
+
242
+ You can manually test your changes with a simple Ruby script + a line of command. The following example will help you check:
243
+
244
+ - Breakpoint insertion.
245
+ - Resume from the breakpoint.
246
+ - Backtrace display.
247
+ - Information (local variables, ivars..etc.) display.
248
+ - Debugger exit.
249
+
250
+
251
+ ### Script
252
+
253
+ ```ruby
254
+ # target.rb
255
+ class Foo
256
+ def first_call
257
+ second_call(20)
258
+ end
259
+
260
+ def second_call(num)
261
+ third_call_with_block do |ten|
262
+ forth_call(num, ten)
263
+ end
264
+ end
265
+
266
+ def third_call_with_block(&block)
267
+ @ivar1 = 10; @ivar2 = 20
268
+
269
+ yield(10)
270
+ end
271
+
272
+ def forth_call(num1, num2)
273
+ num1 + num2
274
+ end
275
+ end
276
+
277
+ Foo.new.first_call
278
+ ```
279
+
280
+ ### Command
281
+
282
+ ```
283
+ $ exe/rdbg -e 'b 20;; c ;; bt ;; info ;; q!' -e c target.rb
284
+ ```
285
+
286
+ ### Expect Result
287
+
288
+ ```
289
+ ❯ exe/rdbg -e 'b 20;; c ;; bt ;; info ;; q!' -e c target.rb
290
+ [1, 10] in target.rb
291
+ => 1| class Foo
292
+ 2| def first_call
293
+ 3| second_call(20)
294
+ 4| end
295
+ 5|
296
+ 6| def second_call(num)
297
+ 7| third_call_with_block do |ten|
298
+ 8| forth_call(num, ten)
299
+ 9| end
300
+ 10| end
301
+ =>#0 <main> at target.rb:1
302
+ (rdbg:init) b 20
303
+ #1 line bp /PATH_TO_PROJECT/debug/target.rb:20 (return)
304
+ (rdbg:init) c
305
+ [15, 23] in target.rb
306
+ 15| yield(10)
307
+ 16| end
308
+ 17|
309
+ 18| def forth_call(num1, num2)
310
+ 19| num1 + num2
311
+ => 20| end
312
+ 21| end
313
+ 22|
314
+ 23| Foo.new.first_call
315
+ =>#0 Foo#forth_call(num1=20, num2=10) at target.rb:20 #=> 30
316
+ #1 block{|ten=10|} in second_call at target.rb:8
317
+ # and 4 frames (use `bt' command for all frames)
318
+
319
+ Stop by #1 line bp /PATH_TO_PROJECT/debug/target.rb:20 (return)
320
+ (rdbg:init) bt
321
+ =>#0 Foo#forth_call(num1=20, num2=10) at target.rb:20 #=> 30
322
+ #1 block{|ten=10|} in second_call at target.rb:8
323
+ #2 Foo#third_call_with_block(block=#<Proc:0x00007f8bc32f0c28 target.rb:7>) at target.rb:15
324
+ #3 Foo#second_call(num=20) at target.rb:7
325
+ #4 first_call at target.rb:3
326
+ #5 <main> at target.rb:23
327
+ (rdbg:init) info
328
+ =>#0 Foo#forth_call(num1=20, num2=10) at target.rb:20 #=> 30
329
+ %self => #<Foo:0x00007f8bc32f0ed0>
330
+ %return => 30
331
+ num1 => 20
332
+ num2 => 10
333
+ @ivar1 => 10
334
+ @ivar2 => 20
335
+ (rdbg:init) q!
336
+ ```
data/Gemfile CHANGED
@@ -2,6 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rake", "~> 12.0"
5
+ gem "rake"
6
6
  gem "rake-compiler"
7
- gem "minitest", "~> 5.0"
7
+ gem "test-unit", "~> 3.0"
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Ruby](https://github.com/ruby/debug/actions/workflows/ruby.yml/badge.svg?branch=master)](https://github.com/ruby/debug/actions/workflows/ruby.yml?query=branch%3Amaster)
2
+
1
3
  # debug.rb
2
4
 
3
5
  This library provides debugging functionality to Ruby.
@@ -9,7 +11,7 @@ New debug.rb has several advantages:
9
11
  * Remote debugging: Support remote debugging natively.
10
12
  * UNIX domain socket
11
13
  * TCP/IP
12
- * VSCode/DAP integration (TODO)
14
+ * VSCode/DAP integration ([VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg))
13
15
  * Extensible: application can introduce debugging support with several methods
14
16
  * By `rdbg` command
15
17
  * By loading libraries with `-r` command line option
@@ -27,6 +29,16 @@ $ gem install debug --pre
27
29
 
28
30
  or specify `-Ipath/to/debug/lib` in `RUBYOPT` or each ruby command-line option, especially for debug this gem development.
29
31
 
32
+ If you use Bundler, write the following line to your Gemfile. And use rdbg command with -c option.
33
+
34
+ ```
35
+ gem "debug", ">= 1.0.0.beta"
36
+ ```
37
+
38
+ ```
39
+ $ rdbg -c bundle exec ruby target.rb
40
+ ```
41
+
30
42
  # How to use
31
43
 
32
44
  ## Invoke with debugger
@@ -49,33 +61,54 @@ To use debugging feature, you can have 3 ways.
49
61
 
50
62
  ### Local debug console
51
63
 
64
+ #### (1) Use `rdbg` command
65
+
52
66
  ```
53
- # (1) Use `rdbg` command
54
67
  $ rdbg target.rb
55
68
  $ rdbg -- -r foo -e expr # -- is required to make clear rdbg options and ruby's options
69
+ ```
56
70
 
57
- # (2) Use `-r debug/run` command line option
71
+ #### (2) Use `-r debug/run` command line option
58
72
 
73
+ ```
59
74
  $ ruby -r debug/run target.rb
75
+ ```
60
76
 
61
- # (3) Write `require 'debug...' in .rb files
77
+ #### (3) Write `require 'debug...'` in .rb files
62
78
 
63
- $ cat target.rb
79
+ ```ruby
80
+ # target.rb
64
81
  require 'debug/run' # start the debug console
65
- ...
66
82
 
67
- # or
83
+ # ... rest of program ...
84
+ ```
68
85
 
69
- $ cat target.rb
70
- require 'debug/session' # introduce the functionality
71
- DEBUGGER__.console # and start the debug console
72
86
 
87
+ ```
73
88
  $ ruby target.rb
74
89
  ```
75
90
 
76
91
  When you run the program with the debug console, you will see the debug console prompt `(rdbg)`.
77
92
  The debuggee program (`target.rb`) is suspended at the beginning of `target.rb`.
78
93
 
94
+
95
+ Alternatively, start the debugger at a specific location in your program using `binding.break` (`binding.b` for short).
96
+
97
+ ```ruby
98
+ # target.rb
99
+ require 'debug' # start the debugger
100
+
101
+ # ... program ...
102
+
103
+ binding.break # setup a breakpoint at this line
104
+
105
+ # ... rest of program ...
106
+ ```
107
+
108
+ ```
109
+ $ ruby target.rb
110
+ ```
111
+
79
112
  You can type any debugger's command described bellow. "c" or "continue" resume the debuggee program.
80
113
  You can suspend the debuggee program and show the debug console with `Ctrl-C`.
81
114
 
@@ -143,33 +176,36 @@ $ rdbg ~/src/rb/target.rb
143
176
 
144
177
  ### Remote debug (1) UNIX domain socket
145
178
 
179
+ #### (1) Use `rdbg` command
180
+
146
181
  ```
147
- # (1) Use `rdbg` command
148
182
  $ rdbg --open target.rb # or rdbg -O target.rb for shorthand
149
183
  Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-5042)
150
- ...
184
+ ```
151
185
 
152
- # (2) Use `-r debug/open` command line option
186
+ #### (2) Use `-r debug/open` command line option
153
187
 
188
+ ```
154
189
  $ ruby -r debug/open target.rb
155
190
  Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-5042)
156
- ...
191
+ ```
157
192
 
158
- # (3) Write `require 'debug/open' in .rb files
159
- $ cat target.rb
193
+ #### (3) Write `require 'debug/open'` in .rb files
194
+
195
+ ```ruby
196
+ # target.rb
160
197
  require 'debug/open' # open the debugger entry point by UNIX domain socket.
161
- ...
162
198
 
163
199
  # or
164
200
 
165
- $ cat target.rb
166
201
  require 'debug/server' # introduce remote debugging feature
167
202
  DEBUGGER__.open # open the debugger entry point by UNIX domain socket.
168
203
  # or DEBUGGER__.open_unix to specify UNIX domain socket.
204
+ ```
169
205
 
206
+ ```
170
207
  $ ruby target.rb
171
208
  Debugger can attach via UNIX domain socket (/home/ko1/.ruby-debug-sock/ruby-debug-ko1-5042)
172
- ...
173
209
  ```
174
210
 
175
211
  It runs target.rb and accept debugger connection within UNIX domain socket.
@@ -233,40 +269,49 @@ The socket file is located at
233
269
 
234
270
  You can open the TCP/IP port instead of using UNIX domain socket.
235
271
 
272
+ #### (1) Use `rdbg` command
273
+
236
274
  ```
237
- # (1) Use `rdbg` command
238
275
  $ rdbg -O --port=12345 target.rb
239
276
  # or
240
277
  $ rdbg --open --port=12345 target.rb
241
278
  Debugger can attach via TCP/IP (localhost:12345)
242
- ...
279
+ ```
243
280
 
244
- # (2) Use `-r debug/open` command line option
281
+ #### (2) Use `-r debug/open` command line option
245
282
 
283
+
284
+ ```
246
285
  $ RUBY_DEBUG_PORT=12345 ruby -r debug/open target.rb
247
286
  Debugger can attach via TCP/IP (localhost:12345)
248
- ...
287
+ ```
288
+
289
+ #### (3) Write `require 'debug/open'` in .rb files
249
290
 
250
- # (3) Write `require 'debug/open' in .rb files
251
- $ cat target.rb
291
+ ```ruby
292
+ # target.rb
252
293
  require 'debug/open' # open the debugger entry point.
253
- ...
294
+ ```
295
+
296
+ and run with environment variable RUBY_DEBUG_PORT
254
297
 
255
- # and run with environment variable RUBY_DEBUG_PORT
298
+ ```
256
299
  $ RUBY_DEBUG_PORT=12345 ruby target.rb
257
300
  Debugger can attach via TCP/IP (localhost:12345)
258
- ...
301
+ ```
259
302
 
260
- # or
303
+ or
261
304
 
262
- $ cat target.rb
305
+ ```ruby
306
+ # target.rb
263
307
  require 'debug/server' # introduce remote debugging feature
264
308
  DEBUGGER__.open(port: 12345)
265
309
  # or DEBUGGER__.open_tcp(port: 12345)
310
+ ```
266
311
 
312
+ ```
267
313
  $ ruby target.rb
268
314
  Debugger can attach via TCP/IP (localhost:12345)
269
- ...
270
315
  ```
271
316
 
272
317
  You can also specify the host with the `RUBY_DEBUG_HOST` environment variable. And also `DEBUGGER__.open` method accepts a `host:` keyword parameter. If the host is not given, `localhost` will be used.
@@ -280,26 +325,45 @@ $ rdbg --attach hostname 12345
280
325
 
281
326
  ### Initial scripts
282
327
 
283
- If there are `.rdbgrc` files are there at the current directory and the home directory, files are loaded as initial scripts which contains debugger commands. `RUBY_DEBUG_INIT_SCRIPT` environment variable can specify the initial script file.
328
+ If there are `~/.rdbgrc`, the file is loaded as initial scripts which contains debugger commands at the beginning of debug session. `RUBY_DEBUG_INIT_SCRIPT` environment variable can specify the initial script file. You can write configurations in a file. For example, you can set break points with `break file:123` in `~/.rdbgrc`.
284
329
 
285
- Initial scripts are evaluated at the first suspend timing (generally, it is the beginning of the target script). For example, you can set break points with `break file:123`.
330
+ If there are `~/.rdbgrc.rb` is available, it is loaded as a ruby script at same timing.
286
331
 
287
- If there are `.rdbgrc.rb` files at the current directory and the home directory, files are loaded as a ruby script at the initializing timing.
332
+ ### Configurations
288
333
 
289
- ### Environment variables
334
+ You can configure debugger's setting with environment variables and `config` command.
335
+ You can write any configuration into `~/.rdbgrc` like:
290
336
 
291
- You can control debuggee's behavior with environment variables:
337
+ ```
338
+ config set log_level INFO
339
+ config set no_color true
340
+ ```
292
341
 
293
- * `RUBY_DEBUG_NONSTOP`: 1 for nonstop at the beginning of program.
294
- * `RUBY_DEBUG_INIT_SCRIPT`: Initial script path loaded at the first stop.
295
- * `RUBY_DEBUG_COMMANDS`: Debug commands invoked at the first stop. Commands should be separated by ';;'.
296
- * `RUBY_DEBUG_SHOW_SRC_LINES`: Show n lines source code on breakpoint (default: 10 lines).
297
- * `RUBY_DEBUG_SHOW_FRAMES`: Show n frames on breakpoint (default: 2 frames).
298
342
 
299
- * Remote debugging
300
- * `RUBY_DEBUG_PORT`: TCP/IP remote debugging: port to open.
301
- * `RUBY_DEBUG_HOST`: TCP/IP remote debugging: host (localhost if not given) to open.
302
- * `RUBY_DEBUG_SOCK_DIR`: UNIX Domain Socket remote debugging: socket directory to open.
343
+ * UI
344
+ * `RUBY_DEBUG_LOG_LEVEL` (`log_level`): Log level same as Logger (default: WARN)
345
+ * `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10 lines)
346
+ * `RUBY_DEBUG_SHOW_FRAMES` (`show_frames`): Show n frames on breakpoint (default: 2 frames)
347
+ * `RUBY_DEBUG_SHOW_INFO_LINES` (`show_info_lines`): Show n lines on info command (default: 10 lines, 0 for unlimited)
348
+ * `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show shoten PATH (like $(Gem)/foo.rb)
349
+ * `RUBY_DEBUG_SKIP_NOSRC` (`skip_nosrc`): Skip on no source code lines (default: false)
350
+ * `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing frames for given paths (default: [])
351
+ * `RUBY_DEBUG_NO_COLOR` (`no_color`): Do not use colorize (default: false)
352
+ * `RUBY_DEBUG_NO_SIGINT_HOOK` (`no_sigint_hook`): Do not suspend on SIGINT (default: false)
353
+
354
+ * BOOT
355
+ * `RUBY_DEBUG_NONSTOP` (`nonstop`): Nonstop mode
356
+ * `RUBY_DEBUG_INIT_SCRIPT` (`init_script`): debug command script path loaded at first stop
357
+ * `RUBY_DEBUG_COMMANDS` (`commands`): debug commands invoked at first stop. commands should be separated by ';;'
358
+ * `RUBY_DEBUG_NO_RC` (`no_rc`): ignore loading ~/.rdbgrc(.rb)
359
+ * `RUBY_DEBUG_HISTORY` (`history`): save and load history file (default: ~/.rdbg_history)
360
+
361
+ * REMOTE
362
+ * `RUBY_DEBUG_PORT` (`port`): TCP/IP remote debugging: port
363
+ * `RUBY_DEBUG_HOST` (`host`): TCP/IP remote debugging: host (localhost if not given)
364
+ * `RUBY_DEBUG_SOCK_PATH` (`sock_path`): UNIX Domain Socket remote debugging: socket path
365
+ * `RUBY_DEBUG_SOCK_DIR` (`sock_dir`): UNIX Domain Socket remote debugging: socket directory
366
+ * `RUBY_DEBUG_COOKIE` (`cookie`): Cookie for negotiation
303
367
 
304
368
  ## Debug command on the debug console
305
369
 
@@ -321,10 +385,14 @@ The `<...>` notation means the argument.
321
385
  * Finish this frame. Resume the program until the current frame is finished.
322
386
  * `c[ontinue]`
323
387
  * Resume the program.
324
- * `q[uit]` or exit or `Ctrl-D`
388
+ * `q[uit]` or `Ctrl-D`
325
389
  * Finish debugger (with the debuggee process on non-remote debugging).
326
- * `kill` or `q[uit]!`
327
- * Stop the debuggee process.
390
+ * `q[uit]!`
391
+ * Same as q[uit] but without the confirmation prompt.
392
+ * `kill`
393
+ * Stop the debuggee process with `Kernal#exit!`.
394
+ * `kill!`
395
+ * Same as kill but without the confirmation prompt.
328
396
 
329
397
  ### Breakpoint
330
398
 
@@ -338,15 +406,19 @@ The `<...>` notation means the argument.
338
406
  * Set breakpoint on the method `<class>#<name>`.
339
407
  * `b[reak] <expr>.<name>`
340
408
  * Set breakpoint on the method `<expr>.<name>`.
341
- * `b[reak] ... if <expr>`
409
+ * `b[reak] ... if: <expr>`
342
410
  * break if `<expr>` is true at specified location.
343
- * `b[reak] if <expr>`
344
- * break if `<expr>` is true at any lines.
411
+ * `b[reak] ... pre: <command>`
412
+ * break and run `<command>` before stopping.
413
+ * `b[reak] ... do: <command>`
414
+ * break and run `<command>`, and continue.
415
+ * `b[reak] if: <expr>`
416
+ * break if: `<expr>` is true at any lines.
345
417
  * Note that this feature is super slow.
346
418
  * `catch <Error>`
347
419
  * Set breakpoint on raising `<Error>`.
348
- * `watch <expr>`
349
- * Stop the execution when the result of <expr> is changed.
420
+ * `watch @ivar`
421
+ * Stop the execution when the result of current scope's `@ivar` is changed.
350
422
  * Note that this feature is super slow.
351
423
  * `del[ete]`
352
424
  * delete all breakpoints.
@@ -357,6 +429,12 @@ The `<...>` notation means the argument.
357
429
 
358
430
  * `bt` or `backtrace`
359
431
  * Show backtrace (frame) information.
432
+ * `bt <num>` or `backtrace <num>`
433
+ * Only shows first `<num>` frames.
434
+ * `bt /regexp/` or `backtrace /regexp/`
435
+ * Only shows frames with method name or location info that matches `/regexp/`.
436
+ * `bt <num> /regexp/` or `backtrace <num> /regexp/`
437
+ * Only shows first `<num>` frames with method name or location info that matches `/regexp/`.
360
438
  * `l[ist]`
361
439
  * Show current frame's source code.
362
440
  * Next `list` command shows the successor lines.
@@ -369,11 +447,11 @@ The `<...>` notation means the argument.
369
447
  * Note that edited file will not be reloaded.
370
448
  * `edit <file>`
371
449
  * Open <file> on the editor.
372
- * `i[nfo]`
450
+ * `i[nfo]`, `i[nfo] l[ocal[s]]`
373
451
  * Show information about the current frame (local variables)
374
452
  * It includes `self` as `%self` and a return value as `%return`.
375
- * `i[nfo] <expr>`
376
- * Show information about the result of <expr>.
453
+ * `i[nfo] th[read[s]]`
454
+ * Show all threads (same as `th[read]`).
377
455
  * `display`
378
456
  * Show display setting.
379
457
  * `display <expr>`
@@ -388,13 +466,13 @@ The `<...>` notation means the argument.
388
466
  ### Frame control
389
467
 
390
468
  * `f[rame]`
391
- * Show current frame.
469
+ * Show the current frame.
392
470
  * `f[rame] <framenum>`
393
- * Specify frame. Evaluation are run on this frame environment.
471
+ * Specify a current frame. Evaluation are run on specified frame.
394
472
  * `up`
395
- * Specify upper frame.
473
+ * Specify the upper frame.
396
474
  * `down`
397
- * Specify down frame.
475
+ * Specify the lower frame.
398
476
 
399
477
  ### Evaluate
400
478
 
@@ -414,6 +492,19 @@ The `<...>` notation means the argument.
414
492
  * `th[read] <thnum>`
415
493
  * Switch thread specified by `<thnum>`.
416
494
 
495
+ ### Configuration
496
+
497
+ * `config`
498
+ * Show all configuration with description.
499
+ * `config <name>`
500
+ * Show current configuration of <name>.
501
+ * `config set <name> <val>` or `config <name> = <val>`
502
+ * Set <name> to <val>.
503
+ * `config append <name> <val>` or `config <name> << <val>`
504
+ * Append `<val>` to `<name>` if it is an array.
505
+ * `config unset <name>`
506
+ * Set <name> to default.
507
+
417
508
  ### Help
418
509
 
419
510
  * `h[elp]`
@@ -429,35 +520,61 @@ exe/rdbg [options] -- [debuggee options]
429
520
 
430
521
  Debug console mode:
431
522
  -n, --nonstop Do not stop at the beginning of the script.
432
- -e [COMMAND] execute debug command at the beginning of the script.
433
- -O, --open Start debuggee with opening the debugger port.
523
+ -e DEBUG_COMMAND Execute debug command at the beginning of the script.
524
+ -x, --init-script=FILE Execute debug command in the FILE.
525
+ --no-rc Ignore ~/.rdbgrc
526
+ --no-color Disable colorize
527
+ -c, --command Enable command mode.
528
+ The first argument should be a command name in $PATH.
529
+ Example: 'rdbg -c bundle exec rake test'
530
+
531
+ -O, --open Start remote debugging with opening the network port.
434
532
  If TCP/IP options are not given,
435
533
  a UNIX domain socket will be used.
436
- --port=[PORT] Listening TCP/IP port
437
- --host=[HOST] Listening TCP/IP host
534
+ --sock-path=SOCK_PATH UNIX Doman socket path
535
+ --port=PORT Listening TCP/IP port
536
+ --host=HOST Listening TCP/IP host
537
+ --cookie=COOKIE Set a cookie for connection
438
538
 
439
539
  Debug console mode runs Ruby program with the debug console.
440
540
 
441
- exe/rdbg target.rb foo bar starts like 'ruby target.rb foo bar'.
442
- exe/rdbg -- -r foo -e bar starts like 'ruby -r foo -e bar'.
443
- exe/rdbg -O target.rb foo bar starts and accepts attaching with UNIX domain socket.
444
- exe/rdbg -O --port 1234 target.rb foo bar starts accepts attaching with TCP/IP localhost:1234.
445
- exe/rdbg -O --port 1234 -- -r foo -e bar starts accepts attaching with TCP/IP localhost:1234.
541
+ 'rdbg target.rb foo bar' starts like 'ruby target.rb foo bar'.
542
+ 'rdbg -- -r foo -e bar' starts like 'ruby -r foo -e bar'.
543
+ 'rdbg -c rake test' starts like 'rake test'.
544
+ 'rdbg -c -- rake test -t' starts like 'rake test -t'.
545
+ 'rdbg -c bundle exec rake test' starts like 'bundle exec rake test'.
546
+ 'rdbg -O target.rb foo bar' starts and accepts attaching with UNIX domain socket.
547
+ 'rdbg -O --port 1234 target.rb foo bar' starts accepts attaching with TCP/IP localhost:1234.
548
+ 'rdbg -O --port 1234 -- -r foo -e bar' starts accepts attaching with TCP/IP localhost:1234.
446
549
 
447
550
  Attach mode:
448
551
  -A, --attach Attach to debuggee process.
449
552
 
450
553
  Attach mode attaches the remote debug console to the debuggee process.
451
554
 
452
- 'exe/rdbg -A' tries to connect via UNIX domain socket.
555
+ 'rdbg -A' tries to connect via UNIX domain socket.
453
556
  If there are multiple processes are waiting for the
454
557
  debugger connection, list possible debuggee names.
455
- 'exe/rdbg -A path' tries to connect via UNIX domain socket with given path name.
456
- 'exe/rdbg -A port' tries to connect localhost:port via TCP/IP.
457
- 'exe/rdbg -A host port' tries to connect host:port via TCP/IP.
558
+ 'rdbg -A path' tries to connect via UNIX domain socket with given path name.
559
+ 'rdbg -A port' tries to connect to localhost:port via TCP/IP.
560
+ 'rdbg -A host port' tries to connect to host:port via TCP/IP.
561
+
562
+ Other options:
563
+ -h, --help Print help
564
+ --util=NAME Utility mode (used by tools)
565
+
566
+ NOTE
567
+ All messages communicated between a debugger and a debuggee are *NOT* encrypted.
568
+ Please use the remote debugging feature carefully.
458
569
 
459
570
  ```
460
571
 
461
572
  # Contributing
462
573
 
463
574
  Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/debug.
575
+
576
+ Please also check the [contributing guideline](/CONTRIBUTING.md).
577
+
578
+ # Acknowledgement
579
+
580
+ * Some tests are based on [deivid-rodriguez/byebug: Debugging in Ruby 2](https://github.com/deivid-rodriguez/byebug)