Author: julianalbo
Date: Wed Aug 13 13:32:04 2008
New Revision: 30211

Modified:
   trunk/src/debug.c

Log:
more debugger work, trace now uses the debug runloop

Modified: trunk/src/debug.c
==============================================================================
--- trunk/src/debug.c   (original)
+++ trunk/src/debug.c   Wed Aug 13 13:32:04 2008
@@ -31,6 +31,15 @@
 #include "parrot/oplib/ops.h"
 #include "debug.str"
 
+/* Hand switched debugger tracing */
+#define TRACE_DEBUGGER 1
+
+#ifdef TRACE_DEBUGGER
+#  define TRACEDEB_MSG(msg) fprintf(stderr, "%s\n", (msg))
+#else
+#  define TRACEDEB_MSG(msg)
+#endif
+
 /* Length of command line buffers */
 #define DEBUG_CMD_BUFFER_LENGTH 255
 
@@ -389,6 +398,8 @@
 void
 Parrot_debugger_init(PARROT_INTERP)
 {
+    TRACEDEB_MSG("Parrot_debugger_init");
+
     if (! interp->pdb) {
         PDB_t *pdb = mem_allocate_zeroed_typed(PDB_t);
         Parrot_Interp debugger = Parrot_new(interp);
@@ -425,6 +436,9 @@
        Free all debugger allocated resources.
      */
     PDB_t *pdb = interp->pdb;
+
+    TRACEDEB_MSG("Parrot_debugger_destroy");
+
     PARROT_ASSERT(pdb);
     PARROT_ASSERT(pdb->debugee == interp);
 
@@ -473,7 +487,7 @@
 void
 Parrot_debugger_start(PARROT_INTERP, ARGIN(opcode_t * cur_opcode))
 {
-    /* fprintf(stderr, "Parrot_debugger_start\n"); */
+    TRACEDEB_MSG("Parrot_debugger_start");
 
     if (!interp->pdb)
         Parrot_ex_throw_from_c_args(interp, NULL, 0, "No debugger");
@@ -495,6 +509,8 @@
         const char * command;
         PDB_get_command(interp);
         command = interp->pdb->cur_command;
+        if (command[0] == '\0')
+            command = interp->pdb->last_command;
 
         PDB_run_command(interp, command);
     }
@@ -523,6 +539,8 @@
 void
 Parrot_debugger_break(PARROT_INTERP, ARGIN(opcode_t * cur_opcode))
 {
+    TRACEDEB_MSG("Parrot_debugger_break");
+
     if (!interp->pdb)
         Parrot_ex_throw_from_c_args(interp, NULL, 0, "No debugger");
 
@@ -588,10 +606,13 @@
     /* flush the buffered data */
     fflush(stdout);
 
+    TRACEDEB_MSG("PDB_get_command");
+
     PARROT_ASSERT(pdb->last_command);
     PARROT_ASSERT(pdb->cur_command);
     /* update the last command */
-    strcpy(pdb->last_command, pdb->cur_command);
+    if (pdb->cur_command[0] != '\0')
+        strcpy(pdb->last_command, pdb->cur_command);
 
     #if 0
     /* if the program is stopped and running show the next line to run */
@@ -710,6 +731,8 @@
     PDB_t        * const pdb = interp->pdb;
     const char   * const original_command = command;
 
+    TRACEDEB_MSG("PDB_run_command");
+
     /* keep a pointer to the command, in case we need to report an error */
 
     /* get a number from what the user typed */
@@ -864,6 +887,8 @@
     PDB_t *  const pdb = interp->pdb;
     Interp        *debugee;
 
+    TRACEDEB_MSG("PDB_trace");
+
     /* if debugger is not running yet, initialize */
     if (!(pdb->state & PDB_RUNNING))
         PDB_init(interp, command);
@@ -884,19 +909,10 @@
         pdb->state |= PDB_STOPPED;
         return;
     }
-
-    for (; n && pdb->cur_opcode; n--) {
-        trace_op(debugee,
-                debugee->code->base.data,
-                debugee->code->base.data +
-                debugee->code->base.size,
-                debugee->pdb->cur_opcode);
-        DO_OP(pdb->cur_opcode, debugee);
-    }
     pdb->tracing = n;
     pdb->debugee->run_core = PARROT_DEBUGGER_CORE;
 
-    runops_int(pdb->debugee, pdb->debugee->code->base.data - pdb->cur_opcode);
+    /* Clear the following when done some testing */
 
     /* we just stopped */
     pdb->state |= PDB_STOPPED;

Reply via email to