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 const char *nextarg

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

static const char *skip_ws

Returns the pointer past any whitespace.

static const char *skip_command

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

static const char *parse_int

Parse an int out of a string and return a pointer to just after the int. The output parameter intP contains the parsed value.

static const char *parse_string

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 and placed in the output parameter strP.

static const char *parse_key

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

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

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_script_file

Interprets the contents of a file as user input commands

int PDB_run_command

Run a command.

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

void PDB_next

Execute the next N operation(s).

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

void PDB_trace

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

PDB_condition_t *PDB_cond

Analyzes a condition from the user input.

void PDB_watchpoint

Set a watchpoint.

void PDB_set_break

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

void PDB_init

Init the program.

void PDB_continue

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

PDB_breakpoint_t *PDB_find_breakpoint

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

void PDB_disable_breakpoint

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

void PDB_enable_breakpoint

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

void PDB_delete_breakpoint

Delete a breakpoint.

void PDB_delete_condition

Delete a condition associated with a breakpoint.

void PDB_skip_breakpoint

Skip i times all breakpoints.

char PDB_program_end

End the program.

char PDB_check_condition

Returns true if the condition was met.

char PDB_break

Returns true if we have to stop running.

char *PDB_escape

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

The returned string must be freed.

int PDB_unescape

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

size_t PDB_disassemble_op

Disassembles op.

void PDB_disassemble

Disassemble the bytecode.

long PDB_add_label

Add a label to the label list.

void PDB_free_file

Frees any allocated source files.

void PDB_load_source

Load a source code file.

char PDB_hasinstruction

Return true if the line has an instruction.

RT#46129:

void PDB_list

Show lines from the source code file.

void PDB_eval

evals an instruction.

opcode_t *PDB_compile

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

Extend the constant table.

static void dump_string

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

void PDB_print

Print interp registers.

void PDB_info

Print the interpreter info.

void PDB_help

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

void PDB_backtrace

Prints a backtrace of the interp's call chain.

static const char *GDB_print_reg

Used by GDB_P to convert register values for display. Takes register type and number as arguments.

Returns a pointer to the start of the string, (except for PMCs, which print directly and return "").

static const char *GDB_P

Used by PDB_print to print register values. Takes a pointer to the register name(s).

Returns "" or error message.

static int GDB_B

Inserts a break-point into a table (which it creates if necessary). Takes an instruction counter (?).

Currently unused.

Returns break-point count, or -1 if point is out of bounds.

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