Re: [PATCH 6/8] port GDB to ia64-hpux (native).

Joel Brobecker
2011-06-17T16:30:35Z

[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]

[putting gdb-patches back, in case it's useful to someone else]

Steve,

> > What I will do as soon as I have a moment is double-check that I didn't
> > make a mistake somewhere, or forgot something. That would definitely
> > explain the problems you are having. We'll get to the bottom of this!

I tried taking a look at what might be causing you some trouble.
I can see some differences between our GDB and the FSF GDB, but
nothing like what you are seeing.

I did have a hard time getting libunwind to be activated, though,
and that failure is silently activated, or not. That's why I took
the bull by the horn, and decided to make that unconditional:
http://www.sourceware.org/ml/gdb-patches/2011-06/msg00234.html

As I said before, the system libunwind is not performing as well
as GNU libunwind does. I use libunwind-0.98.5, not the latest
version. Either version will need to be patched, but I'm attaching
the patch I use with 0.98.5. I also sent some patches to the
libunwind mailing list for the HEAD, but I haven't had time
to test.

That's really as far as I can spend on this, as I've already spent
8 times the 2 hours I wanted to dedicate. There are a few fixes
I should track down at some point that will further improve the
results. But at least I'm satisfied that I didn't miss anything
in my patches...

--
Joel

[-- Attachment #2: libunwind-0.98.5.tar.gz.diff --]
[-- Type: text/x-diff, Size: 5625 bytes --]

2008-10-02 Joel Brobecker <brobecker@adacore.com>

On ia64-hpux version 11.31, there is no <sys/ptrace.h> anymore.

* configure.in: Add check for sys/ptrace.h.
* configure, include/config.h.in: Regenerate.
* src/ptrace/_UPT_internal.h: Include sys/ptrace.h only when
available. Also, include <sys/ptrace.h> AFTER including
"internal.h". Otherwise, "config.h" hasn't been included yet,
and thus HAVE_SYS_PTRACE_H was not defined.

2005-09-02 Joel Brobecker <brobecker@adacore.com>

* Ginit.c (tdep_uc_addr): New function. Needed to avoid a link failure.

2005-09-02 Joel Brobecker <brobecker@adacore.com>

This patches fixes a problem on ia64-hpux when trying to build
this package using GCC 3.4.4. The makefile was incorrectly using
-lgcc instead of -lgcc_s to build the libunwind shared library.
libtool noticed that libgcc does not exist in a shared library
version, and hence removed it from the list of dependencies (after
printing a warning). This adds the missing dependency back, so
that another program dlopen()'ing it doesn't fail due to unresolved
symbols.
* configure.in (LIBCRTS): Use -lgcc_s instead of -lgcc when needed.
* configure: Regenerate.

Index: configure
===================================================================
--- configure (revision 131627)
+++ configure (revision 131628)
@@ -20870,6 +20870,16 @@ rm -f conftest.err conftest.$ac_objext c
if test x$GCC = xyes -a x$intel_compiler != xyes; then
CFLAGS="${CFLAGS} -Wall -Wsign-compare"
LIBCRTS="-lgcc"
+
+ # What we really want to do is link our libraries against is the shared
+ # version of libgcc. Unfortunately, this library may either be named
+ # libgcc or libgcc_s. Try to see if GCC recognizes libgcc_s, in which
+ # case we should be linking against libgcc_s.
+ libgcc_s_so=libgcc_s.so
+ libgcc_s_path=`$CC -print-file-name=$libgcc_s_so`
+ if test x$libgcc_s_path != x$libgcc_s_so; then
+ LIBCRTS="-lgcc_s"
+ fi
fi

CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"

Index: configure.in
===================================================================
--- configure.in (revision 131627)
+++ configure.in (revision 131628)
@@ -103,6 +103,16 @@ AC_TRY_COMPILE([], [#ifndef __INTEL_COMP
if test x$GCC = xyes -a x$intel_compiler != xyes; then
CFLAGS="${CFLAGS} -Wall -Wsign-compare"
LIBCRTS="-lgcc"
+
+ # What we really want to do is link our libraries against is the shared
+ # version of libgcc. Unfortunately, this library may either be named
+ # libgcc or libgcc_s. Try to see if GCC recognizes libgcc_s, in which
+ # case we should be linking against libgcc_s.
+ libgcc_s_so=libgcc_s.so
+ libgcc_s_path=`$CC -print-file-name=$libgcc_s_so`
+ if test x$libgcc_s_path != x$libgcc_s_so; then
+ LIBCRTS="-lgcc_s"
+ fi
fi

CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"

Index: src/ia64/Ginit.c
===================================================================
--- src/ia64/Ginit.c (revision 131628)
+++ src/ia64/Ginit.c (revision 131629)
@@ -82,6 +82,17 @@ PROTECTED unw_addr_space_t unw_local_add

#ifdef HAVE_SYS_UC_ACCESS_H

+void *
+tdep_uc_addr (ucontext_t *uc, int reg, uint8_t *nat_bitnr)
+{
+ /* brobecker/2005-09-01: I couldn't find a way of implementing this
+ on ia64-hpux, as the uc structure is opaque. The OS provides
+ ways to get the values themselves, but not their address. However,
+ I haven't seen this procedure being used at all so far, so we'll
+ just return NULL for now. */
+ return NULL;
+}
+
#else /* !HAVE_SYS_UC_ACCESS_H */

HIDDEN void *

Index: configure
===================================================================
--- configure (revision 135785)
+++ configure (revision 136181)
@@ -19740,7 +19740,7 @@ fi

for ac_header in asm/ptrace_offsets.h endian.h execinfo.h ia64intrin.h \
- sys/uc_access.h unistd.h signal.h
+ sys/uc_access.h unistd.h signal.h sys/ptrace.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
Index: include/config.h.in
===================================================================
--- include/config.h.in (revision 135785)
+++ include/config.h.in (revision 136181)
@@ -60,6 +60,9 @@
/* Define to 1 if `dlpi_subs' is member of `struct dl_phdr_info'. */
#undef HAVE_STRUCT_DL_PHDR_INFO_DLPI_SUBS

+/* Define to 1 if you have the <sys/ptrace.h> header file. */
+#undef HAVE_SYS_PTRACE_H
+
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H

Index: configure.in
===================================================================
--- configure.in (revision 135785)
+++ configure.in (revision 136181)
@@ -28,7 +28,7 @@ CHECK_ATOMIC_OPS
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h execinfo.h ia64intrin.h \
- sys/uc_access.h unistd.h signal.h)
+ sys/uc_access.h unistd.h signal.h sys/ptrace.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
Index: src/ptrace/_UPT_internal.h
===================================================================
--- src/ptrace/_UPT_internal.h (revision 135785)
+++ src/ptrace/_UPT_internal.h (revision 136181)
@@ -32,11 +32,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
#include <stdio.h>
#include <stdlib.h>

-#include <sys/ptrace.h>
-
#include "internal.h"
#include "tdep.h"

+#ifdef HAVE_SYS_PTRACE_H
+#include <sys/ptrace.h>
+#endif
+
struct UPT_info
{
pid_t pid; /* the process-id of the child we're unwinding */