Skip to content

Commit

Permalink
Report thread-id in response to ? packet (#105)
Browse files Browse the repository at this point in the history
When more than one thread is active the following warning is visible upon connecting:

```
warning: multi-threaded target stopped without sending a thread-id, using first non-exited thread
```

This is because gdbstub sends a stop packet of `S05`, which conveys no thread-id.  This fix changes the response to `T05thread:<tid>;`, which eliminates the warning.

Signed-off-by: Ryan Fairfax <ryan@thefaxman.net>
  • Loading branch information
thefaxman committed Jun 7, 2022
1 parent 1fde6f7 commit 2cd3bc6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/stub/core_impl/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,17 @@ impl<T: Target, C: Connection> GdbStubImpl<T, C> {
// TODO: Improve the '?' response based on last-sent stop reason.
// this will be particularly relevant when working on non-stop mode.
Base::QuestionMark(_) => {
res.write_str("S05")?;
// Reply with a valid thread-id or GDB issues a warning when more
// than one thread is active
res.write_str("T05thread:")?;
res.write_specific_thread_id(SpecificThreadId {
pid: self
.features
.multiprocess()
.then(|| SpecificIdKind::WithId(FAKE_PID)),
tid: SpecificIdKind::WithId(self.get_sane_any_tid(target)?),
})?;
res.write_str(";")?;
HandlerStatus::Handled
}
Base::qAttached(cmd) => {
Expand Down

0 comments on commit 2cd3bc6

Please sign in to comment.