Rudimentary breakpoint handling
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 23 Feb 2009 05:12:28 +0000 (21:12 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 23 Feb 2009 05:12:28 +0000 (21:12 -0800)
kern/init.c
kern/trap.c

index ab3cfbc..958390c 100644 (file)
@@ -46,8 +46,12 @@ void kernel_init(multiboot_info_t *mboot_info)
        ENV_CREATE2(TEST, TESTSIZE);
 #else
        // Touch all you want.
-       ENV_CREATE(user_softint);
-       //ENV_CREATE(user_badsegment);
+       ENV_CREATE(user_faultread);
+       //ENV_CREATE(user_faultreadkernel);
+       //ENV_CREATE(user_faultwrite);
+       //ENV_CREATE(user_faultwritekernel);
+       //ENV_CREATE(user_breakpoint);
+       ENV_CREATE(user_badsegment);
        //ENV_CREATE(user_divzero);
        //ENV_CREATE(user_hello);
 #endif // TEST*
index c4f8131..c782df8 100644 (file)
@@ -78,9 +78,10 @@ idt_init(void)
        for(i = 0; i < trap_tbl_size - 1; i++)
                SETGATE(idt[trap_tbl[i].trapnumber], 1, GD_KT, trap_tbl[i].trapaddr, 0);
 
-       // turn on syscall handling.  
+       // turn on syscall handling and other user-accessible ints
        // DPL 3 means this can be triggered by the int instruction
        idt[T_SYSCALL].gd_dpl = 3;
+       idt[T_BRKPT].gd_dpl = 3;
 
        // Setup a TSS so that we get the right stack
        // when we trap to the kernel.
@@ -132,9 +133,13 @@ static void
 trap_dispatch(struct Trapframe *tf)
 {
        // Handle processor exceptions.
-       // LAB 3: Your code here.
        
        switch(tf->tf_trapno) {
+               case (T_BRKPT):
+                       while (1)
+                               monitor(tf);
+                       // never get to this
+                       assert(0);
                case (T_PGFLT):
                        page_fault_handler(tf);
                        break;