gdb_qemu: Ignore UTF-8 errors (#1403)

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
This commit is contained in:
WorksButNotTested 2023-08-07 01:54:49 -07:00 committed by GitHub
parent 3bf3172928
commit 51e2f64e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,6 @@ use {
io::{Read, Write}, io::{Read, Write},
net::{SocketAddr, TcpStream}, net::{SocketAddr, TcpStream},
os::fd::RawFd, os::fd::RawFd,
str::from_utf8,
thread::spawn, thread::spawn,
time::{Duration, SystemTime}, time::{Duration, SystemTime},
}, },
@ -61,8 +60,7 @@ impl Parent {
} }
fn log_packets(direction: &Direction, buffer: &[u8]) -> Result<()> { fn log_packets(direction: &Direction, buffer: &[u8]) -> Result<()> {
for pkt in from_utf8(buffer) for pkt in String::from_utf8_lossy(buffer)
.map_err(|e| anyhow!("Failed to read buffer: {e:}"))?
.split('$') .split('$')
.filter(|x| !x.is_empty()) .filter(|x| !x.is_empty())
.filter(|x| x != &"+") .filter(|x| x != &"+")
@ -73,8 +71,7 @@ impl Parent {
} }
fn log_io(channel: &Channel, buffer: &[u8]) -> Result<()> { fn log_io(channel: &Channel, buffer: &[u8]) -> Result<()> {
for line in from_utf8(buffer) for line in String::from_utf8_lossy(buffer)
.map_err(|e| anyhow!("Failed to read buffer: {e:}"))?
.lines() .lines()
.filter(|x| !x.is_empty()) .filter(|x| !x.is_empty())
{ {