diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-03-10 12:11:07 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-03-10 12:11:07 +0000 |
commit | 0424155dfc29ab8e3b5e4b7f36f9164df7b5b740 (patch) | |
tree | 7198a57c3a72830480a0614a8759cbafc4b62776 /src/server | |
parent | 0a34980f2bfb403ce56d6407ffa7891890852dbb (diff) | |
download | openocd_libswd-0424155dfc29ab8e3b5e4b7f36f9164df7b5b740.tar.gz openocd_libswd-0424155dfc29ab8e3b5e4b7f36f9164df7b5b740.tar.bz2 openocd_libswd-0424155dfc29ab8e3b5e4b7f36f9164df7b5b740.tar.xz openocd_libswd-0424155dfc29ab8e3b5e4b7f36f9164df7b5b740.zip |
- Fixed various error handling when looking for memory leaks
- Fixed memory leak in gdb_server.c
- pushed "Error:" statements up into fn's that know something about what went wrong
- load_image now fails if target_write_memory() fails
- only issue an asynchronous halt() upon connect of GDB. Synchronous halt/reset
doesn't really work as what's required to initialize the target might involve a
special monitor sequence for the target in question
- syntax error handling improved(fewer exit()'s)
git-svn-id: svn://svn.berlios.de/openocd/trunk@482 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/gdb_server.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index f01d638f..ce45f298 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -678,25 +678,23 @@ int gdb_new_connection(connection_t *connection) /* register callback to be informed about target events */ target_register_event_callback(gdb_target_callback_event_handler, connection); - /* a gdb session just attached, try to put the target in halt mode - * or alterantively try to issue a reset. - * - * GDB connection will fail if e.g. register read packets fail, - * otherwise resetting/halting the target could have been left to GDB init - * scripts + /* a gdb session just attached, try to put the target in halt mode. * * DANGER!!!! - * We need a synchronous halt, lest connect will fail. - * Also there is no guarantee that poll() will be invoked - * between here and serving the first packet, so the halt() - * statement above is *NOT* sufficient + * + * If the halt fails(e.g. target needs a reset, JTAG communication not + * working, etc.), then the GDB connect will succeed as + * the get_gdb_reg_list() will lie and return a register list with + * dummy values. + * + * This allows GDB monitor commands to be run from a GDB init script to + * initialize the target + * + * Also, since the halt() is asynchronous target connect will be + * instantaneous and thus avoiding annoying timeout problems during + * connect. */ - if ((retval = gdb_service->target->type->halt(gdb_service->target)) != ERROR_OK) - { - ERROR("error(%d) when trying to halt target, falling back to \"reset\"", retval); - command_run_line(connection->cmd_ctx, "reset"); - } - command_run_line(connection->cmd_ctx, "halt"); + gdb_service->target->type->halt(gdb_service->target); /* remove the initial ACK from the incoming buffer */ if ((retval = gdb_get_char(connection, &initial_ack)) != ERROR_OK) @@ -1182,13 +1180,12 @@ int gdb_write_memory_packet(connection_t *connection, target_t *target, char *pa } else { - if ((retval = gdb_error(connection, retval)) != ERROR_OK) - return retval; + retval = gdb_error(connection, retval); } free(buffer); - return ERROR_OK; + return retval; } int gdb_write_memory_binary_packet(connection_t *connection, target_t *target, char *packet, int packet_size) |