From a6e8381902d2239ab2d3948b6a0d62ff428c29bd Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 2 Nov 2015 23:56:43 +0100
Subject: [PATCH] gdb: Reduce the recent changes to only the necessary bits in
 amd64dfly-nat.c.

This makes maintenance of base and dports gdb easier.

Suggested-by:   marino
Discussed-with: tuxillo
---
 contrib/gdb-7/gdb/amd64dfly-nat.c  | 325 +++++++++++++++++++------------------
 contrib/gdb-7/gdb/amd64dfly-tdep.c | 196 +++++++++++-----------
 contrib/gdb-7/gdb/i386dfly-nat.c   | 232 +++++++++++++-------------
 contrib/gdb-7/gdb/i386dfly-tdep.c  |  95 ++++++-----
 4 files changed, 430 insertions(+), 418 deletions(-)

diff --git a/contrib/gdb-7/gdb/amd64dfly-nat.c b/contrib/gdb-7/gdb/amd64dfly-nat.c
index 89d2c79..d3fc772 100644
--- a/contrib/gdb-7/gdb/amd64dfly-nat.c
+++ b/contrib/gdb-7/gdb/amd64dfly-nat.c
@@ -15,7 +15,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "inferior.h"
@@ -37,6 +37,7 @@
 #include "amd64-nat.h"
 #include "amd64bsd-nat.h"
 #include "i386-nat.h"
+
 
 /* Offset in `struct reg' where MEMBER is stored.  */
 #define REG_OFFSET(member) offsetof (struct reg, member)
@@ -46,31 +47,32 @@
    Unsupported registers are marked with `-1'.  */
 static int amd64dfly64_r_reg_offset[] =
 {
-	REG_OFFSET(r_rax),
-	REG_OFFSET(r_rbx),
-	REG_OFFSET(r_rcx),
-	REG_OFFSET(r_rdx),
-	REG_OFFSET(r_rsi),
-	REG_OFFSET(r_rdi),
-	REG_OFFSET(r_rbp),
-	REG_OFFSET(r_rsp),
-	REG_OFFSET(r_r8),
-	REG_OFFSET(r_r9),
-	REG_OFFSET(r_r10),
-	REG_OFFSET(r_r11),
-	REG_OFFSET(r_r12),
-	REG_OFFSET(r_r13),
-	REG_OFFSET(r_r14),
-	REG_OFFSET(r_r15),
-	REG_OFFSET(r_rip),
-	REG_OFFSET(r_rflags),
-	REG_OFFSET(r_cs),
-	REG_OFFSET(r_ss),
-	-1,
-	-1,
-	-1,
-	-1
+  REG_OFFSET (r_rax),
+  REG_OFFSET (r_rbx),
+  REG_OFFSET (r_rcx),
+  REG_OFFSET (r_rdx),
+  REG_OFFSET (r_rsi),
+  REG_OFFSET (r_rdi),
+  REG_OFFSET (r_rbp),
+  REG_OFFSET (r_rsp),
+  REG_OFFSET (r_r8),
+  REG_OFFSET (r_r9),
+  REG_OFFSET (r_r10),
+  REG_OFFSET (r_r11),
+  REG_OFFSET (r_r12),
+  REG_OFFSET (r_r13),
+  REG_OFFSET (r_r14),
+  REG_OFFSET (r_r15),
+  REG_OFFSET (r_rip),
+  REG_OFFSET (r_rflags),
+  REG_OFFSET (r_cs),
+  REG_OFFSET (r_ss),
+  -1,
+  -1,
+  -1,
+  -1
 };
+
 
 /* Mapping between the general-purpose registers in DragonFly/amd64
    `struct reg' format and GDB's register cache layout for
@@ -83,14 +85,15 @@ static int amd64dfly64_r_reg_offset[] =
 /* From <machine/reg.h>.  */
 static int amd64dfly32_r_reg_offset[I386_NUM_GREGS] =
 {
-	14 * 8, 13 * 8,		/* %eax, %ecx */
-	12 * 8, 11 * 8,		/* %edx, %ebx */
-	20 * 8, 10 * 8,		/* %esp, %ebp */
-	9 * 8, 8 * 8,		/* %esi, %edi */
-	17 * 8, 19 * 8,		/* %eip, %eflags */
-	18 * 8, 21 * 8,		/* %cs, %ss */
-	-1, -1, -1, -1		/* %ds, %es, %fs, %gs */
+  14 * 8, 13 * 8,		/* %eax, %ecx */
+  12 * 8, 11 * 8,		/* %edx, %ebx */
+  20 * 8, 10 * 8,		/* %esp, %ebp */
+  9 * 8, 8 * 8,			/* %esi, %edi */
+  17 * 8, 19 * 8,		/* %eip, %eflags */
+  18 * 8, 21 * 8,		/* %cs, %ss */
+  -1, -1, -1, -1		/* %ds, %es, %fs, %gs */
 };
+
 
 #ifdef DFLY_PCB_SUPPLY
 /* Transfering the registers between GDB, inferiors and core files.  */
@@ -99,9 +102,9 @@ static int amd64dfly32_r_reg_offset[I386_NUM_GREGS] =
    in *GREGSETP.  */
 
 void
-supply_gregset(struct regcache *regcache, const gregset_t * gregsetp)
+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
 {
-	amd64_supply_native_gregset(regcache, gregsetp, -1);
+  amd64_supply_native_gregset (regcache, gregsetp, -1);
 }
 
 /* Fill register REGNUM (if it is a general-purpose register) in
@@ -109,18 +112,18 @@ supply_gregset(struct regcache *regcache, const gregset_t * gregsetp)
    do this for all registers.  */
 
 void
-fill_gregset(const struct regcache *regcache, gdb_gregset_t * gregsetp, int regnum)
+fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum)
 {
-	amd64_collect_native_gregset(regcache, gregsetp, regnum);
+  amd64_collect_native_gregset (regcache, gregsetp, regnum);
 }
 
 /* Fill GDB's register array with the floating-point register values
    in *FPREGSETP.  */
 
 void
