debug 1.0.0 → 1.2.2
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 +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +24 -0
- data/.github/ISSUE_TEMPLATE/custom.md +10 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +14 -0
- data/README.md +17 -10
- data/Rakefile +10 -7
- data/TODO.md +2 -1
- data/debug.gemspec +1 -1
- data/ext/debug/debug.c +5 -0
- data/lib/debug/breakpoint.rb +14 -5
- data/lib/debug/color.rb +25 -3
- data/lib/debug/config.rb +18 -3
- data/lib/debug/console.rb +10 -2
- data/lib/debug/frame_info.rb +5 -5
- data/lib/debug/local.rb +21 -24
- data/lib/debug/server.rb +8 -7
- data/lib/debug/server_dap.rb +30 -19
- data/lib/debug/session.rb +244 -98
- data/lib/debug/thread_client.rb +22 -13
- data/lib/debug/tracer.rb +8 -3
- data/lib/debug/version.rb +1 -1
- data/misc/README.md.erb +10 -8
- metadata +11 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7831c2e401b4bf33ecd14f5cef5eeb1c1a0feb57037a162c00f6cc780975b4c6
|
|
4
|
+
data.tar.gz: 182d55e56b662858b04e03336dd8bb4d0e15da8418b3aea137d05dcd02aa4ac0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dcf9f62fc4cf7f782238cd7b61137bde035047f6226eeac6cae639b28ada181862ee82ce146a1e33c6c08d80a8fc35ffe4a2cf24eda576e4792babbf8436ca88
|
|
7
|
+
data.tar.gz: 1f66b3c18a14f1f337d010a8e9d29d6a0e0b1c4c92c976a87e0c2db265ff6a1259d31918e4c10525d16154f6a8f9fa694bcdbebbb081278b6ee488ae122f8713
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Your environment**
|
|
11
|
+
|
|
12
|
+
* `ruby -v`:
|
|
13
|
+
* `rdbg -v`:
|
|
14
|
+
|
|
15
|
+
**Describe the bug**
|
|
16
|
+
A clear and concise description of what the bug is.
|
|
17
|
+
|
|
18
|
+
**To Reproduce**
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Additional context**
|
|
24
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Your proposal**
|
|
11
|
+
What is your idea?
|
|
12
|
+
|
|
13
|
+
**Additional context**
|
|
14
|
+
Add any other context or screenshots about the feature request here.
|
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This debug.rb is replacement of traditional lib/debug.rb standard library which
|
|
|
8
8
|
New debug.rb has several advantages:
|
|
9
9
|
|
|
10
10
|
* Fast: No performance penalty on non-stepping mode and non-breakpoints.
|
|
11
|
-
* Remote debugging: Support remote debugging natively.
|
|
11
|
+
* [Remote debugging](#remote-debugging): Support remote debugging natively.
|
|
12
12
|
* UNIX domain socket
|
|
13
13
|
* TCP/IP
|
|
14
14
|
* VSCode/DAP integration ([VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg))
|
|
@@ -44,22 +44,24 @@ To use a debugger, roughly you will do the following steps:
|
|
|
44
44
|
2. Run a program with the debugger.
|
|
45
45
|
3. At the breakpoint, enter the debugger console.
|
|
46
46
|
4. Use debug commands.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
47
|
+
* [Evaluate Ruby expressions](#evaluate) (e.g. `p lvar` to see the local variable `lvar`).
|
|
48
|
+
* [Query the program status](#information) (e.g. `info` to see information about the current frame).
|
|
49
|
+
* [Control program flow](#control-flow) (e.g. move to the another line with `step`, to the next line with `next`).
|
|
50
|
+
* [Set another breakpoint](#breakpoint) (e.g. `catch Exception` to set a breakpoint that'll be triggered when `Exception` is raised).
|
|
51
|
+
* [Activate tracing in your program](#trace) (e.g. `trace call` to trace method calls).
|
|
52
|
+
* [Change the configuration](#configuration-1) (e.g. `config set no_color true` to disable coloring).
|
|
51
53
|
* Continue the program (`c` or `continue`) and goto 3.
|
|
52
54
|
|
|
53
55
|
## Invoke with the debugger
|
|
54
56
|
|
|
55
57
|
There are several options for (1) and (2). Please choose your favorite way.
|
|
56
58
|
|
|
57
|
-
### Modify source code
|
|
59
|
+
### Modify source code with [`binding.break`](#bindingbreak-method) (similar to `binding.pry` or `binding.irb`)
|
|
58
60
|
|
|
59
|
-
If you can modify the source code, you can use the debugger by adding `require 'debug'` line at the top of your program and putting `binding.break` method (`binding.b` for short) into lines where you want to stop as breakpoints like `binding.pry` and `binding.irb`.
|
|
61
|
+
If you can modify the source code, you can use the debugger by adding `require 'debug'` line at the top of your program and putting [`binding.break`](#bindingbreak-method) method (`binding.b` for short) into lines where you want to stop as breakpoints like `binding.pry` and `binding.irb`.
|
|
60
62
|
After that, you run the program as usual and you will enter the debug console at breakpoints you inserted.
|
|
61
63
|
|
|
62
|
-
The following example shows the demonstration of `binding.break
|
|
64
|
+
The following example shows the demonstration of [`binding.break`](#bindingbreak-method).
|
|
63
65
|
|
|
64
66
|
```shell
|
|
65
67
|
$ cat target.rb # Sample program
|
|
@@ -355,7 +357,7 @@ config set no_color true
|
|
|
355
357
|
* `RUBY_DEBUG_LOG_LEVEL` (`log_level`): Log level same as Logger (default: WARN)
|
|
356
358
|
* `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10 lines)
|
|
357
359
|
* `RUBY_DEBUG_SHOW_FRAMES` (`show_frames`): Show n frames on breakpoint (default: 2 frames)
|
|
358
|
-
* `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show
|
|
360
|
+
* `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show shorten PATH (like $(Gem)/foo.rb)
|
|
359
361
|
* `RUBY_DEBUG_NO_COLOR` (`no_color`): Do not use colorize (default: false)
|
|
360
362
|
* `RUBY_DEBUG_NO_SIGINT_HOOK` (`no_sigint_hook`): Do not suspend on SIGINT (default: false)
|
|
361
363
|
* `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
|
|
@@ -370,6 +372,7 @@ config set no_color true
|
|
|
370
372
|
|
|
371
373
|
* BOOT
|
|
372
374
|
* `RUBY_DEBUG_NONSTOP` (`nonstop`): Nonstop mode
|
|
375
|
+
* `RUBY_DEBUG_STOP_AT_LOAD` (`stop_at_load`): Stop at just loading location
|
|
373
376
|
* `RUBY_DEBUG_INIT_SCRIPT` (`init_script`): debug command script path loaded at first stop
|
|
374
377
|
* `RUBY_DEBUG_COMMANDS` (`commands`): debug commands invoked at first stop. commands should be separated by ';;'
|
|
375
378
|
* `RUBY_DEBUG_NO_RC` (`no_rc`): ignore loading ~/.rdbgrc(.rb)
|
|
@@ -434,6 +437,9 @@ The `<...>` notation means the argument.
|
|
|
434
437
|
* Stop the debuggee process with `Kernal#exit!`.
|
|
435
438
|
* `kill!`
|
|
436
439
|
* Same as kill but without the confirmation prompt.
|
|
440
|
+
* `sigint`
|
|
441
|
+
* Execute SIGINT handler registerred by the debuggee.
|
|
442
|
+
* Note that this command should be used just after stop by `SIGINT`.
|
|
437
443
|
|
|
438
444
|
### Breakpoint
|
|
439
445
|
|
|
@@ -494,7 +500,7 @@ The `<...>` notation means the argument.
|
|
|
494
500
|
* Show information about the current frame (local variables)
|
|
495
501
|
* It includes `self` as `%self` and a return value as `%return`.
|
|
496
502
|
* `i[nfo] i[var[s]]` or `i[nfo] instance`
|
|
497
|
-
* Show information about
|
|
503
|
+
* Show information about instance variables about `self`.
|
|
498
504
|
* `i[nfo] c[onst[s]]` or `i[nfo] constant[s]`
|
|
499
505
|
* Show information about accessible constants except toplevel constants.
|
|
500
506
|
* `i[nfo] g[lobal[s]]`
|
|
@@ -726,6 +732,7 @@ Attach mode:
|
|
|
726
732
|
Other options:
|
|
727
733
|
-h, --help Print help
|
|
728
734
|
--util=NAME Utility mode (used by tools)
|
|
735
|
+
--stop-at-load Stop immediately when the debugging feature is loaded.
|
|
729
736
|
|
|
730
737
|
NOTE
|
|
731
738
|
All messages communicated between a debugger and a debuggee are *NOT* encrypted.
|
data/Rakefile
CHANGED
|
@@ -7,15 +7,18 @@ Rake::TestTask.new(:test) do |t|
|
|
|
7
7
|
t.test_files = FileList["test/**/*_test.rb"]
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
task :build => :compile
|
|
13
|
-
|
|
14
|
-
Rake::ExtensionTask.new("debug") do |ext|
|
|
15
|
-
|
|
10
|
+
begin
|
|
11
|
+
require "rake/extensiontask"
|
|
12
|
+
task :build => :compile
|
|
13
|
+
|
|
14
|
+
Rake::ExtensionTask.new("debug") do |ext|
|
|
15
|
+
ext.lib_dir = "lib/debug"
|
|
16
|
+
end
|
|
17
|
+
rescue LoadError
|
|
16
18
|
end
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
task :default => [:clobber, :compile, 'README.md', :test]
|
|
19
22
|
|
|
20
23
|
file 'README.md' => ['lib/debug/session.rb', 'lib/debug/config.rb',
|
|
21
24
|
'exe/rdbg', 'misc/README.md.erb'] do
|
data/TODO.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## Basic functionality
|
|
4
4
|
|
|
5
5
|
* Support Ractors
|
|
6
|
-
* Signal (SIGINT) trap handling
|
|
6
|
+
* Signal (SIGINT) trap handling
|
|
7
7
|
|
|
8
8
|
## UI
|
|
9
9
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* Interactive record & play debugging
|
|
13
13
|
* irb integration
|
|
14
14
|
* Web browser integrated UI
|
|
15
|
+
* History file
|
|
15
16
|
|
|
16
17
|
## Debug command
|
|
17
18
|
|
data/debug.gemspec
CHANGED
|
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.require_paths = ["lib"]
|
|
26
26
|
spec.extensions = ['ext/debug/extconf.rb']
|
|
27
27
|
|
|
28
|
-
spec.add_dependency "irb" # for its color_printer class, which was added after 1.3
|
|
28
|
+
spec.add_dependency "irb", ">= 1.3.6" # for its color_printer class, which was added after 1.3
|
|
29
29
|
spec.add_dependency "reline", ">= 0.2.7"
|
|
30
30
|
end
|
data/ext/debug/debug.c
CHANGED
|
@@ -122,6 +122,11 @@ Init_debug(void)
|
|
|
122
122
|
{
|
|
123
123
|
rb_mDebugger = rb_const_get(rb_cObject, rb_intern("DEBUGGER__"));
|
|
124
124
|
rb_cFrameInfo = rb_const_get(rb_mDebugger, rb_intern("FrameInfo"));
|
|
125
|
+
|
|
126
|
+
// Debugger and FrameInfo were defined in Ruby. We need to register them
|
|
127
|
+
// as mark objects so they are automatically pinned.
|
|
128
|
+
rb_gc_register_mark_object(rb_mDebugger);
|
|
129
|
+
rb_gc_register_mark_object(rb_cFrameInfo);
|
|
125
130
|
rb_define_singleton_method(rb_mDebugger, "capture_frames", capture_frames, 1);
|
|
126
131
|
rb_define_singleton_method(rb_mDebugger, "frame_depth", frame_depth, 0);
|
|
127
132
|
rb_define_singleton_method(rb_mDebugger, "create_method_added_tracker", create_method_added_tracker, 0);
|
data/lib/debug/breakpoint.rb
CHANGED
|
@@ -288,6 +288,7 @@ module DEBUGGER__
|
|
|
288
288
|
@tp = TracePoint.new(:line){|tp|
|
|
289
289
|
next if tp.path.start_with? __dir__
|
|
290
290
|
next if tp.path.start_with? '<internal:'
|
|
291
|
+
next if ThreadClient.current.management?
|
|
291
292
|
|
|
292
293
|
if safe_eval tp.binding, @expr
|
|
293
294
|
suspend
|
|
@@ -430,17 +431,24 @@ module DEBUGGER__
|
|
|
430
431
|
if @sig_op == '#'
|
|
431
432
|
@cond_class = @klass if @method.owner != @klass
|
|
432
433
|
else # '.'
|
|
433
|
-
|
|
434
|
+
begin
|
|
435
|
+
@cond_class = @klass.singleton_class if @method.owner != @klass.singleton_class
|
|
436
|
+
rescue TypeError
|
|
437
|
+
end
|
|
434
438
|
end
|
|
435
439
|
|
|
436
|
-
rescue ArgumentError
|
|
440
|
+
rescue ArgumentError => e
|
|
437
441
|
raise if retried
|
|
438
442
|
retried = true
|
|
439
443
|
|
|
440
444
|
# maybe C method
|
|
441
445
|
case @sig_op
|
|
442
446
|
when '.'
|
|
443
|
-
|
|
447
|
+
begin
|
|
448
|
+
override @klass.singleton_class
|
|
449
|
+
rescue TypeError
|
|
450
|
+
override @klass.class
|
|
451
|
+
end
|
|
444
452
|
when '#'
|
|
445
453
|
override @klass
|
|
446
454
|
end
|
|
@@ -450,7 +458,7 @@ module DEBUGGER__
|
|
|
450
458
|
@override_method = true if @method
|
|
451
459
|
retry
|
|
452
460
|
end
|
|
453
|
-
rescue Exception
|
|
461
|
+
rescue Exception => e
|
|
454
462
|
raise unless added
|
|
455
463
|
end
|
|
456
464
|
|
|
@@ -460,7 +468,8 @@ module DEBUGGER__
|
|
|
460
468
|
|
|
461
469
|
def to_s
|
|
462
470
|
if @method
|
|
463
|
-
|
|
471
|
+
loc = @method.source_location || []
|
|
472
|
+
"#{generate_label("Method")} #{sig} at #{loc.join(':')}"
|
|
464
473
|
else
|
|
465
474
|
"#{generate_label("Method (pending)")} #{sig}"
|
|
466
475
|
end + super
|
data/lib/debug/color.rb
CHANGED
|
@@ -17,9 +17,25 @@ end
|
|
|
17
17
|
module DEBUGGER__
|
|
18
18
|
module Color
|
|
19
19
|
if defined? IRB::Color.colorize
|
|
20
|
+
begin
|
|
21
|
+
IRB::Color.colorize('', [:DIM], colorable: true)
|
|
22
|
+
SUPPORT_COLORABLE_OPTION = true
|
|
23
|
+
rescue ArgumentError
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
if defined? SUPPORT_COLORABLE_OPTION
|
|
27
|
+
def irb_colorize str, color
|
|
28
|
+
IRB::Color.colorize str, color, colorable: true
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
def irb_colorize str, color
|
|
32
|
+
IRB::Color.colorize str, color
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
20
36
|
def colorize str, color
|
|
21
37
|
if !CONFIG[:no_color]
|
|
22
|
-
|
|
38
|
+
irb_colorize str, color
|
|
23
39
|
else
|
|
24
40
|
str
|
|
25
41
|
end
|
|
@@ -63,8 +79,14 @@ module DEBUGGER__
|
|
|
63
79
|
end
|
|
64
80
|
|
|
65
81
|
if defined? IRB::Color.colorize_code
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
if SUPPORT_COLORABLE_OPTION
|
|
83
|
+
def colorize_code code
|
|
84
|
+
IRB::Color.colorize_code(code, colorable: true)
|
|
85
|
+
end
|
|
86
|
+
else
|
|
87
|
+
def colorize_code code
|
|
88
|
+
IRB::Color.colorize_code(code)
|
|
89
|
+
end
|
|
68
90
|
end
|
|
69
91
|
else
|
|
70
92
|
def colorize_code code
|
data/lib/debug/config.rb
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module DEBUGGER__
|
|
4
|
+
LOG_LEVELS = {
|
|
5
|
+
UNKNOWN: 0,
|
|
6
|
+
FATAL: 1,
|
|
7
|
+
ERROR: 2,
|
|
8
|
+
WARN: 3,
|
|
9
|
+
INFO: 4,
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
4
12
|
CONFIG_SET = {
|
|
5
13
|
# UI setting
|
|
6
14
|
log_level: ['RUBY_DEBUG_LOG_LEVEL', "UI: Log level same as Logger (default: WARN)", :loglevel],
|
|
7
15
|
show_src_lines: ['RUBY_DEBUG_SHOW_SRC_LINES', "UI: Show n lines source code on breakpoint (default: 10 lines)", :int],
|
|
8
16
|
show_frames: ['RUBY_DEBUG_SHOW_FRAMES', "UI: Show n frames on breakpoint (default: 2 frames)", :int],
|
|
9
|
-
use_short_path: ['RUBY_DEBUG_USE_SHORT_PATH', "UI: Show
|
|
17
|
+
use_short_path: ['RUBY_DEBUG_USE_SHORT_PATH', "UI: Show shorten PATH (like $(Gem)/foo.rb)", :bool],
|
|
10
18
|
no_color: ['RUBY_DEBUG_NO_COLOR', "UI: Do not use colorize (default: false)", :bool],
|
|
11
19
|
no_sigint_hook: ['RUBY_DEBUG_NO_SIGINT_HOOK', "UI: Do not suspend on SIGINT (default: false)", :bool],
|
|
12
20
|
no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library (default: false)", :bool],
|
|
@@ -21,6 +29,7 @@ module DEBUGGER__
|
|
|
21
29
|
|
|
22
30
|
# boot setting
|
|
23
31
|
nonstop: ['RUBY_DEBUG_NONSTOP', "BOOT: Nonstop mode", :bool],
|
|
32
|
+
stop_at_load: ['RUBY_DEBUG_STOP_AT_LOAD',"BOOT: Stop at just loading location", :bool],
|
|
24
33
|
init_script: ['RUBY_DEBUG_INIT_SCRIPT', "BOOT: debug command script path loaded at first stop"],
|
|
25
34
|
commands: ['RUBY_DEBUG_COMMANDS', "BOOT: debug commands invoked at first stop. commands should be separated by ';;'"],
|
|
26
35
|
no_rc: ['RUBY_DEBUG_NO_RC', "BOOT: ignore loading ~/.rdbgrc(.rb)", :bool],
|
|
@@ -102,7 +111,9 @@ module DEBUGGER__
|
|
|
102
111
|
end
|
|
103
112
|
|
|
104
113
|
if_updated old_conf, conf, :postmortem do |_, new_p|
|
|
105
|
-
SESSION
|
|
114
|
+
if defined?(SESSION)
|
|
115
|
+
SESSION.postmortem = new_p
|
|
116
|
+
end
|
|
106
117
|
end
|
|
107
118
|
|
|
108
119
|
if_updated old_conf, conf, :sigdump_sig do |old_sig, new_sig|
|
|
@@ -306,6 +317,10 @@ module DEBUGGER__
|
|
|
306
317
|
exit
|
|
307
318
|
end
|
|
308
319
|
|
|
320
|
+
o.on('--stop-at-load', 'Stop immediately when the debugging feature is loaded.') do
|
|
321
|
+
config[:stop_at_load] = true
|
|
322
|
+
end
|
|
323
|
+
|
|
309
324
|
o.separator ''
|
|
310
325
|
o.separator 'NOTE'
|
|
311
326
|
o.separator ' All messages communicated between a debugger and a debuggee are *NOT* encrypted.'
|
|
@@ -372,7 +387,7 @@ module DEBUGGER__
|
|
|
372
387
|
desc = cat = nil
|
|
373
388
|
cmds = Hash.new
|
|
374
389
|
|
|
375
|
-
File.read(File.join(__dir__, 'session.rb')).each_line do |line|
|
|
390
|
+
File.read(File.join(__dir__, 'session.rb'), encoding: Encoding::UTF_8).each_line do |line|
|
|
376
391
|
case line
|
|
377
392
|
when /\A\s*### (.+)/
|
|
378
393
|
cat = $1
|
data/lib/debug/console.rb
CHANGED
|
@@ -6,11 +6,19 @@ module DEBUGGER__
|
|
|
6
6
|
require 'reline'
|
|
7
7
|
|
|
8
8
|
# reline 0.2.7 or later is required.
|
|
9
|
-
raise LoadError if Reline::VERSION < '0.2.
|
|
9
|
+
raise LoadError if Reline::VERSION < '0.2.7'
|
|
10
10
|
|
|
11
11
|
require_relative 'color'
|
|
12
12
|
include Color
|
|
13
13
|
|
|
14
|
+
begin
|
|
15
|
+
prev = trap(:SIGWINCH, nil)
|
|
16
|
+
trap(:SIGWINCH, prev)
|
|
17
|
+
SIGWINCH_SUPPORTED = true
|
|
18
|
+
rescue ArgumentError
|
|
19
|
+
SIGWINCH_SUPPORTED = false
|
|
20
|
+
end
|
|
21
|
+
|
|
14
22
|
# 0.2.7 has SIGWINCH issue on non-main thread
|
|
15
23
|
class ::Reline::LineEditor
|
|
16
24
|
m = Module.new do
|
|
@@ -20,7 +28,7 @@ module DEBUGGER__
|
|
|
20
28
|
end
|
|
21
29
|
end
|
|
22
30
|
prepend m
|
|
23
|
-
end
|
|
31
|
+
end if SIGWINCH_SUPPORTED
|
|
24
32
|
|
|
25
33
|
def readline_setup prompt
|
|
26
34
|
commands = DEBUGGER__.commands
|
data/lib/debug/frame_info.rb
CHANGED
|
@@ -9,10 +9,10 @@ module DEBUGGER__
|
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
# extend FrameInfo with debug.so
|
|
12
|
-
|
|
12
|
+
begin
|
|
13
13
|
require_relative 'debug.so'
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
rescue LoadError
|
|
15
|
+
require 'debug/debug.so'
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
class FrameInfo
|
|
@@ -27,6 +27,7 @@ module DEBUGGER__
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def pretty_path
|
|
30
|
+
return '#<none>' unless path = self.path
|
|
30
31
|
use_short_path = CONFIG[:use_short_path]
|
|
31
32
|
|
|
32
33
|
case
|
|
@@ -137,10 +138,9 @@ module DEBUGGER__
|
|
|
137
138
|
if lvars = self._local_variables
|
|
138
139
|
lvars
|
|
139
140
|
elsif b = self.binding
|
|
140
|
-
|
|
141
|
+
b.local_variables.map{|var|
|
|
141
142
|
[var, b.local_variable_get(var)]
|
|
142
143
|
}.to_h
|
|
143
|
-
self._local_variables = lvars
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
|
data/lib/debug/local.rb
CHANGED
|
@@ -7,32 +7,27 @@ module DEBUGGER__
|
|
|
7
7
|
class UI_LocalConsole < UI_Base
|
|
8
8
|
def initialize
|
|
9
9
|
@console = Console.new
|
|
10
|
-
|
|
11
|
-
unless CONFIG[:no_sigint_hook]
|
|
12
|
-
@prev_handler = trap(:SIGINT){
|
|
13
|
-
if SESSION.active?
|
|
14
|
-
ThreadClient.current.on_trap :SIGINT
|
|
15
|
-
end
|
|
16
|
-
}
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def close
|
|
21
|
-
if @prev_handler
|
|
22
|
-
trap(:SIGINT, @prev_handler)
|
|
23
|
-
end
|
|
24
10
|
end
|
|
25
11
|
|
|
26
12
|
def remote?
|
|
27
13
|
false
|
|
28
14
|
end
|
|
29
15
|
|
|
30
|
-
def activate on_fork: false
|
|
31
|
-
|
|
16
|
+
def activate session, on_fork: false
|
|
17
|
+
unless CONFIG[:no_sigint_hook]
|
|
18
|
+
prev_handler = trap(:SIGINT){
|
|
19
|
+
if session.active?
|
|
20
|
+
ThreadClient.current.on_trap :SIGINT
|
|
21
|
+
end
|
|
22
|
+
}
|
|
23
|
+
session.intercept_trap_sigint_start prev_handler
|
|
24
|
+
end
|
|
32
25
|
end
|
|
33
26
|
|
|
34
27
|
def deactivate
|
|
35
|
-
|
|
28
|
+
if SESSION.intercept_trap_sigint?
|
|
29
|
+
trap(:SIGINT, SESSION.intercepted_sigint_cmd)
|
|
30
|
+
end
|
|
36
31
|
end
|
|
37
32
|
|
|
38
33
|
def width
|
|
@@ -76,15 +71,17 @@ module DEBUGGER__
|
|
|
76
71
|
end
|
|
77
72
|
|
|
78
73
|
def setup_interrupt
|
|
79
|
-
|
|
74
|
+
SESSION.intercept_trap_sigint false do
|
|
75
|
+
current_thread = Thread.current # should be session_server thread
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
prev_handler = trap(:INT){
|
|
78
|
+
current_thread.raise Interrupt
|
|
79
|
+
}
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
yield
|
|
82
|
+
ensure
|
|
83
|
+
trap(:INT, prev_handler)
|
|
84
|
+
end
|
|
88
85
|
end
|
|
89
86
|
end
|
|
90
87
|
end
|
data/lib/debug/server.rb
CHANGED
|
@@ -15,8 +15,6 @@ module DEBUGGER__
|
|
|
15
15
|
@q_ans = nil
|
|
16
16
|
@unsent_messages = []
|
|
17
17
|
@width = 80
|
|
18
|
-
|
|
19
|
-
activate
|
|
20
18
|
end
|
|
21
19
|
|
|
22
20
|
class Terminate < StandardError
|
|
@@ -37,7 +35,7 @@ module DEBUGGER__
|
|
|
37
35
|
end
|
|
38
36
|
end
|
|
39
37
|
|
|
40
|
-
def activate on_fork: false
|
|
38
|
+
def activate session, on_fork: false
|
|
41
39
|
@reader_thread = Thread.new do
|
|
42
40
|
# An error on this thread should break the system.
|
|
43
41
|
Thread.current.abort_on_exception = true
|
|
@@ -138,9 +136,9 @@ module DEBUGGER__
|
|
|
138
136
|
end
|
|
139
137
|
|
|
140
138
|
def setup_interrupt
|
|
141
|
-
prev_handler = trap(:
|
|
139
|
+
prev_handler = trap(:SIGURG) do
|
|
142
140
|
# $stderr.puts "trapped SIGINT"
|
|
143
|
-
ThreadClient.current.on_trap :
|
|
141
|
+
ThreadClient.current.on_trap :SIGURG
|
|
144
142
|
|
|
145
143
|
case prev_handler
|
|
146
144
|
when Proc
|
|
@@ -150,9 +148,12 @@ module DEBUGGER__
|
|
|
150
148
|
end
|
|
151
149
|
end
|
|
152
150
|
|
|
151
|
+
if prev_handler != "SYSTEM_DEFAULT"
|
|
152
|
+
DEBUGGER__.warn "SIGURG handler is overriddend by the debugger."
|
|
153
|
+
end
|
|
153
154
|
yield
|
|
154
155
|
ensure
|
|
155
|
-
trap(:
|
|
156
|
+
trap(:SIGURG, prev_handler)
|
|
156
157
|
end
|
|
157
158
|
|
|
158
159
|
attr_reader :reader_thread
|
|
@@ -230,7 +231,7 @@ module DEBUGGER__
|
|
|
230
231
|
|
|
231
232
|
def pause
|
|
232
233
|
# $stderr.puts "DEBUG: pause request"
|
|
233
|
-
Process.kill(:
|
|
234
|
+
Process.kill(:SIGURG, Process.pid)
|
|
234
235
|
end
|
|
235
236
|
|
|
236
237
|
def quit n
|