]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: add factorbug command to throw exception
authorJoe Groff <arcata@gmail.com>
Fri, 21 Oct 2011 06:19:32 +0000 (23:19 -0700)
committerJoe Groff <arcata@gmail.com>
Fri, 28 Oct 2011 04:14:49 +0000 (21:14 -0700)
Also rename "q" to "c" because it "c"ontinues, remove the useless "im" command, and rename the less useful "t" to "trim" so we can use "t" to mean "throw"

basis/debugger/debugger.factor
vm/debug.cpp
vm/errors.cpp
vm/errors.hpp

index b193d5080cd0bec1796326e7f1389fff0e996196..18a23f3c0f95e67053725fe4e4bdaaf771ee2fae 100755 (executable)
@@ -134,11 +134,14 @@ HOOK: signal-error. os ( obj -- )
 : fp-trap-error. ( error -- )
     "Floating point trap" print drop ;
 
+: interrupt-error. ( error -- )
+    "Interrupt" print drop ;
+
 PREDICATE: vm-error < array
     {
         { [ dup empty? ] [ drop f ] }
         { [ dup first "kernel-error" = not ] [ drop f ] }
-        [ second 0 17 between? ]
+        [ second 0 18 between? ]
     } cond ;
 
 : vm-errors ( error -- n errors )
@@ -161,6 +164,7 @@ PREDICATE: vm-error < array
         { 15 [ callstack-overflow.     ] }
         { 16 [ memory-error.           ] }
         { 17 [ fp-trap-error.          ] }
+        { 18 [ interrupt-error.        ] }
     } ; inline
 
 M: vm-error summary drop "VM error" ;
index 7d9381b74aae6709e92ee481124453b110be3afc..356ba59e8d1258e68fa3574fb1a5d7b9980f08f7 100755 (executable)
@@ -351,23 +351,22 @@ void factor_vm::factorbug()
                exit(1);
        }
 
-       /* open_console(); */
        fep_p = true;
 
        std::cout << "Starting low level debugger...\n";
        std::cout << "  Basic commands:\n";
-       std::cout << "q                -- continue executing Factor - NOT SAFE\n";
-       std::cout << "im               -- save image to fep.image\n";
+       std::cout << "c                -- continue executing Factor - NOT SAFE\n";
+       std::cout << "t                -- throw exception in Factor - NOT SAFE\n";
        std::cout << "x                -- exit Factor\n";
        std::cout << "  Advanced commands:\n";
        std::cout << "d <addr> <count> -- dump memory\n";
        std::cout << "u <addr>         -- dump object at tagged <addr>\n";
        std::cout << ". <addr>         -- print object at tagged <addr>\n";
-       std::cout << "t                -- toggle output trimming\n";
        std::cout << "s r              -- dump data, retain stacks\n";
        std::cout << ".s .r .c         -- print data, retain, call stacks\n";
        std::cout << "e                -- dump environment\n";
        std::cout << "g                -- dump generations\n";
+       std::cout << "trim             -- toggle output trimming\n";
        std::cout << "data             -- data heap dump\n";
        std::cout << "words            -- words dump\n";
        std::cout << "tuples           -- tuples dump\n";
@@ -427,7 +426,7 @@ void factor_vm::factorbug()
                        print_obj(addr);
                        std::cout << std::endl;
                }
-               else if(strcmp(cmd,"t") == 0)
+               else if(strcmp(cmd,"trim") == 0)
                        full_output = !full_output;
                else if(strcmp(cmd,"s") == 0)
                        dump_memory(ctx->datastack_seg->start,ctx->datastack);
@@ -446,15 +445,19 @@ void factor_vm::factorbug()
                }
                else if(strcmp(cmd,"g") == 0)
                        dump_generations();
-               else if(strcmp(cmd,"q") == 0)
+               else if(strcmp(cmd,"q") == 0 || strcmp(cmd,"c") == 0)
                {
                        fep_p = false;
                        return;
                }
+               else if(strcmp(cmd,"t") == 0)
+               {
+                       fep_p = false;
+                       general_error(ERROR_INTERRUPT,false_object,false_object);
+                       assert(false);
+               }
                else if(strcmp(cmd,"x") == 0)
                        exit(1);
-               else if(strcmp(cmd,"im") == 0)
-                       save_image(STRING_LITERAL("fep.image.saving"),STRING_LITERAL("fep.image"));
                else if(strcmp(cmd,"data") == 0)
                        dump_objects(TYPE_COUNT);
                else if(strcmp(cmd,"refs") == 0)
index 1b5fe221f11127b6f128be671af2abd05c632c95..286176954d3e0f55e6b4a29b5a3a51c97b4a2e42 100755 (executable)
@@ -182,10 +182,10 @@ void factor_vm::handle_safepoint()
        if (signal_from_leaf)
                std::cout << "XXX SIGNALED FROM LEAF\n";
 
+       code->unguard_safepoint();
        if (safepoint_fep) {
                std::cout << "Interrupted\n";
                factorbug();
-               code->unguard_safepoint();
                safepoint_fep = false;
                return;
        }
index ae7557ad52af5cd2587b79cc737879cd55c178b6..2e6ad8f48e8903133f876abd1af0e4fa2e96e8f3 100755 (executable)
@@ -22,6 +22,7 @@ enum vm_error_type
        ERROR_CALLSTACK_OVERFLOW,
        ERROR_MEMORY,
        ERROR_FP_TRAP,
+       ERROR_INTERRUPT,
 };
 
 void fatal_error(const char *msg, cell tagged);