Author: julianalbo
Date: Mon Aug 18 13:37:51 2008
New Revision: 30310

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

Log:
new --script option in parrot_debugger, same as the 'script' debugger command 
line

Modified: trunk/include/parrot/debugger.h
==============================================================================
--- trunk/include/parrot/debugger.h     (original)
+++ trunk/include/parrot/debugger.h     Mon Aug 18 13:37:51 2008
@@ -204,6 +204,11 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
+PARROT_API
+void PDB_script_file(PARROT_INTERP, ARGIN(const char *command))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
 long PDB_add_label(
     ARGMOD(PDB_file_t *file),
     ARGIN(const opcode_t *cur_opcode),
@@ -328,10 +333,6 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
-void PDB_script_file(PARROT_INTERP, ARGIN(const char *command))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
 void PDB_set_break(PARROT_INTERP, ARGIN_NULLOK(const char *command))
         __attribute__nonnull__(1);
 

Modified: trunk/src/debug.c
==============================================================================
--- trunk/src/debug.c   (original)
+++ trunk/src/debug.c   Mon Aug 18 13:37:51 2008
@@ -32,7 +32,7 @@
 #include "debug.str"
 
 /* Hand switched debugger tracing */
-#define TRACE_DEBUGGER 1
+/*#define TRACE_DEBUGGER 1*/
 
 #ifdef TRACE_DEBUGGER
 #  define TRACEDEB_MSG(msg) fprintf(stderr, "%s\n", (msg))
@@ -709,16 +709,12 @@
 
 */
 
+PARROT_API
 void
 PDB_script_file(PARROT_INTERP, ARGIN(const char *command))
 {
-    char buf[1024];
-    const char *ptr = (const char *)&buf;
-    int line = 0;
     FILE *fd;
 
-    command = nextarg(command);
-
     /* If already executing a script, close it */
     close_script_file(interp);
 
@@ -769,6 +765,7 @@
     switch ((enum DebugCmd)c) {
         case debug_cmd_f:
         case debug_cmd_script_file:
+            command = nextarg(command);
             PDB_script_file(interp, command);
             break;
         case debug_cmd_disassemble:

Modified: trunk/src/parrot_debugger.c
==============================================================================
--- trunk/src/parrot_debugger.c (original)
+++ trunk/src/parrot_debugger.c Mon Aug 18 13:37:51 2008
@@ -131,6 +131,7 @@
 int
 main(int argc, char *argv[])
 {
+    int nextarg;
     Parrot_Interp     interp   = Parrot_new(NULL);
 
     /*
@@ -138,6 +139,7 @@
     PDB_t            *pdb      = mem_allocate_zeroed_typed(PDB_t);
     */
     PDB_t *pdb;
+    const char       *scriptname = NULL;
     const char       *filename;
     char             *ext;
     void             *yyscanner;
@@ -162,7 +164,14 @@
         Parrot_exit(interp, 1);
     }
 
-    filename = argv[1];
+    nextarg = 1;
+    if (strcmp(argv[nextarg], "--script") == 0)
+    {
+        scriptname = argv [++nextarg];
+        ++nextarg;
+    }
+
+    filename = argv[nextarg];
     ext      = strrchr(filename, '.');
 
     if (ext && STREQ(ext, ".pbc")) {
@@ -205,10 +214,13 @@
     Parrot_unblock_GC_mark(interp);
     Parrot_unblock_GC_sweep(interp);
 
-    PDB_printwelcome();
+    if (scriptname)
+        PDB_script_file(interp, scriptname);
+    else
+        PDB_printwelcome();
 
     interp->run_core = PARROT_DEBUGGER_CORE;
-    PDB_run_code(interp, argc - 1, argv + 1);
+    PDB_run_code(interp, argc - nextarg, argv + nextarg);
 
 
     Parrot_exit(interp, 0);

Reply via email to