tagged release 0.6.4
[parrot.git] / include / parrot / debug.h
blob5c40e75e8a90e7f005c6eaa1300f4f26e8b279af
1 /*
2 * Copyright (C) 2002-2007, 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
30 enum {
31 PDB_cond_int = 1 << 0,
32 PDB_cond_num = 1 << 1,
33 PDB_cond_str = 1 << 2,
34 PDB_cond_pmc = 1 << 3,
35 PDB_cond_gt = 1 << 4,
36 PDB_cond_ge = 1 << 5,
37 PDB_cond_eq = 1 << 6,
38 PDB_cond_ne = 1 << 7,
39 PDB_cond_le = 1 << 8,
40 PDB_cond_lt = 1 << 9,
41 PDB_cond_const = 1 << 10
44 /* PDB_condition_t
45 * Conditions for breakpoint or watchpoints.
47 * type: The type of condition and the way to use arguments.
48 * reg: The register involved, there must be at least one.
49 * value: A pointer to the second argument.
50 * next: A pointer to the next condition - used to construct a
51 * list of watchpoints; not used for conditional breakpoints
54 typedef struct PDB_condition *PDB_condition_ptr;
56 typedef struct PDB_condition {
57 unsigned short type;
58 unsigned char reg;
59 unsigned char dummy; /* For alignment XXX ?? */
60 void *value; /* What neeeds to be aligned with what? */
61 PDB_condition_ptr next;
62 } PDB_condition_t;
64 /* PDB_label_t
65 * A label in the source file.
67 * opcode: The pointer to the bytecode where the label is.
68 * number: Number label.
69 * next: The next label.
72 typedef struct PDB_label *PDB_label_ptr;
74 typedef struct PDB_label {
75 const opcode_t *opcode;
76 long number;
77 PDB_label_ptr next;
78 } PDB_label_t;
80 /* PDB_line_t
81 * A line in the source file.
83 * opcode: A pointer to the opcode in the bytecode corresponding to
84 * this line.
85 * source_offset: Offset from the source file start.
86 * number: Line number.
87 * label: The label if any.
88 * next: The next line (if any).
90 typedef struct PDB_line *PDB_line_ptr;
92 typedef struct PDB_line {
93 opcode_t *opcode;
94 ptrdiff_t source_offset;
95 unsigned long number;
96 PDB_label_t *label;
97 PDB_line_ptr next;
98 } PDB_line_t;
100 /* PDB_file_t
101 * A source code file.
103 * sourcefilename: The source code file name.
104 * source: The file itself.
105 * size: The size of the file in bytes.
106 * list_line: The next line to list.
107 * line: The first line of the source code.
108 * label: The first label.
109 * next: The next file (if any); multiple files are not currently
110 * supported
112 typedef struct PDB_file *PDB_file_ptr;
114 typedef struct PDB_file {
115 char *sourcefilename;
116 char *source;
117 size_t size;
118 unsigned long list_line;
119 PDB_line_t *line;
120 PDB_label_t *label;
121 PDB_file_ptr next;
122 } PDB_file_t;
124 /* PDB_breakpoint_t
125 * List of breakpoints.
127 * pc: Where the breakpoint is
128 * id: The identification number of this breakpoint
129 * skip: The number of times to skip this breakpoint
130 * condition: The condition attached to the breakpoint; may be NULL
131 * prev, next: The previous & next breakpoints in the list; may be NULL.
134 typedef struct PDB_breakpoint *PDB_breakpoint_ptr;
136 typedef struct PDB_breakpoint {
137 opcode_t *pc;
138 long id;
139 long skip;
140 PDB_condition_t *condition;
141 PDB_breakpoint_ptr prev;
142 PDB_breakpoint_ptr next;
143 } PDB_breakpoint_t;
145 /* PDB_t
146 * The debugger.
148 * file: Source code file.
149 * breakpoint: The first breakpoint.
150 * watchpoint: The first watchpoint
151 * breakpoint_skip: Number of breakpoints to skip.
152 * cur_command: The command being executed.
153 * last_command: Last command executed.
154 * cur_opcode: Current opcode.
155 * state: The status of the program being debugged.
156 * debugee: The interpreter we are debugging
159 typedef struct PDB {
160 PDB_file_t *file;
161 PDB_breakpoint_t *breakpoint;
162 PDB_condition_t *watchpoint;
163 long breakpoint_skip;
164 char *cur_command;
165 char *last_command;
166 opcode_t *cur_opcode;
167 int state;
168 Interp *debugee;
169 } PDB_t;
172 /* HEADERIZER BEGIN: src/debug.c */
173 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
175 PARROT_API
176 void Parrot_debugger_break(PARROT_INTERP, ARGIN(opcode_t * cur_opcode))
177 __attribute__nonnull__(1)
178 __attribute__nonnull__(2);
180 PARROT_API
181 void Parrot_debugger_init(PARROT_INTERP)
182 __attribute__nonnull__(1);
184 PARROT_API
185 void Parrot_debugger_load(PARROT_INTERP, ARGIN_NULLOK(STRING *filename))
186 __attribute__nonnull__(1);
188 long PDB_add_label(
189 ARGMOD(PDB_file_t *file),
190 ARGIN(const opcode_t *cur_opcode),
191 opcode_t offset)
192 __attribute__nonnull__(1)
193 __attribute__nonnull__(2)
194 FUNC_MODIFIES(*file);
196 void PDB_backtrace(PARROT_INTERP)
197 __attribute__nonnull__(1);
199 PARROT_WARN_UNUSED_RESULT
200 char PDB_break(PARROT_INTERP)
201 __attribute__nonnull__(1);
203 PARROT_WARN_UNUSED_RESULT
204 char PDB_check_condition(PARROT_INTERP,
205 ARGIN(const PDB_condition_t *condition))
206 __attribute__nonnull__(1)
207 __attribute__nonnull__(2);
209 PARROT_CAN_RETURN_NULL
210 opcode_t * PDB_compile(PARROT_INTERP, ARGIN(const char *command))
211 __attribute__nonnull__(1)
212 __attribute__nonnull__(2);
214 PARROT_CAN_RETURN_NULL
215 PDB_condition_t * PDB_cond(PARROT_INTERP, ARGIN(const char *command))
216 __attribute__nonnull__(1)
217 __attribute__nonnull__(2);
219 void PDB_continue(PARROT_INTERP, ARGIN_NULLOK(const char *command))
220 __attribute__nonnull__(1);
222 void PDB_delete_breakpoint(PARROT_INTERP, ARGIN(const char *command))
223 __attribute__nonnull__(1)
224 __attribute__nonnull__(2);
226 void PDB_delete_condition(SHIM_INTERP, ARGMOD(PDB_breakpoint_t *breakpoint))
227 __attribute__nonnull__(2)
228 FUNC_MODIFIES(*breakpoint);
230 void PDB_disable_breakpoint(PARROT_INTERP, ARGIN(const char *command))
231 __attribute__nonnull__(1)
232 __attribute__nonnull__(2);
234 void PDB_disassemble(PARROT_INTERP, SHIM(const char *command))
235 __attribute__nonnull__(1);
237 size_t PDB_disassemble_op(PARROT_INTERP,
238 ARGOUT(char *dest),
239 int space,
240 ARGIN(const op_info_t *info),
241 ARGIN(const opcode_t *op),
242 ARGMOD_NULLOK(PDB_file_t *file),
243 ARGIN_NULLOK(const opcode_t *code_start),
244 int full_name)
245 __attribute__nonnull__(1)
246 __attribute__nonnull__(2)
247 __attribute__nonnull__(4)
248 __attribute__nonnull__(5)
249 FUNC_MODIFIES(*dest);
251 void PDB_enable_breakpoint(PARROT_INTERP, ARGIN(const char *command))
252 __attribute__nonnull__(1)
253 __attribute__nonnull__(2);
255 PARROT_WARN_UNUSED_RESULT
256 PARROT_CAN_RETURN_NULL
257 PARROT_MALLOC
258 char * PDB_escape(ARGIN(const char *string), INTVAL length)
259 __attribute__nonnull__(1);
261 void PDB_eval(PARROT_INTERP, ARGIN(const char *command))
262 __attribute__nonnull__(1)
263 __attribute__nonnull__(2);
265 PARROT_CAN_RETURN_NULL
266 PARROT_WARN_UNUSED_RESULT
267 PDB_breakpoint_t * PDB_find_breakpoint(PARROT_INTERP,
268 ARGIN(const char *command))
269 __attribute__nonnull__(1)
270 __attribute__nonnull__(2);
272 void PDB_free_file(PARROT_INTERP)
273 __attribute__nonnull__(1);
275 void PDB_get_command(PARROT_INTERP)
276 __attribute__nonnull__(1);
278 PARROT_WARN_UNUSED_RESULT
279 PARROT_PURE_FUNCTION
280 char PDB_hasinstruction(ARGIN(const char *c))
281 __attribute__nonnull__(1);
283 void PDB_help(PARROT_INTERP, ARGIN(const char *command))
284 __attribute__nonnull__(1)
285 __attribute__nonnull__(2);
287 void PDB_info(PARROT_INTERP)
288 __attribute__nonnull__(1);
290 void PDB_init(PARROT_INTERP, SHIM(const char *command))
291 __attribute__nonnull__(1);
293 void PDB_list(PARROT_INTERP, ARGIN(const char *command))
294 __attribute__nonnull__(1)
295 __attribute__nonnull__(2);
297 void PDB_load_source(PARROT_INTERP, ARGIN(const char *command))
298 __attribute__nonnull__(1)
299 __attribute__nonnull__(2);
301 void PDB_next(PARROT_INTERP, ARGIN_NULLOK(const char *command))
302 __attribute__nonnull__(1);
304 void PDB_print(PARROT_INTERP, ARGIN(const char *command))
305 __attribute__nonnull__(1)
306 __attribute__nonnull__(2);
308 char PDB_program_end(PARROT_INTERP)
309 __attribute__nonnull__(1);
311 PARROT_IGNORABLE_RESULT
312 int PDB_run_command(PARROT_INTERP, ARGIN(const char *command))
313 __attribute__nonnull__(1)
314 __attribute__nonnull__(2);
316 void PDB_script_file(PARROT_INTERP, ARGIN(const char *command))
317 __attribute__nonnull__(1)
318 __attribute__nonnull__(2);
320 void PDB_set_break(PARROT_INTERP, ARGIN_NULLOK(const char *command))
321 __attribute__nonnull__(1);
323 void PDB_skip_breakpoint(PARROT_INTERP, long i)
324 __attribute__nonnull__(1);
326 void PDB_trace(PARROT_INTERP, ARGIN_NULLOK(const char *command))
327 __attribute__nonnull__(1);
329 int PDB_unescape(ARGMOD(char *string))
330 __attribute__nonnull__(1)
331 FUNC_MODIFIES(*string);
333 void PDB_watchpoint(PARROT_INTERP, ARGIN(const char *command))
334 __attribute__nonnull__(1)
335 __attribute__nonnull__(2);
337 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
338 /* HEADERIZER END: src/debug.c */
340 #endif /* PARROT_PDB_H_GUARD */
343 * Local variables:
344 * c-file-style: "parrot"
345 * End:
346 * vim: expandtab shiftwidth=4: