public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>, Roland McGrath <roland@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix backtrace in statically linked programs on ia64/x86-64/s390{,x}
Date: Tue, 08 Jun 2004 13:11:00 -0000	[thread overview]
Message-ID: <20040608105735.GE5191@sunsite.ms.mff.cuni.cz> (raw)

Hi!

libgcc_s.so's unwinder has no way to get at the statically linked binary's
unwind tables.  For -static, we really want to use _Unwind_* stuff
from libgcc_eh.a.

2004-06-08  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/s390/s390-32/backtrace.c (init): Guard with #ifdef SHARED.
	(unwind_backtrace, unwind_getip): Define #ifndef SHARED.
	(__backtrace): Don't call init #ifndef SHARED.
	* sysdeps/s390/s390-64/backtrace.c (init): Guard with #ifdef SHARED.
	(unwind_backtrace, unwind_getip): Define #ifndef SHARED.
	(__backtrace): Don't call init #ifndef SHARED.
	* sysdeps/ia64/backtrace.c (init): Guard with #ifdef SHARED.
	(unwind_backtrace, unwind_getip): Define #ifndef SHARED.
	(__backtrace): Don't call init #ifndef SHARED.

--- libc/sysdeps/s390/s390-32/backtrace.c.jj	2003-12-11 22:23:20.000000000 +0100
+++ libc/sysdeps/s390/s390-32/backtrace.c	2004-06-08 14:56:56.516905061 +0200
@@ -1,5 +1,5 @@
 /* Return backtrace of current program state.
-   Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -61,6 +61,7 @@ struct trace_arg
   int cnt, size;
 };
 
+#ifdef SHARED
 static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
 static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
 
@@ -77,6 +78,10 @@ init (void)
   if (unwind_getip == NULL)
     unwind_backtrace = NULL;
 }
+#else
+# define unwind_backtrace _Unwind_Backtrace
+# define unwind_getip _Unwind_GetIP
+#endif
 
 static int
 __backchain_backtrace (void **array, int size)
@@ -122,9 +127,11 @@ int
 __backtrace (void **array, int size)
 {
   struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+#ifdef SHARED
   __libc_once_define (static, once);
 
   __libc_once (once, init);
+#endif
   if (unwind_backtrace == NULL)
     return __backchain_backtrace (array, size);
 
--- libc/sysdeps/s390/s390-64/backtrace.c.jj	2003-12-11 20:18:30.000000000 +0100
+++ libc/sysdeps/s390/s390-64/backtrace.c	2004-06-08 14:57:59.804563089 +0200
@@ -1,5 +1,5 @@
 /* Return backtrace of current program state.  64 bit S/390 version.
-   Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -60,6 +60,7 @@ struct trace_arg
   int cnt, size;
 };
 
+#ifdef SHARED
 static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
 static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
 
@@ -76,6 +77,10 @@ init (void)
   if (unwind_getip == NULL)
     unwind_backtrace = NULL;
 }
+#else
+# define unwind_backtrace _Unwind_Backtrace
+# define unwind_getip _Unwind_GetIP
+#endif
 
 int
 __backchain_backtrace (void **array, int size)
@@ -121,9 +126,11 @@ int
 __backtrace (void **array, int size)
 {
   struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+#ifdef SHARED
   __libc_once_define (static, once);
 
   __libc_once (once, init);
+#endif
   if (unwind_backtrace == NULL)
     return __backchain_backtrace (array, size);
 
--- libc/sysdeps/ia64/backtrace.c.jj	2003-10-24 14:02:44.000000000 +0200
+++ libc/sysdeps/ia64/backtrace.c	2004-06-08 14:49:37.328613321 +0200
@@ -1,5 +1,5 @@
 /* Return backtrace of current program state.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
 
@@ -30,6 +30,7 @@ struct trace_arg
   int cnt, size;
 };
 
+#ifdef SHARED
 static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
 static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
 
@@ -46,6 +47,10 @@ init (void)
   if (unwind_getip == NULL)
     unwind_backtrace = NULL;
 }
+#else
+# define unwind_backtrace _Unwind_Backtrace
+# define unwind_getip _Unwind_GetIP
+#endif
 
 static _Unwind_Reason_Code
 backtrace_helper (struct _Unwind_Context *ctx, void *a)
@@ -67,11 +72,13 @@ __backtrace (array, size)
      int size;
 {
   struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+#ifdef SHARED
   __libc_once_define (static, once);
 
   __libc_once (once, init);
   if (unwind_backtrace == NULL)
     return 0;
+#endif
 
   if (size >= 1)
     unwind_backtrace (backtrace_helper, &arg);

	Jakub

             reply	other threads:[~2004-06-08 13:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-08 13:11 Jakub Jelinek [this message]
2004-06-08 13:42 ` Steve Munroe
2004-06-08 13:53   ` Jakub Jelinek
2004-06-11 19:28 ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040608105735.GE5191@sunsite.ms.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    --cc=roland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).