summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2018-07-04 17:52:30 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2018-07-04 17:52:30 +0000
commit11362c6c7cabcf7e045553f2434744084bf45d08 (patch)
treea18ec9fb654bd4ba026c6ca82ab8e50642d01ad8 /sys/arch
parent5c660606ecc99ecfa6e8a7105ef6fb197d09718a (diff)
ptrace debug support for arm64.
Single step is not yet supported but reading and setting registers are working as expected, breakpoints also are working. ok kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/arm64/process_machdep.c22
-rw-r--r--sys/arch/arm64/include/pcb.h3
2 files changed, 21 insertions, 4 deletions
diff --git a/sys/arch/arm64/arm64/process_machdep.c b/sys/arch/arm64/arm64/process_machdep.c
index 79d2d959e5c..0c6e0c444ac 100644
--- a/sys/arch/arm64/arm64/process_machdep.c
+++ b/sys/arch/arm64/arm64/process_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process_machdep.c,v 1.3 2017/04/11 06:52:13 kettenis Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.4 2018/07/04 17:52:29 drahn Exp $ */
/*
* Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
*
@@ -81,26 +81,42 @@ process_read_fpregs(struct proc *p, struct fpreg *regs)
int
process_write_regs(struct proc *p, struct reg *regs)
{
+ struct trapframe *tf = p->p_addr->u_pcb.pcb_tf;
+
+ memcpy(&tf->tf_x[0], &regs->r_reg[0], sizeof(tf->tf_x));
+ tf->tf_lr = regs->r_lr;
+ tf->tf_sp = regs->r_sp;
+ tf->tf_elr = regs->r_pc;
+ tf->tf_spsr = (0xff0f0000 & regs->r_spsr) | (tf->tf_spsr & 0x0000ffff);
+ p->p_addr->u_pcb.pcb_tcb = (void *)regs->r_tpidr;
return(0);
}
int
process_write_fpregs(struct proc *p, struct fpreg *regs)
{
+ p->p_addr->u_pcb.pcb_flags |= PCB_FPU;
+ memcpy(&p->p_addr->u_pcb.pcb_fpstate, regs,
+ sizeof(p->p_addr->u_pcb.pcb_fpstate));
return(0);
}
int
process_sstep(struct proc *p, int sstep)
{
- if (sstep)
- return (EINVAL);
+ if (sstep) {
+ p->p_addr->u_pcb.pcb_flags |= PCB_SINGLESTEP;
+ } else {
+ p->p_addr->u_pcb.pcb_flags &= ~(PCB_SINGLESTEP);
+ }
return 0;
}
int
process_set_pc(struct proc *p, caddr_t addr)
{
+ struct trapframe *tf = p->p_addr->u_pcb.pcb_tf;
+ tf->tf_elr = (uint64_t)addr;
return (0);
}
diff --git a/sys/arch/arm64/include/pcb.h b/sys/arch/arm64/include/pcb.h
index c242aab93ac..d56a1c1f7ab 100644
--- a/sys/arch/arm64/include/pcb.h
+++ b/sys/arch/arm64/include/pcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcb.h,v 1.3 2017/03/24 19:48:01 kettenis Exp $ */
+/* $OpenBSD: pcb.h,v 1.4 2018/07/04 17:52:29 drahn Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
*
@@ -31,6 +31,7 @@ struct trapframe;
struct pcb {
u_int pcb_flags;
#define PCB_FPU 0x00000001 /* Process had FPU initialized */
+#define PCB_SINGLESTEP 0x00000002 /* Single step process */
struct trapframe *pcb_tf;
register_t pcb_sp; // stack pointer of switchframe