* Patch to support AMD64 Solaris 10
@ 2004-10-25 17:48 Joseph S. Myers
2004-10-25 19:39 ` Andrew Cagney
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Joseph S. Myers @ 2004-10-25 17:48 UTC (permalink / raw)
To: gdb-patches
This patch adds initial support for Solaris 10 on AMD64. The test results
(debugging both 64-bit and 32-bit binaries) are fairly similar to those
for unmodified GDB (built as 32-bit and debugging 32-bit binaries), though
as the prerelease operating system isn't yet fully reliable running the
GDB testsuite it's difficult to get full testsuite results for comparison.
The configuration is based on the existing IA32 Solaris support.
A limitation of this patch is that GDB needs to be built as a 64-bit
binary (configured with CC="gcc -m64": 32-bit compilation is the default
for this system) to work on AMD64 Solaris; GDB built as a 32-bit binary
doesn't work with this patch on AMD64 Solaris 10. The problem is that
there is a single target triplet and so a single GDB configuration, but
64-bit GDB should be using the functions in amd64-sol2-nat.c added by this
patch while 32-bit GDB (which in any case could only debug 32-bit
binaries, but the operating system does support plain x86 systems as well
as AMD64 ones, so such a GDB is desirable) should be using the functions
in i386v4-nat.c. Any comments on the best approach for having the single
configuration cleanly support being built as both 32-bit and 64-bit?
--
Joseph S. Myers
joseph@codesourcery.com
2004-10-25 Joseph S. Myers <joseph@codesourcery.com>
* Makefile.in (ALLDEPFILES): Add amd64-sol2-nat.c and
amd64-sol2-tdep.c.
* amd64-sol2-nat.c, amd64-sol2-tdep.c, config/i386/sol64.mh,
config/i386/sol64.mt: New files.
* configure.host (i[34567]86-*-solaris2.1[0-9]*): Add new case.
* configure.tgt (i[34567]86-*-solaris2.1[0-9]*): Likewise.
* configure.in (*-*-solaris2.[[6789]]): Add *-*-solaris2.1[[0-9]]
for definition of NEW_PROC_API.
* configure: Regenerate.
diff -rupN gdb/Makefile.in gdb-new/Makefile.in
--- gdb/Makefile.in 2004-10-16 09:40:55.000000000 +0000
+++ gdb-new/Makefile.in 2004-10-22 14:56:02.000000000 +0000
@@ -1358,6 +1358,7 @@ ALLDEPFILES = \
amd64nbsd-nat.c amd64nbsd-tdep.c \
amd64obsd-nat.c amd64obsd-tdep.c \
amd64-linux-nat.c amd64-linux-tdep.c \
+ amd64-sol2-nat.c amd64-sol2-tdep.c \
arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \
armnbsd-nat.c armnbsd-tdep.c \
avr-tdep.c \
@@ -1690,6 +1691,12 @@ amd64obsd-tdep.o: amd64obsd-tdep.c $(def
$(symtab_h) $(objfiles_h) $(osabi_h) $(regset_h) $(target_h) \
$(gdb_assert_h) $(gdb_string_h) $(amd64_tdep_h) $(i387_tdep_h) \
$(solib_svr4_h)
+amd64-sol2-nat.o: amd64-sol2-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
+ $(regcache_h) $(osabi_h) $(symtab_h) $(gdb_string_h) $(amd64_tdep_h) \
+ $(gregset_h) $(amd64_nat_h)
+amd64-sol2-tdep.o: amd64-sol2-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \
+ $(regcache_h) $(osabi_h) $(symtab_h) $(gdb_string_h) $(amd64_tdep_h) \
+ $(solib_svr4_h)
amd64-tdep.o: amd64-tdep.c $(defs_h) $(arch_utils_h) $(block_h) \
$(dummy_frame_h) $(frame_h) $(frame_base_h) $(frame_unwind_h) \
$(inferior_h) $(gdbcmd_h) $(gdbcore_h) $(objfiles_h) $(regcache_h) \
diff -rupN gdb/amd64-sol2-nat.c gdb-new/amd64-sol2-nat.c
--- gdb/amd64-sol2-nat.c 1970-01-01 00:00:00.000000000 +0000
+++ gdb-new/amd64-sol2-nat.c 2004-10-22 14:56:13.000000000 +0000
@@ -0,0 +1,147 @@
+/* Native-dependent code for Solaris x86-64.
+
+ Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Contributed by Joseph Myers, CodeSourcery, LLC.
+ Based on amd64-linux-nat.c.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+#include "inferior.h"
+#include "gdbcore.h"
+#include "regcache.h"
+#include "osabi.h"
+#include "symtab.h"
+
+#include "gdb_string.h"
+
+#include <sys/regset.h>
+#include "gregset.h"
+#include "amd64-tdep.h"
+#include "amd64-nat.h"
+
+/* Mapping between the general-purpose registers in gregset_t format
+ and GDB's register cache layout. */
+
+/* From <sys/regset.h>. */
+static int amd64_sol2_gregset64_reg_offset[] =
+{
+ 14 * 8, /* %rax */
+ 11 * 8, /* %rbx */
+ 13 * 8, /* %rcx */
+ 12 * 8, /* %rdx */
+ 9 * 8, /* %rsi */
+ 8 * 8, /* %rdi */
+ 10 * 8, /* %rbp */
+ 20 * 8, /* %rsp */
+ 7 * 8, /* %r8 ... */
+ 6 * 8,
+ 5 * 8,
+ 4 * 8,
+ 3 * 8,
+ 2 * 8,
+ 1 * 8,
+ 0 * 8, /* ... %r15 */
+ 17 * 8, /* %rip */
+ 16 * 8, /* %eflags */
+ 18 * 8, /* %cs */
+ 21 * 8, /* %ss */
+ 25 * 8, /* %ds */
+ 24 * 8, /* %es */
+ 22 * 8, /* %fs */
+ 23 * 8 /* %gs */
+};
+
+/* 32-bit registers are provided by Solaris in 64-bit format, so just
+ give a subset of the list above. */
+static int amd64_sol2_gregset32_reg_offset[] =
+{
+ 14 * 8, /* %eax */
+ 13 * 8, /* %ecx */
+ 12 * 8, /* %edx */
+ 11 * 8, /* %ebx */
+ 20 * 8, /* %esp */
+ 10 * 8, /* %ebp */
+ 9 * 8, /* %esi */
+ 8 * 8, /* %edi */
+ 17 * 8, /* %eip */
+ 16 * 8, /* %eflags */
+ 18 * 8, /* %cs */
+ 21 * 8, /* %ss */
+ 25 * 8, /* %ds */
+ 24 * 8, /* %es */
+ 22 * 8, /* %fs */
+ 23 * 8 /* %gs */
+};
+\f
+
+/* Transfering the general-purpose registers between GDB, inferiors
+ and core files. */
+
+/* Fill GDB's register cache with the general-purpose register values
+ in *GREGSETP. */
+
+void
+supply_gregset (gregset_t *gregsetp)
+{
+ amd64_supply_native_gregset (current_regcache, gregsetp, -1);
+}
+
+/* Fill register REGNUM (if it is a general-purpose register) in
+ *GREGSETP with the value in GDB's register cache. If REGNUM is -1,
+ do this for all registers. */
+
+void
+fill_gregset (gregset_t *gregsetp, int regnum)
+{
+ amd64_collect_native_gregset (current_regcache, gregsetp, regnum);
+}
+
+/* Transfering floating-point registers between GDB, inferiors and cores. */
+
+/* Fill GDB's register cache with the floating-point and SSE register
+ values in *FPREGSETP. */
+
+void
+supply_fpregset (fpregset_t *fpregsetp)
+{
+ amd64_supply_fxsave (current_regcache, -1, fpregsetp);
+}
+
+/* Fill register REGNUM (if it is a floating-point or SSE register) in
+ *FPREGSETP with the value in GDB's register cache. If REGNUM is
+ -1, do this for all registers. */
+
+void
+fill_fpregset (fpregset_t *fpregsetp, int regnum)
+{
+ amd64_collect_fxsave (current_regcache, regnum, fpregsetp);
+}
+\f
+
+/* Provide a prototype to silence -Wmissing-prototypes. */
+extern void _initialize_amd64_sol2_nat (void);
+
+void
+_initialize_amd64_sol2_nat (void)
+{
+ amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset;
+ amd64_native_gregset32_num_regs = ARRAY_SIZE (amd64_sol2_gregset32_reg_offset);
+ amd64_native_gregset64_reg_offset = amd64_sol2_gregset64_reg_offset;
+ amd64_native_gregset64_num_regs = ARRAY_SIZE (amd64_sol2_gregset64_reg_offset);
+}
diff -rupN gdb/amd64-sol2-tdep.c gdb-new/amd64-sol2-tdep.c
--- gdb/amd64-sol2-tdep.c 1970-01-01 00:00:00.000000000 +0000
+++ gdb-new/amd64-sol2-tdep.c 2004-10-22 14:54:21.000000000 +0000
@@ -0,0 +1,127 @@
+/* Target-dependent code for Solaris x86-64.
+
+ Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Contributed by Joseph Myers, CodeSourcery, LLC.
+ Based on amd64-linux-tdep.c and i386-sol2-tdep.c.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+#include "frame.h"
+#include "gdbcore.h"
+#include "regcache.h"
+#include "osabi.h"
+#include "symtab.h"
+
+#include "gdb_string.h"
+
+#include "amd64-tdep.h"
+#include "solib-svr4.h"
+
+/* Mapping between the general-purpose registers in gregset_t format
+ and GDB's register cache layout. */
+
+/* From <sys/regset.h>. */
+static int amd64_sol2_gregset_reg_offset[] =
+{
+ 14 * 8, /* %rax */
+ 11 * 8, /* %rbx */
+ 13 * 8, /* %rcx */
+ 12 * 8, /* %rdx */
+ 9 * 8, /* %rsi */
+ 8 * 8, /* %rdi */
+ 10 * 8, /* %rbp */
+ 20 * 8, /* %rsp */
+ 7 * 8, /* %r8 ... */
+ 6 * 8,
+ 5 * 8,
+ 4 * 8,
+ 3 * 8,
+ 2 * 8,
+ 1 * 8,
+ 0 * 8, /* ... %r15 */
+ 17 * 8, /* %rip */
+ 16 * 8, /* %eflags */
+ 18 * 8, /* %cs */
+ 21 * 8, /* %ss */
+ 25 * 8, /* %ds */
+ 24 * 8, /* %es */
+ 22 * 8, /* %fs */
+ 23 * 8 /* %gs */
+};
+\f
+
+/* Return whether the frame preceding NEXT_FRAME corresponds to a
+ Solaris sigtramp routine. */
+
+static int
+amd64_sol2_sigtramp_p (struct frame_info *next_frame)
+{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
+ find_pc_partial_function (pc, &name, NULL, NULL);
+ return (name && (strcmp ("sigacthandler", name) == 0
+ || strcmp (name, "ucbsigvechandler") == 0));
+}
+
+/* Solaris doesn't have a 'struct sigcontext', but it does have a
+ 'mcontext_t' that contains the saved set of machine registers. */
+
+static CORE_ADDR
+amd64_sol2_mcontext_addr (struct frame_info *next_frame)
+{
+ CORE_ADDR sp, ucontext_addr;
+
+ sp = frame_unwind_register_unsigned (next_frame, AMD64_RSP_REGNUM);
+ ucontext_addr = get_frame_memory_unsigned (next_frame, sp + 8, 8);
+
+ return ucontext_addr + 72;
+}
+
+static void
+amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset;
+ tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset);
+ tdep->sizeof_gregset = 28 * 8;
+
+ amd64_init_abi (info, gdbarch);
+
+ tdep->sigtramp_p = amd64_sol2_sigtramp_p;
+ tdep->sigcontext_addr = amd64_sol2_mcontext_addr;
+ tdep->sc_reg_offset = tdep->gregset_reg_offset;
+ tdep->sc_num_regs = tdep->gregset_num_regs;
+
+ /* Solaris uses SVR4-style shared libraries. */
+ set_solib_svr4_fetch_link_map_offsets
+ (gdbarch, svr4_lp64_fetch_link_map_offsets);
+}
+\f
+
+/* Provide a prototype to silence -Wmissing-prototypes. */
+extern void _initialize_amd64_sol2_tdep (void);
+
+void
+_initialize_amd64_sol2_tdep (void)
+{
+ gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
+ GDB_OSABI_SOLARIS, amd64_sol2_init_abi);
+}
diff -rupN gdb/config/i386/sol64.mh gdb-new/config/i386/sol64.mh
--- gdb/config/i386/sol64.mh 1970-01-01 00:00:00.000000000 +0000
+++ gdb-new/config/i386/sol64.mh 2004-10-22 14:54:21.000000000 +0000
@@ -0,0 +1,4 @@
+# Host: Solaris x86_64
+NATDEPFILES= fork-child.o amd64-nat.o amd64-sol2-nat.o \
+ procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o gcore.o
+NAT_FILE= nm-i386sol2.h
diff -rupN gdb/config/i386/sol64.mt gdb-new/config/i386/sol64.mt
--- gdb/config/i386/sol64.mt 1970-01-01 00:00:00.000000000 +0000
+++ gdb-new/config/i386/sol64.mt 2004-10-22 14:54:21.000000000 +0000
@@ -0,0 +1,4 @@
+# Target: Solaris x86_64
+TDEPFILES= i386-tdep.o i387-tdep.o amd64-tdep.o amd64-sol2-tdep.o \
+ i386-sol2-tdep.o corelow.o solib.o solib-svr4.o
+DEPRECATED_TM_FILE= tm-i386sol2.h
diff -rupN gdb/configure.host gdb-new/configure.host
--- gdb/configure.host 2004-09-02 08:31:47.000000000 +0000
+++ gdb-new/configure.host 2004-10-22 14:54:21.000000000 +0000
@@ -77,6 +77,7 @@ i[34567]86-*-openbsd*) gdb_host=obsd ;;
i[34567]86-*-sco3.2v5*) gdb_host=i386sco5 ;;
i[34567]86-*-sco3.2v4*) gdb_host=i386sco4 ;;
i[34567]86-*-sco*) gdb_host=i386sco ;;
+i[34567]86-*-solaris2.1[0-9]*) gdb_host=sol64 ;;
i[34567]86-*-solaris*) gdb_host=i386sol2 ;;
i[34567]86-*-sysv4.2*) gdb_host=i386v42mp ;;
i[34567]86-*-sysv4*) gdb_host=i386v4 ;;
diff -rupN gdb/configure.in gdb-new/configure.in
--- gdb/configure.in 2004-10-11 08:48:32.000000000 +0000
+++ gdb-new/configure.in 2004-10-22 14:54:21.000000000 +0000
@@ -725,7 +725,7 @@ if test "${target}" = "${host}"; then
*-*-unixware* | *-*-sysv4.2* | *-*-sysv5* | *-*-interix* )
AC_DEFINE(NEW_PROC_API)
;;
- *-*-solaris2.[[6789]])
+ *-*-solaris2.[[6789]] | *-*-solaris2.1[[0-9]])
AC_DEFINE(NEW_PROC_API)
;;
mips-sgi-irix5*)
diff -rupN gdb/configure.tgt gdb-new/configure.tgt
--- gdb/configure.tgt 2004-10-04 07:44:59.000000000 +0000
+++ gdb-new/configure.tgt 2004-10-22 14:54:21.000000000 +0000
@@ -89,6 +89,7 @@ i[34567]86-*-netbsd* | i[34567]86-*-knet
i[34567]86-*-openbsd*) gdb_target=obsd ;;
i[34567]86-*-nto*) gdb_target=nto ;;
i[34567]86-*-lynxos*) gdb_target=i386lynx ;;
+i[34567]86-*-solaris2.1[0-9]*) gdb_target=sol64 ;;
i[34567]86-*-solaris*) gdb_target=i386sol2 ;;
i[34567]86-*-linux*) gdb_target=linux
build_gdbserver=yes
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: Patch to support AMD64 Solaris 10 2004-10-25 17:48 Patch to support AMD64 Solaris 10 Joseph S. Myers @ 2004-10-25 19:39 ` Andrew Cagney 2004-10-25 19:55 ` Mark Kettenis 2004-11-01 16:43 ` Andrew Cagney 2 siblings, 0 replies; 11+ messages in thread From: Andrew Cagney @ 2004-10-25 19:39 UTC (permalink / raw) To: Joseph S. Myers; +Cc: gdb-patches Joseph S. Myers wrote: > This patch adds initial support for Solaris 10 on AMD64. The test results > (debugging both 64-bit and 32-bit binaries) are fairly similar to those > for unmodified GDB (built as 32-bit and debugging 32-bit binaries), though > as the prerelease operating system isn't yet fully reliable running the > GDB testsuite it's difficult to get full testsuite results for comparison. > > The configuration is based on the existing IA32 Solaris support. Sigh, this is unfortunatly adding a further use of a deprecated mechanism (DEPRECATED_TM_FILE) and a non strictly multi-arch port. I assume it is largely for solib? What about instead modifying things so that solib.c is always included and have it locally handle the legacy #ifdef SOLIB_ADD et.al. case? > A limitation of this patch is that GDB needs to be built as a 64-bit > binary (configured with CC="gcc -m64": 32-bit compilation is the default > for this system) to work on AMD64 Solaris; GDB built as a 32-bit binary > doesn't work with this patch on AMD64 Solaris 10. The problem is that > there is a single target triplet and so a single GDB configuration, but > 64-bit GDB should be using the functions in amd64-sol2-nat.c added by this > patch while 32-bit GDB (which in any case could only debug 32-bit > binaries, but the operating system does support plain x86 systems as well > as AMD64 ones, so such a GDB is desirable) should be using the functions > in i386v4-nat.c. Any comments on the best approach for having the single > configuration cleanly support being built as both 32-bit and 64-bit? The 64-bit PPC GNU/Linux developers have the same problem. It's really a top-level configure / config.guess issue so best rasied there (gcc@?, config@?). By the time things get to GDB it's too late - trying to switch to 'cc -m64' after the fact would leave us with BFD built 'cc -m32' but with GDB built 'cc -m64'. Outch! Andrew PS: Suggest looking at inf-child and inf-ptrace. The use of nm-*.h and macros to implement native configurations is also falling from favour. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-10-25 17:48 Patch to support AMD64 Solaris 10 Joseph S. Myers 2004-10-25 19:39 ` Andrew Cagney @ 2004-10-25 19:55 ` Mark Kettenis 2004-10-25 22:03 ` Joseph S. Myers 2004-10-26 19:44 ` Joseph S. Myers 2004-11-01 16:43 ` Andrew Cagney 2 siblings, 2 replies; 11+ messages in thread From: Mark Kettenis @ 2004-10-25 19:55 UTC (permalink / raw) To: joseph; +Cc: gdb-patches Date: Mon, 25 Oct 2004 17:48:29 +0000 (UTC) From: "Joseph S. Myers" <joseph@codesourcery.com> Hi Joseph, Thanks for your contribution. The code looks pretty good to me, but here are a few comments. This patch adds initial support for Solaris 10 on AMD64. The test results (debugging both 64-bit and 32-bit binaries) are fairly similar to those for unmodified GDB (built as 32-bit and debugging 32-bit binaries), though as the prerelease operating system isn't yet fully reliable running the GDB testsuite it's difficult to get full testsuite results for comparison. Oh dear. So the guys at Sun still have to do some catching up with the Open Source OS'es ;-). The configuration is based on the existing IA32 Solaris support. Fair enough, although it's not necessarily the best example. A limitation of this patch is that GDB needs to be built as a 64-bit binary (configured with CC="gcc -m64": 32-bit compilation is the default for this system) to work on AMD64 Solaris; GDB built as a 32-bit binary doesn't work with this patch on AMD64 Solaris 10. The problem is that there is a single target triplet and so a single GDB configuration, but 64-bit GDB should be using the functions in amd64-sol2-nat.c added by this patch while 32-bit GDB (which in any case could only debug 32-bit binaries, but the operating system does support plain x86 systems as well as AMD64 ones, so such a GDB is desirable) should be using the functions in i386v4-nat.c. Any comments on the best approach for having the single configuration cleanly support being built as both 32-bit and 64-bit? This sounds pretty much like the situation for Solaris SPARC. I think the way this is solved in sparc-sol2-tdep.c is pretty elegant, but I may be biased ;-). The defined(__arch64__) should be dropped though, since there is no need to support Linux and IA-32/AMD64. For consistency with SPARC I'd suggest nameing the file i386-sol2-nat.c. Comparison with Solaris SPARC makes me believe that using gregset_t/fpregset_t in amd64-sol2-nat.c isn't right and that you should use prgregset_t/prfpregset_t instead. Again, for consistency with Solaris SPARC, could you name the makefile fragments sol2-64.m[th] instead of sol64.m[th]? Oh and I suppose Sun is calling this Solaris AMD64 instead of Solaris x86-64 so I think your comments should do the same. AFAIAC, scrap the "Based on" comments. I don't think they're very useful. You're not listed in the GDB MAINTAINERS file, so we'll have to check out the paperwork first before I can approve any of this. Cheers, Mark ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-10-25 19:55 ` Mark Kettenis @ 2004-10-25 22:03 ` Joseph S. Myers 2004-10-26 19:44 ` Joseph S. Myers 1 sibling, 0 replies; 11+ messages in thread From: Joseph S. Myers @ 2004-10-25 22:03 UTC (permalink / raw) To: Mark Kettenis; +Cc: gdb-patches On Mon, 25 Oct 2004, Mark Kettenis wrote: > The configuration is based on the existing IA32 Solaris support. > > Fair enough, although it's not necessarily the best example. It's essentially a subset of the required configuration (as the 64-bit debugger needs to support debugging 32-bit processes), so seemed the most relevant example to follow even if not the best example for an entirely new port. > This sounds pretty much like the situation for Solaris SPARC. I think > the way this is solved in sparc-sol2-tdep.c is pretty elegant, but I You mean sparc-sol2-nat.c? And splitting i386v4-nat.c (which itself defines the {supply,fill}_{g,fp}regset functions) into one part which defines them as i386v4_* and one with the wrapper functions under those names, or duplicating the definitions? I'm not sure quite what the rationale is here for working by defining magic function names in the first place; the internals manual is silent on the matter of these interfaces. (And as regards DEPRECATED_*, where the internals manual mentions them at all it is silent about the deprecation, its rationale and the proper form of replacement - especially if you want to work just like port X (i386-pc-solaris2.9 etc.) except for necessary changes and without the risk of breaking the port to earlier versions.) > Comparison with Solaris SPARC makes me believe that using > gregset_t/fpregset_t in amd64-sol2-nat.c isn't right and that you > should use prgregset_t/prfpregset_t instead. They seem to be defined to the same thing; and i386v4-nat.c (as used for earlier Solaris IA32 versions) is using the gregset_t and fpregset_t. > Again, for consistency with Solaris SPARC, could you name the makefile > fragments sol2-64.m[th] instead of sol64.m[th]? The IA32 Solaris fragments are named i386sol2.m[th], which might suggest i386sol2-64.m[th]. The IA32/AMD64 GNU/Linux fragments are named linux.m[ht] and linux64.m[ht]. Is there a general naming convention in use? > You're not listed in the GDB MAINTAINERS file, so we'll have to check > out the paperwork first before I can approve any of this. This work is under the blanket CodeSourcery company assignment. -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-10-25 19:55 ` Mark Kettenis 2004-10-25 22:03 ` Joseph S. Myers @ 2004-10-26 19:44 ` Joseph S. Myers 2004-10-26 20:50 ` Mark Kettenis 1 sibling, 1 reply; 11+ messages in thread From: Joseph S. Myers @ 2004-10-26 19:44 UTC (permalink / raw) To: Mark Kettenis; +Cc: gdb-patches On Mon, 25 Oct 2004, Mark Kettenis wrote: > Thanks for your contribution. The code looks pretty good to me, but > here are a few comments. This revised patch tries to take account of those comments. > The configuration is based on the existing IA32 Solaris support. > > Fair enough, although it's not necessarily the best example. The configuration remains based on that one. > This sounds pretty much like the situation for Solaris SPARC. I think > the way this is solved in sparc-sol2-tdep.c is pretty elegant, but I > may be biased ;-). The defined(__arch64__) should be dropped though, > since there is no need to support Linux and IA-32/AMD64. For > consistency with SPARC I'd suggest nameing the file i386-sol2-nat.c. It is now following sparc-sol2-nat.c - for that purpose I split i386v4-nat.c into two files, one defining the functions under different names so they can be used in this way and one defining the existing functions as wrappers for those names. > Comparison with Solaris SPARC makes me believe that using > gregset_t/fpregset_t in amd64-sol2-nat.c isn't right and that you > should use prgregset_t/prfpregset_t instead. I haven't made any changes in this area; i386v4-nat.c / i386v4-regset.c, now used from this file, use gregset_t/fpregset_t themselves. > Again, for consistency with Solaris SPARC, could you name the makefile > fragments sol2-64.m[th] instead of sol64.m[th]? Now named i386sol2-65.m[th] given the existing naming of the IA32 Solaris fragments. -- Joseph S. Myers joseph@codesourcery.com 2004-10-26 Joseph S. Myers <joseph@codesourcery.com> * Makefile.in (ALLDEPFILES): Add i386-sol2-nat.c, i386v4-regset.c and amd64-sol2-tdep.c. (i386v4_regset_h): New (amd64-sol2-tdep.o, i386-sol2-nat.o, i386v4-regset.o): Add dependencies. (i386v4-nat.o): Update dependencies. * i386-sol2-nat.c, i386v4-regset.h, amd64-sol2-tdep.c, config/i386/i386sol2-64.mh, config/i386/i386sol2-64.mt: New files. * i386v4-regset.c: Copy i386v4-nat.c with functions under different names. * i384v4-nat.c: Use functions from i386v4-regset.c * configu/i386/i386v4.mh, config/i386/i386v42mp.mh, config/i386/ncr3000.mh: Use i386v4-regset.o as well as i386v4-nat.o. * configure.host (i[34567]86-*-solaris2.1[0-9]*): Add new case. * configure.tgt (i[34567]86-*-solaris2.1[0-9]*): Likewise. * configure.in (*-*-solaris2.[[6789]]): Add *-*-solaris2.1[[0-9]] for definition of NEW_PROC_API. * configure: Regenerate. diff -rupN gdb/Makefile.in gdb-new/Makefile.in --- gdb/Makefile.in 2004-10-16 09:40:55.000000000 +0000 +++ gdb-new/Makefile.in 2004-10-26 19:01:42.000000000 +0000 @@ -701,6 +701,7 @@ gnu_nat_h = gnu-nat.h gregset_h = gregset.h hppa_tdep_h = hppa-tdep.h i386bsd_nat_h = i386bsd-nat.h +i386v4_regset_h = i386v4-regset.h i386_linux_tdep_h = i386-linux-tdep.h i386_tdep_h = i386-tdep.h i387_tdep_h = i387-tdep.h @@ -1358,6 +1359,7 @@ ALLDEPFILES = \ amd64nbsd-nat.c amd64nbsd-tdep.c \ amd64obsd-nat.c amd64obsd-tdep.c \ amd64-linux-nat.c amd64-linux-tdep.c \ + amd64-sol2-tdep.c \ arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \ armnbsd-nat.c armnbsd-tdep.c \ avr-tdep.c \ @@ -1374,6 +1376,7 @@ ALLDEPFILES = \ hppa-linux-tdep.c hppa-linux-nat.c \ hppabsd-nat.c hppabsd-tdep.c \ i386-tdep.c i386v-nat.c i386-linux-nat.c \ + i386-sol2-nat.c i386v4-regset.c \ i386v4-nat.c i386ly-tdep.c i386-cygwin-tdep.c \ i386bsd-nat.c i386bsd-tdep.c i386fbsd-nat.c i386fbsd-tdep.c \ i386nbsd-nat.c i386nbsd-tdep.c i386obsd-nat.c i386obsd-tdep.c \ @@ -1690,6 +1693,9 @@ amd64obsd-tdep.o: amd64obsd-tdep.c $(def $(symtab_h) $(objfiles_h) $(osabi_h) $(regset_h) $(target_h) \ $(gdb_assert_h) $(gdb_string_h) $(amd64_tdep_h) $(i387_tdep_h) \ $(solib_svr4_h) +amd64-sol2-tdep.o: amd64-sol2-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \ + $(regcache_h) $(osabi_h) $(symtab_h) $(gdb_string_h) $(amd64_tdep_h) \ + $(solib_svr4_h) amd64-tdep.o: amd64-tdep.c $(defs_h) $(arch_utils_h) $(block_h) \ $(dummy_frame_h) $(frame_h) $(frame_base_h) $(frame_unwind_h) \ $(inferior_h) $(gdbcmd_h) $(gdbcore_h) $(objfiles_h) $(regcache_h) \ @@ -2032,6 +2038,9 @@ i386obsd-tdep.o: i386obsd-tdep.c $(defs_ $(gdbcore_h) $(regcache_h) $(regset_h) $(symtab_h) $(objfiles_h) \ $(osabi_h) $(target_h) $(gdb_assert_h) $(gdb_string_h) \ $(i386_tdep_h) $(i387_tdep_h) $(solib_svr4_h) +i386-sol2-nat.o: i386-sol2-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \ + $(regcache_h) $(osabi_h) $(symtab_h) $(gdb_string_h) $(amd64_tdep_h) \ + $(gregset_h) $(amd64_nat_h) i386-sol2-tdep.o: i386-sol2-tdep.c $(defs_h) $(value_h) $(osabi_h) \ $(gdb_string_h) $(i386_tdep_h) $(solib_svr4_h) i386-stub.o: i386-stub.c @@ -2043,7 +2052,10 @@ i386-tdep.o: i386-tdep.c $(defs_h) $(arc $(value_h) $(dis_asm_h) $(gdb_assert_h) $(gdb_string_h) \ $(i386_tdep_h) $(i387_tdep_h) i386v4-nat.o: i386v4-nat.c $(defs_h) $(value_h) $(inferior_h) $(regcache_h) \ - $(i386_tdep_h) $(i387_tdep_h) $(gregset_h) + $(i386_tdep_h) $(i387_tdep_h) $(gregset_h) $(i386v4_regset_h) +i386v4-regset.o: i386v4-regset.c $(defs_h) $(value_h) $(inferior_h) \ + $(regcache_h) $(i386_tdep_h) $(i387_tdep_h) $(gregset_h) \ + $(i386v4_regset_h) i386v-nat.o: i386v-nat.c $(defs_h) $(frame_h) $(inferior_h) $(language_h) \ $(gdbcore_h) $(gdb_stat_h) $(floatformat_h) $(target_h) \ $(i386_tdep_h) diff -rupN gdb/amd64-sol2-tdep.c gdb-new/amd64-sol2-tdep.c --- gdb/amd64-sol2-tdep.c 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/amd64-sol2-tdep.c 2004-10-26 18:43:26.000000000 +0000 @@ -0,0 +1,126 @@ +/* Target-dependent code for AMD64 Solaris. + + Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Contributed by Joseph Myers, CodeSourcery, LLC. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "frame.h" +#include "gdbcore.h" +#include "regcache.h" +#include "osabi.h" +#include "symtab.h" + +#include "gdb_string.h" + +#include "amd64-tdep.h" +#include "solib-svr4.h" + +/* Mapping between the general-purpose registers in gregset_t format + and GDB's register cache layout. */ + +/* From <sys/regset.h>. */ +static int amd64_sol2_gregset_reg_offset[] = +{ + 14 * 8, /* %rax */ + 11 * 8, /* %rbx */ + 13 * 8, /* %rcx */ + 12 * 8, /* %rdx */ + 9 * 8, /* %rsi */ + 8 * 8, /* %rdi */ + 10 * 8, /* %rbp */ + 20 * 8, /* %rsp */ + 7 * 8, /* %r8 ... */ + 6 * 8, + 5 * 8, + 4 * 8, + 3 * 8, + 2 * 8, + 1 * 8, + 0 * 8, /* ... %r15 */ + 17 * 8, /* %rip */ + 16 * 8, /* %eflags */ + 18 * 8, /* %cs */ + 21 * 8, /* %ss */ + 25 * 8, /* %ds */ + 24 * 8, /* %es */ + 22 * 8, /* %fs */ + 23 * 8 /* %gs */ +}; +\f + +/* Return whether the frame preceding NEXT_FRAME corresponds to a + Solaris sigtramp routine. */ + +static int +amd64_sol2_sigtramp_p (struct frame_info *next_frame) +{ + CORE_ADDR pc = frame_pc_unwind (next_frame); + char *name; + + find_pc_partial_function (pc, &name, NULL, NULL); + return (name && (strcmp ("sigacthandler", name) == 0 + || strcmp (name, "ucbsigvechandler") == 0)); +} + +/* Solaris doesn't have a 'struct sigcontext', but it does have a + 'mcontext_t' that contains the saved set of machine registers. */ + +static CORE_ADDR +amd64_sol2_mcontext_addr (struct frame_info *next_frame) +{ + CORE_ADDR sp, ucontext_addr; + + sp = frame_unwind_register_unsigned (next_frame, AMD64_RSP_REGNUM); + ucontext_addr = get_frame_memory_unsigned (next_frame, sp + 8, 8); + + return ucontext_addr + 72; +} + +static void +amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset; + tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset); + tdep->sizeof_gregset = 28 * 8; + + amd64_init_abi (info, gdbarch); + + tdep->sigtramp_p = amd64_sol2_sigtramp_p; + tdep->sigcontext_addr = amd64_sol2_mcontext_addr; + tdep->sc_reg_offset = tdep->gregset_reg_offset; + tdep->sc_num_regs = tdep->gregset_num_regs; + + /* Solaris uses SVR4-style shared libraries. */ + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_lp64_fetch_link_map_offsets); +} +\f + +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern void _initialize_amd64_sol2_tdep (void); + +void +_initialize_amd64_sol2_tdep (void) +{ + gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, + GDB_OSABI_SOLARIS, amd64_sol2_init_abi); +} diff -rupN gdb/config/i386/i386sol2-64.mh gdb-new/config/i386/i386sol2-64.mh --- gdb/config/i386/i386sol2-64.mh 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/config/i386/i386sol2-64.mh 2004-10-26 19:19:28.000000000 +0000 @@ -0,0 +1,4 @@ +# Host: Solaris x86_64 +NATDEPFILES= fork-child.o amd64-nat.o i386v4-regset.o i386-sol2-nat.o \ + procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o gcore.o +NAT_FILE= nm-i386sol2.h diff -rupN gdb/config/i386/i386sol2-64.mt gdb-new/config/i386/i386sol2-64.mt --- gdb/config/i386/i386sol2-64.mt 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/config/i386/i386sol2-64.mt 2004-10-22 14:54:21.000000000 +0000 @@ -0,0 +1,4 @@ +# Target: Solaris x86_64 +TDEPFILES= i386-tdep.o i387-tdep.o amd64-tdep.o amd64-sol2-tdep.o \ + i386-sol2-tdep.o corelow.o solib.o solib-svr4.o +DEPRECATED_TM_FILE= tm-i386sol2.h diff -rupN gdb/config/i386/i386v4.mh gdb-new/config/i386/i386v4.mh --- gdb/config/i386/i386v4.mh 2004-08-06 08:05:24.000000000 +0000 +++ gdb-new/config/i386/i386v4.mh 2004-10-26 18:42:18.000000000 +0000 @@ -1,6 +1,6 @@ # Host: Intel 386 running SVR4 NAT_FILE= nm-i386v4.h -NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o \ - solib.o solib-svr4.o solib-legacy.o \ +NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-regset.o \ + i386v4-nat.o solib.o solib-svr4.o solib-legacy.o \ procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o diff -rupN gdb/config/i386/i386v42mp.mh gdb-new/config/i386/i386v42mp.mh --- gdb/config/i386/i386v42mp.mh 2004-08-06 08:05:24.000000000 +0000 +++ gdb-new/config/i386/i386v42mp.mh 2004-10-26 18:42:43.000000000 +0000 @@ -11,6 +11,6 @@ NAT_FILE= nm-i386v42mp.h # consequence, make considers subsequent tab-indented lines to be # some sort of error. NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o \ - gcore.o solib.o solib-svr4.o solib-legacy.o procfs.o proc-api.o \ - proc-events.o proc-flags.o proc-why.o uw-thread.o + i386v4-regset.o gcore.o solib.o solib-svr4.o solib-legacy.o procfs.o \ + proc-api.o proc-events.o proc-flags.o proc-why.o uw-thread.o diff -rupN gdb/config/i386/ncr3000.mh gdb-new/config/i386/ncr3000.mh --- gdb/config/i386/ncr3000.mh 2004-08-06 08:05:24.000000000 +0000 +++ gdb-new/config/i386/ncr3000.mh 2004-10-26 18:43:05.000000000 +0000 @@ -1,5 +1,6 @@ # Host: NCR 3000 (Intel 386 running SVR4) NAT_FILE= nm-i386v4.h -NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o procfs.o \ - proc-api.o proc-events.o proc-flags.o proc-why.o +NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o \ + i386v4-regset.o procfs.o proc-api.o proc-events.o proc-flags.o \ + proc-why.o diff -rupN gdb/configure.host gdb-new/configure.host --- gdb/configure.host 2004-09-02 08:31:47.000000000 +0000 +++ gdb-new/configure.host 2004-10-26 19:14:27.000000000 +0000 @@ -77,6 +77,7 @@ i[34567]86-*-openbsd*) gdb_host=obsd ;; i[34567]86-*-sco3.2v5*) gdb_host=i386sco5 ;; i[34567]86-*-sco3.2v4*) gdb_host=i386sco4 ;; i[34567]86-*-sco*) gdb_host=i386sco ;; +i[34567]86-*-solaris2.1[0-9]*) gdb_host=i386sol2-64 ;; i[34567]86-*-solaris*) gdb_host=i386sol2 ;; i[34567]86-*-sysv4.2*) gdb_host=i386v42mp ;; i[34567]86-*-sysv4*) gdb_host=i386v4 ;; diff -rupN gdb/configure.in gdb-new/configure.in --- gdb/configure.in 2004-10-11 08:48:32.000000000 +0000 +++ gdb-new/configure.in 2004-10-22 14:54:21.000000000 +0000 @@ -725,7 +725,7 @@ if test "${target}" = "${host}"; then *-*-unixware* | *-*-sysv4.2* | *-*-sysv5* | *-*-interix* ) AC_DEFINE(NEW_PROC_API) ;; - *-*-solaris2.[[6789]]) + *-*-solaris2.[[6789]] | *-*-solaris2.1[[0-9]]) AC_DEFINE(NEW_PROC_API) ;; mips-sgi-irix5*) diff -rupN gdb/configure.tgt gdb-new/configure.tgt --- gdb/configure.tgt 2004-10-04 07:44:59.000000000 +0000 +++ gdb-new/configure.tgt 2004-10-26 19:14:37.000000000 +0000 @@ -89,6 +89,7 @@ i[34567]86-*-netbsd* | i[34567]86-*-knet i[34567]86-*-openbsd*) gdb_target=obsd ;; i[34567]86-*-nto*) gdb_target=nto ;; i[34567]86-*-lynxos*) gdb_target=i386lynx ;; +i[34567]86-*-solaris2.1[0-9]*) gdb_target=i386sol2-64 ;; i[34567]86-*-solaris*) gdb_target=i386sol2 ;; i[34567]86-*-linux*) gdb_target=linux build_gdbserver=yes diff -rupN gdb/i386-sol2-nat.c gdb-new/i386-sol2-nat.c --- gdb/i386-sol2-nat.c 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/i386-sol2-nat.c 2004-10-26 18:56:24.000000000 +0000 @@ -0,0 +1,173 @@ +/* Native-dependent code for AMD64 Solaris. + + Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Contributed by Joseph Myers, CodeSourcery, LLC. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "inferior.h" +#include "gdbcore.h" +#include "regcache.h" +#include "osabi.h" +#include "symtab.h" + +#include "gdb_string.h" + +#include <sys/regset.h> +#include "gregset.h" + +#ifdef __x86_64__ + +#include "amd64-tdep.h" +#include "amd64-nat.h" + +#define i386_sol2_supply_gregset(gregsetp) \ + amd64_supply_native_gregset (current_regcache, gregsetp, -1) +#define i386_sol2_fill_gregset(grepsetp, regnum) \ + amd64_collect_native_gregset (current_regcache, gregsetp, regnum) +#define i386_sol2_supply_fpregset(fpregsetp) \ + amd64_supply_fxsave (current_regcache, -1, fpregsetp) +#define i386_sol2_fill_fpregset(fpregsetp, regnum) \ + amd64_collect_fxsave (current_regcache, regnum, fpregsetp) + +#else + +#define i386_sol2_supply_gregset(gregsetp) \ + i386v4_supply_native_gregset (gregsetp) +#define i386_sol2_fill_gregset(grepsetp, regnum) \ + i386v4_collect_native_gregset (gregsetp, regnum) +#define i386_sol2_supply_fpregset(fpregsetp) \ + i386v4_supply_fsave (fpregsetp) +#define i386_sol2_fill_fpregset(fpregsetp, regnum) \ + i386v4_collect_fsave (fpregsetp, regnum) + +#endif + +/* Mapping between the general-purpose registers in gregset_t format + and GDB's register cache layout. */ + +/* From <sys/regset.h>. */ +static int amd64_sol2_gregset64_reg_offset[] = +{ + 14 * 8, /* %rax */ + 11 * 8, /* %rbx */ + 13 * 8, /* %rcx */ + 12 * 8, /* %rdx */ + 9 * 8, /* %rsi */ + 8 * 8, /* %rdi */ + 10 * 8, /* %rbp */ + 20 * 8, /* %rsp */ + 7 * 8, /* %r8 ... */ + 6 * 8, + 5 * 8, + 4 * 8, + 3 * 8, + 2 * 8, + 1 * 8, + 0 * 8, /* ... %r15 */ + 17 * 8, /* %rip */ + 16 * 8, /* %eflags */ + 18 * 8, /* %cs */ + 21 * 8, /* %ss */ + 25 * 8, /* %ds */ + 24 * 8, /* %es */ + 22 * 8, /* %fs */ + 23 * 8 /* %gs */ +}; + +/* 32-bit registers are provided by Solaris in 64-bit format, so just + give a subset of the list above. */ +static int amd64_sol2_gregset32_reg_offset[] = +{ + 14 * 8, /* %eax */ + 13 * 8, /* %ecx */ + 12 * 8, /* %edx */ + 11 * 8, /* %ebx */ + 20 * 8, /* %esp */ + 10 * 8, /* %ebp */ + 9 * 8, /* %esi */ + 8 * 8, /* %edi */ + 17 * 8, /* %eip */ + 16 * 8, /* %eflags */ + 18 * 8, /* %cs */ + 21 * 8, /* %ss */ + 25 * 8, /* %ds */ + 24 * 8, /* %es */ + 22 * 8, /* %fs */ + 23 * 8 /* %gs */ +}; +\f + +/* Transfering the general-purpose registers between GDB, inferiors + and core files. */ + +/* Fill GDB's register cache with the general-purpose register values + in *GREGSETP. */ + +void +supply_gregset (gregset_t *gregsetp) +{ + i386_sol2_supply_gregset (gregsetp); +} + +/* Fill register REGNUM (if it is a general-purpose register) in + *GREGSETP with the value in GDB's register cache. If REGNUM is -1, + do this for all registers. */ + +void +fill_gregset (gregset_t *gregsetp, int regnum) +{ + i386_sol2_fill_gregset (gregsetp, regnum); +} + +/* Transfering floating-point registers between GDB, inferiors and cores. */ + +/* Fill GDB's register cache with the floating-point and SSE register + values in *FPREGSETP. */ + +void +supply_fpregset (fpregset_t *fpregsetp) +{ + i386_sol2_supply_fpregset (fpregsetp); +} + +/* Fill register REGNUM (if it is a floating-point or SSE register) in + *FPREGSETP with the value in GDB's register cache. If REGNUM is + -1, do this for all registers. */ + +void +fill_fpregset (fpregset_t *fpregsetp, int regnum) +{ + i386_sol2_fill_fpregset (fpregsetp, regnum); +} +\f + +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern void _initialize_amd64_sol2_nat (void); + +void +_initialize_amd64_sol2_nat (void) +{ +#ifdef __x86_64__ + amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset; + amd64_native_gregset32_num_regs = ARRAY_SIZE (amd64_sol2_gregset32_reg_offset); + amd64_native_gregset64_reg_offset = amd64_sol2_gregset64_reg_offset; + amd64_native_gregset64_num_regs = ARRAY_SIZE (amd64_sol2_gregset64_reg_offset); +#endif +} diff -rupN gdb/i386v4-nat.c gdb-new/i386v4-nat.c --- gdb/i386v4-nat.c 2004-07-02 14:24:09.000000000 +0000 +++ gdb-new/i386v4-nat.c 2004-10-26 18:59:05.000000000 +0000 @@ -32,6 +32,7 @@ #include "i386-tdep.h" #include "i387-tdep.h" +#include "i386v4-regset.h" #ifdef HAVE_SYS_PROCFS_H @@ -89,27 +90,13 @@ #ifdef HAVE_GREGSET_T -/* Mapping between the general-purpose registers in `/proc' - format and GDB's register array layout. */ -static int regmap[] = -{ - EAX, ECX, EDX, EBX, - UESP, EBP, ESI, EDI, - EIP, EFL, CS, SS, - DS, ES, FS, GS -}; - /* Fill GDB's register array with the general-purpose register values in *GREGSETP. */ void supply_gregset (gregset_t *gregsetp) { - greg_t *regp = (greg_t *) gregsetp; - int regnum; - - for (regnum = 0; regnum < I386_NUM_GREGS; regnum++) - regcache_raw_supply (current_regcache, regnum, regp + regmap[regnum]); + i386v4_supply_native_gregset (gregsetp); } /* Fill register REGNUM (if it is a general-purpose register) in @@ -119,12 +106,7 @@ supply_gregset (gregset_t *gregsetp) void fill_gregset (gregset_t *gregsetp, int regnum) { - greg_t *regp = (greg_t *) gregsetp; - int i; - - for (i = 0; i < I386_NUM_GREGS; i++) - if (regnum == -1 || regnum == i) - regcache_raw_collect (current_regcache, i, regp + regmap[i]); + i386v4_collect_native_gregset (gregsetp, regnum); } #endif /* HAVE_GREGSET_T */ @@ -137,10 +119,7 @@ fill_gregset (gregset_t *gregsetp, int r void supply_fpregset (fpregset_t *fpregsetp) { - if (FP0_REGNUM == 0) - return; - - i387_supply_fsave (current_regcache, -1, fpregsetp); + i386v4_supply_fsave (fpregsetp); } /* Fill register REGNO (if it is a floating-point register) in @@ -150,10 +129,7 @@ supply_fpregset (fpregset_t *fpregsetp) void fill_fpregset (fpregset_t *fpregsetp, int regno) { - if (FP0_REGNUM == 0) - return; - - i387_fill_fsave ((char *) fpregsetp, regno); + i386v4_collect_fsave (fpregsetp, regno); } #endif /* HAVE_FPREGSET_T */ diff -rupN gdb/i386v4-regset.c gdb-new/i386v4-regset.c --- gdb/i386v4-regset.c 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/i386v4-regset.c 2004-10-26 19:00:21.000000000 +0000 @@ -0,0 +1,162 @@ +/* Native-dependent code for Unix SVR4 running on i386's. + + Copyright 1988, 1989, 1991, 1992, 1996, 1997, 1998, 1999, 2000, + 2001, 2002, 2004 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "value.h" +#include "inferior.h" +#include "regcache.h" + +#ifdef HAVE_SYS_REG_H +#include <sys/reg.h> +#endif + +#include "i386-tdep.h" +#include "i387-tdep.h" +#include "i386v4-regset.h" + +#ifdef HAVE_SYS_PROCFS_H + +#include <sys/procfs.h> + +/* Prototypes for supply_gregset etc. */ +#include "gregset.h" + +/* The `/proc' interface divides the target machine's register set up + into two different sets, the general purpose register set (gregset) + and the floating-point register set (fpregset). For each set, + there is an ioctl to get the current register set and another ioctl + to set the current values. + + The actual structure passed through the ioctl interface is, of + course, naturally machine dependent, and is different for each set + of registers. For the i386 for example, the general-purpose + register set is typically defined by: + + typedef int gregset_t[19]; (in <sys/regset.h>) + + #define GS 0 (in <sys/reg.h>) + #define FS 1 + ... + #define UESP 17 + #define SS 18 + + and the floating-point set by: + + typedef struct fpregset { + union { + struct fpchip_state // fp extension state // + { + int state[27]; // 287/387 saved state // + int status; // status word saved at // + // exception // + } fpchip_state; + struct fp_emul_space // for emulators // + { + char fp_emul[246]; + char fp_epad[2]; + } fp_emul_space; + int f_fpregs[62]; // union of the above // + } fp_reg_set; + long f_wregs[33]; // saved weitek state // + } fpregset_t; + + Incidentally fpchip_state contains the FPU state in the same format + as used by the "fsave" instruction, and that's the only thing we + support here. I don't know how the emulator stores it state. The + Weitek stuff definitely isn't supported. + + The routines defined here, provide the packing and unpacking of + gregset_t and fpregset_t formatted data. */ + +#ifdef HAVE_GREGSET_T + +/* Mapping between the general-purpose registers in `/proc' + format and GDB's register array layout. */ +static int regmap[] = +{ + EAX, ECX, EDX, EBX, + UESP, EBP, ESI, EDI, + EIP, EFL, CS, SS, + DS, ES, FS, GS +}; + +/* Fill GDB's register array with the general-purpose register values + in *GREGSETP. */ + +void +i386v4_supply_native_gregset (gregset_t *gregsetp) +{ + greg_t *regp = (greg_t *) gregsetp; + int regnum; + + for (regnum = 0; regnum < I386_NUM_GREGS; regnum++) + regcache_raw_supply (current_regcache, regnum, regp + regmap[regnum]); +} + +/* Fill register REGNUM (if it is a general-purpose register) in + *GREGSETPS with the value in GDB's register array. If REGNUM is -1, + do this for all registers. */ + +void +i386v4_collect_native_gregset (gregset_t *gregsetp, int regnum) +{ + greg_t *regp = (greg_t *) gregsetp; + int i; + + for (i = 0; i < I386_NUM_GREGS; i++) + if (regnum == -1 || regnum == i) + regcache_raw_collect (current_regcache, i, regp + regmap[i]); +} + +#endif /* HAVE_GREGSET_T */ + +#ifdef HAVE_FPREGSET_T + +/* Fill GDB's register array with the floating-point register values in + *FPREGSETP. */ + +void +i386v4_supply_fsave (fpregset_t *fpregsetp) +{ + if (FP0_REGNUM == 0) + return; + + i387_supply_fsave (current_regcache, -1, fpregsetp); +} + +/* Fill register REGNO (if it is a floating-point register) in + *FPREGSETP with the value in GDB's register array. If REGNO is -1, + do this for all registers. */ + +void +i386v4_collect_fsave (fpregset_t *fpregsetp, int regno) +{ + if (FP0_REGNUM == 0) + return; + + i387_fill_fsave ((char *) fpregsetp, regno); +} + +#endif /* HAVE_FPREGSET_T */ + +#endif /* HAVE_SYS_PROCFS_H */ diff -rupN gdb/i386v4-regset.h gdb-new/i386v4-regset.h --- gdb/i386v4-regset.h 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/i386v4-regset.h 2004-10-26 19:05:21.000000000 +0000 @@ -0,0 +1,53 @@ +/* Native-dependent code for Unix SVR4 running on i386's. + + Copyright 1988, 1989, 1991, 1992, 1996, 1997, 1998, 1999, 2000, + 2001, 2002, 2004 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef I386V4_REGSET_H +#define I386V4_REGSET_H + +#include "defs.h" + +#ifdef HAVE_SYS_REG_H +#include <sys/reg.h> +#endif + +#ifdef HAVE_SYS_PROCFS_H + +#include <sys/procfs.h> + +#ifdef HAVE_GREGSET_T + +extern void i386v4_supply_native_gregset (gregset_t *); +extern void i386v4_collect_native_gregset (gregset_t *, int); + +#endif /* HAVE_GREGSET_T */ + +#ifdef HAVE_FPREGSET_T + +extern void i386v4_supply_fsave (fpregset_t *); +extern void i386v4_collect_fsave (fpregset_t *, int); + +#endif /* HAVE_FPREGSET_T */ + +#endif /* HAVE_SYS_PROCFS_H */ + +#endif /* i386v4-regset.h */ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-10-26 19:44 ` Joseph S. Myers @ 2004-10-26 20:50 ` Mark Kettenis 2004-10-30 19:57 ` Mark Kettenis 0 siblings, 1 reply; 11+ messages in thread From: Mark Kettenis @ 2004-10-26 20:50 UTC (permalink / raw) To: joseph; +Cc: gdb-patches Date: Tue, 26 Oct 2004 19:43:59 +0000 (UTC) From: "Joseph S. Myers" <joseph@codesourcery.com> On Mon, 25 Oct 2004, Mark Kettenis wrote: > Thanks for your contribution. The code looks pretty good to me, but > here are a few comments. This revised patch tries to take account of those comments. Sorry Joseph, I didn't find the time yet to answer your previous mail yet. I wish I had, because some of the changes you made aren't exactly going into the direction I'd want them to. > The configuration is based on the existing IA32 Solaris support. > > Fair enough, although it's not necessarily the best example. The configuration remains based on that one. > This sounds pretty much like the situation for Solaris SPARC. I think > the way this is solved in sparc-sol2-tdep.c is pretty elegant, but I > may be biased ;-). The defined(__arch64__) should be dropped though, > since there is no need to support Linux and IA-32/AMD64. For > consistency with SPARC I'd suggest nameing the file i386-sol2-nat.c. It is now following sparc-sol2-nat.c - for that purpose I split i386v4-nat.c into two files, one defining the functions under different names so they can be used in this way and one defining the existing functions as wrappers for those names. The splitting of the file doesn't make me happy. It'd be better if the Solaris code didn't attempt to use i386v4-nat.c at all, but that means some other changes are needed. Big difference between SPARC and AMD64 on one side and i386 on the other side is that the layout of the prfpregset is defined in the -tdep.c file instead of the -nat.c file. That's what I need to do for i386 too. Please give me a few days to set that right first. Why did you use #ifdef __x86_64__ in i386-sol2-nat.c. It's not unlikely that compilers will get that wrong. Please do this in a similar way to SPARC Solaris and use #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) (unless that doesn't work of course). > Comparison with Solaris SPARC makes me believe that using > gregset_t/fpregset_t in amd64-sol2-nat.c isn't right and that you > should use prgregset_t/prfpregset_t instead. I haven't made any changes in this area; i386v4-nat.c / i386v4-regset.c, now used from this file, use gregset_t/fpregset_t themselves. The Solaris-specific files should defenitely use prgregset_t/prfpgregset_t. It's the officially published API. > Again, for consistency with Solaris SPARC, could you name the makefile > fragments sol2-64.m[th] instead of sol64.m[th]? Now named i386sol2-65.m[th] given the existing naming of the IA32 Solaris fragments. The names of the IA32 Solaris fragments is historic. We've been moving to stripping the architecture from the name for quite some time now; it's already encoded in the name of the directory. So please use the names I suggested. Mark ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-10-26 20:50 ` Mark Kettenis @ 2004-10-30 19:57 ` Mark Kettenis 2004-10-30 20:01 ` Joseph S. Myers 0 siblings, 1 reply; 11+ messages in thread From: Mark Kettenis @ 2004-10-30 19:57 UTC (permalink / raw) To: joseph, gdb-patches Date: Tue, 26 Oct 2004 22:49:53 +0200 (CEST) From: Mark Kettenis <kettenis@gnu.org> The splitting of the file doesn't make me happy. It'd be better if the Solaris code didn't attempt to use i386v4-nat.c at all, but that means some other changes are needed. Big difference between SPARC and AMD64 on one side and i386 on the other side is that the layout of the prfpregset is defined in the -tdep.c file instead of the -nat.c file. That's what I need to do for i386 too. Please give me a few days to set that right first. OK, I didn't get it completely right yet, but I've checked in a i386-sol2-nat.c that avoids too much code duplication and should work. It probably needs to be tweaked a bit before it really works for the 64-bit case. Cheers, Mark ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-10-30 19:57 ` Mark Kettenis @ 2004-10-30 20:01 ` Joseph S. Myers 0 siblings, 0 replies; 11+ messages in thread From: Joseph S. Myers @ 2004-10-30 20:01 UTC (permalink / raw) To: Mark Kettenis; +Cc: gdb-patches On Sat, 30 Oct 2004, Mark Kettenis wrote: > OK, I didn't get it completely right yet, but I've checked in a > i386-sol2-nat.c that avoids too much code duplication and should work. > It probably needs to be tweaked a bit before it really works for the > 64-bit case. I think this should be a useful start, I'll produce a new patch based on this code and current CVS (and with the sol64.m[th] file names you requested), thanks. -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-10-25 17:48 Patch to support AMD64 Solaris 10 Joseph S. Myers 2004-10-25 19:39 ` Andrew Cagney 2004-10-25 19:55 ` Mark Kettenis @ 2004-11-01 16:43 ` Andrew Cagney 2004-11-01 20:08 ` Joseph S. Myers 2 siblings, 1 reply; 11+ messages in thread From: Andrew Cagney @ 2004-11-01 16:43 UTC (permalink / raw) To: Joseph S. Myers, Mark Kettenis; +Cc: gdb-patches Joseph, Mark, GDB's acceptance criteria for patches such as this is pretty clear: - (C) assignment tick - coding standard just run it through ./gdb_indent.sh - deprecation oops - ./gdb_ari.sh -Wari to flag other looming coding problems This is often easiest after the event. The only thing really blocking this patch is ``deprecation''. And there, the same patch minus the TM file would be acceptable (such a GDB would even build and to a point work) (notice how test results are not one of the acceptance criteria ;-). Joseph, can you submit an up-to-date patch _minus_ the TM file I'll approve it? By getting that committed we can get the bulk of the patch off the table. Then we can follow up with smaller patches addressing each of the remaining problems. First with the missing multi-arch macros, and second with any concerns with *-nat files. Does that sound reasonable? Andrew ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-11-01 16:43 ` Andrew Cagney @ 2004-11-01 20:08 ` Joseph S. Myers 2004-11-01 20:34 ` Mark Kettenis 0 siblings, 1 reply; 11+ messages in thread From: Joseph S. Myers @ 2004-11-01 20:08 UTC (permalink / raw) To: Andrew Cagney; +Cc: Mark Kettenis, gdb-patches On Mon, 1 Nov 2004, Andrew Cagney wrote: > The only thing really blocking this patch is ``deprecation''. And there, the > same patch minus the TM file would be acceptable (such a GDB would even build > and to a point work) (notice how test results are not one of the acceptance > criteria ;-). > > Joseph, can you submit an up-to-date patch _minus_ the TM file I'll approve > it? By getting that committed we can get the bulk of the patch off the table. > Then we can follow up with smaller patches addressing each of the remaining > problems. First with the missing multi-arch macros, and second with any > concerns with *-nat files. Here is a patch reformatted as requested and without the DEPRECATED_TM_FILE setting. -- Joseph S. Myers joseph@codesourcery.com 2004-11-01 Joseph S. Myers <joseph@codesourcery.com> * Makefile.in (ALLDEPFILES): Add amd64-sol2-tdep.c. (amd64-sol2-tdep.o): Add dependencies. * amd64-sol2-tdep.c, config/i386/sol2-64.mh, config/i386/sol2-64.mt: New files. * i386-sol2-nat.c (amd64_sol2_gregset64_reg_offset, amd64_sol2_gregset32_reg_offset, _initialize_amd64_sol2_nat): New. (supply_gregset): Correct order of arguments to amd64_supply_native_gregset. (fill_gregset): Correct order of arguments to amd64_collect_native_gregset. * configure.host (i[34567]86-*-solaris2.1[0-9]*): Add new case. * configure.tgt (i[34567]86-*-solaris2.1[0-9]*): Likewise. * configure.in (*-*-solaris2.[[6789]]): Add *-*-solaris2.1[[0-9]] for definition of NEW_PROC_API. * configure: Regenerate. diff -rupN gdb/Makefile.in gdb-new/Makefile.in --- gdb/Makefile.in 2004-10-31 10:13:00.000000000 +0000 +++ gdb-new/Makefile.in 2004-10-31 20:17:27.000000000 +0000 @@ -1360,6 +1360,7 @@ ALLDEPFILES = \ amd64nbsd-nat.c amd64nbsd-tdep.c \ amd64obsd-nat.c amd64obsd-tdep.c \ amd64-linux-nat.c amd64-linux-tdep.c \ + amd64-sol2-tdep.c \ arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \ armnbsd-nat.c armnbsd-tdep.c \ avr-tdep.c \ @@ -1694,6 +1695,9 @@ amd64obsd-tdep.o: amd64obsd-tdep.c $(def $(symtab_h) $(objfiles_h) $(osabi_h) $(regset_h) $(target_h) \ $(gdb_assert_h) $(gdb_string_h) $(amd64_tdep_h) $(i387_tdep_h) \ $(solib_svr4_h) +amd64-sol2-tdep.o: amd64-sol2-tdep.c $(defs_h) $(frame_h) $(gdbcore_h) \ + $(regcache_h) $(osabi_h) $(symtab_h) $(gdb_string_h) $(amd64_tdep_h) \ + $(solib_svr4_h) amd64-tdep.o: amd64-tdep.c $(defs_h) $(arch_utils_h) $(block_h) \ $(dummy_frame_h) $(frame_h) $(frame_base_h) $(frame_unwind_h) \ $(inferior_h) $(gdbcmd_h) $(gdbcore_h) $(objfiles_h) $(regcache_h) \ diff -rupN gdb/amd64-sol2-tdep.c gdb-new/amd64-sol2-tdep.c --- gdb/amd64-sol2-tdep.c 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/amd64-sol2-tdep.c 2004-11-01 16:54:02.000000000 +0000 @@ -0,0 +1,125 @@ +/* Target-dependent code for AMD64 Solaris. + + Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Contributed by Joseph Myers, CodeSourcery, LLC. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "frame.h" +#include "gdbcore.h" +#include "regcache.h" +#include "osabi.h" +#include "symtab.h" + +#include "gdb_string.h" + +#include "amd64-tdep.h" +#include "solib-svr4.h" + +/* Mapping between the general-purpose registers in gregset_t format + and GDB's register cache layout. */ + +/* From <sys/regset.h>. */ +static int amd64_sol2_gregset_reg_offset[] = { + 14 * 8, /* %rax */ + 11 * 8, /* %rbx */ + 13 * 8, /* %rcx */ + 12 * 8, /* %rdx */ + 9 * 8, /* %rsi */ + 8 * 8, /* %rdi */ + 10 * 8, /* %rbp */ + 20 * 8, /* %rsp */ + 7 * 8, /* %r8 ... */ + 6 * 8, + 5 * 8, + 4 * 8, + 3 * 8, + 2 * 8, + 1 * 8, + 0 * 8, /* ... %r15 */ + 17 * 8, /* %rip */ + 16 * 8, /* %eflags */ + 18 * 8, /* %cs */ + 21 * 8, /* %ss */ + 25 * 8, /* %ds */ + 24 * 8, /* %es */ + 22 * 8, /* %fs */ + 23 * 8 /* %gs */ +}; +\f + +/* Return whether the frame preceding NEXT_FRAME corresponds to a + Solaris sigtramp routine. */ + +static int +amd64_sol2_sigtramp_p (struct frame_info *next_frame) +{ + CORE_ADDR pc = frame_pc_unwind (next_frame); + char *name; + + find_pc_partial_function (pc, &name, NULL, NULL); + return (name && (strcmp ("sigacthandler", name) == 0 + || strcmp (name, "ucbsigvechandler") == 0)); +} + +/* Solaris doesn't have a 'struct sigcontext', but it does have a + 'mcontext_t' that contains the saved set of machine registers. */ + +static CORE_ADDR +amd64_sol2_mcontext_addr (struct frame_info *next_frame) +{ + CORE_ADDR sp, ucontext_addr; + + sp = frame_unwind_register_unsigned (next_frame, AMD64_RSP_REGNUM); + ucontext_addr = get_frame_memory_unsigned (next_frame, sp + 8, 8); + + return ucontext_addr + 72; +} + +static void +amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset; + tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset); + tdep->sizeof_gregset = 28 * 8; + + amd64_init_abi (info, gdbarch); + + tdep->sigtramp_p = amd64_sol2_sigtramp_p; + tdep->sigcontext_addr = amd64_sol2_mcontext_addr; + tdep->sc_reg_offset = tdep->gregset_reg_offset; + tdep->sc_num_regs = tdep->gregset_num_regs; + + /* Solaris uses SVR4-style shared libraries. */ + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_lp64_fetch_link_map_offsets); +} +\f + +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern void _initialize_amd64_sol2_tdep (void); + +void +_initialize_amd64_sol2_tdep (void) +{ + gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, + GDB_OSABI_SOLARIS, amd64_sol2_init_abi); +} diff -rupN gdb/config/i386/sol2-64.mh gdb-new/config/i386/sol2-64.mh --- gdb/config/i386/sol2-64.mh 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/config/i386/sol2-64.mh 2004-10-31 20:18:47.000000000 +0000 @@ -0,0 +1,4 @@ +# Host: Solaris x86_64 +NATDEPFILES= fork-child.o amd64-nat.o i386v4-nat.o i386-sol2-nat.o \ + procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o gcore.o +NAT_FILE= nm-i386sol2.h diff -rupN gdb/config/i386/sol2-64.mt gdb-new/config/i386/sol2-64.mt --- gdb/config/i386/sol2-64.mt 1970-01-01 00:00:00.000000000 +0000 +++ gdb-new/config/i386/sol2-64.mt 2004-11-01 16:50:18.000000000 +0000 @@ -0,0 +1,3 @@ +# Target: Solaris x86_64 +TDEPFILES= i386-tdep.o i387-tdep.o amd64-tdep.o amd64-sol2-tdep.o \ + i386-sol2-tdep.o corelow.o solib.o solib-svr4.o diff -rupN gdb/configure.host gdb-new/configure.host --- gdb/configure.host 2004-10-24 00:03:16.000000000 +0000 +++ gdb-new/configure.host 2004-10-31 20:19:23.000000000 +0000 @@ -77,6 +77,7 @@ i[34567]86-*-openbsd*) gdb_host=obsd ;; i[34567]86-*-sco3.2v5*) gdb_host=i386sco5 ;; i[34567]86-*-sco3.2v4*) gdb_host=i386sco4 ;; i[34567]86-*-sco*) gdb_host=i386sco ;; +i[34567]86-*-solaris2.1[0-9]*) gdb_host=sol2-64 ;; i[34567]86-*-solaris*) gdb_host=i386sol2 ;; i[34567]86-*-sysv4.2*) gdb_host=i386v42mp ;; i[34567]86-*-sysv4*) gdb_host=i386v4 ;; diff -rupN gdb/configure.in gdb-new/configure.in --- gdb/configure.in 2004-10-11 08:48:32.000000000 +0000 +++ gdb-new/configure.in 2004-10-31 20:19:23.000000000 +0000 @@ -725,7 +725,7 @@ if test "${target}" = "${host}"; then *-*-unixware* | *-*-sysv4.2* | *-*-sysv5* | *-*-interix* ) AC_DEFINE(NEW_PROC_API) ;; - *-*-solaris2.[[6789]]) + *-*-solaris2.[[6789]] | *-*-solaris2.1[[0-9]]) AC_DEFINE(NEW_PROC_API) ;; mips-sgi-irix5*) diff -rupN gdb/configure.tgt gdb-new/configure.tgt --- gdb/configure.tgt 2004-10-24 00:03:16.000000000 +0000 +++ gdb-new/configure.tgt 2004-10-31 20:19:23.000000000 +0000 @@ -89,6 +89,7 @@ i[34567]86-*-netbsd* | i[34567]86-*-knet i[34567]86-*-openbsd*) gdb_target=obsd ;; i[34567]86-*-nto*) gdb_target=nto ;; i[34567]86-*-lynxos*) gdb_target=i386lynx ;; +i[34567]86-*-solaris2.1[0-9]*) gdb_target=sol2-64 ;; i[34567]86-*-solaris*) gdb_target=i386sol2 ;; i[34567]86-*-linux*) gdb_target=linux build_gdbserver=yes diff -rupN gdb/i386-sol2-nat.c gdb-new/i386-sol2-nat.c --- gdb/i386-sol2-nat.c 2004-10-31 20:05:01.000000000 +0000 +++ gdb-new/i386-sol2-nat.c 2004-11-01 16:54:02.000000000 +0000 @@ -46,10 +46,62 @@ #include "amd64-nat.h" #include "amd64-tdep.h" +/* Mapping between the general-purpose registers in gregset_t format + and GDB's register cache layout. */ + +/* From <sys/regset.h>. */ +static int amd64_sol2_gregset64_reg_offset[] = { + 14 * 8, /* %rax */ + 11 * 8, /* %rbx */ + 13 * 8, /* %rcx */ + 12 * 8, /* %rdx */ + 9 * 8, /* %rsi */ + 8 * 8, /* %rdi */ + 10 * 8, /* %rbp */ + 20 * 8, /* %rsp */ + 7 * 8, /* %r8 ... */ + 6 * 8, + 5 * 8, + 4 * 8, + 3 * 8, + 2 * 8, + 1 * 8, + 0 * 8, /* ... %r15 */ + 17 * 8, /* %rip */ + 16 * 8, /* %eflags */ + 18 * 8, /* %cs */ + 21 * 8, /* %ss */ + 25 * 8, /* %ds */ + 24 * 8, /* %es */ + 22 * 8, /* %fs */ + 23 * 8 /* %gs */ +}; + +/* 32-bit registers are provided by Solaris in 64-bit format, so just + give a subset of the list above. */ +static int amd64_sol2_gregset32_reg_offset[] = { + 14 * 8, /* %eax */ + 13 * 8, /* %ecx */ + 12 * 8, /* %edx */ + 11 * 8, /* %ebx */ + 20 * 8, /* %esp */ + 10 * 8, /* %ebp */ + 9 * 8, /* %esi */ + 8 * 8, /* %edi */ + 17 * 8, /* %eip */ + 16 * 8, /* %eflags */ + 18 * 8, /* %cs */ + 21 * 8, /* %ss */ + 25 * 8, /* %ds */ + 24 * 8, /* %es */ + 22 * 8, /* %fs */ + 23 * 8 /* %gs */ +}; + void supply_gregset (prgregset_t *gregs) { - amd64_supply_native_gregset (current_regcache, -1, gregs); + amd64_supply_native_gregset (current_regcache, gregs, -1); } void @@ -61,7 +113,7 @@ supply_fpregset (prfpregset_t *fpregs) void fill_gregset (prgregset_t *gregs, int regnum) { - amd64_collect_native_gregset (current_regcache, regnum, gregs); + amd64_collect_native_gregset (current_regcache, gregs, regnum); } void @@ -75,3 +127,19 @@ fill_fpregset (prfpregset_t *fpregs, int /* For 32-bit Solaris x86, we use the Unix SVR4 code in i386v4-nat.c. */ #endif + +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern void _initialize_amd64_sol2_nat (void); + +void +_initialize_amd64_sol2_nat (void) +{ +#if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) + amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset; + amd64_native_gregset32_num_regs = + ARRAY_SIZE (amd64_sol2_gregset32_reg_offset); + amd64_native_gregset64_reg_offset = amd64_sol2_gregset64_reg_offset; + amd64_native_gregset64_num_regs = + ARRAY_SIZE (amd64_sol2_gregset64_reg_offset); +#endif +} ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Patch to support AMD64 Solaris 10 2004-11-01 20:08 ` Joseph S. Myers @ 2004-11-01 20:34 ` Mark Kettenis 0 siblings, 0 replies; 11+ messages in thread From: Mark Kettenis @ 2004-11-01 20:34 UTC (permalink / raw) To: joseph; +Cc: cagney, gdb-patches Date: Mon, 1 Nov 2004 20:08:41 +0000 (UTC) From: "Joseph S. Myers" <joseph@codesourcery.com> On Mon, 1 Nov 2004, Andrew Cagney wrote: > Joseph, can you submit an up-to-date patch _minus_ the TM file > I'll approve it? By getting that committed we can get the bulk > of the patch off the table. Then we can follow up with smaller > patches addressing each of the remaining problems. First with > the missing multi-arch macros, and second with any concerns with > *-nat files. Here is a patch reformatted as requested and without the DEPRECATED_TM_FILE setting. Go ahead. Please add yourself first to the Write After Aproval list in MAINTAINERS. Then go ahead and check this in. Mark ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-11-01 20:34 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-10-25 17:48 Patch to support AMD64 Solaris 10 Joseph S. Myers 2004-10-25 19:39 ` Andrew Cagney 2004-10-25 19:55 ` Mark Kettenis 2004-10-25 22:03 ` Joseph S. Myers 2004-10-26 19:44 ` Joseph S. Myers 2004-10-26 20:50 ` Mark Kettenis 2004-10-30 19:57 ` Mark Kettenis 2004-10-30 20:01 ` Joseph S. Myers 2004-11-01 16:43 ` Andrew Cagney 2004-11-01 20:08 ` Joseph S. Myers 2004-11-01 20:34 ` Mark Kettenis
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox