debug 1.2.2 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7831c2e401b4bf33ecd14f5cef5eeb1c1a0feb57037a162c00f6cc780975b4c6
4
- data.tar.gz: 182d55e56b662858b04e03336dd8bb4d0e15da8418b3aea137d05dcd02aa4ac0
3
+ metadata.gz: a6251dbcd2eb75a8b4932a740fe0294da996c7bcaaaa965f42353144786b5c0a
4
+ data.tar.gz: 328c4949a62eeb5277d8d6882c1a7da565b2c5aaa4c2fc5cf52850ca7e454240
5
5
  SHA512:
6
- metadata.gz: dcf9f62fc4cf7f782238cd7b61137bde035047f6226eeac6cae639b28ada181862ee82ce146a1e33c6c08d80a8fc35ffe4a2cf24eda576e4792babbf8436ca88
7
- data.tar.gz: 1f66b3c18a14f1f337d010a8e9d29d6a0e0b1c4c92c976a87e0c2db265ff6a1259d31918e4c10525d16154f6a8f9fa694bcdbebbb081278b6ee488ae122f8713
6
+ metadata.gz: 7c8c83768d7d9eca50f18018dc9255a54234ee9c048d9885d54d46399e7bf9910ca87f85a9cd804108ec319ec985095016b00b1ab0d45a787fb55ef96b2a9483
7
+ data.tar.gz: 24c87a5fbef8a8c1851ffea1b21c53613389d0c8fa46a3a205562aa2c98f6515ad863e97a5ee8857914a0363110ef277bc961b8d04902b0a5f537f133f6f18af
@@ -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
 
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.2"
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.2
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-01 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
@@ -94,7 +94,7 @@ licenses:
94
94
  metadata:
95
95
  homepage_uri: https://github.com/ruby/debug
96
96
  source_code_uri: https://github.com/ruby/debug
97
- post_install_message:
97
+ post_install_message:
98
98
  rdoc_options: []
99
99
  require_paths:
100
100
  - lib
@@ -109,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.2.15
113
- signing_key:
112
+ rubygems_version: 3.3.0.dev
113
+ signing_key:
114
114
  specification_version: 4
115
115
  summary: Debugging functionality for Ruby
116
116
  test_files: []