ruby / debug

Debugging functionality for Ruby
BSD 2-Clause "Simplified" License
1.14k stars 127 forks source link

`rdbg` without no arguments #1042

Open ko1 opened 11 months ago

ko1 commented 11 months ago

Now rdbg without script waits script from STDIN:

[master]$ exe/rdbg
p 1 # Ctrl-D here to terminate input
# No sourcefile available for -
=>#0    <main> at -:1
(rdbg) n    # next command
1

But I think nobody use this feature so showing help (rdbg -h) seems better.

ko1 commented 11 months ago

STDIN from pipe will not work because Reline needs input.

$ echo p 1 | exe/rdbg
# No sourcefile available for -
=>#0    <main> at -:1
#<Thread:0x00007f42ded32368@DEBUGGER__::SESSION@server /home/ko1/ruby/debug/lib/debug/session.rb:179 run> terminated with exception (report_on_exception is true):
/home/ko1/ruby/install/trunk/lib/ruby/3.3.0+0/reline/ansi.rb:152:in `raw': Inappropriate ioctl for device (Errno::ENOTTY)

BTW remote debugging works fine.

[master]$ echo p 1 | exe/rdbg -O
DEBUGGER: Debugger can attach via UNIX domain socket (/run/user/1000/rdbg-3543)
DEBUGGER: wait for debugger connection...
DEBUGGER: Connected.
1
DEBUGGER: Disconnected.

hmm. can be used by pipe command line tool?

st0012 commented 11 months ago

I agree that showing help is better 👍

dentarg commented 5 months ago

But I think nobody use this feature

I would use it if it worked, to debug Rack/Puma on the fly:

$ echo 'app { |env| require "debug";debugger;[200, {}, ["OK"]] }' | puma --config /dev/stdin --port 0
Puma starting in single mode...
* Puma version: 6.4.2 (ruby 3.2.4-p170) ("The Eagle of Durango")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 60630
* Listening on http://0.0.0.0:51168/
Use Ctrl-C to stop
# No sourcefile available for /dev/stdin
=>#0    block {|env={"rack.version"=>[1, 6], "rack.errors"=>...|} in _load_from at /dev/stdin:1
  #1    Puma::Configuration::ConfigMiddleware#call(env={"rack.version"=>[1, 6], "rack.errors"=>...) at ~/.arm64_rubies/3.2.4/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/configuration.rb:272
  # and 6 frames (use `bt' command for all frames)
▽#<Thread:0x0000000104ce37b8@DEBUGGER__::SESSION@server /Users/dentarg/.arm64_rubies/3.2.4/lib/ruby/gems/3.2.0/gems/debug-1.9.2/lib/debug/session.rb:179 run> terminated with exception (report_on_exception is true):
/Users/dentarg/.arm64_rubies/3.2.4/lib/ruby/gems/3.2.0/gems/reline-0.5.3/lib/reline/ansi.rb:284:in `pread': not opened for reading (IOError)
...