-
-
Notifications
You must be signed in to change notification settings - Fork 60
MultiThreadSchedulerLocking support #178 #179
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
Conversation
|
Let me know if you'd like me to take a look here. I saw you opened it as a draft PR, so thought I'd ask before leaving comments |
|
@daniel5151 Please go ahead, I'd appreciate the feedback. It's currently running well in my project. I'll mark this as ready. (Apologies for any slow replies—I'm currently busy with final exams.) |
daniel5151
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Overall design looks good, so after we fix up a few minor doc and error-handling related things, we should be gtg here.
Also, like I mentioned in #178 (comment), it'd be good to double-check that the approach we're talking here lines up with how the GDB client (and maybe gdbserver) handle scheduler-locking.
I'll see if I can find some time to poke around https://github.com/bminor/binutils-gdb myself, but would def appreciate it if you could poke around a bit as part of this diff.
Best of luck with exams! I'm also somewhat busy this week (home for the holidays and whatnot), so no need to rush or anything.
I nerd sniped myself, so I did some digging here lol. https://github.com/bminor/binutils-gdb/blob/b0196f0/gdb/remote.c#L960-L961 It looks like GDB unconditionally assumes that the remote target supports scheduler-locking, which seems... not ideal. Interestingly enough - I chased the So, if you want some bonus points - you might want to consider opening an issue (or even sending in a PR?) to GDB that points out this behavior, and that it might be more user-friendly if GDB negotiated support for scheduler-locking on remote targets via a |
- Protocol: Add `MultiThreadSchedulerLocking` IDET to track and enforce GDB's scheduler-locking mode during `vCont` handling. - Error Handling: Introduce `MissingMultiThreadSchedulerLocking` internal error to provide clear feedback when the IDET is missing. - Documentation: Refactor IDET docs to focus on high-level GDB user behavior (`set scheduler-locking`) instead of RSP packet details. - Examples: Update `armv4t_multicore` to support core freezing via `ExecMode::Stop`, providing a reference implementation for lock-step multi-core targets. - Examples: Revert unnecessary cycle stall changes in the emulator. Closes daniel5151#178
31e6113 to
f9b2cf0
Compare
|
@daniel5151 First off, thanks for the deep dive! Reading that massive amount of ancient C code is honestly painful to look at 😂. I’ve been thinking about this, and I’m actually not sure if opening an issue or PR against GDB is the right move here. Since the Remote Serial Protocol uses wildcards in its data packets to convey information, there seems to be an implicit assumption that the remote server should possess the capability to control threads/processes to that degree. In that sense, the hardcoded behavior (defaulting to assuming support) actually seems reasonable. I noticed that for local targets (non-remote), there is indeed code to handle However, regarding remote targets, it seems tied to how packets like That said, I do think the current redesign of I tried to control execution purely by sending signals to specific threads/processes to Also, regarding |
|
Code looks good! I think we are good to land it. Thank you for your contribution! Let me know if you'd like me to cut a new (this section is me musing about whether upstream GDB is doing things in a reasonable way or not - nothing below blocks landing this PR)
Indeed, I also saw that this was a purely client-side concept.
I'm not sure I follow here - the behavior you claim is "forbidden" is exactly what GDB does today, no? i.e: sending a vCont packet that includes thread-specific instructions alongside a
Yeah, my point is that this is a bogus assumption. My (conjectured) read on the situation is this: Given the relatively "low-stakes" failure mode of trying to enable scheduler locking on a remote target that doesn't support it (i.e: "oh, weird, my threads didn't all stop - I guess this remote doesn't support scheduler locking. oh well"), there wasn't ever much reason to invest in extra infrastructure to do proper client/remote negotiation of An interesting data-point to confirm this theory would be to look into what the upstream And yet another point: look at this commit that landed which tweaked the vCont packet language back in 2016: bminor/binutils-gdb@ca6eff5 This is once again a bit hard to interpret... but if you squint, it seems like it used to say that threads "should" remain stopped in all-stop mode. This could be a weasel-word that implies "but it might not always happen". This is just conjecture of course. The new phrasing seems a bit too aggressive IMO, since there's no way for the GDB client to actually force all remote targets to support scheduler-locking on correctly ^and really, that last sentence is the crux of my annoyance here. The fact GDB unconditionally assumes all remote targets support fine-grained scheduling is silly, and the failure mode is - as you've experienced first hand - silent, and subtly wrong behavior. Ideally, there should be some checks/validation (i.e: feature negotiation) between the client and server that allows the GDB client to gate the use of |
Description
This PR implements a new Protocol Extension IDET:
MultiThreadSchedulerLocking.Closes #178
Changes
MultiThreadSchedulerLockingIDET underMultiThreadResume.do_vcont_multi_threadto track the presence of wildcard/default continue actions.gdbstubnow invokesset_resume_action_scheduler_lock.gdbstubreturns a fatalPacketUnexpectederror to avoid silent race conditions (as discussed in issue Expose additional vCont semantics to supportscheduler-lockingmodes #178).armv4t_multicoreexample to demonstrate a working scheduler-locking implementation.API Stability
Checklist
rustdocformatting looks goodexamples/armv4t_multicore./example_no_std/check_size.shexamples/armv4t_multicore./example_no_std/check_size.sh)Validation
1. Functional Validation (
armv4t_multicore)Tested with GDB 15.0. Verified that when
set scheduler-locking onis used, only the selected thread steps, while the other remain frozen at its last PC.GDB Session Output
Code snippet
2. Binary Size Check (
./example_no_std/check_size.sh)check_size Output
before:
after: