mirror of
https://github.com/ianlancetaylor/libbacktrace.git
synced 2026-04-02 15:39:06 +08:00
libbacktrace: look for _pgmptr on Windows
Patch from Andres Freund: * configure.ac: Check for _pgmptr declaration. * fileline.c (fileline_initialize): Check for _pgmfptr before /proc/self/exec. * configure, config.h.in: Regenerate.
This commit is contained in:
@@ -20,6 +20,10 @@
|
|||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL_STRNLEN
|
#undef HAVE_DECL_STRNLEN
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `_pgmptr', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL__PGMPTR
|
||||||
|
|
||||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
#undef HAVE_DLFCN_H
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
|
|||||||
13
configure
vendored
13
configure
vendored
@@ -12517,6 +12517,19 @@ $as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for _pgmptr variable, contains the executable filename on windows
|
||||||
|
ac_fn_c_check_decl "$LINENO" "_pgmptr" "ac_cv_have_decl__pgmptr" "$ac_includes_default"
|
||||||
|
if test "x$ac_cv_have_decl__pgmptr" = xyes; then :
|
||||||
|
ac_have_decl=1
|
||||||
|
else
|
||||||
|
ac_have_decl=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_DECL__PGMPTR $ac_have_decl
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
|
||||||
# Check for sysctl definitions.
|
# Check for sysctl definitions.
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for KERN_PROC" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for KERN_PROC" >&5
|
||||||
|
|||||||
@@ -404,6 +404,9 @@ if test "$have_getexecname" = "yes"; then
|
|||||||
AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
|
AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for _pgmptr variable, contains the executable filename on windows
|
||||||
|
AC_CHECK_DECLS([_pgmptr])
|
||||||
|
|
||||||
# Check for sysctl definitions.
|
# Check for sysctl definitions.
|
||||||
|
|
||||||
AC_CACHE_CHECK([for KERN_PROC],
|
AC_CACHE_CHECK([for KERN_PROC],
|
||||||
|
|||||||
27
fileline.c
27
fileline.c
@@ -155,6 +155,16 @@ macho_get_executable_path (struct backtrace_state *state,
|
|||||||
|
|
||||||
#endif /* !defined (HAVE_MACH_O_DYLD_H) */
|
#endif /* !defined (HAVE_MACH_O_DYLD_H) */
|
||||||
|
|
||||||
|
#if HAVE_DECL__PGMPTR
|
||||||
|
|
||||||
|
#define windows_executable_filename() _pgmptr
|
||||||
|
|
||||||
|
#else /* !HAVE_DECL__PGMPTR */
|
||||||
|
|
||||||
|
#define windows_executable_filename() NULL
|
||||||
|
|
||||||
|
#endif /* !HAVE_DECL__PGMPTR */
|
||||||
|
|
||||||
/* Initialize the fileline information from the executable. Returns 1
|
/* Initialize the fileline information from the executable. Returns 1
|
||||||
on success, 0 on failure. */
|
on success, 0 on failure. */
|
||||||
|
|
||||||
@@ -192,7 +202,7 @@ fileline_initialize (struct backtrace_state *state,
|
|||||||
|
|
||||||
descriptor = -1;
|
descriptor = -1;
|
||||||
called_error_callback = 0;
|
called_error_callback = 0;
|
||||||
for (pass = 0; pass < 8; ++pass)
|
for (pass = 0; pass < 9; ++pass)
|
||||||
{
|
{
|
||||||
int does_not_exist;
|
int does_not_exist;
|
||||||
|
|
||||||
@@ -205,23 +215,28 @@ fileline_initialize (struct backtrace_state *state,
|
|||||||
filename = getexecname ();
|
filename = getexecname ();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
filename = "/proc/self/exe";
|
/* Test this before /proc/self/exe, as the latter exists but points
|
||||||
|
to the wine binary (and thus doesn't work). */
|
||||||
|
filename = windows_executable_filename ();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
filename = "/proc/curproc/file";
|
filename = "/proc/self/exe";
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
filename = "/proc/curproc/file";
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
snprintf (buf, sizeof (buf), "/proc/%ld/object/a.out",
|
snprintf (buf, sizeof (buf), "/proc/%ld/object/a.out",
|
||||||
(long) getpid ());
|
(long) getpid ());
|
||||||
filename = buf;
|
filename = buf;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 6:
|
||||||
filename = sysctl_exec_name1 (state, error_callback, data);
|
filename = sysctl_exec_name1 (state, error_callback, data);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 7:
|
||||||
filename = sysctl_exec_name2 (state, error_callback, data);
|
filename = sysctl_exec_name2 (state, error_callback, data);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 8:
|
||||||
filename = macho_get_executable_path (state, error_callback, data);
|
filename = macho_get_executable_path (state, error_callback, data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user