debug 1.3.0 → 1.3.1
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/lib/debug/client.rb +1 -3
- data/lib/debug/config.rb +36 -20
- data/lib/debug/local.rb +18 -0
- data/lib/debug/prelude.rb +1 -1
- data/lib/debug/server.rb +24 -7
- data/lib/debug/session.rb +5 -16
- data/lib/debug/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 948301b2d85d9acb8758ae20e63a60d0253dc1d1e1bf5c2ddc276abb39d12993
|
4
|
+
data.tar.gz: 2e6b7c89ee568710d52d3fcaff1ff5eb44db71c4e296e039a6f21f4e5de9b9ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd5237c7fc194760f33cdd97c007fe1c879ed4140342821972d2385a612bd5fd4c8faffd2a3763adea1378931be13e65d46e2a23f5997412ac96c6e7c802e0d2
|
7
|
+
data.tar.gz: 396eab432e765065288f49cda52ce8a4449ee6c97465bde2ef70ec8ca39678b80831748b551d6aa6e4417c1c6512b8b0f8caf4371516a9178181582b9bf9542c
|
data/lib/debug/client.rb
CHANGED
data/lib/debug/config.rb
CHANGED
@@ -371,38 +371,54 @@ module DEBUGGER__
|
|
371
371
|
|
372
372
|
## Unix domain socket configuration
|
373
373
|
|
374
|
-
def self.
|
374
|
+
def self.check_dir_authority path
|
375
|
+
fs = File.stat(path)
|
376
|
+
|
377
|
+
unless (dir_uid = fs.uid) == (uid = Process.uid)
|
378
|
+
raise "#{path} uid is #{dir_uid}, but Process.uid is #{uid}"
|
379
|
+
end
|
380
|
+
unless (dir_mode = fs.mode) == 040700 # 4: dir, 7:rwx
|
381
|
+
raise "#{path}'s mode is #{dir_mode.to_s(8)} (should be 040700)"
|
382
|
+
end
|
383
|
+
|
384
|
+
path
|
385
|
+
end
|
386
|
+
|
387
|
+
def self.unix_domain_socket_tmpdir
|
375
388
|
require 'tmpdir'
|
376
389
|
|
377
|
-
|
378
|
-
when path = CONFIG[:sock_dir]
|
379
|
-
when path = ENV['XDG_RUNTIME_DIR']
|
380
|
-
when tmpdir = Dir.tmpdir
|
390
|
+
if tmpdir = Dir.tmpdir
|
381
391
|
path = File.join(tmpdir, "ruby-debug-sock-#{Process.uid}")
|
382
392
|
|
383
|
-
|
384
|
-
fs = File.stat(path)
|
385
|
-
unless (dir_uid = fs.uid) == (uid = Process.uid)
|
386
|
-
raise "#{path} uid is #{dir_uid}, but Process.uid is #{uid}"
|
387
|
-
end
|
388
|
-
unless (dir_mode = fs.mode) == 040700 # 4: dir, 7:rwx
|
389
|
-
raise "#{path}'s mode is #{dir_mode.to_s(8)} (should be 040700)"
|
390
|
-
end
|
391
|
-
else
|
393
|
+
unless File.exist?(path)
|
392
394
|
d = Dir.mktmpdir
|
393
395
|
File.rename(d, path)
|
394
396
|
end
|
395
|
-
|
397
|
+
|
398
|
+
check_dir_authority(path)
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
def self.unix_domain_socket_homedir
|
403
|
+
if home = ENV['HOME']
|
396
404
|
path = File.join(home, '.ruby-debug-sock')
|
397
405
|
|
398
|
-
|
399
|
-
when !File.exist?(path)
|
406
|
+
unless File.exist?(path)
|
400
407
|
Dir.mkdir(path, 0700)
|
401
|
-
when !File.directory?(path)
|
402
|
-
raise "#{path} is not a directory."
|
403
408
|
end
|
409
|
+
|
410
|
+
check_dir_authority(path)
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
def self.unix_domain_socket_dir
|
415
|
+
case
|
416
|
+
when path = CONFIG[:sock_dir]
|
417
|
+
when path = ENV['XDG_RUNTIME_DIR']
|
418
|
+
when path = unix_domain_socket_tmpdir
|
419
|
+
when path = unix_domain_socket_homedir
|
404
420
|
else
|
405
|
-
raise 'specify RUBY_DEBUG_SOCK_DIR environment variable
|
421
|
+
raise 'specify RUBY_DEBUG_SOCK_DIR environment variable.'
|
406
422
|
end
|
407
423
|
|
408
424
|
path
|
data/lib/debug/local.rb
CHANGED
@@ -86,6 +86,24 @@ module DEBUGGER__
|
|
86
86
|
trap(:INT, prev_handler)
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
def after_fork_parent
|
91
|
+
parent_pid = Process.pid
|
92
|
+
|
93
|
+
at_exit{
|
94
|
+
SESSION.intercept_trap_sigint_end
|
95
|
+
trap(:SIGINT, :IGNORE)
|
96
|
+
|
97
|
+
if Process.pid == parent_pid
|
98
|
+
# only check child process from its parent
|
99
|
+
begin
|
100
|
+
# wait for all child processes to keep terminal
|
101
|
+
loop{ Process.waitpid }
|
102
|
+
rescue Errno::ESRCH, Errno::ECHILD
|
103
|
+
end
|
104
|
+
end
|
105
|
+
}
|
106
|
+
end
|
89
107
|
end
|
90
108
|
end
|
91
109
|
|
data/lib/debug/prelude.rb
CHANGED
data/lib/debug/server.rb
CHANGED
@@ -306,6 +306,10 @@ module DEBUGGER__
|
|
306
306
|
s.puts "quit"
|
307
307
|
end
|
308
308
|
end
|
309
|
+
|
310
|
+
def after_fork_parent
|
311
|
+
# do nothing
|
312
|
+
end
|
309
313
|
end
|
310
314
|
|
311
315
|
class UI_TcpServer < UI_ServerBase
|
@@ -454,14 +458,27 @@ module DEBUGGER__
|
|
454
458
|
::DEBUGGER__.warn "Debugger can attach via UNIX domain socket (#{@sock_path})"
|
455
459
|
vscode_setup if CONFIG[:open_frontend] == 'vscode'
|
456
460
|
|
457
|
-
|
458
|
-
@
|
459
|
-
|
461
|
+
begin
|
462
|
+
Socket.unix_server_loop @sock_path do |sock, client|
|
463
|
+
@sock_for_fork = sock
|
464
|
+
@client_addr = client
|
460
465
|
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
466
|
+
yield sock
|
467
|
+
ensure
|
468
|
+
sock.close
|
469
|
+
@sock_for_fork = nil
|
470
|
+
end
|
471
|
+
rescue Errno::ECONNREFUSED => _e
|
472
|
+
::DEBUGGER__.warn "#{_e.message} (socket path: #{@sock_path})"
|
473
|
+
|
474
|
+
if @sock_path.start_with? Config.unix_domain_socket_tmpdir
|
475
|
+
# try on homedir
|
476
|
+
@sock_path = Config.create_unix_domain_socket_name(unix_domain_socket_homedir)
|
477
|
+
::DEBUGGER__.warn "retry with #{@sock_path}"
|
478
|
+
retry
|
479
|
+
else
|
480
|
+
raise
|
481
|
+
end
|
465
482
|
end
|
466
483
|
end
|
467
484
|
end
|
data/lib/debug/session.rb
CHANGED
@@ -1635,20 +1635,7 @@ module DEBUGGER__
|
|
1635
1635
|
end
|
1636
1636
|
|
1637
1637
|
def after_fork_parent
|
1638
|
-
|
1639
|
-
at_exit{
|
1640
|
-
@intercept_trap_sigint = false
|
1641
|
-
trap(:SIGINT, :IGNORE)
|
1642
|
-
|
1643
|
-
if Process.pid == parent_pid
|
1644
|
-
# only check child process from its parent
|
1645
|
-
begin
|
1646
|
-
# wait for all child processes to keep terminal
|
1647
|
-
loop{ Process.waitpid }
|
1648
|
-
rescue Errno::ESRCH, Errno::ECHILD
|
1649
|
-
end
|
1650
|
-
end
|
1651
|
-
}
|
1638
|
+
@ui.after_fork_parent
|
1652
1639
|
end
|
1653
1640
|
end
|
1654
1641
|
|
@@ -1774,8 +1761,8 @@ module DEBUGGER__
|
|
1774
1761
|
def sync &b
|
1775
1762
|
info "sync"
|
1776
1763
|
|
1764
|
+
lock
|
1777
1765
|
begin
|
1778
|
-
lock
|
1779
1766
|
b.call if b
|
1780
1767
|
ensure
|
1781
1768
|
unlock
|
@@ -2012,8 +1999,8 @@ module DEBUGGER__
|
|
2012
1999
|
|
2013
2000
|
parent_hook = -> child_pid {
|
2014
2001
|
DEBUGGER__.warn "Detaching after fork from parent process #{Process.pid}"
|
2015
|
-
SESSION.deactivate
|
2016
2002
|
SESSION.after_fork_parent
|
2003
|
+
SESSION.deactivate
|
2017
2004
|
}
|
2018
2005
|
child_hook = -> {
|
2019
2006
|
DEBUGGER__.warn "Attaching after process #{parent_pid} fork to child process #{Process.pid}"
|
@@ -2112,6 +2099,8 @@ module Kernel
|
|
2112
2099
|
loc = caller_locations(up_level, 1).first; ::DEBUGGER__.add_line_breakpoint loc.path, loc.lineno + 1, oneshot: true, command: cmds
|
2113
2100
|
self
|
2114
2101
|
end
|
2102
|
+
|
2103
|
+
alias bb debugger if ENV['RUBY_DEBUG_BB']
|
2115
2104
|
end
|
2116
2105
|
|
2117
2106
|
class Binding
|
data/lib/debug/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Sasada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: irb
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.1.6
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Debugging functionality for Ruby
|