summaryrefslogtreecommitdiff
path: root/sys/amd64
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2004-07-10 19:56:00 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2004-07-10 19:56:00 +0000
commit5a39cbaf691680e0efa60ed8fa28fa9f1232ecaa (patch)
treeef114b5aee4601f2523b9d10bcaef23b379b7b6a /sys/amd64
parent0aefe3632ecf2a584bb5edca9652b8fc3340f4fc (diff)
Notes
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/machdep.c21
-rw-r--r--sys/amd64/include/pcb.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 2d0fd66dcd4d..8a107ab76a4b 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1265,6 +1265,27 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size)
pcpu->pc_acpi_id = 0xffffffff;
}
+/*
+ * Construct a PCB from a trapframe. This is called from kdb_trap() where
+ * we want to start a backtrace from the function that caused us to enter
+ * the debugger. We have the context in the trapframe, but base the trace
+ * on the PCB. The PCB doesn't have to be perfect, as long as it contains
+ * enough for a backtrace.
+ */
+void
+makectx(struct trapframe *tf, struct pcb *pcb)
+{
+
+ pcb->pcb_r12 = tf->tf_r12;
+ pcb->pcb_r13 = tf->tf_r13;
+ pcb->pcb_r14 = tf->tf_r14;
+ pcb->pcb_r15 = tf->tf_r15;
+ pcb->pcb_rbp = tf->tf_rbp;
+ pcb->pcb_rbx = tf->tf_rbx;
+ pcb->pcb_rip = tf->tf_rip;
+ pcb->pcb_rsp = (ISPL(tf->tf_cs)) ? tf->tf_rsp : (long)(tf + 1) - 8;
+}
+
int
ptrace_set_pc(struct thread *td, unsigned long addr)
{
diff --git a/sys/amd64/include/pcb.h b/sys/amd64/include/pcb.h
index 73d8aa558795..305b7ff895fe 100644
--- a/sys/amd64/include/pcb.h
+++ b/sys/amd64/include/pcb.h
@@ -78,6 +78,9 @@ struct pcb {
};
#ifdef _KERNEL
+struct trapframe;
+
+void makectx(struct trapframe *, struct pcb *);
void savectx(struct pcb *);
#endif