From patchwork Sun Dec 9 19:57:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [libbacktrace] Find executable on ia64 and 64-bit hppa hpux X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 204780 Message-Id: <20121209195737.GA20382@hiauly1.hia.nrc.ca> To: gcc-patches@gcc.gnu.org Date: Sun, 9 Dec 2012 14:57:38 -0500 From: John David Anglin List-Id: 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 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 +#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. */