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