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

Love for remote debugging #406

Merged
merged 27 commits into from
Jan 25, 2018
Merged

Love for remote debugging #406

merged 27 commits into from
Jan 25, 2018

Conversation

deivid-rodriguez
Copy link
Owner

@deivid-rodriguez deivid-rodriguez commented Dec 31, 2017

Fixes #82.
Fixes #141.
Fixes #239.
Fixes #274.
Fixes #302.

@deivid-rodriguez deivid-rodriguez force-pushed the fix/remote_debugging branch 7 times, most recently from ebeea6a to 182828f Compare January 4, 2018 21:13
@deivid-rodriguez
Copy link
Owner Author

Summoning @MSP-Greg in case you're interested. I've been working on remote debugging support. Not ready yet but looking good. However, I'm getting some failures on Windows and I don't have a Windows machine to debug. In case you would like to help out, I suspect it's something around setting binary mode in streams, but not sure. Regards!

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 4, 2018

@deivid-rodriguez

I'll have a look at it, might not be able to seriously do so until Saturday... Thanks, Greg

@deivid-rodriguez
Copy link
Owner Author

That's great, thanks so much!

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 5, 2018

@deivid-rodriguez

Solution found. See commit in my fork, Appveyor results

Probably not what you (or I) expected. Hope this helps, Greg

EDIT:

  1. I didn't remove the Binmode? commit, I doubt it's required, and (as I recall) it may change the line separator. My test was done with it. Also, the two 'forking' tests I may look at using a Thread, so they'll (maybe) work on Windows.

  2. Unrelated - if you have a minute, you might want to have a look at Ruby Issue 14276. I thought about throwing in my thoughts, but yours would be much better...

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 5, 2018

Added another patch to swap the fork for Thread. See commit in my fork. Appveyor results.

Appveyor runs with dual cores, Travis has four. The sleep(windows? ? 2 : 1) line may need windows increased to 2.5 or 3, not sure. The first build I ran stopped with a very strange log, second build passed...

@deivid-rodriguez
Copy link
Owner Author

@MSP-Greg Thanks so much! Your fix makes a lot of sense since only byebug's executable sets up the LOAD_PATH but it can't be used directly on Windows!

Also thanks for letting me know about the ruby-core issue, I commented in there! And also thanks for fixing those tests to not use fork.

I'll either give you access to this branch to add your changes, or cherry-pick them myself!

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 5, 2018

@deivid-rodriguez

Also thanks for letting me know about the ruby-core issue, I commented in there!

Thank you. I keep an eye on it (and the ruby-core Travis & Appveyor), and I knew you could address the issue(s) well.

I'm also sensitive to issues that involve trunk, If someone is concerned about a given repo/gem functioning with trunk, they're welcome to fork and run their own CI, since many 'mature' repos/gems may not have frequent commits...

I'll either give you access to this branch to add your changes, or cherry-pick them myself!

Whatever is easiest.

Finally, I reverted 'Binmode?' with two commits, both passed.

Thanks, Greg

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 5, 2018

@deivid-rodriguez

Would you prefer that I delete or revert the Binmode? commit (since it is the last one)?

@deivid-rodriguez
Copy link
Owner Author

Delete 👍

@MSP-Greg MSP-Greg force-pushed the fix/remote_debugging branch 2 times, most recently from b9239e7 to 7bddb3e Compare January 5, 2018 19:54
@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 5, 2018

Sometimes Appveyor... Had this issue last night, where I changed sleep 1 to sleep(windows? ? 2 : 1).

Just upped it to 3, no change. I'm going to check/fix it on my fork. I must be missing something....

FYI - from all my testing on Appveyor (100's of trunk builds, rubygems builds, etc), I've seen lots of intermittent issues...

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 6, 2018

@deivid-rodriguez

I found what the issue was with my fork passing the one test. I dl'd a diff of the fork, and (oddly) one line was different. I even checked my browser history, and timestamps matched, so it was what GitHub had. The line def write_program(code) was changed to def write_program(program).

Anyway, fixed that, I think I've got this working, just a few minutes more. The change is to RemoteInterface#readline

to this:

def readline(prompt)
  puts(prompt)

  result = (input.gets || "continue")
  result.chomp
rescue Errno::EPIPE, Errno::ECONNABORTED
  "continue"
end

Errno::EPIPE is raised by trunk, Errno::ECONNABORTED is raised by 2.4 and lower.

Thoughts? trying on my fork shortly... Thanks, Greg

@deivid-rodriguez
Copy link
Owner Author

deivid-rodriguez commented Jan 6, 2018

I found what the issue was with my fork passing the one test. I dl'd a diff of the fork, and (oddly) one line was different. I even checked my browser history, and timestamps matched, so it was what GitHub had. The line def write_program(code) was changed to def write_program(program).

Yeah, sorry! I realized that was incorrect and fixed it here, leaving your fork out of date indeed. Feel free to just work on this same branch instead of your fork, I'll be carefull with force-pushing :)

Your fix looks good, but I think the rescue should be moved up to the confirm and read_command methods (which internally call readline), similarly to puts and print. Otherwise I think the exception could be raised outside of the rescue block you're adding. What do you think?

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 6, 2018

Yeah, sorry!

That was before I got changed to 'collaborator', so I grabbed the changes and was working just in my fork in a different new branch. IOW, no problem.

I'll be carefull with force-pushing :)

I do that alot also. I'll try to restrict it to things I do before I push here.

I think the rescue should be moved up to the confirm and read_command methods (which internally call readline), similarly to puts and print. Otherwise I think the exception could be raised outside of the rescue block you're adding. What do you think?

Well, it (as listed) just passed on my fork with Appveyor. The commit is here.

I haven't reviewed the remote code enough to know if a particular error should trigger a 'is the client dead?' check,..

Lastly, can we please remove the 'stop on failure' from Appveyor? I normally do all of my work with trunk. I was passing locally, pushed to Appveyor, and the build stopped on 2.3 (which lead to my adding Errno::ECONNABORTED). I've done a lot of AV (Appveyor) testing,and there have been times where local passed and AV failed. Usually timing/resource issues...

@deivid-rodriguez
Copy link
Owner Author

Well, it (as listed) just passed on my fork with Appveyor. The commit is here.

Yeah, we can't know where the exception will be raised, and most of the times it will happen under the rescue block, but my alternative should be safer I think.

Lastly, can we please remove the 'stop on failure' from Appveyor? I normally do all of my work with trunk. I was passing locally, pushed to Appveyor, and the build stopped on 2.3 (which lead to my adding Errno::ECONNABORTED).

Ok, since you are the only one here working on Windows, let's do whatever works best for you :)

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 6, 2018

Yeah, we can't know where the exception will be raised, and most of the times it will happen under the rescue block, but my alternative should be safer I think.

I'll defer to you. I'm just starting at the tests and moving inward. You know the whole thing.

Changed. Test passed. Commit is here. I changed the readline code to remove the result variable. Old habit, I prefer to never use local variables if not needed, because 6 months from now, I'd feel a need to double check if result was an attribute I'd forgotten about. I think that made sense....

Let me know if it's good, and I'll push it. then I'll move on to #416...

@deivid-rodriguez
Copy link
Owner Author

Changed. Test passed. Commit is here.

Yep, that's what I meant. However, the confirm part should probably default to false, not "continue" since super returns a boolean. That said, that part is untested at the moment, so you can just leave it alone for now. So I'd say no change at all there, or rescue and return false, up to you!

I changed the readline code to remove the result variable. Old habit, I prefer to never use local variables if not needed, because 6 months from now, I'd feel a need to double check if result was an attribute I'd forgotten about. I think that made sense..

Mmmm, not sure. I think local variables have preference over attributes, if you were to set an attribute, you'd have to do self.result =, I think? The new code is more concise but unnecessarily chomps "continue". So I'm "meh" on the change, but let's do it if you prefer it that way.

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 6, 2018

rescue and return false, up to you!

Sorry I missed that. Changed.

unnecessarily chomps "continue".

Can't chomp nil though...

Pushing shortly. Thanks.

@deivid-rodriguez
Copy link
Owner Author

Sorry I missed that. Changed.

👍

unnecessarily chomps "continue".

Can't chomp nil though...

I mean that, correctly but unnecessarily, calls "continue".chomp (which returns "continue" again) when input.gets is nil. I do like its simplicity though, let's do it! 👍

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Jan 6, 2018

Cool. Sorry, I meant that input.gets.chomp || "continue" could error.

Thanks for cancelling Appveyor...

@deivid-rodriguez
Copy link
Owner Author

deivid-rodriguez commented Jan 6, 2018

Cool. Sorry, I meant that input.gets.chomp || "continue" could error.

Yup, that could fail. It was your way or mine, yours works :)

Thanks for cancelling Appveyor...

No problem.

I'll give this a final look tomorrow, hopefully I can add coverage for a couple more cases!


def print(message)
super(message)
rescue Errno::EPIPE
Copy link
Owner Author

Choose a reason for hiding this comment

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

@MSP-Greg Should we rescue Errno::ECONNABORTED here and in puts as well? You were seeing that exception on Windows, but only under some versions if I recall correctly?

Copy link
Collaborator

@MSP-Greg MSP-Greg Jan 13, 2018

Choose a reason for hiding this comment

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

I don't recall, I'll have to check.

EDIT: I can't find anything re Errno::ECONNABORTED, and I looked thru all the AV builds, both here and my fork. Can't see how it would hurt, especially with a remote.

Totally different subject, the exe/byebug script can be run under windows with another file, but ideally the file contents (one line) should be dependent on whether the gem is installed normally or with a user-install option. Somewhat ties into a PR/issue open in Rubygems right now...

Copy link
Owner Author

Choose a reason for hiding this comment

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

You mentioned it here. I think I'll add Errno::ECONNABORTED in the other methods as well then.

Re exe/byebug, feel free to suggest any changes you want in a separate PR!

Copy link
Collaborator

@MSP-Greg MSP-Greg Jan 13, 2018

Choose a reason for hiding this comment

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

You mentioned it here.

Sorry, rather distracted with 'non code' things yesterday evening.

Travis has had large Linux & MacOS backlogs recently (separate occasions). Hope they get it sorted out...

@deivid-rodriguez
Copy link
Owner Author

I'll merge this as soon as CI passes! I added a small question / comment but we could merge without it.

@deivid-rodriguez
Copy link
Owner Author

Let's do this!

@deivid-rodriguez deivid-rodriguez merged commit 1765497 into master Jan 25, 2018
@deivid-rodriguez deivid-rodriguez deleted the fix/remote_debugging branch January 25, 2018 00:54
yui-knk added a commit to yui-knk/byebug that referenced this pull request Dec 8, 2018
This test case was introduced as a regression test of
deivid-rodriguez#274
in deivid-rodriguez#406.

The description of issues/274 says an exception will be raised
if the byebug CLI is terminated when main program is sleeping.

Before this commit there are 2 breakpoints (`byebug` method call)
before `sleep 3` and `"cont"` is called once because the arugment of
`remote_debug_connect_and_interrupt` is `"cont"`.
I think this is not intended.

And the method name of test case is `program_with_two_breakpoints`,
on the other hand the program had 3 breakpoints (`byebug`).
deivid-rodriguez pushed a commit that referenced this pull request Dec 8, 2018
This test case was introduced as a regression test of
#274
in #406.

The description of issues/274 says an exception will be raised
if the byebug CLI is terminated when main program is sleeping.

Before this commit there are 2 breakpoints (`byebug` method call)
before `sleep 3` and `"cont"` is called once because the arugment of
`remote_debug_connect_and_interrupt` is `"cont"`.
I think this is not intended.

And the method name of test case is `program_with_two_breakpoints`,
on the other hand the program had 3 breakpoints (`byebug`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants