debug 1.2.1 → 1.2.4

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: 556965976e9db176b06e1997eb167cf5538ccd301ddb497ae629cfda01062fa3
4
- data.tar.gz: e709e60ef9b43b44a998362347b2b8d7e3d4cbddb4831cd43156d5ddc67dead8
3
+ metadata.gz: a6251dbcd2eb75a8b4932a740fe0294da996c7bcaaaa965f42353144786b5c0a
4
+ data.tar.gz: 328c4949a62eeb5277d8d6882c1a7da565b2c5aaa4c2fc5cf52850ca7e454240
5
5
  SHA512:
6
- metadata.gz: 9169efb00f3f9cebb0f9f21d2773e29d4c67edd7a4bb0b7330664080a15972cfe43199ae3c43e86424b2a6f94b83ce1fb8be1c208149cdd04f28c12f5d9f2842
7
- data.tar.gz: a56d82fb5beb82cd821639ae073d8f902aafbdfc762236ea6eb0b2d391cc1e121e541d16083b6b22ae5a8c73b2c2c2e49e54c39f37ac9d4c03d38210499398c8
6
+ metadata.gz: 7c8c83768d7d9eca50f18018dc9255a54234ee9c048d9885d54d46399e7bf9910ca87f85a9cd804108ec319ec985095016b00b1ab0d45a787fb55ef96b2a9483
7
+ data.tar.gz: 24c87a5fbef8a8c1851ffea1b21c53613389d0c8fa46a3a205562aa2c98f6515ad863e97a5ee8857914a0363110ef277bc961b8d04902b0a5f537f133f6f18af
data/Rakefile CHANGED
@@ -7,14 +7,17 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList["test/**/*_test.rb"]
8
8
  end
9
9
 
10
- require "rake/extensiontask"
11
-
12
- task :build => :compile
13
-
14
- Rake::ExtensionTask.new("debug") do |ext|
15
- ext.lib_dir = "lib/debug"
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
 
20
+
18
21
  task :default => [:clobber, :compile, 'README.md', :test]
19
22
 
20
23
  file 'README.md' => ['lib/debug/session.rb', 'lib/debug/config.rb',
@@ -437,7 +437,7 @@ module DEBUGGER__
437
437
  end
438
438
  end
439
439
 
440
- rescue ArgumentError => e
440
+ rescue ArgumentError
441
441
  raise if retried
442
442
  retried = true
443
443
 
@@ -458,7 +458,7 @@ module DEBUGGER__
458
458
  @override_method = true if @method
459
459
  retry
460
460
  end
461
- rescue Exception => e
461
+ rescue Exception
462
462
  raise unless added
463
463
  end
464
464
 
data/lib/debug/client.rb CHANGED
@@ -13,9 +13,37 @@ module DEBUGGER__
13
13
  class CommandLineOptionError < Exception; end
14
14
 
15
15
  class Client
16
- def initialize argv
17
- return util(argv) if String === argv
16
+ class << self
17
+ def util name
18
+ case name
19
+ when 'gen-sockpath'
20
+ puts DEBUGGER__.create_unix_domain_socket_name
21
+ when 'list-socks'
22
+ cleanup_unix_domain_sockets
23
+ puts list_connections
24
+ else
25
+ raise "Unknown utility: #{name}"
26
+ end
27
+ end
18
28
 
29
+ def cleanup_unix_domain_sockets
30
+ Dir.glob(DEBUGGER__.create_unix_domain_socket_name_prefix + '*') do |file|
31
+ if /(\d+)$/ =~ file
32
+ begin
33
+ Process.kill(0, $1.to_i)
34
+ rescue Errno::ESRCH
35
+ File.unlink(file)
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ def list_connections
42
+ Dir.glob(DEBUGGER__.create_unix_domain_socket_name_prefix + '*')
43
+ end
44
+ end
45
+
46
+ def initialize argv
19
47
  @console = Console.new
20
48
 
21
49
  case argv.size
@@ -48,34 +76,6 @@ module DEBUGGER__
48
76
  @console.readline "(rdbg:remote) "
49
77
  end
50
78
 
51
- def util name
52
- case name
53
- when 'gen-sockpath'
54
- puts DEBUGGER__.create_unix_domain_socket_name
55
- when 'list-socks'
56
- cleanup_unix_domain_sockets
57
- puts list_connections
58
- else
59
- raise "Unknown utility: #{name}"
60
- end
61
- end
62
-
63
- def cleanup_unix_domain_sockets
64
- Dir.glob(DEBUGGER__.create_unix_domain_socket_name_prefix + '*') do |file|
65
- if /(\d+)$/ =~ file
66
- begin
67
- Process.kill(0, $1.to_i)
68
- rescue Errno::ESRCH
69
- File.unlink(file)
70
- end
71
- end
72
- end
73
- end
74
-
75
- def list_connections
76
- Dir.glob(DEBUGGER__.create_unix_domain_socket_name_prefix + '*')
77
- end
78
-
79
79
  def connect_unix name = nil
80
80
  if name
81
81
  if File.exist? name
@@ -84,8 +84,9 @@ module DEBUGGER__
84
84
  @s = Socket.unix(File.join(DEBUGGER__.unix_domain_socket_dir, name))
85
85
  end
86
86
  else
87
- cleanup_unix_domain_sockets
88
- files = list_connections
87
+ Client.cleanup_unix_domain_sockets
88
+ files = Client.list_connections
89
+
89
90
  case files.size
90
91
  when 0
91
92
  $stderr.puts "No debug session is available."
data/lib/debug/config.rb CHANGED
@@ -313,7 +313,7 @@ module DEBUGGER__
313
313
 
314
314
  o.on('--util=NAME', 'Utility mode (used by tools)') do |name|
315
315
  require_relative 'client'
316
- Client.new(name)
316
+ Client.util(name)
317
317
  exit
318
318
  end
319
319
 
@@ -352,9 +352,26 @@ module DEBUGGER__
352
352
  ## Unix domain socket configuration
353
353
 
354
354
  def self.unix_domain_socket_dir
355
+ require 'tmpdir'
356
+
355
357
  case
356
358
  when path = CONFIG[:sock_dir]
357
359
  when path = ENV['XDG_RUNTIME_DIR']
360
+ when tmpdir = Dir.tmpdir
361
+ path = File.join(tmpdir, "ruby-debug-sock-#{Process.uid}")
362
+
363
+ if File.exist?(path)
364
+ fs = File.stat(path)
365
+ unless (dir_uid = fs.uid) == (uid = Process.uid)
366
+ raise "#{path} uid is #{dir_uid}, but Process.uid is #{uid}"
367
+ end
368
+ unless (dir_mode = fs.mode) == 040700 # 4: dir, 7:rwx
369
+ raise "#{path}'s mode is #{dir_mode.to_s(8)} (should be 040700)"
370
+ end
371
+ else
372
+ d = Dir.mktmpdir
373
+ File.rename(d, path)
374
+ end
358
375
  when home = ENV['HOME']
359
376
  path = File.join(home, '.ruby-debug-sock')
360
377
 
@@ -9,10 +9,10 @@ module DEBUGGER__
9
9
  )
10
10
 
11
11
  # extend FrameInfo with debug.so
12
- if File.exist? File.join(__dir__, 'debug.so')
12
+ begin
13
13
  require_relative 'debug.so'
14
- else
15
- require_relative 'debug'
14
+ rescue LoadError
15
+ require 'debug/debug.so'
16
16
  end
17
17
 
18
18
  class FrameInfo
data/lib/debug/session.rb CHANGED
@@ -25,6 +25,7 @@ require_relative 'tracer'
25
25
 
26
26
  # To prevent loading old lib/debug.rb in Ruby 2.6 to 3.0
27
27
  $LOADED_FEATURES << 'debug.rb'
28
+ $LOADED_FEATURES << File.expand_path(File.join(__dir__, '..', 'debug.rb'))
28
29
  require 'debug' # invalidate the $LOADED_FEATURE cache
29
30
 
30
31
  require 'json' if ENV['RUBY_DEBUG_TEST_MODE']
data/lib/debug/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DEBUGGER__
4
- VERSION = "1.2.1"
4
+ VERSION = "1.2.4"
5
5
  end
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.2.1
4
+ version: 1.2.4
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-09-30 00:00:00.000000000 Z
11
+ date: 2021-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: irb
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.1.6
112
+ rubygems_version: 3.3.0.dev
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Debugging functionality for Ruby