summaryrefslogtreecommitdiff
path: root/src/debug/jdwp/sets
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-02-18 16:41:31 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-02-18 16:41:31 (GMT)
commitdeb012d919ea6c5e79702a39a03a85be2ffcf406 (patch)
treeae9cee108d05e0a6674d8617a08d0ea09165443c /src/debug/jdwp/sets
parent73605bffb935fc51a52be1936426211e31dd898a (diff)
Retrieved the frames stack from the running process.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@235 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/debug/jdwp/sets')
-rw-r--r--src/debug/jdwp/sets/list.c7
-rw-r--r--src/debug/jdwp/sets/list.h2
-rw-r--r--src/debug/jdwp/sets/thread.c108
-rw-r--r--src/debug/jdwp/sets/thread.h9
4 files changed, 125 insertions, 1 deletions
diff --git a/src/debug/jdwp/sets/list.c b/src/debug/jdwp/sets/list.c
index 84c6ac0..ba96917 100644
--- a/src/debug/jdwp/sets/list.c
+++ b/src/debug/jdwp/sets/list.c
@@ -87,6 +87,13 @@ static jdwp_command _commands[][256] = {
.free_set_payload = (free_jdwp_payload_fc)NULL,
.get_payload = (get_jdwp_payload_fc)get_jdwp_thread_name,
.free_got_payload = (free_jdwp_payload_fc)free_jdwp_thread_name_reply
+ },
+
+ [JDWP_CMD_THREAD_FRAMES] = {
+ .set_payload = (set_jdwp_payload_fc)set_jdwp_thread_frames,
+ .free_set_payload = (free_jdwp_payload_fc)NULL,
+ .get_payload = (get_jdwp_payload_fc)get_jdwp_thread_frames,
+ .free_got_payload = (free_jdwp_payload_fc)free_jdwp_thread_frames_reply
}
}
diff --git a/src/debug/jdwp/sets/list.h b/src/debug/jdwp/sets/list.h
index 9880e69..ba66842 100644
--- a/src/debug/jdwp/sets/list.h
+++ b/src/debug/jdwp/sets/list.h
@@ -42,6 +42,8 @@ typedef union _jdwp_payload
jdwp_cmd_thread_name_request th_ident; /* Identification d'un thread */
jdwp_cmd_thread_name_reply th_name; /* Désignation d'un thread */
+ jdwp_cmd_thread_frames_request __nu0; /* Inutilisé */
+ jdwp_cmd_thread_frames_reply th_frames; /* Pile des frames courantes */
bin_t padding[500];
diff --git a/src/debug/jdwp/sets/thread.c b/src/debug/jdwp/sets/thread.c
index 9391ff6..ea60bc6 100644
--- a/src/debug/jdwp/sets/thread.c
+++ b/src/debug/jdwp/sets/thread.c
@@ -24,10 +24,12 @@
#include "thread.h"
+#include <malloc.h>
#include <string.h>
#include "../misc/id.h"
+#include "../misc/location.h"
#include "../misc/types.h"
#include "../../../common/endianness.h"
@@ -87,7 +89,7 @@ bool get_jdwp_thread_name(const bin_t *blob, off_t len, const jdwp_cmd_vm_id_siz
off_t pos; /* Tête de lecture */
pos = 0;
- memset(reply, 0, sizeof(jdwp_cmd_vm_version_reply));
+ memset(reply, 0, sizeof(jdwp_cmd_thread_name_reply));
result = get_jdwp_string(blob, &pos, len, &reply->name);
if (!result) return false;
@@ -114,3 +116,107 @@ void free_jdwp_thread_name_reply(jdwp_cmd_thread_name_reply *reply)
free_jdwp_string(&reply->name);
}
+
+
+/******************************************************************************
+* *
+* Paramètres : req = structure de réponse à constituer. *
+* sizes = références pour la valeur des tailles dynamiques. *
+* blob = ensemble de données binaires brutes. [OUT] *
+* len = quantité de données disponibles, puis écrites. [OUT] *
+* *
+* Description : Prépare une requête demandant les frames d'un thread. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool set_jdwp_thread_frames(const jdwp_cmd_thread_frames_request *req, const jdwp_cmd_vm_id_sizes_reply *sizes, bin_t *blob, off_t *len)
+{
+ bool result; /* Bilan à retourner */
+ off_t pos; /* Tête de lecture */
+
+ pos = 0;
+ memset(blob, 0, sizeof(jdwp_cmd_thread_frames_request));
+
+ result = set_jdwp_frame_id(&req->id, sizes, blob, &pos, *len);
+ if (!result) return false;
+
+ result = write_u32(&req->start, blob, &pos, *len, SRE_BIG);
+ if (!result) return false;
+
+ result = write_u32(&req->length, blob, &pos, *len, SRE_BIG);
+ if (!result) return false;
+
+ *len = pos;
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : blob = ensemble de données binaires brutes. *
+* len = quantité de données valides. *
+* sizes = références pour la valeur des tailles dynamiques. *
+* reply = structure de réponse à constituer. [OUT] *
+* *
+* Description : Reconstitue une réponse fournissant les frames d'un thread. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool get_jdwp_thread_frames(const bin_t *blob, off_t len, const jdwp_cmd_vm_id_sizes_reply *sizes, jdwp_cmd_thread_frames_reply *reply)
+{
+ bool result; /* Bilan à retourner */
+ off_t pos; /* Tête de lecture */
+ uint32_t i; /* Boucle de parcours */
+
+ pos = 0;
+ memset(reply, 0, sizeof(jdwp_cmd_thread_frames_reply));
+
+ result = read_u32(&reply->count, blob, &pos, len, SRE_BIG);
+ if (!result) return false;
+
+ reply->frames = (jdwp_thread_frame *)calloc(reply->count, sizeof(jdwp_thread_frame));
+
+ for (i = 0; i < reply->count && result; i++)
+ {
+ result = get_jdwp_frame_id(blob, &pos, len, sizes, &reply->frames[i].frame_id);
+
+ result &= get_jdwp_location(blob, &pos, len, sizes, &reply->frames[i].location);
+
+ }
+
+ if (!result)
+ free_jdwp_thread_frames_reply(reply);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reply = structure de réponse à supprimer de la mémoire. *
+* *
+* Description : Libère une liste de frames d'un thread. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void free_jdwp_thread_frames_reply(jdwp_cmd_thread_frames_reply *reply)
+{
+ if (reply->frames != NULL)
+ free(reply->frames);
+
+}
diff --git a/src/debug/jdwp/sets/thread.h b/src/debug/jdwp/sets/thread.h
index f8c3abe..a304cc0 100644
--- a/src/debug/jdwp/sets/thread.h
+++ b/src/debug/jdwp/sets/thread.h
@@ -41,6 +41,15 @@ bool get_jdwp_thread_name(const bin_t *, off_t, const jdwp_cmd_vm_id_sizes_reply
/* Libère le nom donné à un thread. */
void free_jdwp_thread_name_reply(jdwp_cmd_thread_name_reply *);
+/* Prépare une requête demandant les frames d'un thread. */
+bool set_jdwp_thread_frames(const jdwp_cmd_thread_frames_request *, const jdwp_cmd_vm_id_sizes_reply *, bin_t *, off_t *);
+
+/* Reconstitue une réponse fournissant les frames d'un thread. */
+bool get_jdwp_thread_frames(const bin_t *, off_t, const jdwp_cmd_vm_id_sizes_reply *, jdwp_cmd_thread_frames_reply *);
+
+/* Libère une liste de frames d'un thread. */
+void free_jdwp_thread_frames_reply(jdwp_cmd_thread_frames_reply *);
+
#endif /* _DEBUG_JDWP_SETS_THREAD_H */