The getexecname function is not availble on HP-UX.  This patch provides
an alternative techique to obtain the executable path on HP-UX ELF targets.
These have the dlget and dlgetname calls.  I believe that this requires
the dld.sl library be linked with the application which is the normal
case.

With this change and the other libbacktrace fixes that I previously
posted, libbacktrace now works on hppa64-hp-hpux11.11.  Don't have
an ia64 system, so I can't test there.

There is an alternative technique available using the pstat interface
in HP-UX 11.11 and later.  It's also possible to use the pstat interface
and a file system walk on earlier HP-UX versions.  However, this is
painfully slow on large file systems.  It would probably be better to
use argv[0] and some additional checks.

32-bit hppa*-*-hpux* uses the SOM object format.  Don't know how
hard it would be to port libbacktrace to it.  As a result,
BACKTRACE_SUPPORTED is 0.  However, libbacktrace is still called
and fails in finding the executable.  For example,

/test/gnu/gcc/gcc/gcc/testsuite/g++.dg/pr48660.C:16:18: internal compiler error:
 in simplify_subreg, at simplify-rtx.c:5682
 libbacktrace could not find executable to open
 Please submit a full bug report,with preprocessed source if appropriate.

Not sure what would happen if libbacktrace found the executable.

OK for trunk?

Dave
-- 
J. David Anglin                                  dave.ang...@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2012-12-09  John David Anglin  <dave.ang...@nrc-cnrc.gc.ca>

        * fileline.c (getexecname): Define to getexecname_hpux on ia64 and
        64-bit hppa hpux.
        (getexecname_hpux): New.

Index: fileline.c
===================================================================
--- fileline.c  (revision 194325)
+++ fileline.c  (working copy)
@@ -42,8 +42,23 @@
 #include "internal.h"
 
 #ifndef HAVE_GETEXECNAME
+#if defined(__hpux) && (defined(__ia64) || defined(_LP64))
+#include <dlfcn.h>
+#define getexecname getexecname_hpux
+
+static char *
+getexecname_hpux (void)
+{
+  struct load_module_desc desc;
+
+  dlget(-2, &desc, sizeof(desc));
+  return dlgetname(&desc, sizeof(desc), NULL, 0, 0);
+}
+
+#else
 #define getexecname() NULL
 #endif
+#endif
 
 /* Initialize the fileline information from the executable.  Returns 1
    on success, 0 on failure.  */

Reply via email to