aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2011-02-16 17:50:21 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2011-02-16 17:50:21 +0000
commitdc4f0a9e11b007160b89044731712681dce4a07a (patch)
tree62146c6eb0e72714302c3b80c1ce60ea243223cf /sys/amd64
parent4fd8408ae751af7c07ff8caef79f360145ee8efc (diff)
downloadsrc-dc4f0a9e11b007160b89044731712681dce4a07a.tar.gz
src-dc4f0a9e11b007160b89044731712681dce4a07a.zip
To avoid excessive code duplication create wrapper for fill regs
from stack frame. Change the trap() code to use newly created function instead of explicit regs assignment.
Notes
Notes: svn path=/head/; revision=218744
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/machdep.c6
-rw-r--r--sys/amd64/amd64/trap.c34
-rw-r--r--sys/amd64/include/reg.h1
3 files changed, 9 insertions, 32 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index d350aa691c86..d1f841694069 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1842,6 +1842,12 @@ fill_regs(struct thread *td, struct reg *regs)
struct trapframe *tp;
tp = td->td_frame;
+ return (fill_frame_regs(tp, regs));
+}
+
+int
+fill_frame_regs(struct trapframe *tp, struct reg *regs)
+{
regs->r_r15 = tp->tf_r15;
regs->r_r14 = tp->tf_r14;
regs->r_r13 = tp->tf_r13;
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index e5184a6f6d3a..5c755cde61cb 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -249,38 +249,8 @@ trap(struct trapframe *frame)
if (type == T_DTRACE_PROBE || type == T_DTRACE_RET ||
type == T_BPTFLT) {
struct reg regs;
-
- regs.r_r15 = frame->tf_r15;
- regs.r_r14 = frame->tf_r14;
- regs.r_r13 = frame->tf_r13;
- regs.r_r12 = frame->tf_r12;
- regs.r_r11 = frame->tf_r11;
- regs.r_r10 = frame->tf_r10;
- regs.r_r9 = frame->tf_r9;
- regs.r_r8 = frame->tf_r8;
- regs.r_rdi = frame->tf_rdi;
- regs.r_rsi = frame->tf_rsi;
- regs.r_rbp = frame->tf_rbp;
- regs.r_rbx = frame->tf_rbx;
- regs.r_rdx = frame->tf_rdx;
- regs.r_rcx = frame->tf_rcx;
- regs.r_rax = frame->tf_rax;
- regs.r_rip = frame->tf_rip;
- regs.r_cs = frame->tf_cs;
- regs.r_rflags = frame->tf_rflags;
- regs.r_rsp = frame->tf_rsp;
- regs.r_ss = frame->tf_ss;
- if (frame->tf_flags & TF_HASSEGS) {
- regs.r_ds = frame->tf_ds;
- regs.r_es = frame->tf_es;
- regs.r_fs = frame->tf_fs;
- regs.r_gs = frame->tf_gs;
- } else {
- regs.r_ds = 0;
- regs.r_es = 0;
- regs.r_fs = 0;
- regs.r_gs = 0;
- }
+
+ fill_frame_regs(frame, &regs);
if (type == T_DTRACE_PROBE &&
dtrace_fasttrap_probe_ptr != NULL &&
dtrace_fasttrap_probe_ptr(&regs) == 0)
diff --git a/sys/amd64/include/reg.h b/sys/amd64/include/reg.h
index 592084318ebc..275a9982313c 100644
--- a/sys/amd64/include/reg.h
+++ b/sys/amd64/include/reg.h
@@ -130,6 +130,7 @@ struct dbreg {
* XXX these interfaces are MI, so they should be declared in a MI place.
*/
int fill_regs(struct thread *, struct reg *);
+int fill_frame_regs(struct trapframe *, struct reg *);
int set_regs(struct thread *, struct reg *);
int fill_fpregs(struct thread *, struct fpreg *);
int set_fpregs(struct thread *, struct fpreg *);