[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patches] PATCH: OPTION_EGLIBC_BACKTRACE option group
- To: patches@xxxxxxxxxx
- Subject: [patches] PATCH: OPTION_EGLIBC_BACKTRACE option group
- From: Jim Blandy <jimb@xxxxxxxxxxxxxxxx>
- Date: Fri, 21 Sep 2007 17:37:31 -0700
I've committed the following:
ChangeLog.eglibc:
2007-09-21 Jim Blandy <jimb@xxxxxxxxxxxxxxxx>
Implement the OPTION_EGLIBC_BACKTRACE option group.
* option-groups.def (OPTION_EGLIBC_BACKTRACE): New entry.
* option-groups.defaults (OPTION_EGLIBC_BACKTRACE): Initialize.
* debug/Makefile (routines): Put all backtrace, backtracesyms, and
backtracesymsfd in the group.
(tests): Put backtrace-tst in the group.
(CFLAGS-segfault.c): Define OPTION_EGLIBC_BACKTRACE as
appropriate.
* debug/segfault.c (catch_segfault): Only produce a backtrace when
the group is enabled.
* sysdeps/unix/sysv/linux/Makefile (CFLAGS-libc_fatal.c): Define
OPTION_EGLIBC_BACKTRACE as appropriate.
* sysdeps/unix/sysv/linux/libc_fatal.c (__libc_message): Don't
print a backtrace if the group is not enabled.
* nptl/Makefile (tests): Put tst-backtrace1 in the option group.
Index: option-groups.def
===================================================================
--- option-groups.def (revision 3541)
+++ option-groups.def (working copy)
@@ -71,6 +71,20 @@
inet6_rth_segments
inet6_rth_space
+config OPTION_EGLIBC_BACKTRACE
+ bool "Functions for producing backtraces"
+ help
+ This option group includes functions for producing a list of
+ the function calls that are currently active in a thread, from
+ within the thread itself. These functions are often used
+ within signal handlers, to produce diagnostic output.
+
+ This option group includes the following functions:
+
+ backtrace
+ backtrace_symbols
+ backtrace_symbols_fd
+
config OPTION_EGLIBC_BSD
bool "BSD-specific functions, and their compatibility stubs"
help
Index: debug/Makefile
===================================================================
--- debug/Makefile (revision 3541)
+++ debug/Makefile (working copy)
@@ -26,7 +26,7 @@
headers := execinfo.h
distribute = sigcontextinfo.h register-dump.h frame.h
-routines = backtrace backtracesyms backtracesymsfd noophooks \
+routines = noophooks \
memcpy_chk memmove_chk mempcpy_chk memset_chk stpcpy_chk \
strcat_chk strcpy_chk strncat_chk strncpy_chk stpncpy_chk \
sprintf_chk vsprintf_chk snprintf_chk vsnprintf_chk \
@@ -47,6 +47,7 @@
stack_chk_fail fortify_fail \
$(static-only-routines)
routines-$(OPTION_EGLIBC_GETLOGIN) += getlogin_r_chk
+routines-$(OPTION_EGLIBC_BACKTRACE) += backtrace backtracesyms backtracesymsfd
static-only-routines := warning-nop stack_chk_fail_local
CFLAGS-backtrace.c = -fno-omit-frame-pointer
@@ -89,14 +90,18 @@
tst-lfschk2-ENV = LOCPATH=$(common-objpfx)localedata
tst-lfschk3-ENV = LOCPATH=$(common-objpfx)localedata
-tests = backtrace-tst tst-chk1 tst-chk2 tst-chk3 \
+tests = tst-chk1 tst-chk2 tst-chk3 \
tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk
+tests-$(OPTION_EGLIBC_BACKTRACE) += backtrace-tst
extra-libs = libSegFault libpcprofile
extra-libs-others = $(extra-libs)
libSegFault-routines = segfault
libSegFault-inhibit-o = $(filter-out .os,$(object-suffixes))
+OPTION_EGLIBC_BACKTRACE-CFLAGS-$(OPTION_EGLIBC_BACKTRACE) \
+ = -DOPTION_EGLIBC_BACKTRACE
+CFLAGS-segfault.c = $(OPTION_EGLIBC_BACKTRACE-CFLAGS-y)
libpcprofile-routines = pcprofile
libpcprofile-inhibit-o = $(filter-out .os,$(object-suffixes))
Index: debug/segfault.c
===================================================================
--- debug/segfault.c (revision 3541)
+++ debug/segfault.c (working copy)
@@ -95,6 +95,7 @@
REGISTER_DUMP;
#endif
+#ifdef OPTION_EGLIBC_BACKTRACE
WRITE_STRING ("\nBacktrace:\n");
/* Get the backtrace. */
@@ -117,6 +118,7 @@
/* Now generate nicely formatted output. */
__backtrace_symbols_fd (arr + i, cnt - i, fd);
+#endif
#ifdef HAVE_PROC_SELF
/* Now the link map. */
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
--- sysdeps/unix/sysv/linux/Makefile (revision 3541)
+++ sysdeps/unix/sysv/linux/Makefile (working copy)
@@ -20,6 +20,10 @@
CFLAGS-gethostid.c = -fexceptions $(inet-CFLAGS-y)
+OPTION_EGLIBC_BACKTRACE-CFLAGS-$(OPTION_EGLIBC_BACKTRACE) \
+ = -DOPTION_EGLIBC_BACKTRACE
+CFLAGS-libc_fatal.c += $(OPTION_EGLIBC_BACKTRACE-CFLAGS-y)
+
sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
sys/klog.h sys/kdaemon.h \
sys/user.h sys/procfs.h sys/prctl.h \
Index: sysdeps/unix/sysv/linux/libc_fatal.c
===================================================================
--- sysdeps/unix/sysv/linux/libc_fatal.c (revision 3541)
+++ sysdeps/unix/sysv/linux/libc_fatal.c (working copy)
@@ -143,6 +143,7 @@
if (do_abort)
{
+#ifdef OPTION_EGLIBC_BACKTRACE
if (do_abort > 1 && written)
{
void *addrs[64];
@@ -165,6 +166,7 @@
close_not_cancel_no_status (fd2);
}
}
+#endif /* OPTION_EGLIBC_BACKTRACE */
/* Terminate the process. */
abort ();
Index: option-groups.defaults
===================================================================
--- option-groups.defaults (revision 3541)
+++ option-groups.defaults (working copy)
@@ -9,6 +9,7 @@
#
# By default, all option groups are enabled.
OPTION_EGLIBC_ADVANCED_INET6 = y
+OPTION_EGLIBC_BACKTRACE = y
OPTION_EGLIBC_BSD = y
OPTION_EGLIBC_CATGETS = y
OPTION_EGLIBC_CHARSETS = y
Index: nptl/Makefile
===================================================================
--- nptl/Makefile (revision 3541)
+++ nptl/Makefile (working copy)
@@ -260,7 +260,6 @@
tst-clock1 \
tst-context1 \
tst-sched1 \
- tst-backtrace1 \
tst-oddstacklimit \
tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \
tst-getpid1 tst-getpid2 tst-getpid3 \
@@ -270,6 +269,9 @@
# This test uses the posix_spawn functions.
tests-$(OPTION_EGLIBC_SPAWN) += tst-exec1
+# This test uses the 'backtrace' functions.
+tests-$(OPTION_EGLIBC_BACKTRACE) += tst-backtrace1
+
# Files which must not be linked with libpthread.
tests-nolibpthread = tst-unload