diff options
Diffstat (limited to 'src/debug/remgdb/stream.c')
-rw-r--r-- | src/debug/remgdb/stream.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/debug/remgdb/stream.c b/src/debug/remgdb/stream.c index 2b487ad..0f17930 100644 --- a/src/debug/remgdb/stream.c +++ b/src/debug/remgdb/stream.c @@ -41,6 +41,9 @@ static void g_gdb_stream_class_init(GGdbStreamClass *); /* Initialise une instance de flux de communication avec GDB. */ static void g_gdb_stream_init(GGdbStream *); +/* Envoie un acquittement pour la dernière réception. */ +static bool gdb_stream_ack(GGdbStream *); + /* Ecoute une connexion à un serveur GDB. */ static void *gdb_stream_thread(GGdbStream *); @@ -124,6 +127,37 @@ bool g_gdb_stream_listen(GGdbStream *stream) * * * Paramètres : stream = encadrement associée à l'opération. * * * +* Description : Envoie un acquittement pour la dernière réception. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool gdb_stream_ack(GGdbStream *stream) +{ + bool result; /* Bilan à retourner */ + GGdbPacket *packet; /* Paquet à envoyer */ + + packet = g_gdb_stream_get_free_packet(stream); + + g_gdb_packet_start_new_command(packet); + g_gdb_packet_append(packet, "+"); + + result = g_gdb_stream_send_packet(stream, packet); + + g_gdb_stream_mark_packet_as_free(stream, packet); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : stream = encadrement associée à l'opération. * +* * * Description : Ecoute une connexion à un serveur GDB. * * * * Retour : ??? * @@ -145,6 +179,8 @@ static void *gdb_stream_thread(GGdbStream *stream) ret = select(stream->fd + 1, &rfds, NULL, NULL, NULL); + printf("ret :: %d\n", ret); + switch (ret) { case -1: @@ -162,6 +198,11 @@ static void *gdb_stream_thread(GGdbStream *stream) if (g_gdb_stream_read_packet(stream, packet)) { + /* Acquittement */ + if (!gdb_stream_ack(stream)) goto bad_recv; + + /* On conserve le résultat */ + g_mutex_lock(stream->recv_mutex); g_gdb_packet_push(&stream->recv_packets, packet); g_mutex_unlock(stream->recv_mutex); @@ -169,7 +210,12 @@ static void *gdb_stream_thread(GGdbStream *stream) g_cond_signal(stream->recv_cond); } - else g_gdb_stream_mark_packet_as_free(stream, packet); + + bad_recv: + + printf("bad things happend...\n"); + + g_gdb_stream_mark_packet_as_free(stream, packet); break; |