diff options
4 files changed, 166 insertions, 0 deletions
diff --git a/debian/patches/0001-libshouldbeinlibc-add-assert.h-variant-that-prints-b.patch b/debian/patches/0001-libshouldbeinlibc-add-assert.h-variant-that-prints-b.patch new file mode 100644 index 00000000..1c23b384 --- /dev/null +++ b/debian/patches/0001-libshouldbeinlibc-add-assert.h-variant-that-prints-b.patch @@ -0,0 +1,108 @@ +From 7b40b0208f3ee9af379b83720ff624dd99fdf823 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 20 Jun 2014 15:50:53 +0200 +Subject: [PATCH hurd 1/3] libshouldbeinlibc: add assert.h variant that prints + backtraces + +* libshouldbeinlibc/assert-backtrace.h: New file. +* libshouldbeinlibc/Makefile (installhdrs): Add assert-backtrace.h. +--- + libshouldbeinlibc/Makefile | 4 ++- + libshouldbeinlibc/assert-backtrace.h | 70 ++++++++++++++++++++++++++++++++++++ + 2 files changed, 73 insertions(+), 1 deletion(-) + create mode 100644 libshouldbeinlibc/assert-backtrace.h + +diff --git a/libshouldbeinlibc/Makefile b/libshouldbeinlibc/Makefile +index 14a7939..b32e1bd 100644 +--- a/libshouldbeinlibc/Makefile ++++ b/libshouldbeinlibc/Makefile +@@ -29,7 +29,9 @@ SRCS = termsize.c timefmt.c exec-reauth.c maptime-funcs.c \ + ugids-auth.c ugids-xinl.c ugids-merge.c ugids-imply.c ugids-posix.c \ + ugids-verify-auth.c nullauth.c + installhdrs = idvec.h timefmt.h maptime.h \ +- wire.h portinfo.h portxlate.h cacheq.h ugids.h nullauth.h ++ wire.h portinfo.h portxlate.h cacheq.h ugids.h nullauth.h \ ++ assert-backtrace.h \ ++ + installhdrsubdir = . + + OBJS = $(SRCS:.c=.o) +diff --git a/libshouldbeinlibc/assert-backtrace.h b/libshouldbeinlibc/assert-backtrace.h +new file mode 100644 +index 0000000..099a112 +--- /dev/null ++++ b/libshouldbeinlibc/assert-backtrace.h +@@ -0,0 +1,70 @@ ++/* Augment failing assertions with backtraces. ++ ++ Copyright (C) 2014 Free Software Foundation, Inc. ++ ++ This file is part of the GNU Hurd. ++ ++ The GNU Hurd is free software; you can redistribute it and/or ++ modify it under the terms of the GNU General Public License as ++ published by the Free Software Foundation; either version 2, or (at ++ your option) any later version. ++ ++ The GNU Hurd is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifndef __ASSERT_BACKTRACE__ ++#define __ASSERT_BACKTRACE__ ++ ++#ifndef NDEBUG ++ ++#include <assert.h> ++#include <errno.h> ++#include <execinfo.h> ++#include <stdio.h> ++#include <unistd.h> ++ ++/* This prints an "Assertion failed" message and aborts. */ ++static void __assert_fail_backtrace (const char *__assertion, ++ const char *__file, ++ unsigned int __line, ++ const char *__function) ++ __attribute__ ((noreturn, unused)); ++ ++#undef assert ++#define assert(expr) \ ++ ((expr) \ ++ ? __ASSERT_VOID_CAST (0) \ ++ : __assert_fail_backtrace (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION)) ++ ++static inline void ++__assert_fail_backtrace (const char *__assertion, const char *__file, ++ unsigned int __line, const char *__function) ++{ ++#define SIZE 128 ++#define SKIP 1 ++#define MY_errno (*__errno_location ()) ++ int nptrs; ++ void *buffer[SIZE]; ++ ++ error (0, 0, "%s:%d: %s: Assertion `%s' failed.", ++ __file, __line, __function, __assertion); ++ ++ nptrs = backtrace(buffer, SIZE); ++ if (nptrs == 0) ++ error (1, MY_errno, "backtrace"); ++ ++ backtrace_symbols_fd (&buffer[SKIP], nptrs - SKIP, STDERR_FILENO); ++ fflush (stderr); ++ exit (EXIT_FAILURE); ++#undef MY_errno ++#undef SKIP ++#undef SIZE ++} ++ ++#endif /* NDEBUG */ ++#endif /* __ASSERT_BACKTRACE__ */ +-- +2.1.1 + diff --git a/debian/patches/0002-include-use-assert-backtrace.h-in-refcount.h.patch b/debian/patches/0002-include-use-assert-backtrace.h-in-refcount.h.patch new file mode 100644 index 00000000..2487ed1f --- /dev/null +++ b/debian/patches/0002-include-use-assert-backtrace.h-in-refcount.h.patch @@ -0,0 +1,26 @@ +From 594181754f5067093e7f73217b9b59e98c9abe39 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 20 Jun 2014 15:52:52 +0200 +Subject: [PATCH hurd 2/3] include: use assert-backtrace.h in refcount.h + +* include/refcount.h: Use assert-backtrace.h. +--- + include/refcount.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/refcount.h b/include/refcount.h +index ebde42d..5bb9660 100644 +--- a/include/refcount.h ++++ b/include/refcount.h +@@ -22,7 +22,7 @@ + #ifndef _HURD_REFCOUNT_H_ + #define _HURD_REFCOUNT_H_ + +-#include <assert.h> ++#include <assert-backtrace.h> + #include <limits.h> + #include <stdint.h> + +-- +2.1.1 + diff --git a/debian/patches/0003-hack_why_doesnt_backtrace_symbols_fd_work.patch b/debian/patches/0003-hack_why_doesnt_backtrace_symbols_fd_work.patch new file mode 100644 index 00000000..d2e0b2d4 --- /dev/null +++ b/debian/patches/0003-hack_why_doesnt_backtrace_symbols_fd_work.patch @@ -0,0 +1,29 @@ +From 0dc93993bcdf6e606ed6a8238b4981d9d51294d5 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Wed, 29 Oct 2014 15:00:29 +0100 +Subject: [PATCH hurd 3/3] hack_why_doesnt_backtrace_symbols_fd_work + +--- + libshouldbeinlibc/assert-backtrace.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/libshouldbeinlibc/assert-backtrace.h b/libshouldbeinlibc/assert-backtrace.h +index 099a112..825c9cf 100644 +--- a/libshouldbeinlibc/assert-backtrace.h ++++ b/libshouldbeinlibc/assert-backtrace.h +@@ -58,6 +58,12 @@ __assert_fail_backtrace (const char *__assertion, const char *__file, + if (nptrs == 0) + error (1, MY_errno, "backtrace"); + ++#ifndef why_doesnt_backtrace_symbols_fd_work ++ int i; ++ for (i = SKIP; i < nptrs; i++) ++ error (0, 0, "%d: %p", i - SKIP, buffer[i]); ++#endif ++ + backtrace_symbols_fd (&buffer[SKIP], nptrs - SKIP, STDERR_FILENO); + fflush (stderr); + exit (EXIT_FAILURE); +-- +2.1.1 + diff --git a/debian/patches/series b/debian/patches/series index 205aec0d..a4d2fe8d 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -58,3 +58,6 @@ mach-defpager-protected-payload.patch #procfs-0007-procfs-provide-magic-retry-response-for-proc-self.patch startup-avoid-broken-puts.patch libpager-fixthreads.patch +0001-libshouldbeinlibc-add-assert.h-variant-that-prints-b.patch +0002-include-use-assert-backtrace.h-in-refcount.h.patch +0003-hack_why_doesnt_backtrace_symbols_fd_work.patch |