From c12002b63625021ba345bb2cd9d1f21bed9a2c5d Mon Sep 17 00:00:00 2001 From: Richard Meadows Date: Fri, 16 Jan 2015 21:52:19 +0000 Subject: [PATCH] Check target_attach succeeded in vRun command, and return error if not --- src/gdb_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gdb_main.c b/src/gdb_main.c index dc56a59..83ceeff 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -406,8 +406,13 @@ handle_v_packet(char *packet, int plen) } else if(last_target) { cur_target = target_attach(last_target, gdb_target_destroy_callback); - target_reset(cur_target); - gdb_putpacketz("T05"); + + /* If we were able to attach to the target again */ + if (cur_target) { + target_reset(cur_target); + gdb_putpacketz("T05"); + } else gdb_putpacketz("E01"); + } else gdb_putpacketz("E01"); } else if (sscanf(packet, "vFlashErase:%08lx,%08lx", &addr, &len) == 2) {