forked from WebAssembly/debugging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebugging-modules.webidl
224 lines (200 loc) · 6.33 KB
/
debugging-modules.webidl
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
typedef unsigned long WasmBreakpointId;
typedef unsigned long WasmCodeOffset;
typedef unsigned long SourceBreakpointId;
typedef unsigned long SourceLine;
typedef unsigned long SourceColumn;
typedef DOMString SourceFilename;
typedef DOMString SourceFunctionName;
/**
* The raw debugging APIs for a Wasm module.
*
* Implementations of this interface are provided by the Wasm engine, and called
* by user-provided implementations of `SourceDebugger`.
*/
interface WasmDebugger {
/**
* Set a breakpoint at the instruction at the given offset into the Code
* section.
*
* Execution should be paused when reaching this offset, but before
* evaluating its associated instruction.
*/
WasmBreakpointId? setBreakpoint(WasmCodeOffset offset);
/**
* Clear a breakpoint that was previously set.
*/
void clearBreakpoint(WasmBreakpointId breakpoint);
/**
* Get the contents of a custom section, if it exists in this module.
*
* `SourceDebugger` implementations may use this method to read encoded line
* tables or other debug information from the Wasm module.
*/
ArrayBuffer? getCustomSection(USVString customSectionName);
};
/**
* Options provided by the debugger when requesting that a `SourceDebugger` set
* a breakpoint.
*/
dictionary SourceBreakpointOptions {
required SourceFilename filename;
required SourceLine line;
SourceLine column;
};
/**
* Information about a Wasm breakpoint that has been hit.
*/
dictionary WasmBreakInfo {
required WasmBreakpointId breakpoint;
};
/**
* The kind of source-level action to take after hitting a Wasm breakpoint.
*/
enum SourceBreakResultKind {
/**
* Continue execution and ignore the breakpoint.
*/
"Continue",
/**
* Pause execution because we hit a source-level breakpoint or did a step.
*/
"Pause",
};
/**
* How a Wasm breakpoint in the debuggee should be handled.
*/
dictionary SourceBreakResult {
/**
* The kind of action that should be taken: should the debuggee pause at a
* source-level breakpoint or continue execution?
*/
required SourceBreakResultKind kind;
/**
* If the `kind` is `"Pause"`, this is the source-level breakpoint that the
* debuggee is paused at, if we hit a breakpoint.
*/
SourceBreakpointId breakpoint;
/**
* If the `kind` is `"Pause"`, this is the source location where execution
* is paused at.
*/
SourceLocation location;
};
/**
* What kind of step should be taken.
*/
enum SourceStepKind {
/**
* If currently paused before a function call, continue to the first
* expression of that function. Otherwise, continue execution until the next
* line of code.
*/
"Into",
/**
* Continue execution until the next line of code.
*/
"Over",
/**
* Continue execution until the function returns.
*/
"Out",
};
dictionary SourceStepOptions {
required SourceStepKind kind;
};
/**
* A range within a source file.
*
* Inclusive of `startLine:startColumn`, and exclusive of `endLine:endColumn`.
*/
dictionary SourceRange {
required SourceFilename filename;
SourceFunctionName function;
required SourceLine startLine;
required SourceColumn startColumn;
required SourceLine endLine;
required SourceColumn endColumn;
};
/**
* A location inside some source text.
*/
dictionary SourceLocation {
required SourceFilename filename;
required SourceLine line;
SourceColumn column;
};
/**
* A range of instructions within a Wasm module's Code section.
*
* Inclusive of `start`, and exclusive of `end`.
*/
dictionary WasmCodeRange {
required WasmCodeOffset start;
required WasmCodeOffset end;
};
/**
* Source-level debugging APIs for a Wasm module.
*
* Debugging modules provide an implementation of this interface, wrapping and
* translating the given `WasmDebugger`'s raw Wasm-level debugging APIs into
* source-level debugging APIs which are used by various developer tools
* (debuggers, profilers, etc).
*/
[Constructor(WasmDebugger)]
interface SourceDebugger {
/**
* Set a source-level breakpoint at the given source position.
*
* Execution should be paused when reaching this location, but before
* evaluating its associated code.
*/
SourceBreakpointId? setBreakpoint(SourceBreakpointOptions options);
/**
* Clear a source-level breakpoint that was previously set.
*/
void clearBreakpoint(SourceBreakpointId breakpoint);
/**
* This method will be called whenever the debuggee hits a Wasm
* breakpoint. This allows the `SourceDebugger` to translate Wasm-level
* breaks into source-level breaks.
*/
SourceBreakResult onBreak(WasmBreakInfo);
/**
* This method is called when the debuggee module is paused to step into,
* over, or out of a function.
*
* `SourceDebugger` implementations should set Wasm breakpoint(s) where
* execution should pause after taking the requested step.
*/
void onStep(SourceStepOptions options);
/**
* Get the source range(s) for the given code offset, if any.
*
* Note that various code transformations (e.g. common subexpression
* elinimation) may result in an offset mapping to multiple source ranges.
*
* Note that an offset may also not map to any source range, for example if
* debug information is unavailable for a linked object file that
* contributed to this Wasm module's compilation.
*/
Sequence<SourceRange> getSourceRanges(WasmCodeOffset offset);
/**
* Get the code offset(s) for the given source location, if any.
*
* Note that a source location may map to multiple code ranges, for example
* if one of a location's subexpressions has been hoisted out of a loop.
*
* Note that a source location might not map to any code range. A trivial
* example is a source location within a comment in the source text. Another
* example is an expression that was dead code eliminated.
*/
Sequence<WasmCodeRange> getWasmCodeRanges(SourceLocation location);
/**
* Get a list of the source files that this Wasm module was compiled from.
*/
Sequence<SourceFilename> listSources();
/**
* Get the source text for the given source file.
*/
SourceText? getSourceText(SourceFilename source);
};