-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add option to attach to a running process #3
Comments
'Attach' type is not supported by the extension yet. Thank you for the feature request. |
@OlegKunitsyn as @brunopacheco1 works on the field display and accept, may I suggest that you have a look at
As soon as these things are done I really would say the "beta" part can be removed and a version bump to 1.0 (or something near) be done. |
Yes, this feature request is important (as well as Mac support and strange warnings in Docker), despite the fact that I focus on standard continuous integration. |
Hallo. So I've been playing around on this issue, and by the GDB documentation and some samples online, attaching to a running process should be simple, it should. 😄 MI has a command The initial PID was 3009, but then it changes to 3026. I believe I'm doing something wrong or missing a couple of configurations. If some of you have a clue about that, it will be quite helpful. |
As I suspected, I was doing something wrong. So basically the debugger was attaching to a running process and executing the command Fixing this the debugger is capable to attach correctly! 🎉 But unfortunately, life is not a colorful paradise full of unicorns. The solution for getting display value executing I kinda liked separated terminals, but I'll have to figure out how to print to the debugger terminal instead. Or come up with another solution for getting cob field display value. |
Sounds like both "yay" and "nooo" :-) |
Everything is running in the same local environment, but yes I'm running gdb and the running process on a WSL2. I may try directly on the Windows. Let's see. My guess is it should behave in the same way. |
I especially meant to try on GNU/Linux native ;-) |
Well, you are right as the attaching to a running process feature is not related to displaying the variables, it just brought up a problem that soon or later would be raised. |
I was testing on Docker and it doesn't work out of the box. There's an option to allow the VM to see the host process tree, but it didn't help as supposed. I'm not sure if we should tackle this right now. EDIT: I meant if we should tackle attaching to a running process from Docker. In a native environment, we could keep going. |
Hm, if it is not working in most environments then it may not be that useful. Do you know if it works on GNU/Linux native already? |
I didn't try, but if WSL2 is really a VM, I would say it should work, but we cannot relly on assumptions. Perhaps @OlegKunitsyn can check that. |
May I suggest to PR your current changes and just not describe the attach part or (possibly better) add a note next to it, that it is experimental and works in a very limited scope + at this issue as reference). I'll test in GNU/Linux and Win32 native as soon as it is available in a (testing) release. |
Of course. Can you make the branch? |
I've created a boilerplate of attach/detach. On my Ubuntu I see the error |
That itself is a common no-issue; the part of the log says:
The message mainly says: "Hey I'm GDB and now reached a place where you could go on - but I don't have the sources for this available". I guess you've started a GnuCOBOL program outside of vscode before and tried to use its pid, correct? Can you attach with plain GDB? |
I create a PR that should by-pass this error message, forcing the extension to continue whenever a |
Thanks for #49! |
Thanks for sharing this native-debug extension. Pretty much the attach mechanism is the same. Anyway, for some unknown reason, attaching to a PID is not working correctly in this new branch, I keep receiving a GDB warning saying the break-point couldn't be inserted. I believe this is a minor issue, I'll keep investigating. |
It looks like it was a concurrency issue, once So, basically the status is exactly the same as I've got previously (besides proper VSCode action buttons). The variable panel is not working due to missing custom cob_field eval MI events. |
Same to me - I can't test attach yet. I've pushed minor conflicting changes. Please take a look, then we could merge to the master. This is beta! :) |
* #3 - Adding support to attach to a running process * #3 - Removing leftover from README. * #3 - Fixing attach to a running process * #3 - Adding Experimental info on README * Rollback of a wrong change. * #44 - Removing leading zeroes from variable values * #3 - separating target-attach from other commands fixed break-point insertion.
@OlegKunitsyn Answering your question in the PR thread, I moved the But checking out the extension @GitMensch has shared WebFreak001/code-debug, it looks it should work as you've done before without delays. So, I believe either there is something wrong in the current implementation or it doesn't work as expected in a WSL2 VM. I'll do the following, I will test the code-debug extension and see the |
Confirmed. I see variables as well. Thank you! Shall I merge and release? |
I believe yes, and perhaps not as experimental, WDYT?
Sent from Yahoo Mail for iPhone
On Friday, June 26, 2020, 7:28 AM, OlegKunitsyn <notifications@github.com> wrote:
BTW, it is working after merging master to the attach branch, where there is not cob_display function.
Confirmed. I see variables as well. Thank you! Shall I merge and release?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Does this already include the option for remote debugging or attaching to a local process only? |
Attach to a local process only. I didn't go further as we were blocked by the calling cob_display issue. Should we implement that first before merging or can we track remote debugging on another issue? |
Merge and release is reasonable at any time. Additional it would be good to tackle the remote debugging independent to the cob_display issue. |
* Sketched up the structure of attach/detach * Merging differences between branches (#49) * #3 - Adding support to attach to a running process * #3 - Removing leftover from README. * #3 - Fixing attach to a running process * #3 - Adding Experimental info on README * Rollback of a wrong change. * #44 - Removing leading zeroes from variable values * Makeup * attach running process (#51) * #3 - Adding support to attach to a running process * #3 - Removing leftover from README. * #3 - Fixing attach to a running process * #3 - Adding Experimental info on README * Rollback of a wrong change. * #44 - Removing leading zeroes from variable values * #3 - separating target-attach from other commands fixed break-point insertion. * Removed Beta mark in favor of EXPERIMENTAL * Added missing code * Create executable to attach by default * Removed experimental mark Co-authored-by: Bruno Pacheco <brunopacheco1@yahoo.com>
@GitMensch Were you expecting something specific when you requested this feature? I mean, I just committed some changes to enable the extension to attach to a gdbserver, but I believe this connection is pretty basic (comparing to remote debugging on code-debug. I added a |
Support of tunneling through ssh is nice (and very likely something needed in some COBOL environments where everything is closed but still accessible via ssh with a specific user/key from a specific ip address (range). [Yes, I do have something very specific in mind ;-)] |
Yes, it is working and so far what I did was the following:
And voilà, everything worked without surprises. But the server needs the executable and the gdbserver to have a debuggable running process. And the developer machine needs the source code and the GC, to compile COBOL to C and prepare the source map (line and variable names), for breakpoints insertions and watch the variables, and GDB to connect to the remote debugger. A Wiki would be nice. @OlegKunitsyn Could we add it to Github? Not sure if it is possible and how.
Sure, I will take a look at the code-debug extension, to understand what is needed to enable SSH. |
Wiki is enabled now. |
... so I've tried it and after 10 minutes found that remoteDebugger is not yet released... ... at least I have gdbserver running, attaching to the process, and a local gdb instance attaching to this, both via port and via stdio pipes and also adjusted the source path to the place where the generated .c files are stored. |
@brunopacheco1 said
That is very useful, if this works out you'd only need a ssh connection (and a client, but even Win10 comes with an openssh client/server now) as the complete debugging is done only on the server side this way (no local gdb on the client and no gdbserver on the ... server needed, only the server will have a gdb which then obviously also matches the target environment). Using an approach like this will allow to debug from vscode under Win10 to a remote GNU/Linux machine. |
I was checking the native-code-debug extension and it looks quite complete and powerful, as it allows to execute or attach to a process through an SSH connection, forwarding the remote X11 IO and much more, but for this initial purpose I think this is too much (as we say in Rio, it's using a cannon to kill an ant). Basically, my idea was just to do the ssh port tunneling, forwarding the remote What do you think? It would keep things simple and it would add tons of extra possibilities (and issues). |
I tried running everything manually just to see if the gdbserver connection works and by the log below it looks promising. I've got an error when trying to insert the breakpoint, but every other command had the output as expected. |
I found the issue. It was a compilation problem, I didn't pay attention on GC version and I recompiled the code in the remote machine, but once I uploaded the locally compiled executable the attaching using an ssh tunnel worked properly. I'm going further with this solution then if you think it's reasonable. |
Hm. as you want to remote debug it would be more reasonable to use both GC and its configured C compiler on the remote machine - then copying the results to the local machine (= the other way around). ... which is the reason that "doing everything over ssh as native-debug does it" is the "better" solution (it actually is good to have both remote options). |
This was the working log, BTW. The connection to a micro instance on Google Cloud is quite slow, and I've got a warning about slowness when transferring files from remote. |
Ah, I got it. Well, when I thought about remote debugging, the first thing that came to my mind was connecting directly to a running program on production, therefore connecting through an ssh tunnel. |
In the way you've mentioned, for me sounds more like coding remotely, something similar to using WSL1/2 for coding on a Windows machine. |
@GitMensch Is this what you meant? |
With using gdbserver, which was the first thing that came to my mind it is something like this, but the local GDB must have access to the binary and the sources and it must have one of the targets (I guess gdb supports multiple ones) that the local server uses, and the local gdb must be able to connect to the gdbserver. This connection can be part of a tunnel (SSH/VPN/...).
Yes, that's what it is, just without the proprietary extensions that are in WS1 and WSL2 to allow it - and actually it would allow debugging within WS1/WSL2 from VSCodium, too, which is another bonus :-) Both are reasonable but the second seems to be the more "attractive" one. |
Okay, so everything is clear now. If you don't mind, I would prefer splitting this two options into two different issues. I believe connecting to a gdbserver is related to this issue so I'll finish this ssh tunneling feature, and later on (after setting variables perhaps), I could tackle that. BTW, could you open the new issue? |
* #44 - Removing leading zeroes from variable values * #44 - Removing leading zeroes from variable values * #3 - Attaching to a remote gdbserver * #3 - Adding extra initial configuration for remote debugging * #59 - Supporting different USAGE cases * #59 - Replacing the cob_field_string function if it doesnt exist * #59 - Adding call to cob_put_field_str when it is available
I believe this issue can be closed. Any extra support can be tracked by a new issue. |
@brunopacheco1 Can you recheck what the issue is and open a new one for that? I have the following working with plain gdb:
Note: the sources are actually not writable on the client side. This works fine in plain gdb. Using the remote option of the last release (no idea if it uses
So we likely need also a way to specify the folder of the C sources? |
We currently have the dependencies listed, it would be nice to have a sample launch configuration to debug and to attach (ideally with input variable);
Bonus points (should maybe tracked in a different issue) for documentation how to setup remote debugging :-)
The text was updated successfully, but these errors were encountered: