Use consistently "unsigned int" as C type for an instruction.
;;; returns the overwritten bits. You must call this in a context in
;;; which GC is disabled, so that Lisp doesn't move objects around
;;; that C is pointing to.
-(sb!alien:define-alien-routine "breakpoint_install" sb!alien:unsigned-long
+(sb!alien:define-alien-routine "breakpoint_install" sb!alien:unsigned-int
(code-obj sb!alien:unsigned-long)
(pc-offset sb!alien:int))
(sb!alien:define-alien-routine "breakpoint_remove" sb!alien:void
(code-obj sb!alien:unsigned-long)
(pc-offset sb!alien:int)
- (old-inst sb!alien:unsigned-long))
+ (old-inst sb!alien:unsigned-int))
(sb!alien:define-alien-routine "breakpoint_do_displaced_inst" sb!alien:void
(scp (* os-context-t))
- (orig-inst sb!alien:unsigned-long))
+ (orig-inst sb!alien:unsigned-int))
;;;; breakpoint handlers (layer between C and exported interface)
*os_context_register_addr(context,reg_ALLOC) |= (1L<<63);
}
-unsigned long arch_install_breakpoint(void *pc)
+unsigned int arch_install_breakpoint(void *pc)
{
unsigned int *ptr = (unsigned int *)pc;
- unsigned long result = (unsigned long) *ptr;
+ unsigned int result = *ptr;
*ptr = BREAKPOINT_INST;
- os_flush_icache((os_vm_address_t)ptr, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t)ptr, sizeof(unsigned int));
return result;
}
-void arch_remove_breakpoint(void *pc, unsigned long orig_inst)
+void arch_remove_breakpoint(void *pc, unsigned int orig_inst)
{
- /* was (unsigned int) but gcc complains. Changed to mirror
- * install_breakpoint() above */
- unsigned long *ptr=(unsigned long *)pc;
+ unsigned int *ptr = (unsigned int *)pc;
*ptr = orig_inst;
- os_flush_icache((os_vm_address_t)pc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t)pc, sizeof(unsigned int));
}
static unsigned int *skipped_break_addr, displaced_after_inst,
/* This returns a PC value. Lisp code is all in the 32-bit-addressable
* space, so we should be ok with an unsigned int. */
unsigned int
-emulate_branch(os_context_t *context,unsigned long orig_inst)
+emulate_branch(os_context_t *context, unsigned int orig_inst)
{
int op = orig_inst >> 26;
int reg_a = (orig_inst >> 21) & 0x1f;
/* Put the original instruction back. */
*pc = orig_inst;
- os_flush_icache((os_vm_address_t)pc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t)pc, sizeof(unsigned int));
skipped_break_addr = pc;
/* Figure out where we will end up after running the displaced
displaced_after_inst = *next_pc;
*next_pc = BREAKPOINT_INST;
after_breakpoint=1;
- os_flush_icache((os_vm_address_t)next_pc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t)next_pc, sizeof(unsigned int));
}
static void
*os_context_pc_addr(context) -=4;
*skipped_break_addr = BREAKPOINT_INST;
os_flush_icache((os_vm_address_t)skipped_break_addr,
- sizeof(unsigned long));
+ sizeof(unsigned int));
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_flush_icache((os_vm_address_t)*os_context_pc_addr(context), sizeof(unsigned int));
*os_context_sigmask_addr(context)= orig_sigmask;
after_breakpoint=0; /* false */
return;
extern void arch_set_pseudo_atomic_interrupted(os_context_t*);
extern os_vm_address_t arch_get_bad_addr(int, siginfo_t*, os_context_t*);
extern unsigned char *arch_internal_error_arguments(os_context_t*);
-extern unsigned long arch_install_breakpoint(void *pc);
-extern void arch_remove_breakpoint(void *pc, unsigned long orig_inst);
+extern unsigned int arch_install_breakpoint(void *pc);
+extern void arch_remove_breakpoint(void *pc, unsigned int orig_inst);
extern void arch_install_interrupt_handlers(void);
extern void arch_do_displaced_inst(os_context_t *context,
unsigned int orig_inst);
+ pc_offset);
}
-unsigned long breakpoint_install(lispobj code_obj, int pc_offset)
+unsigned int breakpoint_install(lispobj code_obj, int pc_offset)
{
return arch_install_breakpoint(compute_pc(code_obj, pc_offset));
}
void breakpoint_remove(lispobj code_obj, int pc_offset,
- unsigned long orig_inst)
+ unsigned int orig_inst)
{
arch_remove_breakpoint(compute_pc(code_obj, pc_offset), orig_inst);
}
void breakpoint_do_displaced_inst(os_context_t* context,
- unsigned long orig_inst)
+ unsigned int orig_inst)
{
/* on platforms with sigreturn(), we go directly back from
* arch_do_displaced_inst() to lisp code, so we need to clean up
#ifndef _BREAKPOINT_H_
#define _BREAKPOINT_H_
-extern unsigned long breakpoint_install(lispobj code_obj, int pc_offset);
+extern unsigned int breakpoint_install(lispobj code_obj, int pc_offset);
extern void breakpoint_remove(lispobj code_obj,
int pc_offset,
- unsigned long orig_inst);
+ unsigned int orig_inst);
extern void breakpoint_do_displaced_inst(os_context_t *context,
- unsigned long orig_inst);
+ unsigned int orig_inst);
extern void handle_breakpoint(int signal, siginfo_t *info,
os_context_t *context);
extern void *handle_fun_end_breakpoint(int signal, siginfo_t *info,
((char *) *os_context_npc_addr(context)) += 4;
}
-unsigned long arch_install_breakpoint(void *pc)
+unsigned int arch_install_breakpoint(void *pc)
{
- unsigned long *ulpc = (unsigned long *)pc;
- unsigned long orig_inst = *ulpc;
+ unsigned int *ulpc = (unsigned int *)pc;
+ unsigned int orig_inst = *ulpc;
*ulpc = trap_Breakpoint;
os_flush_icache((os_vm_address_t)pc, sizeof(*ulpc));
return orig_inst;
}
-void arch_remove_breakpoint(void *pc, unsigned long orig_inst)
+void arch_remove_breakpoint(void *pc, unsigned int orig_inst)
{
- unsigned long *ulpc = (unsigned long *)pc;
+ unsigned int *ulpc = (unsigned int *)pc;
*ulpc = orig_inst;
os_flush_icache((os_vm_address_t)pc, sizeof(*ulpc));
/* We change the next-pc to point to a breakpoint instruction, restore */
/* the original instruction, and exit. We would like to be able to */
/* sigreturn, but we can't, because this is hpux. */
- unsigned long *pc = (unsigned long *)(SC_PC(scp) & ~3);
+ unsigned int *pc = (unsigned int *)(SC_PC(scp) & ~3);
NextPc = SC_NPC(scp);
- SC_NPC(scp) = (unsigned)SingleStepTraps | (SC_NPC(scp)&3);
+ SC_NPC(scp) = (unsigned int)SingleStepTraps | (SC_NPC(scp)&3);
BreakpointAddr = pc;
*pc = orig_inst;
- os_flush_icache((os_vm_address_t)pc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t)pc, sizeof(unsigned int));
#else
/* We set the recovery counter to cover one instruction, put the */
/* original instruction back in, and then resume. We will then trap */
((struct hp800_thread_state *)scp->sc_ap)->cr0 = 1;
scp->sc_ps |= 0x10;
- *(unsigned long *)SC_PC(scp) = orig_inst;
+ *(unsigned int *)SC_PC(scp) = orig_inst;
sigreturn(scp);
#endif
if (NextPc == NULL)
lose("SingleStepBreakpoint trap at strange time.");
- if ((SC_PC(scp)&~3) == (unsigned long)SingleStepTraps) {
+ if ((SC_PC(scp)&~3) == (unsigned int)SingleStepTraps) {
/* The next instruction was not nullified. */
SC_PC(scp) = NextPc;
- if ((SC_NPC(scp)&~3) == (unsigned long)SingleStepTraps + 4) {
+ if ((SC_NPC(scp)&~3) == (unsigned int)SingleStepTraps + 4) {
/* The instruction we just stepped over was not a branch, so */
/* we need to fix it up. If it was a branch, it will point to */
/* the correct place. */
if (BreakpointAddr) {
*BreakpointAddr = trap_Breakpoint;
os_flush_icache((os_vm_address_t)BreakpointAddr,
- sizeof(unsigned long));
+ sizeof(unsigned int));
BreakpointAddr = NULL;
}
}
static void sigtrap_handler(int signal, siginfo_t *siginfo, void *void_context)
{
os_context_t *context = arch_os_get_context(&void_context);
- unsigned long bad_inst;
+ unsigned int bad_inst;
#if 0
printf("sigtrap_handler, pc=0x%08x, alloc=0x%08x\n", scp->sc_pcoqh,
SC_REG(scp,reg_ALLOC));
#endif
- bad_inst = *(unsigned long *)(*os_context_pc_addr(context) & ~3);
+ bad_inst = *(unsigned int *)(*os_context_pc_addr(context) & ~3);
if (bad_inst & 0xfc001fe0)
interrupt_handle_now(signal, siginfo, context);
else {
static void sigfpe_handler(int signal, siginfo_t *siginfo, void *void_context)
{
os_context_t *context = arch_os_get_context(&void_context);
- unsigned long badinst;
+ unsigned int badinst;
int opcode, r1, r2, t;
long op1, op2, res;
switch (siginfo->si_code) {
case FPE_INTOVF: /*I_OVFLO: */
- badinst = *(unsigned long *)(*os_context_pc_addr(context) & ~3);
+ badinst = *(unsigned int *)(*os_context_pc_addr(context) & ~3);
opcode = badinst >> 26;
if (opcode == 2) {
break;
case 0: /* I_COND: ?? Maybe tagged add?? FIXME */
- badinst = *(unsigned long *)(*os_context_pc_addr(context) & ~3);
+ badinst = *(unsigned int *)(*os_context_pc_addr(context) & ~3);
if ((badinst&0xfffff800) == (0xb000e000|reg_ALLOC<<21|reg_ALLOC<<16)) {
/* It is an ADDIT,OD i,ALLOC,ALLOC instruction that trapped. */
/* That means that it is the end of a pseudo-atomic. So do the */
static void sigbus_handler(int signal, siginfo_t *siginfo, void *void_context)
{
os_context_t *context = arch_os_get_context(&void_context);
- unsigned long badinst;
+ unsigned int badinst;
int opcode, r1, r2, t;
long op1, op2, res;
- badinst = *(unsigned long *)(*os_context_pc_addr(context) & ~3);
+ badinst = *(unsigned int *)(*os_context_pc_addr(context) & ~3);
/* First, test for the pseudo-atomic instruction */
if ((badinst & 0xfffff800) == (0xb000e000 |
reg_ALLOC<<21 |
*os_context_register_addr(context, reg_NL4) |= -1LL<<31;
}
-unsigned long
+unsigned int
arch_install_breakpoint(void *pc)
{
unsigned int *ptr = (unsigned int *)pc;
*ptr = (trap_Breakpoint << 6) | 0xd;
os_flush_icache((os_vm_address_t)ptr, INSN_LEN);
- return (unsigned long)insn;
+ return insn;
}
static inline unsigned int
}
void
-arch_remove_breakpoint(void *pc, unsigned long orig_inst)
+arch_remove_breakpoint(void *pc, unsigned int orig_inst)
{
unsigned int *ptr = (unsigned int *)pc;
if (arch_insn_with_bdelay_p(*ptr))
ptr++;
- *ptr = (unsigned int)orig_inst;
+ *ptr = orig_inst;
os_flush_icache((os_vm_address_t)ptr, INSN_LEN);
}
+= PSEUDO_ATOMIC_INTERRUPTED_BIAS;
}
-unsigned long
+unsigned int
arch_install_breakpoint(void *pc)
{
- unsigned long *ptr = (unsigned long *)pc;
- unsigned long result = *ptr;
+ unsigned int *ptr = (unsigned int *)pc;
+ unsigned int result = *ptr;
*ptr = (3<<26) | (5 << 21) | trap_Breakpoint;
- os_flush_icache((os_vm_address_t) pc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t) pc, sizeof(unsigned int));
return result;
}
void
-arch_remove_breakpoint(void *pc, unsigned long orig_inst)
+arch_remove_breakpoint(void *pc, unsigned int orig_inst)
{
- *(unsigned long *)pc = orig_inst;
- os_flush_icache((os_vm_address_t) pc, sizeof(unsigned long));
+ *(unsigned int *)pc = orig_inst;
+ os_flush_icache((os_vm_address_t) pc, sizeof(unsigned int));
}
-static unsigned long *skipped_break_addr, displaced_after_inst;
+/*
+ * Perform the instruction that we overwrote with a breakpoint. As we
+ * don't have a single-step facility, this means we have to:
+ * - put the instruction back
+ * - put a second breakpoint at the following instruction,
+ * set after_breakpoint and continue execution.
+ *
+ * When the second breakpoint is hit (very shortly thereafter, we hope)
+ * sigtrap_handler gets called again, but follows the AfterBreakpoint
+ * arm, which
+ * - puts a bpt back in the first breakpoint place (running across a
+ * breakpoint shouldn't cause it to be uninstalled)
+ * - replaces the second bpt with the instruction it was meant to be
+ * - carries on
+ *
+ * Clear?
+ */
+static unsigned int *skipped_break_addr, displaced_after_inst;
static sigset_t orig_sigmask;
void
{
/* not sure how we ensure that we get the breakpoint reinstalled
* after doing this -dan */
- unsigned long *pc = (unsigned long *)(*os_context_pc_addr(context));
+ unsigned int *pc = (unsigned int *)(*os_context_pc_addr(context));
orig_sigmask = *os_context_sigmask_addr(context);
sigaddset_blockable(os_context_sigmask_addr(context));
*pc = orig_inst;
- os_flush_icache((os_vm_address_t) pc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t) pc, sizeof(unsigned int));
skipped_break_addr = pc;
}
static void
sigtrap_handler(int signal, siginfo_t *siginfo, os_context_t *context)
{
- u32 code;
+ unsigned int code;
#ifdef LISP_FEATURE_LINUX
os_restore_fp_control(context);
#endif
case trap_AfterBreakpoint:
*skipped_break_addr = trap_Breakpoint;
skipped_break_addr = NULL;
- *(unsigned long *)*os_context_pc_addr(context)
+ *(unsigned int *)*os_context_pc_addr(context)
= displaced_after_inst;
*os_context_sigmask_addr(context)= orig_sigmask;
os_flush_icache((os_vm_address_t) *os_context_pc_addr(context),
- sizeof(unsigned long));
+ sizeof(unsigned int));
break;
default:
os_vm_address_t arch_get_bad_addr(int sig, siginfo_t *code, os_context_t *context)
{
- unsigned long badinst;
- unsigned long *pc;
+ unsigned int badinst;
+ unsigned int *pc;
int rs1;
- pc = (unsigned long *)(*os_context_pc_addr(context));
+ pc = (unsigned int *)(*os_context_pc_addr(context));
/* On the sparc, we have to decode the instruction. */
*os_context_register_addr(context,reg_ALLOC) |= 1;
}
-unsigned long arch_install_breakpoint(void *pc)
+unsigned int arch_install_breakpoint(void *pc)
{
- unsigned long *ptr = (unsigned long *)pc;
- unsigned long result = *ptr;
+ unsigned int *ptr = (unsigned int *)pc;
+ unsigned int result = *ptr;
*ptr = trap_Breakpoint;
- os_flush_icache((os_vm_address_t) pc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t) pc, sizeof(unsigned int));
return result;
}
-void arch_remove_breakpoint(void *pc, unsigned long orig_inst)
+void arch_remove_breakpoint(void *pc, unsigned int orig_inst)
{
- *(unsigned long *)pc = orig_inst;
- os_flush_icache((os_vm_address_t) pc, sizeof(unsigned long));
+ *(unsigned int *)pc = orig_inst;
+ os_flush_icache((os_vm_address_t) pc, sizeof(unsigned int));
}
-static unsigned long *skipped_break_addr, displaced_after_inst;
+/*
+ * Perform the instruction that we overwrote with a breakpoint. As we
+ * don't have a single-step facility, this means we have to:
+ * - put the instruction back
+ * - put a second breakpoint at the following instruction,
+ * set after_breakpoint and continue execution.
+ *
+ * When the second breakpoint is hit (very shortly thereafter, we hope)
+ * sigtrap_handler gets called again, but follows the AfterBreakpoint
+ * arm, which
+ * - puts a bpt back in the first breakpoint place (running across a
+ * breakpoint shouldn't cause it to be uninstalled)
+ * - replaces the second bpt with the instruction it was meant to be
+ * - carries on
+ *
+ * Clear?
+ */
+static unsigned int *skipped_break_addr, displaced_after_inst;
static sigset_t orig_sigmask;
void arch_do_displaced_inst(os_context_t *context, unsigned int orig_inst)
{
- unsigned long *pc = (unsigned long *)(*os_context_pc_addr(context));
- unsigned long *npc = (unsigned long *)(*os_context_npc_addr(context));
+ unsigned int *pc = (unsigned int *)(*os_context_pc_addr(context));
+ unsigned int *npc = (unsigned int *)(*os_context_npc_addr(context));
/* orig_sigmask = context->sigmask;
sigemptyset(&context->sigmask); */
/* FILLBLOCKSET(&context->uc_sigmask);*/
*pc = orig_inst;
- os_flush_icache((os_vm_address_t) pc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t) pc, sizeof(unsigned int));
skipped_break_addr = pc;
displaced_after_inst = *npc;
*npc = trap_AfterBreakpoint;
- os_flush_icache((os_vm_address_t) npc, sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t) npc, sizeof(unsigned int));
}
case trap_AfterBreakpoint:
*skipped_break_addr = trap_Breakpoint;
+ os_flush_icache(skipped_break_addr, sizeof(unsigned int));
skipped_break_addr = NULL;
*(unsigned long *) os_context_pc_addr(context) = displaced_after_inst;
/* context->sigmask = orig_sigmask; */
- os_flush_icache((os_vm_address_t) os_context_pc_addr(context), sizeof(unsigned long));
+ os_flush_icache((os_vm_address_t) os_context_pc_addr(context), sizeof(unsigned int));
break;
default:
static void sigemt_handler(int signal, siginfo_t *siginfo, void *void_context)
{
- unsigned long badinst;
+ unsigned int badinst;
boolean subtract, immed;
int rd, rs1, op1, rs2, op2, result;
os_context_t *context = arch_os_get_context(&void_context);
os_restore_fp_control(context);
#endif
- badinst = *(unsigned long *)os_context_pc_addr(context);
+ badinst = *(unsigned int *)os_context_pc_addr(context);
if ((badinst >> 30) != 2 || ((badinst >> 20) & 0x1f) != 0x11) {
/* It wasn't a tagged add. Pass the signal into lisp. */
interrupt_handle_now(signal, siginfo, context);
* This stuff seems to get called for TRACE and debug activity.
*/
-unsigned long
+unsigned int
arch_install_breakpoint(void *pc)
{
- unsigned long result = *(unsigned long*)pc;
+ unsigned int result = *(unsigned int*)pc;
*(char*)pc = BREAKPOINT_INST; /* x86 INT3 */
*((char*)pc+1) = trap_Breakpoint; /* Lisp trap code */
}
void
-arch_remove_breakpoint(void *pc, unsigned long orig_inst)
+arch_remove_breakpoint(void *pc, unsigned int orig_inst)
{
*((char *)pc) = orig_inst & 0xff;
*((char *)pc + 1) = (orig_inst & 0xff00) >> 8;
\f
/* When single stepping, single_stepping holds the original instruction
* PC location. */
-unsigned long *single_stepping = NULL;
+unsigned int *single_stepping = NULL;
#ifdef CANNOT_GET_TO_SINGLE_STEP_FLAG
unsigned long single_step_save1;
unsigned long single_step_save2;
void
arch_do_displaced_inst(os_context_t *context, unsigned int orig_inst)
{
- unsigned long *pc = (unsigned long*)(*os_context_pc_addr(context));
+ unsigned int *pc = (unsigned int*)(*os_context_pc_addr(context));
/* Put the original instruction back. */
*((char *)pc) = orig_inst & 0xff;
*context_eflags_addr(context) |= 0x100;
#endif
- single_stepping = (unsigned int*)pc;
+ single_stepping = pc;
#ifdef CANNOT_GET_TO_SINGLE_STEP_FLAG
*os_context_pc_addr(context) = (char *)pc - 9;
* This stuff seems to get called for TRACE and debug activity.
*/
-unsigned long
+unsigned int
arch_install_breakpoint(void *pc)
{
- unsigned long result = *(unsigned long*)pc;
+ unsigned int result = *(unsigned int*)pc;
*(char*)pc = BREAKPOINT_INST; /* x86 INT3 */
*((char*)pc+1) = trap_Breakpoint; /* Lisp trap code */
}
void
-arch_remove_breakpoint(void *pc, unsigned long orig_inst)
+arch_remove_breakpoint(void *pc, unsigned int orig_inst)
{
*((char *)pc) = orig_inst & 0xff;
*((char *)pc + 1) = (orig_inst & 0xff00) >> 8;
*context_eflags_addr(context) |= 0x100;
#endif
- single_stepping = (unsigned int*)pc;
+ single_stepping = pc;
#ifdef CANNOT_GET_TO_SINGLE_STEP_FLAG
*os_context_pc_addr(context) = (char *)pc - 9;
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.5"
+"0.9.5.1"