-
Notifications
You must be signed in to change notification settings - Fork 253
GDB server gets killed too early on debug stop, causing the target to halt #1122
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
Comments
pyocd should behave itself. Putting a 10second delay is not acceptable. It will affect restarts and in general a super bad idea. Even the one second is not normal but there are servers that do not respect a request for a graceful shutdown. We asked the server to disconnect nicely, so it should do that. This used to happen with OpenOCD a long time ago. Now, it doesn't. It also prevents the next session to start because the USB is locked up. Have to you looked into
Why does it take pyocd 10 seconds to shutdown. What is it waiting for? Maybe another gdb connection. Maybe it should have an option to shutdown when the last gdb connection is disconnected. There is an option for some servers to run once or to be persistent. Well, pyocd seems to be neither. This is also the gdb servers responsibility. Not ours. JLink had this problem and we had that fixed but pointing them to gdb's documentation. OpenOCD has that problem and we could NOT get that fixed. Please read gdb's documentation on what a proper shutdown procedure is. You should take these issues to the creator of the gdb-server. Fixing them here is not the solution. GDB defines the rules and servers that mis-implemented should fix their stuff. |
I may have a solution that is better than any timeout -- which we should never need. There is now a monitor command called. I am ashamed that it is even there because none of the gdb-servers did it properly or similarly.
Note that this monitor command seems to be new and may not be implemented by many gdb-servers. I can experiment with it. Please note that we follow rules that GDB has established on how gdb-servers should behave and GDB clients should behave. GDB is the master here. Both us and the gdb-servers are clients of its protocol. |
https://pyocd.io/docs/gdbserver.html See the Btw, I have submitted PRs (I added the initial multi-core support) to pyocd. They were easy to work with and responsive. |
Describe the bug
When I stop the debug session, the target usually (not always) remains halted. It doesn't matter when I exit from a halted or running target.
To Reproduce
cortex-debug
v1.12.1Expected behavior
The target should keep running. This is the expected behavior I get when manually starting a
gdb
+PyOCD
terminal session. If Iquit
gdb, PyOCD will exit automatically as well and leave the target running.Fix
I noticed that the PyOCD gdb-server gets forcefully killed too quickly. Normally it will exit on its own gracefully, and in such a case the target continues to run as expected. But I noticed that this graceful exit can take anywhere from a couple of milliseconds to 3 seconds. By that time,
cortex-debug
will have calledgdb-exit
and/or forcefully kill the gdb process. By increasing the timeout, the issue is completely fixed for my case.My forked commit that fixes the issue for me: 3541297
Notice that I increased the timeout by a lot (10 seconds). This is because the PyOCD server will exit on its own anyway. So it doesn't just hang for 10 seconds, the debug session stops whenever PyOCD exits. I don't know if this is the same behavior for all gdb servers though.
Related issues: same symptoms, not sure if the cause is the same
launch.json
Additional logs
The text was updated successfully, but these errors were encountered: