This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add C backtrace API.
authorH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Wed, 11 Jun 2014 07:18:26 +0000 (09:18 +0200)
committerH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Wed, 11 Jun 2014 07:18:26 +0000 (09:18 +0200)
Backport of 470dd224e4b587137a482c6db3d765860bcba19c
with additional changes

U/modified/d_backtrace.U [new file with mode: 0644]
U/modified/d_dladdr.U [new file with mode: 0644]
U/modified/i_execinfo.U [new file with mode: 0644]
U/modified/libs.U
U/perl/i_bfd.U [new file with mode: 0644]
U/perl/usebacktrace.U [new file with mode: 0644]

diff --git a/U/modified/d_backtrace.U b/U/modified/d_backtrace.U
new file mode 100644 (file)
index 0000000..efda7ed
--- /dev/null
@@ -0,0 +1,31 @@
+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 2014, H.Merijn Brand
+?RCS: 
+?RCS: You may redistribute only under the terms of the Artistic License,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic License; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?RCS:
+?RCS: $Log: d_backtrace.U,v $
+?RCS:
+?MAKE:d_backtrace: Inlibc
+?MAKE: -pick add $@ %<
+?S:d_backtrace:
+?S:    This variable conditionally defines the HAS_BACKTRACE symbol, which
+?S:    indicates to the C program that the backtrace() routine is available
+?S:    to get a stack trace.
+?S:.
+?C:HAS_BACKTRACE:
+?C:    This symbol, if defined, indicates that the backtrace() routine is
+?C:    available to get a stack trace.  The <execinfo.h> header must be
+?C:    included to use this routine.
+?C:.
+?H:#$d_backtrace HAS_BACKTRACE /**/
+?H:.
+?LINT:set d_backtrace
+: see if backtrace exists
+set backtrace d_backtrace
+eval $inlibc
+
diff --git a/U/modified/d_dladdr.U b/U/modified/d_dladdr.U
new file mode 100644 (file)
index 0000000..945be0b
--- /dev/null
@@ -0,0 +1,31 @@
+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 2014, H.Merijn Brand
+?RCS: 
+?RCS: You may redistribute only under the terms of the Artistic License,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic License; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?RCS:
+?RCS: $Log: d_dladdr.U,v $
+?RCS:
+?MAKE:d_dladdr: Inlibc
+?MAKE: -pick add $@ %<
+?S:d_dladdr:
+?S:    This variable conditionally defines the HAS_DLADDR symbol, which
+?S:    indicates to the C program that the dladdr() routine is available
+?S:    to get a stack trace.
+?S:.
+?C:HAS_DLADDR:
+?C:    This symbol, if defined, indicates that the dladdr() routine is
+?C:    available to get a stack trace.  The <execinfo.h> header must be
+?C:    included to use this routine.
+?C:.
+?H:#$d_dladdr HAS_DLADDR       /**/
+?H:.
+?LINT:set d_dladdr
+: see if dladdr exists
+set dladdr d_dladdr
+eval $inlibc
+
diff --git a/U/modified/i_execinfo.U b/U/modified/i_execinfo.U
new file mode 100644 (file)
index 0000000..f9b16a7
--- /dev/null
@@ -0,0 +1,27 @@
+?RCS: $Id: i_execinfo.U 34 2010-11-27 11:55:39Z rmanfredi $
+?RCS:
+?RCS: Copyright (c) 2011, Raphael Manfredi
+?RCS: 
+?RCS: You may redistribute only under the terms of the Artistic License,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic License; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?RCS:
+?MAKE:i_execinfo: Inhdr
+?MAKE: -pick add $@ %<
+?S:i_execinfo:
+?S:    This variable conditionally defines the I_EXECINFO symbol, and indicates
+?S:    whether a C program may include <execinfo.h>, for backtrace() support.
+?S:.
+?C:I_EXECINFO:
+?C:    This symbol, if defined, indicates to the C program that it should
+?C:    include <execinfo.h> for backtrace() support.
+?C:.
+?H:#$i_execinfo I_EXECINFO             /**/
+?H:.
+?LINT:set i_execinfo
+: see if this is an execinfo.h system
+set execinfo.h i_execinfo
+eval $inhdr
+
index bca283f..a5468f8 100644 (file)
@@ -88,6 +88,7 @@
 ?INIT:libswanted=''
 ?INIT:: some systems want to use only the non-versioned libso:s
 ?INIT:ignore_versioned_solibs=''
