Struct GdbServer

Source
pub struct GdbServer<R, W>
where R: BufRead, W: Write,
{ pub reader: R, pub writer: W, /* private fields */ }

Fields§

§reader: R§writer: W

Implementations§

Source§

impl GdbServer<BufReader<TcpStream>, TcpStream>

Source

pub fn listen<A>(addr: A) -> Result<Self, Error>
where A: ToSocketAddrs,

Examples found in repository?
examples/repl.rs (line 6)
4fn main() -> Result<(), Error> {
5    println!("Listening on port 1337...");
6    let mut server = GdbServer::listen("0.0.0.0:1337")?;
7    println!("Connected!");
8
9    while let Some(packet) = server.next_packet()? {
10        println!(
11            "-> {:?} {:?}",
12            packet.kind,
13            std::str::from_utf8(&packet.data)
14        );
15
16        print!(": ");
17        io::stdout().flush()?;
18        let mut response = String::new();
19        io::stdin().read_line(&mut response)?;
20        if response.ends_with('\n') {
21            response.truncate(response.len() - 1);
22        }
23        let response = CheckedPacket::from_data(Kind::Packet, response.into_bytes());
24
25        let mut bytes = Vec::new();
26        response.encode(&mut bytes).unwrap();
27        println!("<- {:?}", std::str::from_utf8(&bytes));
28
29        server.dispatch(&response)?;
30    }
31
32    println!("EOF");
33    Ok(())
34}
Source§

impl<'a> GdbServer<&'a mut &'a [u8], Vec<u8>>

Source

pub fn tester(input: &'a mut &'a [u8]) -> Self

Source

pub fn response(&mut self) -> Vec<u8>

Source§

impl<R, W> GdbServer<R, W>
where R: BufRead, W: Write,

Source

pub fn new(reader: R, writer: W) -> Self

Source

pub fn next_packet(&mut self) -> Result<Option<CheckedPacket>, Error>

Examples found in repository?
examples/repl.rs (line 9)
4fn main() -> Result<(), Error> {
5    println!("Listening on port 1337...");
6    let mut server = GdbServer::listen("0.0.0.0:1337")?;
7    println!("Connected!");
8
9    while let Some(packet) = server.next_packet()? {
10        println!(
11            "-> {:?} {:?}",
12            packet.kind,
13            std::str::from_utf8(&packet.data)
14        );
15
16        print!(": ");
17        io::stdout().flush()?;
18        let mut response = String::new();
19        io::stdin().read_line(&mut response)?;
20        if response.ends_with('\n') {
21            response.truncate(response.len() - 1);
22        }
23        let response = CheckedPacket::from_data(Kind::Packet, response.into_bytes());
24
25        let mut bytes = Vec::new();
26        response.encode(&mut bytes).unwrap();
27        println!("<- {:?}", std::str::from_utf8(&bytes));
28
29        server.dispatch(&response)?;
30    }
31
32    println!("EOF");
33    Ok(())
34}
Source

pub fn dispatch(&mut self, packet: &CheckedPacket) -> Result<(), Error>

Sends a packet, retrying upon any failed checksum verification on the remote.

Examples found in repository?
examples/repl.rs (line 29)
4fn main() -> Result<(), Error> {
5    println!("Listening on port 1337...");
6    let mut server = GdbServer::listen("0.0.0.0:1337")?;
7    println!("Connected!");
8
9    while let Some(packet) = server.next_packet()? {
10        println!(
11            "-> {:?} {:?}",
12            packet.kind,
13            std::str::from_utf8(&packet.data)
14        );
15
16        print!(": ");
17        io::stdout().flush()?;
18        let mut response = String::new();
19        io::stdin().read_line(&mut response)?;
20        if response.ends_with('\n') {
21            response.truncate(response.len() - 1);
22        }
23        let response = CheckedPacket::from_data(Kind::Packet, response.into_bytes());
24
25        let mut bytes = Vec::new();
26        response.encode(&mut bytes).unwrap();
27        println!("<- {:?}", std::str::from_utf8(&bytes));
28
29        server.dispatch(&response)?;
30    }
31
32    println!("EOF");
33    Ok(())
34}

Auto Trait Implementations§

§

impl<R, W> Freeze for GdbServer<R, W>
where R: Freeze, W: Freeze,

§

impl<R, W> RefUnwindSafe for GdbServer<R, W>

§

impl<R, W> Send for GdbServer<R, W>
where R: Send, W: Send,

§

impl<R, W> Sync for GdbServer<R, W>
where R: Sync, W: Sync,

§

impl<R, W> Unpin for GdbServer<R, W>
where R: Unpin, W: Unpin,

§

impl<R, W> UnwindSafe for GdbServer<R, W>
where R: UnwindSafe, W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.