aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorHsiangkai Wang <hsiangkai@gmail.com>2013-03-06 09:39:52 +0800
committerSpencer Oliver <spen@spen-soft.co.uk>2013-08-07 21:01:43 +0000
commit399561eafa747e71202d00985206b65868142afb (patch)
treee4479569d46e3f0ac495f8078568eb518606b312 /src/server
parent0a4c8990c29e61fd0c2796486519cdb256b8da3b (diff)
gdb_server: add target_debug_reason for program exit detection
Currently, there is no way to notify gdb that program has exited. Add new target_debug_reason called DBG_REASON_EXIT to notify gdb the condition has occured. If the debug reason is DBG_REASON_EXIT, gdb_server will send 'W' packet to tell gdb the process has exited. Change-Id: I7a371da292716a3e6ac4cc2c31b009a651fe047a Signed-off-by: Hsiangkai Wang <hsiangkai@gmail.com> Reviewed-on: http://openocd.zylin.com/1242 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/server')
-rw-r--r--src/server/gdb_server.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 14925a2b..c4ad91cf 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -702,40 +702,44 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio
int sig_reply_len;
int signal_var;
- if (gdb_connection->ctrl_c) {
- signal_var = 0x2;
- gdb_connection->ctrl_c = 0;
- } else
- signal_var = gdb_last_signal(target);
+ if (target->debug_reason == DBG_REASON_EXIT) {
+ sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "W00");
+ } else {
+ if (gdb_connection->ctrl_c) {
+ signal_var = 0x2;
+ gdb_connection->ctrl_c = 0;
+ } else
+ signal_var = gdb_last_signal(target);
- stop_reason[0] = '\0';
- if (target->debug_reason == DBG_REASON_WATCHPOINT) {
- enum watchpoint_rw hit_wp_type;
- uint32_t hit_wp_address;
+ stop_reason[0] = '\0';
+ if (target->debug_reason == DBG_REASON_WATCHPOINT) {
+ enum watchpoint_rw hit_wp_type;
+ uint32_t hit_wp_address;
- if (watchpoint_hit(target, &hit_wp_type, &hit_wp_address) == ERROR_OK) {
+ if (watchpoint_hit(target, &hit_wp_type, &hit_wp_address) == ERROR_OK) {
- switch (hit_wp_type) {
- case WPT_WRITE:
- snprintf(stop_reason, sizeof(stop_reason),
- "watch:%08x;", hit_wp_address);
- break;
- case WPT_READ:
- snprintf(stop_reason, sizeof(stop_reason),
- "rwatch:%08x;", hit_wp_address);
- break;
- case WPT_ACCESS:
- snprintf(stop_reason, sizeof(stop_reason),
- "awatch:%08x;", hit_wp_address);
- break;
- default:
- break;
+ switch (hit_wp_type) {
+ case WPT_WRITE:
+ snprintf(stop_reason, sizeof(stop_reason),
+ "watch:%08x;", hit_wp_address);
+ break;
+ case WPT_READ:
+ snprintf(stop_reason, sizeof(stop_reason),
+ "rwatch:%08x;", hit_wp_address);
+ break;
+ case WPT_ACCESS:
+ snprintf(stop_reason, sizeof(stop_reason),
+ "awatch:%08x;", hit_wp_address);
+ break;
+ default:
+ break;
+ }
}
}
- }
- sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "T%2.2x%s",
- signal_var, stop_reason);
+ sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "T%2.2x%s",
+ signal_var, stop_reason);
+ }
gdb_put_packet(connection, sig_reply, sig_reply_len);
gdb_connection->frontend_state = TARGET_HALTED;