summaryrefslogtreecommitdiff
path: root/src/debug/jdwp/jdwp_def.h
blob: 7f13f8c83d2317a47a8188989e9312db7d81725b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195

/* OpenIDA - Outil d'analyse de fichiers binaires
 * jdwp_def.h - transcription du protocole Java Debug Wire Protocol
 *
 * Copyright (C) 2010-2012 Cyrille Bagard
 *
 *  This file is part of OpenIDA.
 *
 *  OpenIDA is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  OpenIDA is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef _DEBUG_JDWP_JDWP_DEF_H
#define _DEBUG_JDWP_JDWP_DEF_H


#include <stdint.h>
#include <sys/types.h>



/**
 * Les définitions ci-dessous sont issues des pages Web suivantes :
 *  - http://download.oracle.com/javase/1.4.2/docs/guide/jpda/jdwp-spec.html
 *  - http://download.oracle.com/javase/1.4.2/docs/guide/jpda/jdwp/jdwp-protocol.html
 */



/* ---------------------------------------------------------------------------------- */
/*                              EN-TETES DE PAQUETS JDWP                              */
/* ---------------------------------------------------------------------------------- */


/* En-tête générique */
typedef struct __attribute__((__packed__)) _jdwp_header
{
    uint32_t length;                        /* Taille totale du paquet     */
    uint32_t id;                            /* Numéro de séquence          */
    uint8_t flags;                          /* Options diverses            */

    union
    {
        /* Requête */
        struct
        {
            uint8_t set;                    /* Jeu de commandes            */
            uint8_t command;                /* Identifiant de commande     */
        };

        /* Réponse */
        uint16_t error;                     /* Numéro d'erreur             */

    };

} jdwp_header;


#define JDWP_FLAGS_NONE     0x00
#define JDWP_FLAGS_REPLY    0x80



/* ---------------------------------------------------------------------------------- */
/*                           CONSTANTES UTILISEES DANS JDWP                           */
/* ---------------------------------------------------------------------------------- */


/* Constantes TypeTag */
typedef uint8_t jdwp_type_tag;

#define JDWP_TYPE_TAG_CLASS     1           /* Le type est une classe      */
#define JDWP_TYPE_TAG_INTERFACE 2           /* Le type est une interface   */
#define JDWP_TYPE_TAG_ARRAY     3           /* Le type est un tableau      */






/* ---------------------------------------------------------------------------------- */
/*                           TYPES DE BASE DIVERS POUR JDWP                           */
/* ---------------------------------------------------------------------------------- */


/* Identifiant de taille dynamique */
typedef uint64_t jdwp_dynsized_id;




/* "string" */
typedef struct _jdwp_string
{
    uint32_t length;                        /* Taille de la chaîne         */
    char *value;                            /* Chaîne encodée en UTF-8     */

} jdwp_string;




/**
 * Jeux de commandes.
 */

#define JDWP_CST_NONE               0       /* Organisation interne        */
#define JDWP_CST_VIRTUAL_MACHINE    1
#define JDWP_CST_THREAD_REFERENCE   11


/**
 * Sous-commandes d'un jeu.
 */

/* Organisation interne */

#define JDWP_CMD_NONE               0

/* VirtualMachine Command Set */

#define JDWP_CMD_VM_VERSION         1
#define JDWP_CMD_VM_ALL_THREADS     4
#define JDWP_CMD_VM_ID_SIZES        7

/* ThreadReference Command Set */

#define JDWP_CMD_THREAD_NAME        1


/**
 * Charges utiles des paquets.
 */

/* JDWP_CMD_VM_VERSION */

typedef struct _jdwp_cmd_vm_version_reply
{
    jdwp_string description;                /* Infos sur la VM             */
    uint32_t jdwp_major;                    /* Numéro majeur de JDWP       */
    uint32_t jdwp_minor;                    /* Numéro mineur de JDWP       */
    jdwp_string vm_version;                 /* Version JRE de la VM ciblée */
    jdwp_string vm_name;                    /* Nom de la VM                */

} jdwp_cmd_vm_version_reply;

/* JDWP_CMD_VM_ALL_THREADS */

typedef struct _jdwp_cmd_vm_allthreads_reply
{
    uint32_t count;                         /* Taille de la liste          */
    jdwp_dynsized_id *threads;              /* Identifiant des threads     */

} jdwp_cmd_vm_allthreads_reply;

/* JDWP_CMD_VM_ID_SIZES */

typedef struct _jdwp_cmd_vm_id_sizes_reply
{
	uint32_t field_id_size;                 /* taille pour un 'fieldID'    */
    uint32_t method_id_size;                /* taille pour un 'methodID'   */
    uint32_t object_id_size;                /* taille pour un 'objectID'   */
    uint32_t reference_type_id_size;        /* taille pour un '...TypeID'  */
    uint32_t frame_id_size;                 /* taille pour un 'frameID'    */

} jdwp_cmd_vm_id_sizes_reply;

/* JDWP_CMD_THREAD_NAME */

typedef struct _jdwp_cmd_thread_name_request
{
    jdwp_dynsized_id id;                    /* Identifiant du thread visé  */

} jdwp_cmd_thread_name_request;

typedef struct _jdwp_cmd_thread_name_reply
{
    jdwp_string name;                       /* Désignation humaine         */

} jdwp_cmd_thread_name_reply;



#endif  /* _DEBUG_JDWP_JDWP_DEF_H */