- /* this is different from how CMUCL does it. CMUCL used
- * "call_pal PAL_gentrap", which doesn't do anything on Linux
- * so screwed up our offsets in odd ways. We use "bpt" instead
- */
-
- /* probably we should
- assert(*(unsigned int*)(*os_context_pc_addr(context)-4) == BREAKPOINT_INST)
- but I've not decided a good way to handle it if it turns out not to be
- */
+ /* this is different from how CMUCL does it. CMUCL used "call_pal
+ * PAL_gentrap", which doesn't do anything on Linux (unless NL0
+ * contains certain specific values). We use "bugchk" instead.
+ * It's (for our purposes) just the same as bpt but has a
+ * different opcode so we can test whether we're dealing with a
+ * breakpoint or a "system service" */
+
+ if((*(unsigned int*)(*os_context_pc_addr(context)-4))== BREAKPOINT_INST) {
+ if(after_breakpoint) {
+ /* see comments above arch_do_displaced_inst. This is where
+ * we reinsert the breakpoint that we removed earlier */
+
+ *os_context_pc_addr(context) -=4;
+ *skipped_break_addr = BREAKPOINT_INST;
+ os_flush_icache((os_vm_address_t)skipped_break_addr,
+ sizeof(unsigned long));
+ skipped_break_addr = NULL;
+ *(unsigned int *)*os_context_pc_addr(context) =
+ displaced_after_inst;
+ os_flush_icache((os_vm_address_t)*os_context_pc_addr(context), sizeof(unsigned long));
+ *os_context_sigmask_addr(context)= orig_sigmask;
+ after_breakpoint=0; /* false */
+ return;
+ } else
+ code = trap_Breakpoint;
+ } else
+ /* a "system service" */