aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2020-05-31 00:41:21 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2020-06-04 23:13:13 +0200
commit3390159e1f610a57465add05ca56c31cef78cdc2 (patch)
tree4fa122e0c622f5efd68004f7c6014388ca816bf2
parenta03d79fcc6f5c7ce7389d586977ca8d2cfe94f1a (diff)
Added support for Z0/z0 (aka breakpoint) commands
-rw-r--r--gdbstub.c56
-rw-r--r--gdbstub.h2
2 files changed, 58 insertions, 0 deletions
diff --git a/gdbstub.c b/gdbstub.c
index 155b37c..a14db06 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -944,6 +944,62 @@ int dbg_main(struct dbg_state *state)
break;
/*
+ * Breakpoint
+ * Command Format: Z0,[addr],[type]
+ */
+ case 'Z': {
+ int zero;
+ size_t brk_sz;
+
+ ptr_next += 1;
+ token_expect_integer_arg(zero);
+ token_expect_seperator(',');
+ token_expect_integer_arg(addr);
+ token_expect_seperator(',');
+ token_expect_integer_arg(brk_sz);
+
+ if (zero) {
+ goto error;
+ }
+
+ /* Set breakpoint */
+ if (dbg_sys_breakpoint(addr)) {
+ goto error;
+ }
+
+ dbg_send_ok_packet(pkt_buf, sizeof(pkt_buf));
+ }
+ break;
+
+ /*
+ * Remove Breakpoint
+ * Command Format: Z0,[addr],[type]
+ */
+ case 'z': {
+ int zero;
+ size_t brk_sz;
+
+ ptr_next += 1;
+ token_expect_integer_arg(zero);
+ token_expect_seperator(',');
+ token_expect_integer_arg(addr);
+ token_expect_seperator(',');
+ token_expect_integer_arg(brk_sz);
+
+ if (zero) {
+ goto error;
+ }
+
+ /* Set breakpoint */
+ if (dbg_sys_del_breakpoint(addr)) {
+ goto error;
+ }
+
+ dbg_send_ok_packet(pkt_buf, sizeof(pkt_buf));
+ }
+ break;
+
+ /*
* Unsupported Command
*/
default:
diff --git a/gdbstub.h b/gdbstub.h
index e72635d..da1c05b 100644
--- a/gdbstub.h
+++ b/gdbstub.h
@@ -82,5 +82,7 @@ int dbg_sys_mem_readb(address addr, char *val);
int dbg_sys_mem_writeb(address addr, char val);
int dbg_sys_continue(void);
int dbg_sys_step(void);
+int dbg_sys_breakpoint(address addr);
+int dbg_sys_del_breakpoint(address addr);
#endif