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 *interp, 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 *interp, 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 *interp)

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 *interp, const char *command)

Run a command.

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

void PDB_next(Interp *interp, 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 *interp, const char *command)

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

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

Analyzes a condition from the user input.

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

Set a watchpoint.

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

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

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

Init the program.

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

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

PDB_breakpoint_t *PDB_find_breakpoint(Interp *interp, 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 *interp, const char *command)

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

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

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

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

Delete a breakpoint.

void PDB_delete_condition(Interp *interp, PDB_breakpoint_t *breakpoint)

Delete a condition associated with a breakpoint.

void PDB_skip_breakpoint(Interp *interp, long i)

Skip i times all breakpoints.

char PDB_program_end(Interp *interp)

End the program.

char PDB_check_condition(Interp *interp, PDB_condition_t *condition)

Returns true if the condition was met.

char PDB_break(Interp *interp)

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 *interp, 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 *interp, 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 *interp)

Frees any allocated source files.

void PDB_load_source(Interp *interp, 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 *interp, const char *command)

Show lines from the source code file.

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

evals an instruction.

struct PackFile *PDB_compile(Interp *interp, 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 *interp)

Extend the constant table.

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

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

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

Print an entry from the user stack.

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

Print interp registers.

void PDB_info(Interp *interp)

Print the interpreter info.

void PDB_help(Interp *interp, 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 *interp)

Prints a backtrace of the interp'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.

Start of rewrite - leo 2005.02.16

The debugger now uses its own interpreter. User code is run in Interp* debugee. We have:

  debug_interp->pdb->debugee->debugger
    ^                            |
    |                            v
    +------------- := -----------+
Debug commands are mostly run inside the debugger. User code runs of course in the debugee.


parrot