+?LINT:extern usecbacktrace
 ?LINT:extern libscheck
 ?LINT:extern p
 ?LINT:use uselongdouble
@@ -106,6 +107,9 @@ esac
 case "$usesocks" in
 "$define") libswanted="$libswanted socks5 socks5_sh" ;;
 esac
+case "$usecbacktrace" in
+"$define") libswanted="$libswanted bfd" ;;
+esac
 libsfound=''
 libsfiles=''
 libsdirs=''
diff --git a/U/perl/i_bfd.U b/U/perl/i_bfd.U
new file mode 100644 (file)
index 0000000..9ea7413
--- /dev/null
@@ -0,0 +1,24 @@
+?RCS: $Id: i_bfd.U,v $
+?RCS:
+?RCS: Copyright (c) 2014 H.Merijn Brand
+?RCS:
+?RCS: You may distribute under the terms of either the GNU General Public
+?RCS: License or the Artistic License, as specified in the README file.
+?RCS:
+?MAKE:i_bfd: Inhdr Hasfield
+?MAKE: -pick add $@ %<
+?S:i_bfd:
+?S:    This variable conditionally defines the I_BFD symbol, and
+?S:    indicates whether a C program can include <bfd.h>.
+?S:.
+?C:I_BFD:
+?C:    This symbol, if defined, indicates that <bfd.h> exists and
+?C:    can be included.
+?C:.
+?H:#$i_bfd     I_BFD           /**/
+?H:.
+?LINT:set i_bfd
+: see if this is a bfd.h system
+set bfd.h i_bfd
+eval $inhdr
+
diff --git a/U/perl/usebacktrace.U b/U/perl/usebacktrace.U
new file mode 100644 (file)
index 0000000..5fa5b3a
--- /dev/null
@@ -0,0 +1,43 @@
+?RCS: $Id: usecbacktrace.U,v $
+?RCS:
+?RCS: Copyright (c) 2014 H.Merijn Brand
+?RCS:
+?RCS: You may distribute under the terms of either the GNU General Public
+?RCS: License or the Artistic License, as specified in the README file.
+?RCS:
+?RCS: $Log: usecbacktrace.U,v $
+?RCS:
+?MAKE:usecbacktrace: Myread Oldconfig Setvar Getfile d_backtrace
+?MAKE: -pick add $@ %<
+?Y:TOP
+?S:usecbacktrace:
+?S:    This variable indicates whether we are compiling with backtrace
+?S:    support.
+?S:.
+?C:USE_CBACKTRACE:
+?C:    This symbol, if defined, indicates that Perl should
+?C:    be built with support for backtrace.
+?C:.
+?H:#$usecbacktrace USE_CBACKTRACE              /**/
+?H:.
+?D:usecbacktrace=''
+?LINT:extern ccflags
+?LINT:change ccflags
+: add flags if using c backtrace
+case "$usecbacktrace" in
+  [yY]*|true|$define)
+    case "$d_backtrace" in
+      [yY]*|true|$define)
+        case " $ccflags " in
+         *" -DUSE_C_BACKTRACE "*) ;; # Already there.
+         *) ccflags="$ccflags -DUSE_C_BACKTRACE -g" ;;
+         esac
+        ;;
+      *)
+        echo "This system does not support backtrace" >&4
+        usecbacktrace=$undef
+        ;;
+      esac
+    ;;
+  esac
+