• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão61a12cfa7b25746914493cc0d94e5053a8492aa5 (tree)
Hora2015-03-14 04:24:22
AutorJan Kratochvil <jan.kratochvil@redh...>
CommiterJan Kratochvil

Mensagem de Log

Remove HPUX

IIUC it is a pre-requisite for IPv6 support, some UNICes do not support
getaddrinfo required for IPv6. But coincidentally such UNICes are no longer
really supported by GDB. Therefore it was concluded we can remove all such
UNICes and then we can implement IPv6 easily with getaddrinfo.

In mail

Re: getaddrinfo available on all GDB hosts? [Re: [PATCH v2] Add IPv6 support for remote TCP connections]
Message-ID: <20140211034157.GG5485@adacore.com>
https://sourceware.org/ml/gdb-patches/2014-02/msg00333.html

Joel said:

So I chose HP-UX first for this patch.

gdb/ChangeLog
2014-10-16 Jan Kratochvil <jan.kratochvil@redhat.com>

Remove HPUX.
* Makefile.in (ALL_64_TARGET_OBS): Remove ia64-hpux-tdep.o.
(ALL_TARGET_OBS): Remove hppa-hpux-tdep.o, solib-som.o and solib-pa64.o.
(HFILES_NO_SRCDIR): Remove solib-som.h, inf-ttrace.h, solib-pa64.h and
ia64-hpux-tdep.h, solib-ia64-hpux.h.
(ALLDEPFILES): Remove hppa-hpux-tdep.c, hppa-hpux-nat.c,
ia64-hpux-nat.c, ia64-hpux-tdep.c, somread.c and solib-som.c.
* config/djgpp/fnchange.lst: Remove hppa-hpux-nat.c and
hppa-hpux-tdep.c.
* config/ia64/hpux.mh: Remove file.
* config/pa/hpux.mh: Remove file.
* configure: Rebuilt.
* configure.ac (dlgetmodinfo, somread.o): Remove.
* configure.host (hppa*-*-hpux*, ia64-*-hpux*): Make them obsolete.
(ia64-*-hpux*): Remove its float format exception.
* configure.tgt (hppa*-*-hpux*, ia64-*-hpux*): Make them obsolete.
* hppa-hpux-nat.c: Remove file.
* hppa-hpux-tdep.c: Remove file.
* hppa-tdep.c (struct hppa_unwind_info, struct hppa_objfile_private):
Move them here from hppa-tdep.h
(hppa_objfile_priv_data, hppa_init_objfile_priv_data): Make it static.
(hppa_frame_prev_register_helper): Remove HPPA_FLAGS_REGNUM exception.
* hppa-tdep.h (struct hppa_unwind_info, struct hppa_objfile_private):
Move them to hppa-tdep.c.
(hppa_objfile_priv_data, hppa_init_objfile_priv_data): Remove
declarations.
* ia64-hpux-nat.c: Remove file.
* ia64-hpux-tdep.c: Remove file.
* ia64-hpux-tdep.h: Remove file.
* inf-ttrace.c: Remove file.
* inf-ttrace.h: Remove file.
* solib-ia64-hpux.c: Remove file.
* solib-ia64-hpux.h: Remove file.
* solib-pa64.c: Remove file.
* solib-pa64.h: Remove file.
* solib-som.c: Remove file.
* solib-som.h: Remove file.
* somread.c: Remove file.

Mudança Sumário

