* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
- * Copyright (C) 2007,2008 Øyvind Harboe *
+ * Copyright (C) 2007,2008 Øyvind Harboe *
* oyvind.harboe@zylin.com *
* *
* Copyright (C) 2008 by Spencer Oliver *
break;
if ((retval = gdb_get_char(connection, &reply)) != ERROR_OK)
return retval;
- if (reply == '$'){
+ if (reply == '$') {
/* fix a problem with some IAR tools */
gdb_putback_char(connection, reply);
LOG_DEBUG("Unexpected start of new packet");
log_remove_callback(gdb_log_callback, connection);
LOG_WARNING("negative reply, retrying");
}
- else if (reply == '$'){
+ else if (reply == '$') {
LOG_ERROR("GDB missing ack(1) - assumed good");
gdb_putback_char(connection, reply);
return ERROR_OK;
return ERROR_SERVER_REMOTE_CLOSED;
}
}
- else if (reply == '$'){
+ else if (reply == '$') {
LOG_ERROR("GDB missing ack(2) - assumed good");
gdb_putback_char(connection, reply);
return ERROR_OK;
{
gdb_connection_t *gdb_connection = connection->priv;
- /* In the GDB protocol when we are stepping or coninuing execution,
+ /* In the GDB protocol when we are stepping or continuing execution,
* we have a lingering reply. Upon receiving a halted event
* when we have that lingering packet, we reply to the original
* step or continue packet.
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_ATTACH);
gdb_actual_connections++;
+ LOG_DEBUG("New GDB Connection: %d, Target %s, state: %s",
+ gdb_actual_connections,
+ gdb_service->target->cmd_name,
+ target_state_name(gdb_service->target));
return ERROR_OK;
}
gdb_service_t *gdb_service = connection->service->priv;
gdb_connection_t *gdb_connection = connection->priv;
+ /* we're done forwarding messages. Tear down callback before
+ * cleaning up connection.
+ */
+ log_remove_callback(gdb_log_callback, connection);
+
gdb_actual_connections--;
+ LOG_DEBUG("GDB Close, Target: %s, state: %s, gdb_actual_connections=%d",
+ gdb_service->target->cmd_name,
+ target_state_name(gdb_service->target),
+ gdb_actual_connections);
/* see if an image built with vFlash commands is left */
if (gdb_connection->vflash_image)
LOG_ERROR("BUG: connection->priv == NULL");
}
+
target_unregister_event_callback(gdb_target_callback_event_handler, connection);
+
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_END);
- log_remove_callback(gdb_log_callback, connection);
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_DETACH);
/* terminate with zero */
packet[packet_size] = 0;
- if (LOG_LEVEL_IS(LOG_LVL_DEBUG)){
- if (packet[0] == 'X'){
+ if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
+ if (packet[0] == 'X') {
// binary packets spew junk into the debug log stream
char buf[ 50 ];
int x;
- for (x = 0 ; (x < 49) && (packet[x] != ':') ; x++){
+ for (x = 0 ; (x < 49) && (packet[x] != ':') ; x++) {
buf[x] = packet[x];
}
buf[x] = 0;
return ERROR_OK;
}
- /* only if the port wasn't overwritten by cmdline */
- if (gdb_port == 0)
- gdb_port = strtoul(args[0], NULL, 0);
+ gdb_port = strtoul(args[0], NULL, 0);
return ERROR_OK;
}