This is an automated email from Gerrit. Hsiangkai Wang (hsiang...@gmail.com) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/1242
-- gerrit commit 142a8a00ed7a39864de4d2da7e9b246725c0bf2e Author: Hsiangkai Wang <hsiang...@gmail.com> Date: Wed Mar 6 09:39:52 2013 +0800 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 <hsiang...@gmail.com> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 2407b4e..b3a72cd 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -695,49 +695,46 @@ 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); - - snprintf(sig_reply, 4, "T%2.2x", signal_var); - sig_reply_len = 3; + if (target->debug_reason == DBG_REASON_EXIT) { + snprintf(sig_reply, 4, "W00"); + sig_reply_len = 3; + } else { + 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_WATCHPOINT) { - enum watchpoint_rw hit_wp_type; - uint32_t hit_address; + snprintf(sig_reply, 4, "T%2.2x", signal_var); + sig_reply_len = 3; - if (watchpoint_hit(target, &hit_wp_type, &hit_address) == ERROR_OK) { - uint32_t i; - uint8_t *buffer; + if (target->debug_reason == DBG_REASON_WATCHPOINT) { + enum watchpoint_rw hit_wp_type; + uint32_t hit_address; - switch (hit_wp_type) { - case WPT_WRITE: - snprintf(sig_reply + 3, 7, "watch:"); - sig_reply_len = 9; - break; - case WPT_READ: - snprintf(sig_reply + 3, 8, "rwatch:"); - sig_reply_len = 10; - break; - case WPT_ACCESS: - snprintf(sig_reply + 3, 8, "awatch:"); - sig_reply_len = 10; - break; - } + if (watchpoint_hit(target, &hit_wp_type, &hit_address) == ERROR_OK) { + switch (hit_wp_type) { + case WPT_WRITE: + snprintf(sig_reply + 3, 7, "watch:"); + sig_reply_len = 9; + break; + case WPT_READ: + snprintf(sig_reply + 3, 8, "rwatch:"); + sig_reply_len = 10; + break; + case WPT_ACCESS: + snprintf(sig_reply + 3, 8, "awatch:"); + sig_reply_len = 10; + break; + } - buffer = (uint8_t *)&hit_address; - for (i = 0; i < 4; i++) { - uint8_t t = buffer[4 - i - 1]; /* reported address uses big-endian */ - sig_reply[sig_reply_len] = DIGITS[(t >> 4) & 0xf]; - sig_reply[sig_reply_len + 1] = DIGITS[t & 0xf]; - sig_reply_len += 2; + sig_reply_len += sprintf(sig_reply + sig_reply_len, "%08x", hit_address); + sig_reply[sig_reply_len++] = ';'; + sig_reply[sig_reply_len] = 0; } - sig_reply[sig_reply_len++] = ';'; - sig_reply[sig_reply_len] = 0; } } + gdb_put_packet(connection, sig_reply, sig_reply_len); gdb_connection->frontend_state = TARGET_HALTED; rtos_update_threads(target); diff --git a/src/target/target.h b/src/target/target.h index 17ba68f..835739e 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -83,7 +83,8 @@ enum target_debug_reason { DBG_REASON_WPTANDBKPT = 3, DBG_REASON_SINGLESTEP = 4, DBG_REASON_NOTHALTED = 5, - DBG_REASON_UNDEFINED = 6 + DBG_REASON_EXIT = 6, + DBG_REASON_UNDEFINED = 7, }; enum target_endianness { -- ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel