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 ^

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.

skip_ws

Returns the pointer past any whitespace.

skip_command

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

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.

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.

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.

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.

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.

PDB_script_file

Interprets the contents of a file as user input commands

PDB_run_command

Run a command.

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

PDB_next

Execute the next N operation(s).

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

PDB_trace

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

PDB_cond

Analyzes a condition from the user input.

PDB_watchpoint

Set a watchpoint.

PDB_set_break

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

PDB_init

Init the program.

PDB_continue

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

PDB_disable_breakpoint

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

PDB_enable_breakpoint

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

PDB_delete_breakpoint

Delete a breakpoint.

PDB_delete_condition

Delete a condition associated with a breakpoint.

PDB_skip_breakpoint

Skip i times all breakpoints.

PDB_program_end

End the program.

PDB_check_condition

Returns true if the condition was met.

PDB_break

Returns true if we have to stop running.

PDB_escape

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

PDB_unescape

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

PDB_disassemble_op

Disassembles op.

PDB_disassemble

Disassemble the bytecode.

PDB_add_label

Add a label to the label list.

PDB_free_file

Frees any allocated source files.

PDB_load_source

Load a source code file.

PDB_hasinstruction

Return true if the line has an instruction.

RT#46129:

PDB_list

Show lines from the source code file.

PDB_eval

evals an instruction.

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.

PDB_extend_const_table

Extend the constant table.

PDB_print_user_stack

Print an entry from the user stack.

PDB_print

Print interp registers.

PDB_info

Print the interpreter info.

PDB_help

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

PDB_backtrace

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