Page MenuHomeFreeBSD

D32735.diff
No OneTemporary

D32735.diff

diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h
--- a/sys/amd64/linux/linux.h
+++ b/sys/amd64/linux/linux.h
@@ -461,5 +461,8 @@
void bsd_to_linux_regset(const struct reg *b_reg,
struct linux_pt_regset *l_regset);
+void linux_to_bsd_regset(struct reg *b_reg,
+ const struct linux_pt_regset *l_regset);
+
#endif /* !_AMD64_LINUX_H_ */
diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c
--- a/sys/amd64/linux/linux_machdep.c
+++ b/sys/amd64/linux/linux_machdep.c
@@ -330,3 +330,34 @@
l_regset->fs = b_reg->r_fs;
l_regset->gs = b_reg->r_gs;
}
+
+void
+linux_to_bsd_regset(struct reg *b_reg, const struct linux_pt_regset *l_regset)
+{
+
+ b_reg->r_r15 = l_regset->r15;
+ b_reg->r_r14 = l_regset->r14;
+ b_reg->r_r13 = l_regset->r13;
+ b_reg->r_r12 = l_regset->r12;
+ b_reg->r_rbp = l_regset->rbp;
+ b_reg->r_rbx = l_regset->rbx;
+ b_reg->r_r11 = l_regset->r11;
+ b_reg->r_r10 = l_regset->r10;
+ b_reg->r_r9 = l_regset->r9;
+ b_reg->r_r8 = l_regset->r8;
+ b_reg->r_rax = l_regset->rax;
+ b_reg->r_rcx = l_regset->rcx;
+ b_reg->r_rdx = l_regset->rdx;
+ b_reg->r_rsi = l_regset->rsi;
+ b_reg->r_rdi = l_regset->rdi;
+ b_reg->r_rax = l_regset->orig_rax;
+ b_reg->r_rip = l_regset->rip;
+ b_reg->r_cs = l_regset->cs;
+ b_reg->r_rflags = l_regset->eflags;
+ b_reg->r_rsp = l_regset->rsp;
+ b_reg->r_ss = l_regset->ss;
+ b_reg->r_ds = l_regset->ds;
+ b_reg->r_es = l_regset->es;
+ b_reg->r_fs = l_regset->fs;
+ b_reg->r_gs = l_regset->gs;
+}
diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c
--- a/sys/amd64/linux/linux_ptrace.c
+++ b/sys/amd64/linux/linux_ptrace.c
@@ -168,30 +168,6 @@
return (status);
}
-struct linux_pt_reg {
- l_ulong r15;
- l_ulong r14;
- l_ulong r13;
- l_ulong r12;
- l_ulong rbp;
- l_ulong rbx;
- l_ulong r11;
- l_ulong r10;
- l_ulong r9;
- l_ulong r8;
- l_ulong rax;
- l_ulong rcx;
- l_ulong rdx;
- l_ulong rsi;
- l_ulong rdi;
- l_ulong orig_rax;
- l_ulong rip;
- l_ulong cs;
- l_ulong eflags;
- l_ulong rsp;
- l_ulong ss;
-};
-
struct syscall_info {
uint8_t op;
uint32_t arch;
@@ -214,42 +190,6 @@
};
};
-static void
-map_regs_from_linux(struct reg *b_reg, struct linux_pt_reg *l_reg)
-{
- b_reg->r_r15 = l_reg->r15;
- b_reg->r_r14 = l_reg->r14;
- b_reg->r_r13 = l_reg->r13;
- b_reg->r_r12 = l_reg->r12;
- b_reg->r_r11 = l_reg->r11;
- b_reg->r_r10 = l_reg->r10;
- b_reg->r_r9 = l_reg->r9;
- b_reg->r_r8 = l_reg->r8;
- b_reg->r_rdi = l_reg->rdi;
- b_reg->r_rsi = l_reg->rsi;
- b_reg->r_rbp = l_reg->rbp;
- b_reg->r_rbx = l_reg->rbx;
- b_reg->r_rdx = l_reg->rdx;
- b_reg->r_rcx = l_reg->rcx;
- b_reg->r_rax = l_reg->rax;
-
- /*
- * XXX: Are zeroes the right thing to put here?
- */
- b_reg->r_trapno = 0;
- b_reg->r_fs = 0;
- b_reg->r_gs = 0;
- b_reg->r_err = 0;
- b_reg->r_es = 0;
- b_reg->r_ds = 0;
-
- b_reg->r_rip = l_reg->rip;
- b_reg->r_cs = l_reg->cs;
- b_reg->r_rflags = l_reg->eflags;
- b_reg->r_rsp = l_reg->rsp;
- b_reg->r_ss = l_reg->ss;
-}
-
static int
linux_ptrace_peek(struct thread *td, pid_t pid, void *addr, void *data)
{
@@ -446,13 +386,13 @@
linux_ptrace_setregs(struct thread *td, pid_t pid, void *data)
{
struct reg b_reg;
- struct linux_pt_reg l_reg;
+ struct linux_pt_regset l_regset;
int error;
- error = copyin(data, &l_reg, sizeof(l_reg));
+ error = copyin(data, &l_regset, sizeof(l_regset));
if (error != 0)
return (error);
- map_regs_from_linux(&b_reg, &l_reg);
+ linux_to_bsd_regset(&b_reg, &l_regset);
error = kern_ptrace(td, PT_SETREGS, pid, &b_reg, 0);
return (error);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 31, 3:19 AM (10 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16352951
Default Alt Text
D32735.diff (3 KB)

Event Timeline