-
Notifications
You must be signed in to change notification settings - Fork 126
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,24 @@ def type(command) | |
end | ||
|
||
def create_message fail_msg | ||
"#{fail_msg} on #{@mode} mode\n[DEBUG SESSION LOG]\n> " + @backlog.join('> ') | ||
"#{fail_msg} on #{@mode} mode\n[DEBUGGER SESSION LOG]\n> #{@backlog.join('> ')}#{debuggee_backlog}" | ||
end | ||
|
||
def debuggee_backlog | ||
return if @mode == 'LOCAL' | ||
|
||
backlog = [] | ||
begin | ||
Timeout.timeout(TIMEOUT_SEC) do | ||
while (line = @remote_r.gets) | ||
backlog << line | ||
end | ||
end | ||
rescue Timeout::Error, Errno::EIO | ||
# result of `gets` return Errno::EIO in some platform | ||
# https://github.com/ruby/ruby/blob/master/ext/pty/pty.c#L729-L736 | ||
end | ||
"\n[DEBUGGEE SESSION LOG]\n> #{backlog.join('> ')}" | ||
end | ||
|
||
# This method will execute both local and remote mode by default. | ||
|
@@ -74,21 +91,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
@remote_r.read(1) # wait for the remote server to boot up | ||
end | ||
|
||
TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 10).to_i | ||
|
||
def run_test_scenario(cmd, repl_prompt) | ||
@queue = Queue.new | ||
@scenario.call | ||
|
||
timeout_sec = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 10).to_i | ||
|
||
PTY.spawn(cmd) do |read, write, pid| | ||
@backlog = [] | ||
@last_backlog = [] | ||
begin | ||
Timeout.timeout(timeout_sec) do | ||
Timeout.timeout(TIMEOUT_SEC) do | ||
while (line = read.gets) | ||
debug_print line | ||
case line.chomp | ||
|
@@ -124,7 +141,7 @@ def run_test_scenario(cmd, repl_prompt) | |
# https://github.com/ruby/ruby/blob/master/ext/pty/pty.c#L729-L736 | ||
assert_empty_queue(exception: e) | ||
rescue Timeout::Error => e | ||
assert false, create_message("TIMEOUT ERROR (#{timeout_sec} sec)") | ||
assert false, create_message("TIMEOUT ERROR (#{TIMEOUT_SEC} sec)") | ||
ensure | ||
# kill remote debuggee | ||
if defined?(@remote_debuggee_pid) && @remote_debuggee_pid | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ruby/debug/pull/132/files#diff-ee14bf65f14927f7778a246f90c5cec0c581be3e2658c2a8a3726c59db5be3f9R27