Improve flow of command-line debugging
This commit is contained in:
+12
-2
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user