Skip to main content

jdwp_client/
commands.rs

1// JDWP command implementations
2//
3// Command Sets:
4// 1 = VirtualMachine
5// 2 = ReferenceType
6// 6 = Method
7// 9 = ObjectReference
8// 11 = ThreadReference
9// 15 = EventRequest
10// 16 = StackFrame
11
12// Command set IDs
13pub mod command_sets {
14    pub const VIRTUAL_MACHINE: u8 = 1;
15    pub const REFERENCE_TYPE: u8 = 2;
16    pub const CLASS_TYPE: u8 = 3;
17    pub const METHOD: u8 = 6;
18    pub const OBJECT_REFERENCE: u8 = 9;
19    pub const STRING_REFERENCE: u8 = 10;
20    pub const THREAD_REFERENCE: u8 = 11;
21    pub const THREAD_GROUP_REFERENCE: u8 = 12;
22    pub const ARRAY_REFERENCE: u8 = 13;
23    pub const EVENT_REQUEST: u8 = 15;
24    pub const STACK_FRAME: u8 = 16;
25}
26
27// VirtualMachine commands (set 1)
28pub mod vm_commands {
29    pub const VERSION: u8 = 1;
30    pub const CLASSES_BY_SIGNATURE: u8 = 2;
31    pub const ALL_CLASSES: u8 = 3;
32    pub const ALL_THREADS: u8 = 4;
33    pub const TOP_LEVEL_THREAD_GROUPS: u8 = 5;
34    pub const DISPOSE: u8 = 6;
35    pub const ID_SIZES: u8 = 7;
36    pub const SUSPEND: u8 = 8;
37    pub const RESUME: u8 = 9;
38    pub const EXIT: u8 = 10;
39    pub const CREATE_STRING: u8 = 11;
40    pub const CAPABILITIES: u8 = 12;
41    pub const CLASS_PATHS: u8 = 13;
42    pub const DISPOSE_OBJECTS: u8 = 14;
43    pub const HOLD_EVENTS: u8 = 15;
44    pub const RELEASE_EVENTS: u8 = 16;
45    pub const CAPABILITIES_NEW: u8 = 17;
46    pub const REDEFINE_CLASSES: u8 = 18;
47    /// How many live instances each of several types has — one heap walk for the whole batch, which is
48    /// why the tool takes a list (DISC-10).
49    pub const INSTANCE_COUNTS: u8 = 21;
50}
51
52// ReferenceType commands (set 2)
53pub mod reference_type_commands {
54    pub const SIGNATURE: u8 = 1;
55    pub const CLASS_LOADER: u8 = 2;
56    pub const MODIFIERS: u8 = 3;
57    pub const FIELDS: u8 = 4;
58    pub const METHODS: u8 = 5;
59    pub const GET_VALUES: u8 = 6;
60    pub const SOURCE_FILE: u8 = 7;
61    pub const NESTED_TYPES: u8 = 8;
62    pub const STATUS: u8 = 9;
63    pub const INTERFACES: u8 = 10;
64    pub const CLASS_OBJECT: u8 = 11;
65    pub const SOURCE_DEBUG_EXTENSION: u8 = 12;
66    pub const SIGNATURE_WITH_GENERIC: u8 = 13;
67    pub const FIELDS_WITH_GENERIC: u8 = 14;
68    pub const METHODS_WITH_GENERIC: u8 = 15;
69    /// The live instances of ONE type — **exact type, not subtype-inclusive** (DISC-10).
70    pub const INSTANCES: u8 = 16;
71}
72
73// Method commands (set 6)
74pub mod method_commands {
75    pub const LINE_TABLE: u8 = 1;
76    pub const VARIABLE_TABLE: u8 = 2;
77    pub const BYTECODES: u8 = 3;
78    pub const IS_OBSOLETE: u8 = 4;
79    pub const VARIABLE_TABLE_WITH_GENERIC: u8 = 5;
80}
81
82// ThreadReference commands (set 11)
83pub mod thread_commands {
84    pub const NAME: u8 = 1;
85    pub const SUSPEND: u8 = 2;
86    pub const RESUME: u8 = 3;
87    pub const STATUS: u8 = 4;
88    pub const THREAD_GROUP: u8 = 5;
89    pub const FRAMES: u8 = 6;
90    pub const FRAME_COUNT: u8 = 7;
91    pub const OWNED_MONITORS: u8 = 8;
92    pub const CURRENT_CONTENDED_MONITOR: u8 = 9;
93    pub const STOP: u8 = 10;
94    pub const INTERRUPT: u8 = 11;
95    pub const SUSPEND_COUNT: u8 = 12;
96    pub const FORCE_EARLY_RETURN: u8 = 14;
97}
98
99// EventRequest commands (set 15)
100pub mod event_commands {
101    pub const SET: u8 = 1;
102    pub const CLEAR: u8 = 2;
103    pub const CLEAR_ALL_BREAKPOINTS: u8 = 3;
104}
105
106// StringReference commands (set 10)
107pub mod string_reference_commands {
108    pub const VALUE: u8 = 1;
109}
110
111// ObjectReference commands (set 9)
112pub mod object_reference_commands {
113    pub const REFERENCE_TYPE: u8 = 1;
114    pub const GET_VALUES: u8 = 2;
115    pub const SET_VALUES: u8 = 3;
116    pub const MONITOR_INFO: u8 = 5;
117    pub const INVOKE_METHOD: u8 = 6;
118    pub const DISABLE_COLLECTION: u8 = 7;
119    pub const ENABLE_COLLECTION: u8 = 8;
120    pub const IS_COLLECTED: u8 = 9;
121}
122
123// StackFrame commands (set 16)
124pub mod stack_frame_commands {
125    pub const GET_VALUES: u8 = 1;
126    pub const SET_VALUES: u8 = 2;
127    pub const THIS_OBJECT: u8 = 3;
128    pub const POP_FRAMES: u8 = 4;
129}
130
131// Event kinds for EventRequest.Set.
132//
133// This is the protocol's full table, so most entries are named but unrequested — that is deliberate, and
134// different from having decode paths for an event nothing can arm. Two worth knowing about:
135//
136// - `METHOD_ENTRY` (40) is named but intentionally NOT wired up. With a `ClassMatch` it fires on every
137//   method of every matching class — the noisiest event in JDWP — and "what calls this?" is answered
138//   far more cheaply by a traced breakpoint's caller chain (TRACE-5). `EventKind::MethodEntry` was
139//   removed for that reason (METH-1); this constant is a spec reference, not an oversight to fix.
140// - The `MONITOR_*` kinds (43-46) are the event-driven view of lock contention. The polling view —
141//   `owned_monitors` / `current_contended_monitor`, behind `debug.thread_dump` — is what DUMP-1 needed;
142//   these would only be worth arming for a live contention *detector*.
143pub mod event_kinds {
144    pub const SINGLE_STEP: u8 = 1;
145    pub const BREAKPOINT: u8 = 2;
146    pub const FRAME_POP: u8 = 3;
147    pub const EXCEPTION: u8 = 4;
148    pub const USER_DEFINED: u8 = 5;
149    pub const THREAD_START: u8 = 6;
150    pub const THREAD_DEATH: u8 = 7;
151    pub const CLASS_PREPARE: u8 = 8;
152    pub const CLASS_UNLOAD: u8 = 9;
153    pub const CLASS_LOAD: u8 = 10;
154    pub const FIELD_ACCESS: u8 = 20;
155    pub const FIELD_MODIFICATION: u8 = 21;
156    pub const EXCEPTION_CATCH: u8 = 30;
157    pub const METHOD_ENTRY: u8 = 40;
158    pub const METHOD_EXIT: u8 = 41;
159    pub const METHOD_EXIT_WITH_RETURN_VALUE: u8 = 42;
160    pub const MONITOR_CONTENDED_ENTER: u8 = 43;
161    pub const MONITOR_CONTENDED_ENTERED: u8 = 44;
162    pub const MONITOR_WAIT: u8 = 45;
163    pub const MONITOR_WAITED: u8 = 46;
164    pub const VM_START: u8 = 90;
165    pub const VM_DEATH: u8 = 99;
166}
167
168// Step sizes
169pub mod step_sizes {
170    pub const MIN: i32 = 0;
171    pub const LINE: i32 = 1;
172}
173
174// Step depths
175pub mod step_depths {
176    pub const INTO: i32 = 0;
177    pub const OVER: i32 = 1;
178    pub const OUT: i32 = 2;
179}