tagged release 0.7.1
[parrot.git] / include / parrot / debugger.h
blob811d242accf1b9084bd40e2bbb3f0dba34481bd1
1 /*
2 * Copyright (C) 2002-2008, The Perl Foundation
3 */
5 /*
6 * debug.h
8 * SVN Info
9 * $Id$
10 * Overview:
11 * Parrot debugger header files
12 * History:
13 * Initial version by Daniel Grunblatt on 2002.5.19
14 * Notes:
15 * References:
18 #ifndef PARROT_PDB_H_GUARD
19 #define PARROT_PDB_H_GUARD
21 enum {
22 PDB_NO_RUN = 1 << 0,
23 PDB_SRC_LOADED = 1 << 1,
24 PDB_RUNNING = 1 << 2,
25 PDB_STOPPED = 1 << 3,
26 PDB_BREAK = 1 << 4, /* Set only from debug_break */
27 PDB_EXIT = 1 << 5,
28 PDB_ENTER = 1 << 6,
29 PDB_GCDEBUG = 1 << 7,
30 PDB_TRACING = 1 << 8,
31 PDB_ECHO = 1 << 9
34 enum {
35 PDB_cond_int = 1 << 0,
36 PDB_cond_num = 1 << 1,
37 PDB_cond_str = 1 << 2,
38 PDB_cond_pmc = 1 << 3,
39 PDB_cond_gt = 1 << 4,
40 PDB_cond_ge = 1 << 5,
41 PDB_cond_eq = 1 << 6,
42 PDB_cond_ne = 1 << 7,
43 PDB_cond_le = 1 << 8,
44 PDB_cond_lt = 1 << 9,
45 PDB_cond_const = 1 << 10,
46 PDB_cond_notnull = 1 << 11
49 /* PDB_condition_t
50 * Conditions for breakpoint or watchpoints.
52 * type: The type of condition and the way to use arguments.
53 * reg: The register involved, there must be at least one.
54 * value: A pointer to the second argument.
55 * next: A pointer to the next condition - used to construct a
56 * list of watchpoints; not used for conditional breakpoints
59 typedef struct PDB_condition *PDB_condition_ptr;
61 typedef struct PDB_condition {
62 unsigned short type;
63 unsigned char reg;
64 unsigned char dummy; /* For alignment XXX ?? */
65 void *value; /* What neeeds to be aligned with what? */
66 PDB_condition_ptr next;
67 } PDB_condition_t;
69 /* PDB_label_t
70 * A label in the source file.
72 * opcode: The pointer to the bytecode where the label is.
73 * number: Number label.
74 * next: The next label.
77 typedef struct PDB_label *PDB_label_ptr;
79 typedef struct PDB_label {
80 const opcode_t *opcode;
81 long number;
82 PDB_label_ptr next;
83 } PDB_label_t;
85 /* PDB_line_t
86 * A line in the source file.
88 * opcode: A pointer to the opcode in the bytecode corresponding to
89 * this line.
90 * source_offset: Offset from the source file start.
91 * number: Line number.
92 * label: The label if any.
93 * next: The next line (if any).
95 typedef struct PDB_line *PDB_line_ptr;
97 typedef struct PDB_line {
98 opcode_t *opcode;
99 ptrdiff_t source_offset;
100 unsigned long number;
101 PDB_label_t *label;
102 PDB_line_ptr next;
103 } PDB_line_t;
105 /* PDB_file_t
106 * A source code file.
108 * sourcefilename: The source code file name.
109 * source: The file itself.
110 * size: The size of the file in bytes.
111 * list_line: The next line to list.
112 * line: The first line of the source code.
113 * label: The first label.
114 * next: The next file (if any); multiple files are not currently
115 * supported
117 typedef struct PDB_file *PDB_file_ptr;
119 typedef struct PDB_file {
120 char *sourcefilename;
121 char *source;
122 size_t size;
123 unsigned long list_line;
124 PDB_line_t *line;
125 PDB_label_t *label;
126 PDB_file_ptr next;
127 } PDB_file_t;
129 /* PDB_breakpoint_t
130 * List of breakpoints.
132 * pc: Where the breakpoint is
133 * id: The identification number of this breakpoint
134 * skip: The number of times to skip this breakpoint
135 * condition: The condition attached to the breakpoint; may be NULL
136 * prev, next: The previous & next breakpoints in the list; may be NULL.
139 typedef struct PDB_breakpoint *PDB_breakpoint_ptr;
141 typedef struct PDB_breakpoint {
142 opcode_t *pc;
143 unsigned long id;
144 long skip;
145 PDB_condition_t *condition;
146 PDB_breakpoint_ptr prev;
147 PDB_breakpoint_ptr next;
148 } PDB_breakpoint_t;
150 /* PDB_t
151 * The debugger.
153 * file: Source code file.
154 * breakpoint: The first breakpoint.
155 * watchpoint: The first watchpoint
156 * breakpoint_skip: Number of breakpoints to skip.
157 * cur_command: The command being executed.
158 * last_command: Last command executed.
159 * cur_opcode: Current opcode.
160 * state: The status of the program being debugged.
161 * debugee: The interpreter we are debugging
162 * debugger: The debugger interpreter
165 typedef struct PDB {
166 PDB_file_t *file;
167 PDB_breakpoint_t *breakpoint;
168 PDB_condition_t *watchpoint;
169 long breakpoint_skip;
170 char *cur_command;
171 char *last_command;
172 opcode_t *cur_opcode;
173 int state;
174 Interp *debugee;
175 Interp *debugger;
176 unsigned long tracing;
177 FILE *script_file;
178 unsigned long script_line;
179 } PDB_t;
182 /* HEADERIZER BEGIN: src/debug.c */
183 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
185 PARROT_API
186 void Parrot_debugger_break(PARROT_INTERP, ARGIN(opcode_t * cur_opcode))
187 __attribute__nonnull__(1)
188 __attribute__nonnull__(2);
190 PARROT_API
191 void Parrot_debugger_destroy(PARROT_INTERP)
192 __attribute__nonnull__(1);
194 PARROT_API
195 void Parrot_debugger_init(PARROT_INTERP)
196 __attribute__nonnull__(1);
198 PARROT_API
199 void Parrot_debugger_load(PARROT_INTERP, ARGIN_NULLOK(STRING *filename))
200 __attribute__nonnull__(1);
202 PARROT_API
203 void Parrot_debugger_start(PARROT_INTERP, ARGIN(opcode_t * cur_opcode))
204 __attribute__nonnull__(1)
205 __attribute__nonnull__(2);
207 PARROT_API
208 void PDB_load_source(PARROT_INTERP, ARGIN(const char *command))
209 __attribute__nonnull__(1)
210 __attribute__nonnull__(2);
212 PARROT_API
213 void PDB_script_file(PARROT_INTERP, ARGIN(const char *command))
214 __attribute__nonnull__(1)
215 __attribute__nonnull__(2);
217 long PDB_add_label(
218 ARGMOD(PDB_file_t *file),
219 ARGIN(const opcode_t *cur_opcode),
220 opcode_t offset)
221 __attribute__nonnull__(1)
222 __attribute__nonnull__(2)
223 FUNC_MODIFIES(*file);
225 void PDB_backtrace(PARROT_INTERP)
226 __attribute__nonnull__(1);
228 PARROT_WARN_UNUSED_RESULT
229 char PDB_break(PARROT_INTERP)
230 __attribute__nonnull__(1);
232 PARROT_WARN_UNUSED_RESULT
233 char PDB_check_condition(PARROT_INTERP,
234 ARGIN(const PDB_condition_t *condition))
235 __attribute__nonnull__(1)
236 __attribute__nonnull__(2);
238 PARROT_CAN_RETURN_NULL
239 opcode_t * PDB_compile(PARROT_INTERP, ARGIN(const char *command))
240 __attribute__nonnull__(1)
241 __attribute__nonnull__(2);
243 PARROT_CAN_RETURN_NULL
244 PDB_condition_t * PDB_cond(PARROT_INTERP, ARGIN(const char *command))
245 __attribute__nonnull__(1)
246 __attribute__nonnull__(2);
248 void PDB_continue(PARROT_INTERP, ARGIN_NULLOK(const char *command))
249 __attribute__nonnull__(1);
251 void PDB_delete_breakpoint(PARROT_INTERP, ARGIN(const char *command))
252 __attribute__nonnull__(1)
253 __attribute__nonnull__(2);
255 void PDB_delete_condition(SHIM_INTERP, ARGMOD(PDB_breakpoint_t *breakpoint))
256 __attribute__nonnull__(2)
257 FUNC_MODIFIES(*breakpoint);
259 void PDB_disable_breakpoint(PARROT_INTERP, ARGIN(const char *command))
260 __attribute__nonnull__(1)
261 __attribute__nonnull__(2);
263 void PDB_disassemble(PARROT_INTERP, SHIM(const char *command))
264 __attribute__nonnull__(1);
266 size_t PDB_disassemble_op(PARROT_INTERP,
267 ARGOUT(char *dest),
268 int space,
269 ARGIN(const op_info_t *info),
270 ARGIN(const opcode_t *op),
271 ARGMOD_NULLOK(PDB_file_t *file),
272 ARGIN_NULLOK(const opcode_t *code_start),
273 int full_name)
274 __attribute__nonnull__(1)
275 __attribute__nonnull__(2)
276 __attribute__nonnull__(4)
277 __attribute__nonnull__(5)
278 FUNC_MODIFIES(*dest);
280 void PDB_enable_breakpoint(PARROT_INTERP, ARGIN(const char *command))
281 __attribute__nonnull__(1)
282 __attribute__nonnull__(2);
284 PARROT_WARN_UNUSED_RESULT
285 PARROT_CAN_RETURN_NULL
286 PARROT_MALLOC
287 char * PDB_escape(ARGIN(const char *string), INTVAL length)
288 __attribute__nonnull__(1);
290 void PDB_eval(PARROT_INTERP, ARGIN(const char *command))
291 __attribute__nonnull__(1)
292 __attribute__nonnull__(2);
294 PARROT_CAN_RETURN_NULL
295 PARROT_WARN_UNUSED_RESULT
296 PDB_breakpoint_t * PDB_find_breakpoint(PARROT_INTERP,
297 ARGIN(const char *command))
298 __attribute__nonnull__(1)
299 __attribute__nonnull__(2);
301 void PDB_free_file(PARROT_INTERP)
302 __attribute__nonnull__(1);
304 void PDB_get_command(PARROT_INTERP)
305 __attribute__nonnull__(1);
307 PARROT_WARN_UNUSED_RESULT
308 PARROT_PURE_FUNCTION
309 char PDB_hasinstruction(ARGIN(const char *c))
310 __attribute__nonnull__(1);
312 void PDB_help(PARROT_INTERP, ARGIN(const char *command))
313 __attribute__nonnull__(1)
314 __attribute__nonnull__(2);
316 void PDB_info(PARROT_INTERP)
317 __attribute__nonnull__(1);
319 void PDB_init(PARROT_INTERP, SHIM(const char *command))
320 __attribute__nonnull__(1);
322 void PDB_list(PARROT_INTERP, ARGIN(const char *command))
323 __attribute__nonnull__(1)
324 __attribute__nonnull__(2);
326 void PDB_next(PARROT_INTERP, ARGIN_NULLOK(const char *command))
327 __attribute__nonnull__(1);
329 void PDB_print(PARROT_INTERP, ARGIN(const char *command))
330 __attribute__nonnull__(1)
331 __attribute__nonnull__(2);
333 char PDB_program_end(PARROT_INTERP)
334 __attribute__nonnull__(1);
336 PARROT_IGNORABLE_RESULT
337 int PDB_run_command(PARROT_INTERP, ARGIN(const char *command))
338 __attribute__nonnull__(1)
339 __attribute__nonnull__(2);
341 void PDB_set_break(PARROT_INTERP, ARGIN_NULLOK(const char *command))
342 __attribute__nonnull__(1);
344 void PDB_skip_breakpoint(PARROT_INTERP, long i)
345 __attribute__nonnull__(1);
347 void PDB_trace(PARROT_INTERP, ARGIN_NULLOK(const char *command))
348 __attribute__nonnull__(1);
350 int PDB_unescape(ARGMOD(char *string))
351 __attribute__nonnull__(1)
352 FUNC_MODIFIES(*string);
354 void PDB_watchpoint(PARROT_INTERP, ARGIN(const char *command))
355 __attribute__nonnull__(1)
356 __attribute__nonnull__(2);
358 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
359 /* HEADERIZER END: src/debug.c */
361 #endif /* PARROT_PDB_H_GUARD */
364 * Local variables:
365 * c-file-style: "parrot"
366 * End:
367 * vim: expandtab shiftwidth=4: