Apply some clippy-suggested fixes
This commit is contained in:
@@ -112,7 +112,7 @@ impl Core {
|
|||||||
loop {
|
loop {
|
||||||
match dbg_stream.recv()? {
|
match dbg_stream.recv()? {
|
||||||
DebugCommand::GetRegs(sender) => sender.send(gdb::RegsResponse {
|
DebugCommand::GetRegs(sender) => sender.send(gdb::RegsResponse {
|
||||||
x_regs: self.x_regs.clone(),
|
x_regs: self.x_regs,
|
||||||
pc: self.pc,
|
pc: self.pc,
|
||||||
})?,
|
})?,
|
||||||
DebugCommand::ReadMem {
|
DebugCommand::ReadMem {
|
||||||
@@ -163,7 +163,7 @@ impl Core {
|
|||||||
return StopReason::Exception(ExceptionType::Breakpoint);
|
return StopReason::Exception(ExceptionType::Breakpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(_) = stopper.try_recv() {
|
if stopper.try_recv().is_ok() {
|
||||||
return StopReason::Interrupted;
|
return StopReason::Interrupted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,14 +98,14 @@ impl MemoryException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<MemoryExceptionType> for MemoryException {
|
impl From<MemoryException> for MemoryExceptionType {
|
||||||
fn into(self) -> MemoryExceptionType {
|
fn from(val: MemoryException) -> Self {
|
||||||
self.type_
|
val.type_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<ExceptionType> for Exception {
|
impl From<Exception> for ExceptionType {
|
||||||
fn into(self) -> ExceptionType {
|
fn from(val: Exception) -> Self {
|
||||||
self.type_
|
val.type_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/gdb.rs
35
src/gdb.rs
@@ -71,8 +71,7 @@ pub fn run_stub(cmd_sender: crossbeam::channel::Sender<CoreCmd>) {
|
|||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let listener = TcpListener::bind("127.0.0.1:1234").expect("couldnt start tcp listener");
|
let listener = TcpListener::bind("127.0.0.1:1234").expect("couldnt start tcp listener");
|
||||||
|
|
||||||
for stream_res in listener.incoming() {
|
for stream in listener.incoming().flatten() {
|
||||||
if let Ok(stream) = stream_res {
|
|
||||||
let (dbg_tx, dbg_rx) = crossbeam::channel::bounded(16);
|
let (dbg_tx, dbg_rx) = crossbeam::channel::bounded(16);
|
||||||
|
|
||||||
stream
|
stream
|
||||||
@@ -85,7 +84,6 @@ pub fn run_stub(cmd_sender: crossbeam::channel::Sender<CoreCmd>) {
|
|||||||
|
|
||||||
handle_gdb_connection(stream, dbg_tx).expect("failure during connection");
|
handle_gdb_connection(stream, dbg_tx).expect("failure during connection");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,18 +97,19 @@ fn handle_gdb_connection(
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
match read_rsp_packet(&mut reader) {
|
match read_rsp_packet(&mut reader) {
|
||||||
Ok(packet) => match handle_packet(
|
Ok(packet) => {
|
||||||
|
if handle_packet(
|
||||||
&packet[..packet.len() - 1],
|
&packet[..packet.len() - 1],
|
||||||
&mut writer,
|
&mut writer,
|
||||||
&dbg_tx,
|
&dbg_tx,
|
||||||
&mut reader,
|
&mut reader,
|
||||||
) {
|
)
|
||||||
Err(_) => {
|
.is_err()
|
||||||
|
{
|
||||||
let _ = dbg_tx.send(DebugCommand::ExitDebugMode);
|
let _ = dbg_tx.send(DebugCommand::ExitDebugMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_ => {}
|
}
|
||||||
},
|
|
||||||
Err(ref e) if e.kind() == ErrorKind::WouldBlock => {
|
Err(ref e) if e.kind() == ErrorKind::WouldBlock => {
|
||||||
std::thread::yield_now();
|
std::thread::yield_now();
|
||||||
}
|
}
|
||||||
@@ -224,7 +223,7 @@ fn handle_packet<W: Write, R: BufRead>(
|
|||||||
let (responder, stop_reason_rx) = oneshot::channel();
|
let (responder, stop_reason_rx) = oneshot::channel();
|
||||||
dbg_tx.send(DebugCommand::Step(responder)).unwrap();
|
dbg_tx.send(DebugCommand::Step(responder)).unwrap();
|
||||||
let stop_reason = stop_reason_rx.recv().unwrap();
|
let stop_reason = stop_reason_rx.recv().unwrap();
|
||||||
send_packet(&stop_reason.to_rsp(), writer)?;
|
send_packet(stop_reason.to_rsp(), writer)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
"c" => {
|
"c" => {
|
||||||
@@ -253,7 +252,7 @@ fn handle_packet<W: Write, R: BufRead>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(stop_reason) = stop_reason_rx.try_recv() {
|
if let Ok(stop_reason) = stop_reason_rx.try_recv() {
|
||||||
send_packet(&stop_reason.to_rsp(), writer)?;
|
send_packet(stop_reason.to_rsp(), writer)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,11 +264,12 @@ fn handle_packet<W: Write, R: BufRead>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
"Z" if packet.chars().nth(1) == Some('0') => {
|
"Z" if packet.chars().nth(1) == Some('0') => {
|
||||||
if let Some((addr_str, size_str)) = packet[3..].split_once(',') {
|
if let Some((addr_str, size_str)) = packet[3..].split_once(',')
|
||||||
if let (Ok(addr), Ok(size)) = (
|
&& let (Ok(addr), Ok(size)) = (
|
||||||
u64::from_str_radix(addr_str, 16),
|
u64::from_str_radix(addr_str, 16),
|
||||||
u64::from_str_radix(size_str, 16),
|
u64::from_str_radix(size_str, 16),
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if size != 4 {
|
if size != 4 {
|
||||||
send_packet("", writer)?;
|
send_packet("", writer)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -279,16 +279,16 @@ fn handle_packet<W: Write, R: BufRead>(
|
|||||||
send_packet("OK", writer)?;
|
send_packet("OK", writer)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
send_packet("", writer)?;
|
send_packet("", writer)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
"z" if packet.chars().nth(1) == Some('0') => {
|
"z" if packet.chars().nth(1) == Some('0') => {
|
||||||
if let Some((addr_str, size_str)) = packet[3..].split_once(',') {
|
if let Some((addr_str, size_str)) = packet[3..].split_once(',')
|
||||||
if let (Ok(addr), Ok(size)) = (
|
&& let (Ok(addr), Ok(size)) = (
|
||||||
u64::from_str_radix(addr_str, 16),
|
u64::from_str_radix(addr_str, 16),
|
||||||
u64::from_str_radix(size_str, 16),
|
u64::from_str_radix(size_str, 16),
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if size != 4 {
|
if size != 4 {
|
||||||
send_packet("", writer)?;
|
send_packet("", writer)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -298,7 +298,6 @@ fn handle_packet<W: Write, R: BufRead>(
|
|||||||
send_packet("OK", writer)?;
|
send_packet("OK", writer)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
send_packet("", writer)?;
|
send_packet("", writer)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user