-
Notifications
You must be signed in to change notification settings - Fork 218
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
MIMode "gdb" wrongly assumes the type of Inferior; debugger pause does not work #844
Comments
If my analysis is right (I hope I am wrong), it is a super serious problem. MIEngine might kill a random process Wanted to stress that. |
I think this is related to this issue: microsoft/vscode-cpptools#833. |
@cynecx Yes, it is. Thanks for the pointer. But there is more to it. When gdb is using a gdbserver (local or remote), pause/stop works everywhere now. I am testing my fix right now. Early next week, I hope to do a PR. If I can get cygwin/mingw to work reliably without a gdbserver, then we are golden. Lot of combinations to test :-) The arm-none-eabi-gdb on Windows is actually a mingw compiled executable. |
Is there a reason you are using:
Instead of: The reason this does the wrong thing is that MIEngine doesn't understand that it is doing remote debugging here. |
Hi @gregg-miskelly, not sure where you saw the 4242, but it is true that we use something like that A typical embedded setup looks something like
The first two lines in From what I understand, you either use the When you use the '-target-select' command, I found out that gdb sends a pretty unique response and that is all we have to look for in MIEngine. |
Btw, @gregg-miskelly, a remote target can also be a serial device like COM port or a /dev/ttyX which I don't think you can do using I am finished testing but I'd be thrilled if you can review my changes here... I only had to touch one file, very few changes. I did not have a Linux box, and I am in the process of installing one. |
Using |
I should add, your check is trying to determine exactly the same as
|
@gregg-miskelly, I had initially changed the implementations of
Boy, cygwin is a beast to deal with. I tried so many things to make it behave to no avail. I tried |
…ing gdbservers (#855) * Support local gdb but remote target, testing ongoing: checkpoint * Intermediate checkpoint, untested * Intermediate checkpoint, untested * Implement Pausing MIDebuggerServerAddress & DebugServer instead of 'connected' message * Removed a debug stmt * Be consistent with IsNullOrEmpty vs. the preferred IsNullOrWhiteSpace * Broke up a long line * Fided a defect in IsLocalGdbTarget() from code review. To make it mean same thing as before
@haneefdm this is now in vscode-cpptools version |
Cool. Thanks. |
I meet similar issue on latest extension microsoft/vscode-cpptools#7719 Unable to set breakpoint or pause on a running application with extended-remote connection debug. |
Okay, here is the scenario. Sorry, long
I am using GDB on my Mac (via MIEngine/cpptools) to debug a program/image running on a board connected to my USB/serial port. Pretty much everything works except for one huge thing. I cannot pause a running target. I can pause it using any other tool (Eclipse, gdb command line, even another VSCode extension, etc.). This is the 99.9% use case for embedded/IoT applications where they can't actually afford to have an entire OS/gdb running on the board. When I try to pause, nothing happens. I pretty much have to kill the VSCode Debug session, find and kill the gdb-server and/or gdb itself.
I think I know why this is happening. In MICore/src/Debugger.cs, around line 707, you check to see if it is local gdb and assumes program is local too.
Then there is https://sourceware.org/bugzilla/show_bug.cgi?id=20035.
Well, that is only applicable to gdb executing native prorgrams. In our case, gdb is debugging a quasi-remote program in async mode. It is called "remote serial" or "extended remote serial". The local gdb talks to a gdb-server either using a serial port, local/remote IP address See -target-select doc.
Problem is that gdb-servers can create fake pids and thread-groups if they have to and gdb hasn't got a clue they are fake. Since MIEngine monitors and collects these pids, it tries to send a SIGINT to the debuggee which will never work. Might even kill an innocent process on local machine? :-).
Using the gdb command
info target
When you debug something with gdb, you can figure out what kind of target it is even though gdb and executable are local...With gdb running on my Mac and board connected to a USB port, it shows.
With gdb running a local process on Windows/Cygwin, it will say 'Native process'
Applies to ALL platforms but just for gdb. If you don't see 'Native process', you are debugging something not local. And '-exec interrupt' will work. I have proof. Signaling the Inferior obviously wont work. Unfortunately, I don't have a MI equivalent of
info target
. I just did-exec info target
You send an-exec-interrupt
, gdb says, since I am running remote mode, I will pass it on to the gdb-server and they all report back to MIEngine/VSCode/UserYou want to figure out the target type at the start of the session. There is another way, which is to look at the startup commands. Anyone who is doing this will have to execute '-target-select' command during startup, but there are 2-3 ways of doing it syntax wise. Logic for
IsLocalGdb()
andIsRemoteGdb()
has to be reviewed and how they are used. May need isLocalGdbRemoteTarget() for instance. Lucky, these areinternal/private
all contained in that same file.Let me know if you want my help fixing/testing this. I apologize, if I misread the code in MIEngine.
The text was updated successfully, but these errors were encountered: