Skip to content
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

gdbstub: Fix order of task list when first BP occurs after tasks created #216

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions src/debug/gdbstub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,32 +539,23 @@ pub mod svsm_gdbstub {
) -> Result<(), Self::Error> {
let mut tl = TASKLIST.lock();

let mut any_scheduled = false;

if tl.list().is_empty() {
// Task list has not been initialised yet. Report a single thread
// for the current CPU
// Get the current task. If this is the first request after the remote
// GDB has connected then we need to report the current task first.
// There is no harm in doing this every time the thread list is requested.
let current_task = this_cpu().runqueue().lock_read().current_task_id();
if current_task == INITIAL_TASK_ID {
thread_is_active(Tid::new(INITIAL_TASK_ID as usize).unwrap());
} else {
thread_is_active(Tid::new(current_task as usize).unwrap());

let mut cursor = tl.list().front_mut();
while cursor.get().is_some() {
if cursor.get().unwrap().task.lock_read().allocation.is_some() {
any_scheduled = true;
break;
let this_task = cursor.get().unwrap().task.lock_read().id;
if this_task != current_task {
thread_is_active(Tid::new(this_task as usize).unwrap());
}
cursor.move_next();
}
if any_scheduled {
let mut cursor = tl.list().front_mut();
while cursor.get().is_some() {
thread_is_active(
Tid::new(cursor.get().unwrap().task.lock_read().id as usize).unwrap(),
);
cursor.move_next();
}
} else {
thread_is_active(Tid::new(INITIAL_TASK_ID as usize).unwrap());
}
}
Ok(())
}
Expand Down
Loading