-supply_fpregset(struct regcache *regcache, const fpregset_t * fpregsetp)
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
 {
-	amd64_supply_fxsave(regcache, -1, fpregsetp);
+  amd64_supply_fxsave (regcache, -1, fpregsetp);
 }
 
 /* Fill register REGNUM (if it is a floating-point register) in
@@ -128,11 +131,11 @@ supply_fpregset(struct regcache *regcache, const fpregset_t * fpregsetp)
    do this for all registers.  */
 
 void
-fill_fpregset(const struct regcache *regcache, gdb_fpregset_t * fpregsetp, int regnum)
+fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum)
 {
-	amd64_collect_fxsave(regcache, regnum, fpregsetp);
+  amd64_collect_fxsave (regcache, regnum, fpregsetp);
 }
-
+
 /* Support for debugging kernel virtual memory images.  */
 
 #include <sys/types.h>
@@ -142,44 +145,50 @@ fill_fpregset(const struct regcache *regcache, gdb_fpregset_t * fpregsetp, int r
 #include "bsd-kvm.h"
 
 static int
-amd64dfly_supply_pcb(struct regcache *regcache, struct pcb *pcb)
+amd64dfly_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 {
-	/* The following is true for FreeBSD 5.2:
-	 *
-	 * The pcb contains %rip, %rbx, %rsp, %rbp, %r12, %r13, %r14, %r15, %ds,
-	 * %es, %fs and %gs.  This accounts for all callee-saved registers
-	 * specified by the psABI and then some.  Here %esp contains the stack
-	 * pointer at the point just after the call to cpu_switch().  From
-	 * this information we reconstruct the register state as it would like
-	 * when we just returned from cpu_switch().  */
-
-	/* The stack pointer shouldn't be zero.  */
-	if (pcb->pcb_rsp == 0)
-		return 0;
+  /* The following is true for FreeBSD 5.2:
+
+     The pcb contains %rip, %rbx, %rsp, %rbp, %r12, %r13, %r14, %r15,
+     %ds, %es, %fs and %gs.  This accounts for all callee-saved
+     registers specified by the psABI and then some.  Here %esp
+     contains the stack pointer at the point just after the call to
+     cpu_switch().  From this information we reconstruct the register
+     state as it would like when we just returned from cpu_switch().  */
+
+  /* The stack pointer shouldn't be zero.  */
+  if (pcb->pcb_rsp == 0)
+    return 0;
+
+  pcb->pcb_rsp += 8;
+  regcache_raw_supply (regcache, AMD64_RIP_REGNUM, &pcb->pcb_rip);
+  regcache_raw_supply (regcache, AMD64_RBX_REGNUM, &pcb->pcb_rbx);
+  regcache_raw_supply (regcache, AMD64_RSP_REGNUM, &pcb->pcb_rsp);
+  regcache_raw_supply (regcache, AMD64_RBP_REGNUM, &pcb->pcb_rbp);
+  regcache_raw_supply (regcache, 12, &pcb->pcb_r12);
+  regcache_raw_supply (regcache, 13, &pcb->pcb_r13);
+  regcache_raw_supply (regcache, 14, &pcb->pcb_r14);
+  regcache_raw_supply (regcache, 15, &pcb->pcb_r15);
+#if (__FreeBSD_version < 800075) && (__FreeBSD_kernel_version < 800075)
+  /* struct pcb provides the pcb_ds/pcb_es/pcb_fs/pcb_gs fields only
+     up until __FreeBSD_version 800074: The removal of these fields
+     occurred on 2009-04-01 while the __FreeBSD_version number was
+     bumped to 800075 on 2009-04-06.  So 800075 is the closest version
+     number where we should not try to access these fields.  */
+  regcache_raw_supply (regcache, AMD64_DS_REGNUM, &pcb->pcb_ds);
+  regcache_raw_supply (regcache, AMD64_ES_REGNUM, &pcb->pcb_es);
+  regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs);
+  regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs);
+#endif
 
-	pcb->pcb_rsp += 8;
-	regcache_raw_supply(regcache, AMD64_RIP_REGNUM, &pcb->pcb_rip);
-	regcache_raw_supply(regcache, AMD64_RBX_REGNUM, &pcb->pcb_rbx);
-	regcache_raw_supply(regcache, AMD64_RSP_REGNUM, &pcb->pcb_rsp);
-	regcache_raw_supply(regcache, AMD64_RBP_REGNUM, &pcb->pcb_rbp);
-	regcache_raw_supply(regcache, 12, &pcb->pcb_r12);
-	regcache_raw_supply(regcache, 13, &pcb->pcb_r13);
-	regcache_raw_supply(regcache, 14, &pcb->pcb_r14);
-	regcache_raw_supply(regcache, 15, &pcb->pcb_r15);
-
-	return 1;
+  return 1;
 }
-#endif				/* DFLY_PCB_SUPPLY */
+#endif /* DFLY_PCB_SUPPLY */
+
 
 static void (*super_mourn_inferior) (struct target_ops *ops);
 
-/*
- * XXX Checks if inside a vkernel.
- *
- * Current vkernel(7) does not have support for PT_GETDBREGS/PT_SETDBREGS
- * via ptrace(2). It is not a platform on its own either so there are not
- * platform-specific files to change but this one. This is just a workaround.
- */
+/* Work around vkernels not having PT_{GET,SET}DBREGS via ptrace(2) support. */
 static int
 is_vkernel(void)
 {
@@ -187,10 +196,8 @@ is_vkernel(void)
 	char buf[64];
 
 	len = sizeof(buf);
-	if (sysctlbyname("kern.vmm_guest", buf, &len, NULL, 0) < 0) {
+	if (sysctlbyname("kern.vmm_guest", buf, &len, NULL, 0) < 0)
 		return 0;
-	}
-
 	if (strncmp("vkernel", buf, len) == 0)
 		return 1;
 	else
@@ -198,124 +205,132 @@ is_vkernel(void)
 }
 
 static void
-amd64dfly_mourn_inferior(struct target_ops *ops)
+amd64dfly_mourn_inferior (struct target_ops *ops)
 {
 #ifdef HAVE_PT_GETDBREGS
-	if (!is_vkernel())
-		i386_cleanup_dregs();
+  if (!isvkernel())
+  i386_cleanup_dregs ();
 #endif
-	super_mourn_inferior(ops);
+  super_mourn_inferior (ops);
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
-void _initialize_amd64dfly_nat(void);
+void _initialize_amd64dfly_nat (void);
 
 void
-_initialize_amd64dfly_nat(void)
+_initialize_amd64dfly_nat (void)
 {
-	struct target_ops *t;
-	int offset;
+  struct target_ops *t;
+  int offset;
 
-	amd64_native_gregset32_reg_offset = amd64dfly32_r_reg_offset;
-	amd64_native_gregset64_reg_offset = amd64dfly64_r_reg_offset;
+  amd64_native_gregset32_reg_offset = amd64dfly32_r_reg_offset;
+  amd64_native_gregset64_reg_offset = amd64dfly64_r_reg_offset;
 
-	/* Add some extra features to the common *BSD/i386 target.  */
-	t = amd64bsd_target();
+  /* Add some extra features to the common *BSD/i386 target.  */
+  t = amd64bsd_target ();
 
 #ifdef HAVE_PT_GETDBREGS
 
-	if (!is_vkernel()) {
-		i386_use_watchpoints(t);
+  if (!is_vkernel()) {
+  i386_use_watchpoints (t);
 
-		i386_dr_low.set_control = amd64bsd_dr_set_control;
-		i386_dr_low.set_addr = amd64bsd_dr_set_addr;
-		i386_dr_low.get_addr = amd64bsd_dr_get_addr;
-		i386_dr_low.get_status = amd64bsd_dr_get_status;
-		i386_dr_low.get_control = amd64bsd_dr_get_control;
-		i386_set_debug_register_length(8);
-	}
+  i386_dr_low.set_control = amd64bsd_dr_set_control;
+  i386_dr_low.set_addr = amd64bsd_dr_set_addr;
+  i386_dr_low.get_addr = amd64bsd_dr_get_addr;
+  i386_dr_low.get_status = amd64bsd_dr_get_status;
+  i386_dr_low.get_control = amd64bsd_dr_get_control;
+  i386_set_debug_register_length (8);
+  }
 
-#endif				/* HAVE_PT_GETDBREGS */
+#endif /* HAVE_PT_GETDBREGS */
 
-	super_mourn_inferior = t->to_mourn_inferior;
-	t->to_mourn_inferior = amd64dfly_mourn_inferior;
+  super_mourn_inferior = t->to_mourn_inferior;
+  t->to_mourn_inferior = amd64dfly_mourn_inferior;
 
-	t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
-	t->to_find_memory_regions = fbsd_find_memory_regions;
-	t->to_make_corefile_notes = fbsd_make_corefile_notes;
-	add_target(t);
+  t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+  t->to_find_memory_regions = fbsd_find_memory_regions;
+  t->to_make_corefile_notes = fbsd_make_corefile_notes;
+  add_target (t);
 
 #ifdef DFLY_PCB_SUPPLY
-	/* Support debugging kernel virtual memory images.  */
-	bsd_kvm_add_target(amd64dfly_supply_pcb);
+  /* Support debugging kernel virtual memory images.  */
+  bsd_kvm_add_target (amd64dfly_supply_pcb);
 #endif
 
-	/* To support the recognition of signal handlers, i386bsd-tdep.c
-	 * hardcodes some constants.  Inclusion of this file means that we are
-	 * compiling a native debugger, which means that we can use the system
-	 * header files and sysctl(3) to get at the relevant information.  */
+  /* To support the recognition of signal handlers, i386bsd-tdep.c
+     hardcodes some constants.  Inclusion of this file means that we
+     are compiling a native debugger, which means that we can use the
+     system header files and sysctl(3) to get at the relevant
+     information.  */
 
 #define SC_REG_OFFSET amd64dfly_sc_reg_offset
 
-	/* We only check the program counter, stack pointer and frame pointer
-	 * since these members of `struct sigcontext' are essential for
-	 * providing backtraces.  */
+  /* We only check the program counter, stack pointer and frame
+     pointer since these members of `struct sigcontext' are essential
+     for providing backtraces.  */
 
 #define SC_RIP_OFFSET SC_REG_OFFSET[AMD64_RIP_REGNUM]
 #define SC_RSP_OFFSET SC_REG_OFFSET[AMD64_RSP_REGNUM]
 #define SC_RBP_OFFSET SC_REG_OFFSET[AMD64_RBP_REGNUM]
 
-	/* Override the default value for the offset of the program counter in
-	 * the sigcontext structure.  */
-	offset = offsetof(struct sigcontext, sc_rip);
+  /* Override the default value for the offset of the program counter
+     in the sigcontext structure.  */
+  offset = offsetof (struct sigcontext, sc_rip);
 
-	if (SC_RIP_OFFSET != offset) {
-		warning(_("\
+  if (SC_RIP_OFFSET != offset)
+    {
+      warning (_("\
 offsetof (struct sigcontext, sc_rip) yields %d instead of %d.\n\
 Please report this to <bug-gdb@gnu.org>."),
-		    offset, SC_RIP_OFFSET);
-	}
-	SC_RIP_OFFSET = offset;
+	       offset, SC_RIP_OFFSET);
+    }
+
+  SC_RIP_OFFSET = offset;
 
-	/* Likewise for the stack pointer.  */
-	offset = offsetof(struct sigcontext, sc_rsp);
+  /* Likewise for the stack pointer.  */
+  offset = offsetof (struct sigcontext, sc_rsp);
 
-	if (SC_RSP_OFFSET != offset) {
-		warning(_("\
+  if (SC_RSP_OFFSET != offset)
+    {
+      warning (_("\
 offsetof (struct sigcontext, sc_rsp) yields %d instead of %d.\n\
 Please report this to <bug-gdb@gnu.org>."),
-		    offset, SC_RSP_OFFSET);
-	}
-	SC_RSP_OFFSET = offset;
+	       offset, SC_RSP_OFFSET);
+    }
+
+  SC_RSP_OFFSET = offset;
 
-	/* And the frame pointer.  */
-	offset = offsetof(struct sigcontext, sc_rbp);
+  /* And the frame pointer.  */
+  offset = offsetof (struct sigcontext, sc_rbp);
 
-	if (SC_RBP_OFFSET != offset) {
-		warning(_("\
+  if (SC_RBP_OFFSET != offset)
+    {
+      warning (_("\
 offsetof (struct sigcontext, sc_rbp) yields %d instead of %d.\n\
 Please report this to <bug-gdb@gnu.org>."),
-		    offset, SC_RBP_OFFSET);
-	}
-	SC_RBP_OFFSET = offset;
-
-	/* DragonFly provides a kern.ps_strings sysctl that we can use to
-	 * locate the sigtramp.  That way we can still recognize a sigtramp if
-	 * its location is changed in a new kernel.  Of course this is still
-	 * based on the assumption that the sigtramp is placed directly under
-	 * the location where the program arguments and environment can be
-	 * found.  */
-	{
-		int mib[2];
-		long ps_strings;
-		size_t len;
-
-		mib[0] = CTL_KERN;
-		mib[1] = KERN_PS_STRINGS;
-		len = sizeof(ps_strings);
-		if (sysctl(mib, 2, &ps_strings, &len, NULL, 0) == 0) {
-			amd64dfly_sigtramp_start_addr = ps_strings - 32;
-			amd64dfly_sigtramp_end_addr = ps_strings;
-		}
-	}
+	       offset, SC_RBP_OFFSET);
+    }
+
+  SC_RBP_OFFSET = offset;
+
+  /* DragonFly provides a kern.ps_strings sysctl that we can use to
+     locate the sigtramp.  That way we can still recognize a sigtramp
+     if its location is changed in a new kernel.  Of course this is
+     still based on the assumption that the sigtramp is placed
+     directly under the location where the program arguments and
+     environment can be found.  */
+  {
+    int mib[2];
+    long ps_strings;
+    size_t len;
+
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_PS_STRINGS;
+    len = sizeof (ps_strings);
+    if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0)
+      {
+	amd64dfly_sigtramp_start_addr = ps_strings - 32;
+	amd64dfly_sigtramp_end_addr = ps_strings;
+      }
+  }
 }
diff --git a/contrib/gdb-7/gdb/amd64dfly-tdep.c b/contrib/gdb-7/gdb/amd64dfly-tdep.c
index af39a7f..1f59876 100644
--- a/contrib/gdb-7/gdb/amd64dfly-tdep.c
+++ b/contrib/gdb-7/gdb/amd64dfly-tdep.c
@@ -36,22 +36,21 @@
    address of the associated sigcontext structure.  */
 
 static CORE_ADDR
-amd64dfly_sigcontext_addr(struct frame_info *this_frame)
+amd64dfly_sigcontext_addr (struct frame_info *this_frame)
 {
-	struct gdbarch *gdbarch = get_frame_arch(this_frame);
-	enum bfd_endian byte_order = gdbarch_byte_order(gdbarch);
-	CORE_ADDR sp;
-	gdb_byte buf[8];
-
-	/* The `struct sigcontext' (which really is an `ucontext_t' on
-	 * DragonFly/amd64) lives at a fixed offset in the signal frame.  See
-	 * <machine/sigframe.h>.  */
-	get_frame_register(this_frame, AMD64_RSP_REGNUM, buf);
-	sp = extract_unsigned_integer(buf, 8, byte_order);
-	return sp + 16;
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  CORE_ADDR sp;
+  gdb_byte buf[8];
+
+  /* The `struct sigcontext' (which really is an `ucontext_t' on
+     DragonFly/amd64) lives at a fixed offset in the signal frame.  See
+     <machine/sigframe.h>.  */
+  get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
+  sp = extract_unsigned_integer (buf, 8, byte_order);
+  return sp + 16;
 }
-
-
+
 /* Mapping between the general-purpose registers in `struct reg'
    format and GDB's register cache layout.
 
@@ -61,30 +60,30 @@ amd64dfly_sigcontext_addr(struct frame_info *this_frame)
 /* From <machine/reg.h>.  */
 static int amd64dfly_r_reg_offset[] =
 {
-	6 * 8,			/* %rax */
-	7 * 8,			/* %rbx */
-	3 * 8,			/* %rcx */
-	2 * 8,			/* %rdx */
-	1 * 8,			/* %rsi */
-	0 * 8,			/* %rdi */
-	8 * 8,			/* %rbp */
-	23 * 8,			/* %rsp */
-	4 * 8,			/* %r8 ... */
-	5 * 8,
-	9 * 8,
-	10 * 8,
-	11 * 8,
-	12 * 8,
-	13 * 8,
-	14 * 8,			/* ... %r15 */
-	20 * 8,			/* %rip */
-	22 * 8,			/* %eflags */
-	21 * 8,			/* %cs */
-	24 * 8,			/* %ss */
-	-1,			/* %ds */
-	-1,			/* %es */
-	-1,			/* %fs */
-	-1			/* %gs */
+  6 * 8,			/* %rax */
+  7 * 8,			/* %rbx */
+  3 * 8,			/* %rcx */
+  2 * 8,			/* %rdx */
+  1 * 8,			/* %rsi */
+  0 * 8,			/* %rdi */
+  8 * 8,			/* %rbp */
+  23 * 8,			/* %rsp */
+  4 * 8,			/* %r8 ... */
+  5 * 8,
+  9 * 8,
+  10 * 8,
+  11 * 8,
+  12 * 8,
+  13 * 8,
+  14 * 8,			/* ... %r15 */
+  20 * 8,			/* %rip */
+  22 * 8,			/* %eflags */
+  21 * 8,			/* %cs */
+  24 * 8,			/* %ss */
+  -1,				/* %ds */
+  -1,				/* %es */
+  -1,				/* %fs */
+  -1				/* %gs */
 };
 
 /* Location of the signal trampoline.  */
@@ -94,85 +93,84 @@ CORE_ADDR amd64dfly_sigtramp_end_addr = 0x7fffffffffe0ULL;
 /* From <machine/signal.h>.  */
 int amd64dfly_sc_reg_offset[] =
 {
-	24 + 6 * 8,		/* %rax */
-	24 + 7 * 8,		/* %rbx */
-	24 + 3 * 8,		/* %rcx */
-	24 + 2 * 8,		/* %rdx */
-	24 + 1 * 8,		/* %rsi */
-	24 + 0 * 8,		/* %rdi */
-	24 + 8 * 8,		/* %rbp */
-	24 + 23 * 8,		/* %rsp */
-	24 + 4 * 8,		/* %r8 ... */
-	24 + 5 * 8,
-	24 + 9 * 8,
-	24 + 10 * 8,
-	24 + 11 * 8,
-	24 + 12 * 8,
-	24 + 13 * 8,
-	24 + 14 * 8,		/* ... %r15 */
-	24 + 20 * 8,		/* %rip */
-	24 + 22 * 8,		/* %eflags */
-	24 + 21 * 8,		/* %cs */
-	24 + 24 * 8,		/* %ss */
-	-1,			/* %ds */
-	-1,			/* %es */
-	-1,			/* %fs */
-	-1			/* %gs */
+  24 + 6 * 8,			/* %rax */
+  24 + 7 * 8,			/* %rbx */
+  24 + 3 * 8,			/* %rcx */
+  24 + 2 * 8,			/* %rdx */
+  24 + 1 * 8,			/* %rsi */
+  24 + 0 * 8,			/* %rdi */
+  24 + 8 * 8,			/* %rbp */
+  24 + 23 * 8,			/* %rsp */
+  24 + 4 * 8,			/* %r8 ... */
+  24 + 5 * 8,
+  24 + 9 * 8,
+  24 + 10 * 8,
+  24 + 11 * 8,
+  24 + 12 * 8,
+  24 + 13 * 8,
+  24 + 14 * 8,			/* ... %r15 */
+  24 + 20 * 8,			/* %rip */
+  24 + 22 * 8,			/* %eflags */
+  24 + 21 * 8,			/* %cs */
+  24 + 24 * 8,			/* %ss */
+  -1,				/* %ds */
+  -1,				/* %es */
+  -1,				/* %fs */
+  -1				/* %gs */
 };
 
 /* From /usr/src/lib/libc/amd64/gen/_setjmp.S.  */
 static int amd64dfly_jmp_buf_reg_offset[] =
 {
-	-1,			/* %rax */
-	1 * 8,			/* %rbx */
-	-1,			/* %rcx */
-	-1,			/* %rdx */
-	-1,			/* %rsi */
-	-1,			/* %rdi */
-	3 * 8,			/* %rbp */
-	2 * 8,			/* %rsp */
-	-1,			/* %r8 ... */
-	-1,
-	-1,
-	-1,			/* ... %r11 */
-	4 * 8,			/* %r12 ... */
-	5 * 8,
-	6 * 8,
-	7 * 8,			/* ... %r15 */
-	0 * 8			/* %rip */
+  -1,				/* %rax */
+  1 * 8,			/* %rbx */
+  -1,				/* %rcx */
+  -1,				/* %rdx */
+  -1,				/* %rsi */
+  -1,				/* %rdi */
+  3 * 8,			/* %rbp */
+  2 * 8,			/* %rsp */
+  -1,				/* %r8 ... */
+  -1,
+  -1,
+  -1,				/* ... %r11 */
+  4 * 8,			/* %r12 ... */
+  5 * 8,
+  6 * 8,
+  7 * 8,			/* ... %r15 */
+  0 * 8				/* %rip */
 };
 
 static void
-amd64dfly_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
+amd64dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-	struct gdbarch_tdep *tdep = gdbarch_tdep(gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-	i386bsd_init_abi(info, gdbarch);
+  i386bsd_init_abi (info, gdbarch);
 
-	tdep->gregset_reg_offset = amd64dfly_r_reg_offset;
-	tdep->gregset_num_regs = ARRAY_SIZE(amd64dfly_r_reg_offset);
-	tdep->sizeof_gregset = 25 * 8;
+  tdep->gregset_reg_offset = amd64dfly_r_reg_offset;
+  tdep->gregset_num_regs = ARRAY_SIZE (amd64dfly_r_reg_offset);
+  tdep->sizeof_gregset = 25 * 8;
 
-	amd64_init_abi(info, gdbarch);
+  amd64_init_abi (info, gdbarch);
 
-	tdep->sigtramp_start = amd64dfly_sigtramp_start_addr;
-	tdep->sigtramp_end = amd64dfly_sigtramp_end_addr;
-	tdep->sigcontext_addr = amd64dfly_sigcontext_addr;
-	tdep->sc_reg_offset = amd64dfly_sc_reg_offset;
-	tdep->sc_num_regs = ARRAY_SIZE(amd64dfly_sc_reg_offset);
+  tdep->sigtramp_start = amd64dfly_sigtramp_start_addr;
+  tdep->sigtramp_end = amd64dfly_sigtramp_end_addr;
+  tdep->sigcontext_addr = amd64dfly_sigcontext_addr;
+  tdep->sc_reg_offset = amd64dfly_sc_reg_offset;
+  tdep->sc_num_regs = ARRAY_SIZE (amd64dfly_sc_reg_offset);
 
-	set_solib_svr4_fetch_link_map_offsets
-	    (gdbarch, svr4_lp64_fetch_link_map_offsets);
+  set_solib_svr4_fetch_link_map_offsets
+    (gdbarch, svr4_lp64_fetch_link_map_offsets);
 }
-
-
+
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
-void _initialize_amd64dfly_tdep(void);
+void _initialize_amd64dfly_tdep (void);
 
 void
-_initialize_amd64dfly_tdep(void)
+_initialize_amd64dfly_tdep (void)
 {
-	gdbarch_register_osabi(bfd_arch_i386, bfd_mach_x86_64,
-	    GDB_OSABI_DRAGONFLY, amd64dfly_init_abi);
+  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
+			  GDB_OSABI_DRAGONFLY, amd64dfly_init_abi);
 }
diff --git a/contrib/gdb-7/gdb/i386dfly-nat.c b/contrib/gdb-7/gdb/i386dfly-nat.c
index 43d1b67..cd12d1d 100644
--- a/contrib/gdb-7/gdb/i386dfly-nat.c
+++ b/contrib/gdb-7/gdb/i386dfly-nat.c
@@ -38,49 +38,50 @@
    single-step it.  If SIGNAL is nonzero, give it that signal.  */
 
 static void
-i386dfly_resume(struct target_ops *ops,
-    ptid_t ptid, int step, enum gdb_signal signal)
+i386dfly_resume (struct target_ops *ops,
+		 ptid_t ptid, int step, enum gdb_signal signal)
 {
-	pid_t pid = ptid_get_pid(ptid);
-	int request = PT_STEP;
-
-	if (pid == -1)
-		/* Resume all threads.  This only gets used in the
-		 * non-threaded case, where "resume all threads" and "resume
-		 * inferior_ptid" are the same.  */
-		pid = ptid_get_pid(inferior_ptid);
-
-	if (!step) {
-		struct regcache *regcache = get_current_regcache();
-		ULONGEST eflags;
-
-		/* Workaround for a bug in FreeBSD.  Make sure that the trace
-		 * flag is off when doing a continue.  There is a code path
-		 * through the kernel which leaves the flag set when it should
-		 * have been cleared.  If a process has a signal pending (such
-		 * as SIGALRM) and we do a PT_STEP, the process never really
-		 * has a chance to run because the kernel needs to notify the
-		 * debugger that a signal is being sent.  Therefore, the
-		 * process never goes through the kernel's trap() function
-		 * which would normally clear it.  */
-
-		regcache_cooked_read_unsigned(regcache, I386_EFLAGS_REGNUM,
-		    &eflags);
-		if (eflags & 0x0100)
-			regcache_cooked_write_unsigned(regcache, I386_EFLAGS_REGNUM,
-			    eflags & ~0x0100);
-
-		request = PT_CONTINUE;
-	}
-	/* An addres of (caddr_t) 1 tells ptrace to continue from where it
-	 * was.  (If GDB wanted it to start some other way, we have already
-	 * written a new PC value to the child.)  */
-	if (ptrace(request, pid, (caddr_t) 1,
-	    gdb_signal_to_host(signal)) == -1)
-		perror_with_name(("ptrace"));
+  pid_t pid = ptid_get_pid (ptid);
+  int request = PT_STEP;
+
+  if (pid == -1)
+    /* Resume all threads.  This only gets used in the non-threaded
+       case, where "resume all threads" and "resume inferior_ptid" are
+       the same.  */
+    pid = ptid_get_pid (inferior_ptid);
+
+  if (!step)
+    {
+      struct regcache *regcache = get_current_regcache ();
+      ULONGEST eflags;
+
+      /* Workaround for a bug in FreeBSD.  Make sure that the trace
+ 	 flag is off when doing a continue.  There is a code path
+ 	 through the kernel which leaves the flag set when it should
+ 	 have been cleared.  If a process has a signal pending (such
+ 	 as SIGALRM) and we do a PT_STEP, the process never really has
+ 	 a chance to run because the kernel needs to notify the
+ 	 debugger that a signal is being sent.  Therefore, the process
+ 	 never goes through the kernel's trap() function which would
+ 	 normally clear it.  */
+
+      regcache_cooked_read_unsigned (regcache, I386_EFLAGS_REGNUM,
+				     &eflags);
+      if (eflags & 0x0100)
+	regcache_cooked_write_unsigned (regcache, I386_EFLAGS_REGNUM,
+					eflags & ~0x0100);
+
+      request = PT_CONTINUE;
+    }
+
+  /* An addres of (caddr_t) 1 tells ptrace to continue from where it
+     was.  (If GDB wanted it to start some other way, we have already
+     written a new PC value to the child.)  */
+  if (ptrace (request, pid, (caddr_t) 1,
+	      gdb_signal_to_host (signal)) == -1)
+    perror_with_name (("ptrace"));
 }
-
-
+
 
 /* Transfering the registers between GDB, inferiors and core files.  */
 
@@ -88,9 +89,9 @@ i386dfly_resume(struct target_ops *ops,
    in *GREGSETP.  */
 
 void
-supply_gregset(struct regcache *regcache, const gregset_t * gregsetp)
+supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
 {
-	i386bsd_supply_gregset(regcache, gregsetp);
+  i386bsd_supply_gregset (regcache, gregsetp);
 }
 
 /* Fill register REGNUM (if it is a general-purpose register) in
@@ -98,9 +99,9 @@ supply_gregset(struct regcache *regcache, const gregset_t * gregsetp)
    do this for all registers.  */
 
 void
-fill_gregset(const struct regcache *regcache, gdb_gregset_t * gregsetp, int regnum)
+fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum)
 {
-	i386bsd_collect_gregset(regcache, gregsetp, regnum);
+  i386bsd_collect_gregset (regcache, gregsetp, regnum);
 }
 
 #include "i387-tdep.h"
@@ -109,9 +110,9 @@ fill_gregset(const struct regcache *regcache, gdb_gregset_t * gregsetp, int regn
    in *FPREGSETP.  */
 
 void
-supply_fpregset(struct regcache *regcache, const fpregset_t * fpregsetp)
+supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
 {
-	i387_supply_fsave(regcache, -1, fpregsetp);
+  i387_supply_fsave (regcache, -1, fpregsetp);
 }
 
 /* Fill register REGNUM (if it is a floating-point register) in
@@ -119,12 +120,11 @@ supply_fpregset(struct regcache *regcache, const fpregset_t * fpregsetp)
    do this for all registers.  */
 
 void
-fill_fpregset(const struct regcache *regcache, gdb_fpregset_t * fpregsetp, int regnum)
+fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum)
 {
-	i387_collect_fsave(regcache, regnum, fpregsetp);
+  i387_collect_fsave (regcache, regnum, fpregsetp);
 }
-
-
+
 
 /* Support for debugging kernel virtual memory images.  */
 
@@ -134,90 +134,90 @@ fill_fpregset(const struct regcache *regcache, gdb_fpregset_t * fpregsetp, int r
 #include "bsd-kvm.h"
 
 static int
-i386dfly_supply_pcb(struct regcache *regcache, struct pcb *pcb)
+i386dfly_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 {
-	/* The following is true for FreeBSD 4.7:
-	 * 
-	 * The pcb contains %eip, %ebx, %esp, %ebp, %esi, %edi and %gs. This
-	 * accounts for all callee-saved registers specified by the psABI and
-	 * then some.  Here %esp contains the stack pointer at the point just
-	 * after the call to cpu_switch().  From this information we
-	 * reconstruct the register state as it would look when we just
-	 * returned from cpu_switch().  */
-
-	/* The stack pointer shouldn't be zero.  */
-	if (pcb->pcb_esp == 0)
-		return 0;
-
-	pcb->pcb_esp += 4;
-	regcache_raw_supply(regcache, I386_EDI_REGNUM, &pcb->pcb_edi);
-	regcache_raw_supply(regcache, I386_ESI_REGNUM, &pcb->pcb_esi);
-	regcache_raw_supply(regcache, I386_EBP_REGNUM, &pcb->pcb_ebp);
-	regcache_raw_supply(regcache, I386_ESP_REGNUM, &pcb->pcb_esp);
-	regcache_raw_supply(regcache, I386_EBX_REGNUM, &pcb->pcb_ebx);
-	regcache_raw_supply(regcache, I386_EIP_REGNUM, &pcb->pcb_eip);
-	regcache_raw_supply(regcache, I386_GS_REGNUM, &pcb->pcb_gs);
-
-	return 1;
+  /* The following is true for FreeBSD 4.7:
+
+     The pcb contains %eip, %ebx, %esp, %ebp, %esi, %edi and %gs.
+     This accounts for all callee-saved registers specified by the
+     psABI and then some.  Here %esp contains the stack pointer at the
+     point just after the call to cpu_switch().  From this information
+     we reconstruct the register state as it would look when we just
+     returned from cpu_switch().  */
+
+  /* The stack pointer shouldn't be zero.  */
+  if (pcb->pcb_esp == 0)
+    return 0;
+
+  pcb->pcb_esp += 4;
+  regcache_raw_supply (regcache, I386_EDI_REGNUM, &pcb->pcb_edi);
+  regcache_raw_supply (regcache, I386_ESI_REGNUM, &pcb->pcb_esi);
+  regcache_raw_supply (regcache, I386_EBP_REGNUM, &pcb->pcb_ebp);
+  regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_esp);
+  regcache_raw_supply (regcache, I386_EBX_REGNUM, &pcb->pcb_ebx);
+  regcache_raw_supply (regcache, I386_EIP_REGNUM, &pcb->pcb_eip);
+  regcache_raw_supply (regcache, I386_GS_REGNUM, &pcb->pcb_gs);
+
+  return 1;
 }
-#endif				/* DFLY_PCB_SUPPLY */
-
-
+#endif /* DFLY_PCB_SUPPLY */
+
 
 /* Prevent warning from -Wmissing-prototypes.  */
-void _initialize_i386dfly_nat(void);
+void _initialize_i386dfly_nat (void);
 
 void
-_initialize_i386dfly_nat(void)
+_initialize_i386dfly_nat (void)
 {
-	struct target_ops *t;
+  struct target_ops *t;
 
-	/* Add some extra features to the common *BSD/i386 target.  */
-	t = i386bsd_target();
+  /* Add some extra features to the common *BSD/i386 target.  */
+  t = i386bsd_target ();
 
 #ifdef HAVE_PT_GETDBREGS
 
-	i386_use_watchpoints(t);
+  i386_use_watchpoints (t);
 
-	i386_dr_low.set_control = i386bsd_dr_set_control;
-	i386_dr_low.set_addr = i386bsd_dr_set_addr;
-	i386_dr_low.get_addr = i386bsd_dr_get_addr;
-	i386_dr_low.get_status = i386bsd_dr_get_status;
-	i386_dr_low.get_control = i386bsd_dr_get_control;
-	i386_set_debug_register_length(4);
+  i386_dr_low.set_control = i386bsd_dr_set_control;
+  i386_dr_low.set_addr = i386bsd_dr_set_addr;
+  i386_dr_low.get_addr = i386bsd_dr_get_addr;
+  i386_dr_low.get_status = i386bsd_dr_get_status;
+  i386_dr_low.get_control = i386bsd_dr_get_control;
+  i386_set_debug_register_length (4);
 
-#endif				/* HAVE_PT_GETDBREGS */
+#endif /* HAVE_PT_GETDBREGS */
 
 
-	t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
-	t->to_find_memory_regions = fbsd_find_memory_regions;
-	t->to_make_corefile_notes = fbsd_make_corefile_notes;
-	add_target(t);
+  t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
+  t->to_find_memory_regions = fbsd_find_memory_regions;
+  t->to_make_corefile_notes = fbsd_make_corefile_notes;
+  add_target (t);
 
 #ifdef DFLY_PCB_SUPPLY
-	/* Support debugging kernel virtual memory images.  */
-	bsd_kvm_add_target(i386dfly_supply_pcb);
+  /* Support debugging kernel virtual memory images.  */
+  bsd_kvm_add_target (i386dfly_supply_pcb);
 #endif
 
-	/* DragonFly provides a kern.ps_strings sysctl that we can use to
-	 * locate the sigtramp.  That way we can still recognize a sigtramp if
-	 * its location is changed in a new kernel.  Of course this is still
-	 * based on the assumption that the sigtramp is placed directly under
-	 * the location where the program arguments and environment can be
-	 * found.  */
+  /* DragonFly provides a kern.ps_strings sysctl that we can use to
+     locate the sigtramp.  That way we can still recognize a sigtramp
+     if its location is changed in a new kernel.  Of course this is
+     still based on the assumption that the sigtramp is placed
+     directly under the location where the program arguments and
+     environment can be found.  */
 #ifdef KERN_PS_STRINGS
-	{
-		int mib[2];
-		u_long ps_strings;
-		size_t len;
-
-		mib[0] = CTL_KERN;
-		mib[1] = KERN_PS_STRINGS;
-		len = sizeof(ps_strings);
-		if (sysctl(mib, 2, &ps_strings, &len, NULL, 0) == 0) {
-			i386dfly_sigtramp_start_addr = ps_strings - 128;
-			i386dfly_sigtramp_end_addr = ps_strings;
-		}
-	}
+  {
+    int mib[2];
+    u_long ps_strings;
+    size_t len;
+
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_PS_STRINGS;
+    len = sizeof (ps_strings);
+    if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0)
+      {
+	i386dfly_sigtramp_start_addr = ps_strings - 128;
+	i386dfly_sigtramp_end_addr = ps_strings;
+      }
+  }
 #endif
 }
diff --git a/contrib/gdb-7/gdb/i386dfly-tdep.c b/contrib/gdb-7/gdb/i386dfly-tdep.c
index 0f0c22f..0830c60 100644
--- a/contrib/gdb-7/gdb/i386dfly-tdep.c
+++ b/contrib/gdb-7/gdb/i386dfly-tdep.c
@@ -31,22 +31,22 @@
 
 static int i386dfly_r_reg_offset[] =
 {
-	44,			/* %eax */
-	40,			/* %ecx */
-	36,			/* %edx */
-	32,			/* %ebx */
-	72,			/* %esp */
-	24,			/* %ebp */
-	20,			/* %esi */
-	16,			/* %edi */
-	60,			/* %eip */
-	68,			/* %eflags */
-	64,			/* %cs */
-	76,			/* %ss */
-	12,			/* %ds */
-	8,			/* %es */
-	4,			/* %fs */
-	0			/* %gs */
+  44, /* %eax */
+  40, /* %ecx */
+  36, /* %edx */
+  32, /* %ebx */
+  72, /* %esp */
+  24, /* %ebp */
+  20, /* %esi */
+  16, /* %edi */
+  60, /* %eip */
+  68, /* %eflags */
+  64, /* %cs */
+  76, /* %ss */
+  12, /* %ds */
+  8, /* %es */
+  4, /* %fs */
+  0  /* %gs */
 };
 
 /* Sigtramp routine location.  */
@@ -55,50 +55,49 @@ CORE_ADDR i386dfly_sigtramp_end_addr = 0xbfbfdff0;
 
 int i386dfly_sc_reg_offset[] =
 {
-	64,			/* %eax */
-	60,			/* %ecx */
-	56,			/* %edx */
-	52,			/* %ebx */
-	92,			/* %esp */
-	44,			/* %ebp */
-	40,			/* %esi */
-	36,			/* %edi */
-	80,			/* %eip */
-	88,			/* %eflags */
-	84,			/* %cs */
-	96,			/* %ss */
-	32,			/* %ds */
-	28,			/* %es */
-	24,			/* %fs */
-	20			/* %gs */
+  64, /* %eax */
+  60, /* %ecx */
+  56, /* %edx */
+  52, /* %ebx */
+  92, /* %esp */
+  44, /* %ebp */
+  40, /* %esi */
+  36, /* %edi */
+  80, /* %eip */
+  88, /* %eflags */
+  84, /* %cs */
+  96, /* %ss */
+  32, /* %ds */
+  28, /* %es */
+  24, /* %fs */
+  20  /* %gs */
 };
 
 static void
-i386dfly_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
+i386dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-	struct gdbarch_tdep *tdep = gdbarch_tdep(gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-	i386_elf_init_abi(info, gdbarch);
+  i386_elf_init_abi(info, gdbarch);
 
-	tdep->gregset_reg_offset = i386dfly_r_reg_offset;
-	tdep->gregset_num_regs = ARRAY_SIZE(i386dfly_r_reg_offset);
-	tdep->sizeof_gregset = 80;
+  tdep->gregset_reg_offset = i386dfly_r_reg_offset;
+  tdep->gregset_num_regs = ARRAY_SIZE (i386dfly_r_reg_offset);
+  tdep->sizeof_gregset = 80;
 
-	tdep->sc_reg_offset = i386dfly_sc_reg_offset;
-	tdep->sc_num_regs = ARRAY_SIZE(i386dfly_sc_reg_offset);
+  tdep->sc_reg_offset = i386dfly_sc_reg_offset;
+  tdep->sc_num_regs = ARRAY_SIZE (i386dfly_sc_reg_offset);
 
-	set_solib_svr4_fetch_link_map_offsets
-	    (gdbarch, svr4_ilp32_fetch_link_map_offsets);
+  set_solib_svr4_fetch_link_map_offsets
+    (gdbarch, svr4_ilp32_fetch_link_map_offsets);
 }
 
-
-
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
-void _initialize_i386dfly_tdep(void);
+void _initialize_i386dfly_tdep (void);
 
 void
-_initialize_i386dfly_tdep(void)
+_initialize_i386dfly_tdep (void)
 {
-	gdbarch_register_osabi(bfd_arch_i386, 0, GDB_OSABI_DRAGONFLY,
-	    i386dfly_init_abi);
+  gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_DRAGONFLY,
+			  i386dfly_init_abi);
 }
-- 
2.5.3

