[svn:parrot] r36504 - in trunk: examples/pir src
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Mon Feb 9 20:12:36 UTC 2009
Author: NotFound
Date: Mon Feb 9 20:12:35 2009
New Revision: 36504
URL: https://trac.parrot.org/parrot/changeset/36504
Log:
[debugger] some fixes and add an option to pirric for interaction with the debugger
Modified:
trunk/examples/pir/pirric.pir
trunk/src/debug.c
Modified: trunk/examples/pir/pirric.pir
==============================================================================
--- trunk/examples/pir/pirric.pir Mon Feb 9 20:09:58 2009 (r36503)
+++ trunk/examples/pir/pirric.pir Mon Feb 9 20:12:35 2009 (r36504)
@@ -36,6 +36,8 @@
# - Calls to functions in foreign namespaces
#
# Command line options:
+# -d Parrot debugger mode. Jumps to the debugger after each
+# TRON line inform.
# -t Trace on. Same as the TRON instruction
# -p all remaining arguments are executed as PRINT instructions
#-----------------------------------------------------------------------
@@ -92,6 +94,7 @@
addattribute runnerclass, 'curline'
addattribute runnerclass, 'vars'
addattribute runnerclass, 'stack'
+ addattribute runnerclass, 'debugger'
addattribute runnerclass, 'tron'
$P0 = get_class 'String'
@@ -207,6 +210,7 @@
le $I0, $I1, no_prog
.local string arg
arg = args[$I1]
+ if arg == '-d' goto opt_debugger
if arg == '-t' goto opt_tron
if arg == '-p' goto print_items
@@ -216,6 +220,11 @@
$I0 = 1
goto start
+opt_debugger:
+ runner.'debugger'()
+ inc $I1
+ goto read_args
+
opt_tron:
runner.'trace'(1)
inc $I1
@@ -377,6 +386,9 @@
$P0 = new 'Integer'
$P0 = 0
setattribute self, 'tron', $P0
+ $P0 = new 'Integer'
+ $P0 = 0
+ setattribute self, 'debugger', $P0
$P1 = new 'ResizablePMCArray'
setattribute self, 'stack', $P1
$P2 = new 'Integer'
@@ -469,6 +481,12 @@
.end
#-----------------------------------------------------------------------
+.sub debugger :method
+ $P0 = getattribute self, 'debugger'
+ $P0 = 1
+.end
+
+#-----------------------------------------------------------------------
.sub trace :method
.param int level
@@ -1361,6 +1379,7 @@
.local pmc program
.local pmc stack
.local pmc iter
+ .local pmc debugger
.local pmc tron
.local pmc pircontrol
.local int stopline
@@ -1374,6 +1393,7 @@
stack = getattribute self, 'stack'
tron = getattribute self, 'tron'
+ debugger = getattribute self, 'debugger'
stopline = 0
pcurline = new 'Integer'
@@ -1400,6 +1420,9 @@
print curline
print ']'
+ unless debugger goto executeline
+ debug_break
+
executeline:
program = getattribute self, 'program'
$S1 = program [curline]
Modified: trunk/src/debug.c
==============================================================================
--- trunk/src/debug.c Mon Feb 9 20:09:58 2009 (r36503)
+++ trunk/src/debug.c Mon Feb 9 20:12:35 2009 (r36504)
@@ -1144,6 +1144,7 @@
Parrot_ex_throw_from_c_args(interp, NULL, 0, "No file loaded to debug");
if (!(interp->pdb->state & PDB_BREAK)) {
+ TRACEDEB_MSG("Parrot_debugger_break - in BREAK state");
new_runloop_jump_point(interp);
if (setjmp(interp->current_runloop->resume)) {
fprintf(stderr, "Unhandled exception in debugger\n");
@@ -1154,7 +1155,7 @@
interp->pdb->state |= PDB_STOPPED;
interp->pdb->cur_opcode = (opcode_t *)cur_opcode + 1;
- PDB_set_break(interp, NULL);
+ /*PDB_set_break(interp, NULL);*/
debugger_cmdline(interp);
@@ -1163,8 +1164,9 @@
}
else {
interp->pdb->cur_opcode = (opcode_t *)cur_opcode + 1;
- PDB_set_break(interp, NULL);
+ /*PDB_set_break(interp, NULL);*/
}
+ TRACEDEB_MSG("Parrot_debugger_break done");
}
/*
@@ -1552,6 +1554,8 @@
unsigned char regleft;
int i, reg_number;
+ TRACEDEB_MSG("PDB_cond");
+
/* Return if no more arguments */
if (!(command && *command)) {
Parrot_io_eprintf(interp->pdb->debugger, "No condition specified\n");
@@ -1928,6 +1932,7 @@
(void)PDB_program_end(interp);
#endif
pdb->state |= PDB_RUNNING;
+ pdb->state &= ~PDB_BREAK;
pdb->state &= ~PDB_STOPPED;
}
@@ -2299,7 +2304,9 @@
PDB_condition_t *watchpoint = pdb->watchpoint;
PDB_breakpoint_t *breakpoint;
+/*
TRACEDEB_MSG("PDB_break");
+*/
/* Check the watchpoints first. */
while (watchpoint) {
More information about the parrot-commits
mailing list