dsh-ris-ide 0.0.0-stage → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +123 -2
- package/bin/run-with-log.ps1 +173 -0
- package/bin/run-with-log.sh +136 -0
- package/cordis.patch.yml +25 -0
- package/lib/client-codemirror.js +29822 -0
- package/lib/client.js +10772 -0
- package/lib/debug/engine.js +537 -0
- package/lib/debug/vendor/LICENSE +21 -0
- package/lib/debug/vendor/README.md +36 -0
- package/lib/debug/vendor/UPSTREAM_COMMIT +1 -0
- package/lib/debug/vendor/jdwp/client.js +1104 -0
- package/lib/debug/vendor/jdwp/constants.js +309 -0
- package/lib/debug/vendor/jdwp/protocol.js +253 -0
- package/lib/debug/vendor/src/jdwp/client.ts +1368 -0
- package/lib/debug/vendor/src/jdwp/constants.ts +310 -0
- package/lib/debug/vendor/src/jdwp/protocol.ts +326 -0
- package/lib/index.js +6112 -0
- package/lib/standalone/vendor/react-dom.js +267 -0
- package/lib/standalone/vendor/react.js +31 -0
- package/lib/standalone/window.html +248 -0
- package/package.json +96 -4
- package/skills/dsh-ris-ide-debug/SKILL.md +158 -0
- package/test/client-viewer.test.mjs +3557 -0
- package/test/debug-engine.test.mjs +351 -0
- package/test/harness.test.mjs +93 -0
- package/test/host-nogit.test.mjs +48 -0
- package/test/host-tail.test.mjs +2846 -0
- package/test/host-window.test.mjs +119 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// JDWP Command Sets and Commands
|
|
2
|
+
// Reference: https://docs.oracle.com/en/java/javase/17/docs/specs/jdwp/jdwp-protocol.html
|
|
3
|
+
export const HANDSHAKE = "JDWP-Handshake";
|
|
4
|
+
// Packet flags
|
|
5
|
+
export const FLAGS_REPLY = 0x80;
|
|
6
|
+
// Command Sets
|
|
7
|
+
export var CommandSet;
|
|
8
|
+
(function (CommandSet) {
|
|
9
|
+
CommandSet[CommandSet["VirtualMachine"] = 1] = "VirtualMachine";
|
|
10
|
+
CommandSet[CommandSet["ReferenceType"] = 2] = "ReferenceType";
|
|
11
|
+
CommandSet[CommandSet["ClassType"] = 3] = "ClassType";
|
|
12
|
+
CommandSet[CommandSet["ArrayType"] = 4] = "ArrayType";
|
|
13
|
+
CommandSet[CommandSet["InterfaceType"] = 5] = "InterfaceType";
|
|
14
|
+
CommandSet[CommandSet["Method"] = 6] = "Method";
|
|
15
|
+
CommandSet[CommandSet["Field"] = 8] = "Field";
|
|
16
|
+
CommandSet[CommandSet["ObjectReference"] = 9] = "ObjectReference";
|
|
17
|
+
CommandSet[CommandSet["StringReference"] = 10] = "StringReference";
|
|
18
|
+
CommandSet[CommandSet["ThreadReference"] = 11] = "ThreadReference";
|
|
19
|
+
CommandSet[CommandSet["ThreadGroupReference"] = 12] = "ThreadGroupReference";
|
|
20
|
+
CommandSet[CommandSet["ArrayReference"] = 13] = "ArrayReference";
|
|
21
|
+
CommandSet[CommandSet["ClassLoaderReference"] = 14] = "ClassLoaderReference";
|
|
22
|
+
CommandSet[CommandSet["EventRequest"] = 15] = "EventRequest";
|
|
23
|
+
CommandSet[CommandSet["StackFrame"] = 16] = "StackFrame";
|
|
24
|
+
CommandSet[CommandSet["ClassObjectReference"] = 17] = "ClassObjectReference";
|
|
25
|
+
CommandSet[CommandSet["ModuleReference"] = 18] = "ModuleReference";
|
|
26
|
+
CommandSet[CommandSet["Event"] = 64] = "Event";
|
|
27
|
+
})(CommandSet || (CommandSet = {}));
|
|
28
|
+
// VirtualMachine commands
|
|
29
|
+
export var VMCommand;
|
|
30
|
+
(function (VMCommand) {
|
|
31
|
+
VMCommand[VMCommand["Version"] = 1] = "Version";
|
|
32
|
+
VMCommand[VMCommand["ClassesBySignature"] = 2] = "ClassesBySignature";
|
|
33
|
+
VMCommand[VMCommand["AllClasses"] = 3] = "AllClasses";
|
|
34
|
+
VMCommand[VMCommand["AllThreads"] = 4] = "AllThreads";
|
|
35
|
+
VMCommand[VMCommand["TopLevelThreadGroups"] = 5] = "TopLevelThreadGroups";
|
|
36
|
+
VMCommand[VMCommand["Dispose"] = 6] = "Dispose";
|
|
37
|
+
VMCommand[VMCommand["IDSizes"] = 7] = "IDSizes";
|
|
38
|
+
VMCommand[VMCommand["Suspend"] = 8] = "Suspend";
|
|
39
|
+
VMCommand[VMCommand["Resume"] = 9] = "Resume";
|
|
40
|
+
VMCommand[VMCommand["Exit"] = 10] = "Exit";
|
|
41
|
+
VMCommand[VMCommand["CreateString"] = 11] = "CreateString";
|
|
42
|
+
VMCommand[VMCommand["Capabilities"] = 12] = "Capabilities";
|
|
43
|
+
VMCommand[VMCommand["ClassPaths"] = 13] = "ClassPaths";
|
|
44
|
+
VMCommand[VMCommand["DisposeObjects"] = 14] = "DisposeObjects";
|
|
45
|
+
VMCommand[VMCommand["HoldEvents"] = 15] = "HoldEvents";
|
|
46
|
+
VMCommand[VMCommand["ReleaseEvents"] = 16] = "ReleaseEvents";
|
|
47
|
+
VMCommand[VMCommand["CapabilitiesNew"] = 17] = "CapabilitiesNew";
|
|
48
|
+
VMCommand[VMCommand["RedefineClasses"] = 18] = "RedefineClasses";
|
|
49
|
+
VMCommand[VMCommand["SetDefaultStratum"] = 19] = "SetDefaultStratum";
|
|
50
|
+
VMCommand[VMCommand["AllClassesWithGeneric"] = 20] = "AllClassesWithGeneric";
|
|
51
|
+
VMCommand[VMCommand["InstanceCounts"] = 21] = "InstanceCounts";
|
|
52
|
+
VMCommand[VMCommand["AllModules"] = 22] = "AllModules";
|
|
53
|
+
})(VMCommand || (VMCommand = {}));
|
|
54
|
+
// ReferenceType commands
|
|
55
|
+
export var ReferenceTypeCommand;
|
|
56
|
+
(function (ReferenceTypeCommand) {
|
|
57
|
+
ReferenceTypeCommand[ReferenceTypeCommand["Signature"] = 1] = "Signature";
|
|
58
|
+
ReferenceTypeCommand[ReferenceTypeCommand["ClassLoader"] = 2] = "ClassLoader";
|
|
59
|
+
ReferenceTypeCommand[ReferenceTypeCommand["Modifiers"] = 3] = "Modifiers";
|
|
60
|
+
ReferenceTypeCommand[ReferenceTypeCommand["Fields"] = 4] = "Fields";
|
|
61
|
+
ReferenceTypeCommand[ReferenceTypeCommand["Methods"] = 5] = "Methods";
|
|
62
|
+
ReferenceTypeCommand[ReferenceTypeCommand["GetValues"] = 6] = "GetValues";
|
|
63
|
+
ReferenceTypeCommand[ReferenceTypeCommand["SourceFile"] = 7] = "SourceFile";
|
|
64
|
+
ReferenceTypeCommand[ReferenceTypeCommand["NestedTypes"] = 8] = "NestedTypes";
|
|
65
|
+
ReferenceTypeCommand[ReferenceTypeCommand["Status"] = 9] = "Status";
|
|
66
|
+
ReferenceTypeCommand[ReferenceTypeCommand["Interfaces"] = 10] = "Interfaces";
|
|
67
|
+
ReferenceTypeCommand[ReferenceTypeCommand["ClassObject"] = 11] = "ClassObject";
|
|
68
|
+
ReferenceTypeCommand[ReferenceTypeCommand["SourceDebugExtension"] = 12] = "SourceDebugExtension";
|
|
69
|
+
ReferenceTypeCommand[ReferenceTypeCommand["SignatureWithGeneric"] = 13] = "SignatureWithGeneric";
|
|
70
|
+
ReferenceTypeCommand[ReferenceTypeCommand["FieldsWithGeneric"] = 14] = "FieldsWithGeneric";
|
|
71
|
+
ReferenceTypeCommand[ReferenceTypeCommand["MethodsWithGeneric"] = 15] = "MethodsWithGeneric";
|
|
72
|
+
ReferenceTypeCommand[ReferenceTypeCommand["Instances"] = 16] = "Instances";
|
|
73
|
+
ReferenceTypeCommand[ReferenceTypeCommand["ClassFileVersion"] = 17] = "ClassFileVersion";
|
|
74
|
+
ReferenceTypeCommand[ReferenceTypeCommand["ConstantPool"] = 18] = "ConstantPool";
|
|
75
|
+
ReferenceTypeCommand[ReferenceTypeCommand["Module"] = 19] = "Module";
|
|
76
|
+
})(ReferenceTypeCommand || (ReferenceTypeCommand = {}));
|
|
77
|
+
// Method commands
|
|
78
|
+
export var MethodCommand;
|
|
79
|
+
(function (MethodCommand) {
|
|
80
|
+
MethodCommand[MethodCommand["LineTable"] = 1] = "LineTable";
|
|
81
|
+
MethodCommand[MethodCommand["VariableTable"] = 2] = "VariableTable";
|
|
82
|
+
MethodCommand[MethodCommand["Bytecodes"] = 3] = "Bytecodes";
|
|
83
|
+
MethodCommand[MethodCommand["IsObsolete"] = 4] = "IsObsolete";
|
|
84
|
+
MethodCommand[MethodCommand["VariableTableWithGeneric"] = 5] = "VariableTableWithGeneric";
|
|
85
|
+
})(MethodCommand || (MethodCommand = {}));
|
|
86
|
+
// ThreadReference commands
|
|
87
|
+
export var ThreadCommand;
|
|
88
|
+
(function (ThreadCommand) {
|
|
89
|
+
ThreadCommand[ThreadCommand["Name"] = 1] = "Name";
|
|
90
|
+
ThreadCommand[ThreadCommand["Suspend"] = 2] = "Suspend";
|
|
91
|
+
ThreadCommand[ThreadCommand["Resume"] = 3] = "Resume";
|
|
92
|
+
ThreadCommand[ThreadCommand["Status"] = 4] = "Status";
|
|
93
|
+
ThreadCommand[ThreadCommand["ThreadGroup"] = 5] = "ThreadGroup";
|
|
94
|
+
ThreadCommand[ThreadCommand["Frames"] = 6] = "Frames";
|
|
95
|
+
ThreadCommand[ThreadCommand["FrameCount"] = 7] = "FrameCount";
|
|
96
|
+
ThreadCommand[ThreadCommand["OwnedMonitors"] = 8] = "OwnedMonitors";
|
|
97
|
+
ThreadCommand[ThreadCommand["CurrentContendedMonitor"] = 9] = "CurrentContendedMonitor";
|
|
98
|
+
ThreadCommand[ThreadCommand["Stop"] = 10] = "Stop";
|
|
99
|
+
ThreadCommand[ThreadCommand["Interrupt"] = 11] = "Interrupt";
|
|
100
|
+
ThreadCommand[ThreadCommand["SuspendCount"] = 12] = "SuspendCount";
|
|
101
|
+
ThreadCommand[ThreadCommand["OwnedMonitorsStackDepthInfo"] = 13] = "OwnedMonitorsStackDepthInfo";
|
|
102
|
+
ThreadCommand[ThreadCommand["ForceEarlyReturn"] = 14] = "ForceEarlyReturn";
|
|
103
|
+
})(ThreadCommand || (ThreadCommand = {}));
|
|
104
|
+
// StackFrame commands
|
|
105
|
+
export var StackFrameCommand;
|
|
106
|
+
(function (StackFrameCommand) {
|
|
107
|
+
StackFrameCommand[StackFrameCommand["GetValues"] = 1] = "GetValues";
|
|
108
|
+
StackFrameCommand[StackFrameCommand["SetValues"] = 2] = "SetValues";
|
|
109
|
+
StackFrameCommand[StackFrameCommand["ThisObject"] = 3] = "ThisObject";
|
|
110
|
+
StackFrameCommand[StackFrameCommand["PopFrames"] = 4] = "PopFrames";
|
|
111
|
+
})(StackFrameCommand || (StackFrameCommand = {}));
|
|
112
|
+
// EventRequest commands
|
|
113
|
+
export var EventRequestCommand;
|
|
114
|
+
(function (EventRequestCommand) {
|
|
115
|
+
EventRequestCommand[EventRequestCommand["Set"] = 1] = "Set";
|
|
116
|
+
EventRequestCommand[EventRequestCommand["Clear"] = 2] = "Clear";
|
|
117
|
+
EventRequestCommand[EventRequestCommand["ClearAllBreakpoints"] = 3] = "ClearAllBreakpoints";
|
|
118
|
+
})(EventRequestCommand || (EventRequestCommand = {}));
|
|
119
|
+
// StringReference commands
|
|
120
|
+
export var StringReferenceCommand;
|
|
121
|
+
(function (StringReferenceCommand) {
|
|
122
|
+
StringReferenceCommand[StringReferenceCommand["Value"] = 1] = "Value";
|
|
123
|
+
})(StringReferenceCommand || (StringReferenceCommand = {}));
|
|
124
|
+
// ObjectReference commands
|
|
125
|
+
export var ObjectReferenceCommand;
|
|
126
|
+
(function (ObjectReferenceCommand) {
|
|
127
|
+
ObjectReferenceCommand[ObjectReferenceCommand["ReferenceType"] = 1] = "ReferenceType";
|
|
128
|
+
ObjectReferenceCommand[ObjectReferenceCommand["GetValues"] = 2] = "GetValues";
|
|
129
|
+
ObjectReferenceCommand[ObjectReferenceCommand["SetValues"] = 3] = "SetValues";
|
|
130
|
+
ObjectReferenceCommand[ObjectReferenceCommand["MonitorInfo"] = 5] = "MonitorInfo";
|
|
131
|
+
ObjectReferenceCommand[ObjectReferenceCommand["InvokeMethod"] = 6] = "InvokeMethod";
|
|
132
|
+
ObjectReferenceCommand[ObjectReferenceCommand["DisableCollection"] = 7] = "DisableCollection";
|
|
133
|
+
ObjectReferenceCommand[ObjectReferenceCommand["EnableCollection"] = 8] = "EnableCollection";
|
|
134
|
+
ObjectReferenceCommand[ObjectReferenceCommand["IsCollected"] = 9] = "IsCollected";
|
|
135
|
+
ObjectReferenceCommand[ObjectReferenceCommand["ReferringObjects"] = 10] = "ReferringObjects";
|
|
136
|
+
})(ObjectReferenceCommand || (ObjectReferenceCommand = {}));
|
|
137
|
+
// ArrayReference commands
|
|
138
|
+
export var ArrayReferenceCommand;
|
|
139
|
+
(function (ArrayReferenceCommand) {
|
|
140
|
+
ArrayReferenceCommand[ArrayReferenceCommand["Length"] = 1] = "Length";
|
|
141
|
+
ArrayReferenceCommand[ArrayReferenceCommand["GetValues"] = 2] = "GetValues";
|
|
142
|
+
ArrayReferenceCommand[ArrayReferenceCommand["SetValues"] = 3] = "SetValues";
|
|
143
|
+
})(ArrayReferenceCommand || (ArrayReferenceCommand = {}));
|
|
144
|
+
// Event kinds
|
|
145
|
+
export var EventKind;
|
|
146
|
+
(function (EventKind) {
|
|
147
|
+
EventKind[EventKind["SingleStep"] = 1] = "SingleStep";
|
|
148
|
+
EventKind[EventKind["Breakpoint"] = 2] = "Breakpoint";
|
|
149
|
+
EventKind[EventKind["FramePop"] = 3] = "FramePop";
|
|
150
|
+
EventKind[EventKind["Exception"] = 4] = "Exception";
|
|
151
|
+
EventKind[EventKind["UserDefined"] = 5] = "UserDefined";
|
|
152
|
+
EventKind[EventKind["ThreadStart"] = 6] = "ThreadStart";
|
|
153
|
+
EventKind[EventKind["ThreadDeath"] = 7] = "ThreadDeath";
|
|
154
|
+
EventKind[EventKind["ClassPrepare"] = 8] = "ClassPrepare";
|
|
155
|
+
EventKind[EventKind["ClassUnload"] = 9] = "ClassUnload";
|
|
156
|
+
EventKind[EventKind["ClassLoad"] = 10] = "ClassLoad";
|
|
157
|
+
EventKind[EventKind["FieldAccess"] = 20] = "FieldAccess";
|
|
158
|
+
EventKind[EventKind["FieldModification"] = 21] = "FieldModification";
|
|
159
|
+
EventKind[EventKind["ExceptionCatch"] = 30] = "ExceptionCatch";
|
|
160
|
+
EventKind[EventKind["MethodEntry"] = 40] = "MethodEntry";
|
|
161
|
+
EventKind[EventKind["MethodExit"] = 41] = "MethodExit";
|
|
162
|
+
EventKind[EventKind["MethodExitWithReturnValue"] = 42] = "MethodExitWithReturnValue";
|
|
163
|
+
EventKind[EventKind["MonitorContendedEnter"] = 43] = "MonitorContendedEnter";
|
|
164
|
+
EventKind[EventKind["MonitorContendedEntered"] = 44] = "MonitorContendedEntered";
|
|
165
|
+
EventKind[EventKind["MonitorWait"] = 45] = "MonitorWait";
|
|
166
|
+
EventKind[EventKind["MonitorWaited"] = 46] = "MonitorWaited";
|
|
167
|
+
EventKind[EventKind["VMStart"] = 90] = "VMStart";
|
|
168
|
+
EventKind[EventKind["VMDeath"] = 99] = "VMDeath";
|
|
169
|
+
})(EventKind || (EventKind = {}));
|
|
170
|
+
// Suspend policy
|
|
171
|
+
export var SuspendPolicy;
|
|
172
|
+
(function (SuspendPolicy) {
|
|
173
|
+
SuspendPolicy[SuspendPolicy["None"] = 0] = "None";
|
|
174
|
+
SuspendPolicy[SuspendPolicy["EventThread"] = 1] = "EventThread";
|
|
175
|
+
SuspendPolicy[SuspendPolicy["All"] = 2] = "All";
|
|
176
|
+
})(SuspendPolicy || (SuspendPolicy = {}));
|
|
177
|
+
// Step size
|
|
178
|
+
export var StepSize;
|
|
179
|
+
(function (StepSize) {
|
|
180
|
+
StepSize[StepSize["Min"] = 0] = "Min";
|
|
181
|
+
StepSize[StepSize["Line"] = 1] = "Line";
|
|
182
|
+
})(StepSize || (StepSize = {}));
|
|
183
|
+
// Step depth
|
|
184
|
+
export var StepDepth;
|
|
185
|
+
(function (StepDepth) {
|
|
186
|
+
StepDepth[StepDepth["Into"] = 0] = "Into";
|
|
187
|
+
StepDepth[StepDepth["Over"] = 1] = "Over";
|
|
188
|
+
StepDepth[StepDepth["Out"] = 2] = "Out";
|
|
189
|
+
})(StepDepth || (StepDepth = {}));
|
|
190
|
+
// Type tags
|
|
191
|
+
export var TypeTag;
|
|
192
|
+
(function (TypeTag) {
|
|
193
|
+
TypeTag[TypeTag["Class"] = 1] = "Class";
|
|
194
|
+
TypeTag[TypeTag["Interface"] = 2] = "Interface";
|
|
195
|
+
TypeTag[TypeTag["Array"] = 3] = "Array";
|
|
196
|
+
})(TypeTag || (TypeTag = {}));
|
|
197
|
+
// Tag values for primitive/object types
|
|
198
|
+
export var Tag;
|
|
199
|
+
(function (Tag) {
|
|
200
|
+
Tag[Tag["Array"] = 91] = "Array";
|
|
201
|
+
Tag[Tag["Byte"] = 66] = "Byte";
|
|
202
|
+
Tag[Tag["Char"] = 67] = "Char";
|
|
203
|
+
Tag[Tag["Object"] = 76] = "Object";
|
|
204
|
+
Tag[Tag["Float"] = 70] = "Float";
|
|
205
|
+
Tag[Tag["Double"] = 68] = "Double";
|
|
206
|
+
Tag[Tag["Int"] = 73] = "Int";
|
|
207
|
+
Tag[Tag["Long"] = 74] = "Long";
|
|
208
|
+
Tag[Tag["Short"] = 83] = "Short";
|
|
209
|
+
Tag[Tag["Void"] = 86] = "Void";
|
|
210
|
+
Tag[Tag["Boolean"] = 90] = "Boolean";
|
|
211
|
+
Tag[Tag["String"] = 115] = "String";
|
|
212
|
+
Tag[Tag["Thread"] = 116] = "Thread";
|
|
213
|
+
Tag[Tag["ThreadGroup"] = 103] = "ThreadGroup";
|
|
214
|
+
Tag[Tag["ClassLoader"] = 108] = "ClassLoader";
|
|
215
|
+
Tag[Tag["ClassObject"] = 99] = "ClassObject";
|
|
216
|
+
Tag[Tag["Null"] = 110] = "Null";
|
|
217
|
+
})(Tag || (Tag = {}));
|
|
218
|
+
// Thread status
|
|
219
|
+
export var ThreadStatus;
|
|
220
|
+
(function (ThreadStatus) {
|
|
221
|
+
ThreadStatus[ThreadStatus["Zombie"] = 0] = "Zombie";
|
|
222
|
+
ThreadStatus[ThreadStatus["Running"] = 1] = "Running";
|
|
223
|
+
ThreadStatus[ThreadStatus["Sleeping"] = 2] = "Sleeping";
|
|
224
|
+
ThreadStatus[ThreadStatus["Monitor"] = 3] = "Monitor";
|
|
225
|
+
ThreadStatus[ThreadStatus["Wait"] = 4] = "Wait";
|
|
226
|
+
})(ThreadStatus || (ThreadStatus = {}));
|
|
227
|
+
// Suspend status
|
|
228
|
+
export var SuspendStatus;
|
|
229
|
+
(function (SuspendStatus) {
|
|
230
|
+
SuspendStatus[SuspendStatus["Suspended"] = 1] = "Suspended";
|
|
231
|
+
})(SuspendStatus || (SuspendStatus = {}));
|
|
232
|
+
// Event modifier kinds
|
|
233
|
+
export var ModKind;
|
|
234
|
+
(function (ModKind) {
|
|
235
|
+
ModKind[ModKind["Count"] = 1] = "Count";
|
|
236
|
+
ModKind[ModKind["Conditional"] = 2] = "Conditional";
|
|
237
|
+
ModKind[ModKind["ThreadOnly"] = 3] = "ThreadOnly";
|
|
238
|
+
ModKind[ModKind["ClassOnly"] = 4] = "ClassOnly";
|
|
239
|
+
ModKind[ModKind["ClassMatch"] = 5] = "ClassMatch";
|
|
240
|
+
ModKind[ModKind["ClassExclude"] = 6] = "ClassExclude";
|
|
241
|
+
ModKind[ModKind["LocationOnly"] = 7] = "LocationOnly";
|
|
242
|
+
ModKind[ModKind["ExceptionOnly"] = 8] = "ExceptionOnly";
|
|
243
|
+
ModKind[ModKind["FieldOnly"] = 9] = "FieldOnly";
|
|
244
|
+
ModKind[ModKind["Step"] = 10] = "Step";
|
|
245
|
+
ModKind[ModKind["InstanceOnly"] = 11] = "InstanceOnly";
|
|
246
|
+
ModKind[ModKind["SourceNameMatch"] = 12] = "SourceNameMatch";
|
|
247
|
+
})(ModKind || (ModKind = {}));
|
|
248
|
+
// JDWP error codes
|
|
249
|
+
export var JDWPError;
|
|
250
|
+
(function (JDWPError) {
|
|
251
|
+
JDWPError[JDWPError["None"] = 0] = "None";
|
|
252
|
+
JDWPError[JDWPError["InvalidThread"] = 10] = "InvalidThread";
|
|
253
|
+
JDWPError[JDWPError["InvalidThreadGroup"] = 11] = "InvalidThreadGroup";
|
|
254
|
+
JDWPError[JDWPError["InvalidPriority"] = 12] = "InvalidPriority";
|
|
255
|
+
JDWPError[JDWPError["ThreadNotSuspended"] = 13] = "ThreadNotSuspended";
|
|
256
|
+
JDWPError[JDWPError["ThreadSuspended"] = 14] = "ThreadSuspended";
|
|
257
|
+
JDWPError[JDWPError["ThreadNotAlive"] = 15] = "ThreadNotAlive";
|
|
258
|
+
JDWPError[JDWPError["InvalidObject"] = 20] = "InvalidObject";
|
|
259
|
+
JDWPError[JDWPError["InvalidClass"] = 21] = "InvalidClass";
|
|
260
|
+
JDWPError[JDWPError["ClassNotPrepared"] = 22] = "ClassNotPrepared";
|
|
261
|
+
JDWPError[JDWPError["InvalidMethodid"] = 23] = "InvalidMethodid";
|
|
262
|
+
JDWPError[JDWPError["InvalidLocation"] = 24] = "InvalidLocation";
|
|
263
|
+
JDWPError[JDWPError["InvalidFieldid"] = 25] = "InvalidFieldid";
|
|
264
|
+
JDWPError[JDWPError["InvalidFrameid"] = 30] = "InvalidFrameid";
|
|
265
|
+
JDWPError[JDWPError["NoMoreFrames"] = 31] = "NoMoreFrames";
|
|
266
|
+
JDWPError[JDWPError["OpaqueFrame"] = 32] = "OpaqueFrame";
|
|
267
|
+
JDWPError[JDWPError["NotCurrentFrame"] = 33] = "NotCurrentFrame";
|
|
268
|
+
JDWPError[JDWPError["TypeMismatch"] = 34] = "TypeMismatch";
|
|
269
|
+
JDWPError[JDWPError["InvalidSlot"] = 35] = "InvalidSlot";
|
|
270
|
+
JDWPError[JDWPError["Duplicate"] = 40] = "Duplicate";
|
|
271
|
+
JDWPError[JDWPError["NotFound"] = 41] = "NotFound";
|
|
272
|
+
JDWPError[JDWPError["InvalidMonitor"] = 50] = "InvalidMonitor";
|
|
273
|
+
JDWPError[JDWPError["NotMonitorOwner"] = 51] = "NotMonitorOwner";
|
|
274
|
+
JDWPError[JDWPError["Interrupt"] = 52] = "Interrupt";
|
|
275
|
+
JDWPError[JDWPError["InvalidClassFormat"] = 60] = "InvalidClassFormat";
|
|
276
|
+
JDWPError[JDWPError["CircularClassDefinition"] = 61] = "CircularClassDefinition";
|
|
277
|
+
JDWPError[JDWPError["FailsVerification"] = 62] = "FailsVerification";
|
|
278
|
+
JDWPError[JDWPError["AddMethodNotImplemented"] = 63] = "AddMethodNotImplemented";
|
|
279
|
+
JDWPError[JDWPError["SchemaChangeNotImplemented"] = 64] = "SchemaChangeNotImplemented";
|
|
280
|
+
JDWPError[JDWPError["InvalidTypestate"] = 65] = "InvalidTypestate";
|
|
281
|
+
JDWPError[JDWPError["HierarchyChangeNotImplemented"] = 66] = "HierarchyChangeNotImplemented";
|
|
282
|
+
JDWPError[JDWPError["DeleteMethodNotImplemented"] = 67] = "DeleteMethodNotImplemented";
|
|
283
|
+
JDWPError[JDWPError["UnsupportedVersion"] = 68] = "UnsupportedVersion";
|
|
284
|
+
JDWPError[JDWPError["NamesMismatch"] = 69] = "NamesMismatch";
|
|
285
|
+
JDWPError[JDWPError["ClassModifiersChangeNotImplemented"] = 70] = "ClassModifiersChangeNotImplemented";
|
|
286
|
+
JDWPError[JDWPError["MethodModifiersChangeNotImplemented"] = 71] = "MethodModifiersChangeNotImplemented";
|
|
287
|
+
JDWPError[JDWPError["NotImplemented"] = 99] = "NotImplemented";
|
|
288
|
+
JDWPError[JDWPError["NullPointer"] = 100] = "NullPointer";
|
|
289
|
+
JDWPError[JDWPError["AbsentInformation"] = 101] = "AbsentInformation";
|
|
290
|
+
JDWPError[JDWPError["InvalidEventType"] = 102] = "InvalidEventType";
|
|
291
|
+
JDWPError[JDWPError["IllegalArgument"] = 103] = "IllegalArgument";
|
|
292
|
+
JDWPError[JDWPError["OutOfMemory"] = 110] = "OutOfMemory";
|
|
293
|
+
JDWPError[JDWPError["AccessDenied"] = 111] = "AccessDenied";
|
|
294
|
+
JDWPError[JDWPError["VmDead"] = 112] = "VmDead";
|
|
295
|
+
JDWPError[JDWPError["Internal"] = 113] = "Internal";
|
|
296
|
+
JDWPError[JDWPError["UnattachedThread"] = 115] = "UnattachedThread";
|
|
297
|
+
JDWPError[JDWPError["InvalidTag"] = 500] = "InvalidTag";
|
|
298
|
+
JDWPError[JDWPError["AlreadyInvoking"] = 502] = "AlreadyInvoking";
|
|
299
|
+
JDWPError[JDWPError["InvalidIndex"] = 503] = "InvalidIndex";
|
|
300
|
+
JDWPError[JDWPError["InvalidLength"] = 504] = "InvalidLength";
|
|
301
|
+
JDWPError[JDWPError["InvalidString"] = 506] = "InvalidString";
|
|
302
|
+
JDWPError[JDWPError["InvalidClassLoader"] = 507] = "InvalidClassLoader";
|
|
303
|
+
JDWPError[JDWPError["InvalidArray"] = 508] = "InvalidArray";
|
|
304
|
+
JDWPError[JDWPError["TransportLoad"] = 509] = "TransportLoad";
|
|
305
|
+
JDWPError[JDWPError["TransportInit"] = 510] = "TransportInit";
|
|
306
|
+
JDWPError[JDWPError["NativeMethod"] = 511] = "NativeMethod";
|
|
307
|
+
JDWPError[JDWPError["InvalidCount"] = 512] = "InvalidCount";
|
|
308
|
+
})(JDWPError || (JDWPError = {}));
|
|
309
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { FLAGS_REPLY, Tag } from "./constants.js";
|
|
2
|
+
const defaultIDSizes = {
|
|
3
|
+
fieldIDSize: 8,
|
|
4
|
+
methodIDSize: 8,
|
|
5
|
+
objectIDSize: 8,
|
|
6
|
+
referenceTypeIDSize: 8,
|
|
7
|
+
frameIDSize: 8,
|
|
8
|
+
};
|
|
9
|
+
// Buffer writer for building JDWP data
|
|
10
|
+
export class JDWPWriter {
|
|
11
|
+
buffers = [];
|
|
12
|
+
idSizes;
|
|
13
|
+
constructor(idSizes = defaultIDSizes) {
|
|
14
|
+
this.idSizes = idSizes;
|
|
15
|
+
}
|
|
16
|
+
writeByte(value) {
|
|
17
|
+
const buf = Buffer.alloc(1);
|
|
18
|
+
buf.writeInt8(value, 0);
|
|
19
|
+
this.buffers.push(buf);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
writeBoolean(value) {
|
|
23
|
+
return this.writeByte(value ? 1 : 0);
|
|
24
|
+
}
|
|
25
|
+
writeShort(value) {
|
|
26
|
+
const buf = Buffer.alloc(2);
|
|
27
|
+
buf.writeInt16BE(value, 0);
|
|
28
|
+
this.buffers.push(buf);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
writeInt(value) {
|
|
32
|
+
const buf = Buffer.alloc(4);
|
|
33
|
+
buf.writeInt32BE(value, 0);
|
|
34
|
+
this.buffers.push(buf);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
writeLong(value) {
|
|
38
|
+
const buf = Buffer.alloc(8);
|
|
39
|
+
buf.writeBigInt64BE(value, 0);
|
|
40
|
+
this.buffers.push(buf);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
writeID(value, size) {
|
|
44
|
+
const buf = Buffer.alloc(size);
|
|
45
|
+
// Write big-endian, right-aligned
|
|
46
|
+
for (let i = size - 1; i >= 0; i--) {
|
|
47
|
+
buf[i] = Number(value & 0xffn);
|
|
48
|
+
value >>= 8n;
|
|
49
|
+
}
|
|
50
|
+
this.buffers.push(buf);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
writeObjectID(value) {
|
|
54
|
+
return this.writeID(value, this.idSizes.objectIDSize);
|
|
55
|
+
}
|
|
56
|
+
writeReferenceTypeID(value) {
|
|
57
|
+
return this.writeID(value, this.idSizes.referenceTypeIDSize);
|
|
58
|
+
}
|
|
59
|
+
writeMethodID(value) {
|
|
60
|
+
return this.writeID(value, this.idSizes.methodIDSize);
|
|
61
|
+
}
|
|
62
|
+
writeFieldID(value) {
|
|
63
|
+
return this.writeID(value, this.idSizes.fieldIDSize);
|
|
64
|
+
}
|
|
65
|
+
writeFrameID(value) {
|
|
66
|
+
return this.writeID(value, this.idSizes.frameIDSize);
|
|
67
|
+
}
|
|
68
|
+
writeThreadID(value) {
|
|
69
|
+
return this.writeObjectID(value);
|
|
70
|
+
}
|
|
71
|
+
writeString(value) {
|
|
72
|
+
const strBuf = Buffer.from(value, "utf-8");
|
|
73
|
+
this.writeInt(strBuf.length);
|
|
74
|
+
this.buffers.push(strBuf);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
writeLocation(typeTag, classID, methodID, index) {
|
|
78
|
+
this.writeByte(typeTag);
|
|
79
|
+
this.writeReferenceTypeID(classID);
|
|
80
|
+
this.writeMethodID(methodID);
|
|
81
|
+
this.writeLong(index);
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
toBuffer() {
|
|
85
|
+
return Buffer.concat(this.buffers);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Buffer reader for parsing JDWP data
|
|
89
|
+
export class JDWPReader {
|
|
90
|
+
buffer;
|
|
91
|
+
offset = 0;
|
|
92
|
+
idSizes;
|
|
93
|
+
constructor(buffer, idSizes = defaultIDSizes) {
|
|
94
|
+
this.buffer = buffer;
|
|
95
|
+
this.idSizes = idSizes;
|
|
96
|
+
}
|
|
97
|
+
get remaining() {
|
|
98
|
+
return this.buffer.length - this.offset;
|
|
99
|
+
}
|
|
100
|
+
readByte() {
|
|
101
|
+
const value = this.buffer.readInt8(this.offset);
|
|
102
|
+
this.offset += 1;
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
readBoolean() {
|
|
106
|
+
return this.readByte() !== 0;
|
|
107
|
+
}
|
|
108
|
+
readShort() {
|
|
109
|
+
const value = this.buffer.readInt16BE(this.offset);
|
|
110
|
+
this.offset += 2;
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
readInt() {
|
|
114
|
+
const value = this.buffer.readInt32BE(this.offset);
|
|
115
|
+
this.offset += 4;
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
readLong() {
|
|
119
|
+
const value = this.buffer.readBigInt64BE(this.offset);
|
|
120
|
+
this.offset += 8;
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
readID(size) {
|
|
124
|
+
let value = 0n;
|
|
125
|
+
for (let i = 0; i < size; i++) {
|
|
126
|
+
value = (value << 8n) | BigInt(this.buffer[this.offset + i]);
|
|
127
|
+
}
|
|
128
|
+
this.offset += size;
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
readObjectID() {
|
|
132
|
+
return this.readID(this.idSizes.objectIDSize);
|
|
133
|
+
}
|
|
134
|
+
readReferenceTypeID() {
|
|
135
|
+
return this.readID(this.idSizes.referenceTypeIDSize);
|
|
136
|
+
}
|
|
137
|
+
readMethodID() {
|
|
138
|
+
return this.readID(this.idSizes.methodIDSize);
|
|
139
|
+
}
|
|
140
|
+
readFieldID() {
|
|
141
|
+
return this.readID(this.idSizes.fieldIDSize);
|
|
142
|
+
}
|
|
143
|
+
readFrameID() {
|
|
144
|
+
return this.readID(this.idSizes.frameIDSize);
|
|
145
|
+
}
|
|
146
|
+
readThreadID() {
|
|
147
|
+
return this.readObjectID();
|
|
148
|
+
}
|
|
149
|
+
readString() {
|
|
150
|
+
const length = this.readInt();
|
|
151
|
+
const value = this.buffer.toString("utf-8", this.offset, this.offset + length);
|
|
152
|
+
this.offset += length;
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
readLocation() {
|
|
156
|
+
const typeTag = this.readByte();
|
|
157
|
+
const classID = this.readReferenceTypeID();
|
|
158
|
+
const methodID = this.readMethodID();
|
|
159
|
+
const index = this.readLong();
|
|
160
|
+
return { typeTag, classID, methodID, index };
|
|
161
|
+
}
|
|
162
|
+
readTaggedObjectID() {
|
|
163
|
+
const tag = this.readByte();
|
|
164
|
+
const objectID = this.readObjectID();
|
|
165
|
+
return { tag, objectID };
|
|
166
|
+
}
|
|
167
|
+
readValue(tag) {
|
|
168
|
+
switch (tag) {
|
|
169
|
+
case Tag.Byte:
|
|
170
|
+
return { tag, value: this.readByte() };
|
|
171
|
+
case Tag.Boolean:
|
|
172
|
+
return { tag, value: this.readBoolean() };
|
|
173
|
+
case Tag.Char:
|
|
174
|
+
return { tag, value: String.fromCharCode(this.readShort() & 0xffff) };
|
|
175
|
+
case Tag.Short:
|
|
176
|
+
return { tag, value: this.readShort() };
|
|
177
|
+
case Tag.Int:
|
|
178
|
+
return { tag, value: this.readInt() };
|
|
179
|
+
case Tag.Long:
|
|
180
|
+
return { tag, value: this.readLong() };
|
|
181
|
+
case Tag.Float: {
|
|
182
|
+
const buf = this.buffer.subarray(this.offset, this.offset + 4);
|
|
183
|
+
this.offset += 4;
|
|
184
|
+
return { tag, value: buf.readFloatBE(0) };
|
|
185
|
+
}
|
|
186
|
+
case Tag.Double: {
|
|
187
|
+
const buf = this.buffer.subarray(this.offset, this.offset + 8);
|
|
188
|
+
this.offset += 8;
|
|
189
|
+
return { tag, value: buf.readDoubleBE(0) };
|
|
190
|
+
}
|
|
191
|
+
case Tag.Void:
|
|
192
|
+
return { tag, value: null };
|
|
193
|
+
case Tag.Null:
|
|
194
|
+
return { tag, value: null };
|
|
195
|
+
case Tag.String:
|
|
196
|
+
case Tag.Object:
|
|
197
|
+
case Tag.Array:
|
|
198
|
+
case Tag.Thread:
|
|
199
|
+
case Tag.ThreadGroup:
|
|
200
|
+
case Tag.ClassLoader:
|
|
201
|
+
case Tag.ClassObject:
|
|
202
|
+
return { tag, value: this.readObjectID() };
|
|
203
|
+
default:
|
|
204
|
+
return { tag, value: this.readObjectID() };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
readUntaggedValue(tag) {
|
|
208
|
+
return this.readValue(tag);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Build a command packet
|
|
212
|
+
export function buildCommandPacket(id, commandSet, command, data = Buffer.alloc(0)) {
|
|
213
|
+
const length = 11 + data.length;
|
|
214
|
+
const header = Buffer.alloc(11);
|
|
215
|
+
header.writeInt32BE(length, 0);
|
|
216
|
+
header.writeInt32BE(id, 4);
|
|
217
|
+
header.writeUInt8(0, 8); // flags
|
|
218
|
+
header.writeUInt8(commandSet, 9);
|
|
219
|
+
header.writeUInt8(command, 10);
|
|
220
|
+
return Buffer.concat([header, data]);
|
|
221
|
+
}
|
|
222
|
+
// Parse a reply packet from buffer
|
|
223
|
+
export function parseReplyPacket(buffer) {
|
|
224
|
+
if (buffer.length < 11)
|
|
225
|
+
return null;
|
|
226
|
+
const length = buffer.readInt32BE(0);
|
|
227
|
+
if (buffer.length < length)
|
|
228
|
+
return null;
|
|
229
|
+
return {
|
|
230
|
+
id: buffer.readInt32BE(4),
|
|
231
|
+
flags: buffer.readUInt8(8),
|
|
232
|
+
errorCode: buffer.readUInt16BE(9),
|
|
233
|
+
data: buffer.subarray(11, length),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
// Check if buffer has a complete packet
|
|
237
|
+
export function hasCompletePacket(buffer) {
|
|
238
|
+
if (buffer.length < 4)
|
|
239
|
+
return false;
|
|
240
|
+
const length = buffer.readInt32BE(0);
|
|
241
|
+
return buffer.length >= length;
|
|
242
|
+
}
|
|
243
|
+
export function getPacketLength(buffer) {
|
|
244
|
+
if (buffer.length < 4)
|
|
245
|
+
return -1;
|
|
246
|
+
return buffer.readInt32BE(0);
|
|
247
|
+
}
|
|
248
|
+
export function isReplyPacket(buffer) {
|
|
249
|
+
if (buffer.length < 9)
|
|
250
|
+
return false;
|
|
251
|
+
return (buffer.readUInt8(8) & FLAGS_REPLY) !== 0;
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=protocol.js.map
|