Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve debug log -add remote debuggee backlog #132

Merged
merged 2 commits into from
Jul 6, 2021

Conversation

ono-max
Copy link
Collaborator

@ono-max ono-max commented Jul 6, 2021

Now, logs of remote debugee doesn't show in failure message. This PR fix it.

Example

Failure: test_foo(DEBUGGER__::FooTest):
  TIMEOUT ERROR (10 sec) on UNIX DOMAIN SOCKET mode
  [DEBUGGER SESSION LOG]
  > [1, 9] in /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb
  > =>    1| module Foo
  >       2|   class Bar
  >       3|     def self.a
  >       4|       p "hello"
  >       5|     end
  >       6|   end
  >       7|   Bar.a
  >       8|   bar = Bar.new
  >       9| end
  > =>#0	<main> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:1
  > s
  >
  > (rdbg:remote) s
[1, 9] in /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb
  >       1| module Foo
  > =>    2|   class Bar
  >       3|     def self.a
  >       4|       p "hello"
  >       5|     end
  >       6|   end
  >       7|   Bar.a
  >       8|   bar = Bar.new
  >       9| end
  > =>#0	<module:Foo> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:2
  >   #1	<main> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:1
  >
  > (rdbg:remote) s
[1, 9] in /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb
  >       1| module Foo
  >       2|   class Bar
  > =>    3|     def self.a
  >       4|       p "hello"
  >       5|     end
  >       6|   end
  >       7|   Bar.a
  >       8|   bar = Bar.new
  >       9| end
  > =>#0	<class:Bar> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:3
  >   #1	<module:Foo> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:2
  >   #2	<main> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:1
  >
  > (rdbg:remote) s
[2, 9] in /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb
  >       2|   class Bar
  >       3|     def self.a
  >       4|       p "hello"
  >       5|     end
  >       6|   end
  > =>    7|   Bar.a
  >       8|   bar = Bar.new
  >       9| end
  > =>#0	<module:Foo> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:7
  >   #1	<main> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:1
  > s
  >
  > (rdbg:remote) s
[1, 9] in /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb
  >       1| module Foo
  >       2|   class Bar
  >       3|     def self.a
  > =>    4|       p "hello"
  >       5|     end
  >       6|   end
  >       7|   Bar.a
  >       8|   bar = Bar.new
  >       9| end
  > =>#0	Foo::Bar.a at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:4
  >   #1	<module:Foo> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:7
  >   #2	<main> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:1
  > s
  >
  > (rdbg:remote) s
[1, 9] in /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb
  >       1| module Foo
  >       2|   class Bar
  >       3|     def self.a
  >       4|       p "hello"
  > =>    5|     end
  >       6|   end
  >       7|   Bar.a
  >       8|   bar = Bar.new
  >       9| end
  > =>#0	Foo::Bar.a at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:5 #=> "hello"
  >   #1	<module:Foo> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:7
  >   #2	<main> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:1
  > s
  >
  > (rdbg:remote) s
[3, 9] in /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb
  >       3|     def self.a
  >       4|       p "hello"
  >       5|     end
  >       6|   end
  >       7|   Bar.a
  > =>    8|   bar = Bar.new
  >       9| end
  > =>#0	<module:Foo> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:8
  >   #1	<main> at /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/debugger20210706-45047-efy1kk.rb:1

  [DEBUGGEE SESSION LOG]
  > EBUGGER: Debugger can attach via UNIX domain socket (/Users/naotto/.ruby-debug-sock/ruby-debug-naotto-45078)
  > DEBUGGER: wait for debuger connection...
  > DEBUGGER: Connected.
  > "hello"
   .
  <false> is not true.
/Users/naotto/workspace/debug/test/support/utils.rb:146:in `rescue in block in run_test_scenario'
/Users/naotto/workspace/debug/test/support/utils.rb:141:in `block in run_test_scenario'
/Users/naotto/workspace/debug/test/support/utils.rb:102:in `spawn'
/Users/naotto/workspace/debug/test/support/utils.rb:102:in `run_test_scenario'
/Users/naotto/workspace/debug/test/support/utils.rb:81:in `debug_on_unix_domain_socket'
/Users/naotto/workspace/debug/test/support/utils.rb:44:in `debug_code'
test/debug/foo_test.rb:22:in `test_foo'
     19:     end
     20:
     21:     def test_foo
  => 22:       debug_code(program) do
     23:         type 's'
     24:         type 's'
     25:         type 's'
```shell

@@ -74,21 +89,21 @@ def debug_on_tcpip repl_prompt = '(rdbg:remote)'
end

def setup_remote_debuggee(cmd)
@remote_r, @remote_w, @remote_debuggee_pid = PTY.spawn(cmd, :in=>'/dev/null', :out=>'/dev/null')
@remote_r, @remote_w, @remote_debuggee_pid = PTY.spawn(cmd)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to change this part to output complete backlog(In the above example, this would be "hello") in remote deguggee.

backlog = []
begin
Timeout.timeout(TIMEOUT_SEC) do
while (line = @remote_r.gets)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can raise EIO error, so you need to rescue it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I'll change it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ko1 ko1 merged commit da22e7c into ruby:master Jul 6, 2021
@ono-max ono-max deleted the improve-debug-log branch July 9, 2021 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants