Implement GDB/LLDB compatible server #3
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -239,7 +239,7 @@ impl GdbConnection {
 | 
			
		|||
                self.response()
 | 
			
		||||
            }
 | 
			
		||||
        } else if req.match_str("vCont?") {
 | 
			
		||||
            self.response().write_str("vCont;c;")
 | 
			
		||||
            self.response().write_str("vCont;c;s;")
 | 
			
		||||
        } else if req.match_str("qC") {
 | 
			
		||||
            // The v810 has no threads, so report that the "current thread" is 1.
 | 
			
		||||
            self.response().write_str("QCp1.t1")
 | 
			
		||||
| 
						 | 
				
			
			@ -258,7 +258,7 @@ impl GdbConnection {
 | 
			
		|||
            self.stop_reason = None;
 | 
			
		||||
            // Don't send a response until we hit a breakpoint or get interrupted
 | 
			
		||||
            return Ok(None);
 | 
			
		||||
        } else if req.match_str("s") {
 | 
			
		||||
        } else if req.match_some_str(["s", "vCont;s:"]).is_some() {
 | 
			
		||||
            self.client
 | 
			
		||||
                .send_command(EmulatorCommand::DebugStep(self.sim_id));
 | 
			
		||||
            self.stop_reason = None;
 | 
			
		||||
| 
						 | 
				
			
			@ -280,13 +280,25 @@ impl GdbConnection {
 | 
			
		|||
            }
 | 
			
		||||
        } else if let Some(op) = req.match_some_str(["m", "x"]) {
 | 
			
		||||
            let mut read_memory = || {
 | 
			
		||||
                let start = req.match_hex::<u64>()? as u32;
 | 
			
		||||
                let start = req.match_hex::<u64>()?;
 | 
			
		||||
                if !req.match_str(",") {
 | 
			
		||||
                    return None;
 | 
			
		||||
                };
 | 
			
		||||
                let length = req.match_hex::<usize>()?;
 | 
			
		||||
 | 
			
		||||
                let mut buf = self.memory_buf.take().unwrap_or_default();
 | 
			
		||||
                buf.clear();
 | 
			
		||||
 | 
			
		||||
                // The v810 has a 32-bit address space.
 | 
			
		||||
                // Addresses wrap within that space, but we don't need to implement that for 64-bit addresses.
 | 
			
		||||
                // Just refuse to return any info for addresses above 0xffffffff.
 | 
			
		||||
                let Ok(start) = u32::try_from(start) else {
 | 
			
		||||
                    return Some(buf);
 | 
			
		||||
                };
 | 
			
		||||
                let length = length.min((u32::MAX - start) as usize + 1);
 | 
			
		||||
                if length == 0 {
 | 
			
		||||
                    return Some(buf);
 | 
			
		||||
                }
 | 
			
		||||
                let (tx, rx) = ::oneshot::channel();
 | 
			
		||||
                self.client.send_command(EmulatorCommand::ReadMemory(
 | 
			
		||||
                    self.sim_id,
 | 
			
		||||
| 
						 | 
				
			
			@ -299,7 +311,9 @@ impl GdbConnection {
 | 
			
		|||
            };
 | 
			
		||||
            if let Some(memory) = read_memory() {
 | 
			
		||||
                let mut res = self.response();
 | 
			
		||||
                if op == "m" {
 | 
			
		||||
                if memory.is_empty() {
 | 
			
		||||
                    res = res.write_str("OK");
 | 
			
		||||
                } else if op == "m" {
 | 
			
		||||
                    // send the hex-encoded byte stream
 | 
			
		||||
                    for byte in &memory {
 | 
			
		||||
                        res = res.write_hex(*byte);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue