NAME ^

src/debug.c - Parrot debugging

DESCRIPTION ^

This file implements Parrot debugging and is used by pdb, the Parrot debugger, and the debug ops.

Functions ^

static char *nextarg(char *command)

Returns the position just past the current argument in a PASM instruction. This is not the same as na(), above, which is intended for debugger commands. This function is used for eval.

static const char *skip_ws(const char *str)

Returns the pointer past any whitespace.

static const char *skip_command(const char *str)

Returns the pointer past the current debugger command. (This is an alternative to the na() macro above.)

static const char *parse_int(const char *str, int *intP)

Parse an int out of a string and return a pointer to just after the int.

static const char *parse_string(Interp *interpreter, const char *str, STRING** strP)

Parse a double-quoted string out of a C string and return a pointer to just after the string. The parsed string is converted to a Parrot STRING.

static const char *parse_key(Interp *interpreter, const char *str, PMC** keyP)

Parse an aggregate key out of a string and return a pointer to just after the key. Currently only string and integer keys are allowed.

static const char *parse_command(const char *command, unsigned long *cmdP)

Convert the command at the beginning of a string into a numeric value that can be used as a switch key for fast lookup.

void PDB_get_command(Interp *interpreter)

Get a command from the user input to execute.

It saves the last command executed (in pdb->last_command), so it first frees the old one and updates it with the current one.

Also prints the next line to run if the program is still active.

The user input can't be longer than 255 characters.

The input is saved in pdb->cur_command.

void PDB_run_command(Interp *interpreter, const char *command)

Run a command.

Hash the command to make a simple switch calling the correct handler.

void PDB_next(Interp *interpreter, const char *command)

Execute the next N operation(s).

Inits the program if needed, runs the next N >= 1 operations and stops.

void PDB_trace(Interp *interpreter, const char *command)

Execute the next N operations; if no number is specified, it defaults to 1.

PDB_condition_t *PDB_cond(Interp *interpreter, const char *command)

Analyzes a condition from the user input.

void PDB_watchpoint(Interp *interpreter, const char *command)

Set a watchpoint.

void PDB_set_break(Interp *interpreter, const char *command)

Set a break point, the source code file must be loaded.

void PDB_init(Interp *interpreter, const char *command)

Init the program.

void PDB_continue(Interp *interpreter, const char *command)

Continue running the program. If a number is specified, skip that many breakpoints.

PDB_breakpoint_t *PDB_find_breakpoint(Interp *interpreter, const char *command)

Find breakpoint number N; returns NULL if the breakpoint doesn't exist or if no breakpoint was specified.

void PDB_disable_breakpoint(Interp *interpreter, const char *command)

Disable a breakpoint; it can be reenabled with the enable command.

void PDB_enable_breakpoint(Interp *interpreter, const char *command)

Reenable a disabled breakpoint; if the breakpoint was not disabled, has no effect.

void PDB_delete_breakpoint(Interp *interpreter, const char *command)

Delete a breakpoint.

void PDB_delete_condition(Interp *interpreter, PDB_breakpoint_t *breakpoint)

Delete a condition associated with a breakpoint.

void PDB_skip_breakpoint(Interp *interpreter, long i)

Skip i times all breakpoints.

char PDB_program_end(Interp *interpreter)

End the program.

char PDB_check_condition(Interp *interpreter, PDB_condition_t *condition)

Returns true if the condition was met.

char PDB_break(Interp *interpreter)

Returns true if we have to stop running.

char *PDB_escape(const char *string, INTVAL length)

Escapes ", \r, \n, \t, \a and \\.

int PDB_unescape(char *string)

Do inplace unescape of \r, \n, \t, \a and \\.

size_t PDB_disassemble_op(Interp *interpreter, char *dest, int space, op_info_t *info, opcode_t *op, PDB_file_t *file, opcode_t *code_start, int full_name)

Disassembles op.

void PDB_disassemble(Interp *interpreter, const char *command)

Disassemble the bytecode.

long PDB_add_label(PDB_file_t *file, opcode_t *cur_opcode, opcode_t offset)

Add a label to the label list.

void PDB_free_file(Interp *interpreter)

Frees any allocated source files.

void PDB_load_source(Interp *interpreter, const char *command)

Load a source code file.

char PDB_hasinstruction(char *c)

Return true if the line has an instruction.

XXX TODO:

void PDB_list(Interp *interpreter, const char *command)

Show lines from the source code file.

void PDB_eval(Interp *interpreter, const char *command)

evals an instruction.

struct PackFile *PDB_compile(Interp *interpreter, const char *command)

Compiles instructions with the PASM compiler.

Appends an end op.

This may be called from PDB_eval above or from the compile opcode which generates a malloced string.

int PDB_extend_const_table(Interp *interpreter)

Extend the constant table.

void PDB_print_stack(Interp *interpreter, const char *command)

Print entries in the stack.

void PDB_print_stack_int(Interp *interpreter, const char *command)

Print the integer register stack.

void PDB_print_stack_num(Interp *interpreter, const char *command)

Print the float register stack.

void PDB_print_stack_string(Interp *interpreter, const char *command)

Print the string register stack.

void PDB_print_stack_pmc(Interp *interpreter, const char *command)

Print the pmc register stack.

static void dump_string(Interp *interpreter, STRING *s)

Dumps the buflen, flags, bufused, strlen, offset associated with a string and the string itself.

void PDB_print_user_stack(Interp *interpreter, const char *command)

Print an entry from the user stack.

void PDB_print(Interp *interpreter, const char *command)

Print interpreter registers.

void PDB_print_int(Interp *interpreter, struct IReg *int_reg, int regnum)

Print the whole or a specific value of a integer register structure.

void PDB_print_int_frame(Interp *interpreter, struct IRegFrame *int_reg, int regnum)

Print the whole or a specific value of a integer register frame structure.

void PDB_print_num(Interp *interpreter, struct NReg *num_reg, int regnum)

Print the whole or a specific value of a float register structure.

void PDB_print_num_frame(Interp *interpreter, struct NRegFrame *num_reg, int regnum)

Print the whole or a specific value of a float register frame structure.

void PDB_print_string(Interp *interpreter, struct SReg *string_reg, int regnum)

Print the whole or a specific value of a string register structure.

void PDB_print_string_frame(Interp *interpreter, struct SRegFrame *string_reg, int regnum)

Print the whole or a specific value of a string register frame structure.

static void print_pmc(Interp *interpreter, PMC *pmc)

Prints out a human-readable description of pmc.

void PDB_print_pmc(Interp *interpreter, struct PReg *pmc_reg, int regnum, PMC *key)

Print the whole or a specific value of a PMC register structure.

void PDB_print_pmc_frame(Interp *interpreter, struct PRegFrame *pmc_reg, int regnum, PMC *key)

Print the whole or a specific value of a PMC register frame structure.

void PDB_info(Interp *interpreter)

Print the interpreter info.

void PDB_help(Interp *interpreter, const char *command)

Print the help text. "Help" with no arguments prints a list of commands. "Help xxx" prints information on command xxx.

void PDB_backtrace(Interp *interpreter)

Prints a backtrace of the interpreter's call chain.

SEE ALSO ^

include/parrot/debug.h, src/pdb.c and ops/debug.ops.

HISTORY ^

Initial version by Daniel Grunblatt on 2002.5.19.


parrot