Author: julianalbo
Date: Wed Aug 13 03:07:51 2008
New Revision: 30206

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

Log:
fix parrot_debugger initializing

Modified: trunk/include/parrot/debugger.h
==============================================================================
--- trunk/include/parrot/debugger.h     (original)
+++ trunk/include/parrot/debugger.h     Wed Aug 13 03:07:51 2008
@@ -155,6 +155,7 @@
  *  cur_opcode:         Current opcode.
  *  state:              The status of the program being debugged.
  *  debugee:            The interpreter we are debugging
+ *  debugger:           The debugger interpreter
  */
 
 typedef struct PDB {
@@ -167,6 +168,7 @@
     opcode_t                *cur_opcode;
     int                     state;
     Interp                  *debugee;
+    Interp                  *debugger;
     unsigned long           tracing;
 } PDB_t;
 

Modified: trunk/src/debug.c
==============================================================================
--- trunk/src/debug.c   (original)
+++ trunk/src/debug.c   Wed Aug 13 03:07:51 2008
@@ -395,6 +395,7 @@
         interp->pdb     = pdb;
         debugger->pdb   = pdb;
         pdb->debugee    = interp;
+       pdb->debugger   = debugger;
 
        /* Allocate space for command line buffers, NUL terminated c strings */
         pdb->cur_command = (char *)mem_sys_allocate(DEBUG_CMD_BUFFER_LENGTH + 
1);
@@ -403,7 +404,6 @@
 
     /* PDB_disassemble(interp, NULL); */
 
-    interp->pdb->cur_opcode = interp->code->base.data;
     interp->pdb->state     |= PDB_RUNNING;
 }
 
@@ -478,6 +478,8 @@
     if (!interp->pdb)
         Parrot_ex_throw_from_c_args(interp, NULL, 0, "No debugger");
 
+    interp->pdb->cur_opcode = interp->code->base.data;
+
     if (interp->pdb->state & PDB_ENTER) {
         if (!interp->pdb->file) {
             /* PDB_disassemble(interp, NULL); */
@@ -586,6 +588,8 @@
     /* flush the buffered data */
     fflush(stdout);
 
+    PARROT_ASSERT(pdb->last_command);
+    PARROT_ASSERT(pdb->cur_command);
     /* update the last command */
     strcpy(pdb->last_command, pdb->cur_command);
 

Modified: trunk/src/parrot_debugger.c
==============================================================================
--- trunk/src/parrot_debugger.c (original)
+++ trunk/src/parrot_debugger.c Wed Aug 13 03:07:51 2008
@@ -132,19 +132,24 @@
 main(int argc, char *argv[])
 {
     Parrot_Interp     interp   = Parrot_new(NULL);
+
+    /*
     Parrot_Interp     debugger = Parrot_new(interp);
     PDB_t            *pdb      = mem_allocate_zeroed_typed(PDB_t);
+    */
+    PDB_t *pdb;
     const char       *filename;
     char             *ext;
     void             *yyscanner;
 
+    Parrot_debugger_init(interp);
+
+    pdb = interp->pdb;
+
     /*Parrot_set_config_hash();  TODO link with cfg */
 
     /* attach pdb structure */
-    debugger->pdb    = pdb;
-    interp->pdb      = pdb;
-    interp->debugger = debugger;
-    pdb->debugee     = interp;
+    interp->debugger = pdb->debugger;
     pdb->state       = PDB_ENTER;
 
     Parrot_block_GC_mark(interp);

Reply via email to