mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-12-26 21:13:42 +01:00
Include "config.h" if we have it.
Declare "backtrace()" manually if we don't have execinfo.h. Declare "sighandler_t" manually if the system doesn't do it for us. On ia64, print sc->sc_ip only if we're on Linux. (Logical change 1.63)
This commit is contained in:
parent
d798e7dd07
commit
00cfbc61fe
1 changed files with 15 additions and 1 deletions
16
tests/bt.c
16
tests/bt.c
|
@ -25,8 +25,16 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <execinfo.h>
|
||||
#if HAVE_EXECINFO_H
|
||||
# include <execinfo.h>
|
||||
#else
|
||||
extern int backtrace (void **, int);
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -37,6 +45,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|||
#define panic(args...) \
|
||||
{ fprintf (stderr, args); exit (-1); }
|
||||
|
||||
#ifndef HAVE_SIGHANDLER_T
|
||||
typedef RETSIGTYPE (*sighandler_t) (int);
|
||||
#endif
|
||||
|
||||
static void
|
||||
do_backtrace (void)
|
||||
{
|
||||
|
@ -117,7 +129,9 @@ sighandler (int signal, void *siginfo, struct sigcontext *sc)
|
|||
|
||||
printf ("sighandler: got signal %d, sp=%p", signal, &sp);
|
||||
#if UNW_TARGET_IA64
|
||||
# if defined(__linux__)
|
||||
printf (" @ %lx", sc->sc_ip);
|
||||
# endif
|
||||
#elif UNW_TARGET_X86
|
||||
printf (" @ %lx", sc.eip);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue