summaryrefslogtreecommitdiff
path: root/src/debug/jdwp/sets/thread.c
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/thread.c
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/thread.c')
-rw-r--r--src/debug/jdwp/sets/thread.c108
1 files changed, 107 insertions, 1 deletions
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);
+
+}