-
Notifications
You must be signed in to change notification settings - Fork 255
feat: gdb SIGINT interrupt mode #1124
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR and the kind words. Hmmm. Could it be that your gdb-server senses that the stdin is interactive because of how it is started and thus only responds to Control-C? Normally, when cortex-debug starts a gdb-server, the gdb-server is a pipe. Programs can tell what kind of stdin they have and adapt their behavior .. albeit inappropriately. But there is one big difference between send GDB a Control-C vs us sending an interrupt request to GDB. Note that we are not requesting this of the server. We are talking to gdb. So, why is gdb not doing the right thing? How do other debugger frontends deal with it? How does NXP's own frontend deal with it? I can't believe they don't support exec-interrups. I have a feeling we are solving the wrong problem. Now, here is the difference. sending gdb Could you point me to some NXP docs for their gdb-server? Is the following correct? https://mcuoneclipse.com/2023/05/14/linkserver-for-microcontrollers/ |
I don't understand what we are doing here, and why/how it is working.
So, how is this working? Sending gdb Or, did you end up pausing gdb and not the FW (program/inferior) itself? I am at a total loss here |
Right, honestly I'm sharing your feeling about fixing symptoms rather than issues - though finally happy to get it working at least "somehow" :). But your point about the missing feedback loop makes sense. There's not much information about their gdb server (gta) available, and the How I understand that it works right now (and I can confirm it's actually interrupting the FW in my setup):
It's probably worth exploring how their own S32DS IDE interacts with the gta server. |
Yup. We need to investigate why it is working. Please look at the debug traces between GDB and the server. You can do the following in GDB
Use that command as part of preLaunchCommands or on the gdb command line or the Debug Console in VSCode or your gdbinit file. You should be familiar with the remote serial protocol (RSP). https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_124.html#SEC129 Whatever is happening via SIGINT, should also be happening Also, why not use other GDB servers that support their probes? I don't like magic. I will end up supporting this and I need to understand the mechanics. I am sure you do too |
I gathered some data with logging enabled: SIGINT interrupt modegdb log from Debug Consolegta server logwiresharkexec-interrupt modegdb log from Debug Console
gta server log
wireshark
SummaryLooks like signaling SIGINT (or Ctrl+C) to gdb emits a "03" to the gdb server. The same behavior can be observed with the S32 Design Studio IDE, no exec-interrupt is used there. With "exec-interrupt" the gdb client does nothing. The gdb client is supplied by NXP with version string Some background research on the '03' packet: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Interrupts.html The probe cannot be used with other servers as gta interfaces with another proprietary tool that finally talks to the probe. Another (generic) probe cannot be used as they lack support for some proprietary cores on the chip in question. |
Thanks. Lets enter the sausage factory for a bit. We need to understand what is going, why and if there other established methods of doing the same. At the start of the session (initial connection between GDB and the server), they negotiate capabilities. GDB queries the server of its capabilities. GDB will behave accordingly based on the responses. Could you capture the first part of the session where a bunch of https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#qSupported There may be QPassSignals/QProgramSignals/qSupported being exchanged. See also Shoould we have used one of these remote settings where gdb could translate an exec-interrupt to the appropriate thing for this server. I have a feeling that the authors of the gdb-server have not fully advertised their capabilities. It would be interesting to see what happens on a server where exec-interrupt actually works. If you are thinking 'why do I have to do this because I already implemented the SIGINT?` -- it is because both of us should understand why we are doing this and was there a better way. |
Yes, I know about the Ctrl-C packet (interrupt event packet). See All servers support it I am sure. Question is why GDB is not translating an |
I don't think this is true. Whether the target/server support non-stop mode or not, exec-interrupt is expressly allowed while target is running. Most other commands that require examining the target are not allowed. And, most servers do not support non-stop mode and even if they do, not very well.
But, we are not talking about the probe here. We are concerned about why gdb is not sending an interrupt packet like it does for all other servers. I looked at non-stop mode and decided it is highly unreliable or unsupported by almost all the servers. See section 20.5 below https://openocd.org/doc/html/GDB-and-OpenOCD.html
But why, though? Why does it do it for everyone else? |
Our messages are getting crossed :-). As I am typing a message, you sent additional messages and vice versa :-) |
This is true of most gdb servers. It is not actually an The whole GDB RSP is designed so it could truly be used "remotely". I remember brining up linux like kernels and this is all we had. Even today, that is true. |
I will go silent on this issue for a day. Will give you some time to investigate. I have to attend to other things in the meantime. |
This is the data exchanged during client and server at start:
|
We use a NXP S32 Debug Probe together with the provided gdb server. I configured your (awesome) extension on "external" mode, but the (funky) server does not react to "exec-interrupt" commands. To get it working, I added functionality to send a
SIGINT
signal to the gdb process instead - and thought maybe others might be interested in this addition as well.This PR:
gdbInterruptMode
to launch props, default isexec-interrupt
== current stock behavior, new optionSIGINT