[Git][NTPsec/ntpsec][master] 3 commits: libisc: replace HAVE_LIBCTRACE with HAVE_BACKTRACE_SYMBOLS_FD

Gary E. Miller gitlab at mg.gitlab.com
Thu Jun 1 22:53:05 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
80404703 by Gary E. Miller at 2017-06-01T13:58:06-07:00
libisc: replace HAVE_LIBCTRACE with HAVE_BACKTRACE_SYMBOLS_FD

Instead of manually set HAVE_LIBCTRACE use automatic HAVE_BACKTRACE_SYMBOLS_FD

- - - - -
c9067bae by Gary E. Miller at 2017-06-01T15:27:08-07:00
libisc: note which OS support backtrace().

- - - - -
33bc854e by Gary E. Miller at 2017-06-01T15:50:58-07:00
libisc: test for __Unwind_Backtrace(), don't guess.

Change anem from BACKTRACE_GCC to BACKTRACE_UNWIND since this is available
also on OS X with llvm.

- - - - -


3 changed files:

- devel/ifdex-ignores
- libisc/backtrace.c
- wscript


Changes:

=====================================
devel/ifdex-ignores
=====================================
--- a/devel/ifdex-ignores
+++ b/devel/ifdex-ignores
@@ -39,7 +39,6 @@ DEBUG
 ISC_LIST_CHECKINIT	# Debugging flag
 ISC_PLATFORM_USEBACKTRACE	# Use the ISC backtrace code on assertions
 ISC_UTIL_TRACEON	# Enables trace code in ISC service routines.
-HAVE_LIBCTRACE		# Some random C tracing lib - NTP Classic never sets this
 DEBUG_PARSELIB		# Enable debugging in the parse library.
 NTP_DEBUG_LISTS		# Debug list handling
 DEBUG_PPS720		# Only in refclock_true.c


=====================================
libisc/backtrace.c
=====================================
--- a/libisc/backtrace.c
+++ b/libisc/backtrace.c
@@ -10,7 +10,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#ifdef HAVE_LIBCTRACE
+#ifdef HAVE_BACKTRACE_SYMBOLS_FD
 #include <execinfo.h>
 #endif
 
@@ -23,9 +23,9 @@
  * Getting a back trace of a running process is tricky and highly platform
  * dependent.  Our current approach is as follows:
  * 1. If the system library supports the "backtrace()" function, use it.
- * 2. Otherwise, if the compiler is gcc and the architecture is x86_64 or IA64,
- *    then use gcc's (hidden) Unwind_Backtrace() function.  Note that this
- *    function doesn't work for C programs on many other architectures.
+ *    OS X support this starting at with SDK 10.5.  glibc since version 2.1
+ * 2. Otherwise, if unwind.h exists then use the __Unwind_Backtrace() function.
+ *    This function is available on Linux and  OS X.
  * 3. Otherwise, if the architecture x86 or x86_64, try to unwind the stack
  *    frame following frame pointers.  This assumes the executable binary
  *    compiled with frame pointers; this is not always true for x86_64 (rather,
@@ -35,15 +35,15 @@
  *    due to this problem, the whole package should be rebuilt with
  *    --disable-backtrace.
  */
-#ifdef HAVE_LIBCTRACE
+#ifdef HAVE_BACKTRACE_SYMBOLS_FD
 #define BACKTRACE_LIBC
-#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__ia64__))
-#define BACKTRACE_GCC
+#elif defined(HAVE__UNWIND_BACKTRACE)
+#define BACKTRACE_UNWIND
 #elif defined(__x86_64__) || defined(__i386__)
 #define BACKTRACE_X86STACK
 #else
 #define BACKTRACE_DISABLED
-#endif  /* HAVE_LIBCTRACE */
+#endif  /* HAVE_BACKTRACE_SYMBOLS_FD */
 #else	/* !ISC_PLATFORM_USEBACKTRACE */
 #define BACKTRACE_DISABLED
 #endif	/* ISC_PLATFORM_USEBACKTRACE */
@@ -72,9 +72,8 @@ isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes) {
 	*nframes = n;
 	return (ISC_R_SUCCESS);
 }
-#elif defined(BACKTRACE_GCC)
-extern int _Unwind_Backtrace(void* fn, void* a);
-extern void* _Unwind_GetIP(void* ctx);
+#elif defined(BACKTRACE_UNWIND)
+#include <unwind.h>
 
 typedef struct {
 	void **result;


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -608,7 +608,9 @@ int main(int argc, char **argv) {
     # Optional functions.  Do all function checks here, otherwise
     # we're likely to duplicate them.
     functions = (
+        ('_Unwind_Backtrace', ["unwind.h"]),
         ('adjtimex', ["sys/time.h", "sys/timex.h"]),
+        ('backtrace_symbols_fd', ["execinfo.h"]),
         ('closefrom', ["stdlib.h"]),
         ('clock_gettime', ["time.h"], "RT"),
         ('clock_settime', ["time.h"], "RT"),



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/24ddb16ebbce678df999b4bb471b2d57f90d43cf...33bc854ecb014d3d125832ec062ec390990be517

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/24ddb16ebbce678df999b4bb471b2d57f90d43cf...33bc854ecb014d3d125832ec062ec390990be517
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170601/e1db0601/attachment.html>


More information about the vc mailing list