diff options
author | Tim Newsome <tim@sifive.com> | 2019-01-24 15:15:18 -0800 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2019-01-24 15:27:53 -0800 |
commit | afedcb337a79517462765aa62b1988c8857cc724 (patch) | |
tree | 11d36231a907beca10dd6fe597e3d216533444a2 /src/server/gdb_server.c | |
parent | c296c625214c74e25744ed8c2c0b62b65c90532d (diff) | |
download | riscv-openocd-afedcb337a79517462765aa62b1988c8857cc724.zip riscv-openocd-afedcb337a79517462765aa62b1988c8857cc724.tar.gz riscv-openocd-afedcb337a79517462765aa62b1988c8857cc724.tar.bz2 |
WIP on hardware breakpoints.
This is messy, but contains at least some bugfixes.
39/43 tests pass now.
Change-Id: Ic9e8dad2a0ceb237e28c93906d1cd60876a5766d
Diffstat (limited to 'src/server/gdb_server.c')
-rw-r--r-- | src/server/gdb_server.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 4631ffb..2772e7a 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -144,6 +144,7 @@ static char gdb_running_type; static int gdb_last_signal(struct target *target) { + LOG_DEBUG(">>> [%d] debug_reason=%d", target->coreid, target->debug_reason); switch (target->debug_reason) { case DBG_REASON_DBGRQ: return 0x2; /* SIGINT */ @@ -733,17 +734,28 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio if (target->debug_reason == DBG_REASON_EXIT) { sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "W00"); } else { + struct target *ct; + if (target->rtos != NULL) { + target->rtos->current_threadid = target->rtos->current_thread; + LOG_DEBUG("current_threadid=%ld", target->rtos->current_threadid); + target->rtos->gdb_target_for_threadid(connection, target->rtos->current_threadid, &ct); + } else { + ct = target; + } + if (gdb_connection->ctrl_c) { signal_var = 0x2; } else - signal_var = gdb_last_signal(target); + signal_var = gdb_last_signal(ct); + LOG_DEBUG(">>> ctrl_c=%d, signal_var=%d", gdb_connection->ctrl_c, + signal_var); stop_reason[0] = '\0'; - if (target->debug_reason == DBG_REASON_WATCHPOINT) { + if (ct->debug_reason == DBG_REASON_WATCHPOINT) { enum watchpoint_rw hit_wp_type; target_addr_t hit_wp_address; - if (watchpoint_hit(target, &hit_wp_type, &hit_wp_address) == ERROR_OK) { + if (watchpoint_hit(ct, &hit_wp_type, &hit_wp_address) == ERROR_OK) { switch (hit_wp_type) { case WPT_WRITE: @@ -765,15 +777,10 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio } current_thread[0] = '\0'; - if (target->rtos != NULL) { - struct target *ct; + if (target->rtos != NULL) snprintf(current_thread, sizeof(current_thread), "thread:%" PRIx64 ";", target->rtos->current_thread); - target->rtos->current_threadid = target->rtos->current_thread; - target->rtos->gdb_target_for_threadid(connection, target->rtos->current_threadid, &ct); - if (!gdb_connection->ctrl_c) - signal_var = gdb_last_signal(ct); - } + LOG_DEBUG(">>> signal_var=%d", signal_var); sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "T%2.2x%s%s", signal_var, stop_reason, current_thread); @@ -1652,7 +1659,7 @@ static int gdb_breakpoint_watchpoint_packet(struct connection *connection, char *separator; int retval; - LOG_DEBUG("-"); + LOG_DEBUG("[%d]", target->coreid); type = strtoul(packet + 1, &separator, 16); @@ -3178,6 +3185,7 @@ static int gdb_input_inner(struct connection *connection) } if (packet_size > 0) { + LOG_DEBUG(">>> current_threadid=%ld", target->rtos ? target->rtos->current_threadid : 1234); retval = ERROR_OK; switch (packet[0]) { case 'T': /* Is thread alive? */ |