/
debug.h
380 lines (317 loc) · 10.8 KB
/
debug.h
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
/*
* Copyright (C) 2002-2007, The Perl Foundation
*/
/*
* debug.h
*
* SVN Info
* $Id$
* Overview:
* Parrot debugger header files
* History:
* Initial version by Daniel Grunblatt on 2002.5.19
* Notes:
* References:
*/
#ifndef PARROT_PDB_H_GUARD
#define PARROT_PDB_H_GUARD
enum {
PDB_NO_RUN = 1 << 0,
PDB_SRC_LOADED = 1 << 1,
PDB_RUNNING = 1 << 2,
PDB_STOPPED = 1 << 3,
PDB_BREAK = 1 << 4, /* Set only from debug_break */
PDB_EXIT = 1 << 5
};
enum {
PDB_cond_int = 1 << 0,
PDB_cond_num = 1 << 1,
PDB_cond_str = 1 << 2,
PDB_cond_pmc = 1 << 3,
PDB_cond_gt = 1 << 4,
PDB_cond_ge = 1 << 5,
PDB_cond_eq = 1 << 6,
PDB_cond_ne = 1 << 7,
PDB_cond_le = 1 << 8,
PDB_cond_lt = 1 << 9,
PDB_cond_const = 1 << 10
};
/* PDB_condition_t
* Conditions for breakpoint or watchpoints.
*
* type: The type of condition and the way to use arguments.
* reg: The register involved, there must be at least one.
* value: A pointer to the second argument.
* next: A pointer to the next condition - used to construct a
* list of watchpoints; not used for conditional breakpoints
*/
typedef struct PDB_condition *PDB_condition_ptr;
typedef struct PDB_condition {
unsigned short type;
unsigned char reg;
unsigned char dummy; /* For alignment XXX ?? */
void *value; /* What neeeds to be aligned with what? */
PDB_condition_ptr next;
} PDB_condition_t;
/* PDB_label_t
* A label in the source file.
*
* opcode: The pointer to the bytecode where the label is.
* number: Number label.
* next: The next label.
*/
typedef struct PDB_label *PDB_label_ptr;
typedef struct PDB_label {
opcode_t *opcode;
long number;
PDB_label_ptr next;
} PDB_label_t;
/* PDB_line_t
* A line in the source file.
*
* opcode: A pointer to the opcode in the bytecode corresponding to
* this line.
* source_offset: Offset from the source file start.
* number: Line number.
* label: The label if any.
* next: The next line (if any).
*/
typedef struct PDB_line *PDB_line_ptr;
typedef struct PDB_line {
opcode_t *opcode;
ptrdiff_t source_offset;
unsigned long number;
PDB_label_t *label;
PDB_line_ptr next;
} PDB_line_t;
/* PDB_file_t
* A source code file.
*
* sourcefilename: The source code file name.
* source: The file itself.
* size: The size of the file in bytes.
* list_line: The next line to list.
* line: The first line of the source code.
* label: The first label.
* next: The next file (if any); multiple files are not currently
* supported
*/
typedef struct PDB_file *PDB_file_ptr;
typedef struct PDB_file {
char *sourcefilename;
char *source;
size_t size;
unsigned long list_line;
PDB_line_t *line;
PDB_label_t *label;
PDB_file_ptr next;
} PDB_file_t;
/* PDB_breakpoint_t
* List of breakpoints.
*
* pc: Where the breakpoint is
* id: The identification number of this breakpoint
* skip: The number of times to skip this breakpoint
* condition: The condition attached to the breakpoint; may be NULL
* prev, next: The previous & next breakpoints in the list; may be NULL.
*/
typedef struct PDB_breakpoint *PDB_breakpoint_ptr;
typedef struct PDB_breakpoint {
opcode_t *pc;
long id;
long skip;
PDB_condition_t *condition;
PDB_breakpoint_ptr prev;
PDB_breakpoint_ptr next;
} PDB_breakpoint_t;
/* PDB_t
* The debugger.
*
* file: Source code file.
* breakpoint: The first breakpoint.
* watchpoint: The first watchpoint
* breakpoint_skip: Number of breakpoints to skip.
* cur_command: The command being executed.
* last_command: Last command executed.
* cur_opcode: Current opcode.
* state: The status of the program being debugged.
* debugee: The interpreter we are debugging
*/
typedef struct PDB {
PDB_file_t *file;
PDB_breakpoint_t *breakpoint;
PDB_condition_t *watchpoint;
long breakpoint_skip;
char *cur_command;
char *last_command;
opcode_t *cur_opcode;
int state;
Interp *debugee;
} PDB_t;
/* HEADERIZER BEGIN: src/debug.c */
long PDB_add_label(
NOTNULL(PDB_file_t *file),
NOTNULL(opcode_t *cur_opcode),
opcode_t offset)
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_backtrace(PARROT_INTERP)
__attribute__nonnull__(1);
PARROT_WARN_UNUSED_RESULT
char PDB_break(PARROT_INTERP)
__attribute__nonnull__(1);
PARROT_WARN_UNUSED_RESULT
char PDB_check_condition(PARROT_INTERP, NOTNULL(PDB_condition_t *condition))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_CAN_RETURN_NULL
opcode_t * PDB_compile(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_CAN_RETURN_NULL
PDB_condition_t * PDB_cond(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_continue(PARROT_INTERP, ARGIN_NULLOK(const char *command))
__attribute__nonnull__(1);
void PDB_delete_breakpoint(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_delete_condition(SHIM_INTERP,
NOTNULL(PDB_breakpoint_t *breakpoint))
__attribute__nonnull__(2);
void PDB_disable_breakpoint(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_disassemble(PARROT_INTERP, SHIM(const char *command))
__attribute__nonnull__(1);
size_t PDB_disassemble_op(PARROT_INTERP,
ARGOUT(char *dest),
int space,
NOTNULL(op_info_t *info),
NOTNULL(opcode_t *op),
NULLOK(PDB_file_t *file),
NULLOK(opcode_t *code_start),
int full_name)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(4)
__attribute__nonnull__(5);
void PDB_enable_breakpoint(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
char * PDB_escape(ARGIN(const char *string), INTVAL length)
__attribute__nonnull__(1);
void PDB_eval(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
int PDB_extend_const_table(PARROT_INTERP)
__attribute__nonnull__(1);
PARROT_CAN_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
PDB_breakpoint_t * PDB_find_breakpoint(PARROT_INTERP,
ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_free_file(PARROT_INTERP)
__attribute__nonnull__(1);
void PDB_get_command(PARROT_INTERP)
__attribute__nonnull__(1);
PARROT_WARN_UNUSED_RESULT
PARROT_PURE_FUNCTION
char PDB_hasinstruction(ARGIN(const char *c))
__attribute__nonnull__(1);
void PDB_help(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_info(PARROT_INTERP)
__attribute__nonnull__(1);
void PDB_init(PARROT_INTERP, SHIM(const char *command))
__attribute__nonnull__(1);
void PDB_list(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_load_source(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_next(PARROT_INTERP, ARGIN_NULLOK(const char *command))
__attribute__nonnull__(1);
void PDB_print(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_print_user_stack(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
char PDB_program_end(PARROT_INTERP)
__attribute__nonnull__(1);
PARROT_IGNORABLE_RESULT
int PDB_run_command(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_script_file(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_set_break(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
void PDB_skip_breakpoint(PARROT_INTERP, long i)
__attribute__nonnull__(1);
void PDB_trace(PARROT_INTERP, ARGIN_NULLOK(const char *command))
__attribute__nonnull__(1);
int PDB_unescape(NOTNULL(char *string))
__attribute__nonnull__(1);
void PDB_watchpoint(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
/* HEADERIZER END: src/debug.c */
/*
* These constants correspond to the debugger commands and are
* used in src/debug.c. To map command strings to their
* numeric values, use the algorithm from parse_command() in that file.
*/
#define c_b 25245
#define c_c 25500
#define c_d 25755
#define c_e 26010
#define c_h 26775
#define c_i 27030
#define c_l 27795
#define c_n 28305
#define c_p 28815
#define c_q 29070
#define c_r 29325
#define c_s 29580
#define c_t 29835
#define c_w 30600
#define c_int 175185
#define c_run 176460
#define c_num 174675
#define c_str 179265
#define c_pmc 163455
#define c_eval 277950
#define c_help 282540
#define c_info 281775
#define c_list 295035
#define c_load 268005
#define c_next 297330
#define c_quit 294780
#define c_break 409785
#define c_print 441150
#define c_stack 414120
#define c_trace 405705
#define c_watch 416160
#define c_enable 571455
#define c_delete 588285
#define c_script_file 617610
#define c_disable 772140
#define c_continue 1053405
#define c_disassemble 1903830
#endif /* PARROT_PDB_H_GUARD */
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4:
*/