Date: Fri, 9 Jul 2004 02:30:43 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 56826 for review Message-ID: <200407090230.i692UhTI036566@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=56826 Change 56826 by marcel@marcel_nfs on 2004/07/09 02:29:47 Implement support for the M packet (memory write). This allows setting breakpoints for example. Can't be bad... Affected files ... .. //depot/projects/gdb/sys/gdb/gdb_int.h#7 edit .. //depot/projects/gdb/sys/gdb/gdb_main.c#16 edit .. //depot/projects/gdb/sys/gdb/gdb_packet.c#10 edit Differences ... ==== //depot/projects/gdb/sys/gdb/gdb_int.h#7 (text+ko) ==== @@ -37,6 +37,7 @@ int gdb_rx_begin(void); int gdb_rx_equal(const char *); +int gdb_rx_mem(unsigned char *, size_t); int gdb_rx_varhex(uintmax_t *); static __inline int ==== //depot/projects/gdb/sys/gdb/gdb_main.c#16 (text+ko) ==== @@ -163,13 +163,25 @@ break; } gdb_tx_begin(0); - gdb_tx_mem((char *)(uintptr_t)addr, size); - gdb_tx_end(); + if (gdb_tx_mem((char *)(uintptr_t)addr, size)) + gdb_tx_end(); + else + gdb_tx_err(EIO); break; } - case 'M': /* Write memory. */ - gdb_tx_err(0); + case 'M': { /* Write memory. */ + uintmax_t addr, size; + if (gdb_rx_varhex(&addr) || gdb_rx_char() != ',' || + gdb_rx_varhex(&size) || gdb_rx_char() != ':') { + gdb_tx_err(EINVAL); + break; + } + if (gdb_rx_mem((char *)(uintptr_t)addr, size) == 0) + gdb_tx_err(EIO); + else + gdb_tx_ok(); break; + } case 'P': { /* Write register. */ uintmax_t reg, val; if (gdb_rx_varhex(®) || gdb_rx_char() != '=' || ==== //depot/projects/gdb/sys/gdb/gdb_packet.c#10 (text+ko) ==== @@ -112,6 +112,32 @@ } int +gdb_rx_mem(unsigned char *addr, size_t size) +{ + void *prev; + jmp_buf jb; + int ret; + unsigned char c; + + if (size * 2 != gdb_rxsz) + return (-1); + + prev = kdb_jmpbuf(jb); + ret = setjmp(jb); + if (ret == 0) { + while (size-- > 0) { + c = (C2N(gdb_rxp[0]) << 4) & 0xf0; + c |= C2N(gdb_rxp[1]) & 0x0f; + *addr++ = c; + gdb_rxsz -= 2; + gdb_rxp += 2; + } + } + (void)kdb_jmpbuf(prev); + return ((ret == 0) ? 1 : 0); +} + +int gdb_rx_varhex(uintmax_t *vp) { uintmax_t v;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407090230.i692UhTI036566>