diff options
Diffstat (limited to 'src/debug/jdwp')
-rw-r--r-- | src/debug/jdwp/debugger.c | 99 | ||||
-rw-r--r-- | src/debug/jdwp/tcp.c | 14 |
2 files changed, 64 insertions, 49 deletions
diff --git a/src/debug/jdwp/debugger.c b/src/debug/jdwp/debugger.c index a99c6d0..829d31c 100644 --- a/src/debug/jdwp/debugger.c +++ b/src/debug/jdwp/debugger.c @@ -24,12 +24,14 @@ #include "debugger.h" -#include "packet.h" -#include "tcp.h" +#include <i18n.h> +#include "packet.h" +#include "tcp.h" #include "../debugger-int.h" #include "../stream.h" +#include "../../panels/log.h" @@ -61,6 +63,8 @@ static void g_java_debugger_class_init(GJavaDebuggerClass *); /* Procède à l'initialisation du débogueur utilisant Java. */ static void g_java_debugger_init(GJavaDebugger *); +/* Procède au démarrage effectif de la session de débogage. */ +static bool g_java_debugger_attach(GJavaDebugger *); /* Indique le type défini par la GLib pour le débogueur java. */ @@ -103,6 +107,9 @@ static void g_java_debugger_init(GJavaDebugger *debugger) GBinaryDebugger *parent; /* Instance parente */ parent = G_BINARY_DEBUGGER(debugger); + + parent->attach = (attach_debugger_fc)g_java_debugger_attach; + #if 0 parent->run = (basic_debugger_fc)g_java_debugger_run; parent->resume = (resume_debugger_fc)g_java_debugger_resume; @@ -118,7 +125,7 @@ static void g_java_debugger_init(GJavaDebugger *debugger) * Paramètres : binary = binaire représenter à déboguer. * * options = paramètres destinés au débogage. * * * -* Description : Crée un débogueur utilisant un serveur JAVA distant. * +* Description : Crée un débogueur utilisant un serveur Java distant. * * * * Retour : Instance de débogueur mise en place ou NULL. * * * @@ -140,65 +147,67 @@ GBinaryDebugger *g_java_debugger_new(GOpenidaBinary *binary, void *options) } +/****************************************************************************** +* * +* Paramètres : debugger = instance du module de débogage chargé. * +* * +* Description : Procède au démarrage effectif de la session de débogage. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ - - - - -void test_java(void) +static bool g_java_debugger_attach(GJavaDebugger *debugger) { - GBinaryDebugger *debugger; - GDebugPacket *packet; - GDebugPacket *packet2; - jdwp_payload *payload; - - printf("JDWP-start !!!!\n"); - - printf("size == %d\n", sizeof(jdwp_header)); - - - debugger = g_java_debugger_new(NULL, NULL); - + bool result; /* Bilan à retourner */ + GDebugPacket *req; /* Requête à formuler */ + GDebugPacket *ret; /* Obtention de la réponse */ + jdwp_payload *payload; /* Charge utile d'une réponse */ - g_debug_stream_connect(G_JAVA_DEBUGGER(debugger)->stream); + req = NULL; + ret = NULL; + /* Connexion physique */ - packet = g_debug_stream_get_free_packet(G_JAVA_DEBUGGER(debugger)->stream); + result = g_debug_stream_connect(debugger->stream); + if (!result) goto gjda_error; + /* Demande de version */ - g_jdwp_packet_set_request_header(G_JDWP_PACKET(packet), JDWP_CST_VIRTUAL_MACHINE, JDWP_CMD_VM_VERSION); + req = g_debug_stream_get_free_packet(debugger->stream); - if (!g_debug_stream_send_packet(G_JAVA_DEBUGGER(debugger)->stream, packet)) - printf("erreur envoi\n"); + g_jdwp_packet_set_request_header(G_JDWP_PACKET(req), + JDWP_CST_VIRTUAL_MACHINE, JDWP_CMD_VM_VERSION); - packet2 = g_debug_stream_recv_packet(G_JAVA_DEBUGGER(debugger)->stream, (filter_packet_fc)g_jdwp_packet_is_reply, packet); + if (!g_debug_stream_send_packet(debugger->stream, req)) + goto gjda_error; - if (!packet2) - printf("erreur réception\n"); + ret = g_debug_stream_recv_packet(debugger->stream, + (filter_packet_fc)g_jdwp_packet_is_reply, req); + if (!ret) goto gjda_error; - if (!g_jdwp_packet_parse_payload(G_JDWP_PACKET(packet2), JDWP_CST_VIRTUAL_MACHINE, JDWP_CMD_VM_VERSION)) - printf("erreur de décodage\n"); + if (!g_jdwp_packet_parse_payload(G_JDWP_PACKET(ret), JDWP_CST_VIRTUAL_MACHINE, JDWP_CMD_VM_VERSION)) + goto gjda_error; - payload = g_jdwp_packet_get_payload(G_JDWP_PACKET(packet2)); + payload = g_jdwp_packet_get_payload(G_JDWP_PACKET(ret)); + log_variadic_message(LMT_INFO, _("The debugger is '%s' (JRE %d.%d; VM %s)."), + payload->vs_reply.description.value, + payload->vs_reply.jdwp_major, payload->vs_reply.jdwp_minor, + payload->vs_reply.vm_version.value); + g_jdwp_packet_free_payload(G_JDWP_PACKET(ret), JDWP_CST_VIRTUAL_MACHINE, JDWP_CMD_VM_VERSION); - printf("-----------\n"); + gjda_error: - printf("desc :: '%s'\n", payload->vs_reply.description.value); + if (req != NULL) + g_debug_stream_mark_packet_as_free(debugger->stream, req); - printf("version :: %d.%d\n", payload->vs_reply.jdwp_major, payload->vs_reply.jdwp_minor); + if (ret != NULL) + g_debug_stream_mark_packet_as_free(debugger->stream, ret); - printf("version :: '%s'\n", payload->vs_reply.vm_version.value); - printf("name :: '%s'\n", payload->vs_reply.vm_name.value); - - printf("-----------\n"); - - - - g_jdwp_packet_free_payload(G_JDWP_PACKET(packet2), JDWP_CST_VIRTUAL_MACHINE, JDWP_CMD_VM_VERSION); - - - printf("JDWP-end !!!!\n"); + return result; } diff --git a/src/debug/jdwp/tcp.c b/src/debug/jdwp/tcp.c index 38acd29..d4ec1d7 100644 --- a/src/debug/jdwp/tcp.c +++ b/src/debug/jdwp/tcp.c @@ -32,11 +32,15 @@ #include <sys/types.h> +#include <i18n.h> + + #include "packet.h" #include "misc/header.h" #include "sets/list.h" #include "../stream-int.h" #include "../../common/net.h" +#include "../../panels/log.h" @@ -180,12 +184,14 @@ static bool g_jdwp_tcp_client_connect(GJdwpTcpClient *client) sock = connect_via_tcp(client->server, client->port, &addr); if (sock == -1) { - printf("Echec de connexion au serveur JDWP sur %s:%s\n", - client->server, client->port); + log_variadic_message(LMT_ERROR, _("Error while connecting to the JDWP server at %s:%s."), + //printf("Echec de connexion au serveur JDWP sur %s:%s\n", + client->server, client->port); return false; } - printf("Connecté à %s:%hd\n", client->server, ntohs(addr.sin_port)); + log_variadic_message(LMT_PROCESS, _("Connected to %s:%hd."), + client->server, ntohs(addr.sin_port)); if (send(sock, "JDWP-Handshake", 14, 0) != 14) goto gjtcc_error; @@ -202,7 +208,7 @@ static bool g_jdwp_tcp_client_connect(GJdwpTcpClient *client) gjtcc_error: - printf("Echec des premiers échanges !\n"); + log_simple_message(LMT_ERROR, _("Failure in the first JDWP handshake.")); close(sock); |