-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
NoActiveThreads error when there are no active thread #122
Comments
Hey, long time no see! Glad to hear you're circling back to A few immediate thoughts:
|
I'm traveling, so unfortunately I won't be able to do any extra work on this for one week. Unfortunately the debugger also exploded the night before I departed so there isn't any code posted online.
I'll have more concrete information after March 8th.
The sequence of events was that I connected to the target and then had my thread enumeration function return immediately - since there was no process selected and therefore no threads. I may have tried to continue execution, but I can't recall.
#124 sounds suspiciously useful and applicable.
Processes in this system are composed of multiple threads. Currently I have a monitor command that prints out the process table, and if you specify a pid it will switch to debugging that process. Actually, I did get that working before I left so I can just link the code: https://github.com/betrusted-io/xous-core/blob/18a40111cb5a20be55b775959b2b4d49e1f3363d/kernel/src/debug/gdb.rs#L464
One thing about this approach is that you have to do "info thr" and select a thread after switching processes. It'd be nice if that wasn't required.
I haven't looked at extended mode since that seemed to be too closely related to posix and semi hosting and all that, but I can take another look.
…On 1 March 2023 1:51:44 am SGT, Daniel Prilik ***@***.***> wrote:
Hey, long time no see!
Glad to hear you're circling back to `gdbstub` again - I'm always excited to see the work you come up with running things in `no_std`.
* * *
A few immediate thoughts:
- Can you share the trace output from `gdbstub` that led to this error?
- If you're interested in _properly_ supporting multi-process debugging, this might be a good opportunity to take a stab at #124 (something I've had as a TODO in the README for years now, but never opened a tracking issue for)
- In the meantime... can you share some more context on how your custom `monitor` command works, and what your "processes" look like (i.e: do they support multiple threads each? or is each thread a process? etc...)
- Have you explored the `ExtendedMode` extensions? From the GDB docs:
- > With target extended-remote mode: When the debugged program exits or you detach from it, GDB remains connected to the target, even though no program is running
- Presumably, it's possible to connect to a stock `gdbserver` from `gdb` with no processes attached. I'd be interested to see the GDB RSP logs that occur during that connection. Could you help out with that investigation?
- i.e: open `gdb`, run `set debug remote 1` (to dump RSP packets `gdb` sends/recvs), and then connect to `gdbserver`
--
Reply to this email directly or view it on GitHub:
#122 (comment)
You are receiving this because you authored the thread.
Message ID: ***@***.***>
|
All good, no rush or anything! I do strongly suspect that standing up proper multiprocess debugging is the real solution to your problems here. Aside from the ideological purity of it, it'd also fix your "info thr" problem, since GDB would natively understand when you're switching between processes. That said - if that ends up becoming too daunting of a task, we can also dig into trying to mitigate the problem at hand (i.e: the "NoActiveThreads" error). Aside from seeing if It might be possible to mitigate this immediate issue by adding some logic to the initial |
Here is the output from gdb when I don't create a fake thread:
|
In contrast,
|
Fascinating... I gather two important observations from these logs:
Looking through the code, I believe this should be a relatively straightforward thing to fix:
...and I think that's it really. The Can you make those tweaks, and see if that fixes things? I'd do it myself, but as it happens, i'm actually on vacation for the next ~1.5 weeks, so idk how much hands-on coding time I'll have 😅 * I suspect it'll only start to matter if |
No hurry on this, either. I'm not yet familiar enough with the inner workings to know where to patch it. And if we wait until you're back, then you don't have to think about this on your holiday. |
Oh, don't worry about that - That said, If you would like to lend a hand and take a stab at this fix yourself: the Rust compiler will totally enumerate all "downstream" modification points once |
Sometimes, a target has no threads. This may be the case when a process is not yet selected, or when all threads have terminated in a specific process. Support `None` as a return from `get_sane_any_tid()` and return an error to GDB. This addresses a `NoActiveThreads` error, and closes daniel5151#122. Signed-off-by: Sean Cross <sean@xobs.io>
I went ahead and made the change, and it does seem to fix the case where there are no threads. Ergonomics is better, as gdb now won't let you do anything until you select a process and list threads:
(There's still a bit of an oddity in that the thread IDs don't match up with the target IDs, but that's definitely a different issue.) |
Sometimes, a target has no threads. This may be the case when a process is not yet selected, or when all threads have terminated in a specific process. Support `None` as a return from `get_sane_any_tid()` and return an error to GDB. This addresses a `NoActiveThreads` error, and closes daniel5151#122. Signed-off-by: Sean Cross <sean@xobs.io>
* error: mark NoActiveThreads as `deprecated` This variant is no longer generated, so note that it will be removed. Signed-off-by: Sean Cross <sean@xobs.io> * core_impl: fix support for no threads Sometimes, a target has no threads. This may be the case when a process is not yet selected, or when all threads have terminated in a specific process. Support `None` as a return from `get_sane_any_tid()` and return an error to GDB. This addresses a `NoActiveThreads` error, and closes #122. Signed-off-by: Sean Cross <sean@xobs.io> * base: use Error:NonFatalError to return E01 Since this plumbing exists, use this to return an error. Signed-off-by: Sean Cross <sean@xobs.io> --------- Signed-off-by: Sean Cross <sean@xobs.io>
When no threads are reported as part of
list_active_threads()
, gdbstub throws an errorgdbstub error during idle operation: NoActiveThreads
. A comment notes that this shouldn't happen, but it appears as though it does.Background
I've recently picked up gdbstub again and am working to integrate it into Xous more fully. It really is a fantastic project.
I have things mostly working now, and I'm filing off some of the rough edges. One of the rough edges is process selection. I have a
monitor
command to allow switching between processes, but the question arises of what process to connect to initially.I support having
None
process, which is what I'd like to have selected initially. This coincides with a system that's fully running and does not halt when a debugger is attached.However, returning early in
list_active_threads()
before adding any threads appears to result in this error.The text was updated successfully, but these errors were encountered: