Skip to content

Commit

Permalink
Updates some dependencies, minor refactors (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuchAFuriousDeath authored Nov 20, 2024
1 parent 582fd11 commit c25bf3e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 56 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ qt = []
[dependencies]
bitfield-struct = "0.9.2"
ciborium = "0.2.2"
clap = { version = "4.5.20", features = ["derive"], optional = true }
clap = { version = "4.5.21", features = ["derive"], optional = true }
gdbstub = "0.7.3"
gdbstub_arch = "0.3.1"
humansize = "2.1.3"
libc = "0.2.155"
libc = "0.2.164"
obconf = { path = "../src/obconf", features = ["serde", "virt"] }
obfw = { git = "https://github.com/obhq/firmware-dumper.git", features = [
"read",
Expand All @@ -35,7 +35,7 @@ pkg = { path = "../src/pkg" }
rfd = { version = "0.14.0", optional = true }
serde = { version = "1.0.209", features = ["derive"] }
thiserror = "1.0"
uuid = { version = "1.10.0", features = ["serde", "v4"] }
uuid = { version = "1.11.0", features = ["serde", "v4"] }

[dependencies.slint]
version = "1.8.0"
Expand Down
45 changes: 2 additions & 43 deletions gui/src/vmm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use crate::debug::DebugClient;
use crate::error::RustError;
use crate::profile::Profile;
use crate::screen::Screen;
use gdbstub::common::Signal;
use gdbstub::stub::state_machine::GdbStubStateMachine;
use gdbstub::stub::MultiThreadStopReason;
use std::ffi::{c_char, c_void, CStr};
use std::ptr::null_mut;
use std::sync::atomic::Ordering;
Expand Down Expand Up @@ -78,52 +76,13 @@ pub unsafe extern "C" fn vmm_draw(vmm: *mut Vmm) -> *mut RustError {
pub unsafe extern "C" fn vmm_dispatch_debug(vmm: *mut Vmm, stop: *mut KernelStop) -> DebugResult {
// Consume stop reason now to prevent memory leak.
let vmm = &mut *vmm;
let mut stop = if stop.is_null() {
let stop = if stop.is_null() {
None
} else {
Some(Box::from_raw(stop).0)
};

loop {
// Check current state.
let r = match vmm.gdb.take().unwrap() {
GdbStubStateMachine::Idle(s) => match super::debug::dispatch_idle(&mut vmm.cpu, s) {
Ok(Ok(v)) => Ok(v),
Ok(Err(v)) => {
// No pending data from the debugger.
vmm.gdb = Some(v.into());
return DebugResult::Ok;
}
Err(e) => Err(e),
},
GdbStubStateMachine::Running(s) => {
match super::debug::dispatch_running(&mut vmm.cpu, s, stop.take()) {
Ok(Ok(v)) => Ok(v),
Ok(Err(v)) => {
// No pending data from the debugger.
vmm.gdb = Some(v.into());
return DebugResult::Ok;
}
Err(e) => Err(e),
}
}
GdbStubStateMachine::CtrlCInterrupt(s) => {
vmm.cpu.lock();

s.interrupt_handled(
&mut vmm.cpu,
Some(MultiThreadStopReason::Signal(Signal::SIGINT)),
)
.map_err(|e| RustError::with_source("couldn't handle CTRL+C from a debugger", e))
}
GdbStubStateMachine::Disconnected(_) => return DebugResult::Disconnected,
};

match r {
Ok(v) => vmm.gdb = Some(v),
Err(e) => return DebugResult::Error { reason: e.into_c() },
}
}
vmm.dispatch_debug(stop)
}

#[no_mangle]
Expand Down
48 changes: 48 additions & 0 deletions gui/src/vmm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::hv::{Hypervisor, Ram};
use crate::profile::Profile;
use crate::screen::Screen;
use cpu::GdbError;
use gdbstub::common::Signal;
use gdbstub::stub::state_machine::GdbStubStateMachine;
use gdbstub::stub::{GdbStubError, MultiThreadStopReason};
use kernel::{KernelError, ProgramHeaderError};
Expand Down Expand Up @@ -345,6 +346,53 @@ impl Vmm {

Ok(vmm)
}

fn dispatch_debug(&mut self, mut stop: Option<MultiThreadStopReason<u64>>) -> DebugResult {
loop {
// Check current state.
let r = match self.gdb.take().unwrap() {
GdbStubStateMachine::Idle(s) => {
match debug::dispatch_idle(&mut self.cpu, s) {
Ok(Ok(v)) => Ok(v),
Ok(Err(v)) => {
// No pending data from the debugger.
self.gdb = Some(v.into());
return DebugResult::Ok;
}
Err(e) => Err(e),
}
}
GdbStubStateMachine::Running(s) => {
match debug::dispatch_running(&mut self.cpu, s, stop.take()) {
Ok(Ok(v)) => Ok(v),
Ok(Err(v)) => {
// No pending data from the debugger.
self.gdb = Some(v.into());
return DebugResult::Ok;
}
Err(e) => Err(e),
}
}
GdbStubStateMachine::CtrlCInterrupt(s) => {
self.cpu.lock();

s.interrupt_handled(
&mut self.cpu,
Some(MultiThreadStopReason::Signal(Signal::SIGINT)),
)
.map_err(|e| {
RustError::with_source("couldn't handle CTRL+C from a debugger", e)
})
}
GdbStubStateMachine::Disconnected(_) => return DebugResult::Disconnected,
};

match r {
Ok(v) => self.gdb = Some(v),
Err(e) => return DebugResult::Error { reason: e.into_c() },
}
}
}
}

impl Drop for Vmm {
Expand Down

0 comments on commit c25bf3e

Please sign in to comment.