aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tmate/0001-Fix-building-with-or-without-backtrace-3.patch
blob: bebb41a374ba391113e6d8cca4f271b139606ae6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
From c56f00dd22611274fd6ac7626d85ceca8692abf6 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 28 Sep 2017 10:28:42 +0000
Subject: [PATCH] Fix building with or without backtrace(3)

backtrace(3) and execinfo.h are GNU extensions and may or may not be
available, and they may be provided via libexecinfo.

Fix detection of libexecinfo and allow building without any support of
backtrace, in which case we let kernel create core dump.

Fixes #116
---
 configure.ac  |  5 +++++
 tmate-debug.c | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/configure.ac b/configure.ac
index 02d2872b..05c1c482 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,6 +102,7 @@ AC_CHECK_HEADERS(
 		bitstring.h \
 		curses.h \
 		dirent.h \
+		execinfo.h \
 		fcntl.h \
 		inttypes.h \
 		libutil.h \
@@ -121,9 +122,13 @@ AC_CHECK_HEADERS(
 # Look for library needed for flock.
 AC_SEARCH_LIBS(flock, bsd)
 
+# Look for library needed for backtrace
+AC_SEARCH_LIBS(backtrace, execinfo)
+
 # Check for some functions that are replaced or omitted.
 AC_CHECK_FUNCS(
 	[ \
+		backtrace \
 		dirfd \
 		flock \
 		setproctitle \
diff --git a/tmate-debug.c b/tmate-debug.c
index f1fd971f..f58efe0e 100644
--- a/tmate-debug.c
+++ b/tmate-debug.c
@@ -1,10 +1,19 @@
+#ifdef HAVE_EXECINFO_H
 #include <execinfo.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <regex.h>
 #include <signal.h>
 #include "tmate.h"
 
+#ifndef HAVE_BACKTRACE
+
+void tmate_print_stack_trace(void) {}
+void tmate_catch_sigsegv(void) {}
+
+#else
+
 #if DEBUG
 
 static int print_resolved_stack_frame(const char *frame)
@@ -88,3 +97,4 @@ void tmate_catch_sigsegv(void)
 {
 	signal(SIGSEGV, handle_sigsegv);
 }
+#endif
-- 
2.14.1