-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathChakraDebug.pas
More file actions
571 lines (517 loc) · 14.9 KB
/
ChakraDebug.pas
File metadata and controls
571 lines (517 loc) · 14.9 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
unit ChakraDebug;
interface
uses ChakraCommon;
type
JsDiagDebugEvent = (
JsDiagDebugEventSourceCompile = 0,
JsDiagDebugEventCompileError = 1,
JsDiagDebugEventBreakpoint = 2,
JsDiagDebugEventStepComplete = 3,
JsDiagDebugEventDebuggerStatement = 4,
JsDiagDebugEventAsyncBreak = 5,
JsDiagDebugEventRuntimeException = 6
);
JsDiagBreakOnExceptionAttributes = (
JsDiagBreakOnExceptionAttributeNone = $0,
JsDiagBreakOnExceptionAttributeUncaught = $1,
JsDiagBreakOnExceptionAttributeFirstChance = $2
);
JsDiagStepType = (
JsDiagStepTypeStepIn = 0,
JsDiagStepTypeStepOut = 1,
JsDiagStepTypeStepOver = 2,
JsDiagStepTypeStepBack = 3
);
{
typedef void (CHAKRA_CALLBACK * JsDiagDebugEventCallback)(
_In_ JsDiagDebugEvent debugEvent,
_In_ JsValueRef eventData,
_In_opt_ void* callbackState
);
}
JsDiagDebugEventCallback = procedure(
debugEvent: JsDiagDebugEvent;
eventData: JsValueRef;
callbackState: Pointer
); stdcall;
{
CHAKRA_API
JsDiagStartDebugging(
_In_ JsRuntimeHandle runtimeHandle,
_In_ JsDiagDebugEventCallback debugEventCallback,
_In_opt_ void* callbackState);
}
function JsDiagStartDebugging(
runtimeHandle: JsRuntimeHandle;
debugEventCallback: JsDiagDebugEventCallback;
callbackState: Pointer
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagStopDebugging(
_In_ JsRuntimeHandle runtimeHandle,
_Out_ void** callbackState);
}
function JsDiagStopDebugging(
runtimeHandle: JsRuntimeHandle;
var callbackState: Pointer
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagRequestAsyncBreak(
_In_ JsRuntimeHandle runtimeHandle);
}
function JsDiagRequestAsyncBreak(
runtimeHandle: JsRuntimeHandle
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetBreakpoints(
_Out_ JsValueRef *breakpoints);
}
function JsDiagGetBreakpoints(
var breakpoints: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagSetBreakpoint(
_In_ unsigned int scriptId,
_In_ unsigned int lineNumber,
_In_ unsigned int columnNumber,
_Out_ JsValueRef *breakpoint);
}
function JsDiagSetBreakpoint(
scriptId: uint;
lineNumber: uint;
columnNumber: uint;
var breakpoint: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagRemoveBreakpoint(
_In_ unsigned int breakpointId);
}
function JsDiagRemoveBreakpoint(
breakpointId: uint
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagSetBreakOnException(
_In_ JsRuntimeHandle runtimeHandle,
_In_ JsDiagBreakOnExceptionAttributes exceptionAttributes);
}
function JsDiagSetBreakOnException(
runtimeHandle: JsRuntimeHandle;
exceptionAttributes: JsDiagBreakOnExceptionAttributes
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetBreakOnException(
_In_ JsRuntimeHandle runtimeHandle,
_Out_ JsDiagBreakOnExceptionAttributes* exceptionAttributes);
}
function JsDiagGetBreakOnException(
runtimeHandle: JsRuntimeHandle;
var exceptionAttributes: JsDiagBreakOnExceptionAttributes
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagSetStepType(
_In_ JsDiagStepType stepType);
}
function JsDiagSetStepType(
stepType: JsDiagStepType
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetScripts(
_Out_ JsValueRef *scriptsArray);
}
function JsDiagGetScripts(
var scriptsArray: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetSource(
_In_ unsigned int scriptId,
_Out_ JsValueRef *source);
}
function JsDiagGetSource(
scriptId: uint;
var source: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetFunctionPosition(
_In_ JsValueRef function,
_Out_ JsValueRef *functionPosition);
}
function JsDiagGetFunctionPosition(
_function: JsValueRef;
functionPosition: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetStackTrace(
_Out_ JsValueRef *stackTrace);
}
function JsDiagGetStackTrace(
var stackTrace: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetStackProperties(
_In_ unsigned int stackFrameIndex,
_Out_ JsValueRef *properties);
}
function JsDiagGetStackProperties(
stackFrameIndex: uint;
var properties: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetProperties(
_In_ unsigned int objectHandle,
_In_ unsigned int fromCount,
_In_ unsigned int totalCount,
_Out_ JsValueRef *propertiesObject);
}
function JsDiagGetProperties(
objectHandle: uint;
fromCount: uint;
totalCount: uint;
var propertiesObject: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsDiagGetObjectFromHandle(
_In_ unsigned int objectHandle,
_Out_ JsValueRef *handleObject);
}
function JsDiagGetObjectFromHandle(
objectHandle: uint;
var handleObject: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{$ifdef WIN32}
{
CHAKRA_API
JsDiagEvaluate(
_In_z_ const wchar_t *expression,
_In_ unsigned int stackFrameIndex,
_Out_ JsValueRef *evalResult);
}
function JsDiagEvaluate(
const expression: pwchar_t;
stackFrameIndex: uint;
var evalResult: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
{$endif}
{
CHAKRA_API JsDiagEvaluateUtf8(
_In_z_ const char *expression,
_In_ unsigned int stackFrameIndex,
_Out_ JsValueRef *evalResult);
}
function JsDiagEvaluateUtf8(
const expression: PChar;
stackFrameIndex: uint;
var evalResult: JsValueRef
): JsErrorCode; stdcall; external DLL_NAME;
type
JsTTDMoveMode{ : int64_t} = (
JsTTDMoveNone = $0,
JsTTDMoveFirstEvent = $1,
JsTTDMoveLastEvent = $2,
JsTTDMoveKthEvent = $4,
JsTTDMoveScanIntervalBeforeDebugExecute = $10,
JsTTDMoveScanIntervalForContinue = $20,
JsTTDMoveBreakOnEntry = $100
);
JsTTDStreamHandle = Pointer;
{
typedef void (CHAKRA_CALLBACK *JsTTDInitializeForWriteLogStreamCallback)(
_In_ size_t uriByteLength,
_In_reads_(uriByteLength) const byte* uriBytes
);
}
JsTTDInitializeForWriteLogStreamCallback = procedure(
uriByteLength: size_t;
const uriBytes: PByte
); stdcall;
{
typedef JsTTDStreamHandle (CHAKRA_CALLBACK *TTDOpenResourceStreamCallback)(
_In_ size_t uriByteLength,
_In_reads_(uriByteLength) const byte* uriBytes,
_In_z_ const char* asciiResourceName,
_In_ bool read,
_In_ bool write
);
}
TTDOpenResourceStreamCallback = function(
uriByteLength: size_t;
const uriBytes: PByte;
const asciiResourceName: PChar;
read: bool;
write: bool
): JsTTDStreamHandle; stdcall;
{
typedef bool (CHAKRA_CALLBACK *JsTTDReadBytesFromStreamCallback)(
_In_ JsTTDStreamHandle handle,
_Out_writes_(size) byte* buff,
_In_ size_t size,
_Out_ size_t* readCount
);
}
JsTTDReadBytesFromStreamCallback = function(
handle: JsTTDStreamHandle;
buff: PByte;
size: size_t;
var readCount: size_t
): bool; stdcall;
{
typedef bool (CHAKRA_CALLBACK *JsTTDWriteBytesToStreamCallback)(
_In_ JsTTDStreamHandle handle,
_In_reads_(size) const byte* buff,
_In_ size_t size,
_Out_ size_t* writtenCount
);
}
JsTTDWriteBytesToStreamCallback = function(
handle: JsTTDStreamHandle;
buff: PByte;
size: size_t;
var writtenCount: size_t
): bool; stdcall;
{
typedef void (CHAKRA_CALLBACK *JsTTDFlushAndCloseStreamCallback)(
_In_ JsTTDStreamHandle handle,
_In_ bool read,
_In_ bool write
);
}
JsTTDFlushAndCloseStreamCallback = procedure(
handle: JsTTDStreamHandle;
read: bool;
write: bool
); stdcall;
{
CHAKRA_API
JsTTDCreateRecordRuntime(
_In_ JsRuntimeAttributes attributes,
_In_reads_(infoUriCount) const byte* infoUri,
_In_ size_t infoUriCount,
_In_ size_t snapInterval,
_In_ size_t snapHistoryLength,
_In_opt_ JsThreadServiceCallback threadService,
_Out_ JsRuntimeHandle *runtime);
}
function JsTTDCreateRecordRuntime(
attributes: JsRuntimeAttributes;
const infoUri: PByte;
infoUriCount: size_t;
snapInterval: size_t;
snapHistoryLength: size_t;
threadService: JsThreadServiceCallback;
var runtime: JsRuntimeHandle
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDCreateDebugRuntime(
_In_ JsRuntimeAttributes attributes,
_In_reads_(infoUriCount) const byte* infoUri,
_In_ size_t infoUriCount,
_In_opt_ JsThreadServiceCallback threadService,
_Out_ JsRuntimeHandle *runtime);
}
function JsTTDCreateDebugRuntime(
attributes: JsRuntimeAttributes;
const infoUri: PByte;
infoUriCount: size_t;
threadService: JsThreadServiceCallback;
var runtime: JsRuntimeHandle
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDCreateContext(
_In_ JsRuntimeHandle runtime,
_Out_ JsContextRef *newContext);
}
function JsTTDCreateContext(
runtime: JsRuntimeHandle;
var newContext: JsContextRef
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDSetIOCallbacks(
_In_ JsRuntimeHandle runtime,
_In_ JsTTDInitializeForWriteLogStreamCallback writeInitializeFunction,
_In_ TTDOpenResourceStreamCallback openResourceStream,
_In_ JsTTDReadBytesFromStreamCallback readBytesFromStream,
_In_ JsTTDWriteBytesToStreamCallback writeBytesToStream,
_In_ JsTTDFlushAndCloseStreamCallback flushAndCloseStream);
}
function JsTTDSetIOCallbacks(
runtime: JsRuntimeHandle;
writeInitializeFunction: JsTTDInitializeForWriteLogStreamCallback;
openResourceStream: TTDOpenResourceStreamCallback;
readBytesFromStream: JsTTDReadBytesFromStreamCallback;
writeBytesToStream: JsTTDWriteBytesToStreamCallback;
flushAndCloseStream: JsTTDFlushAndCloseStreamCallback
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDStartTimeTravelRecording();
}
function JsTTDStartTimeTravelRecording(
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDStopTimeTravelRecording();
}
function JsTTDStopTimeTravelRecording(
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDEmitTimeTravelRecording();
}
function JsTTDEmitTimeTravelRecording(
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDStartTimeTravelDebugging();
}
function JsTTDStartTimeTravelDebugging(
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDPauseTimeTravelBeforeRuntimeOperation();
}
function JsTTDPauseTimeTravelBeforeRuntimeOperation(
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDReStartTimeTravelAfterRuntimeOperation();
}
function JsTTDReStartTimeTravelAfterRuntimeOperation(
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDNotifyYield();
}
function JsTTDNotifyYield(
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDHostExit(_In_ int statusCode);
}
function JsTTDHostExit(
statusCode: int
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDRawBufferCopySyncIndirect(
_In_ JsValueRef dst,
_In_ size_t dstIndex,
_In_ JsValueRef src,
_In_ size_t srcIndex,
_In_ size_t count);
}
function JsTTDRawBufferCopySyncIndirect(
dst: JsValueRef;
dstIndex: size_t;
src: JsValueRef;
srcIndex: size_t;
count: size_t
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDRawBufferModifySyncIndirect(
_In_ JsValueRef buffer,
_In_ size_t index,
_In_ size_t count);
}
function JsTTDRawBufferModifySyncIndirect(
buffer: JsValueRef;
index: size_t;
count: size_t
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDRawBufferAsyncModificationRegister(
_In_ JsValueRef instance,
_In_ byte* initialModPos);
}
function JsTTDRawBufferAsyncModificationRegister(
instance: JsValueRef;
initialModPos: PByte
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDRawBufferAsyncModifyComplete(
_In_ byte* finalModPos);
}
function JsTTDRawBufferAsyncModifyComplete(
finalModPos: PByte
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API JsTTDGetSnapTimeTopLevelEventMove(
_In_ JsRuntimeHandle runtimeHandle,
_In_ JsTTDMoveMode moveMode,
_Inout_ int64_t* targetEventTime,
_Out_ bool* createFreshCxts,
_Out_ int64_t* targetStartSnapTime,
_Out_opt_ int64_t* targetEndSnapTime);
}
function JsTTDGetSnapTimeTopLevelEventMove(
runtimeHandle: JsRuntimeHandle;
moveMode: JsTTDMoveMode;
var targetEventTime: int64_t;
var createFreshCxts: bool;
var targetStartSnapTime: int64_t;
var targetEndSnapTime: int64_t
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDPrepContextsForTopLevelEventMove(
_In_ JsRuntimeHandle runtimeHandle,
_In_ bool createFreshCtxs);
}
function JsTTDPrepContextsForTopLevelEventMove(
runtimeHandle: JsRuntimeHandle;
createFreshCtxs: bool
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API JsTTDPreExecuteSnapShotInterval(
_In_ int64_t startSnapTime,
_In_ int64_t endSnapTime,
_In_ JsTTDMoveMode moveMode);
}
function JsTTDPreExecuteSnapShotInterval(
startSnapTime: int64_t;
endSnapTime: int64_t;
moveMode: JsTTDMoveMode
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDMoveToTopLevelEvent(
_In_ JsTTDMoveMode moveMode,
_In_ int64_t snapshotTime,
_In_ int64_t eventTime);
}
function JsTTDMoveToTopLevelEvent(
moveMode: JsTTDMoveMode;
snapshotTime: int64_t;
eventTime: int64_t
): JsErrorCode; stdcall; external DLL_NAME;
{
CHAKRA_API
JsTTDReplayExecution(
_Inout_ JsTTDMoveMode* moveMode,
_Inout_ int64_t* rootEventTime);
}
function JsTTDReplayExecution(
var moveMode: JsTTDMoveMode;
var rootEventTime: int64_t
): JsErrorCode; stdcall; external DLL_NAME;
implementation
end.