Improve flow of command-line debugging

This commit is contained in:
2025-01-05 11:24:59 -05:00
parent d6eb8ec7ef
commit 6fd8d8f5cf
5 changed files with 40 additions and 8 deletions
+12 -2
View File
@@ -1,6 +1,8 @@
use egui::{Button, CentralPanel, TextEdit, ViewportBuilder, ViewportId};
use winit::event_loop::EventLoopProxy;
use crate::{
app::UserEvent,
emulator::{EmulatorClient, SimId},
gdbserver::{GdbServer, GdbServerStatus},
};
@@ -10,21 +12,26 @@ use super::AppWindow;
pub struct GdbServerWindow {
sim_id: SimId,
port_str: String,
launched: bool,
server: GdbServer,
proxy: EventLoopProxy<UserEvent>,
}
impl GdbServerWindow {
pub fn new(sim_id: SimId, client: EmulatorClient) -> Self {
pub fn new(sim_id: SimId, client: EmulatorClient, proxy: EventLoopProxy<UserEvent>) -> Self {
Self {
sim_id,
port_str: (8080 + sim_id.to_index()).to_string(),
launched: false,
server: GdbServer::new(sim_id, client),
proxy,
}
}
pub fn start(&mut self, port: u16) {
pub fn launch(&mut self, port: u16) {
self.server.stop();
self.port_str = port.to_string();
self.launched = true;
self.server.start(port);
}
}
@@ -57,6 +64,9 @@ impl AppWindow for GdbServerWindow {
});
if !status.running() {
if self.launched {
self.proxy.send_event(UserEvent::Quit).unwrap();
}
let start_button = Button::new("Start");
if ui.add_enabled(port_num.is_some(), start_button).clicked() {
let port = port_num.unwrap();