Author: julianalbo
Date: Wed Aug 20 05:28:40 2008
New Revision: 30377

Modified:
   trunk/include/parrot/debugger.h
   trunk/src/debug.c
   trunk/src/runops_cores.c

Log:
added gcdebug mode to debugger, to run GC cycles like the gcdebug core, and 
'gcdebug' command to toggle this mode

Modified: trunk/include/parrot/debugger.h
==============================================================================
--- trunk/include/parrot/debugger.h     (original)
+++ trunk/include/parrot/debugger.h     Wed Aug 20 05:28:40 2008
@@ -25,7 +25,8 @@
     PDB_STOPPED     = 1 << 3,
     PDB_BREAK       = 1 << 4, /* Set only from debug_break */
     PDB_EXIT        = 1 << 5,
-    PDB_ENTER       = 1 << 6
+    PDB_ENTER       = 1 << 6,
+    PDB_GCDEBUG     = 1 << 7
 };
 
 enum {

Modified: trunk/src/debug.c
==============================================================================
--- trunk/src/debug.c   (original)
+++ trunk/src/debug.c   Wed Aug 20 05:28:40 2008
@@ -92,7 +92,8 @@
     debug_cmd_script_file = 617610,
     debug_cmd_disable     = 772140,
     debug_cmd_continue    = 1053405,
-    debug_cmd_disassemble = 1903830
+    debug_cmd_disassemble = 1903830,
+    debug_cmd_gcdebug     = 779790
 };
 
 /* HEADERIZER HFILE: include/parrot/debugger.h */
@@ -829,6 +830,16 @@
         case debug_cmd_info:
             PDB_info(interp);
             break;
+        case debug_cmd_gcdebug:
+            if (pdb->state & PDB_GCDEBUG) {
+                TRACEDEB_MSG("Disabling gcdebug mode");
+                pdb->state &= ~PDB_GCDEBUG;
+            }
+            else {
+                TRACEDEB_MSG("Enabling gcdebug mode");
+                pdb->state |= PDB_GCDEBUG;
+            }
+            break;
         case debug_cmd_h:
         case debug_cmd_help:
             PDB_help(interp, command);
@@ -2816,6 +2827,12 @@
             PIO_eprintf(interp,
                     "Print information about the current interpreter\n");
             break;
+        case debug_cmd_gcdebug:
+            PIO_eprintf(interp,
+"Toggle gcdebug mode.\n\n\
+In gcdebug mode a garbage collection cycle is run before each opcocde,\n\
+same as using the gcdebug core.\n");
+            break;
         case debug_cmd_quit:
             PIO_eprintf(interp, "Exit the debugger.\n");
             break;
@@ -2844,6 +2861,7 @@
     print    (p) -- print the interpreter registers\n\
     stack    (s) -- examine the stack\n\
     info         -- print interpreter information\n\
+    gcdebug      -- toggle gcdebug mode\n\
     quit     (q) -- exit the debugger\n\
     help     (h) -- print this help\n\n\
 Type \"help\" followed by a command name for full documentation.\n\n");

Modified: trunk/src/runops_cores.c
==============================================================================
--- trunk/src/runops_cores.c    (original)
+++ trunk/src/runops_cores.c    Wed Aug 20 05:28:40 2008
@@ -336,7 +336,9 @@
         if (pc < interp->code->base.data || pc >= interp->code->base.data + 
interp->code->base.size)
             Parrot_ex_throw_from_c_args(interp, NULL, 1,
                     "attempt to access code outside of current code segment");
-        Parrot_do_dod_run(interp, 0);
+
+        if (interp->pdb->state & PDB_GCDEBUG)
+            Parrot_do_dod_run(interp, 0);
 
         if (interp->pdb->tracing) {
             trace_op(interp,
@@ -347,8 +349,8 @@
         }
 
         CONTEXT(interp)->current_pc = pc;
-
         DO_OP(pc, interp);
+
         interp->pdb->cur_opcode = pc;
         if (interp->pdb->tracing) {
             if (--interp->pdb->tracing == 0) {

Reply via email to