Diff

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,44 @@
1+2014-10-16 Jan Kratochvil <jan.kratochvil@redhat.com>
2+
3+ Remove HPUX.
4+ * Makefile.in (ALL_64_TARGET_OBS): Remove ia64-hpux-tdep.o.
5+ (ALL_TARGET_OBS): Remove hppa-hpux-tdep.o, solib-som.o and solib-pa64.o.
6+ (HFILES_NO_SRCDIR): Remove solib-som.h, inf-ttrace.h, solib-pa64.h and
7+ ia64-hpux-tdep.h, solib-ia64-hpux.h.
8+ (ALLDEPFILES): Remove hppa-hpux-tdep.c, hppa-hpux-nat.c,
9+ ia64-hpux-nat.c, ia64-hpux-tdep.c, somread.c and solib-som.c.
10+ * config/djgpp/fnchange.lst: Remove hppa-hpux-nat.c and
11+ hppa-hpux-tdep.c.
12+ * config/ia64/hpux.mh: Remove file.
13+ * config/pa/hpux.mh: Remove file.
14+ * configure: Rebuilt.
15+ * configure.ac (dlgetmodinfo, somread.o): Remove.
16+ * configure.host (hppa*-*-hpux*, ia64-*-hpux*): Make them obsolete.
17+ (ia64-*-hpux*): Remove its float format exception.
18+ * configure.tgt (hppa*-*-hpux*, ia64-*-hpux*): Make them obsolete.
19+ * hppa-hpux-nat.c: Remove file.
20+ * hppa-hpux-tdep.c: Remove file.
21+ * hppa-tdep.c (struct hppa_unwind_info, struct hppa_objfile_private):
22+ Move them here from hppa-tdep.h
23+ (hppa_objfile_priv_data, hppa_init_objfile_priv_data): Make it static.
24+ (hppa_frame_prev_register_helper): Remove HPPA_FLAGS_REGNUM exception.
25+ * hppa-tdep.h (struct hppa_unwind_info, struct hppa_objfile_private):
26+ Move them to hppa-tdep.c.
27+ (hppa_objfile_priv_data, hppa_init_objfile_priv_data): Remove
28+ declarations.
29+ * ia64-hpux-nat.c: Remove file.
30+ * ia64-hpux-tdep.c: Remove file.
31+ * ia64-hpux-tdep.h: Remove file.
32+ * inf-ttrace.c: Remove file.
33+ * inf-ttrace.h: Remove file.
34+ * solib-ia64-hpux.c: Remove file.
35+ * solib-ia64-hpux.h: Remove file.
36+ * solib-pa64.c: Remove file.
37+ * solib-pa64.h: Remove file.
38+ * solib-som.c: Remove file.
39+ * solib-som.h: Remove file.
40+ * somread.c: Remove file.
41+
142 2015-03-13 John Baldwin <jhb@FreeBSD.org>
243
344 * configure.ac: AC_SEARCH_LIBS(kinfo_getvmmap, util).
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -635,7 +635,7 @@ ALL_64_TARGET_OBS = \
635635 amd64fbsd-tdep.o amd64-darwin-tdep.o amd64-dicos-tdep.o \
636636 amd64-linux-tdep.o amd64nbsd-tdep.o \
637637 amd64obsd-tdep.o amd64-sol2-tdep.o amd64-tdep.o amd64-windows-tdep.o \
638- ia64-hpux-tdep.o ia64-linux-tdep.o ia64-vms-tdep.o ia64-tdep.o \
638+ ia64-linux-tdep.o ia64-vms-tdep.o ia64-tdep.o \
639639 mips64obsd-tdep.o \
640640 sparc64fbsd-tdep.o sparc64-linux-tdep.o sparc64nbsd-tdep.o \
641641 sparc64obsd-tdep.o sparc64-sol2-tdep.o sparc64-tdep.o
@@ -653,7 +653,7 @@ ALL_TARGET_OBS = \
653653 frv-linux-tdep.o frv-tdep.o \
654654 h8300-tdep.o \
655655 hppabsd-tdep.o hppanbsd-tdep.o hppaobsd-tdep.o \
656- hppa-hpux-tdep.o hppa-linux-tdep.o hppa-tdep.o \
656+ hppa-linux-tdep.o hppa-tdep.o \
657657 i386bsd-tdep.o i386-cygwin-tdep.o i386fbsd-tdep.o i386gnu-tdep.o \
658658 i386-linux-tdep.o i386nbsd-tdep.o i386-nto-tdep.o i386obsd-tdep.o \
659659 i386-sol2-tdep.o i386-tdep.o i387-tdep.o \
@@ -698,7 +698,7 @@ ALL_TARGET_OBS = \
698698 nbsd-tdep.o obsd-tdep.o \
699699 sol2-tdep.o \
700700 solib-frv.o solib-svr4.o \
701- solib-som.o solib-pa64.o solib-darwin.o solib-dsbt.o \
701+ solib-darwin.o solib-dsbt.o \
702702 dbug-rom.o dink32-rom.o ppcbug-rom.o m32r-rom.o dsrec.o monitor.o \
703703 remote-m32r-sdi.o remote-mips.o \
704704 xcoffread.o \
@@ -894,7 +894,7 @@ common/gdb_signals.h nat/gdb_thread_db.h common/gdb_vecs.h \
894894 common/x86-xstate.h nat/linux-ptrace.h nat/mips-linux-watch.h \
895895 proc-utils.h aarch64-tdep.h arm-tdep.h ax-gdb.h ppcfbsd-tdep.h \
896896 ppcnbsd-tdep.h cli-out.h gdb_expat.h breakpoint.h infcall.h obsd-tdep.h \
897-exec.h m32r-tdep.h osabi.h gdbcore.h solib-som.h amd64bsd-nat.h \
897+exec.h m32r-tdep.h osabi.h gdbcore.h amd64bsd-nat.h \
898898 i386bsd-nat.h xml-support.h xml-tdesc.h alphabsd-tdep.h gdb_obstack.h \
899899 ia64-tdep.h ada-lang.h varobj.h varobj-iter.h frv-tdep.h \
900900 nto-tdep.h serial.h \
@@ -911,7 +911,7 @@ ser-unix.h inf-ptrace.h terminal.h ui-out.h frame-base.h \
911911 f-lang.h dwarf2loc.h value.h sparc-tdep.h defs.h target-descriptions.h \
912912 objfiles.h common/vec.h disasm.h mips-tdep.h ser-base.h \
913913 gdb_curses.h bfd-target.h memattr.h inferior.h ax.h dummy-frame.h \
914-inflow.h fbsd-nat.h ia64-libunwind-tdep.h completer.h inf-ttrace.h \
914+inflow.h fbsd-nat.h ia64-libunwind-tdep.h completer.h \
915915 solib-target.h gdb_vfork.h alpha-tdep.h dwarf2expr.h \
916916 m2-lang.h stack.h charset.h addrmap.h command.h solist.h source.h \
917917 target.h target-dcache.h prologue-value.h cp-abi.h tui/tui-hooks.h tui/tui.h \
@@ -928,7 +928,7 @@ complaints.h gdb_proc_service.h gdb_regex.h xtensa-tdep.h inf-loop.h \
928928 common/gdb_wait.h common/gdb_assert.h solib.h ppc-tdep.h cp-support.h glibc-tdep.h \
929929 interps.h auxv.h gdbcmd.h tramp-frame.h mipsnbsd-tdep.h \
930930 amd64-linux-tdep.h linespec.h i387-tdep.h mn10300-tdep.h \
931-sparc64-tdep.h monitor.h ppcobsd-tdep.h srec.h solib-pa64.h \
931+sparc64-tdep.h monitor.h ppcobsd-tdep.h srec.h \
932932 coff-pe-read.h parser-defs.h gdb_ptrace.h mips-linux-tdep.h \
933933 m68k-tdep.h spu-tdep.h jv-lang.h environ.h amd64-tdep.h \
934934 doublest.h regset.h hppa-tdep.h ppc-linux-tdep.h ppc64-tdep.h \
@@ -945,7 +945,7 @@ annotate.h sim-regno.h dictionary.h dfp.h main.h frame-unwind.h \
945945 remote-fileio.h i386-linux-tdep.h vax-tdep.h objc-lang.h \
946946 sentinel-frame.h bcache.h symfile.h windows-tdep.h linux-tdep.h \
947947 gdb_usleep.h jit.h xml-syscall.h microblaze-tdep.h \
948-psymtab.h psympriv.h progspace.h bfin-tdep.h ia64-hpux-tdep.h \
948+psymtab.h psympriv.h progspace.h bfin-tdep.h \
949949 amd64-darwin-tdep.h charset-list.h \
950950 config/djgpp/langinfo.h config/djgpp/nl_types.h darwin-nat.h \
951951 dicos-tdep.h filesystem.h gcore.h gdb_wchar.h hppabsd-tdep.h \
@@ -953,7 +953,7 @@ i386-darwin-tdep.h x86-nat.h linux-record.h moxie-tdep.h nios2-tdep.h \
953953 osdata.h procfs.h python/py-event.h python/py-events.h python/py-stopevent.h \
954954 python/python-internal.h python/python.h ravenscar-thread.h record.h \
955955 record-full.h solib-aix.h \
956-solib-darwin.h solib-ia64-hpux.h solib-spu.h windows-nat.h xcoffread.h \
956+solib-darwin.h solib-spu.h windows-nat.h xcoffread.h \
957957 gnulib/import/extra/snippet/arg-nonnull.h gnulib/import/extra/snippet/c++defs.h \
958958 gnulib/import/extra/snippet/warn-on-use.h \
959959 gnulib/import/stddef.in.h gnulib/import/inttypes.in.h inline-frame.h skip.h \
@@ -1657,7 +1657,7 @@ ALLDEPFILES = \
16571657 fork-child.c \
16581658 glibc-tdep.c \
16591659 go32-nat.c h8300-tdep.c \
1660- hppa-tdep.c hppa-hpux-tdep.c hppa-hpux-nat.c \
1660+ hppa-tdep.c \
16611661 hppa-linux-tdep.c hppa-linux-nat.c \
16621662 hppabsd-tdep.c \
16631663 hppanbsd-nat.c hppanbsd-tdep.c \
@@ -1672,9 +1672,8 @@ ALLDEPFILES = \
16721672 i386-linux-tdep.c x86-nat.c \
16731673 i386-sol2-nat.c i386-sol2-tdep.c \
16741674 i386gnu-nat.c i386gnu-tdep.c \
1675- ia64-hpux-nat.c ia64-hpux-tdep.c \
16761675 ia64-linux-nat.c ia64-linux-tdep.c ia64-tdep.c ia64-vms-tdep.c \
1677- inf-ptrace.c inf-ttrace.c \
1676+ inf-ptrace.c \
16781677 ia64-libunwind-tdep.c \
16791678 linux-fork.c \
16801679 linux-tdep.c \
@@ -1697,7 +1696,6 @@ ALLDEPFILES = \
16971696 msp430-tdep.c \
16981697 nios2-tdep.c nios2-linux-tdep.c \
16991698 nbsd-nat.c nbsd-tdep.c obsd-nat.c obsd-tdep.c \
1700- somread.c solib-som.c \
17011699 posix-hdep.c common/posix-strerror.c \
17021700 ppc-sysv-tdep.c ppc-linux-nat.c ppc-linux-tdep.c ppc64-tdep.c \
17031701 ppcfbsd-nat.c ppcfbsd-tdep.c \
--- a/gdb/config/djgpp/fnchange.lst
+++ b/gdb/config/djgpp/fnchange.lst
@@ -510,8 +510,6 @@
510510 @V@/gdb/amd64-linux-nat.c @V@/gdb/amd64-lnat.c
511511 @V@/gdb/hppa-linux-tdep.c @V@/gdb/palnxtdep.c
512512 @V@/gdb/hppa-linux-nat.c @V@/gdb/palnxnat.c
513-@V@/gdb/hppa-hpux-nat.c @V@/gdb/pahpuxnat.c
514-@V@/gdb/hppa-hpux-tdep.c @V@/gdb/pahpuxtdep.c
515513 @V@/gdb/hppanbsd-nat.c @V@/gdb/panbsd-nat.c
516514 @V@/gdb/hppanbsd-tdep.c @V@/gdb/panbsd-tdep.c
517515 @V@/gdb/amd64-windows-nat.c @V@/gdb/amd64-wnat.c
--- a/gdb/config/ia64/hpux.mh
+++ /dev/null
@@ -1,3 +0,0 @@
1-# Host: ia64 running HP-UX
2-NATDEPFILES= fork-child.o inf-ttrace.o ia64-hpux-nat.o \
3- solib-ia64-hpux.o
--- a/gdb/config/pa/hpux.mh
+++ /dev/null
@@ -1,3 +0,0 @@
1-# Host: PA-RISC HP-UX
2-NATDEPFILES= fork-child.o inf-ptrace.o inf-ttrace.o \
3- hppa-hpux-nat.o
--- a/gdb/configure
+++ b/gdb/configure
@@ -7101,64 +7101,6 @@ fi
71017101 fi
71027102
71037103
7104-# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
7105-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlgetmodinfo" >&5
7106-$as_echo_n "checking for library containing dlgetmodinfo... " >&6; }
7107-if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
7108- $as_echo_n "(cached) " >&6
7109-else
7110- ac_func_search_save_LIBS=$LIBS
7111-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7112-/* end confdefs.h. */
7113-
7114-/* Override any GCC internal prototype to avoid an error.
7115- Use char because int might match the return type of a GCC
7116- builtin and then its argument prototype would still apply. */
7117-#ifdef __cplusplus
7118-extern "C"
7119-#endif
7120-char dlgetmodinfo ();
7121-int
7122-main ()
7123-{
7124-return dlgetmodinfo ();
7125- ;
7126- return 0;
7127-}
7128-_ACEOF
7129-for ac_lib in '' dl xpdl; do
7130- if test -z "$ac_lib"; then
7131- ac_res="none required"
7132- else
7133- ac_res=-l$ac_lib
7134- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
7135- fi
7136- if ac_fn_c_try_link "$LINENO"; then :
7137- ac_cv_search_dlgetmodinfo=$ac_res
7138-fi
7139-rm -f core conftest.err conftest.$ac_objext \
7140- conftest$ac_exeext
7141- if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
7142- break
7143-fi
7144-done
7145-if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
7146-
7147-else
7148- ac_cv_search_dlgetmodinfo=no
7149-fi
7150-rm conftest.$ac_ext
7151-LIBS=$ac_func_search_save_LIBS
7152-fi
7153-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlgetmodinfo" >&5
7154-$as_echo "$ac_cv_search_dlgetmodinfo" >&6; }
7155-ac_res=$ac_cv_search_dlgetmodinfo
7156-if test "$ac_res" != no; then :
7157- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
7158-
7159-fi
7160-
7161-
71627104 # On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
71637105 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kinfo_getvmmap" >&5
71647106 $as_echo_n "checking for library containing kinfo_getvmmap... " >&6; }
@@ -13803,54 +13745,6 @@ if test $gdb_cv_var_macho = yes; then
1380313745 CONFIG_OBS="$CONFIG_OBS machoread.o"
1380413746 fi
1380513747
13806-# Add SOM support to GDB, but only if BFD includes it.
13807-
13808- OLD_CFLAGS=$CFLAGS
13809- OLD_LDFLAGS=$LDFLAGS
13810- OLD_LIBS=$LIBS
13811- # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
13812- # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
13813- # always want our bfd.
13814- CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
13815- LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
13816- intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
13817- LIBS="-lbfd -liberty $intl $LIBS"
13818- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SOM support in BFD" >&5
13819-$as_echo_n "checking for SOM support in BFD... " >&6; }
13820-if test "${gdb_cv_var_som+set}" = set; then :
13821- $as_echo_n "(cached) " >&6
13822-else
13823- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13824-/* end confdefs.h. */
13825-#include <stdlib.h>
13826- #include "bfd.h"
13827- #include "som.h"
13828-
13829-int
13830-main ()
13831-{
13832-return bfd_som_attach_aux_hdr (NULL, 0, NULL);
13833- ;
13834- return 0;
13835-}
13836-_ACEOF
13837-if ac_fn_c_try_link "$LINENO"; then :
13838- gdb_cv_var_som=yes
13839-else
13840- gdb_cv_var_som=no
13841-fi
13842-rm -f core conftest.err conftest.$ac_objext \
13843- conftest$ac_exeext conftest.$ac_ext
13844-fi
13845-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_var_som" >&5
13846-$as_echo "$gdb_cv_var_som" >&6; }
13847- CFLAGS=$OLD_CFLAGS
13848- LDFLAGS=$OLD_LDFLAGS
13849- LIBS=$OLD_LIBS
13850-if test $gdb_cv_var_som = yes; then
13851- CONFIG_OBS="$CONFIG_OBS somread.o"
13852-fi
13853-
1385413748 # Add any host-specific objects to GDB.
1385513749 CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
1385613750
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -534,9 +534,6 @@ AC_SEARCH_LIBS(socketpair, socket)
534534 # Link in zlib if we can. This allows us to read compressed debug sections.
535535 AM_ZLIB
536536
537-# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
538-AC_SEARCH_LIBS(dlgetmodinfo, [dl xpdl])
539-
540537 # On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
541538 AC_SEARCH_LIBS(kinfo_getvmmap, util,
542539 [AC_DEFINE(HAVE_KINFO_GETVMMAP, 1,
@@ -2134,13 +2131,6 @@ if test $gdb_cv_var_macho = yes; then
21342131 CONFIG_OBS="$CONFIG_OBS machoread.o"
21352132 fi
21362133
2137-# Add SOM support to GDB, but only if BFD includes it.
2138-GDB_AC_CHECK_BFD([for SOM support in BFD], gdb_cv_var_som,
2139- [bfd_som_attach_aux_hdr (NULL, 0, NULL)], som.h)
2140-if test $gdb_cv_var_som = yes; then
2141- CONFIG_OBS="$CONFIG_OBS somread.o"
2142-fi
2143-
21442134 # Add any host-specific objects to GDB.
21452135 CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
21462136
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -44,6 +44,8 @@ case $host in
4444 vax-*-bsd* | \
4545 vax-*-netbsd* | \
4646 vax-*-ultrix* | \
47+ hppa*-*-hpux* | \
48+ ia64-*-hpux* | \
4749 null)
4850 echo "*** Configuration $host is obsolete." >&2
4951 echo "*** Support has been REMOVED." >&2
@@ -93,8 +95,6 @@ arm*-*-netbsdelf* | arm*-*-knetbsd*-gnu)
9395 gdb_host=nbsdelf ;;
9496 arm*-*-openbsd*) gdb_host=nbsdelf ;;
9597
96-hppa*-*-hpux*)
97- gdb_host=hpux ;;
9898 hppa*-*-linux*) gdb_host=linux ;;
9999 hppa*-*-netbsd*) gdb_host=nbsd ;;
100100 hppa*-*-openbsd*) gdb_host=obsd ;;
@@ -117,7 +117,6 @@ i[34567]86-*-solaris2.1[0-9]* | x86_64-*-solaris2.1[0-9]*)
117117 i[34567]86-*-solaris*) gdb_host=i386sol2 ;;
118118 i[34567]86-*-cygwin*) gdb_host=cygwin ;;
119119
120-ia64-*-hpux*) gdb_host=hpux ;;
121120 ia64-*-linux*) gdb_host=linux ;;
122121
123122 m68*-*-linux*) gdb_host=linux ;;
@@ -211,11 +210,6 @@ m68*-*-*)
211210 gdb_host_double_format="&floatformat_ieee_double_big"
212211 gdb_host_long_double_format="&floatformat_m68881_ext"
213212 ;;
214-ia64-*-hpux*)
215- gdb_host_float_format="&floatformat_ieee_single_big"
216- gdb_host_double_format="&floatformat_ieee_double_big"
217- gdb_host_long_double_format="&floatformat_ia64_quad_big"
218- ;;
219213 *)
220214 gdb_host_float_format=0
221215 gdb_host_double_format=0
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -24,6 +24,8 @@ case $targ in
2424 mips*-*-pe | \
2525 rs6000-*-lynxos* | \
2626 sh*-*-pe | \
27+ hppa*-*-hpux* | \
28+ ia64-*-hpux* | \
2729 null)
2830 echo "*** Configuration $targ is obsolete." >&2
2931 echo "*** Support has been REMOVED." >&2
@@ -149,10 +151,6 @@ h8300-*-*)
149151 gdb_sim=../sim/h8300/libsim.a
150152 ;;
151153
152-hppa*-*-hpux*)
153- # Target: HP PA-RISC running hpux
154- gdb_target_obs="hppa-tdep.o hppa-hpux-tdep.o solib-som.o solib-pa64.o"
155- ;;
156154 hppa*-*-linux*)
157155 # Target: HP PA-RISC running Linux
158156 gdb_target_obs="hppa-tdep.o hppa-linux-tdep.o glibc-tdep.o \
@@ -247,10 +245,6 @@ i[34567]86-*-*)
247245 gdb_target_obs="i386-tdep.o i387-tdep.o"
248246 ;;
249247
250-ia64-*-hpux*)
251- # Target: Intel IA-64 running HP-UX
252- gdb_target_obs="ia64-tdep.o ia64-hpux-tdep.o"
253- ;;
254248 ia64-*-linux*)
255249 # Target: Intel IA-64 running GNU/Linux
256250 gdb_target_obs="ia64-tdep.o ia64-linux-tdep.o linux-tdep.o \
--- a/gdb/hppa-hpux-nat.c
+++ /dev/null
@@ -1,273 +0,0 @@
1-/* Native-dependent code for PA-RISC HP-UX.
2-
3- Copyright (C) 2004-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#include "defs.h"
21-#include "inferior.h"
22-#include "regcache.h"
23-#include "target.h"
24-
25-#include <sys/ptrace.h>
26-#include <sys/utsname.h>
27-#include <machine/save_state.h>
28-
29-#ifdef HAVE_TTRACE
30-#include <sys/ttrace.h>
31-#endif
32-
33-#include "hppa-tdep.h"
34-#include "solib-som.h"
35-#include "inf-ptrace.h"
36-#include "inf-ttrace.h"
37-
38-/* Return the offset of register REGNUM within `struct save_state'.
39- The offset returns depends on the flags in the "flags" register and
40- the register size (32-bit or 64-bit). These are taken from
41- REGCACHE. */
42-
43-static LONGEST
44-hppa_hpux_save_state_offset (struct regcache *regcache, int regnum)
45-{
46- LONGEST offset;
47-
48- if (regnum == HPPA_FLAGS_REGNUM)
49- return ssoff (ss_flags);
50-
51- if (HPPA_R0_REGNUM < regnum && regnum < HPPA_FP0_REGNUM)
52- {
53- struct gdbarch *arch = get_regcache_arch (regcache);
54- size_t size = register_size (arch, HPPA_R1_REGNUM);
55- ULONGEST flags;
56-
57- gdb_assert (size == 4 || size == 8);
58-
59- regcache_cooked_read_unsigned (regcache, HPPA_FLAGS_REGNUM, &flags);
60- if (flags & SS_WIDEREGS)
61- offset = ssoff (ss_wide) + (8 - size) + (regnum - HPPA_R0_REGNUM) * 8;
62- else
63- offset = ssoff (ss_narrow) + (regnum - HPPA_R1_REGNUM) * 4;
64- }
65- else
66- {
67- struct gdbarch *arch = get_regcache_arch (regcache);
68- size_t size = register_size (arch, HPPA_FP0_REGNUM);
69-
70- gdb_assert (size == 4 || size == 8);
71- gdb_assert (regnum >= HPPA_FP0_REGNUM);
72- offset = ssoff(ss_fpblock) + (regnum - HPPA_FP0_REGNUM) * size;
73- }
74-
75- gdb_assert (offset < sizeof (save_state_t));
76- return offset;
77-}
78-
79-/* Just in case a future version of PA-RISC HP-UX won't have ptrace(2)
80- at all. */
81-#ifndef PTRACE_TYPE_RET
82-#define PTRACE_TYPE_RET void
83-#endif
84-
85-static void
86-hppa_hpux_fetch_register (struct regcache *regcache, int regnum)
87-{
88- struct gdbarch *gdbarch = get_regcache_arch (regcache);
89- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
90- CORE_ADDR addr;
91- size_t size;
92- PTRACE_TYPE_RET *buf;
93- pid_t pid;
94- int i;
95-
96- pid = ptid_get_pid (inferior_ptid);
97-
98- /* This isn't really an address, but ptrace thinks of it as one. */
99- addr = hppa_hpux_save_state_offset (regcache, regnum);
100- size = register_size (gdbarch, regnum);
101-
102- gdb_assert (size == 4 || size == 8);
103- buf = alloca (size);
104-
105-#ifdef HAVE_TTRACE
106- {
107- lwpid_t lwp = ptid_get_lwp (inferior_ptid);
108-
109- if (ttrace (TT_LWP_RUREGS, pid, lwp, addr, size, (uintptr_t)buf) == -1)
110- error (_("Couldn't read register %s (#%d): %s"),
111- gdbarch_register_name (gdbarch, regnum),
112- regnum, safe_strerror (errno));
113- }
114-#else
115- {
116- int i;
117-
118- /* Read the register contents from the inferior a chuck at the time. */
119- for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
120- {
121- errno = 0;
122- buf[i] = ptrace (PT_RUREGS, pid, (PTRACE_TYPE_ARG3) addr, 0, 0);
123- if (errno != 0)
124- error (_("Couldn't read register %s (#%d): %s"),
125- gdbarch_register_name (gdbarch, regnum),
126- regnum, safe_strerror (errno));
127-
128- addr += sizeof (PTRACE_TYPE_RET);
129- }
130- }
131-#endif
132-
133- /* Take care with the "flags" register. It's stored as an `int' in
134- `struct save_state', even for 64-bit code. */
135- if (regnum == HPPA_FLAGS_REGNUM && size == 8)
136- {
137- ULONGEST flags;
138- flags = extract_unsigned_integer ((gdb_byte *)buf, 4, byte_order);
139- store_unsigned_integer ((gdb_byte *)buf, 8, byte_order, flags);
140- }
141-
142- regcache_raw_supply (regcache, regnum, buf);
143-}
144-
145-static void
146-hppa_hpux_fetch_inferior_registers (struct target_ops *ops,
147- struct regcache *regcache, int regnum)
148-{
149- if (regnum == -1)
150- for (regnum = 0;
151- regnum < gdbarch_num_regs (get_regcache_arch (regcache));
152- regnum++)
153- hppa_hpux_fetch_register (regcache, regnum);
154- else
155- hppa_hpux_fetch_register (regcache, regnum);
156-}
157-
158-/* Store register REGNUM into the inferior. */
159-
160-static void
161-hppa_hpux_store_register (struct regcache *regcache, int regnum)
162-{
163- struct gdbarch *gdbarch = get_regcache_arch (regcache);
164- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
165- CORE_ADDR addr;
166- size_t size;
167- PTRACE_TYPE_RET *buf;
168- pid_t pid;
169-
170- pid = ptid_get_pid (inferior_ptid);
171-
172- /* This isn't really an address, but ptrace thinks of it as one. */
173- addr = hppa_hpux_save_state_offset (regcache, regnum);
174- size = register_size (gdbarch, regnum);
175-
176- gdb_assert (size == 4 || size == 8);
177- buf = alloca (size);
178-
179- regcache_raw_collect (regcache, regnum, buf);
180-
181- /* Take care with the "flags" register. It's stored as an `int' in
182- `struct save_state', even for 64-bit code. */
183- if (regnum == HPPA_FLAGS_REGNUM && size == 8)
184- {
185- ULONGEST flags;
186- flags = extract_unsigned_integer ((gdb_byte *)buf, 8, byte_order);
187- store_unsigned_integer ((gdb_byte *)buf, 4, byte_order, flags);
188- size = 4;
189- }
190-
191-#ifdef HAVE_TTRACE
192- {
193- lwpid_t lwp = ptid_get_lwp (inferior_ptid);
194-
195- if (ttrace (TT_LWP_WUREGS, pid, lwp, addr, size, (uintptr_t)buf) == -1)
196- error (_("Couldn't write register %s (#%d): %s"),
197- gdbarch_register_name (gdbarch, regnum),
198- regnum, safe_strerror (errno));
199- }
200-#else
201- {
202- int i;
203-
204- /* Write the register contents into the inferior a chunk at the time. */
205- for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
206- {
207- errno = 0;
208- ptrace (PT_WUREGS, pid, (PTRACE_TYPE_ARG3) addr, buf[i], 0);
209- if (errno != 0)
210- error (_("Couldn't write register %s (#%d): %s"),
211- gdbarch_register_name (gdbarch, regnum),
212- regnum, safe_strerror (errno));
213-
214- addr += sizeof (PTRACE_TYPE_RET);
215- }
216- }
217-#endif
218-}
219-
220-/* Store register REGNUM back into the inferior. If REGNUM is -1, do
221- this for all registers (including the floating point registers). */
222-
223-static void
224-hppa_hpux_store_inferior_registers (struct target_ops *ops,
225- struct regcache *regcache, int regnum)
226-{
227- if (regnum == -1)
228- for (regnum = 0;
229- regnum < gdbarch_num_regs (get_regcache_arch (regcache));
230- regnum++)
231- hppa_hpux_store_register (regcache, regnum);
232- else
233- hppa_hpux_store_register (regcache, regnum);
234-}
235-
236-/* Set hpux_major_release variable to the value retrieved from a call to
237- uname function. */
238-
239-static void
240-set_hpux_major_release (void)
241-{
242- struct utsname x;
243- char *p;
244-
245- uname (&x);
246- p = strchr (x.release, '.');
247- if (p)
248- hpux_major_release = atoi (p + 1);
249-}
250-
251-
252-
253-/* Prevent warning from -Wmissing-prototypes. */
254-void _initialize_hppa_hpux_nat (void);
255-
256-void
257-_initialize_hppa_hpux_nat (void)
258-{
259- struct target_ops *t;
260-
261- set_hpux_major_release ();
262-
263-#ifdef HAVE_TTRACE
264- t = inf_ttrace_target ();
265-#else
266- t = inf_ptrace_target ();
267-#endif
268-
269- t->to_fetch_registers = hppa_hpux_fetch_inferior_registers;
270- t->to_store_registers = hppa_hpux_store_inferior_registers;
271-
272- add_target (t);
273-}
--- a/gdb/hppa-hpux-tdep.c
+++ /dev/null
@@ -1,1572 +0,0 @@
1-/* Target-dependent code for HP-UX on PA-RISC.
2-
3- Copyright (C) 2002-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#include "defs.h"
21-#include "arch-utils.h"
22-#include "gdbcore.h"
23-#include "osabi.h"
24-#include "frame.h"
25-#include "frame-unwind.h"
26-#include "trad-frame.h"
27-#include "symtab.h"
28-#include "objfiles.h"
29-#include "inferior.h"
30-#include "infcall.h"
31-#include "observer.h"
32-#include "hppa-tdep.h"
33-#include "solib-som.h"
34-#include "solib-pa64.h"
35-#include "regset.h"
36-#include "regcache.h"
37-
38-#define IS_32BIT_TARGET(_gdbarch) \
39- ((gdbarch_tdep (_gdbarch))->bytes_per_address == 4)
40-
41-/* Bit in the `ss_flag' member of `struct save_state' that indicates
42- that the 64-bit register values are live. From
43- <machine/save_state.h>. */
44-#define HPPA_HPUX_SS_WIDEREGS 0x40
45-
46-/* Offsets of various parts of `struct save_state'. From
47- <machine/save_state.h>. */
48-#define HPPA_HPUX_SS_FLAGS_OFFSET 0
49-#define HPPA_HPUX_SS_NARROW_OFFSET 4
50-#define HPPA_HPUX_SS_FPBLOCK_OFFSET 256
51-#define HPPA_HPUX_SS_WIDE_OFFSET 640
52-
53-/* The size of `struct save_state. */
54-#define HPPA_HPUX_SAVE_STATE_SIZE 1152
55-
56-/* The size of `struct pa89_save_state', which corresponds to PA-RISC
57- 1.1, the lowest common denominator that we support. */
58-#define HPPA_HPUX_PA89_SAVE_STATE_SIZE 512
59-
60-
61-/* Forward declarations. */
62-extern void _initialize_hppa_hpux_tdep (void);
63-extern initialize_file_ftype _initialize_hppa_hpux_tdep;
64-
65-/* Return one if PC is in the call path of a trampoline, else return zero.
66-
67- Note we return one for *any* call trampoline (long-call, arg-reloc), not
68- just shared library trampolines (import, export). */
69-
70-static int
71-hppa32_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc)
72-{
73- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
74- struct bound_minimal_symbol minsym;
75- struct unwind_table_entry *u;
76-
77- /* First see if PC is in one of the two C-library trampolines. */
78- if (pc == hppa_symbol_address("$$dyncall")
79- || pc == hppa_symbol_address("_sr4export"))
80- return 1;
81-
82- minsym = lookup_minimal_symbol_by_pc (pc);
83- if (minsym.minsym
84- && strcmp (MSYMBOL_LINKAGE_NAME (minsym.minsym), ".stub") == 0)
85- return 1;
86-
87- /* Get the unwind descriptor corresponding to PC, return zero
88- if no unwind was found. */
89- u = find_unwind_entry (pc);
90- if (!u)
91- return 0;
92-
93- /* If this isn't a linker stub, then return now. */
94- if (u->stub_unwind.stub_type == 0)
95- return 0;
96-
97- /* By definition a long-branch stub is a call stub. */
98- if (u->stub_unwind.stub_type == LONG_BRANCH)
99- return 1;
100-
101- /* The call and return path execute the same instructions within
102- an IMPORT stub! So an IMPORT stub is both a call and return
103- trampoline. */
104- if (u->stub_unwind.stub_type == IMPORT)
105- return 1;
106-
107- /* Parameter relocation stubs always have a call path and may have a
108- return path. */
109- if (u->stub_unwind.stub_type == PARAMETER_RELOCATION
110- || u->stub_unwind.stub_type == EXPORT)
111- {
112- CORE_ADDR addr;
113-
114- /* Search forward from the current PC until we hit a branch
115- or the end of the stub. */
116- for (addr = pc; addr <= u->region_end; addr += 4)
117- {
118- unsigned long insn;
119-
120- insn = read_memory_integer (addr, 4, byte_order);
121-
122- /* Does it look like a bl? If so then it's the call path, if
123- we find a bv or be first, then we're on the return path. */
124- if ((insn & 0xfc00e000) == 0xe8000000)
125- return 1;
126- else if ((insn & 0xfc00e001) == 0xe800c000
127- || (insn & 0xfc000000) == 0xe0000000)
128- return 0;
129- }
130-
131- /* Should never happen. */
132- warning (_("Unable to find branch in parameter relocation stub."));
133- return 0;
134- }
135-
136- /* Unknown stub type. For now, just return zero. */
137- return 0;
138-}
139-
140-static int
141-hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc)
142-{
143- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
144-
145- /* PA64 has a completely different stub/trampoline scheme. Is it
146- better? Maybe. It's certainly harder to determine with any
147- certainty that we are in a stub because we can not refer to the
148- unwinders to help.
149-
150- The heuristic is simple. Try to lookup the current PC value in th
151- minimal symbol table. If that fails, then assume we are not in a
152- stub and return.
153-
154- Then see if the PC value falls within the section bounds for the
155- section containing the minimal symbol we found in the first
156- step. If it does, then assume we are not in a stub and return.
157-
158- Finally peek at the instructions to see if they look like a stub. */
159- struct bound_minimal_symbol minsym;
160- asection *sec;
161- CORE_ADDR addr;
162- int insn;
163-
164- minsym = lookup_minimal_symbol_by_pc (pc);
165- if (! minsym.minsym)
166- return 0;
167-
168- sec = MSYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym)->the_bfd_section;
169-
170- if (bfd_get_section_vma (sec->owner, sec) <= pc
171- && pc < (bfd_get_section_vma (sec->owner, sec)
172- + bfd_section_size (sec->owner, sec)))
173- return 0;
174-
175- /* We might be in a stub. Peek at the instructions. Stubs are 3
176- instructions long. */
177- insn = read_memory_integer (pc, 4, byte_order);
178-
179- /* Find out where we think we are within the stub. */
180- if ((insn & 0xffffc00e) == 0x53610000)
181- addr = pc;
182- else if ((insn & 0xffffffff) == 0xe820d000)
183- addr = pc - 4;
184- else if ((insn & 0xffffc00e) == 0x537b0000)
185- addr = pc - 8;
186- else
187- return 0;
188-
189- /* Now verify each insn in the range looks like a stub instruction. */
190- insn = read_memory_integer (addr, 4, byte_order);
191- if ((insn & 0xffffc00e) != 0x53610000)
192- return 0;
193-
194- /* Now verify each insn in the range looks like a stub instruction. */
195- insn = read_memory_integer (addr + 4, 4, byte_order);
196- if ((insn & 0xffffffff) != 0xe820d000)
197- return 0;
198-
199- /* Now verify each insn in the range looks like a stub instruction. */
200- insn = read_memory_integer (addr + 8, 4, byte_order);
201- if ((insn & 0xffffc00e) != 0x537b0000)
202- return 0;
203-
204- /* Looks like a stub. */
205- return 1;
206-}
207-
208-/* Return one if PC is in the return path of a trampoline, else return zero.
209-
210- Note we return one for *any* call trampoline (long-call, arg-reloc), not
211- just shared library trampolines (import, export). */
212-
213-static int
214-hppa_hpux_in_solib_return_trampoline (struct gdbarch *gdbarch,
215- CORE_ADDR pc, const char *name)
216-{
217- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
218- struct unwind_table_entry *u;
219-
220- /* Get the unwind descriptor corresponding to PC, return zero
221- if no unwind was found. */
222- u = find_unwind_entry (pc);
223- if (!u)
224- return 0;
225-
226- /* If this isn't a linker stub or it's just a long branch stub, then
227- return zero. */
228- if (u->stub_unwind.stub_type == 0 || u->stub_unwind.stub_type == LONG_BRANCH)
229- return 0;
230-
231- /* The call and return path execute the same instructions within
232- an IMPORT stub! So an IMPORT stub is both a call and return
233- trampoline. */
234- if (u->stub_unwind.stub_type == IMPORT)
235- return 1;
236-
237- /* Parameter relocation stubs always have a call path and may have a
238- return path. */
239- if (u->stub_unwind.stub_type == PARAMETER_RELOCATION
240- || u->stub_unwind.stub_type == EXPORT)
241- {
242- CORE_ADDR addr;
243-
244- /* Search forward from the current PC until we hit a branch
245- or the end of the stub. */
246- for (addr = pc; addr <= u->region_end; addr += 4)
247- {
248- unsigned long insn;
249-
250- insn = read_memory_integer (addr, 4, byte_order);
251-
252- /* Does it look like a bl? If so then it's the call path, if
253- we find a bv or be first, then we're on the return path. */
254- if ((insn & 0xfc00e000) == 0xe8000000)
255- return 0;
256- else if ((insn & 0xfc00e001) == 0xe800c000
257- || (insn & 0xfc000000) == 0xe0000000)
258- return 1;
259- }
260-
261- /* Should never happen. */
262- warning (_("Unable to find branch in parameter relocation stub."));
263- return 0;
264- }
265-
266- /* Unknown stub type. For now, just return zero. */
267- return 0;
268-
269-}
270-
271-/* Figure out if PC is in a trampoline, and if so find out where
272- the trampoline will jump to. If not in a trampoline, return zero.
273-
274- Simple code examination probably is not a good idea since the code
275- sequences in trampolines can also appear in user code.
276-
277- We use unwinds and information from the minimal symbol table to
278- determine when we're in a trampoline. This won't work for ELF
279- (yet) since it doesn't create stub unwind entries. Whether or
280- not ELF will create stub unwinds or normal unwinds for linker
281- stubs is still being debated.
282-
283- This should handle simple calls through dyncall or sr4export,
284- long calls, argument relocation stubs, and dyncall/sr4export
285- calling an argument relocation stub. It even handles some stubs
286- used in dynamic executables. */
287-
288-static CORE_ADDR
289-hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
290-{
291- struct gdbarch *gdbarch = get_frame_arch (frame);
292- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
293- int word_size = gdbarch_ptr_bit (gdbarch) / 8;
294- long orig_pc = pc;
295- long prev_inst, curr_inst, loc;
296- struct bound_minimal_symbol msym;
297- struct unwind_table_entry *u;
298-
299- /* Addresses passed to dyncall may *NOT* be the actual address
300- of the function. So we may have to do something special. */
301- if (pc == hppa_symbol_address("$$dyncall"))
302- {
303- pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
304-
305- /* If bit 30 (counting from the left) is on, then pc is the address of
306- the PLT entry for this function, not the address of the function
307- itself. Bit 31 has meaning too, but only for MPE. */
308- if (pc & 0x2)
309- pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size,
310- byte_order);
311- }
312- if (pc == hppa_symbol_address("$$dyncall_external"))
313- {
314- pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
315- pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size, byte_order);
316- }
317- else if (pc == hppa_symbol_address("_sr4export"))
318- pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
319-
320- /* Get the unwind descriptor corresponding to PC, return zero
321- if no unwind was found. */
322- u = find_unwind_entry (pc);
323- if (!u)
324- return 0;
325-
326- /* If this isn't a linker stub, then return now. */
327- /* elz: attention here! (FIXME) because of a compiler/linker
328- error, some stubs which should have a non zero stub_unwind.stub_type
329- have unfortunately a value of zero. So this function would return here
330- as if we were not in a trampoline. To fix this, we go look at the partial
331- symbol information, which reports this guy as a stub.
332- (FIXME): Unfortunately, we are not that lucky: it turns out that the
333- partial symbol information is also wrong sometimes. This is because
334- when it is entered (somread.c::som_symtab_read()) it can happen that
335- if the type of the symbol (from the som) is Entry, and the symbol is
336- in a shared library, then it can also be a trampoline. This would be OK,
337- except that I believe the way they decide if we are ina shared library
338- does not work. SOOOO..., even if we have a regular function w/o
339- trampolines its minimal symbol can be assigned type mst_solib_trampoline.
340- Also, if we find that the symbol is a real stub, then we fix the unwind
341- descriptor, and define the stub type to be EXPORT.
342- Hopefully this is correct most of the times. */
343- if (u->stub_unwind.stub_type == 0)
344- {
345-
346-/* elz: NOTE (FIXME!) once the problem with the unwind information is fixed
347- we can delete all the code which appears between the lines. */
348-/*--------------------------------------------------------------------------*/
349- msym = lookup_minimal_symbol_by_pc (pc);
350-
351- if (msym.minsym == NULL
352- || MSYMBOL_TYPE (msym.minsym) != mst_solib_trampoline)
353- return orig_pc == pc ? 0 : pc & ~0x3;
354-
355- else if (msym.minsym != NULL
356- && MSYMBOL_TYPE (msym.minsym) == mst_solib_trampoline)
357- {
358- struct objfile *objfile;
359- struct minimal_symbol *msymbol;
360- int function_found = 0;
361-
362- /* Go look if there is another minimal symbol with the same name as
363- this one, but with type mst_text. This would happen if the msym
364- is an actual trampoline, in which case there would be another
365- symbol with the same name corresponding to the real function. */
366-
367- ALL_MSYMBOLS (objfile, msymbol)
368- {
369- if (MSYMBOL_TYPE (msymbol) == mst_text
370- && strcmp (MSYMBOL_LINKAGE_NAME (msymbol),
371- MSYMBOL_LINKAGE_NAME (msym.minsym)) == 0)
372- {
373- function_found = 1;
374- break;
375- }
376- }
377-
378- if (function_found)
379- /* The type of msym is correct (mst_solib_trampoline), but
380- the unwind info is wrong, so set it to the correct value. */
381- u->stub_unwind.stub_type = EXPORT;
382- else
383- /* The stub type info in the unwind is correct (this is not a
384- trampoline), but the msym type information is wrong, it
385- should be mst_text. So we need to fix the msym, and also
386- get out of this function. */
387- {
388- MSYMBOL_TYPE (msym.minsym) = mst_text;
389- return orig_pc == pc ? 0 : pc & ~0x3;
390- }
391- }
392-
393-/*--------------------------------------------------------------------------*/
394- }
395-
396- /* It's a stub. Search for a branch and figure out where it goes.
397- Note we have to handle multi insn branch sequences like ldil;ble.
398- Most (all?) other branches can be determined by examining the contents
399- of certain registers and the stack. */
400-
401- loc = pc;
402- curr_inst = 0;
403- prev_inst = 0;
404- while (1)
405- {
406- /* Make sure we haven't walked outside the range of this stub. */
407- if (u != find_unwind_entry (loc))
408- {
409- warning (_("Unable to find branch in linker stub"));
410- return orig_pc == pc ? 0 : pc & ~0x3;
411- }
412-
413- prev_inst = curr_inst;
414- curr_inst = read_memory_integer (loc, 4, byte_order);
415-
416- /* Does it look like a branch external using %r1? Then it's the
417- branch from the stub to the actual function. */
418- if ((curr_inst & 0xffe0e000) == 0xe0202000)
419- {
420- /* Yup. See if the previous instruction loaded
421- a value into %r1. If so compute and return the jump address. */
422- if ((prev_inst & 0xffe00000) == 0x20200000)
423- return (hppa_extract_21 (prev_inst)
424- + hppa_extract_17 (curr_inst)) & ~0x3;
425- else
426- {
427- warning (_("Unable to find ldil X,%%r1 "
428- "before ble Y(%%sr4,%%r1)."));
429- return orig_pc == pc ? 0 : pc & ~0x3;
430- }
431- }
432-
433- /* Does it look like a be 0(sr0,%r21)? OR
434- Does it look like a be, n 0(sr0,%r21)? OR
435- Does it look like a bve (r21)? (this is on PA2.0)
436- Does it look like a bve, n(r21)? (this is also on PA2.0)
437- That's the branch from an
438- import stub to an export stub.
439-
440- It is impossible to determine the target of the branch via
441- simple examination of instructions and/or data (consider
442- that the address in the plabel may be the address of the
443- bind-on-reference routine in the dynamic loader).
444-
445- So we have try an alternative approach.
446-
447- Get the name of the symbol at our current location; it should
448- be a stub symbol with the same name as the symbol in the
449- shared library.
450-
451- Then lookup a minimal symbol with the same name; we should
452- get the minimal symbol for the target routine in the shared
453- library as those take precedence of import/export stubs. */
454- if ((curr_inst == 0xe2a00000) ||
455- (curr_inst == 0xe2a00002) ||
456- (curr_inst == 0xeaa0d000) ||
457- (curr_inst == 0xeaa0d002))
458- {
459- struct bound_minimal_symbol stubsym;
460- struct bound_minimal_symbol libsym;
461-
462- stubsym = lookup_minimal_symbol_by_pc (loc);
463- if (stubsym.minsym == NULL)
464- {
465- warning (_("Unable to find symbol for 0x%lx"), loc);
466- return orig_pc == pc ? 0 : pc & ~0x3;
467- }
468-
469- libsym = lookup_minimal_symbol (MSYMBOL_LINKAGE_NAME (stubsym.minsym),
470- NULL, NULL);
471- if (libsym.minsym == NULL)
472- {
473- warning (_("Unable to find library symbol for %s."),
474- MSYMBOL_PRINT_NAME (stubsym.minsym));
475- return orig_pc == pc ? 0 : pc & ~0x3;
476- }
477-
478- return MSYMBOL_VALUE (libsym.minsym);
479- }
480-
481- /* Does it look like bl X,%rp or bl X,%r0? Another way to do a
482- branch from the stub to the actual function. */
483- /*elz */
484- else if ((curr_inst & 0xffe0e000) == 0xe8400000
485- || (curr_inst & 0xffe0e000) == 0xe8000000
486- || (curr_inst & 0xffe0e000) == 0xe800A000)
487- return (loc + hppa_extract_17 (curr_inst) + 8) & ~0x3;
488-
489- /* Does it look like bv (rp)? Note this depends on the
490- current stack pointer being the same as the stack
491- pointer in the stub itself! This is a branch on from the
492- stub back to the original caller. */
493- /*else if ((curr_inst & 0xffe0e000) == 0xe840c000) */
494- else if ((curr_inst & 0xffe0f000) == 0xe840c000)
495- {
496- /* Yup. See if the previous instruction loaded
497- rp from sp - 8. */
498- if (prev_inst == 0x4bc23ff1)
499- {
500- CORE_ADDR sp;
501- sp = get_frame_register_unsigned (frame, HPPA_SP_REGNUM);
502- return read_memory_integer (sp - 8, 4, byte_order) & ~0x3;
503- }
504- else
505- {
506- warning (_("Unable to find restore of %%rp before bv (%%rp)."));
507- return orig_pc == pc ? 0 : pc & ~0x3;
508- }
509- }
510-
511- /* elz: added this case to capture the new instruction
512- at the end of the return part of an export stub used by
513- the PA2.0: BVE, n (rp) */
514- else if ((curr_inst & 0xffe0f000) == 0xe840d000)
515- {
516- return (read_memory_integer
517- (get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
518- word_size, byte_order)) & ~0x3;
519- }
520-
521- /* What about be,n 0(sr0,%rp)? It's just another way we return to
522- the original caller from the stub. Used in dynamic executables. */
523- else if (curr_inst == 0xe0400002)
524- {
525- /* The value we jump to is sitting in sp - 24. But that's
526- loaded several instructions before the be instruction.
527- I guess we could check for the previous instruction being
528- mtsp %r1,%sr0 if we want to do sanity checking. */
529- return (read_memory_integer
530- (get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
531- word_size, byte_order)) & ~0x3;
532- }
533-
534- /* Haven't found the branch yet, but we're still in the stub.
535- Keep looking. */
536- loc += 4;
537- }
538-}
539-
540-static void
541-hppa_skip_permanent_breakpoint (struct regcache *regcache)
542-{
543- /* To step over a breakpoint instruction on the PA takes some
544- fiddling with the instruction address queue.
545-
546- When we stop at a breakpoint, the IA queue front (the instruction
547- we're executing now) points at the breakpoint instruction, and
548- the IA queue back (the next instruction to execute) points to
549- whatever instruction we would execute after the breakpoint, if it
550- were an ordinary instruction. This is the case even if the
551- breakpoint is in the delay slot of a branch instruction.
552-
553- Clearly, to step past the breakpoint, we need to set the queue
554- front to the back. But what do we put in the back? What
555- instruction comes after that one? Because of the branch delay
556- slot, the next insn is always at the back + 4. */
557-
558- ULONGEST pcoq_tail, pcsq_tail;
559- regcache_cooked_read_unsigned (regcache, HPPA_PCOQ_TAIL_REGNUM, &pcoq_tail);
560- regcache_cooked_read_unsigned (regcache, HPPA_PCSQ_TAIL_REGNUM, &pcsq_tail);
561-
562- regcache_cooked_write_unsigned (regcache, HPPA_PCOQ_HEAD_REGNUM, pcoq_tail);
563- regcache_cooked_write_unsigned (regcache, HPPA_PCSQ_HEAD_REGNUM, pcsq_tail);
564-
565- regcache_cooked_write_unsigned (regcache,
566- HPPA_PCOQ_TAIL_REGNUM, pcoq_tail + 4);
567- /* We can leave the tail's space the same, since there's no jump. */
568-}
569-
570-
571-/* Signal frames. */
572-struct hppa_hpux_sigtramp_unwind_cache
573-{
574- CORE_ADDR base;
575- struct trad_frame_saved_reg *saved_regs;
576-};
577-
578-static int hppa_hpux_tramp_reg[] = {
579- HPPA_SAR_REGNUM,
580- HPPA_PCOQ_HEAD_REGNUM,
581- HPPA_PCSQ_HEAD_REGNUM,
582- HPPA_PCOQ_TAIL_REGNUM,
583- HPPA_PCSQ_TAIL_REGNUM,
584- HPPA_EIEM_REGNUM,
585- HPPA_IIR_REGNUM,
586- HPPA_ISR_REGNUM,
587- HPPA_IOR_REGNUM,
588- HPPA_IPSW_REGNUM,
589- -1,
590- HPPA_SR4_REGNUM,
591- HPPA_SR4_REGNUM + 1,
592- HPPA_SR4_REGNUM + 2,
593- HPPA_SR4_REGNUM + 3,
594- HPPA_SR4_REGNUM + 4,
595- HPPA_SR4_REGNUM + 5,
596- HPPA_SR4_REGNUM + 6,
597- HPPA_SR4_REGNUM + 7,
598- HPPA_RCR_REGNUM,
599- HPPA_PID0_REGNUM,
600- HPPA_PID1_REGNUM,
601- HPPA_CCR_REGNUM,
602- HPPA_PID2_REGNUM,
603- HPPA_PID3_REGNUM,
604- HPPA_TR0_REGNUM,
605- HPPA_TR0_REGNUM + 1,
606- HPPA_TR0_REGNUM + 2,
607- HPPA_CR27_REGNUM
608-};
609-
610-static struct hppa_hpux_sigtramp_unwind_cache *
611-hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
612- void **this_cache)
613-
614-{
615- struct gdbarch *gdbarch = get_frame_arch (this_frame);
616- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
617- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
618- struct hppa_hpux_sigtramp_unwind_cache *info;
619- unsigned int flag;
620- CORE_ADDR sp, scptr, off;
621- int i, incr, szoff;
622-
623- if (*this_cache)
624- return *this_cache;
625-
626- info = FRAME_OBSTACK_ZALLOC (struct hppa_hpux_sigtramp_unwind_cache);
627- *this_cache = info;
628- info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
629-
630- sp = get_frame_register_unsigned (this_frame, HPPA_SP_REGNUM);
631-
632- if (IS_32BIT_TARGET (gdbarch))
633- scptr = sp - 1352;
634- else
635- scptr = sp - 1520;
636-
637- off = scptr;
638-
639- /* See /usr/include/machine/save_state.h for the structure of the
640- save_state_t structure. */
641-
642- flag = read_memory_unsigned_integer (scptr + HPPA_HPUX_SS_FLAGS_OFFSET,
643- 4, byte_order);
644-
645- if (!(flag & HPPA_HPUX_SS_WIDEREGS))
646- {
647- /* Narrow registers. */
648- off = scptr + HPPA_HPUX_SS_NARROW_OFFSET;
649- incr = 4;
650- szoff = 0;
651- }
652- else
653- {
654- /* Wide registers. */
655- off = scptr + HPPA_HPUX_SS_WIDE_OFFSET + 8;
656- incr = 8;
657- szoff = (tdep->bytes_per_address == 4 ? 4 : 0);
658- }
659-
660- for (i = 1; i < 32; i++)
661- {
662- info->saved_regs[HPPA_R0_REGNUM + i].addr = off + szoff;
663- off += incr;
664- }
665-
666- for (i = 0; i < ARRAY_SIZE (hppa_hpux_tramp_reg); i++)
667- {
668- if (hppa_hpux_tramp_reg[i] > 0)
669- info->saved_regs[hppa_hpux_tramp_reg[i]].addr = off + szoff;
670-
671- off += incr;
672- }
673-
674- /* TODO: fp regs */
675-
676- info->base = get_frame_register_unsigned (this_frame, HPPA_SP_REGNUM);
677-
678- return info;
679-}
680-
681-static void
682-hppa_hpux_sigtramp_frame_this_id (struct frame_info *this_frame,
683- void **this_prologue_cache,
684- struct frame_id *this_id)
685-{
686- struct hppa_hpux_sigtramp_unwind_cache *info
687- = hppa_hpux_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
688-
689- *this_id = frame_id_build (info->base, get_frame_pc (this_frame));
690-}
691-
692-static struct value *
693-hppa_hpux_sigtramp_frame_prev_register (struct frame_info *this_frame,
694- void **this_prologue_cache,
695- int regnum)
696-{
697- struct hppa_hpux_sigtramp_unwind_cache *info
698- = hppa_hpux_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
699-
700- return hppa_frame_prev_register_helper (this_frame,
701- info->saved_regs, regnum);
702-}
703-
704-static int
705-hppa_hpux_sigtramp_unwind_sniffer (const struct frame_unwind *self,
706- struct frame_info *this_frame,
707- void **this_cache)
708-{
709- struct gdbarch *gdbarch = get_frame_arch (this_frame);
710- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
711- struct unwind_table_entry *u;
712- CORE_ADDR pc = get_frame_pc (this_frame);
713-
714- u = find_unwind_entry (pc);
715-
716- /* If this is an export stub, try to get the unwind descriptor for
717- the actual function itself. */
718- if (u && u->stub_unwind.stub_type == EXPORT)
719- {
720- gdb_byte buf[HPPA_INSN_SIZE];
721- unsigned long insn;
722-
723- if (!safe_frame_unwind_memory (this_frame, u->region_start,
724- buf, sizeof buf))
725- return 0;
726-
727- insn = extract_unsigned_integer (buf, sizeof buf, byte_order);
728- if ((insn & 0xffe0e000) == 0xe8400000)
729- u = find_unwind_entry(u->region_start + hppa_extract_17 (insn) + 8);
730- }
731-
732- if (u && u->HP_UX_interrupt_marker)
733- return 1;
734-
735- return 0;
736-}
737-
738-static const struct frame_unwind hppa_hpux_sigtramp_frame_unwind = {
739- SIGTRAMP_FRAME,
740- default_frame_unwind_stop_reason,
741- hppa_hpux_sigtramp_frame_this_id,
742- hppa_hpux_sigtramp_frame_prev_register,
743- NULL,
744- hppa_hpux_sigtramp_unwind_sniffer
745-};
746-
747-static CORE_ADDR
748-hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
749- struct value *function)
750-{
751- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
752- CORE_ADDR faddr;
753-
754- faddr = value_as_address (function);
755-
756- /* Is this a plabel? If so, dereference it to get the gp value. */
757- if (faddr & 2)
758- {
759- int status;
760- gdb_byte buf[4];
761-
762- faddr &= ~3;
763-
764- status = target_read_memory (faddr + 4, buf, sizeof (buf));
765- if (status == 0)
766- return extract_unsigned_integer (buf, sizeof (buf), byte_order);
767- }
768-
769- return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
770-}
771-
772-static CORE_ADDR
773-hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
774- struct value *function)
775-{
776- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
777- CORE_ADDR faddr;
778- gdb_byte buf[32];
779-
780- faddr = value_as_address (function);
781-
782- if (pc_in_section (faddr, ".opd"))
783- {
784- target_read_memory (faddr, buf, sizeof (buf));
785- return extract_unsigned_integer (&buf[24], 8, byte_order);
786- }
787- else
788- {
789- return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
790- }
791-}
792-
793-static unsigned int ldsid_pattern[] = {
794- 0x000010a0, /* ldsid (rX),rY */
795- 0x00001820, /* mtsp rY,sr0 */
796- 0xe0000000 /* be,n (sr0,rX) */
797-};
798-
799-static CORE_ADDR
800-hppa_hpux_search_pattern (struct gdbarch *gdbarch,
801- CORE_ADDR start, CORE_ADDR end,
802- unsigned int *patterns, int count)
803-{
804- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
805- int num_insns = (end - start + HPPA_INSN_SIZE) / HPPA_INSN_SIZE;
806- unsigned int *insns;
807- gdb_byte *buf;
808- int offset, i;
809-
810- buf = alloca (num_insns * HPPA_INSN_SIZE);
811- insns = alloca (num_insns * sizeof (unsigned int));
812-
813- read_memory (start, buf, num_insns * HPPA_INSN_SIZE);
814- for (i = 0; i < num_insns; i++, buf += HPPA_INSN_SIZE)
815- insns[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE, byte_order);
816-
817- for (offset = 0; offset <= num_insns - count; offset++)
818- {
819- for (i = 0; i < count; i++)
820- {
821- if ((insns[offset + i] & patterns[i]) != patterns[i])
822- break;
823- }
824- if (i == count)
825- break;
826- }
827-
828- if (offset <= num_insns - count)
829- return start + offset * HPPA_INSN_SIZE;
830- else
831- return 0;
832-}
833-
834-static CORE_ADDR
835-hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
836- int *argreg)
837-{
838- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
839- struct objfile *obj;
840- struct obj_section *sec;
841- struct hppa_objfile_private *priv;
842- struct frame_info *frame;
843- struct unwind_table_entry *u;
844- CORE_ADDR addr, rp;
845- gdb_byte buf[4];
846- unsigned int insn;
847-
848- sec = find_pc_section (pc);
849- obj = sec->objfile;
850- priv = objfile_data (obj, hppa_objfile_priv_data);
851-
852- if (!priv)
853- priv = hppa_init_objfile_priv_data (obj);
854- if (!priv)
855- error (_("Internal error creating objfile private data."));
856-
857- /* Use the cached value if we have one. */
858- if (priv->dummy_call_sequence_addr != 0)
859- {
860- *argreg = priv->dummy_call_sequence_reg;
861- return priv->dummy_call_sequence_addr;
862- }
863-
864- /* First try a heuristic; if we are in a shared library call, our return
865- pointer is likely to point at an export stub. */
866- frame = get_current_frame ();
867- rp = frame_unwind_register_unsigned (frame, 2);
868- u = find_unwind_entry (rp);
869- if (u && u->stub_unwind.stub_type == EXPORT)
870- {
871- addr = hppa_hpux_search_pattern (gdbarch,
872- u->region_start, u->region_end,
873- ldsid_pattern,
874- ARRAY_SIZE (ldsid_pattern));
875- if (addr)
876- goto found_pattern;
877- }
878-
879- /* Next thing to try is to look for an export stub. */
880- if (priv->unwind_info)
881- {
882- int i;
883-
884- for (i = 0; i < priv->unwind_info->last; i++)
885- {
886- struct unwind_table_entry *u;
887- u = &priv->unwind_info->table[i];
888- if (u->stub_unwind.stub_type == EXPORT)
889- {
890- addr = hppa_hpux_search_pattern (gdbarch,
891- u->region_start, u->region_end,
892- ldsid_pattern,
893- ARRAY_SIZE (ldsid_pattern));
894- if (addr)
895- {
896- goto found_pattern;
897- }
898- }
899- }
900- }
901-
902- /* Finally, if this is the main executable, try to locate a sequence
903- from noshlibs */
904- addr = hppa_symbol_address ("noshlibs");
905- sec = find_pc_section (addr);
906-
907- if (sec && sec->objfile == obj)
908- {
909- CORE_ADDR start, end;
910-
911- find_pc_partial_function (addr, NULL, &start, &end);
912- if (start != 0 && end != 0)
913- {
914- addr = hppa_hpux_search_pattern (gdbarch, start, end, ldsid_pattern,
915- ARRAY_SIZE (ldsid_pattern));
916- if (addr)
917- goto found_pattern;
918- }
919- }
920-
921- /* Can't find a suitable sequence. */
922- return 0;
923-
924-found_pattern:
925- target_read_memory (addr, buf, sizeof (buf));
926- insn = extract_unsigned_integer (buf, sizeof (buf), byte_order);
927- priv->dummy_call_sequence_addr = addr;
928- priv->dummy_call_sequence_reg = (insn >> 21) & 0x1f;
929-
930- *argreg = priv->dummy_call_sequence_reg;
931- return priv->dummy_call_sequence_addr;
932-}
933-
934-static CORE_ADDR
935-hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
936- int *argreg)
937-{
938- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
939- struct objfile *obj;
940- struct obj_section *sec;
941- struct hppa_objfile_private *priv;
942- CORE_ADDR addr;
943- struct minimal_symbol *msym;
944-
945- sec = find_pc_section (pc);
946- obj = sec->objfile;
947- priv = objfile_data (obj, hppa_objfile_priv_data);
948-
949- if (!priv)
950- priv = hppa_init_objfile_priv_data (obj);
951- if (!priv)
952- error (_("Internal error creating objfile private data."));
953-
954- /* Use the cached value if we have one. */
955- if (priv->dummy_call_sequence_addr != 0)
956- {
957- *argreg = priv->dummy_call_sequence_reg;
958- return priv->dummy_call_sequence_addr;
959- }
960-
961- /* FIXME: Without stub unwind information, locating a suitable sequence is
962- fairly difficult. For now, we implement a very naive and inefficient
963- scheme; try to read in blocks of code, and look for a "bve,n (rp)"
964- instruction. These are likely to occur at the end of functions, so
965- we only look at the last two instructions of each function. */
966- ALL_OBJFILE_MSYMBOLS (obj, msym)
967- {
968- CORE_ADDR begin, end;
969- const char *name;
970- gdb_byte buf[2 * HPPA_INSN_SIZE];
971- int offset;
972-
973- find_pc_partial_function (MSYMBOL_VALUE_ADDRESS (obj, msym), &name,
974- &begin, &end);
975-
976- if (name == NULL || begin == 0 || end == 0)
977- continue;
978-
979- if (target_read_memory (end - sizeof (buf), buf, sizeof (buf)) == 0)
980- {
981- for (offset = 0; offset < sizeof (buf); offset++)
982- {
983- unsigned int insn;
984-
985- insn = extract_unsigned_integer (buf + offset,
986- HPPA_INSN_SIZE, byte_order);
987- if (insn == 0xe840d002) /* bve,n (rp) */
988- {
989- addr = (end - sizeof (buf)) + offset;
990- goto found_pattern;
991- }
992- }
993- }
994- }
995-
996- /* Can't find a suitable sequence. */
997- return 0;
998-
999-found_pattern:
1000- priv->dummy_call_sequence_addr = addr;
1001- /* Right now we only look for a "bve,l (rp)" sequence, so the register is
1002- always HPPA_RP_REGNUM. */
1003- priv->dummy_call_sequence_reg = HPPA_RP_REGNUM;
1004-
1005- *argreg = priv->dummy_call_sequence_reg;
1006- return priv->dummy_call_sequence_addr;
1007-}
1008-
1009-static CORE_ADDR
1010-hppa_hpux_find_import_stub_for_addr (CORE_ADDR funcaddr)
1011-{
1012- struct objfile *objfile;
1013- struct bound_minimal_symbol funsym;
1014- struct bound_minimal_symbol stubsym;
1015- CORE_ADDR stubaddr;
1016-
1017- funsym = lookup_minimal_symbol_by_pc (funcaddr);
1018- stubaddr = 0;
1019-
1020- ALL_OBJFILES (objfile)
1021- {
1022- stubsym = lookup_minimal_symbol_solib_trampoline
1023- (MSYMBOL_LINKAGE_NAME (funsym.minsym), objfile);
1024-
1025- if (stubsym.minsym)
1026- {
1027- struct unwind_table_entry *u;
1028-
1029- u = find_unwind_entry (MSYMBOL_VALUE (stubsym.minsym));
1030- if (u == NULL
1031- || (u->stub_unwind.stub_type != IMPORT
1032- && u->stub_unwind.stub_type != IMPORT_SHLIB))
1033- continue;
1034-
1035- stubaddr = MSYMBOL_VALUE (stubsym.minsym);
1036-
1037- /* If we found an IMPORT stub, then we can stop searching;
1038- if we found an IMPORT_SHLIB, we want to continue the search
1039- in the hopes that we will find an IMPORT stub. */
1040- if (u->stub_unwind.stub_type == IMPORT)
1041- break;
1042- }
1043- }
1044-
1045- return stubaddr;
1046-}
1047-
1048-static int
1049-hppa_hpux_sr_for_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
1050-{
1051- int sr;
1052- /* The space register to use is encoded in the top 2 bits of the address. */
1053- sr = addr >> (gdbarch_tdep (gdbarch)->bytes_per_address * 8 - 2);
1054- return sr + 4;
1055-}
1056-
1057-static CORE_ADDR
1058-hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr)
1059-{
1060- /* In order for us to restore the space register to its starting state,
1061- we need the dummy trampoline to return to an instruction address in
1062- the same space as where we started the call. We used to place the
1063- breakpoint near the current pc, however, this breaks nested dummy calls
1064- as the nested call will hit the breakpoint address and terminate
1065- prematurely. Instead, we try to look for an address in the same space to
1066- put the breakpoint.
1067-
1068- This is similar in spirit to putting the breakpoint at the "entry point"
1069- of an executable. */
1070-
1071- struct obj_section *sec;
1072- struct unwind_table_entry *u;
1073- struct minimal_symbol *msym;
1074- CORE_ADDR func;
1075-
1076- sec = find_pc_section (addr);
1077- if (sec)
1078- {
1079- /* First try the lowest address in the section; we can use it as long
1080- as it is "regular" code (i.e. not a stub). */
1081- u = find_unwind_entry (obj_section_addr (sec));
1082- if (!u || u->stub_unwind.stub_type == 0)
1083- return obj_section_addr (sec);
1084-
1085- /* Otherwise, we need to find a symbol for a regular function. We
1086- do this by walking the list of msymbols in the objfile. The symbol
1087- we find should not be the same as the function that was passed in. */
1088-
1089- /* FIXME: this is broken, because we can find a function that will be
1090- called by the dummy call target function, which will still not
1091- work. */
1092-
1093- find_pc_partial_function (addr, NULL, &func, NULL);
1094- ALL_OBJFILE_MSYMBOLS (sec->objfile, msym)
1095- {
1096- u = find_unwind_entry (MSYMBOL_VALUE_ADDRESS (sec->objfile, msym));
1097- if (func != MSYMBOL_VALUE_ADDRESS (sec->objfile, msym)
1098- && (!u || u->stub_unwind.stub_type == 0))
1099- return MSYMBOL_VALUE_ADDRESS (sec->objfile, msym);
1100- }
1101- }
1102-
1103- warning (_("Cannot find suitable address to place dummy breakpoint; nested "
1104- "calls may fail."));
1105- return addr - 4;
1106-}
1107-
1108-static CORE_ADDR
1109-hppa_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
1110- CORE_ADDR funcaddr,
1111- struct value **args, int nargs,
1112- struct type *value_type,
1113- CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
1114- struct regcache *regcache)
1115-{
1116- CORE_ADDR pc, stubaddr;
1117- int argreg = 0;
1118-
1119- pc = regcache_read_pc (regcache);
1120-
1121- /* Note: we don't want to pass a function descriptor here; push_dummy_call
1122- fills in the PIC register for us. */
1123- funcaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funcaddr, NULL);
1124-
1125- /* The simple case is where we call a function in the same space that we are
1126- currently in; in that case we don't really need to do anything. */
1127- if (hppa_hpux_sr_for_addr (gdbarch, pc)
1128- == hppa_hpux_sr_for_addr (gdbarch, funcaddr))
1129- {
1130- /* Intraspace call. */
1131- *bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
1132- *real_pc = funcaddr;
1133- regcache_cooked_write_unsigned (regcache, HPPA_RP_REGNUM, *bp_addr);
1134-
1135- return sp;
1136- }
1137-
1138- /* In order to make an interspace call, we need to go through a stub.
1139- gcc supplies an appropriate stub called "__gcc_plt_call", however, if
1140- an application is compiled with HP compilers then this stub is not
1141- available. We used to fallback to "__d_plt_call", however that stub
1142- is not entirely useful for us because it doesn't do an interspace
1143- return back to the caller. Also, on hppa64-hpux, there is no
1144- __gcc_plt_call available. In order to keep the code uniform, we
1145- instead don't use either of these stubs, but instead write our own
1146- onto the stack.
1147-
1148- A problem arises since the stack is located in a different space than
1149- code, so in order to branch to a stack stub, we will need to do an
1150- interspace branch. Previous versions of gdb did this by modifying code
1151- at the current pc and doing single-stepping to set the pcsq. Since this
1152- is highly undesirable, we use a different scheme:
1153-
1154- All we really need to do the branch to the stub is a short instruction
1155- sequence like this:
1156-
1157- PA1.1:
1158- ldsid (rX),r1
1159- mtsp r1,sr0
1160- be,n (sr0,rX)
1161-
1162- PA2.0:
1163- bve,n (sr0,rX)
1164-
1165- Instead of writing these sequences ourselves, we can find it in
1166- the instruction stream that belongs to the current space. While this
1167- seems difficult at first, we are actually guaranteed to find the sequences
1168- in several places:
1169-
1170- For 32-bit code:
1171- - in export stubs for shared libraries
1172- - in the "noshlibs" routine in the main module
1173-
1174- For 64-bit code:
1175- - at the end of each "regular" function
1176-
1177- We cache the address of these sequences in the objfile's private data
1178- since these operations can potentially be quite expensive.
1179-
1180- So, what we do is:
1181- - write a stack trampoline
1182- - look for a suitable instruction sequence in the current space
1183- - point the sequence at the trampoline
1184- - set the return address of the trampoline to the current space
1185- (see hppa_hpux_find_dummy_call_bpaddr)
1186- - set the continuing address of the "dummy code" as the sequence. */
1187-
1188- if (IS_32BIT_TARGET (gdbarch))
1189- {
1190-#define INSN(I1, I2, I3, I4) 0x ## I1, 0x ## I2, 0x ## I3, 0x ## I4
1191- static const gdb_byte hppa32_tramp[] = {
1192- INSN(0f,df,12,91), /* stw r31,-8(,sp) */
1193- INSN(02,c0,10,a1), /* ldsid (,r22),r1 */
1194- INSN(00,01,18,20), /* mtsp r1,sr0 */
1195- INSN(e6,c0,00,00), /* be,l 0(sr0,r22),%sr0,%r31 */
1196- INSN(08,1f,02,42), /* copy r31,rp */
1197- INSN(0f,d1,10,82), /* ldw -8(,sp),rp */
1198- INSN(00,40,10,a1), /* ldsid (,rp),r1 */
1199- INSN(00,01,18,20), /* mtsp r1,sr0 */
1200- INSN(e0,40,00,00), /* be 0(sr0,rp) */
1201- INSN(08,00,02,40) /* nop */
1202- };
1203-
1204- /* for hppa32, we must call the function through a stub so that on
1205- return it can return to the space of our trampoline. */
1206- stubaddr = hppa_hpux_find_import_stub_for_addr (funcaddr);
1207- if (stubaddr == 0)
1208- error (_("Cannot call external function not referenced by application "
1209- "(no import stub).\n"));
1210- regcache_cooked_write_unsigned (regcache, 22, stubaddr);
1211-
1212- write_memory (sp, hppa32_tramp, sizeof (hppa32_tramp));
1213-
1214- *bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
1215- regcache_cooked_write_unsigned (regcache, 31, *bp_addr);
1216-
1217- *real_pc = hppa32_hpux_search_dummy_call_sequence (gdbarch, pc, &argreg);
1218- if (*real_pc == 0)
1219- error (_("Cannot make interspace call from here."));
1220-
1221- regcache_cooked_write_unsigned (regcache, argreg, sp);
1222-
1223- sp += sizeof (hppa32_tramp);
1224- }
1225- else
1226- {
1227- static const gdb_byte hppa64_tramp[] = {
1228- INSN(ea,c0,f0,00), /* bve,l (r22),%r2 */
1229- INSN(0f,df,12,d1), /* std r31,-8(,sp) */
1230- INSN(0f,d1,10,c2), /* ldd -8(,sp),rp */
1231- INSN(e8,40,d0,02), /* bve,n (rp) */
1232- INSN(08,00,02,40) /* nop */
1233- };
1234-#undef INSN
1235-
1236- /* for hppa64, we don't need to call through a stub; all functions
1237- return via a bve. */
1238- regcache_cooked_write_unsigned (regcache, 22, funcaddr);
1239- write_memory (sp, hppa64_tramp, sizeof (hppa64_tramp));
1240-
1241- *bp_addr = pc - 4;
1242- regcache_cooked_write_unsigned (regcache, 31, *bp_addr);
1243-
1244- *real_pc = hppa64_hpux_search_dummy_call_sequence (gdbarch, pc, &argreg);
1245- if (*real_pc == 0)
1246- error (_("Cannot make interspace call from here."));
1247-
1248- regcache_cooked_write_unsigned (regcache, argreg, sp);
1249-
1250- sp += sizeof (hppa64_tramp);
1251- }
1252-
1253- sp = gdbarch_frame_align (gdbarch, sp);
1254-
1255- return sp;
1256-}
1257-
1258-
1259-
1260-static void
1261-hppa_hpux_supply_ss_narrow (struct regcache *regcache,
1262- int regnum, const gdb_byte *save_state)
1263-{
1264- const gdb_byte *ss_narrow = save_state + HPPA_HPUX_SS_NARROW_OFFSET;
1265- int i, offset = 0;
1266-
1267- for (i = HPPA_R1_REGNUM; i < HPPA_FP0_REGNUM; i++)
1268- {
1269- if (regnum == i || regnum == -1)
1270- regcache_raw_supply (regcache, i, ss_narrow + offset);
1271-
1272- offset += 4;
1273- }
1274-}
1275-
1276-static void
1277-hppa_hpux_supply_ss_fpblock (struct regcache *regcache,
1278- int regnum, const gdb_byte *save_state)
1279-{
1280- const gdb_byte *ss_fpblock = save_state + HPPA_HPUX_SS_FPBLOCK_OFFSET;
1281- int i, offset = 0;
1282-
1283- /* FIXME: We view the floating-point state as 64 single-precision
1284- registers for 32-bit code, and 32 double-precision register for
1285- 64-bit code. This distinction is artificial and should be
1286- eliminated. If that ever happens, we should remove the if-clause
1287- below. */
1288-
1289- if (register_size (get_regcache_arch (regcache), HPPA_FP0_REGNUM) == 4)
1290- {
1291- for (i = HPPA_FP0_REGNUM; i < HPPA_FP0_REGNUM + 64; i++)
1292- {
1293- if (regnum == i || regnum == -1)
1294- regcache_raw_supply (regcache, i, ss_fpblock + offset);
1295-
1296- offset += 4;
1297- }
1298- }
1299- else
1300- {
1301- for (i = HPPA_FP0_REGNUM; i < HPPA_FP0_REGNUM + 32; i++)
1302- {
1303- if (regnum == i || regnum == -1)
1304- regcache_raw_supply (regcache, i, ss_fpblock + offset);
1305-
1306- offset += 8;
1307- }
1308- }
1309-}
1310-
1311-static void
1312-hppa_hpux_supply_ss_wide (struct regcache *regcache,
1313- int regnum, const gdb_byte *save_state)
1314-{
1315- const gdb_byte *ss_wide = save_state + HPPA_HPUX_SS_WIDE_OFFSET;
1316- int i, offset = 8;
1317-
1318- if (register_size (get_regcache_arch (regcache), HPPA_R1_REGNUM) == 4)
1319- offset += 4;
1320-
1321- for (i = HPPA_R1_REGNUM; i < HPPA_FP0_REGNUM; i++)
1322- {
1323- if (regnum == i || regnum == -1)
1324- regcache_raw_supply (regcache, i, ss_wide + offset);
1325-
1326- offset += 8;
1327- }
1328-}
1329-
1330-static void
1331-hppa_hpux_supply_save_state (const struct regset *regset,
1332- struct regcache *regcache,
1333- int regnum, const void *regs, size_t len)
1334-{
1335- struct gdbarch *gdbarch = get_regcache_arch (regcache);
1336- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1337- const gdb_byte *proc_info = regs;
1338- const gdb_byte *save_state = proc_info + 8;
1339- ULONGEST flags;
1340-
1341- flags = extract_unsigned_integer (save_state + HPPA_HPUX_SS_FLAGS_OFFSET,
1342- 4, byte_order);
1343- if (regnum == -1 || regnum == HPPA_FLAGS_REGNUM)
1344- {
1345- size_t size = register_size (gdbarch, HPPA_FLAGS_REGNUM);
1346- gdb_byte buf[8];
1347-
1348- store_unsigned_integer (buf, size, byte_order, flags);
1349- regcache_raw_supply (regcache, HPPA_FLAGS_REGNUM, buf);
1350- }
1351-
1352- /* If the SS_WIDEREGS flag is set, we really do need the full
1353- `struct save_state'. */
1354- if (flags & HPPA_HPUX_SS_WIDEREGS && len < HPPA_HPUX_SAVE_STATE_SIZE)
1355- error (_("Register set contents too small"));
1356-
1357- if (flags & HPPA_HPUX_SS_WIDEREGS)
1358- hppa_hpux_supply_ss_wide (regcache, regnum, save_state);
1359- else
1360- hppa_hpux_supply_ss_narrow (regcache, regnum, save_state);
1361-
1362- hppa_hpux_supply_ss_fpblock (regcache, regnum, save_state);
1363-}
1364-
1365-/* HP-UX register set. */
1366-
1367-static const struct regset hppa_hpux_regset =
1368-{
1369- NULL,
1370- hppa_hpux_supply_save_state,
1371- NULL,
1372- REGSET_VARIABLE_SIZE
1373-};
1374-
1375-static void
1376-hppa_hpux_iterate_over_regset_sections (struct gdbarch *gdbarch,
1377- iterate_over_regset_sections_cb *cb,
1378- void *cb_data,
1379- const struct regcache *regcache)
1380-{
1381- cb (".reg", HPPA_HPUX_PA89_SAVE_STATE_SIZE + 8, &hppa_hpux_regset,
1382- NULL, cb_data);
1383-}
1384-
1385-
1386-/* Bit in the `ss_flag' member of `struct save_state' that indicates
1387- the state was saved from a system call. From
1388- <machine/save_state.h>. */
1389-#define HPPA_HPUX_SS_INSYSCALL 0x02
1390-
1391-static CORE_ADDR
1392-hppa_hpux_read_pc (struct regcache *regcache)
1393-{
1394- ULONGEST flags;
1395-
1396- /* If we're currently in a system call return the contents of %r31. */
1397- regcache_cooked_read_unsigned (regcache, HPPA_FLAGS_REGNUM, &flags);
1398- if (flags & HPPA_HPUX_SS_INSYSCALL)
1399- {
1400- ULONGEST pc;
1401- regcache_cooked_read_unsigned (regcache, HPPA_R31_REGNUM, &pc);
1402- return pc & ~0x3;
1403- }
1404-
1405- return hppa_read_pc (regcache);
1406-}
1407-
1408-static void
1409-hppa_hpux_write_pc (struct regcache *regcache, CORE_ADDR pc)
1410-{
1411- ULONGEST flags;
1412-
1413- /* If we're currently in a system call also write PC into %r31. */
1414- regcache_cooked_read_unsigned (regcache, HPPA_FLAGS_REGNUM, &flags);
1415- if (flags & HPPA_HPUX_SS_INSYSCALL)
1416- regcache_cooked_write_unsigned (regcache, HPPA_R31_REGNUM, pc | 0x3);
1417-
1418- hppa_write_pc (regcache, pc);
1419-}
1420-
1421-static CORE_ADDR
1422-hppa_hpux_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
1423-{
1424- ULONGEST flags;
1425-
1426- /* If we're currently in a system call return the contents of %r31. */
1427- flags = frame_unwind_register_unsigned (next_frame, HPPA_FLAGS_REGNUM);
1428- if (flags & HPPA_HPUX_SS_INSYSCALL)
1429- return frame_unwind_register_unsigned (next_frame, HPPA_R31_REGNUM) & ~0x3;
1430-
1431- return hppa_unwind_pc (gdbarch, next_frame);
1432-}
1433-
1434-
1435-/* Given the current value of the pc, check to see if it is inside a stub, and
1436- if so, change the value of the pc to point to the caller of the stub.
1437- THIS_FRAME is the current frame in the current list of frames.
1438- BASE contains to stack frame base of the current frame.
1439- SAVE_REGS is the register file stored in the frame cache. */
1440-static void
1441-hppa_hpux_unwind_adjust_stub (struct frame_info *this_frame, CORE_ADDR base,
1442- struct trad_frame_saved_reg *saved_regs)
1443-{
1444- struct gdbarch *gdbarch = get_frame_arch (this_frame);
1445- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1446- int word_size = gdbarch_ptr_bit (gdbarch) / 8;
1447- struct value *pcoq_head_val;
1448- ULONGEST pcoq_head;
1449- CORE_ADDR stubpc;
1450- struct unwind_table_entry *u;
1451-
1452- pcoq_head_val = trad_frame_get_prev_register (this_frame, saved_regs,
1453- HPPA_PCOQ_HEAD_REGNUM);
1454- pcoq_head =
1455- extract_unsigned_integer (value_contents_all (pcoq_head_val),
1456- register_size (gdbarch, HPPA_PCOQ_HEAD_REGNUM),
1457- byte_order);
1458-
1459- u = find_unwind_entry (pcoq_head);
1460- if (u && u->stub_unwind.stub_type == EXPORT)
1461- {
1462- stubpc = read_memory_integer (base - 24, word_size, byte_order);
1463- trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
1464- }
1465- else if (hppa_symbol_address ("__gcc_plt_call")
1466- == get_pc_function_start (pcoq_head))
1467- {
1468- stubpc = read_memory_integer (base - 8, word_size, byte_order);
1469- trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
1470- }
1471-}
1472-
1473-static void
1474-hppa_hpux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1475-{
1476- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1477-
1478- if (IS_32BIT_TARGET (gdbarch))
1479- tdep->in_solib_call_trampoline = hppa32_hpux_in_solib_call_trampoline;
1480- else
1481- tdep->in_solib_call_trampoline = hppa64_hpux_in_solib_call_trampoline;
1482-
1483- tdep->unwind_adjust_stub = hppa_hpux_unwind_adjust_stub;
1484-
1485- set_gdbarch_in_solib_return_trampoline
1486- (gdbarch, hppa_hpux_in_solib_return_trampoline);
1487- set_gdbarch_skip_trampoline_code (gdbarch, hppa_hpux_skip_trampoline_code);
1488-
1489- set_gdbarch_push_dummy_code (gdbarch, hppa_hpux_push_dummy_code);
1490- set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
1491-
1492- set_gdbarch_read_pc (gdbarch, hppa_hpux_read_pc);
1493- set_gdbarch_write_pc (gdbarch, hppa_hpux_write_pc);
1494- set_gdbarch_unwind_pc (gdbarch, hppa_hpux_unwind_pc);
1495- set_gdbarch_skip_permanent_breakpoint
1496- (gdbarch, hppa_skip_permanent_breakpoint);
1497-
1498- set_gdbarch_iterate_over_regset_sections
1499- (gdbarch, hppa_hpux_iterate_over_regset_sections);
1500-
1501- frame_unwind_append_unwinder (gdbarch, &hppa_hpux_sigtramp_frame_unwind);
1502-}
1503-
1504-static void
1505-hppa_hpux_som_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1506-{
1507- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1508-
1509- tdep->is_elf = 0;
1510-
1511- tdep->find_global_pointer = hppa32_hpux_find_global_pointer;
1512-
1513- hppa_hpux_init_abi (info, gdbarch);
1514- som_solib_select (gdbarch);
1515-}
1516-
1517-static void
1518-hppa_hpux_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1519-{
1520- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1521-
1522- tdep->is_elf = 1;
1523- tdep->find_global_pointer = hppa64_hpux_find_global_pointer;
1524-
1525- hppa_hpux_init_abi (info, gdbarch);
1526- pa64_solib_select (gdbarch);
1527-}
1528-
1529-static enum gdb_osabi
1530-hppa_hpux_core_osabi_sniffer (bfd *abfd)
1531-{
1532- if (strcmp (bfd_get_target (abfd), "hpux-core") == 0)
1533- return GDB_OSABI_HPUX_SOM;
1534- else if (strcmp (bfd_get_target (abfd), "elf64-hppa") == 0)
1535- {
1536- asection *section;
1537-
1538- section = bfd_get_section_by_name (abfd, ".kernel");
1539- if (section)
1540- {
1541- bfd_size_type size;
1542- char *contents;
1543-
1544- size = bfd_section_size (abfd, section);
1545- contents = alloca (size);
1546- if (bfd_get_section_contents (abfd, section, contents,
1547- (file_ptr) 0, size)
1548- && strcmp (contents, "HP-UX") == 0)
1549- return GDB_OSABI_HPUX_ELF;
1550- }
1551- }
1552-
1553- return GDB_OSABI_UNKNOWN;
1554-}
1555-
1556-void
1557-_initialize_hppa_hpux_tdep (void)
1558-{
1559- /* BFD doesn't set a flavour for HP-UX style core files. It doesn't
1560- set the architecture either. */
1561- gdbarch_register_osabi_sniffer (bfd_arch_unknown,
1562- bfd_target_unknown_flavour,
1563- hppa_hpux_core_osabi_sniffer);
1564- gdbarch_register_osabi_sniffer (bfd_arch_hppa,
1565- bfd_target_elf_flavour,
1566- hppa_hpux_core_osabi_sniffer);
1567-
1568- gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_SOM,
1569- hppa_hpux_som_init_abi);
1570- gdbarch_register_osabi (bfd_arch_hppa, bfd_mach_hppa20w, GDB_OSABI_HPUX_ELF,
1571- hppa_hpux_elf_init_abi);
1572-}
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -46,13 +46,44 @@ static int hppa_debug = 0;
4646 static const int hppa32_num_regs = 128;
4747 static const int hppa64_num_regs = 96;
4848
49+/* We use the objfile->obj_private pointer for two things:
50+ * 1. An unwind table;
51+ *
52+ * 2. A pointer to any associated shared library object.
53+ *
54+ * #defines are used to help refer to these objects.
55+ */
56+
57+/* Info about the unwind table associated with an object file.
58+ * This is hung off of the "objfile->obj_private" pointer, and
59+ * is allocated in the objfile's psymbol obstack. This allows
60+ * us to have unique unwind info for each executable and shared
61+ * library that we are debugging.
62+ */
63+struct hppa_unwind_info
64+ {
65+ struct unwind_table_entry *table; /* Pointer to unwind info */
66+ struct unwind_table_entry *cache; /* Pointer to last entry we found */
67+ int last; /* Index of last entry */
68+ };
69+
70+struct hppa_objfile_private
71+ {
72+ struct hppa_unwind_info *unwind_info; /* a pointer */
73+ struct so_list *so_info; /* a pointer */
74+ CORE_ADDR dp;
75+
76+ int dummy_call_sequence_reg;
77+ CORE_ADDR dummy_call_sequence_addr;
78+ };
79+
4980 /* hppa-specific object data -- unwind and solib info.
5081 TODO/maybe: think about splitting this into two parts; the unwind data is
5182 common to all hppa targets, but is only used in this file; we can register
5283 that separately and make this static. The solib data is probably hpux-
5384 specific, so we can create a separate extern objfile_data that is registered
5485 by hppa-hpux-tdep.c and shared with pa64solib.c and somsolib.c. */
55-const struct objfile_data *hppa_objfile_priv_data = NULL;
86+static const struct objfile_data *hppa_objfile_priv_data = NULL;
5687
5788 /* Get at various relevent fields of an instruction word. */
5889 #define MASK_5 0x1f
@@ -170,7 +201,7 @@ hppa_symbol_address(const char *sym)
170201 return (CORE_ADDR)-1;
171202 }
172203
173-struct hppa_objfile_private *
204+static struct hppa_objfile_private *
174205 hppa_init_objfile_priv_data (struct objfile *objfile)
175206 {
176207 struct hppa_objfile_private *priv;
@@ -2778,14 +2809,6 @@ hppa_frame_prev_register_helper (struct frame_info *this_frame,
27782809 return frame_unwind_got_constant (this_frame, regnum, pc + 4);
27792810 }
27802811
2781- /* Make sure the "flags" register is zero in all unwound frames.
2782- The "flags" registers is a HP-UX specific wart, and only the code
2783- in hppa-hpux-tdep.c depends on it. However, it is easier to deal
2784- with it here. This shouldn't affect other systems since those
2785- should provide zero for the "flags" register anyway. */
2786- if (regnum == HPPA_FLAGS_REGNUM)
2787- return frame_unwind_got_constant (this_frame, regnum, 0);
2788-
27892812 return trad_frame_get_prev_register (this_frame, saved_regs, regnum);
27902813 }
27912814
--- a/gdb/hppa-tdep.h
+++ b/gdb/hppa-tdep.h
@@ -188,39 +188,6 @@ enum unwind_stub_types
188188
189189 struct unwind_table_entry *find_unwind_entry (CORE_ADDR);
190190
191-/* We use the objfile->obj_private pointer for two things:
192- * 1. An unwind table;
193- *
194- * 2. A pointer to any associated shared library object.
195- *
196- * #defines are used to help refer to these objects.
197- */
198-
199-/* Info about the unwind table associated with an object file.
200- * This is hung off of the "objfile->obj_private" pointer, and
201- * is allocated in the objfile's psymbol obstack. This allows
202- * us to have unique unwind info for each executable and shared
203- * library that we are debugging.
204- */
205-struct hppa_unwind_info
206- {
207- struct unwind_table_entry *table; /* Pointer to unwind info */
208- struct unwind_table_entry *cache; /* Pointer to last entry we found */
209- int last; /* Index of last entry */
210- };
211-
212-struct hppa_objfile_private
213- {
214- struct hppa_unwind_info *unwind_info; /* a pointer */
215- struct so_list *so_info; /* a pointer */
216- CORE_ADDR dp;
217-
218- int dummy_call_sequence_reg;
219- CORE_ADDR dummy_call_sequence_addr;
220- };
221-
222-extern const struct objfile_data *hppa_objfile_priv_data;
223-
224191 int hppa_get_field (unsigned word, int from, int to);
225192 int hppa_extract_5_load (unsigned int);
226193 unsigned hppa_extract_5R_store (unsigned int);
@@ -244,8 +211,6 @@ extern struct bound_minimal_symbol
244211 hppa_lookup_stub_minimal_symbol (const char *name,
245212 enum unwind_stub_types stub_type);
246213
247-extern struct hppa_objfile_private *hppa_init_objfile_priv_data (struct objfile *objfile);
248-
249214 extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
250215 CORE_ADDR pc);
251216 extern CORE_ADDR hppa_skip_trampoline_code (struct frame_info *, CORE_ADDR pc);
--- a/gdb/ia64-hpux-nat.c
+++ /dev/null
@@ -1,756 +0,0 @@
1-/* Copyright (C) 2010-2015 Free Software Foundation, Inc.
2-
3- This file is part of GDB.
4-
5- This program is free software; you can redistribute it and/or modify
6- it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 3 of the License, or
8- (at your option) any later version.
9-
10- This program is distributed in the hope that it will be useful,
11- but WITHOUT ANY WARRANTY; without even the implied warranty of
12- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13- GNU General Public License for more details.
14-
15- You should have received a copy of the GNU General Public License
16- along with this program. If not, see <http://www.gnu.org/licenses/>. */
17-
18-#include "defs.h"
19-#include "ia64-tdep.h"
20-#include "inferior.h"
21-#include "inf-ttrace.h"
22-#include "regcache.h"
23-#include "solib-ia64-hpux.h"
24-
25-#include <ia64/sys/uregs.h>
26-#include <sys/ttrace.h>
27-
28-/* The offsets used with ttrace to read the value of the raw registers. */
29-
30-static int u_offsets[] =
31-{ /* Static General Registers. */
32- -1, __r1, __r2, __r3, __r4, __r5, __r6, __r7,
33- __r8, __r9, __r10, __r11, __r12, __r13, __r14, __r15,
34- __r16, __r17, __r18, __r19, __r20, __r21, __r22, __r23,
35- __r24, __r25, __r26, __r27, __r28, __r29, __r30, __r31,
36- -1, -1, -1, -1, -1, -1, -1, -1,
37- -1, -1, -1, -1, -1, -1, -1, -1,
38- -1, -1, -1, -1, -1, -1, -1, -1,
39- -1, -1, -1, -1, -1, -1, -1, -1,
40- -1, -1, -1, -1, -1, -1, -1, -1,
41- -1, -1, -1, -1, -1, -1, -1, -1,
42- -1, -1, -1, -1, -1, -1, -1, -1,
43- -1, -1, -1, -1, -1, -1, -1, -1,
44- -1, -1, -1, -1, -1, -1, -1, -1,
45- -1, -1, -1, -1, -1, -1, -1, -1,
46- -1, -1, -1, -1, -1, -1, -1, -1,
47- -1, -1, -1, -1, -1, -1, -1, -1,
48-
49- /* Static Floating-Point Registers. */
50- -1, -1, __f2, __f3, __f4, __f5, __f6, __f7,
51- __f8, __f9, __f10, __f11, __f12, __f13, __f14, __f15,
52- __f16, __f17, __f18, __f19, __f20, __f21, __f22, __f23,
53- __f24, __f25, __f26, __f27, __f28, __f29, __f30, __f31,
54- __f32, __f33, __f34, __f35, __f36, __f37, __f38, __f39,
55- __f40, __f41, __f42, __f43, __f44, __f45, __f46, __f47,
56- __f48, __f49, __f50, __f51, __f52, __f53, __f54, __f55,
57- __f56, __f57, __f58, __f59, __f60, __f61, __f62, __f63,
58- __f64, __f65, __f66, __f67, __f68, __f69, __f70, __f71,
59- __f72, __f73, __f74, __f75, __f76, __f77, __f78, __f79,
60- __f80, __f81, __f82, __f83, __f84, __f85, __f86, __f87,
61- __f88, __f89, __f90, __f91, __f92, __f93, __f94, __f95,
62- __f96, __f97, __f98, __f99, __f100, __f101, __f102, __f103,
63- __f104, __f105, __f106, __f107, __f108, __f109, __f110, __f111,
64- __f112, __f113, __f114, __f115, __f116, __f117, __f118, __f119,
65- __f120, __f121, __f122, __f123, __f124, __f125, __f126, __f127,
66-
67- -1, -1, -1, -1, -1, -1, -1, -1,
68- -1, -1, -1, -1, -1, -1, -1, -1,
69- -1, -1, -1, -1, -1, -1, -1, -1,
70- -1, -1, -1, -1, -1, -1, -1, -1,
71- -1, -1, -1, -1, -1, -1, -1, -1,
72- -1, -1, -1, -1, -1, -1, -1, -1,
73- -1, -1, -1, -1, -1, -1, -1, -1,
74- -1, -1, -1, -1, -1, -1, -1, -1,
75-
76- /* Branch Registers. */
77- __b0, __b1, __b2, __b3, __b4, __b5, __b6, __b7,
78-
79- /* Virtual frame pointer and virtual return address pointer. */
80- -1, -1,
81-
82- /* Other registers. */
83- __pr, __ip, __cr_ipsr, __cfm,
84-
85- /* Kernel registers. */
86- -1, -1, -1, -1,
87- -1, -1, -1, -1,
88-
89- -1, -1, -1, -1, -1, -1, -1, -1,
90-
91- /* Some application registers. */
92- __ar_rsc, __ar_bsp, __ar_bspstore, __ar_rnat,
93-
94- -1,
95- -1, /* Not available: FCR, IA32 floating control register. */
96- -1, -1,
97-
98- -1, /* Not available: EFLAG. */
99- -1, /* Not available: CSD. */
100- -1, /* Not available: SSD. */
101- -1, /* Not available: CFLG. */
102- -1, /* Not available: FSR. */
103- -1, /* Not available: FIR. */
104- -1, /* Not available: FDR. */
105- -1,
106- __ar_ccv, -1, -1, -1, __ar_unat, -1, -1, -1,
107- __ar_fpsr, -1, -1, -1,
108- -1, /* Not available: ITC. */
109- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
110- -1, -1, -1, -1, -1, -1, -1, -1, -1,
111- __ar_pfs, __ar_lc, __ar_ec,
112- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
113- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
114- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
115- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
116- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
117- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
118- -1
119- /* All following registers, starting with nat0, are handled as
120- pseudo registers, and hence are handled separately. */
121-};
122-
123-/* Some register have a fixed value and can not be modified.
124- Store their value in static constant buffers that can be used
125- later to fill the register cache. */
126-static const char r0_value[8] = {0x00, 0x00, 0x00, 0x00,
127- 0x00, 0x00, 0x00, 0x00};
128-static const char f0_value[16] = {0x00, 0x00, 0x00, 0x00,
129- 0x00, 0x00, 0x00, 0x00,
130- 0x00, 0x00, 0x00, 0x00,
131- 0x00, 0x00, 0x00, 0x00};
132-static const char f1_value[16] = {0x00, 0x00, 0x00, 0x00,
133- 0x00, 0x00, 0xff, 0xff,
134- 0x80, 0x00, 0x00, 0x00,
135- 0x00, 0x00, 0x00, 0x00};
136-
137-/* The "to_wait" routine from the "inf-ttrace" layer. */
138-
139-static ptid_t (*super_to_wait) (struct target_ops *, ptid_t,
140- struct target_waitstatus *, int);
141-
142-/* The "to_wait" target_ops routine routine for ia64-hpux. */
143-
144-static ptid_t
145-ia64_hpux_wait (struct target_ops *ops, ptid_t ptid,
146- struct target_waitstatus *ourstatus, int options)
147-{
148- ptid_t new_ptid;
149-
150- new_ptid = super_to_wait (ops, ptid, ourstatus, options);
151-
152- /* If this is a DLD event (hard-coded breakpoint instruction
153- that was activated by the solib-ia64-hpux module), we need to
154- process it, and then resume the execution as if the event did
155- not happen. */
156- if (ourstatus->kind == TARGET_WAITKIND_STOPPED
157- && ourstatus->value.sig == GDB_SIGNAL_TRAP
158- && ia64_hpux_at_dld_breakpoint_p (new_ptid))
159- {
160- ia64_hpux_handle_dld_breakpoint (new_ptid);
161-
162- target_resume (new_ptid, 0, GDB_SIGNAL_0);
163- ourstatus->kind = TARGET_WAITKIND_IGNORE;
164- }
165-
166- return new_ptid;
167-}
168-
169-/* Fetch the RNAT register and supply it to the REGCACHE. */
170-
171-static void
172-ia64_hpux_fetch_rnat_register (struct regcache *regcache)
173-{
174- CORE_ADDR addr;
175- gdb_byte buf[8];
176- int status;
177-
178- /* The value of RNAT is stored at bsp|0x1f8, and must be read using
179- TT_LWP_RDRSEBS. */
180-
181- regcache_raw_read_unsigned (regcache, IA64_BSP_REGNUM, &addr);
182- addr |= 0x1f8;
183-
184- status = ttrace (TT_LWP_RDRSEBS, ptid_get_pid (inferior_ptid),
185- ptid_get_lwp (inferior_ptid), addr, sizeof (buf),
186- (uintptr_t) buf);
187- if (status < 0)
188- error (_("failed to read RNAT register at %s"),
189- paddress (get_regcache_arch(regcache), addr));
190-
191- regcache_raw_supply (regcache, IA64_RNAT_REGNUM, buf);
192-}
193-
194-/* Read the value of the register saved at OFFSET in the save_state_t
195- structure, and store its value in BUF. LEN is the size of the register
196- to be read. */
197-
198-static int
199-ia64_hpux_read_register_from_save_state_t (int offset, gdb_byte *buf, int len)
200-{
201- int status;
202-
203- status = ttrace (TT_LWP_RUREGS, ptid_get_pid (inferior_ptid),
204- ptid_get_lwp (inferior_ptid), offset, len, (uintptr_t) buf);
205-
206- return status;
207-}
208-
209-/* Fetch register REGNUM from the inferior. */
210-
211-static void
212-ia64_hpux_fetch_register (struct regcache *regcache, int regnum)
213-{
214- struct gdbarch *gdbarch = get_regcache_arch (regcache);
215- int offset, len, status;
216- gdb_byte *buf;
217-
218- if (regnum == IA64_GR0_REGNUM)
219- {
220- /* r0 is always 0. */
221- regcache_raw_supply (regcache, regnum, r0_value);
222- return;
223- }
224-
225- if (regnum == IA64_FR0_REGNUM)
226- {
227- /* f0 is always 0.0. */
228- regcache_raw_supply (regcache, regnum, f0_value);
229- return;
230- }
231-
232- if (regnum == IA64_FR1_REGNUM)
233- {
234- /* f1 is always 1.0. */
235- regcache_raw_supply (regcache, regnum, f1_value);
236- return;
237- }
238-
239- if (regnum == IA64_RNAT_REGNUM)
240- {
241- ia64_hpux_fetch_rnat_register (regcache);
242- return;
243- }
244-
245- /* Get the register location. If the register can not be fetched,
246- then return now. */
247- offset = u_offsets[regnum];
248- if (offset == -1)
249- return;
250-
251- len = register_size (gdbarch, regnum);
252- buf = alloca (len * sizeof (gdb_byte));
253- status = ia64_hpux_read_register_from_save_state_t (offset, buf, len);
254- if (status < 0)
255- warning (_("Failed to read register value for %s."),
256- gdbarch_register_name (gdbarch, regnum));
257-
258- regcache_raw_supply (regcache, regnum, buf);
259-}
260-
261-/* The "to_fetch_registers" target_ops routine for ia64-hpux. */
262-
263-static void
264-ia64_hpux_fetch_registers (struct target_ops *ops,
265- struct regcache *regcache, int regnum)
266-{
267- if (regnum == -1)
268- for (regnum = 0;
269- regnum < gdbarch_num_regs (get_regcache_arch (regcache));
270- regnum++)
271- ia64_hpux_fetch_register (regcache, regnum);
272- else
273- ia64_hpux_fetch_register (regcache, regnum);
274-}
275-
276-/* Save register REGNUM (stored in BUF) in the save_state_t structure.
277- LEN is the size of the register in bytes.
278-
279- Return the value from the corresponding ttrace call (a negative value
280- means that the operation failed). */
281-
282-static int
283-ia64_hpux_write_register_to_saved_state_t (int offset, gdb_byte *buf, int len)
284-{
285- return ttrace (TT_LWP_WUREGS, ptid_get_pid (inferior_ptid),
286- ptid_get_lwp (inferior_ptid), offset, len, (uintptr_t) buf);
287-}
288-
289-/* Store register REGNUM into the inferior. */
290-
291-static void
292-ia64_hpux_store_register (const struct regcache *regcache, int regnum)
293-{
294- struct gdbarch *gdbarch = get_regcache_arch (regcache);
295- int offset = u_offsets[regnum];
296- gdb_byte *buf;
297- int len, status;
298-
299- /* If the register can not be stored, then return now. */
300- if (offset == -1)
301- return;
302-
303- /* I don't know how to store that register for now. So just ignore any
304- request to store it, to avoid an internal error. */
305- if (regnum == IA64_PSR_REGNUM)
306- return;
307-
308- len = register_size (gdbarch, regnum);
309- buf = alloca (len * sizeof (gdb_byte));
310- regcache_raw_collect (regcache, regnum, buf);
311-
312- status = ia64_hpux_write_register_to_saved_state_t (offset, buf, len);
313-
314- if (status < 0)
315- error (_("failed to write register value for %s."),
316- gdbarch_register_name (gdbarch, regnum));
317-}
318-
319-/* The "to_store_registers" target_ops routine for ia64-hpux. */
320-
321-static void
322-ia64_hpux_store_registers (struct target_ops *ops,
323- struct regcache *regcache, int regnum)
324-{
325- if (regnum == -1)
326- for (regnum = 0;
327- regnum < gdbarch_num_regs (get_regcache_arch (regcache));
328- regnum++)
329- ia64_hpux_store_register (regcache, regnum);
330- else
331- ia64_hpux_store_register (regcache, regnum);
332-}
333-
334-/* The "xfer_partial" routine from the "inf-ttrace" target layer.
335- Ideally, we would like to use this routine for all transfer
336- requests, but this platforms has a lot of special cases that
337- need to be handled manually. So we override this routine and
338- delegate back if we detect that we are not in a special case. */
339-
340-static target_xfer_partial_ftype *super_xfer_partial;
341-
342-/* The "xfer_partial" routine for a memory region that is completely
343- outside of the backing-store region. */
344-
345-static enum target_xfer_status
346-ia64_hpux_xfer_memory_no_bs (struct target_ops *ops, const char *annex,
347- gdb_byte *readbuf, const gdb_byte *writebuf,
348- CORE_ADDR addr, LONGEST len,
349- ULONGEST *xfered_len)
350-{
351- /* Memory writes need to be aligned on 16byte boundaries, at least
352- when writing in the text section. On the other hand, the size
353- of the buffer does not need to be a multiple of 16bytes.
354-
355- No such restriction when performing memory reads. */
356-
357- if (writebuf && addr & 0x0f)
358- {
359- const CORE_ADDR aligned_addr = addr & ~0x0f;
360- const int aligned_len = len + (addr - aligned_addr);
361- gdb_byte *aligned_buf = alloca (aligned_len * sizeof (gdb_byte));
362- LONGEST status;
363-
364- /* Read the portion of memory between ALIGNED_ADDR and ADDR, so
365- that we can write it back during our aligned memory write. */
366- status = super_xfer_partial (ops, TARGET_OBJECT_MEMORY, annex,
367- aligned_buf /* read */,
368- NULL /* write */,
369- aligned_addr, addr - aligned_addr);
370- if (status <= 0)
371- return TARGET_XFER_EOF;
372- memcpy (aligned_buf + (addr - aligned_addr), writebuf, len);
373-
374- return super_xfer_partial (ops, TARGET_OBJECT_MEMORY, annex,
375- NULL /* read */, aligned_buf /* write */,
376- aligned_addr, aligned_len, xfered_len);
377- }
378- else
379- /* Memory read or properly aligned memory write. */
380- return super_xfer_partial (ops, TARGET_OBJECT_MEMORY, annex, readbuf,
381- writebuf, addr, len, xfered_len);
382-}
383-
384-/* Read LEN bytes at ADDR from memory, and store it in BUF. This memory
385- region is assumed to be inside the backing store.
386-
387- Return zero if the operation failed. */
388-
389-static int
390-ia64_hpux_read_memory_bs (gdb_byte *buf, CORE_ADDR addr, int len)
391-{
392- gdb_byte tmp_buf[8];
393- CORE_ADDR tmp_addr = addr & ~0x7;
394-
395- while (tmp_addr < addr + len)
396- {
397- int status;
398- int skip_lo = 0;
399- int skip_hi = 0;
400-
401- status = ttrace (TT_LWP_RDRSEBS, ptid_get_pid (inferior_ptid),
402- ptid_get_lwp (inferior_ptid), tmp_addr,
403- sizeof (tmp_buf), (uintptr_t) tmp_buf);
404- if (status < 0)
405- return 0;
406-
407- if (tmp_addr < addr)
408- skip_lo = addr - tmp_addr;
409-
410- if (tmp_addr + sizeof (tmp_buf) > addr + len)
411- skip_hi = (tmp_addr + sizeof (tmp_buf)) - (addr + len);
412-
413- memcpy (buf + (tmp_addr + skip_lo - addr),
414- tmp_buf + skip_lo,
415- sizeof (tmp_buf) - skip_lo - skip_hi);
416-
417- tmp_addr += sizeof (tmp_buf);
418- }
419-
420- return 1;
421-}
422-
423-/* Write LEN bytes from BUF in memory at ADDR. This memory region is assumed
424- to be inside the backing store.
425-
426- Return zero if the operation failed. */
427-
428-static int
429-ia64_hpux_write_memory_bs (const gdb_byte *buf, CORE_ADDR addr, int len)
430-{
431- gdb_byte tmp_buf[8];
432- CORE_ADDR tmp_addr = addr & ~0x7;
433-
434- while (tmp_addr < addr + len)
435- {
436- int status;
437- int lo = 0;
438- int hi = 7;
439-
440- if (tmp_addr < addr || tmp_addr + sizeof (tmp_buf) > addr + len)
441- /* Part of the 8byte region pointed by tmp_addr needs to be preserved.
442- So read it in before we copy the data that needs to be changed. */
443- if (!ia64_hpux_read_memory_bs (tmp_buf, tmp_addr, sizeof (tmp_buf)))
444- return 0;
445-
446- if (tmp_addr < addr)
447- lo = addr - tmp_addr;
448-
449- if (tmp_addr + sizeof (tmp_buf) > addr + len)
450- hi = addr - tmp_addr + len - 1;
451-
452- memcpy (tmp_buf + lo, buf + tmp_addr - addr + lo, hi - lo + 1);
453-
454- status = ttrace (TT_LWP_WRRSEBS, ptid_get_pid (inferior_ptid),
455- ptid_get_lwp (inferior_ptid), tmp_addr,
456- sizeof (tmp_buf), (uintptr_t) tmp_buf);
457- if (status < 0)
458- return 0;
459-
460- tmp_addr += sizeof (tmp_buf);
461- }
462-
463- return 1;
464-}
465-
466-/* The "xfer_partial" routine for a memory region that is completely
467- inside of the backing-store region. */
468-
469-static LONGEST
470-ia64_hpux_xfer_memory_bs (struct target_ops *ops, const char *annex,
471- gdb_byte *readbuf, const gdb_byte *writebuf,
472- CORE_ADDR addr, LONGEST len)
473-{
474- int success;
475-
476- if (readbuf)
477- success = ia64_hpux_read_memory_bs (readbuf, addr, len);
478- else
479- success = ia64_hpux_write_memory_bs (writebuf, addr, len);
480-
481- if (success)
482- return len;
483- else
484- return 0;
485-}
486-
487-/* Get a register value as a unsigned value directly from the system,
488- instead of going through the regcache.
489-
490- This function is meant to be used when inferior_ptid is not
491- a thread/process known to GDB. */
492-
493-static ULONGEST
494-ia64_hpux_get_register_from_save_state_t (int regnum, int reg_size)
495-{
496- gdb_byte *buf = alloca (reg_size);
497- int offset = u_offsets[regnum];
498- int status;
499-
500- /* The register is assumed to be available for fetching. */
501- gdb_assert (offset != -1);
502-
503- status = ia64_hpux_read_register_from_save_state_t (offset, buf, reg_size);
504- if (status < 0)
505- {
506- /* This really should not happen. If it does, emit a warning
507- and pretend the register value is zero. Not exactly the best
508- error recovery mechanism, but better than nothing. We will
509- try to do better if we can demonstrate that this can happen
510- under normal circumstances. */
511- warning (_("Failed to read value of register number %d."), regnum);
512- return 0;
513- }
514-
515- return extract_unsigned_integer (buf, reg_size, BFD_ENDIAN_BIG);
516-}
517-
518-/* The "xfer_partial" target_ops routine for ia64-hpux, in the case
519- where the requested object is TARGET_OBJECT_MEMORY. */
520-
521-static enum target_xfer_status
522-ia64_hpux_xfer_memory (struct target_ops *ops, const char *annex,
523- gdb_byte *readbuf, const gdb_byte *writebuf,
524- CORE_ADDR addr, ULONGEST len, ULONGEST *xfered_len)
525-{
526- CORE_ADDR bsp, bspstore;
527- CORE_ADDR start_addr, short_len;
528- int status = 0;
529-
530- /* The back-store region cannot be read/written by the standard memory
531- read/write operations. So we handle the memory region piecemeal:
532- (1) and (2) The regions before and after the backing-store region,
533- which can be treated as normal memory;
534- (3) The region inside the backing-store, which needs to be
535- read/written specially. */
536-
537- if (in_inferior_list (ptid_get_pid (inferior_ptid)))
538- {
539- struct regcache *regcache = get_current_regcache ();
540-
541- regcache_raw_read_unsigned (regcache, IA64_BSP_REGNUM, &bsp);
542- regcache_raw_read_unsigned (regcache, IA64_BSPSTORE_REGNUM, &bspstore);
543- }
544- else
545- {
546- /* This is probably a child of our inferior created by a fork.
547- Because this process has not been added to our inferior list
548- (we are probably in the process of handling that child
549- process), we do not have a regcache to read the registers
550- from. So get those values directly from the kernel. */
551- bsp = ia64_hpux_get_register_from_save_state_t (IA64_BSP_REGNUM, 8);
552- bspstore =
553- ia64_hpux_get_register_from_save_state_t (IA64_BSPSTORE_REGNUM, 8);
554- }
555-
556- /* 1. Memory region before BSPSTORE. */
557-
558- if (addr < bspstore)
559- {
560- short_len = len;
561- if (addr + len > bspstore)
562- short_len = bspstore - addr;
563-
564- status = ia64_hpux_xfer_memory_no_bs (ops, annex, readbuf, writebuf,
565- addr, short_len);
566- if (status <= 0)
567- return TARGET_XFER_EOF;
568- }
569-
570- /* 2. Memory region after BSP. */
571-
572- if (addr + len > bsp)
573- {
574- start_addr = addr;
575- if (start_addr < bsp)
576- start_addr = bsp;
577- short_len = len + addr - start_addr;
578-
579- status = ia64_hpux_xfer_memory_no_bs
580- (ops, annex,
581- readbuf ? readbuf + (start_addr - addr) : NULL,
582- writebuf ? writebuf + (start_addr - addr) : NULL,
583- start_addr, short_len);
584- if (status <= 0)
585- return TARGET_XFER_EOF;
586- }
587-
588- /* 3. Memory region between BSPSTORE and BSP. */
589-
590- if (bspstore != bsp
591- && ((addr < bspstore && addr + len > bspstore)
592- || (addr + len <= bsp && addr + len > bsp)))
593- {
594- start_addr = addr;
595- if (addr < bspstore)
596- start_addr = bspstore;
597- short_len = len + addr - start_addr;
598-
599- if (start_addr + short_len > bsp)
600- short_len = bsp - start_addr;
601-
602- gdb_assert (short_len > 0);
603-
604- status = ia64_hpux_xfer_memory_bs
605- (ops, annex,
606- readbuf ? readbuf + (start_addr - addr) : NULL,
607- writebuf ? writebuf + (start_addr - addr) : NULL,
608- start_addr, short_len);
609- if (status < 0)
610- return TARGET_XFER_EOF;
611- }
612-
613- *xfered_len = len;
614- return TARGET_XFER_OK;
615-}
616-
617-/* Handle the transfer of TARGET_OBJECT_HPUX_UREGS objects on ia64-hpux.
618- ANNEX is currently ignored.
619-
620- The current implementation does not support write transfers (because
621- we do not currently do not need these transfers), and will raise
622- a failed assertion if WRITEBUF is not NULL. */
623-
624-static enum target_xfer_status
625-ia64_hpux_xfer_uregs (struct target_ops *ops, const char *annex,
626- gdb_byte *readbuf, const gdb_byte *writebuf,
627- ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
628-{
629- int status;
630-
631- gdb_assert (writebuf == NULL);
632-
633- status = ia64_hpux_read_register_from_save_state_t (offset, readbuf, len);
634- if (status < 0)
635- return TARGET_XFER_E_IO;
636-
637- *xfered_len = (ULONGEST) len;
638- return TARGET_XFER_OK;
639-}
640-
641-/* Handle the transfer of TARGET_OBJECT_HPUX_SOLIB_GOT objects on ia64-hpux.
642-
643- The current implementation does not support write transfers (because
644- we do not currently do not need these transfers), and will raise
645- a failed assertion if WRITEBUF is not NULL. */
646-
647-static enum target_xfer_status
648-ia64_hpux_xfer_solib_got (struct target_ops *ops, const char *annex,
649- gdb_byte *readbuf, const gdb_byte *writebuf,
650- ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
651-{
652- CORE_ADDR fun_addr;
653- /* The linkage pointer. We use a uint64_t to make sure that the size
654- of the object we are returning is always 64 bits long, as explained
655- in the description of the TARGET_OBJECT_HPUX_SOLIB_GOT object.
656- This is probably paranoia, but we do not use a CORE_ADDR because
657- it could conceivably be larger than uint64_t. */
658- uint64_t got;
659-
660- gdb_assert (writebuf == NULL);
661-
662- if (offset > sizeof (got))
663- return TARGET_XFER_EOF;
664-
665- fun_addr = string_to_core_addr (annex);
666- got = ia64_hpux_get_solib_linkage_addr (fun_addr);
667-
668- if (len > sizeof (got) - offset)
669- len = sizeof (got) - offset;
670- memcpy (readbuf, &got + offset, len);
671-
672- *xfered_len = (ULONGEST) len;
673- return TARGET_XFER_OK;
674-}
675-
676-/* The "to_xfer_partial" target_ops routine for ia64-hpux. */
677-
678-static enum target_xfer_status
679-ia64_hpux_xfer_partial (struct target_ops *ops, enum target_object object,
680- const char *annex, gdb_byte *readbuf,
681- const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
682- ULONGEST *xfered_len)
683-{
684- enum target_xfer_status val;
685-
686- if (object == TARGET_OBJECT_MEMORY)
687- val = ia64_hpux_xfer_memory (ops, annex, readbuf, writebuf, offset, len,
688- xfered_len);
689- else if (object == TARGET_OBJECT_HPUX_UREGS)
690- val = ia64_hpux_xfer_uregs (ops, annex, readbuf, writebuf, offset, len,
691- xfered_len);
692- else if (object == TARGET_OBJECT_HPUX_SOLIB_GOT)
693- val = ia64_hpux_xfer_solib_got (ops, annex, readbuf, writebuf, offset,
694- len, xfered_len);
695- else
696- val = super_xfer_partial (ops, object, annex, readbuf, writebuf, offset,
697- len, xfered_len);
698-
699- return val;
700-}
701-
702-/* The "to_can_use_hw_breakpoint" target_ops routine for ia64-hpux. */
703-
704-static int
705-ia64_hpux_can_use_hw_breakpoint (struct target_ops *self,
706- int type, int cnt, int othertype)
707-{
708- /* No hardware watchpoint/breakpoint support yet. */
709- return 0;
710-}
711-
712-/* The "to_mourn_inferior" routine from the "inf-ttrace" target_ops layer. */
713-
714-static void (*super_mourn_inferior) (struct target_ops *);
715-
716-/* The "to_mourn_inferior" target_ops routine for ia64-hpux. */
717-
718-static void
719-ia64_hpux_mourn_inferior (struct target_ops *ops)
720-{
721- const int pid = ptid_get_pid (inferior_ptid);
722- int status;
723-
724- super_mourn_inferior (ops);
725-
726- /* On this platform, the process still exists even after we received
727- an exit event. Detaching from the process isn't sufficient either,
728- as it only turns the process into a zombie. So the only solution
729- we found is to kill it. */
730- ttrace (TT_PROC_EXIT, pid, 0, 0, 0, 0);
731- wait (&status);
732-}
733-
734-/* Prevent warning from -Wmissing-prototypes. */
735-void _initialize_ia64_hpux_nat (void);
736-
737-void
738-_initialize_ia64_hpux_nat (void)
739-{
740- struct target_ops *t;
741-
742- t = inf_ttrace_target ();
743- super_to_wait = t->to_wait;
744- super_xfer_partial = t->to_xfer_partial;
745- super_mourn_inferior = t->to_mourn_inferior;
746-
747- t->to_wait = ia64_hpux_wait;
748- t->to_fetch_registers = ia64_hpux_fetch_registers;
749- t->to_store_registers = ia64_hpux_store_registers;
750- t->to_xfer_partial = ia64_hpux_xfer_partial;
751- t->to_can_use_hw_breakpoint = ia64_hpux_can_use_hw_breakpoint;
752- t->to_mourn_inferior = ia64_hpux_mourn_inferior;
753- t->to_attach_no_wait = 1;
754-
755- add_target (t);
756-}
--- a/gdb/ia64-hpux-tdep.c
+++ /dev/null
@@ -1,434 +0,0 @@
1-/* Target-dependent code for the IA-64 for GDB, the GNU debugger.
2-
3- Copyright (C) 2010-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#include "defs.h"
21-#include "ia64-tdep.h"
22-#include "ia64-hpux-tdep.h"
23-#include "osabi.h"
24-#include "gdbtypes.h"
25-#include "solib.h"
26-#include "target.h"
27-#include "frame.h"
28-#include "regcache.h"
29-#include "gdbcore.h"
30-#include "inferior.h"
31-
32-/* A sequence of instructions pushed on the stack when we want to perform
33- an inferior function call. The main purpose of this code is to save
34- the output region of the register frame belonging to the function
35- from which we are making the call. Normally, all registers are saved
36- prior to the call, but this does not include stacked registers because
37- they are seen by GDB as pseudo registers.
38-
39- With Linux kernels, these stacked registers can be saved by simply
40- creating a new register frame, or in other words by moving the BSP.
41- But the HP/UX kernel does not allow this. So we rely on this code
42- instead, that makes functions calls whose only purpose is to create
43- new register frames.
44-
45- The array below is the result obtained after assembling the code
46- shown below. It's an array of bytes in order to make it independent
47- of the host endianess, in case it ends up being used on more than
48- one target.
49-
50- start:
51- // Save b0 before using it (into preserved reg: r4).
52- mov r4 = b0
53- ;;
54-
55- br.call.dptk.few b0 = stub#
56- ;;
57-
58- // Add a nop bundle where we can insert our dummy breakpoint.
59- nop.m 0
60- nop.i 0
61- nop.i 0
62- ;;
63-
64- stub:
65- // Alloc a new register stack frame. Here, we set the size
66- // of all regions to zero. Eventually, GDB will manually
67- // change the instruction to set the size of the local region
68- // to match size of the output region of the function from
69- // which we are making the function call. This is to protect
70- // the value of the output registers of the function from
71- // which we are making the call.
72- alloc r6 = ar.pfs, 0, 0, 0, 0
73-
74- // Save b0 before using it again (into preserved reg: r5).
75- mov r5 = b0
76- ;;
77-
78- // Now that we have protected the entire output region of the
79- // register stack frame, we can call our function that will
80- // setup the arguments, and call our target function.
81- br.call.dptk.few b0 = call_dummy#
82- ;;
83-
84- // Restore b0, ar.pfs, and return
85- mov b0 = r5
86- mov.i ar.pfs = r6
87- ;;
88- br.ret.dptk.few b0
89- ;;
90-
91- call_dummy:
92- // Alloc a new frame, with 2 local registers, and 8 output registers
93- // (8 output registers for the maximum of 8 slots passed by register).
94- alloc r32 = ar.pfs, 2, 0, 8, 0
95-
96- // Save b0 before using it to call our target function.
97- mov r33 = b0
98-
99- // Load the argument values placed by GDB inside r14-r21 in their
100- // proper registers.
101- or r34 = r14, r0
102- or r35 = r15, r0
103- or r36 = r16, r0
104- or r37 = r17, r0
105- or r38 = r18, r0
106- or r39 = r19, r0
107- or r40 = r20, r0
108- or r41 = r21, r0
109- ;;
110-
111- // actual call
112- br.call.dptk.few b0 = b1
113- ;;
114-
115- mov.i ar.pfs=r32
116- mov b0=r33
117- ;;
118-
119- br.ret.dptk.few b0
120- ;;
121-
122-*/
123-
124-static const gdb_byte ia64_hpux_dummy_code[] =
125-{
126- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, 0x00,
127- 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
128- 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
129- 0x00, 0x02, 0x00, 0x00, 0x20, 0x00, 0x00, 0x52,
130- 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
131- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
132- 0x02, 0x30, 0x00, 0x00, 0x80, 0x05, 0x50, 0x00,
133- 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
134- 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
135- 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0x52,
136- 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x28,
137- 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0xaa, 0x00,
138- 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
139- 0x00, 0x02, 0x00, 0x80, 0x00, 0x00, 0x84, 0x02,
140- 0x00, 0x00, 0x29, 0x04, 0x80, 0x05, 0x10, 0x02,
141- 0x00, 0x62, 0x00, 0x40, 0xe4, 0x00, 0x38, 0x80,
142- 0x00, 0x18, 0x3d, 0x00, 0x0e, 0x20, 0x40, 0x82,
143- 0x00, 0x1c, 0x40, 0xa0, 0x14, 0x01, 0x38, 0x80,
144- 0x00, 0x30, 0x49, 0x00, 0x0e, 0x20, 0x70, 0x9a,
145- 0x00, 0x1c, 0x40, 0x00, 0x45, 0x01, 0x38, 0x80,
146- 0x0a, 0x48, 0x55, 0x00, 0x0e, 0x20, 0x00, 0x00,
147- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
148- 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
149- 0x00, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x12,
150- 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
151- 0x01, 0x55, 0x00, 0x00, 0x10, 0x0a, 0x00, 0x07,
152- 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
153- 0x00, 0x02, 0x00, 0x80, 0x00, 0x00, 0x84, 0x02
154-};
155-
156-/* The offset to be used in order to get the __reason pseudo-register
157- when using one of the *UREGS ttrace requests (see system header file
158- /usr/include/ia64/sys/uregs.h for more details).
159-
160- The documentation for this pseudo-register says that a nonzero value
161- indicates that the thread stopped due to a fault, trap, or interrupt.
162- A null value indicates a stop inside a syscall. */
163-#define IA64_HPUX_UREG_REASON 0x00070000
164-
165-/* Return nonzero if the value of the register identified by REGNUM
166- can be modified. */
167-
168-static int
169-ia64_hpux_can_store_ar_register (int regnum)
170-{
171- switch (regnum)
172- {
173- case IA64_RSC_REGNUM:
174- case IA64_RNAT_REGNUM:
175- case IA64_CSD_REGNUM:
176- case IA64_SSD_REGNUM:
177- case IA64_CCV_REGNUM:
178- case IA64_UNAT_REGNUM:
179- case IA64_FPSR_REGNUM:
180- case IA64_PFS_REGNUM:
181- case IA64_LC_REGNUM:
182- case IA64_EC_REGNUM:
183- return 1;
184- break;
185-
186- default:
187- return 0;
188- break;
189- }
190-}
191-
192-/* The "cannot_store_register" target_ops method. */
193-
194-static int
195-ia64_hpux_cannot_store_register (struct gdbarch *gdbarch, int regnum)
196-{
197- /* General registers. */
198-
199- if (regnum == IA64_GR0_REGNUM)
200- return 1;
201-
202- /* FP register. */
203-
204- if (regnum == IA64_FR0_REGNUM || regnum == IA64_FR1_REGNUM)
205- return 1;
206-
207- /* Application registers. */
208- if (regnum >= IA64_AR0_REGNUM && regnum <= IA64_AR0_REGNUM + 127)
209- return (!ia64_hpux_can_store_ar_register (regnum));
210-
211- /* We can store all other registers. */
212- return 0;
213-}
214-
215-/* Return nonzero if the inferior is stopped inside a system call. */
216-
217-static int
218-ia64_hpux_stopped_in_syscall (struct gdbarch *gdbarch)
219-{
220- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
221- struct target_ops *ops = &current_target;
222- gdb_byte buf[8];
223- int len;
224-
225- len = target_read (ops, TARGET_OBJECT_HPUX_UREGS, NULL,
226- buf, IA64_HPUX_UREG_REASON, sizeof (buf));
227- if (len == -1)
228- /* The target wasn't able to tell us. Assume we are not stopped
229- in a system call, which is the normal situation. */
230- return 0;
231- gdb_assert (len == 8);
232-
233- return (extract_unsigned_integer (buf, len, byte_order) == 0);
234-}
235-
236-/* The "size_of_register_frame" gdbarch_tdep routine for ia64-hpux. */
237-
238-static int
239-ia64_hpux_size_of_register_frame (struct frame_info *this_frame,
240- ULONGEST cfm)
241-{
242- int sof;
243-
244- if (frame_relative_level (this_frame) == 0
245- && ia64_hpux_stopped_in_syscall (get_frame_arch (this_frame)))
246- /* If the inferior stopped in a system call, the base address
247- of the register frame is at BSP - SOL instead of BSP - SOF.
248- This is an HP-UX exception. */
249- sof = (cfm & 0x3f80) >> 7;
250- else
251- sof = (cfm & 0x7f);
252-
253- return sof;
254-}
255-
256-/* Implement the push_dummy_code gdbarch method.
257-
258- This function assumes that the SP is already 16-byte-aligned. */
259-
260-static CORE_ADDR
261-ia64_hpux_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
262- CORE_ADDR funaddr, struct value **args, int nargs,
263- struct type *value_type, CORE_ADDR *real_pc,
264- CORE_ADDR *bp_addr, struct regcache *regcache)
265-{
266- ULONGEST cfm;
267- int sof, sol, sor, soo;
268- gdb_byte buf[16];
269-
270- regcache_cooked_read_unsigned (regcache, IA64_CFM_REGNUM, &cfm);
271- sof = cfm & 0x7f;
272- sol = (cfm >> 7) & 0x7f;
273- sor = (cfm >> 14) & 0xf;
274- soo = sof - sol - sor;
275-
276- /* Reserve some space on the stack to hold the dummy code. */
277- sp = sp - sizeof (ia64_hpux_dummy_code);
278-
279- /* Set the breakpoint address at the first instruction of the bundle
280- in the dummy code that has only nops. This is where the dummy code
281- expects us to break. */
282- *bp_addr = sp + 0x20;
283-
284- /* Start the inferior function call from the dummy code. The dummy
285- code will then call our function. */
286- *real_pc = sp;
287-
288- /* Transfer the dummy code to the inferior. */
289- write_memory (sp, ia64_hpux_dummy_code, sizeof (ia64_hpux_dummy_code));
290-
291- /* Update the size of the local portion of the register frame allocated
292- by ``stub'' to match the size of the output region of the current
293- register frame. This allows us to save the stacked registers.
294-
295- The "alloc" instruction is located at slot 0 of the bundle at +0x30.
296- Update the "sof" and "sol" portion of that instruction which are
297- respectively at bits 18-24 and 25-31 of the bundle. */
298- memcpy (buf, ia64_hpux_dummy_code + 0x30, sizeof (buf));
299-
300- buf[2] |= ((soo & 0x3f) << 2);
301- buf[3] |= (soo << 1);
302- if (soo > 63)
303- buf[3] |= 1;
304-
305- write_memory (sp + 0x30, buf, sizeof (buf));
306-
307- /* Return the new (already properly aligned) SP. */
308- return sp;
309-}
310-
311-/* The "allocate_new_rse_frame" ia64_infcall_ops routine for ia64-hpux. */
312-
313-static void
314-ia64_hpux_allocate_new_rse_frame (struct regcache *regcache, ULONGEST bsp,
315- int sof)
316-{
317- /* We cannot change the value of the BSP register on HP-UX,
318- so we can't allocate a new RSE frame. */
319-}
320-
321-/* The "store_argument_in_slot" ia64_infcall_ops routine for ia64-hpux. */
322-
323-static void
324-ia64_hpux_store_argument_in_slot (struct regcache *regcache, CORE_ADDR bsp,
325- int slotnum, gdb_byte *buf)
326-{
327- /* The call sequence on this target expects us to place the arguments
328- inside r14 - r21. */
329- regcache_cooked_write (regcache, IA64_GR0_REGNUM + 14 + slotnum, buf);
330-}
331-
332-/* The "set_function_addr" ia64_infcall_ops routine for ia64-hpux. */
333-
334-static void
335-ia64_hpux_set_function_addr (struct regcache *regcache, CORE_ADDR func_addr)
336-{
337- /* The calling sequence calls the function whose address is placed
338- in register b1. */
339- regcache_cooked_write_unsigned (regcache, IA64_BR1_REGNUM, func_addr);
340-}
341-
342-/* The ia64_infcall_ops structure for ia64-hpux. */
343-
344-static const struct ia64_infcall_ops ia64_hpux_infcall_ops =
345-{
346- ia64_hpux_allocate_new_rse_frame,
347- ia64_hpux_store_argument_in_slot,
348- ia64_hpux_set_function_addr
349-};
350-
351-/* The "dummy_id" gdbarch routine for ia64-hpux. */
352-
353-static struct frame_id
354-ia64_hpux_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
355-{
356- CORE_ADDR sp, pc, bp_addr, bsp;
357-
358- sp = get_frame_register_unsigned (this_frame, IA64_GR12_REGNUM);
359-
360- /* Just double-check that the frame PC is within a certain region
361- of the stack that would be plausible for our dummy code (the dummy
362- code was pushed at SP + 16). If not, then return a null frame ID.
363- This is necessary in our case, because it is possible to produce
364- the same frame ID for a normal frame, if that frame corresponds
365- to the function called by our dummy code, and the function has not
366- modified the registers that we use to build the dummy frame ID. */
367- pc = get_frame_pc (this_frame);
368- if (pc < sp + 16 || pc >= sp + 16 + sizeof (ia64_hpux_dummy_code))
369- return null_frame_id;
370-
371- /* The call sequence is such that the address of the dummy breakpoint
372- we inserted is stored in r5. */
373- bp_addr = get_frame_register_unsigned (this_frame, IA64_GR5_REGNUM);
374-
375- bsp = get_frame_register_unsigned (this_frame, IA64_BSP_REGNUM);
376-
377- return frame_id_build_special (sp, bp_addr, bsp);
378-}
379-
380-/* Should be set to non-NULL if the ia64-hpux solib module is linked in.
381- This may not be the case because the shared library support code can
382- only be compiled on ia64-hpux. */
383-
384-struct target_so_ops *ia64_hpux_so_ops = NULL;
385-
386-/* The "find_global_pointer_from_solib" gdbarch_tdep routine for
387- ia64-hpux. */
388-
389-static CORE_ADDR
390-ia64_hpux_find_global_pointer_from_solib (struct gdbarch *gdbarch,
391- CORE_ADDR faddr)
392-{
393- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
394- struct target_ops *ops = &current_target;
395- gdb_byte buf[8];
396- LONGEST len;
397-
398- len = target_read (ops, TARGET_OBJECT_HPUX_SOLIB_GOT,
399- paddress (gdbarch, faddr), buf, 0, sizeof (buf));
400-
401- return extract_unsigned_integer (buf, len, byte_order);
402-}
403-
404-static void
405-ia64_hpux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
406-{
407- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
408-
409- tdep->size_of_register_frame = ia64_hpux_size_of_register_frame;
410-
411- set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
412- set_gdbarch_cannot_store_register (gdbarch, ia64_hpux_cannot_store_register);
413-
414- /* Inferior functions must be called from stack. */
415- set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
416- set_gdbarch_push_dummy_code (gdbarch, ia64_hpux_push_dummy_code);
417- tdep->infcall_ops = ia64_hpux_infcall_ops;
418- tdep->find_global_pointer_from_solib
419- = ia64_hpux_find_global_pointer_from_solib;
420- set_gdbarch_dummy_id (gdbarch, ia64_hpux_dummy_id);
421-
422- if (ia64_hpux_so_ops)
423- set_solib_ops (gdbarch, ia64_hpux_so_ops);
424-}
425-
426-/* Provide a prototype to silence -Wmissing-prototypes. */
427-extern initialize_file_ftype _initialize_ia64_hpux_tdep;
428-
429-void
430-_initialize_ia64_hpux_tdep (void)
431-{
432- gdbarch_register_osabi (bfd_arch_ia64, 0, GDB_OSABI_HPUX_ELF,
433- ia64_hpux_init_abi);
434-}
--- a/gdb/ia64-hpux-tdep.h
+++ /dev/null
@@ -1,24 +0,0 @@
1-/* Copyright (C) 2010-2015 Free Software Foundation, Inc.
2-
3- This file is part of GDB.
4-
5- This program is free software; you can redistribute it and/or modify
6- it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 3 of the License, or
8- (at your option) any later version.
9-
10- This program is distributed in the hope that it will be useful,
11- but WITHOUT ANY WARRANTY; without even the implied warranty of
12- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13- GNU General Public License for more details.
14-
15- You should have received a copy of the GNU General Public License
16- along with this program. If not, see <http://www.gnu.org/licenses/>. */
17-
18-#ifndef IA64_HPUX_TDEP_H
19-#define IA64_HPUX_TDEP_H
20-
21-struct target_so_ops;
22-extern struct target_so_ops *ia64_hpux_so_ops;
23-
24-#endif
--- a/gdb/inf-ttrace.c
+++ /dev/null
@@ -1,1224 +0,0 @@
1-/* Low-level child interface to ttrace.
2-
3- Copyright (C) 2004-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#include "defs.h"
21-
22-/* The ttrace(2) system call didn't exist before HP-UX 10.30. Don't
23- try to compile this code unless we have it. */
24-#ifdef HAVE_TTRACE
25-
26-#include "command.h"
27-#include "gdbcore.h"
28-#include "gdbthread.h"
29-#include "inferior.h"
30-#include "terminal.h"
31-#include "target.h"
32-#include <sys/mman.h>
33-#include <sys/ttrace.h>
34-#include <signal.h>
35-
36-#include "inf-child.h"
37-#include "inf-ttrace.h"
38-#include "common/filestuff.h"
39-
40-
41-
42-/* HP-UX uses a threading model where each user-space thread
43- corresponds to a kernel thread. These kernel threads are called
44- lwps. The ttrace(2) interface gives us almost full control over
45- the threads, which makes it very easy to support them in GDB. We
46- identify the threads by process ID and lwp ID. The ttrace(2) also
47- provides us with a thread's user ID (in the `tts_user_tid' member
48- of `ttstate_t') but we don't use that (yet) as it isn't necessary
49- to uniquely label the thread. */
50-
51-/* Number of active lwps. */
52-static int inf_ttrace_num_lwps;
53-
54-
55-/* On HP-UX versions that have the ttrace(2) system call, we can
56- implement "hardware" watchpoints by fiddling with the protection of
57- pages in the address space that contain the variable being watched.
58- In order to implement this, we keep a dictionary of pages for which
59- we have changed the protection. */
60-
61-struct inf_ttrace_page
62-{
63- CORE_ADDR addr; /* Page address. */
64- int prot; /* Protection. */
65- int refcount; /* Reference count. */
66- struct inf_ttrace_page *next;
67- struct inf_ttrace_page *prev;
68-};
69-
70-struct inf_ttrace_page_dict
71-{
72- struct inf_ttrace_page buckets[128];
73- int pagesize; /* Page size. */
74- int count; /* Number of pages in this dictionary. */
75-} inf_ttrace_page_dict;
76-
77-struct inf_ttrace_private_thread_info
78-{
79- int dying;
80-};
81-
82-/* Number of lwps that are currently in a system call. */
83-static int inf_ttrace_num_lwps_in_syscall;
84-
85-/* Flag to indicate whether we should re-enable page protections after
86- the next wait. */
87-static int inf_ttrace_reenable_page_protections;
88-
89-/* Enable system call events for process PID. */
90-
91-static void
92-inf_ttrace_enable_syscall_events (pid_t pid)
93-{
94- ttevent_t tte;
95- ttstate_t tts;
96-
97- gdb_assert (inf_ttrace_num_lwps_in_syscall == 0);
98-
99- if (ttrace (TT_PROC_GET_EVENT_MASK, pid, 0,
100- (uintptr_t)&tte, sizeof tte, 0) == -1)
101- perror_with_name (("ttrace"));
102-
103- tte.tte_events |= (TTEVT_SYSCALL_ENTRY | TTEVT_SYSCALL_RETURN);
104-
105- if (ttrace (TT_PROC_SET_EVENT_MASK, pid, 0,
106- (uintptr_t)&tte, sizeof tte, 0) == -1)
107- perror_with_name (("ttrace"));
108-
109- if (ttrace (TT_PROC_GET_FIRST_LWP_STATE, pid, 0,
110- (uintptr_t)&tts, sizeof tts, 0) == -1)
111- perror_with_name (("ttrace"));
112-
113- if (tts.tts_flags & TTS_INSYSCALL)
114- inf_ttrace_num_lwps_in_syscall++;
115-
116- /* FIXME: Handle multiple threads. */
117-}
118-
119-/* Disable system call events for process PID. */
120-
121-static void
122-inf_ttrace_disable_syscall_events (pid_t pid)
123-{
124- ttevent_t tte;
125-
126- gdb_assert (inf_ttrace_page_dict.count == 0);
127-
128- if (ttrace (TT_PROC_GET_EVENT_MASK, pid, 0,
129- (uintptr_t)&tte, sizeof tte, 0) == -1)
130- perror_with_name (("ttrace"));
131-
132- tte.tte_events &= ~(TTEVT_SYSCALL_ENTRY | TTEVT_SYSCALL_RETURN);
133-
134- if (ttrace (TT_PROC_SET_EVENT_MASK, pid, 0,
135- (uintptr_t)&tte, sizeof tte, 0) == -1)
136- perror_with_name (("ttrace"));
137-
138- inf_ttrace_num_lwps_in_syscall = 0;
139-}
140-
141-/* Get information about the page at address ADDR for process PID from
142- the dictionary. */
143-
144-static struct inf_ttrace_page *
145-inf_ttrace_get_page (pid_t pid, CORE_ADDR addr)
146-{
147- const int num_buckets = ARRAY_SIZE (inf_ttrace_page_dict.buckets);
148- const int pagesize = inf_ttrace_page_dict.pagesize;
149- int bucket;
150- struct inf_ttrace_page *page;
151-
152- bucket = (addr / pagesize) % num_buckets;
153- page = &inf_ttrace_page_dict.buckets[bucket];
154- while (page)
155- {
156- if (page->addr == addr)
157- break;
158-
159- page = page->next;
160- }
161-
162- return page;
163-}
164-
165-/* Add the page at address ADDR for process PID to the dictionary. */
166-
167-static struct inf_ttrace_page *
168-inf_ttrace_add_page (pid_t pid, CORE_ADDR addr)
169-{
170- const int num_buckets = ARRAY_SIZE (inf_ttrace_page_dict.buckets);
171- const int pagesize = inf_ttrace_page_dict.pagesize;
172- int bucket;
173- struct inf_ttrace_page *page;
174- struct inf_ttrace_page *prev = NULL;
175-
176- bucket = (addr / pagesize) % num_buckets;
177- page = &inf_ttrace_page_dict.buckets[bucket];
178- while (page)
179- {
180- if (page->addr == addr)
181- break;
182-
183- prev = page;
184- page = page->next;
185- }
186-
187- if (!page)
188- {
189- int prot;
190-
191- if (ttrace (TT_PROC_GET_MPROTECT, pid, 0,
192- addr, 0, (uintptr_t)&prot) == -1)
193- perror_with_name (("ttrace"));
194-
195- page = XNEW (struct inf_ttrace_page);
196- page->addr = addr;
197- page->prot = prot;
198- page->refcount = 0;
199- page->next = NULL;
200-
201- page->prev = prev;
202- prev->next = page;
203-
204- inf_ttrace_page_dict.count++;
205- if (inf_ttrace_page_dict.count == 1)
206- inf_ttrace_enable_syscall_events (pid);
207-
208- if (inf_ttrace_num_lwps_in_syscall == 0)
209- {
210- if (ttrace (TT_PROC_SET_MPROTECT, pid, 0,
211- addr, pagesize, prot & ~PROT_WRITE) == -1)
212- perror_with_name (("ttrace"));
213- }
214- }
215-
216- return page;
217-}
218-
219-/* Insert the page at address ADDR of process PID to the dictionary. */
220-
221-static void
222-inf_ttrace_insert_page (pid_t pid, CORE_ADDR addr)
223-{
224- struct inf_ttrace_page *page;
225-
226- page = inf_ttrace_get_page (pid, addr);
227- if (!page)
228- page = inf_ttrace_add_page (pid, addr);
229-
230- page->refcount++;
231-}
232-
233-/* Remove the page at address ADDR of process PID from the dictionary. */
234-
235-static void
236-inf_ttrace_remove_page (pid_t pid, CORE_ADDR addr)
237-{
238- const int pagesize = inf_ttrace_page_dict.pagesize;
239- struct inf_ttrace_page *page;
240-
241- page = inf_ttrace_get_page (pid, addr);
242- page->refcount--;
243-
244- gdb_assert (page->refcount >= 0);
245-
246- if (page->refcount == 0)
247- {
248- if (inf_ttrace_num_lwps_in_syscall == 0)
249- {
250- if (ttrace (TT_PROC_SET_MPROTECT, pid, 0,
251- addr, pagesize, page->prot) == -1)
252- perror_with_name (("ttrace"));
253- }
254-
255- inf_ttrace_page_dict.count--;
256- if (inf_ttrace_page_dict.count == 0)
257- inf_ttrace_disable_syscall_events (pid);
258-
259- page->prev->next = page->next;
260- if (page->next)
261- page->next->prev = page->prev;
262-
263- xfree (page);
264- }
265-}
266-
267-/* Mask the bits in PROT from the page protections that are currently
268- in the dictionary for process PID. */
269-
270-static void
271-inf_ttrace_mask_page_protections (pid_t pid, int prot)
272-{
273- const int num_buckets = ARRAY_SIZE (inf_ttrace_page_dict.buckets);
274- const int pagesize = inf_ttrace_page_dict.pagesize;
275- int bucket;
276-
277- for (bucket = 0; bucket < num_buckets; bucket++)
278- {
279- struct inf_ttrace_page *page;
280-
281- page = inf_ttrace_page_dict.buckets[bucket].next;
282- while (page)
283- {
284- if (ttrace (TT_PROC_SET_MPROTECT, pid, 0,
285- page->addr, pagesize, page->prot & ~prot) == -1)
286- perror_with_name (("ttrace"));
287-
288- page = page->next;
289- }
290- }
291-}
292-
293-/* Write-protect the pages in the dictionary for process PID. */
294-
295-static void
296-inf_ttrace_enable_page_protections (pid_t pid)
297-{
298- inf_ttrace_mask_page_protections (pid, PROT_WRITE);
299-}
300-
301-/* Restore the protection of the pages in the dictionary for process
302- PID. */
303-
304-static void
305-inf_ttrace_disable_page_protections (pid_t pid)
306-{
307- inf_ttrace_mask_page_protections (pid, 0);
308-}
309-
310-/* Insert a "hardware" watchpoint for LEN bytes at address ADDR of
311- type TYPE. */
312-
313-static int
314-inf_ttrace_insert_watchpoint (struct target_ops *self,
315- CORE_ADDR addr, int len, int type,
316- struct expression *cond)
317-{
318- const int pagesize = inf_ttrace_page_dict.pagesize;
319- pid_t pid = ptid_get_pid (inferior_ptid);
320- CORE_ADDR page_addr;
321- int num_pages;
322- int page;
323-
324- gdb_assert (type == hw_write);
325-
326- page_addr = (addr / pagesize) * pagesize;
327- num_pages = (len + pagesize - 1) / pagesize;
328-
329- for (page = 0; page < num_pages; page++, page_addr += pagesize)
330- inf_ttrace_insert_page (pid, page_addr);
331-
332- return 1;
333-}
334-
335-/* Remove a "hardware" watchpoint for LEN bytes at address ADDR of
336- type TYPE. */
337-
338-static int
339-inf_ttrace_remove_watchpoint (struct target_ops *self,
340- CORE_ADDR addr, int len, int type,
341- struct expression *cond)
342-{
343- const int pagesize = inf_ttrace_page_dict.pagesize;
344- pid_t pid = ptid_get_pid (inferior_ptid);
345- CORE_ADDR page_addr;
346- int num_pages;
347- int page;
348-
349- gdb_assert (type == hw_write);
350-
351- page_addr = (addr / pagesize) * pagesize;
352- num_pages = (len + pagesize - 1) / pagesize;
353-
354- for (page = 0; page < num_pages; page++, page_addr += pagesize)
355- inf_ttrace_remove_page (pid, page_addr);
356-
357- return 1;
358-}
359-
360-static int
361-inf_ttrace_can_use_hw_breakpoint (struct target_ops *self,
362- int type, int len, int ot)
363-{
364- return (type == bp_hardware_watchpoint);
365-}
366-
367-static int
368-inf_ttrace_region_ok_for_hw_watchpoint (struct target_ops *self,
369- CORE_ADDR addr, int len)
370-{
371- return 1;
372-}
373-
374-/* Return non-zero if the current inferior was (potentially) stopped
375- by hitting a "hardware" watchpoint. */
376-
377-static int
378-inf_ttrace_stopped_by_watchpoint (struct target_ops *ops)
379-{
380- pid_t pid = ptid_get_pid (inferior_ptid);
381- lwpid_t lwpid = ptid_get_lwp (inferior_ptid);
382- ttstate_t tts;
383-
384- if (inf_ttrace_page_dict.count > 0)
385- {
386- if (ttrace (TT_LWP_GET_STATE, pid, lwpid,
387- (uintptr_t)&tts, sizeof tts, 0) == -1)
388- perror_with_name (("ttrace"));
389-
390- if (tts.tts_event == TTEVT_SIGNAL
391- && tts.tts_u.tts_signal.tts_signo == SIGBUS)
392- {
393- const int pagesize = inf_ttrace_page_dict.pagesize;
394- void *addr = tts.tts_u.tts_signal.tts_siginfo.si_addr;
395- CORE_ADDR page_addr = ((uintptr_t)addr / pagesize) * pagesize;
396-
397- if (inf_ttrace_get_page (pid, page_addr))
398- return 1;
399- }
400- }
401-
402- return 0;
403-}
404-
405-
406-/* Target hook for follow_fork. On entry and at return inferior_ptid
407- is the ptid of the followed inferior. */
408-
409-static int
410-inf_ttrace_follow_fork (struct target_ops *ops, int follow_child,
411- int detach_fork)
412-{
413- struct thread_info *tp = inferior_thread ();
414-
415- gdb_assert (tp->pending_follow.kind == TARGET_WAITKIND_FORKED
416- || tp->pending_follow.kind == TARGET_WAITKIND_VFORKED);
417-
418- if (follow_child)
419- {
420- struct thread_info *ti;
421-
422- /* The child will start out single-threaded. */
423- inf_ttrace_num_lwps = 1;
424- inf_ttrace_num_lwps_in_syscall = 0;
425-
426- ti = inferior_thread ();
427- ti->priv =
428- xmalloc (sizeof (struct inf_ttrace_private_thread_info));
429- memset (ti->priv, 0,
430- sizeof (struct inf_ttrace_private_thread_info));
431- }
432- else
433- {
434- pid_t child_pid;
435-
436- /* Following parent. Detach child now. */
437- child_pid = ptid_get_pid (tp->pending_follow.value.related_pid);
438- if (ttrace (TT_PROC_DETACH, child_pid, 0, 0, 0, 0) == -1)
439- perror_with_name (("ttrace"));
440- }
441-
442- return 0;
443-}
444-
445-
446-/* File descriptors for pipes used as semaphores during initial
447- startup of an inferior. */
448-static int inf_ttrace_pfd1[2];
449-static int inf_ttrace_pfd2[2];
450-
451-static void
452-do_cleanup_pfds (void *dummy)
453-{
454- close (inf_ttrace_pfd1[0]);
455- close (inf_ttrace_pfd1[1]);
456- close (inf_ttrace_pfd2[0]);
457- close (inf_ttrace_pfd2[1]);
458-
459- unmark_fd_no_cloexec (inf_ttrace_pfd1[0]);
460- unmark_fd_no_cloexec (inf_ttrace_pfd1[1]);
461- unmark_fd_no_cloexec (inf_ttrace_pfd2[0]);
462- unmark_fd_no_cloexec (inf_ttrace_pfd2[1]);
463-}
464-
465-static void
466-inf_ttrace_prepare (void)
467-{
468- if (pipe (inf_ttrace_pfd1) == -1)
469- perror_with_name (("pipe"));
470-
471- if (pipe (inf_ttrace_pfd2) == -1)
472- {
473- close (inf_ttrace_pfd1[0]);
474- close (inf_ttrace_pfd2[0]);
475- perror_with_name (("pipe"));
476- }
477-
478- mark_fd_no_cloexec (inf_ttrace_pfd1[0]);
479- mark_fd_no_cloexec (inf_ttrace_pfd1[1]);
480- mark_fd_no_cloexec (inf_ttrace_pfd2[0]);
481- mark_fd_no_cloexec (inf_ttrace_pfd2[1]);
482-}
483-
484-/* Prepare to be traced. */
485-
486-static void
487-inf_ttrace_me (void)
488-{
489- struct cleanup *old_chain = make_cleanup (do_cleanup_pfds, 0);
490- char c;
491-
492- /* "Trace me, Dr. Memory!" */
493- if (ttrace (TT_PROC_SETTRC, 0, 0, 0, TT_VERSION, 0) == -1)
494- perror_with_name (("ttrace"));
495-
496- /* Tell our parent that we are ready to be traced. */
497- if (write (inf_ttrace_pfd1[1], &c, sizeof c) != sizeof c)
498- perror_with_name (("write"));
499-
500- /* Wait until our parent has set the initial event mask. */
501- if (read (inf_ttrace_pfd2[0], &c, sizeof c) != sizeof c)
502- perror_with_name (("read"));
503-
504- do_cleanups (old_chain);
505-}
506-
507-/* Start tracing PID. */
508-
509-static void
510-inf_ttrace_him (struct target_ops *ops, int pid)
511-{
512- struct cleanup *old_chain = make_cleanup (do_cleanup_pfds, 0);
513- ttevent_t tte;
514- char c;
515-
516- /* Wait until our child is ready to be traced. */
517- if (read (inf_ttrace_pfd1[0], &c, sizeof c) != sizeof c)
518- perror_with_name (("read"));
519-
520- /* Set the initial event mask. */
521- memset (&tte, 0, sizeof (tte));
522- tte.tte_events |= TTEVT_EXEC | TTEVT_EXIT | TTEVT_FORK | TTEVT_VFORK;
523- tte.tte_events |= TTEVT_LWP_CREATE | TTEVT_LWP_EXIT | TTEVT_LWP_TERMINATE;
524-#ifdef TTEVT_BPT_SSTEP
525- tte.tte_events |= TTEVT_BPT_SSTEP;
526-#endif
527- tte.tte_opts |= TTEO_PROC_INHERIT;
528- if (ttrace (TT_PROC_SET_EVENT_MASK, pid, 0,
529- (uintptr_t)&tte, sizeof tte, 0) == -1)
530- perror_with_name (("ttrace"));
531-
532- /* Tell our child that we have set the initial event mask. */
533- if (write (inf_ttrace_pfd2[1], &c, sizeof c) != sizeof c)
534- perror_with_name (("write"));
535-
536- do_cleanups (old_chain);
537-
538- if (!target_is_pushed (ops))
539- push_target (ops);
540-
541- startup_inferior (START_INFERIOR_TRAPS_EXPECTED);
542-
543- /* On some targets, there must be some explicit actions taken after
544- the inferior has been started up. */
545- target_post_startup_inferior (pid_to_ptid (pid));
546-}
547-
548-static void
549-inf_ttrace_create_inferior (struct target_ops *ops, char *exec_file,
550- char *allargs, char **env, int from_tty)
551-{
552- int pid;
553-
554- gdb_assert (inf_ttrace_num_lwps == 0);
555- gdb_assert (inf_ttrace_num_lwps_in_syscall == 0);
556- gdb_assert (inf_ttrace_page_dict.count == 0);
557- gdb_assert (inf_ttrace_reenable_page_protections == 0);
558-
559- pid = fork_inferior (exec_file, allargs, env, inf_ttrace_me, NULL,
560- inf_ttrace_prepare, NULL, NULL);
561-
562- inf_ttrace_him (ops, pid);
563-}
564-
565-static void
566-inf_ttrace_mourn_inferior (struct target_ops *ops)
567-{
568- const int num_buckets = ARRAY_SIZE (inf_ttrace_page_dict.buckets);
569- int bucket;
570-
571- inf_ttrace_num_lwps = 0;
572- inf_ttrace_num_lwps_in_syscall = 0;
573-
574- for (bucket = 0; bucket < num_buckets; bucket++)
575- {
576- struct inf_ttrace_page *page;
577- struct inf_ttrace_page *next;
578-
579- page = inf_ttrace_page_dict.buckets[bucket].next;
580- while (page)
581- {
582- next = page->next;
583- xfree (page);
584- page = next;
585- }
586- }
587- inf_ttrace_page_dict.count = 0;
588-
589- inf_child_mourn_inferior (ops);
590-}
591-
592-/* Assuming we just attached the debugger to a new inferior, create
593- a new thread_info structure for each thread, and add it to our
594- list of threads. */
595-
596-static void
597-inf_ttrace_create_threads_after_attach (int pid)
598-{
599- int status;
600- ptid_t ptid;
601- ttstate_t tts;
602- struct thread_info *ti;
603-
604- status = ttrace (TT_PROC_GET_FIRST_LWP_STATE, pid, 0,
605- (uintptr_t) &tts, sizeof (ttstate_t), 0);
606- if (status < 0)
607- perror_with_name (_("TT_PROC_GET_FIRST_LWP_STATE ttrace call failed"));
608- gdb_assert (tts.tts_pid == pid);
609-
610- /* Add the stopped thread. */
611- ptid = ptid_build (pid, tts.tts_lwpid, 0);
612- ti = add_thread (ptid);
613- ti->priv = xzalloc (sizeof (struct inf_ttrace_private_thread_info));
614- inf_ttrace_num_lwps++;
615-
616- /* We use the "first stopped thread" as the currently active thread. */
617- inferior_ptid = ptid;
618-
619- /* Iterative over all the remaining threads. */
620-
621- for (;;)
622- {
623- ptid_t ptid;
624-
625- status = ttrace (TT_PROC_GET_NEXT_LWP_STATE, pid, 0,
626- (uintptr_t) &tts, sizeof (ttstate_t), 0);
627- if (status < 0)
628- perror_with_name (_("TT_PROC_GET_NEXT_LWP_STATE ttrace call failed"));
629- if (status == 0)
630- break; /* End of list. */
631-
632- ptid = ptid_build (tts.tts_pid, tts.tts_lwpid, 0);
633- ti = add_thread (ptid);
634- ti->priv = xzalloc (sizeof (struct inf_ttrace_private_thread_info));
635- inf_ttrace_num_lwps++;
636- }
637-}
638-
639-static void
640-inf_ttrace_attach (struct target_ops *ops, const char *args, int from_tty)
641-{
642- char *exec_file;
643- pid_t pid;
644- ttevent_t tte;
645- struct inferior *inf;
646-
647- pid = parse_pid_to_attach (args);
648-
649- if (pid == getpid ()) /* Trying to masturbate? */
650- error (_("I refuse to debug myself!"));
651-
652- if (from_tty)
653- {
654- exec_file = get_exec_file (0);
655-
656- if (exec_file)
657- printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
658- target_pid_to_str (pid_to_ptid (pid)));
659- else
660- printf_unfiltered (_("Attaching to %s\n"),
661- target_pid_to_str (pid_to_ptid (pid)));
662-
663- gdb_flush (gdb_stdout);
664- }
665-
666- gdb_assert (inf_ttrace_num_lwps == 0);
667- gdb_assert (inf_ttrace_num_lwps_in_syscall == 0);
668-
669- if (ttrace (TT_PROC_ATTACH, pid, 0, TT_KILL_ON_EXIT, TT_VERSION, 0) == -1)
670- perror_with_name (("ttrace"));
671-
672- inf = current_inferior ();
673- inferior_appeared (inf, pid);
674- inf->attach_flag = 1;
675-
676- /* Set the initial event mask. */
677- memset (&tte, 0, sizeof (tte));
678- tte.tte_events |= TTEVT_EXEC | TTEVT_EXIT | TTEVT_FORK | TTEVT_VFORK;
679- tte.tte_events |= TTEVT_LWP_CREATE | TTEVT_LWP_EXIT | TTEVT_LWP_TERMINATE;
680-#ifdef TTEVT_BPT_SSTEP
681- tte.tte_events |= TTEVT_BPT_SSTEP;
682-#endif
683- tte.tte_opts |= TTEO_PROC_INHERIT;
684- if (ttrace (TT_PROC_SET_EVENT_MASK, pid, 0,
685- (uintptr_t)&tte, sizeof tte, 0) == -1)
686- perror_with_name (("ttrace"));
687-
688- if (!target_is_pushed (ops))
689- push_target (ops);
690-
691- inf_ttrace_create_threads_after_attach (pid);
692-}
693-
694-static void
695-inf_ttrace_detach (struct target_ops *ops, const char *args, int from_tty)
696-{
697- pid_t pid = ptid_get_pid (inferior_ptid);
698- int sig = 0;
699-
700- if (from_tty)
701- {
702- char *exec_file = get_exec_file (0);
703- if (exec_file == 0)
704- exec_file = "";
705- printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
706- target_pid_to_str (pid_to_ptid (pid)));
707- gdb_flush (gdb_stdout);
708- }
709- if (args)
710- sig = atoi (args);
711-
712- /* ??? The HP-UX 11.0 ttrace(2) manual page doesn't mention that we
713- can pass a signal number here. Does this really work? */
714- if (ttrace (TT_PROC_DETACH, pid, 0, 0, sig, 0) == -1)
715- perror_with_name (("ttrace"));
716-
717- inf_ttrace_num_lwps = 0;
718- inf_ttrace_num_lwps_in_syscall = 0;
719-
720- inferior_ptid = null_ptid;
721- detach_inferior (pid);
722-
723- inf_child_maybe_unpush_target (ops);
724-}
725-
726-static void
727-inf_ttrace_kill (struct target_ops *ops)
728-{
729- pid_t pid = ptid_get_pid (inferior_ptid);
730-
731- if (pid == 0)
732- return;
733-
734- if (ttrace (TT_PROC_EXIT, pid, 0, 0, 0, 0) == -1)
735- perror_with_name (("ttrace"));
736- /* ??? Is it necessary to call ttrace_wait() here? */
737-
738- target_mourn_inferior ();
739-}
740-
741-/* Check is a dying thread is dead by now, and delete it from GDBs
742- thread list if so. */
743-static int
744-inf_ttrace_delete_dead_threads_callback (struct thread_info *info, void *arg)
745-{
746- lwpid_t lwpid;
747- struct inf_ttrace_private_thread_info *p;
748-
749- if (is_exited (info->ptid))
750- return 0;
751-
752- lwpid = ptid_get_lwp (info->ptid);
753- p = (struct inf_ttrace_private_thread_info *) info->priv;
754-
755- /* Check if an lwp that was dying is still there or not. */
756- if (p->dying && (kill (lwpid, 0) == -1))
757- /* It's gone now. */
758- delete_thread (info->ptid);
759-
760- return 0;
761-}
762-
763-/* Resume the lwp pointed to by INFO, with REQUEST, and pass it signal
764- SIG. */
765-
766-static void
767-inf_ttrace_resume_lwp (struct thread_info *info, ttreq_t request, int sig)
768-{
769- pid_t pid = ptid_get_pid (info->ptid);
770- lwpid_t lwpid = ptid_get_lwp (info->ptid);
771-
772- if (ttrace (request, pid, lwpid, TT_NOPC, sig, 0) == -1)
773- {
774- struct inf_ttrace_private_thread_info *p
775- = (struct inf_ttrace_private_thread_info *) info->priv;
776- if (p->dying && errno == EPROTO)
777- /* This is expected, it means the dying lwp is really gone
778- by now. If ttrace had an event to inform the debugger
779- the lwp is really gone, this wouldn't be needed. */
780- delete_thread (info->ptid);
781- else
782- /* This was really unexpected. */
783- perror_with_name (("ttrace"));
784- }
785-}
786-
787-/* Callback for iterate_over_threads. */
788-
789-static int
790-inf_ttrace_resume_callback (struct thread_info *info, void *arg)
791-{
792- if (!ptid_equal (info->ptid, inferior_ptid) && !is_exited (info->ptid))
793- inf_ttrace_resume_lwp (info, TT_LWP_CONTINUE, 0);
794-
795- return 0;
796-}
797-
798-static void
799-inf_ttrace_resume (struct target_ops *ops,
800- ptid_t ptid, int step, enum gdb_signal signal)
801-{
802- int resume_all;
803- ttreq_t request = step ? TT_LWP_SINGLE : TT_LWP_CONTINUE;
804- int sig = gdb_signal_to_host (signal);
805- struct thread_info *info;
806-
807- /* A specific PTID means `step only this process id'. */
808- resume_all = (ptid_equal (ptid, minus_one_ptid));
809-
810- /* If resuming all threads, it's the current thread that should be
811- handled specially. */
812- if (resume_all)
813- ptid = inferior_ptid;
814-
815- info = find_thread_ptid (ptid);
816- inf_ttrace_resume_lwp (info, request, sig);
817-
818- if (resume_all)
819- /* Let all the other threads run too. */
820- iterate_over_threads (inf_ttrace_resume_callback, NULL);
821-}
822-
823-static ptid_t
824-inf_ttrace_wait (struct target_ops *ops,
825- ptid_t ptid, struct target_waitstatus *ourstatus, int options)
826-{
827- pid_t pid = ptid_get_pid (ptid);
828- lwpid_t lwpid = ptid_get_lwp (ptid);
829- ttstate_t tts;
830- struct thread_info *ti;
831- ptid_t related_ptid;
832-
833- /* Until proven otherwise. */
834- ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
835-
836- if (pid == -1)
837- pid = lwpid = 0;
838-
839- gdb_assert (pid != 0 || lwpid == 0);
840-
841- do
842- {
843- set_sigint_trap ();
844-
845- if (ttrace_wait (pid, lwpid, TTRACE_WAITOK, &tts, sizeof tts) == -1)
846- perror_with_name (("ttrace_wait"));
847-
848- clear_sigint_trap ();
849- }
850- while (tts.tts_event == TTEVT_NONE);
851-
852- /* Now that we've waited, we can re-enable the page protections. */
853- if (inf_ttrace_reenable_page_protections)
854- {
855- gdb_assert (inf_ttrace_num_lwps_in_syscall == 0);
856- inf_ttrace_enable_page_protections (tts.tts_pid);
857- inf_ttrace_reenable_page_protections = 0;
858- }
859-
860- ptid = ptid_build (tts.tts_pid, tts.tts_lwpid, 0);
861-
862- if (inf_ttrace_num_lwps == 0)
863- {
864- struct thread_info *ti;
865-
866- inf_ttrace_num_lwps = 1;
867-
868- /* This is the earliest we hear about the lwp member of
869- INFERIOR_PTID, after an attach or fork_inferior. */
870- gdb_assert (ptid_get_lwp (inferior_ptid) == 0);
871-
872- /* We haven't set the private member on the main thread yet. Do
873- it now. */
874- ti = find_thread_ptid (inferior_ptid);
875- gdb_assert (ti != NULL && ti->priv == NULL);
876- ti->priv =
877- xmalloc (sizeof (struct inf_ttrace_private_thread_info));
878- memset (ti->priv, 0,
879- sizeof (struct inf_ttrace_private_thread_info));
880-
881- /* Notify the core that this ptid changed. This changes
882- inferior_ptid as well. */
883- thread_change_ptid (inferior_ptid, ptid);
884- }
885-
886- switch (tts.tts_event)
887- {
888-#ifdef TTEVT_BPT_SSTEP
889- case TTEVT_BPT_SSTEP:
890- /* Make it look like a breakpoint. */
891- ourstatus->kind = TARGET_WAITKIND_STOPPED;
892- ourstatus->value.sig = GDB_SIGNAL_TRAP;
893- break;
894-#endif
895-
896- case TTEVT_EXEC:
897- ourstatus->kind = TARGET_WAITKIND_EXECD;
898- ourstatus->value.execd_pathname =
899- xmalloc (tts.tts_u.tts_exec.tts_pathlen + 1);
900- if (ttrace (TT_PROC_GET_PATHNAME, tts.tts_pid, 0,
901- (uintptr_t)ourstatus->value.execd_pathname,
902- tts.tts_u.tts_exec.tts_pathlen, 0) == -1)
903- perror_with_name (("ttrace"));
904- ourstatus->value.execd_pathname[tts.tts_u.tts_exec.tts_pathlen] = 0;
905-
906- /* At this point, all inserted breakpoints are gone. Doing this
907- as soon as we detect an exec prevents the badness of deleting
908- a breakpoint writing the current "shadow contents" to lift
909- the bp. That shadow is NOT valid after an exec. */
910- mark_breakpoints_out ();
911- break;
912-
913- case TTEVT_EXIT:
914- store_waitstatus (ourstatus, tts.tts_u.tts_exit.tts_exitcode);
915- inf_ttrace_num_lwps = 0;
916- break;
917-
918- case TTEVT_FORK:
919- related_ptid = ptid_build (tts.tts_u.tts_fork.tts_fpid,
920- tts.tts_u.tts_fork.tts_flwpid, 0);
921-
922- ourstatus->kind = TARGET_WAITKIND_FORKED;
923- ourstatus->value.related_pid = related_ptid;
924-
925- /* Make sure the other end of the fork is stopped too. */
926- if (ttrace_wait (tts.tts_u.tts_fork.tts_fpid,
927- tts.tts_u.tts_fork.tts_flwpid,
928- TTRACE_WAITOK, &tts, sizeof tts) == -1)
929- perror_with_name (("ttrace_wait"));
930-
931- gdb_assert (tts.tts_event == TTEVT_FORK);
932- if (tts.tts_u.tts_fork.tts_isparent)
933- {
934- related_ptid = ptid_build (tts.tts_u.tts_fork.tts_fpid,
935- tts.tts_u.tts_fork.tts_flwpid, 0);
936- ptid = ptid_build (tts.tts_pid, tts.tts_lwpid, 0);
937- ourstatus->value.related_pid = related_ptid;
938- }
939- break;
940-
941- case TTEVT_VFORK:
942- if (tts.tts_u.tts_fork.tts_isparent)
943- ourstatus->kind = TARGET_WAITKIND_VFORK_DONE;
944- else
945- {
946- related_ptid = ptid_build (tts.tts_u.tts_fork.tts_fpid,
947- tts.tts_u.tts_fork.tts_flwpid, 0);
948-
949- ourstatus->kind = TARGET_WAITKIND_VFORKED;
950- ourstatus->value.related_pid = related_ptid;
951- }
952- break;
953-
954- case TTEVT_LWP_CREATE:
955- lwpid = tts.tts_u.tts_thread.tts_target_lwpid;
956- ptid = ptid_build (tts.tts_pid, lwpid, 0);
957- ti = add_thread (ptid);
958- ti->priv =
959- xmalloc (sizeof (struct inf_ttrace_private_thread_info));
960- memset (ti->priv, 0,
961- sizeof (struct inf_ttrace_private_thread_info));
962- inf_ttrace_num_lwps++;
963- ptid = ptid_build (tts.tts_pid, tts.tts_lwpid, 0);
964- /* Let the lwp_create-caller thread continue. */
965- ttrace (TT_LWP_CONTINUE, ptid_get_pid (ptid),
966- ptid_get_lwp (ptid), TT_NOPC, 0, 0);
967- /* Return without stopping the whole process. */
968- ourstatus->kind = TARGET_WAITKIND_IGNORE;
969- return ptid;
970-
971- case TTEVT_LWP_EXIT:
972- if (print_thread_events)
973- printf_unfiltered (_("[%s exited]\n"), target_pid_to_str (ptid));
974- ti = find_thread_ptid (ptid);
975- gdb_assert (ti != NULL);
976- ((struct inf_ttrace_private_thread_info *)ti->priv)->dying = 1;
977- inf_ttrace_num_lwps--;
978- /* Let the thread really exit. */
979- ttrace (TT_LWP_CONTINUE, ptid_get_pid (ptid),
980- ptid_get_lwp (ptid), TT_NOPC, 0, 0);
981- /* Return without stopping the whole process. */
982- ourstatus->kind = TARGET_WAITKIND_IGNORE;
983- return ptid;
984-
985- case TTEVT_LWP_TERMINATE:
986- lwpid = tts.tts_u.tts_thread.tts_target_lwpid;
987- ptid = ptid_build (tts.tts_pid, lwpid, 0);
988- if (print_thread_events)
989- printf_unfiltered(_("[%s has been terminated]\n"),
990- target_pid_to_str (ptid));
991- ti = find_thread_ptid (ptid);
992- gdb_assert (ti != NULL);
993- ((struct inf_ttrace_private_thread_info *)ti->priv)->dying = 1;
994- inf_ttrace_num_lwps--;
995-
996- /* Resume the lwp_terminate-caller thread. */
997- ptid = ptid_build (tts.tts_pid, tts.tts_lwpid, 0);
998- ttrace (TT_LWP_CONTINUE, ptid_get_pid (ptid),
999- ptid_get_lwp (ptid), TT_NOPC, 0, 0);
1000- /* Return without stopping the whole process. */
1001- ourstatus->kind = TARGET_WAITKIND_IGNORE;
1002- return ptid;
1003-
1004- case TTEVT_SIGNAL:
1005- ourstatus->kind = TARGET_WAITKIND_STOPPED;
1006- ourstatus->value.sig =
1007- gdb_signal_from_host (tts.tts_u.tts_signal.tts_signo);
1008- break;
1009-
1010- case TTEVT_SYSCALL_ENTRY:
1011- gdb_assert (inf_ttrace_reenable_page_protections == 0);
1012- inf_ttrace_num_lwps_in_syscall++;
1013- if (inf_ttrace_num_lwps_in_syscall == 1)
1014- {
1015- /* A thread has just entered a system call. Disable any
1016- page protections as the kernel can't deal with them. */
1017- inf_ttrace_disable_page_protections (tts.tts_pid);
1018- }
1019- ourstatus->kind = TARGET_WAITKIND_SYSCALL_ENTRY;
1020- ourstatus->value.syscall_number = tts.tts_scno;
1021- break;
1022-
1023- case TTEVT_SYSCALL_RETURN:
1024- if (inf_ttrace_num_lwps_in_syscall > 0)
1025- {
1026- /* If the last thread has just left the system call, this
1027- would be a logical place to re-enable the page
1028- protections, but that doesn't work. We can't re-enable
1029- them until we've done another wait. */
1030- inf_ttrace_reenable_page_protections =
1031- (inf_ttrace_num_lwps_in_syscall == 1);
1032- inf_ttrace_num_lwps_in_syscall--;
1033- }
1034- ourstatus->kind = TARGET_WAITKIND_SYSCALL_RETURN;
1035- ourstatus->value.syscall_number = tts.tts_scno;
1036- break;
1037-
1038- default:
1039- gdb_assert (!"Unexpected ttrace event");
1040- break;
1041- }
1042-
1043- /* Make sure all threads within the process are stopped. */
1044- if (ttrace (TT_PROC_STOP, tts.tts_pid, 0, 0, 0, 0) == -1)
1045- perror_with_name (("ttrace"));
1046-
1047- /* Now that the whole process is stopped, check if any dying thread
1048- is really dead by now. If a dying thread is still alive, it will
1049- be stopped too, and will still show up in `info threads', tagged
1050- with "(Exiting)". We could make `info threads' prune dead
1051- threads instead via inf_ttrace_thread_alive, but doing this here
1052- has the advantage that a frontend is notificed sooner of thread
1053- exits. Note that a dying lwp is still alive, it still has to be
1054- resumed, like any other lwp. */
1055- iterate_over_threads (inf_ttrace_delete_dead_threads_callback, NULL);
1056-
1057- return ptid;
1058-}
1059-
1060-/* Transfer LEN bytes from ADDR in the inferior's memory into READBUF,
1061- and transfer LEN bytes from WRITEBUF into the inferior's memory at
1062- ADDR. Either READBUF or WRITEBUF may be null, in which case the
1063- corresponding transfer doesn't happen. Return the number of bytes
1064- actually transferred (which may be zero if an error occurs). */
1065-
1066-static LONGEST
1067-inf_ttrace_xfer_memory (CORE_ADDR addr, ULONGEST len,
1068- void *readbuf, const void *writebuf)
1069-{
1070- pid_t pid = ptid_get_pid (inferior_ptid);
1071-
1072- /* HP-UX treats text space and data space differently. GDB however,
1073- doesn't really know the difference. Therefore we try both. Try
1074- text space before data space though because when we're writing
1075- into text space the instruction cache might need to be flushed. */
1076-
1077- if (readbuf
1078- && ttrace (TT_PROC_RDTEXT, pid, 0, addr, len, (uintptr_t)readbuf) == -1
1079- && ttrace (TT_PROC_RDDATA, pid, 0, addr, len, (uintptr_t)readbuf) == -1)
1080- return 0;
1081-
1082- if (writebuf
1083- && ttrace (TT_PROC_WRTEXT, pid, 0, addr, len, (uintptr_t)writebuf) == -1
1084- && ttrace (TT_PROC_WRDATA, pid, 0, addr, len, (uintptr_t)writebuf) == -1)
1085- return 0;
1086-
1087- return len;
1088-}
1089-
1090-static enum target_xfer_status
1091-inf_ttrace_xfer_partial (struct target_ops *ops, enum target_object object,
1092- const char *annex, gdb_byte *readbuf,
1093- const gdb_byte *writebuf,
1094- ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
1095-{
1096- switch (object)
1097- {
1098- case TARGET_OBJECT_MEMORY:
1099- {
1100- LONGEST val = inf_ttrace_xfer_memory (offset, len, readbuf, writebuf);
1101-
1102- if (val == 0)
1103- return TARGET_XFER_EOF;
1104- else
1105- {
1106- *xfered_len = (ULONGEST) val;
1107- return TARGET_XFER_OK;
1108- }
1109- }
1110-
1111- case TARGET_OBJECT_UNWIND_TABLE:
1112- return TARGET_XFER_E_IO;
1113-
1114- case TARGET_OBJECT_AUXV:
1115- return TARGET_XFER_E_IO;
1116-
1117- case TARGET_OBJECT_WCOOKIE:
1118- return TARGET_XFER_E_IO;
1119-
1120- default:
1121- return TARGET_XFER_E_IO;
1122- }
1123-}
1124-
1125-/* Print status information about what we're accessing. */
1126-
1127-static void
1128-inf_ttrace_files_info (struct target_ops *ignore)
1129-{
1130- struct inferior *inf = current_inferior ();
1131- printf_filtered (_("\tUsing the running image of %s %s.\n"),
1132- inf->attach_flag ? "attached" : "child",
1133- target_pid_to_str (inferior_ptid));
1134-}
1135-
1136-static int
1137-inf_ttrace_thread_alive (struct target_ops *ops, ptid_t ptid)
1138-{
1139- return 1;
1140-}
1141-
1142-/* Return a string describing the state of the thread specified by
1143- INFO. */
1144-
1145-static char *
1146-inf_ttrace_extra_thread_info (struct target_ops *self,
1147- struct thread_info *info)
1148-{
1149- struct inf_ttrace_private_thread_info* priv =
1150- (struct inf_ttrace_private_thread_info *) info->priv;
1151-
1152- if (priv != NULL && priv->dying)
1153- return "Exiting";
1154-
1155- return NULL;
1156-}
1157-
1158-static char *
1159-inf_ttrace_pid_to_str (struct target_ops *ops, ptid_t ptid)
1160-{
1161- pid_t pid = ptid_get_pid (ptid);
1162- lwpid_t lwpid = ptid_get_lwp (ptid);
1163- static char buf[128];
1164-
1165- if (lwpid == 0)
1166- xsnprintf (buf, sizeof buf, "process %ld",
1167- (long) pid);
1168- else
1169- xsnprintf (buf, sizeof buf, "process %ld, lwp %ld",
1170- (long) pid, (long) lwpid);
1171- return buf;
1172-}
1173-
1174-
1175-/* Implement the get_ada_task_ptid target_ops method. */
1176-
1177-static ptid_t
1178-inf_ttrace_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
1179-{
1180- return ptid_build (ptid_get_pid (inferior_ptid), lwp, 0);
1181-}
1182-
1183-
1184-struct target_ops *
1185-inf_ttrace_target (void)
1186-{
1187- struct target_ops *t = inf_child_target ();
1188-
1189- t->to_attach = inf_ttrace_attach;
1190- t->to_detach = inf_ttrace_detach;
1191- t->to_resume = inf_ttrace_resume;
1192- t->to_wait = inf_ttrace_wait;
1193- t->to_files_info = inf_ttrace_files_info;
1194- t->to_can_use_hw_breakpoint = inf_ttrace_can_use_hw_breakpoint;
1195- t->to_insert_watchpoint = inf_ttrace_insert_watchpoint;
1196- t->to_remove_watchpoint = inf_ttrace_remove_watchpoint;
1197- t->to_stopped_by_watchpoint = inf_ttrace_stopped_by_watchpoint;
1198- t->to_region_ok_for_hw_watchpoint =
1199- inf_ttrace_region_ok_for_hw_watchpoint;
1200- t->to_kill = inf_ttrace_kill;
1201- t->to_create_inferior = inf_ttrace_create_inferior;
1202- t->to_follow_fork = inf_ttrace_follow_fork;
1203- t->to_mourn_inferior = inf_ttrace_mourn_inferior;
1204- t->to_thread_alive = inf_ttrace_thread_alive;
1205- t->to_extra_thread_info = inf_ttrace_extra_thread_info;
1206- t->to_pid_to_str = inf_ttrace_pid_to_str;
1207- t->to_xfer_partial = inf_ttrace_xfer_partial;
1208- t->to_get_ada_task_ptid = inf_ttrace_get_ada_task_ptid;
1209-
1210- return t;
1211-}
1212-#endif
1213-
1214-
1215-/* Prevent warning from -Wmissing-prototypes. */
1216-void _initialize_inf_ttrace (void);
1217-
1218-void
1219-_initialize_inf_ttrace (void)
1220-{
1221-#ifdef HAVE_TTRACE
1222- inf_ttrace_page_dict.pagesize = getpagesize();
1223-#endif
1224-}
--- a/gdb/inf-ttrace.h
+++ /dev/null
@@ -1,28 +0,0 @@
1-/* Low-level child interface to ttrace.
2-
3- Copyright (C) 2004-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#ifndef INF_TTRACE_H
21-#define INF_TTRACE_H
22-
23-/* Create a prototype ttrace target. The client can override it with
24- local methods. */
25-
26-extern struct target_ops *inf_ttrace_target (void);
27-
28-#endif
--- a/gdb/solib-ia64-hpux.c
+++ /dev/null
@@ -1,705 +0,0 @@
1-/* Copyright (C) 2010-2015 Free Software Foundation, Inc.
2-
3- This file is part of GDB.
4-
5- This program is free software; you can redistribute it and/or modify
6- it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 3 of the License, or
8- (at your option) any later version.
9-
10- This program is distributed in the hope that it will be useful,
11- but WITHOUT ANY WARRANTY; without even the implied warranty of
12- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13- GNU General Public License for more details.
14-
15- You should have received a copy of the GNU General Public License
16- along with this program. If not, see <http://www.gnu.org/licenses/>. */
17-
18-#include "defs.h"
19-#include "ia64-tdep.h"
20-#include "ia64-hpux-tdep.h"
21-#include "solib-ia64-hpux.h"
22-#include "solist.h"
23-#include "solib.h"
24-#include "target.h"
25-#include "gdbtypes.h"
26-#include "inferior.h"
27-#include "gdbcore.h"
28-#include "regcache.h"
29-#include "opcode/ia64.h"
30-#include "symfile.h"
31-#include "objfiles.h"
32-#include "elf-bfd.h"
33-
34-/* Need to define the following macro in order to get the complete
35- load_module_desc struct definition in dlfcn.h Otherwise, it doesn't
36- match the size of the struct the loader is providing us during load
37- events. */
38-#define _LOAD_MODULE_DESC_EXT
39-
40-#include <sys/ttrace.h>
41-#include <dlfcn.h>
42-#include <elf.h>
43-#include <service_mgr.h>
44-
45-/* The following is to have access to the definition of type load_info_t. */
46-#include <crt0.h>
47-
48-/* The r32 pseudo-register number.
49-
50- Like all stacked registers, r32 is treated as a pseudo-register,
51- because it is not always available for read/write via the ttrace
52- interface. */
53-/* This is a bit of a hack, as we duplicate something hidden inside
54- ia64-tdep.c, but oh well... */
55-#define IA64_R32_PSEUDO_REGNUM (IA64_NAT127_REGNUM + 2)
56-
57-/* Our struct so_list private data structure. */
58-
59-struct lm_info
60-{
61- /* The shared library module descriptor. We extract this structure
62- from the loader at the time the shared library gets mapped. */
63- struct load_module_desc module_desc;
64-
65- /* The text segment address as defined in the shared library object
66- (this is not the address where this segment got loaded). This
67- field is initially set to zero, and computed lazily. */
68- CORE_ADDR text_start;
69-
70- /* The data segment address as defined in the shared library object
71- (this is not the address where this segment got loaded). This
72- field is initially set to zero, and computed lazily. */
73- CORE_ADDR data_start;
74-};
75-
76-/* The list of shared libraries currently mapped by the inferior. */
77-
78-static struct so_list *so_list_head = NULL;
79-
80-/* Create a new so_list element. The result should be deallocated
81- when no longer in use. */
82-
83-static struct so_list *
84-new_so_list (char *so_name, struct load_module_desc module_desc)
85-{
86- struct so_list *new_so;
87-
88- new_so = (struct so_list *) XCNEW (struct so_list);
89- new_so->lm_info = (struct lm_info *) XCNEW (struct lm_info);
90- new_so->lm_info->module_desc = module_desc;
91-
92- strncpy (new_so->so_name, so_name, SO_NAME_MAX_PATH_SIZE - 1);
93- new_so->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
94- strcpy (new_so->so_original_name, new_so->so_name);
95-
96- return new_so;
97-}
98-
99-/* Return non-zero if the instruction at the current PC is a breakpoint
100- part of the dynamic loading process.
101-
102- We identify such instructions by checking that the instruction at
103- the current pc is a break insn where no software breakpoint has been
104- inserted by us. We also verify that the operands have specific
105- known values, to be extra certain.
106-
107- PTID is the ptid of the thread that should be checked, but this
108- function also assumes that inferior_ptid is already equal to PTID.
109- Ideally, we would like to avoid the requirement on inferior_ptid,
110- but many routines still use the inferior_ptid global to access
111- the relevant thread's register and memory. We still have the ptid
112- as parameter to be able to pass it to the routines that do take a ptid
113- - that way we avoid increasing explicit uses of the inferior_ptid
114- global. */
115-
116-static int
117-ia64_hpux_at_dld_breakpoint_1_p (ptid_t ptid)
118-{
119- struct regcache *regcache = get_thread_regcache (ptid);
120- CORE_ADDR pc = regcache_read_pc (regcache);
121- struct address_space *aspace = get_regcache_aspace (regcache);
122- ia64_insn t0, t1, slot[3], templ, insn;
123- int slotnum;
124- bfd_byte bundle[16];
125-
126- /* If this is a regular breakpoint, then it can not be a dld one. */
127- if (breakpoint_inserted_here_p (aspace, pc))
128- return 0;
129-
130- slotnum = ((long) pc) & 0xf;
131- if (slotnum > 2)
132- internal_error (__FILE__, __LINE__,
133- "invalid slot (%d) for address %s", slotnum,
134- paddress (get_regcache_arch (regcache), pc));
135-
136- pc -= (pc & 0xf);
137- read_memory (pc, bundle, sizeof (bundle));
138-
139- /* bundles are always in little-endian byte order */
140- t0 = bfd_getl64 (bundle);
141- t1 = bfd_getl64 (bundle + 8);
142- templ = (t0 >> 1) & 0xf;
143- slot[0] = (t0 >> 5) & 0x1ffffffffffLL;
144- slot[1] = ((t0 >> 46) & 0x3ffff) | ((t1 & 0x7fffff) << 18);
145- slot[2] = (t1 >> 23) & 0x1ffffffffffLL;
146-
147- if (templ == 2 && slotnum == 1)
148- {
149- /* skip L slot in MLI template: */
150- slotnum = 2;
151- }
152-
153- insn = slot[slotnum];
154-
155- return (insn == 0x1c0c9c0 /* break.i 0x070327 */
156- || insn == 0x3c0c9c0); /* break.i 0x0f0327 */
157-}
158-
159-/* Same as ia64_hpux_at_dld_breakpoint_1_p above, with the following
160- differences: It temporarily sets inferior_ptid to PTID, and also
161- contains any exception being raised. */
162-
163-int
164-ia64_hpux_at_dld_breakpoint_p (ptid_t ptid)
165-{
166- ptid_t saved_ptid = inferior_ptid;
167- int result = 0;
168-
169- inferior_ptid = ptid;
170- TRY
171- {
172- result = ia64_hpux_at_dld_breakpoint_1_p (ptid);
173- }
174- inferior_ptid = saved_ptid;
175- CATCH (e, RETURN_MASK_ALL)
176- {
177- warning (_("error while checking for dld breakpoint: %s"), e.message);
178- }
179- END_CATCH
180-
181- return result;
182-}
183-
184-/* Handler for library load event: Read the information provided by
185- the loader, and then use it to read the shared library symbols. */
186-
187-static void
188-ia64_hpux_handle_load_event (struct regcache *regcache)
189-{
190- CORE_ADDR module_desc_addr;
191- ULONGEST module_desc_size;
192- CORE_ADDR so_path_addr;
193- char so_path[PATH_MAX];
194- struct load_module_desc module_desc;
195- struct so_list *new_so;
196-
197- /* Extract the data provided by the loader as follow:
198- - r33: Address of load_module_desc structure
199- - r34: size of struct load_module_desc
200- - r35: Address of string holding shared library path
201- */
202- regcache_cooked_read_unsigned (regcache, IA64_R32_PSEUDO_REGNUM + 1,
203- &module_desc_addr);
204- regcache_cooked_read_unsigned (regcache, IA64_R32_PSEUDO_REGNUM + 2,
205- &module_desc_size);
206- regcache_cooked_read_unsigned (regcache, IA64_R32_PSEUDO_REGNUM + 3,
207- &so_path_addr);
208-
209- if (module_desc_size != sizeof (struct load_module_desc))
210- warning (_("load_module_desc size (%ld) != size returned by kernel (%s)"),
211- sizeof (struct load_module_desc),
212- pulongest (module_desc_size));
213-
214- read_memory_string (so_path_addr, so_path, PATH_MAX);
215- read_memory (module_desc_addr, (gdb_byte *) &module_desc,
216- sizeof (module_desc));
217-
218- /* Create a new so_list element and insert it at the start of our
219- so_list_head (we insert at the start of the list only because
220- it is less work compared to inserting it elsewhere). */
221- new_so = new_so_list (so_path, module_desc);
222- new_so->next = so_list_head;
223- so_list_head = new_so;
224-}
225-
226-/* Update the value of the PC to point to the begining of the next
227- instruction bundle. */
228-
229-static void
230-ia64_hpux_move_pc_to_next_bundle (struct regcache *regcache)
231-{
232- CORE_ADDR pc = regcache_read_pc (regcache);
233-
234- pc -= pc & 0xf;
235- pc += 16;
236- ia64_write_pc (regcache, pc);
237-}
238-
239-/* Handle loader events.
240-
241- PTID is the ptid of the thread corresponding to the event being
242- handled. Similarly to ia64_hpux_at_dld_breakpoint_1_p, this
243- function assumes that inferior_ptid is set to PTID. */
244-
245-static void
246-ia64_hpux_handle_dld_breakpoint_1 (ptid_t ptid)
247-{
248- struct regcache *regcache = get_thread_regcache (ptid);
249- ULONGEST arg0;
250-
251- /* The type of event is provided by the loaded via r32. */
252- regcache_cooked_read_unsigned (regcache, IA64_R32_PSEUDO_REGNUM, &arg0);
253- switch (arg0)
254- {
255- case BREAK_DE_SVC_LOADED:
256- /* Currently, the only service loads are uld and dld,
257- so we shouldn't need to do anything. Just ignore. */
258- break;
259- case BREAK_DE_LIB_LOADED:
260- ia64_hpux_handle_load_event (regcache);
261- solib_add (NULL, 0, &current_target, auto_solib_add);
262- break;
263- case BREAK_DE_LIB_UNLOADED:
264- case BREAK_DE_LOAD_COMPLETE:
265- case BREAK_DE_BOR:
266- /* Ignore for now. */
267- break;
268- }
269-
270- /* Now that we have handled the event, we can move the PC to
271- the next instruction bundle, past the break instruction. */
272- ia64_hpux_move_pc_to_next_bundle (regcache);
273-}
274-
275-/* Same as ia64_hpux_handle_dld_breakpoint_1 above, with the following
276- differences: This function temporarily sets inferior_ptid to PTID,
277- and also contains any exception. */
278-
279-void
280-ia64_hpux_handle_dld_breakpoint (ptid_t ptid)
281-{
282- ptid_t saved_ptid = inferior_ptid;
283-
284- inferior_ptid = ptid;
285- TRY
286- {
287- ia64_hpux_handle_dld_breakpoint_1 (ptid);
288- }
289- inferior_ptid = saved_ptid;
290- CATCH (e, RETURN_MASK_ALL)
291- {
292- warning (_("error detected while handling dld breakpoint: %s"), e.message);
293- }
294- END_CATCH
295-}
296-
297-/* Find the address of the code and data segments in ABFD, and update
298- TEXT_START and DATA_START accordingly. */
299-
300-static void
301-ia64_hpux_find_start_vma (bfd *abfd, CORE_ADDR *text_start,
302- CORE_ADDR *data_start)
303-{
304- Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
305- Elf64_Phdr phdr;
306- int i;
307-
308- *text_start = 0;
309- *data_start = 0;
310-
311- if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) == -1)
312- error (_("invalid program header offset in %s"), abfd->filename);
313-
314- for (i = 0; i < i_ehdrp->e_phnum; i++)
315- {
316- if (bfd_bread (&phdr, sizeof (phdr), abfd) != sizeof (phdr))
317- error (_("failed to read segment %d in %s"), i, abfd->filename);
318-
319- if (phdr.p_flags & PF_X
320- && (*text_start == 0 || phdr.p_vaddr < *text_start))
321- *text_start = phdr.p_vaddr;
322-
323- if (phdr.p_flags & PF_W
324- && (*data_start == 0 || phdr.p_vaddr < *data_start))
325- *data_start = phdr.p_vaddr;
326- }
327-}
328-
329-/* The "relocate_section_addresses" target_so_ops routine for ia64-hpux. */
330-
331-static void
332-ia64_hpux_relocate_section_addresses (struct so_list *so,
333- struct target_section *sec)
334-{
335- CORE_ADDR offset = 0;
336-
337- /* If we haven't computed the text & data segment addresses, do so now.
338- We do this here, because we now have direct access to the associated
339- bfd, whereas we would have had to open our own if we wanted to do it
340- while processing the library-load event. */
341- if (so->lm_info->text_start == 0 && so->lm_info->data_start == 0)
342- ia64_hpux_find_start_vma (sec->the_bfd_section->owner,
343- &so->lm_info->text_start,
344- &so->lm_info->data_start);
345-
346- /* Determine the relocation offset based on which segment
347- the section belongs to. */
348- if ((so->lm_info->text_start < so->lm_info->data_start
349- && sec->addr < so->lm_info->data_start)
350- || (so->lm_info->text_start > so->lm_info->data_start
351- && sec->addr >= so->lm_info->text_start))
352- offset = so->lm_info->module_desc.text_base - so->lm_info->text_start;
353- else if ((so->lm_info->text_start < so->lm_info->data_start
354- && sec->addr >= so->lm_info->data_start)
355- || (so->lm_info->text_start > so->lm_info->data_start
356- && sec->addr < so->lm_info->text_start))
357- offset = so->lm_info->module_desc.data_base - so->lm_info->data_start;
358-
359- /* And now apply the relocation. */
360- sec->addr += offset;
361- sec->endaddr += offset;
362-
363- /* Best effort to set addr_high/addr_low. This is used only by
364- 'info sharedlibrary'. */
365- if (so->addr_low == 0 || sec->addr < so->addr_low)
366- so->addr_low = sec->addr;
367-
368- if (so->addr_high == 0 || sec->endaddr > so->addr_high)
369- so->addr_high = sec->endaddr;
370-}
371-
372-/* The "free_so" target_so_ops routine for ia64-hpux. */
373-
374-static void
375-ia64_hpux_free_so (struct so_list *so)
376-{
377- xfree (so->lm_info);
378-}
379-
380-/* The "clear_solib" target_so_ops routine for ia64-hpux. */
381-
382-static void
383-ia64_hpux_clear_solib (void)
384-{
385- struct so_list *so;
386-
387- while (so_list_head != NULL)
388- {
389- so = so_list_head;
390- so_list_head = so_list_head->next;
391-
392- ia64_hpux_free_so (so);
393- xfree (so);
394- }
395-}
396-
397-/* Assuming the inferior just stopped on an EXEC event, return
398- the address of the load_info_t structure. */
399-
400-static CORE_ADDR
401-ia64_hpux_get_load_info_addr (void)
402-{
403- struct type *data_ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
404- CORE_ADDR addr;
405- int status;
406-
407- /* The address of the load_info_t structure is stored in the 4th
408- argument passed to the initial thread of the process (in other
409- words, in argv[3]). So get the address of these arguments,
410- and extract the 4th one. */
411- status = ttrace (TT_PROC_GET_ARGS, ptid_get_pid (inferior_ptid),
412- 0, (uintptr_t) &addr, sizeof (CORE_ADDR), 0);
413- if (status == -1 && errno)
414- perror_with_name (_("Unable to get argument list"));
415- return (read_memory_typed_address (addr + 3 * 8, data_ptr_type));
416-}
417-
418-/* A structure used to aggregate some information extracted from
419- the dynamic section of the main executable. */
420-
421-struct dld_info
422-{
423- ULONGEST dld_flags;
424- CORE_ADDR load_map;
425-};
426-
427-/* Scan the ".dynamic" section referenced by ABFD and DYN_SECT,
428- and extract the information needed to fill in INFO. */
429-
430-static void
431-ia64_hpux_read_dynamic_info (struct gdbarch *gdbarch, bfd *abfd,
432- asection *dyn_sect, struct dld_info *info)
433-{
434- int sect_size;
435- char *buf;
436- char *buf_end;
437-
438- /* Make sure that info always has initialized data, even if we fail
439- to read the syn_sect section. */
440- memset (info, 0, sizeof (struct dld_info));
441-
442- sect_size = bfd_section_size (abfd, dyn_sect);
443- buf = alloca (sect_size);
444- buf_end = buf + sect_size;
445-
446- if (bfd_seek (abfd, dyn_sect->filepos, SEEK_SET) != 0
447- || bfd_bread (buf, sect_size, abfd) != sect_size)
448- error (_("failed to read contents of .dynamic section"));
449-
450- for (; buf < buf_end; buf += sizeof (Elf64_Dyn))
451- {
452- Elf64_Dyn *dynp = (Elf64_Dyn *) buf;
453- Elf64_Sxword d_tag;
454-
455- d_tag = bfd_h_get_64 (abfd, &dynp->d_tag);
456- switch (d_tag)
457- {
458- case DT_HP_DLD_FLAGS:
459- info->dld_flags = bfd_h_get_64 (abfd, &dynp->d_un);
460- break;
461-
462- case DT_HP_LOAD_MAP:
463- {
464- CORE_ADDR load_map_addr = bfd_h_get_64 (abfd, &dynp->d_un.d_ptr);
465-
466- if (target_read_memory (load_map_addr,
467- (gdb_byte *) &info->load_map,
468- sizeof (info->load_map)) != 0)
469- error (_("failed to read load map at %s"),
470- paddress (gdbarch, load_map_addr));
471- }
472- break;
473- }
474- }
475-}
476-
477-/* Wrapper around target_read_memory used with libdl. */
478-
479-static void *
480-ia64_hpux_read_tgt_mem (void *buffer, uint64_t ptr, size_t bufsiz, int ident)
481-{
482- if (target_read_memory (ptr, (gdb_byte *) buffer, bufsiz) != 0)
483- return 0;
484- else
485- return buffer;
486-}
487-
488-/* Create a new so_list object for a shared library, and store that
489- new so_list object in our SO_LIST_HEAD list.
490-
491- SO_INDEX is an index specifying the placement of the loaded shared
492- library in the dynamic loader's search list. Normally, this index
493- is strictly positive, but an index of -1 refers to the loader itself.
494-
495- Return nonzero if the so_list object could be created. A null
496- return value with a positive SO_INDEX normally means that there are
497- no more entries in the dynamic loader's search list at SO_INDEX or
498- beyond. */
499-
500-static int
501-ia64_hpux_add_so_from_dld_info (struct dld_info info, int so_index)
502-{
503- struct load_module_desc module_desc;
504- uint64_t so_handle;
505- char *so_path;
506- struct so_list *so;
507-
508- so_handle = dlgetmodinfo (so_index, &module_desc, sizeof (module_desc),
509- ia64_hpux_read_tgt_mem, 0, info.load_map);
510-
511- if (so_handle == 0)
512- /* No such entry. We probably reached the end of the list. */
513- return 0;
514-
515- so_path = dlgetname (&module_desc, sizeof (module_desc),
516- ia64_hpux_read_tgt_mem, 0, info.load_map);
517- if (so_path == NULL)
518- {
519- /* Should never happen, but let's not crash if it does. */
520- warning (_("unable to get shared library name, symbols not loaded"));
521- return 0;
522- }
523-
524- /* Create a new so_list and insert it at the start of our list.
525- The order is not extremely important, but it's less work to do so
526- at the end of the list. */
527- so = new_so_list (so_path, module_desc);
528- so->next = so_list_head;
529- so_list_head = so;
530-
531- return 1;
532-}
533-
534-/* Assuming we just attached to a process, update our list of shared
535- libraries (SO_LIST_HEAD) as well as GDB's list. */
536-
537-static void
538-ia64_hpux_solib_add_after_attach (void)
539-{
540- bfd *abfd;
541- asection *dyn_sect;
542- struct dld_info info;
543- int i;
544-
545- if (symfile_objfile == NULL)
546- return;
547-
548- abfd = symfile_objfile->obfd;
549- dyn_sect = bfd_get_section_by_name (abfd, ".dynamic");
550-
551- if (dyn_sect == NULL || bfd_section_size (abfd, dyn_sect) == 0)
552- return;
553-
554- ia64_hpux_read_dynamic_info (get_objfile_arch (symfile_objfile), abfd,
555- dyn_sect, &info);
556-
557- if ((info.dld_flags & DT_HP_DEBUG_PRIVATE) == 0)
558- {
559- warning (_(
560-"The shared libraries were not privately mapped; setting a breakpoint\n\
561-in a shared library will not work until you rerun the program.\n\
562-Use the following command to enable debugging of shared libraries.\n\
563-chatr +dbg enable a.out"));
564- }
565-
566- /* Read the symbols of the dynamic loader (dld.so). */
567- ia64_hpux_add_so_from_dld_info (info, -1);
568-
569- /* Read the symbols of all the other shared libraries. */
570- for (i = 1; ; i++)
571- if (!ia64_hpux_add_so_from_dld_info (info, i))
572- break; /* End of list. */
573-
574- /* Resync the library list at the core level. */
575- solib_add (NULL, 1, &current_target, auto_solib_add);
576-}
577-
578-/* The "create_inferior_hook" target_so_ops routine for ia64-hpux. */
579-
580-static void
581-ia64_hpux_solib_create_inferior_hook (int from_tty)
582-{
583- CORE_ADDR load_info_addr;
584- load_info_t load_info;
585-
586- /* Initially, we were thinking about adding a check that the program
587- (accessible through symfile_objfile) was linked against some shared
588- libraries, by searching for a ".dynamic" section. However, could
589- this break in the case of a statically linked program that later
590- uses dlopen? Programs that are fully statically linked are very
591- rare, and we will worry about them when we encounter one that
592- causes trouble. */
593-
594- /* Set the LI_TRACE flag in the load_info_t structure. This enables
595- notifications when shared libraries are being mapped. */
596- load_info_addr = ia64_hpux_get_load_info_addr ();
597- read_memory (load_info_addr, (gdb_byte *) &load_info, sizeof (load_info));
598- load_info.li_flags |= LI_TRACE;
599- write_memory (load_info_addr, (gdb_byte *) &load_info, sizeof (load_info));
600-
601- /* If we just attached to our process, some shard libraries have
602- already been mapped. Find which ones they are... */
603- if (current_inferior ()->attach_flag)
604- ia64_hpux_solib_add_after_attach ();
605-}
606-
607-/* The "special_symbol_handling" target_so_ops routine for ia64-hpux. */
608-
609-static void
610-ia64_hpux_special_symbol_handling (void)
611-{
612- /* Nothing to do. */
613-}
614-
615-/* The "current_sos" target_so_ops routine for ia64-hpux. */
616-
617-static struct so_list *
618-ia64_hpux_current_sos (void)
619-{
620- /* Return a deep copy of our own list. */
621- struct so_list *new_head = NULL, *prev_new_so = NULL;
622- struct so_list *our_so;
623-
624- for (our_so = so_list_head; our_so != NULL; our_so = our_so->next)
625- {
626- struct so_list *new_so;
627-
628- new_so = new_so_list (our_so->so_name, our_so->lm_info->module_desc);
629- if (prev_new_so != NULL)
630- prev_new_so->next = new_so;
631- prev_new_so = new_so;
632- if (new_head == NULL)
633- new_head = new_so;
634- }
635-
636- return new_head;
637-}
638-
639-/* The "open_symbol_file_object" target_so_ops routine for ia64-hpux. */
640-
641-static int
642-ia64_hpux_open_symbol_file_object (void *from_ttyp)
643-{
644- return 0;
645-}
646-
647-/* The "in_dynsym_resolve_code" target_so_ops routine for ia64-hpux. */
648-
649-static int
650-ia64_hpux_in_dynsym_resolve_code (CORE_ADDR pc)
651-{
652- return 0;
653-}
654-
655-/* If FADDR is the address of a function inside one of the shared
656- libraries, return the shared library linkage address. */
657-
658-CORE_ADDR
659-ia64_hpux_get_solib_linkage_addr (CORE_ADDR faddr)
660-{
661- struct so_list *so = so_list_head;
662-
663- while (so != NULL)
664- {
665- struct load_module_desc module_desc = so->lm_info->module_desc;
666-
667- if (module_desc.text_base <= faddr
668- && (module_desc.text_base + module_desc.text_size) > faddr)
669- return module_desc.linkage_ptr;
670-
671- so = so->next;
672- }
673-
674- return 0;
675-}
676-
677-/* Create a new target_so_ops structure suitable for ia64-hpux, and
678- return its address. */
679-
680-static struct target_so_ops *
681-ia64_hpux_target_so_ops (void)
682-{
683- struct target_so_ops *ops = XCNEW (struct target_so_ops);
684-
685- ops->relocate_section_addresses = ia64_hpux_relocate_section_addresses;
686- ops->free_so = ia64_hpux_free_so;
687- ops->clear_solib = ia64_hpux_clear_solib;
688- ops->solib_create_inferior_hook = ia64_hpux_solib_create_inferior_hook;
689- ops->special_symbol_handling = ia64_hpux_special_symbol_handling;
690- ops->current_sos = ia64_hpux_current_sos;
691- ops->open_symbol_file_object = ia64_hpux_open_symbol_file_object;
692- ops->in_dynsym_resolve_code = ia64_hpux_in_dynsym_resolve_code;
693- ops->bfd_open = solib_bfd_open;
694-
695- return ops;
696-}
697-
698-/* Prevent warning from -Wmissing-prototypes. */
699-void _initialize_solib_ia64_hpux (void);
700-
701-void
702-_initialize_solib_ia64_hpux (void)
703-{
704- ia64_hpux_so_ops = ia64_hpux_target_so_ops ();
705-}
--- a/gdb/solib-ia64-hpux.h
+++ /dev/null
@@ -1,25 +0,0 @@
1-/* Copyright (C) 2010-2015 Free Software Foundation, Inc.
2-
3- This file is part of GDB.
4-
5- This program is free software; you can redistribute it and/or modify
6- it under the terms of the GNU General Public License as published by
7- the Free Software Foundation; either version 3 of the License, or
8- (at your option) any later version.
9-
10- This program is distributed in the hope that it will be useful,
11- but WITHOUT ANY WARRANTY; without even the implied warranty of
12- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13- GNU General Public License for more details.
14-
15- You should have received a copy of the GNU General Public License
16- along with this program. If not, see <http://www.gnu.org/licenses/>. */
17-
18-#ifndef SOLIB_IA64_HPUX_H
19-#define SOLIB_IA64_HPUX_H
20-
21-int ia64_hpux_at_dld_breakpoint_p (ptid_t ptid);
22-void ia64_hpux_handle_dld_breakpoint (ptid_t ptid);
23-CORE_ADDR ia64_hpux_get_solib_linkage_addr (CORE_ADDR faddr);
24-
25-#endif
--- a/gdb/solib-pa64.c
+++ /dev/null
@@ -1,654 +0,0 @@
1-/* Handle PA64 shared libraries for GDB, the GNU Debugger.
2-
3- Copyright (C) 2004-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-/* HP in their infinite stupidity choose not to use standard ELF dynamic
21- linker interfaces. They also choose not to make their ELF dymamic
22- linker interfaces compatible with the SOM dynamic linker. The
23- net result is we can not use either of the existing somsolib.c or
24- solib.c. What a crock.
25-
26- Even more disgusting. This file depends on functions provided only
27- in certain PA64 libraries. Thus this file is supposed to only be
28- used native. When will HP ever learn that they need to provide the
29- same functionality in all their libraries! */
30-
31-#include "defs.h"
32-#include "symtab.h"
33-#include "bfd.h"
34-#include "symfile.h"
35-#include "objfiles.h"
36-#include "gdbcore.h"
37-#include "target.h"
38-#include "inferior.h"
39-#include "regcache.h"
40-#include "gdb_bfd.h"
41-
42-#include "hppa-tdep.h"
43-#include "solist.h"
44-#include "solib.h"
45-#include "solib-pa64.h"
46-
47-#undef SOLIB_PA64_DBG
48-
49-/* We can build this file only when running natively on 64-bit HP/UX.
50- We check for that by checking for the elf_hp.h header file. */
51-#if defined(HAVE_ELF_HP_H) && defined(__LP64__)
52-
53-/* FIXME: kettenis/20041213: These includes should be eliminated. */
54-#include <dlfcn.h>
55-#include <elf.h>
56-#include <elf_hp.h>
57-
58-struct lm_info {
59- struct load_module_desc desc;
60- CORE_ADDR desc_addr;
61-};
62-
63-/* When adding fields, be sure to clear them in _initialize_pa64_solib. */
64-typedef struct
65- {
66- CORE_ADDR dld_flags_addr;
67- LONGEST dld_flags;
68- struct bfd_section *dyninfo_sect;
69- int have_read_dld_descriptor;
70- int is_valid;
71- CORE_ADDR load_map;
72- CORE_ADDR load_map_addr;
73- struct load_module_desc dld_desc;
74- }
75-dld_cache_t;
76-
77-static dld_cache_t dld_cache;
78-
79-static int read_dynamic_info (asection *dyninfo_sect,
80- dld_cache_t *dld_cache_p);
81-
82-static void
83-pa64_relocate_section_addresses (struct so_list *so,
84- struct target_section *sec)
85-{
86- asection *asec = sec->the_bfd_section;
87- CORE_ADDR load_offset;
88-
89- /* Relocate all the sections based on where they got loaded. */
90-
91- load_offset = bfd_section_vma (so->abfd, asec) - asec->filepos;
92-
93- if (asec->flags & SEC_CODE)
94- {
95- sec->addr += so->lm_info->desc.text_base - load_offset;
96- sec->endaddr += so->lm_info->desc.text_base - load_offset;
97- }
98- else if (asec->flags & SEC_DATA)
99- {
100- sec->addr += so->lm_info->desc.data_base - load_offset;
101- sec->endaddr += so->lm_info->desc.data_base - load_offset;
102- }
103-}
104-
105-static void
106-pa64_free_so (struct so_list *so)
107-{
108- xfree (so->lm_info);
109-}
110-
111-static void
112-pa64_clear_solib (void)
113-{
114-}
115-
116-/* Wrapper for target_read_memory for dlgetmodinfo. */
117-
118-static void *
119-pa64_target_read_memory (void *buffer, CORE_ADDR ptr, size_t bufsiz, int ident)
120-{
121- if (target_read_memory (ptr, buffer, bufsiz) != 0)
122- return 0;
123- return buffer;
124-}
125-
126-/* Read the dynamic linker's internal shared library descriptor.
127-
128- This must happen after dld starts running, so we can't do it in
129- read_dynamic_info. Record the fact that we have loaded the
130- descriptor. If the library is archive bound or the load map
131- hasn't been setup, then return zero; else return nonzero. */
132-
133-static int
134-read_dld_descriptor (void)
135-{
136- char *dll_path;
137- asection *dyninfo_sect;
138-
139- /* If necessary call read_dynamic_info to extract the contents of the
140- .dynamic section from the shared library. */
141- if (!dld_cache.is_valid)
142- {
143- if (symfile_objfile == NULL)
144- error (_("No object file symbols."));
145-
146- dyninfo_sect = bfd_get_section_by_name (symfile_objfile->obfd,
147- ".dynamic");
148- if (!dyninfo_sect)
149- {
150- return 0;
151- }
152-
153- if (!read_dynamic_info (dyninfo_sect, &dld_cache))
154- error (_("Unable to read in .dynamic section information."));
155- }
156-
157- /* Read the load map pointer. */
158- if (target_read_memory (dld_cache.load_map_addr,
159- (char *) &dld_cache.load_map,
160- sizeof (dld_cache.load_map))
161- != 0)
162- {
163- error (_("Error while reading in load map pointer."));
164- }
165-
166- if (!dld_cache.load_map)
167- return 0;
168-
169- /* Read in the dld load module descriptor. */
170- if (dlgetmodinfo (-1,
171- &dld_cache.dld_desc,
172- sizeof (dld_cache.dld_desc),
173- pa64_target_read_memory,
174- 0,
175- dld_cache.load_map)
176- == 0)
177- {
178- error (_("Error trying to get information about dynamic linker."));
179- }
180-
181- /* Indicate that we have loaded the dld descriptor. */
182- dld_cache.have_read_dld_descriptor = 1;
183-
184- return 1;
185-}
186-
187-
188-/* Read the .dynamic section and extract the information of interest,
189- which is stored in dld_cache. The routine elf_locate_base in solib.c
190- was used as a model for this. */
191-
192-static int
193-read_dynamic_info (asection *dyninfo_sect, dld_cache_t *dld_cache_p)
194-{
195- char *buf;
196- char *bufend;
197- CORE_ADDR dyninfo_addr;
198- int dyninfo_sect_size;
199- CORE_ADDR entry_addr;
200-
201- /* Read in .dynamic section, silently ignore errors. */
202- dyninfo_addr = bfd_section_vma (symfile_objfile->obfd, dyninfo_sect);
203- dyninfo_sect_size = bfd_section_size (exec_bfd, dyninfo_sect);
204- buf = alloca (dyninfo_sect_size);
205- if (target_read_memory (dyninfo_addr, buf, dyninfo_sect_size))
206- return 0;
207-
208- /* Scan the .dynamic section and record the items of interest.
209- In particular, DT_HP_DLD_FLAGS. */
210- for (bufend = buf + dyninfo_sect_size, entry_addr = dyninfo_addr;
211- buf < bufend;
212- buf += sizeof (Elf64_Dyn), entry_addr += sizeof (Elf64_Dyn))
213- {
214- Elf64_Dyn *x_dynp = (Elf64_Dyn*)buf;
215- Elf64_Sxword dyn_tag;
216- CORE_ADDR dyn_ptr;
217-
218- dyn_tag = bfd_h_get_64 (symfile_objfile->obfd,
219- (bfd_byte*) &x_dynp->d_tag);
220-
221- /* We can't use a switch here because dyn_tag is 64 bits and HP's
222- lame comiler does not handle 64bit items in switch statements. */
223- if (dyn_tag == DT_NULL)
224- break;
225- else if (dyn_tag == DT_HP_DLD_FLAGS)
226- {
227- /* Set dld_flags_addr and dld_flags in *dld_cache_p. */
228- dld_cache_p->dld_flags_addr = entry_addr + offsetof(Elf64_Dyn, d_un);
229- if (target_read_memory (dld_cache_p->dld_flags_addr,
230- (char*) &dld_cache_p->dld_flags,
231- sizeof (dld_cache_p->dld_flags))
232- != 0)
233- {
234- error (_("Error while reading in "
235- ".dynamic section of the program."));
236- }
237- }
238- else if (dyn_tag == DT_HP_LOAD_MAP)
239- {
240- /* Dld will place the address of the load map at load_map_addr
241- after it starts running. */
242- if (target_read_memory (entry_addr + offsetof(Elf64_Dyn,
243- d_un.d_ptr),
244- (char*) &dld_cache_p->load_map_addr,
245- sizeof (dld_cache_p->load_map_addr))
246- != 0)
247- {
248- error (_("Error while reading in "
249- ".dynamic section of the program."));
250- }
251- }
252- else
253- {
254- /* Tag is not of interest. */
255- }
256- }
257-
258- /* Record other information and set is_valid to 1. */
259- dld_cache_p->dyninfo_sect = dyninfo_sect;
260-
261- /* Verify that we read in required info. These fields are re-set to zero
262- in pa64_solib_restart. */
263-
264- if (dld_cache_p->dld_flags_addr != 0 && dld_cache_p->load_map_addr != 0)
265- dld_cache_p->is_valid = 1;
266- else
267- return 0;
268-
269- return 1;
270-}
271-
272-/* Helper function for gdb_bfd_lookup_symbol_from_symtab. */
273-
274-static int
275-cmp_name (asymbol *sym, void *data)
276-{
277- return (strcmp (sym->name, (const char *) data) == 0);
278-}
279-
280-/* This hook gets called just before the first instruction in the
281- inferior process is executed.
282-
283- This is our opportunity to set magic flags in the inferior so
284- that GDB can be notified when a shared library is mapped in and
285- to tell the dynamic linker that a private copy of the library is
286- needed (so GDB can set breakpoints in the library).
287-
288- We need to set DT_HP_DEBUG_CALLBACK to indicate that we want the
289- dynamic linker to call the breakpoint routine for significant events.
290- We used to set DT_HP_DEBUG_PRIVATE to indicate that shared libraries
291- should be mapped private. However, this flag can be set using
292- "chatr +dbg enable". Not setting DT_HP_DEBUG_PRIVATE allows debugging
293- with shared libraries mapped shareable. */
294-
295-static void
296-pa64_solib_create_inferior_hook (int from_tty)
297-{
298- struct minimal_symbol *msymbol;
299- unsigned int dld_flags, status;
300- asection *shlib_info, *interp_sect;
301- struct objfile *objfile;
302- CORE_ADDR anaddr;
303-
304- if (symfile_objfile == NULL)
305- return;
306-
307- /* First see if the objfile was dynamically linked. */
308- shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, ".dynamic");
309- if (!shlib_info)
310- return;
311-
312- /* It's got a .dynamic section, make sure it's not empty. */
313- if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0)
314- return;
315-
316- /* Read in the .dynamic section. */
317- if (! read_dynamic_info (shlib_info, &dld_cache))
318- error (_("Unable to read the .dynamic section."));
319-
320- /* If the libraries were not mapped private, warn the user. */
321- if ((dld_cache.dld_flags & DT_HP_DEBUG_PRIVATE) == 0)
322- warning
323- (_("\
324-Private mapping of shared library text was not specified\n\
325-by the executable; setting a breakpoint in a shared library which\n\
326-is not privately mapped will not work. See the HP-UX 11i v3 chatr\n\
327-manpage for methods to privately map shared library text."));
328-
329- /* Turn on the flags we care about. */
330- dld_cache.dld_flags |= DT_HP_DEBUG_CALLBACK;
331- status = target_write_memory (dld_cache.dld_flags_addr,
332- (char *) &dld_cache.dld_flags,
333- sizeof (dld_cache.dld_flags));
334- if (status != 0)
335- error (_("Unable to modify dynamic linker flags."));
336-
337- /* Now we have to create a shared library breakpoint in the dynamic
338- linker. This can be somewhat tricky since the symbol is inside
339- the dynamic linker (for which we do not have symbols or a base
340- load address! Luckily I wrote this code for solib.c years ago. */
341- interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
342- if (interp_sect)
343- {
344- unsigned int interp_sect_size;
345- char *buf;
346- CORE_ADDR load_addr;
347- bfd *tmp_bfd;
348- CORE_ADDR sym_addr = 0;
349-
350- /* Read the contents of the .interp section into a local buffer;
351- the contents specify the dynamic linker this program uses. */
352- interp_sect_size = bfd_section_size (exec_bfd, interp_sect);
353- buf = alloca (interp_sect_size);
354- bfd_get_section_contents (exec_bfd, interp_sect,
355- buf, 0, interp_sect_size);
356-
357- /* Now we need to figure out where the dynamic linker was
358- loaded so that we can load its symbols and place a breakpoint
359- in the dynamic linker itself.
360-
361- This address is stored on the stack. However, I've been unable
362- to find any magic formula to find it for Solaris (appears to
363- be trivial on GNU/Linux). Therefore, we have to try an alternate
364- mechanism to find the dynamic linker's base address. */
365- tmp_bfd = gdb_bfd_open (buf, gnutarget, -1);
366- if (tmp_bfd == NULL)
367- return;
368-
369- /* Make sure the dynamic linker's really a useful object. */
370- if (!bfd_check_format (tmp_bfd, bfd_object))
371- {
372- warning (_("Unable to grok dynamic linker %s as an object file"),
373- buf);
374- gdb_bfd_unref (tmp_bfd);
375- return;
376- }
377-
378- /* We find the dynamic linker's base address by examining the
379- current pc (which point at the entry point for the dynamic
380- linker) and subtracting the offset of the entry point.
381-
382- Also note the breakpoint is the second instruction in the
383- routine. */
384- load_addr = regcache_read_pc (get_current_regcache ())
385- - tmp_bfd->start_address;
386- sym_addr = gdb_bfd_lookup_symbol_from_symtab (tmp_bfd, cmp_name,
387- "__dld_break");
388- sym_addr = load_addr + sym_addr + 4;
389-
390- /* Create the shared library breakpoint. */
391- {
392- struct breakpoint *b
393- = create_solib_event_breakpoint (target_gdbarch (), sym_addr);
394-
395- /* The breakpoint is actually hard-coded into the dynamic linker,
396- so we don't need to actually insert a breakpoint instruction
397- there. In fact, the dynamic linker's code is immutable, even to
398- ttrace, so we shouldn't even try to do that. For cases like
399- this, we have "permanent" breakpoints. */
400- make_breakpoint_permanent (b);
401- }
402-
403- /* We're done with the temporary bfd. */
404- gdb_bfd_unref (tmp_bfd);
405- }
406-}
407-
408-static void
409-pa64_special_symbol_handling (void)
410-{
411-}
412-
413-static struct so_list *
414-pa64_current_sos (void)
415-{
416- struct so_list *head = 0;
417- struct so_list **link_ptr = &head;
418- int dll_index;
419-
420- /* Read in the load map pointer if we have not done so already. */
421- if (! dld_cache.have_read_dld_descriptor)
422- if (! read_dld_descriptor ())
423- return NULL;
424-
425- for (dll_index = -1; ; dll_index++)
426- {
427- struct load_module_desc dll_desc;
428- char *dll_path;
429- struct so_list *newobj;
430- struct cleanup *old_chain;
431-
432- if (dll_index == 0)
433- continue;
434-
435- /* Read in the load module descriptor. */
436- if (dlgetmodinfo (dll_index, &dll_desc, sizeof (dll_desc),
437- pa64_target_read_memory, 0, dld_cache.load_map)
438- == 0)
439- break;
440-
441- /* Get the name of the shared library. */
442- dll_path = (char *)dlgetname (&dll_desc, sizeof (dll_desc),
443- pa64_target_read_memory,
444- 0, dld_cache.load_map);
445-
446- newobj = (struct so_list *) xmalloc (sizeof (struct so_list));
447- memset (newobj, 0, sizeof (struct so_list));
448- newobj->lm_info = (struct lm_info *) xmalloc (sizeof (struct lm_info));
449- memset (newobj->lm_info, 0, sizeof (struct lm_info));
450-
451- strncpy (newobj->so_name, dll_path, SO_NAME_MAX_PATH_SIZE - 1);
452- newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
453- strcpy (newobj->so_original_name, newobj->so_name);
454-
455- memcpy (&newobj->lm_info->desc, &dll_desc, sizeof (dll_desc));
456-
457-#ifdef SOLIB_PA64_DBG
458- {
459- struct load_module_desc *d = &newobj->lm_info->desc;
460-
461- printf ("\n+ library \"%s\" is described at index %d\n", newobj->so_name,
462- dll_index);
463- printf (" text_base = %s\n", hex_string (d->text_base));
464- printf (" text_size = %s\n", hex_string (d->text_size));
465- printf (" data_base = %s\n", hex_string (d->data_base));
466- printf (" data_size = %s\n", hex_string (d->data_size));
467- printf (" unwind_base = %s\n", hex_string (d->unwind_base));
468- printf (" linkage_ptr = %s\n", hex_string (d->linkage_ptr));
469- printf (" phdr_base = %s\n", hex_string (d->phdr_base));
470- printf (" tls_size = %s\n", hex_string (d->tls_size));
471- printf (" tls_start_addr = %s\n", hex_string (d->tls_start_addr));
472- printf (" unwind_size = %s\n", hex_string (d->unwind_size));
473- printf (" tls_index = %s\n", hex_string (d->tls_index));
474- }
475-#endif
476-
477- /* Link the new object onto the list. */
478- newobj->next = NULL;
479- *link_ptr = newobj;
480- link_ptr = &newobj->next;
481- }
482-
483- return head;
484-}
485-
486-static int
487-pa64_open_symbol_file_object (void *from_ttyp)
488-{
489- int from_tty = *(int *)from_ttyp;
490- struct load_module_desc dll_desc;
491- char *dll_path;
492-
493- if (symfile_objfile)
494- if (!query (_("Attempt to reload symbols from process? ")))
495- return 0;
496-
497- /* Read in the load map pointer if we have not done so already. */
498- if (! dld_cache.have_read_dld_descriptor)
499- if (! read_dld_descriptor ())
500- return 0;
501-
502- /* Read in the load module descriptor. */
503- if (dlgetmodinfo (0, &dll_desc, sizeof (dll_desc),
504- pa64_target_read_memory, 0, dld_cache.load_map) == 0)
505- return 0;
506-
507- /* Get the name of the shared library. */
508- dll_path = (char *)dlgetname (&dll_desc, sizeof (dll_desc),
509- pa64_target_read_memory,
510- 0, dld_cache.load_map);
511-
512- /* Have a pathname: read the symbol file. */
513- symbol_file_add_main (dll_path, from_tty);
514-
515- return 1;
516-}
517-
518-/* Return nonzero if PC is an address inside the dynamic linker. */
519-static int
520-pa64_in_dynsym_resolve_code (CORE_ADDR pc)
521-{
522- asection *shlib_info;
523-
524- if (symfile_objfile == NULL)
525- return 0;
526-
527- if (!dld_cache.have_read_dld_descriptor)
528- if (!read_dld_descriptor ())
529- return 0;
530-
531- return (pc >= dld_cache.dld_desc.text_base
532- && pc < dld_cache.dld_desc.text_base + dld_cache.dld_desc.text_size);
533-}
534-
535-
536-/* Return the GOT value for the shared library in which ADDR belongs. If
537- ADDR isn't in any known shared library, return zero. */
538-
539-static CORE_ADDR
540-pa64_solib_get_got_by_pc (CORE_ADDR addr)
541-{
542- struct so_list *so_list = master_so_list ();
543- CORE_ADDR got_value = 0;
544-
545- while (so_list)
546- {
547- if (so_list->lm_info->desc.text_base <= addr
548- && ((so_list->lm_info->desc.text_base
549- + so_list->lm_info->desc.text_size)
550- > addr))
551- {
552- got_value = so_list->lm_info->desc.linkage_ptr;
553- break;
554- }
555- so_list = so_list->next;
556- }
557- return got_value;
558-}
559-
560-/* Get some HPUX-specific data from a shared lib. */
561-static CORE_ADDR
562-pa64_solib_thread_start_addr (struct so_list *so)
563-{
564- return so->lm_info->desc.tls_start_addr;
565-}
566-
567-
568-/* Return the address of the handle of the shared library in which ADDR
569- belongs. If ADDR isn't in any known shared library, return zero. */
570-
571-static CORE_ADDR
572-pa64_solib_get_solib_by_pc (CORE_ADDR addr)
573-{
574- struct so_list *so_list = master_so_list ();
575- CORE_ADDR retval = 0;
576-
577- while (so_list)
578- {
579- if (so_list->lm_info->desc.text_base <= addr
580- && ((so_list->lm_info->desc.text_base
581- + so_list->lm_info->desc.text_size)
582- > addr))
583- {
584- retval = so_list->lm_info->desc_addr;
585- break;
586- }
587- so_list = so_list->next;
588- }
589- return retval;
590-}
591-
592-/* pa64 libraries do not seem to set the section offsets in a standard (i.e.
593- SVr4) way; the text section offset stored in the file doesn't correspond
594- to the place where the library is actually loaded into memory. Instead,
595- we rely on the dll descriptor to tell us where things were loaded. */
596-static CORE_ADDR
597-pa64_solib_get_text_base (struct objfile *objfile)
598-{
599- struct so_list *so;
600-
601- for (so = master_so_list (); so; so = so->next)
602- if (so->objfile == objfile)
603- return so->lm_info->desc.text_base;
604-
605- return 0;
606-}
607-
608-static struct target_so_ops pa64_so_ops;
609-
610-extern initialize_file_ftype _initialize_pa64_solib; /* -Wmissing-prototypes */
611-
612-void
613-_initialize_pa64_solib (void)
614-{
615- pa64_so_ops.relocate_section_addresses = pa64_relocate_section_addresses;
616- pa64_so_ops.free_so = pa64_free_so;
617- pa64_so_ops.clear_solib = pa64_clear_solib;
618- pa64_so_ops.solib_create_inferior_hook = pa64_solib_create_inferior_hook;
619- pa64_so_ops.special_symbol_handling = pa64_special_symbol_handling;
620- pa64_so_ops.current_sos = pa64_current_sos;
621- pa64_so_ops.open_symbol_file_object = pa64_open_symbol_file_object;
622- pa64_so_ops.in_dynsym_resolve_code = pa64_in_dynsym_resolve_code;
623- pa64_so_ops.bfd_open = solib_bfd_open;
624-
625- memset (&dld_cache, 0, sizeof (dld_cache));
626-}
627-
628-void pa64_solib_select (struct gdbarch *gdbarch)
629-{
630- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
631-
632- set_solib_ops (gdbarch, &pa64_so_ops);
633- tdep->solib_thread_start_addr = pa64_solib_thread_start_addr;
634- tdep->solib_get_got_by_pc = pa64_solib_get_got_by_pc;
635- tdep->solib_get_solib_by_pc = pa64_solib_get_solib_by_pc;
636- tdep->solib_get_text_base = pa64_solib_get_text_base;
637-}
638-
639-#else /* HAVE_ELF_HP_H */
640-
641-extern initialize_file_ftype _initialize_pa64_solib; /* -Wmissing-prototypes */
642-
643-void
644-_initialize_pa64_solib (void)
645-{
646-}
647-
648-void pa64_solib_select (struct gdbarch *gdbarch)
649-{
650- /* For a SOM-only target, there is no pa64 solib support. This is needed
651- for hppa-hpux-tdep.c to build. */
652- error (_("Cannot select pa64 solib support for this configuration."));
653-}
654-#endif
--- a/gdb/solib-pa64.h
+++ /dev/null
@@ -1,25 +0,0 @@
1-/* Handle PA64 shared libraries for GDB, the GNU Debugger.
2-
3- Copyright (C) 2004-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#ifndef SOLIB_PA64_H
21-#define SOLIB_PA64_H
22-
23-void pa64_solib_select (struct gdbarch *gdbarch);
24-
25-#endif
--- a/gdb/solib-som.c
+++ /dev/null
@@ -1,891 +0,0 @@
1-/* Handle SOM shared libraries.
2-
3- Copyright (C) 2004-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#include "defs.h"
21-#include "symtab.h"
22-#include "bfd.h"
23-#include "symfile.h"
24-#include "objfiles.h"
25-#include "gdbcore.h"
26-#include "target.h"
27-#include "inferior.h"
28-
29-#include "hppa-tdep.h"
30-#include "solist.h"
31-#include "solib.h"
32-#include "solib-som.h"
33-
34-#undef SOLIB_SOM_DBG
35-
36-/* These ought to be defined in some public interface, but aren't. They
37- define the meaning of the various bits in the distinguished __dld_flags
38- variable that is declared in every debuggable a.out on HP-UX, and that
39- is shared between the debugger and the dynamic linker. */
40-
41-#define DLD_FLAGS_MAPPRIVATE 0x1
42-#define DLD_FLAGS_HOOKVALID 0x2
43-#define DLD_FLAGS_LISTVALID 0x4
44-#define DLD_FLAGS_BOR_ENABLE 0x8
45-
46-struct lm_info
47- {
48- /* Version of this structure (it is expected to change again in
49- hpux10). */
50- unsigned char struct_version;
51-
52- /* Binding mode for this library. */
53- unsigned char bind_mode;
54-
55- /* Version of this library. */
56- short library_version;
57-
58- /* Start of text address,
59- link-time text location (length of text area),
60- end of text address. */
61- CORE_ADDR text_addr;
62- CORE_ADDR text_link_addr;
63- CORE_ADDR text_end;
64-
65- /* Start of data, start of bss and end of data. */
66- CORE_ADDR data_start;
67- CORE_ADDR bss_start;
68- CORE_ADDR data_end;
69-
70- /* Value of linkage pointer (%r19). */
71- CORE_ADDR got_value;
72-
73- /* Address in target of offset from thread-local register of
74- start of this thread's data. I.e., the first thread-local
75- variable in this shared library starts at *(tsd_start_addr)
76- from that area pointed to by cr27 (mpsfu_hi).
77-
78- We do the indirection as soon as we read it, so from then
79- on it's the offset itself. */
80- CORE_ADDR tsd_start_addr;
81-
82- /* Address of the link map entry in the loader. */
83- CORE_ADDR lm_addr;
84- };
85-
86-/* These addresses should be filled in by som_solib_create_inferior_hook.
87- They are also used elsewhere in this module. */
88-
89-typedef struct
90- {
91- CORE_ADDR address;
92- struct unwind_table_entry *unwind;
93- }
94-addr_and_unwind_t;
95-
96-/* When adding fields, be sure to clear them in _initialize_som_solib. */
97-static struct
98- {
99- int is_valid;
100- addr_and_unwind_t hook;
101- addr_and_unwind_t hook_stub;
102- addr_and_unwind_t load;
103- addr_and_unwind_t load_stub;
104- addr_and_unwind_t unload;
105- addr_and_unwind_t unload2;
106- addr_and_unwind_t unload_stub;
107- }
108-dld_cache;
109-
110-static void
111-som_relocate_section_addresses (struct so_list *so,
112- struct target_section *sec)
113-{
114- flagword aflag = bfd_get_section_flags(so->abfd, sec->the_bfd_section);
115-
116- if (aflag & SEC_CODE)
117- {
118- sec->addr += so->lm_info->text_addr - so->lm_info->text_link_addr;
119- sec->endaddr += so->lm_info->text_addr - so->lm_info->text_link_addr;
120- }
121- else if (aflag & SEC_DATA)
122- {
123- sec->addr += so->lm_info->data_start;
124- sec->endaddr += so->lm_info->data_start;
125- }
126- else
127- {
128- /* Nothing. */
129- }
130-}
131-
132-
133-/* Variable storing HP-UX major release number.
134-
135- On non-native system, simply assume that the major release number
136- is 11. On native systems, hppa-hpux-nat.c initialization code
137- sets this number to the real one on startup.
138-
139- We cannot compute this value here, because we need to make a native
140- call to "uname". We are are not allowed to do that from here, as
141- this file is used for both native and cross debugging. */
142-
143-#define DEFAULT_HPUX_MAJOR_RELEASE 11
144-int hpux_major_release = DEFAULT_HPUX_MAJOR_RELEASE;
145-
146-static int
147-get_hpux_major_release (void)
148-{
149- return hpux_major_release;
150-}
151-
152-/* DL header flag defines. */
153-#define SHLIB_TEXT_PRIVATE_ENABLE 0x4000
154-
155-/* The DL header is documented in <shl.h>. We are only interested
156- in the flags field to determine whether the executable wants shared
157- libraries mapped private. */
158-struct {
159- short junk[37];
160- short flags;
161-} dl_header;
162-
163-/* This hook gets called just before the first instruction in the
164- inferior process is executed.
165-
166- This is our opportunity to set magic flags in the inferior so
167- that GDB can be notified when a shared library is mapped in and
168- to tell the dynamic linker that a private copy of the library is
169- needed (so GDB can set breakpoints in the library).
170-
171- __dld_flags is the location of the magic flags; as of this implementation
172- there are 3 flags of interest:
173-
174- bit 0 when set indicates that private copies of the libraries are needed
175- bit 1 when set indicates that the callback hook routine is valid
176- bit 2 when set indicates that the dynamic linker should maintain the
177- __dld_list structure when loading/unloading libraries.
178-
179- Note that shared libraries are not mapped in at this time, so we have
180- run the inferior until the libraries are mapped in. Typically this
181- means running until the "_start" is called. */
182-
183-static void
184-som_solib_create_inferior_hook (int from_tty)
185-{
186- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
187- struct bound_minimal_symbol msymbol;
188- unsigned int dld_flags, status, have_endo;
189- asection *shlib_info;
190- gdb_byte buf[4];
191- CORE_ADDR anaddr;
192-
193- if (symfile_objfile == NULL)
194- return;
195-
196- /* First see if the objfile was dynamically linked. */
197- shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$");
198- if (!shlib_info)
199- return;
200-
201- /* It's got a $SHLIB_INFO$ section, make sure it's not empty. */
202- if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0)
203- return;
204-
205- /* Read the DL header. */
206- bfd_get_section_contents (symfile_objfile->obfd, shlib_info,
207- (char *) &dl_header, 0, sizeof (dl_header));
208-
209- have_endo = 0;
210- /* Slam the pid of the process into __d_pid.
211-
212- We used to warn when this failed, but that warning is only useful
213- on very old HP systems (hpux9 and older). The warnings are an
214- annoyance to users of modern systems and foul up the testsuite as
215- well. As a result, the warnings have been disabled. */
216- msymbol = lookup_minimal_symbol ("__d_pid", NULL, symfile_objfile);
217- if (msymbol.minsym == NULL)
218- goto keep_going;
219-
220- anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol);
221- store_unsigned_integer (buf, 4, byte_order, ptid_get_pid (inferior_ptid));
222- status = target_write_memory (anaddr, buf, 4);
223- if (status != 0)
224- {
225- warning (_("\
226-Unable to write __d_pid.\n\
227-Suggest linking with /opt/langtools/lib/end.o.\n\
228-GDB will be unable to track shl_load/shl_unload calls"));
229- goto keep_going;
230- }
231-
232- /* Get the value of _DLD_HOOK (an export stub) and put it in __dld_hook;
233- This will force the dynamic linker to call __d_trap when significant
234- events occur.
235-
236- Note that the above is the pre-HP-UX 9.0 behaviour. At 9.0 and above,
237- the dld provides an export stub named "__d_trap" as well as the
238- function named "__d_trap" itself, but doesn't provide "_DLD_HOOK".
239- We'll look first for the old flavor and then the new. */
240-
241- msymbol = lookup_minimal_symbol ("_DLD_HOOK", NULL, symfile_objfile);
242- if (msymbol.minsym == NULL)
243- msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile);
244- if (msymbol.minsym == NULL)
245- {
246- warning (_("\
247-Unable to find _DLD_HOOK symbol in object file.\n\
248-Suggest linking with /opt/langtools/lib/end.o.\n\
249-GDB will be unable to track shl_load/shl_unload calls"));
250- goto keep_going;
251- }
252- anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol);
253- dld_cache.hook.address = anaddr;
254-
255- /* Grrr, this might not be an export symbol! We have to find the
256- export stub. */
257- msymbol
258- = hppa_lookup_stub_minimal_symbol (MSYMBOL_LINKAGE_NAME (msymbol.minsym),
259- EXPORT);
260- if (msymbol.minsym != NULL)
261- {
262- anaddr = MSYMBOL_VALUE (msymbol.minsym);
263- dld_cache.hook_stub.address = anaddr;
264- }
265- store_unsigned_integer (buf, 4, byte_order, anaddr);
266-
267- msymbol = lookup_minimal_symbol ("__dld_hook", NULL, symfile_objfile);
268- if (msymbol.minsym == NULL)
269- {
270- warning (_("\
271-Unable to find __dld_hook symbol in object file.\n\
272-Suggest linking with /opt/langtools/lib/end.o.\n\
273-GDB will be unable to track shl_load/shl_unload calls"));
274- goto keep_going;
275- }
276- anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol);
277- status = target_write_memory (anaddr, buf, 4);
278-
279- /* Now set a shlib_event breakpoint at __d_trap so we can track
280- significant shared library events. */
281- msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile);
282- if (msymbol.minsym == NULL)
283- {
284- warning (_("\
285-Unable to find __dld_d_trap symbol in object file.\n\
286-Suggest linking with /opt/langtools/lib/end.o.\n\
287-GDB will be unable to track shl_load/shl_unload calls"));
288- goto keep_going;
289- }
290- create_solib_event_breakpoint (target_gdbarch (),
291- BMSYMBOL_VALUE_ADDRESS (msymbol));
292-
293- /* We have all the support usually found in end.o, so we can track
294- shl_load and shl_unload calls. */
295- have_endo = 1;
296-
297-keep_going:
298-
299- /* Get the address of __dld_flags, if no such symbol exists, then we can
300- not debug the shared code. */
301- msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
302- if (msymbol.minsym == NULL)
303- {
304- error (_("Unable to find __dld_flags symbol in object file."));
305- }
306-
307- anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol);
308-
309- /* Read the current contents. */
310- status = target_read_memory (anaddr, buf, 4);
311- if (status != 0)
312- error (_("Unable to read __dld_flags."));
313- dld_flags = extract_unsigned_integer (buf, 4, byte_order);
314-
315- /* If the libraries were not mapped private on HP-UX 11 and later, warn
316- the user. On HP-UX 10 and earlier, there is no easy way to specify
317- that shared libraries should be privately mapped. So, we just force
318- private mapping. */
319- if (get_hpux_major_release () >= 11
320- && (dl_header.flags & SHLIB_TEXT_PRIVATE_ENABLE) == 0
321- && (dld_flags & DLD_FLAGS_MAPPRIVATE) == 0)
322- warning
323- (_("\
324-Private mapping of shared library text was not specified\n\
325-by the executable; setting a breakpoint in a shared library which\n\
326-is not privately mapped will not work. See the HP-UX 11i v3 chatr\n\
327-manpage for methods to privately map shared library text."));
328-
329- /* Turn on the flags we care about. */
330- if (get_hpux_major_release () < 11)
331- dld_flags |= DLD_FLAGS_MAPPRIVATE;
332- if (have_endo)
333- dld_flags |= DLD_FLAGS_HOOKVALID;
334- store_unsigned_integer (buf, 4, byte_order, dld_flags);
335- status = target_write_memory (anaddr, buf, 4);
336- if (status != 0)
337- error (_("Unable to write __dld_flags."));
338-
339- /* Now find the address of _start and set a breakpoint there.
340- We still need this code for two reasons:
341-
342- * Not all sites have /opt/langtools/lib/end.o, so it's not always
343- possible to track the dynamic linker's events.
344-
345- * At this time no events are triggered for shared libraries
346- loaded at startup time (what a crock). */
347-
348- msymbol = lookup_minimal_symbol ("_start", NULL, symfile_objfile);
349- if (msymbol.minsym == NULL)
350- error (_("Unable to find _start symbol in object file."));
351-
352- anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol);
353-
354- /* Make the breakpoint at "_start" a shared library event breakpoint. */
355- create_solib_event_breakpoint (target_gdbarch (), anaddr);
356-
357- clear_symtab_users (0);
358-}
359-
360-static void
361-som_special_symbol_handling (void)
362-{
363-}
364-
365-static void
366-som_solib_desire_dynamic_linker_symbols (void)
367-{
368- struct objfile *objfile;
369- struct unwind_table_entry *u;
370- struct bound_minimal_symbol dld_msymbol;
371-
372- /* Do we already know the value of these symbols? If so, then
373- we've no work to do.
374-
375- (If you add clauses to this test, be sure to likewise update the
376- test within the loop.) */
377-
378- if (dld_cache.is_valid)
379- return;
380-
381- ALL_OBJFILES (objfile)
382- {
383- dld_msymbol = lookup_minimal_symbol ("shl_load", NULL, objfile);
384- if (dld_msymbol.minsym != NULL)
385- {
386- dld_cache.load.address = MSYMBOL_VALUE (dld_msymbol.minsym);
387- dld_cache.load.unwind = find_unwind_entry (dld_cache.load.address);
388- }
389-
390- dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_load",
391- objfile);
392- if (dld_msymbol.minsym != NULL)
393- {
394- if (MSYMBOL_TYPE (dld_msymbol.minsym) == mst_solib_trampoline)
395- {
396- u = find_unwind_entry (MSYMBOL_VALUE (dld_msymbol.minsym));
397- if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
398- {
399- dld_cache.load_stub.address
400- = MSYMBOL_VALUE (dld_msymbol.minsym);
401- dld_cache.load_stub.unwind = u;
402- }
403- }
404- }
405-
406- dld_msymbol = lookup_minimal_symbol ("shl_unload", NULL, objfile);
407- if (dld_msymbol.minsym != NULL)
408- {
409- dld_cache.unload.address = MSYMBOL_VALUE (dld_msymbol.minsym);
410- dld_cache.unload.unwind = find_unwind_entry (dld_cache.unload.address);
411-
412- /* ??rehrauer: I'm not sure exactly what this is, but it appears
413- that on some HPUX 10.x versions, there's two unwind regions to
414- cover the body of "shl_unload", the second being 4 bytes past
415- the end of the first. This is a large hack to handle that
416- case, but since I don't seem to have any legitimate way to
417- look for this thing via the symbol table... */
418-
419- if (dld_cache.unload.unwind != NULL)
420- {
421- u = find_unwind_entry (dld_cache.unload.unwind->region_end + 4);
422- if (u != NULL)
423- {
424- dld_cache.unload2.address = u->region_start;
425- dld_cache.unload2.unwind = u;
426- }
427- }
428- }
429-
430- dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_unload",
431- objfile);
432- if (dld_msymbol.minsym != NULL)
433- {
434- if (MSYMBOL_TYPE (dld_msymbol.minsym) == mst_solib_trampoline)
435- {
436- u = find_unwind_entry (MSYMBOL_VALUE (dld_msymbol.minsym));
437- if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
438- {
439- dld_cache.unload_stub.address
440- = MSYMBOL_VALUE (dld_msymbol.minsym);
441- dld_cache.unload_stub.unwind = u;
442- }
443- }
444- }
445-
446- /* Did we find everything we were looking for? If so, stop. */
447- if ((dld_cache.load.address != 0)
448- && (dld_cache.load_stub.address != 0)
449- && (dld_cache.unload.address != 0)
450- && (dld_cache.unload_stub.address != 0))
451- {
452- dld_cache.is_valid = 1;
453- break;
454- }
455- }
456-
457- dld_cache.hook.unwind = find_unwind_entry (dld_cache.hook.address);
458- dld_cache.hook_stub.unwind = find_unwind_entry (dld_cache.hook_stub.address);
459-
460- /* We're prepared not to find some of these symbols, which is why
461- this function is a "desire" operation, and not a "require". */
462-}
463-
464-static int
465-som_in_dynsym_resolve_code (CORE_ADDR pc)
466-{
467- struct unwind_table_entry *u_pc;
468-
469- /* Are we in the dld itself?
470-
471- ??rehrauer: Large hack -- We'll assume that any address in a
472- shared text region is the dld's text. This would obviously
473- fall down if the user attached to a process, whose shlibs
474- weren't mapped to a (writeable) private region. However, in
475- that case the debugger probably isn't able to set the fundamental
476- breakpoint in the dld callback anyways, so this hack should be
477- safe. */
478-
479- if ((pc & (CORE_ADDR) 0xc0000000) == (CORE_ADDR) 0xc0000000)
480- return 1;
481-
482- /* Cache the address of some symbols that are part of the dynamic
483- linker, if not already known. */
484-
485- som_solib_desire_dynamic_linker_symbols ();
486-
487- /* Are we in the dld callback? Or its export stub? */
488- u_pc = find_unwind_entry (pc);
489- if (u_pc == NULL)
490- return 0;
491-
492- if ((u_pc == dld_cache.hook.unwind) || (u_pc == dld_cache.hook_stub.unwind))
493- return 1;
494-
495- /* Or the interface of the dld (i.e., "shl_load" or friends)? */
496- if ((u_pc == dld_cache.load.unwind)
497- || (u_pc == dld_cache.unload.unwind)
498- || (u_pc == dld_cache.unload2.unwind)
499- || (u_pc == dld_cache.load_stub.unwind)
500- || (u_pc == dld_cache.unload_stub.unwind))
501- return 1;
502-
503- /* Apparently this address isn't part of the dld's text. */
504- return 0;
505-}
506-
507-static void
508-som_clear_solib (void)
509-{
510-}
511-
512-struct dld_list {
513- char name[4];
514- char info[4];
515- char text_addr[4];
516- char text_link_addr[4];
517- char text_end[4];
518- char data_start[4];
519- char bss_start[4];
520- char data_end[4];
521- char got_value[4];
522- char next[4];
523- char tsd_start_addr_ptr[4];
524-};
525-
526-static CORE_ADDR
527-link_map_start (void)
528-{
529- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
530- struct bound_minimal_symbol sym;
531- CORE_ADDR addr;
532- gdb_byte buf[4];
533- unsigned int dld_flags;
534-
535- sym = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
536- if (!sym.minsym)
537- error (_("Unable to find __dld_flags symbol in object file."));
538- addr = BMSYMBOL_VALUE_ADDRESS (sym);
539- read_memory (addr, buf, 4);
540- dld_flags = extract_unsigned_integer (buf, 4, byte_order);
541- if ((dld_flags & DLD_FLAGS_LISTVALID) == 0)
542- error (_("__dld_list is not valid according to __dld_flags."));
543-
544- sym = lookup_minimal_symbol ("__dld_list", NULL, NULL);
545- if (!sym.minsym)
546- {
547- /* Older crt0.o files (hpux8) don't have __dld_list as a symbol,
548- but the data is still available if you know where to look. */
549- sym = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
550- if (!sym.minsym)
551- {
552- error (_("Unable to find dynamic library list."));
553- return 0;
554- }
555- addr = BMSYMBOL_VALUE_ADDRESS (sym) - 8;
556- }
557- else
558- addr = BMSYMBOL_VALUE_ADDRESS (sym);
559-
560- read_memory (addr, buf, 4);
561- addr = extract_unsigned_integer (buf, 4, byte_order);
562- if (addr == 0)
563- return 0;
564-
565- read_memory (addr, buf, 4);
566- return extract_unsigned_integer (buf, 4, byte_order);
567-}
568-
569-/* Does this so's name match the main binary? */
570-static int
571-match_main (const char *name)
572-{
573- return strcmp (name, objfile_name (symfile_objfile)) == 0;
574-}
575-
576-static struct so_list *
577-som_current_sos (void)
578-{
579- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
580- CORE_ADDR lm;
581- struct so_list *head = 0;
582- struct so_list **link_ptr = &head;
583-
584- for (lm = link_map_start (); lm; )
585- {
586- char *namebuf;
587- CORE_ADDR addr;
588- struct so_list *newobj;
589- struct cleanup *old_chain;
590- int errcode;
591- struct dld_list dbuf;
592- gdb_byte tsdbuf[4];
593-
594- newobj = (struct so_list *) xmalloc (sizeof (struct so_list));
595- old_chain = make_cleanup (xfree, newobj);
596-
597- memset (newobj, 0, sizeof (*newobj));
598- newobj->lm_info = xmalloc (sizeof (struct lm_info));
599- make_cleanup (xfree, newobj->lm_info);
600-
601- read_memory (lm, (gdb_byte *)&dbuf, sizeof (struct dld_list));
602-
603- addr = extract_unsigned_integer ((gdb_byte *)&dbuf.name,
604- sizeof (dbuf.name), byte_order);
605- target_read_string (addr, &namebuf, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
606- if (errcode != 0)
607- warning (_("Can't read pathname for load map: %s."),
608- safe_strerror (errcode));
609- else
610- {
611- strncpy (newobj->so_name, namebuf, SO_NAME_MAX_PATH_SIZE - 1);
612- newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
613- xfree (namebuf);
614- strcpy (newobj->so_original_name, newobj->so_name);
615- }
616-
617- if (newobj->so_name[0] && !match_main (newobj->so_name))
618- {
619- struct lm_info *lmi = newobj->lm_info;
620- unsigned int tmp;
621-
622- lmi->lm_addr = lm;
623-
624-#define EXTRACT(_fld) \
625- extract_unsigned_integer ((gdb_byte *)&dbuf._fld, \
626- sizeof (dbuf._fld), byte_order);
627-
628- lmi->text_addr = EXTRACT (text_addr);
629- tmp = EXTRACT (info);
630- lmi->library_version = (tmp >> 16) & 0xffff;
631- lmi->bind_mode = (tmp >> 8) & 0xff;
632- lmi->struct_version = tmp & 0xff;
633- lmi->text_link_addr = EXTRACT (text_link_addr);
634- lmi->text_end = EXTRACT (text_end);
635- lmi->data_start = EXTRACT (data_start);
636- lmi->bss_start = EXTRACT (bss_start);
637- lmi->data_end = EXTRACT (data_end);
638- lmi->got_value = EXTRACT (got_value);
639- tmp = EXTRACT (tsd_start_addr_ptr);
640- read_memory (tmp, tsdbuf, 4);
641- lmi->tsd_start_addr
642- = extract_unsigned_integer (tsdbuf, 4, byte_order);
643-
644-#ifdef SOLIB_SOM_DBG
645- printf ("\n+ library \"%s\" is described at %s\n", newobj->so_name,
646- paddress (target_gdbarch (), lm));
647- printf (" 'version' is %d\n", newobj->lm_info->struct_version);
648- printf (" 'bind_mode' is %d\n", newobj->lm_info->bind_mode);
649- printf (" 'library_version' is %d\n",
650- newobj->lm_info->library_version);
651- printf (" 'text_addr' is %s\n",
652- paddress (target_gdbarch (), newobj->lm_info->text_addr));
653- printf (" 'text_link_addr' is %s\n",
654- paddress (target_gdbarch (), newobj->lm_info->text_link_addr));
655- printf (" 'text_end' is %s\n",
656- paddress (target_gdbarch (), newobj->lm_info->text_end));
657- printf (" 'data_start' is %s\n",
658- paddress (target_gdbarch (), newobj->lm_info->data_start));
659- printf (" 'bss_start' is %s\n",
660- paddress (target_gdbarch (), newobj->lm_info->bss_start));
661- printf (" 'data_end' is %s\n",
662- paddress (target_gdbarch (), newobj->lm_info->data_end));
663- printf (" 'got_value' is %s\n",
664- paddress (target_gdbarch (), newobj->lm_info->got_value));
665- printf (" 'tsd_start_addr' is %s\n",
666- paddress (target_gdbarch (), newobj->lm_info->tsd_start_addr));
667-#endif
668-
669- newobj->addr_low = lmi->text_addr;
670- newobj->addr_high = lmi->text_end;
671-
672- /* Link the new object onto the list. */
673- newobj->next = NULL;
674- *link_ptr = newobj;
675- link_ptr = &newobj->next;
676- }
677- else
678- {
679- free_so (newobj);
680- }
681-
682- lm = EXTRACT (next);
683- discard_cleanups (old_chain);
684-#undef EXTRACT
685- }
686-
687- /* TODO: The original somsolib code has logic to detect and eliminate
688- duplicate entries. Do we need that? */
689-
690- return head;
691-}
692-
693-static int
694-som_open_symbol_file_object (void *from_ttyp)
695-{
696- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
697- CORE_ADDR lm, l_name;
698- char *filename;
699- int errcode;
700- int from_tty = *(int *)from_ttyp;
701- gdb_byte buf[4];
702- struct cleanup *cleanup;
703-
704- if (symfile_objfile)
705- if (!query (_("Attempt to reload symbols from process? ")))
706- return 0;
707-
708- /* First link map member should be the executable. */
709- if ((lm = link_map_start ()) == 0)
710- return 0; /* failed somehow... */
711-
712- /* Read address of name from target memory to GDB. */
713- read_memory (lm + offsetof (struct dld_list, name), buf, 4);
714-
715- /* Convert the address to host format. Assume that the address is
716- unsigned. */
717- l_name = extract_unsigned_integer (buf, 4, byte_order);
718-
719- if (l_name == 0)
720- return 0; /* No filename. */
721-
722- /* Now fetch the filename from target memory. */
723- target_read_string (l_name, &filename, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
724-
725- if (errcode)
726- {
727- warning (_("failed to read exec filename from attached file: %s"),
728- safe_strerror (errcode));
729- return 0;
730- }
731-
732- cleanup = make_cleanup (xfree, filename);
733- /* Have a pathname: read the symbol file. */
734- symbol_file_add_main (filename, from_tty);
735-
736- do_cleanups (cleanup);
737- return 1;
738-}
739-
740-static void
741-som_free_so (struct so_list *so)
742-{
743- xfree (so->lm_info);
744-}
745-
746-static CORE_ADDR
747-som_solib_thread_start_addr (struct so_list *so)
748-{
749- return so->lm_info->tsd_start_addr;
750-}
751-
752-/* Return the GOT value for the shared library in which ADDR belongs. If
753- ADDR isn't in any known shared library, return zero. */
754-
755-static CORE_ADDR
756-som_solib_get_got_by_pc (CORE_ADDR addr)
757-{
758- struct so_list *so_list = master_so_list ();
759- CORE_ADDR got_value = 0;
760-
761- while (so_list)
762- {
763- if (so_list->lm_info->text_addr <= addr
764- && so_list->lm_info->text_end > addr)
765- {
766- got_value = so_list->lm_info->got_value;
767- break;
768- }
769- so_list = so_list->next;
770- }
771- return got_value;
772-}
773-
774-/* Return the address of the handle of the shared library in which
775- ADDR belongs. If ADDR isn't in any known shared library, return
776- zero. */
777-/* This function is used in initialize_hp_cxx_exception_support in
778- hppa-hpux-tdep.c. */
779-
780-static CORE_ADDR
781-som_solib_get_solib_by_pc (CORE_ADDR addr)
782-{
783- struct so_list *so_list = master_so_list ();
784-
785- while (so_list)
786- {
787- if (so_list->lm_info->text_addr <= addr
788- && so_list->lm_info->text_end > addr)
789- {
790- break;
791- }
792- so_list = so_list->next;
793- }
794- if (so_list)
795- return so_list->lm_info->lm_addr;
796- else
797- return 0;
798-}
799-
800-
801-static struct target_so_ops som_so_ops;
802-
803-extern initialize_file_ftype _initialize_som_solib; /* -Wmissing-prototypes */
804-
805-void
806-_initialize_som_solib (void)
807-{
808- som_so_ops.relocate_section_addresses = som_relocate_section_addresses;
809- som_so_ops.free_so = som_free_so;
810- som_so_ops.clear_solib = som_clear_solib;
811- som_so_ops.solib_create_inferior_hook = som_solib_create_inferior_hook;
812- som_so_ops.special_symbol_handling = som_special_symbol_handling;
813- som_so_ops.current_sos = som_current_sos;
814- som_so_ops.open_symbol_file_object = som_open_symbol_file_object;
815- som_so_ops.in_dynsym_resolve_code = som_in_dynsym_resolve_code;
816- som_so_ops.bfd_open = solib_bfd_open;
817-}
818-
819-void
820-som_solib_select (struct gdbarch *gdbarch)
821-{
822- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
823-
824- set_solib_ops (gdbarch, &som_so_ops);
825- tdep->solib_thread_start_addr = som_solib_thread_start_addr;
826- tdep->solib_get_got_by_pc = som_solib_get_got_by_pc;
827- tdep->solib_get_solib_by_pc = som_solib_get_solib_by_pc;
828-}
829-
830-/* The rest of these functions are not part of the solib interface; they
831- are used by somread.c or hppa-hpux-tdep.c. */
832-
833-int
834-som_solib_section_offsets (struct objfile *objfile,
835- struct section_offsets *offsets)
836-{
837- struct so_list *so_list = master_so_list ();
838-
839- while (so_list)
840- {
841- /* Oh what a pain! We need the offsets before so_list->objfile
842- is valid. The BFDs will never match. Make a best guess. */
843- if (strstr (objfile_name (objfile), so_list->so_name))
844- {
845- asection *private_section;
846- struct obj_section *sect;
847-
848- /* The text offset is easy. */
849- offsets->offsets[SECT_OFF_TEXT (objfile)]
850- = (so_list->lm_info->text_addr
851- - so_list->lm_info->text_link_addr);
852-
853- /* We should look at presumed_dp in the SOM header, but
854- that's not easily available. This should be OK though. */
855- private_section = bfd_get_section_by_name (objfile->obfd,
856- "$PRIVATE$");
857- if (!private_section)
858- {
859- warning (_("Unable to find $PRIVATE$ in shared library!"));
860- offsets->offsets[SECT_OFF_DATA (objfile)] = 0;
861- offsets->offsets[SECT_OFF_BSS (objfile)] = 0;
862- return 1;
863- }
864- if (objfile->sect_index_data != -1)
865- {
866- offsets->offsets[SECT_OFF_DATA (objfile)]
867- = (so_list->lm_info->data_start - private_section->vma);
868- if (objfile->sect_index_bss != -1)
869- offsets->offsets[SECT_OFF_BSS (objfile)]
870- = ANOFFSET (offsets, SECT_OFF_DATA (objfile));
871- }
872-
873- ALL_OBJFILE_OSECTIONS (objfile, sect)
874- {
875- flagword flags = bfd_get_section_flags (objfile->obfd,
876- sect->the_bfd_section);
877-
878- if ((flags & SEC_CODE) != 0)
879- offsets->offsets[sect->the_bfd_section->index]
880- = offsets->offsets[SECT_OFF_TEXT (objfile)];
881- else
882- offsets->offsets[sect->the_bfd_section->index]
883- = offsets->offsets[SECT_OFF_DATA (objfile)];
884- }
885-
886- return 1;
887- }
888- so_list = so_list->next;
889- }
890- return 0;
891-}
--- a/gdb/solib-som.h
+++ /dev/null
@@ -1,35 +0,0 @@
1-/* Handle SOM shared libraries for GDB, the GNU Debugger.
2-
3- Copyright (C) 2004-2015 Free Software Foundation, Inc.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#ifndef SOLIB_SOM_H
21-#define SOLIB_SOM_H
22-
23-struct objfile;
24-struct section_offsets;
25-struct gdbarch;
26-
27-extern int hpux_major_release;
28-
29-void som_solib_select (struct gdbarch *gdbarch);
30-
31-int som_solib_section_offsets (struct objfile *objfile,
32- struct section_offsets *offsets);
33-
34-#endif
35-
--- a/gdb/somread.c
+++ /dev/null
@@ -1,547 +0,0 @@
1-/* Read HP PA/Risc object files for GDB.
2- Copyright (C) 1991-2015 Free Software Foundation, Inc.
3- Written by Fred Fish at Cygnus Support.
4-
5- This file is part of GDB.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- You should have received a copy of the GNU General Public License
18- along with this program. If not, see <http://www.gnu.org/licenses/>. */
19-
20-#include "defs.h"
21-#include "bfd.h"
22-#include "som/aout.h"
23-#include "symtab.h"
24-#include "symfile.h"
25-#include "objfiles.h"
26-#include "buildsym.h"
27-#include "stabsread.h"
28-#include "gdb-stabs.h"
29-#include "complaints.h"
30-#include "demangle.h"
31-#include "som.h"
32-#include "libhppa.h"
33-#include "psymtab.h"
34-
35-#include "solib-som.h"
36-
37-/* Read the symbol table of a SOM file.
38-
39- Given an open bfd, a base address to relocate symbols to, and a
40- flag that specifies whether or not this bfd is for an executable
41- or not (may be shared library for example), add all the global
42- function and data symbols to the minimal symbol table. */
43-
44-static void
45-som_symtab_read (bfd *abfd, struct objfile *objfile,
46- struct section_offsets *section_offsets)
47-{
48- struct cleanup *cleanup;
49- struct gdbarch *gdbarch = get_objfile_arch (objfile);
50- unsigned int number_of_symbols;
51- int val, dynamic;
52- char *stringtab;
53- asection *shlib_info;
54- struct som_external_symbol_dictionary_record *buf, *bufp, *endbufp;
55- char *symname;
56- const int symsize = sizeof (struct som_external_symbol_dictionary_record);
57-
58-
59- number_of_symbols = bfd_get_symcount (abfd);
60-
61- /* Allocate a buffer to read in the debug info.
62- We avoid using alloca because the memory size could be so large
63- that we could hit the stack size limit. */
64- buf = xmalloc (symsize * number_of_symbols);
65- cleanup = make_cleanup (xfree, buf);
66- bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET);
67- val = bfd_bread (buf, symsize * number_of_symbols, abfd);
68- if (val != symsize * number_of_symbols)
69- error (_("Couldn't read symbol dictionary!"));
70-
71- /* Allocate a buffer to read in the som stringtab section of
72- the debugging info. Again, we avoid using alloca because
73- the data could be so large that we could potentially hit
74- the stack size limitat. */
75- stringtab = xmalloc (obj_som_stringtab_size (abfd));
76- make_cleanup (xfree, stringtab);
77- bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET);
78- val = bfd_bread (stringtab, obj_som_stringtab_size (abfd), abfd);
79- if (val != obj_som_stringtab_size (abfd))
80- error (_("Can't read in HP string table."));
81-
82- /* We need to determine if objfile is a dynamic executable (so we
83- can do the right thing for ST_ENTRY vs ST_CODE symbols).
84-
85- There's nothing in the header which easily allows us to do
86- this.
87-
88- This code used to rely upon the existence of a $SHLIB_INFO$
89- section to make this determination. HP claims that it is
90- more accurate to check for a nonzero text offset, but they
91- have not provided any information about why that test is
92- more accurate. */
93- dynamic = (ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)) != 0);
94-
95- endbufp = buf + number_of_symbols;
96- for (bufp = buf; bufp < endbufp; ++bufp)
97- {
98- enum minimal_symbol_type ms_type;
99- unsigned int flags = bfd_getb32 (bufp->flags);
100- unsigned int symbol_type
101- = (flags >> SOM_SYMBOL_TYPE_SH) & SOM_SYMBOL_TYPE_MASK;
102- unsigned int symbol_scope
103- = (flags >> SOM_SYMBOL_SCOPE_SH) & SOM_SYMBOL_SCOPE_MASK;
104- CORE_ADDR symbol_value = bfd_getb32 (bufp->symbol_value);
105- asection *section = NULL;
106-
107- QUIT;
108-
109- /* Compute the section. */
110- switch (symbol_scope)
111- {
112- case SS_EXTERNAL:
113- if (symbol_type != ST_STORAGE)
114- section = bfd_und_section_ptr;
115- else
116- section = bfd_com_section_ptr;
117- break;
118-
119- case SS_UNSAT:
120- if (symbol_type != ST_STORAGE)
121- section = bfd_und_section_ptr;
122- else
123- section = bfd_com_section_ptr;
124- break;
125-
126- case SS_UNIVERSAL:
127- section = bfd_section_from_som_symbol (abfd, bufp);
128- break;
129-
130- case SS_LOCAL:
131- section = bfd_section_from_som_symbol (abfd, bufp);
132- break;
133- }
134-
135- switch (symbol_scope)
136- {
137- case SS_UNIVERSAL:
138- case SS_EXTERNAL:
139- switch (symbol_type)
140- {
141- case ST_SYM_EXT:
142- case ST_ARG_EXT:
143- continue;
144-
145- case ST_CODE:
146- case ST_PRI_PROG:
147- case ST_SEC_PROG:
148- case ST_MILLICODE:
149- symname = bfd_getb32 (bufp->name) + stringtab;
150- ms_type = mst_text;
151- symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
152- break;
153-
154- case ST_ENTRY:
155- symname = bfd_getb32 (bufp->name) + stringtab;
156- /* For a dynamic executable, ST_ENTRY symbols are
157- the stubs, while the ST_CODE symbol is the real
158- function. */
159- if (dynamic)
160- ms_type = mst_solib_trampoline;
161- else
162- ms_type = mst_text;
163- symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
164- break;
165-
166- case ST_STUB:
167- symname = bfd_getb32 (bufp->name) + stringtab;
168- ms_type = mst_solib_trampoline;
169- symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
170- break;
171-
172- case ST_DATA:
173- symname = bfd_getb32 (bufp->name) + stringtab;
174- ms_type = mst_data;
175- break;
176- default:
177- continue;
178- }
179- break;
180-
181-#if 0
182- /* SS_GLOBAL and SS_LOCAL are two names for the same thing (!). */
183- case SS_GLOBAL:
184-#endif
185- case SS_LOCAL:
186- switch (symbol_type)
187- {
188- case ST_SYM_EXT:
189- case ST_ARG_EXT:
190- continue;
191-
192- case ST_CODE:
193- symname = bfd_getb32 (bufp->name) + stringtab;
194- ms_type = mst_file_text;
195- symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
196-
197- check_strange_names:
198- /* Utah GCC 2.5, FSF GCC 2.6 and later generate correct local
199- label prefixes for stabs, constant data, etc. So we need
200- only filter out L$ symbols which are left in due to
201- limitations in how GAS generates SOM relocations.
202-
203- When linking in the HPUX C-library the HP linker has
204- the nasty habit of placing section symbols from the literal
205- subspaces in the middle of the program's text. Filter
206- those out as best we can. Check for first and last character
207- being '$'.
208-
209- And finally, the newer HP compilers emit crud like $PIC_foo$N
210- in some circumstance (PIC code I guess). It's also claimed
211- that they emit D$ symbols too. What stupidity. */
212- if ((symname[0] == 'L' && symname[1] == '$')
213- || (symname[0] == '$' && symname[strlen (symname) - 1] == '$')
214- || (symname[0] == 'D' && symname[1] == '$')
215- || (startswith (symname, "L0\001"))
216- || (startswith (symname, "$PIC")))
217- continue;
218- break;
219-
220- case ST_PRI_PROG:
221- case ST_SEC_PROG:
222- case ST_MILLICODE:
223- symname = bfd_getb32 (bufp->name) + stringtab;
224- ms_type = mst_file_text;
225- symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
226- break;
227-
228- case ST_ENTRY:
229- symname = bfd_getb32 (bufp->name) + stringtab;
230- /* SS_LOCAL symbols in a shared library do not have
231- export stubs, so we do not have to worry about
232- using mst_file_text vs mst_solib_trampoline here like
233- we do for SS_UNIVERSAL and SS_EXTERNAL symbols above. */
234- ms_type = mst_file_text;
235- symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
236- break;
237-
238- case ST_STUB:
239- symname = bfd_getb32 (bufp->name) + stringtab;
240- ms_type = mst_solib_trampoline;
241- symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
242- break;
243-
244-
245- case ST_DATA:
246- symname = bfd_getb32 (bufp->name) + stringtab;
247- ms_type = mst_file_data;
248- goto check_strange_names;
249-
250- default:
251- continue;
252- }
253- break;
254-
255- /* This can happen for common symbols when -E is passed to the
256- final link. No idea _why_ that would make the linker force
257- common symbols to have an SS_UNSAT scope, but it does.
258-
259- This also happens for weak symbols, but their type is
260- ST_DATA. */
261- case SS_UNSAT:
262- switch (symbol_type)
263- {
264- case ST_STORAGE:
265- case ST_DATA:
266- symname = bfd_getb32 (bufp->name) + stringtab;
267- ms_type = mst_data;
268- break;
269-
270- default:
271- continue;
272- }
273- break;
274-
275- default:
276- continue;
277- }
278-
279- if (bfd_getb32 (bufp->name) > obj_som_stringtab_size (abfd))
280- error (_("Invalid symbol data; bad HP string table offset: %s"),
281- plongest (bfd_getb32 (bufp->name)));
282-
283- if (bfd_is_const_section (section))
284- {
285- struct obj_section *iter;
286-
287- ALL_OBJFILE_OSECTIONS (objfile, iter)
288- {
289- CORE_ADDR start;
290- CORE_ADDR len;
291-
292- if (bfd_is_const_section (iter->the_bfd_section))
293- continue;
294-
295- start = bfd_get_section_vma (iter->objfile->obfd,
296- iter->the_bfd_section);
297- len = bfd_get_section_size (iter->the_bfd_section);
298- if (start <= symbol_value && symbol_value < start + len)
299- {
300- section = iter->the_bfd_section;
301- break;
302- }
303- }
304- }
305-
306- prim_record_minimal_symbol_and_info (symname, symbol_value, ms_type,
307- gdb_bfd_section_index (objfile->obfd,
308- section),
309- objfile);
310- }
311-
312- do_cleanups (cleanup);
313-}
314-
315-/* Scan and build partial symbols for a symbol file.
316- We have been initialized by a call to som_symfile_init, which
317- currently does nothing.
318-
319- SECTION_OFFSETS is a set of offsets to apply to relocate the symbols
320- in each section. This is ignored, as it isn't needed for SOM.
321-
322- This function only does the minimum work necessary for letting the
323- user "name" things symbolically; it does not read the entire symtab.
324- Instead, it reads the external and static symbols and puts them in partial
325- symbol tables. When more extensive information is requested of a
326- file, the corresponding partial symbol table is mutated into a full
327- fledged symbol table by going back and reading the symbols
328- for real.
329-
330- We look for sections with specific names, to tell us what debug
331- format to look for.
332-
333- somstab_build_psymtabs() handles STABS symbols.
334-
335- Note that SOM files have a "minimal" symbol table, which is vaguely
336- reminiscent of a COFF symbol table, but has only the minimal information
337- necessary for linking. We process this also, and use the information to
338- build gdb's minimal symbol table. This gives us some minimal debugging
339- capability even for files compiled without -g. */
340-
341-static void
342-som_symfile_read (struct objfile *objfile, int symfile_flags)
343-{
344- bfd *abfd = objfile->obfd;
345- struct cleanup *back_to;
346-
347- init_minimal_symbol_collection ();
348- back_to = make_cleanup_discard_minimal_symbols ();
349-
350- /* Process the normal SOM symbol table first.
351- This reads in the DNTT and string table, but doesn't
352- actually scan the DNTT. It does scan the linker symbol
353- table and thus build up a "minimal symbol table". */
354-
355- som_symtab_read (abfd, objfile, objfile->section_offsets);
356-
357- /* Install any minimal symbols that have been collected as the current
358- minimal symbols for this objfile.
359- Further symbol-reading is done incrementally, file-by-file,
360- in a step known as "psymtab-to-symtab" expansion. hp-symtab-read.c
361- contains the code to do the actual DNTT scanning and symtab building. */
362- install_minimal_symbols (objfile);
363- do_cleanups (back_to);
364-
365- /* Now read information from the stabs debug sections.
366- This is emitted by gcc. */
367- stabsect_build_psymtabs (objfile,
368- "$GDB_SYMBOLS$", "$GDB_STRINGS$", "$TEXT$");
369-}
370-
371-/* Initialize anything that needs initializing when a completely new symbol
372- file is specified (not just adding some symbols from another file, e.g. a
373- shared library).
374-
375- We reinitialize buildsym, since we may be reading stabs from a SOM file. */
376-
377-static void
378-som_new_init (struct objfile *ignore)
379-{
380- stabsread_new_init ();
381- buildsym_new_init ();
382-}
383-
384-/* Perform any local cleanups required when we are done with a particular
385- objfile. I.e, we are in the process of discarding all symbol information
386- for an objfile, freeing up all memory held for it, and unlinking the
387- objfile struct from the global list of known objfiles. */
388-
389-static void
390-som_symfile_finish (struct objfile *objfile)
391-{
392-}
393-
394-/* SOM specific initialization routine for reading symbols. */
395-
396-static void
397-som_symfile_init (struct objfile *objfile)
398-{
399- /* SOM objects may be reordered, so set OBJF_REORDERED. If we
400- find this causes a significant slowdown in gdb then we could
401- set it in the debug symbol readers only when necessary. */
402- objfile->flags |= OBJF_REORDERED;
403-}
404-
405-/* An object of this type is passed to find_section_offset. */
406-
407-struct find_section_offset_arg
408-{
409- /* The objfile. */
410-
411- struct objfile *objfile;
412-
413- /* Flags to invert. */
414-
415- flagword invert;
416-
417- /* Flags to look for. */
418-
419- flagword flags;
420-
421- /* A text section with non-zero size, if any. */
422-
423- asection *best_section;
424-
425- /* An empty text section, if any. */
426-
427- asection *empty_section;
428-};
429-
430-/* A callback for bfd_map_over_sections that tries to find a section
431- with particular flags in an objfile. */
432-
433-static void
434-find_section_offset (bfd *abfd, asection *sect, void *arg)
435-{
436- struct find_section_offset_arg *info = arg;
437- flagword aflag;
438-
439- aflag = bfd_get_section_flags (abfd, sect);
440-
441- aflag ^= info->invert;
442-
443- if ((aflag & info->flags) == info->flags)
444- {
445- if (bfd_section_size (abfd, sect) > 0)
446- {
447- if (info->best_section == NULL)
448- info->best_section = sect;
449- }
450- else
451- {
452- if (info->empty_section == NULL)
453- info->empty_section = sect;
454- }
455- }
456-}
457-
458-/* Set a section index from a BFD. */
459-
460-static void
461-set_section_index (struct objfile *objfile, flagword invert, flagword flags,
462- int *index_ptr)
463-{
464- struct find_section_offset_arg info;
465-
466- info.objfile = objfile;
467- info.best_section = NULL;
468- info.empty_section = NULL;
469- info.invert = invert;
470- info.flags = flags;
471- bfd_map_over_sections (objfile->obfd, find_section_offset, &info);
472-
473- if (info.best_section)
474- *index_ptr = info.best_section->index;
475- else if (info.empty_section)
476- *index_ptr = info.empty_section->index;
477-}
478-
479-/* SOM specific parsing routine for section offsets.
480-
481- Plain and simple for now. */
482-
483-static void
484-som_symfile_offsets (struct objfile *objfile,
485- const struct section_addr_info *addrs)
486-{
487- int i;
488- CORE_ADDR text_addr;
489- asection *sect;
490-
491- objfile->num_sections = bfd_count_sections (objfile->obfd);
492- objfile->section_offsets = (struct section_offsets *)
493- obstack_alloc (&objfile->objfile_obstack,
494- SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
495-
496- set_section_index (objfile, 0, SEC_ALLOC | SEC_CODE,
497- &objfile->sect_index_text);
498- set_section_index (objfile, 0, SEC_ALLOC | SEC_DATA,
499- &objfile->sect_index_data);
500- set_section_index (objfile, SEC_LOAD, SEC_ALLOC | SEC_LOAD,
501- &objfile->sect_index_bss);
502- set_section_index (objfile, 0, SEC_ALLOC | SEC_READONLY,
503- &objfile->sect_index_rodata);
504-
505- /* First see if we're a shared library. If so, get the section
506- offsets from the library, else get them from addrs. */
507- if (!som_solib_section_offsets (objfile, objfile->section_offsets))
508- {
509- /* Note: Here is OK to compare with ".text" because this is the
510- name that gdb itself gives to that section, not the SOM
511- name. */
512- for (i = 0; i < addrs->num_sections; i++)
513- if (strcmp (addrs->other[i].name, ".text") == 0)
514- break;
515- text_addr = addrs->other[i].addr;
516-
517- for (i = 0; i < objfile->num_sections; i++)
518- (objfile->section_offsets)->offsets[i] = text_addr;
519- }
520-}
521-
522-
523-
524-/* Register that we are able to handle SOM object file formats. */
525-
526-static const struct sym_fns som_sym_fns =
527-{
528- som_new_init, /* init anything gbl to entire symtab */
529- som_symfile_init, /* read initial info, setup for sym_read() */
530- som_symfile_read, /* read a symbol file into symtab */
531- NULL, /* sym_read_psymbols */
532- som_symfile_finish, /* finished with file, cleanup */
533- som_symfile_offsets, /* Translate ext. to int. relocation */
534- default_symfile_segments, /* Get segment information from a file. */
535- NULL,
536- default_symfile_relocate, /* Relocate a debug section. */
537- NULL, /* sym_get_probes */
538- &psym_functions
539-};
540-
541-initialize_file_ftype _initialize_somread;
542-
543-void
544-_initialize_somread (void)
545-{
546- add_symtab_fns (bfd_target_som_flavour, &som_sym_fns);
547-}