summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2018-04-10 16:35:07 +1200
committerKarolin Seeger <kseeger@samba.org>2018-06-04 09:54:23 +0200
commit0dc480678749484819c72533c0e00552627ab262 (patch)
tree424c49d4efbfa371ee79b0cf2bc88fbcd0c0ff0d /source3/lib
parent67d037c58f93845640cfff792686d4797cb86a7c (diff)
downloadsamba-0dc480678749484819c72533c0e00552627ab262.tar.gz
lib/util: Move log_stack_trace() to common code
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13454 (cherry picked from commit bf9551902afdb32310db4a3381964c435dd08bf0)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 98c47b3df9f..5f786f95d3e 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -839,103 +839,6 @@ void smb_panic_s3(const char *why)
}
/*******************************************************************
- Print a backtrace of the stack to the debug log. This function
- DELIBERATELY LEAKS MEMORY. The expectation is that you should
- exit shortly after calling it.
-********************************************************************/
-
-#ifdef HAVE_LIBUNWIND_H
-#include <libunwind.h>
-#endif
-
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>
-#endif
-
-void log_stack_trace(void)
-{
-#ifdef HAVE_LIBUNWIND
- /* Try to use libunwind before any other technique since on ia64
- * libunwind correctly walks the stack in more circumstances than
- * backtrace.
- */
- unw_cursor_t cursor;
- unw_context_t uc;
- unsigned i = 0;
-
- char procname[256];
- unw_word_t ip, sp, off;
-
- procname[sizeof(procname) - 1] = '\0';
-
- if (unw_getcontext(&uc) != 0) {
- goto libunwind_failed;
- }
-
- if (unw_init_local(&cursor, &uc) != 0) {
- goto libunwind_failed;
- }
-
- DEBUG(0, ("BACKTRACE:\n"));
-
- do {
- ip = sp = 0;
- unw_get_reg(&cursor, UNW_REG_IP, &ip);
- unw_get_reg(&cursor, UNW_REG_SP, &sp);
-
- switch (unw_get_proc_name(&cursor,
- procname, sizeof(procname) - 1, &off) ) {
- case 0:
- /* Name found. */
- case -UNW_ENOMEM:
- /* Name truncated. */
- DEBUGADD(0, (" #%u %s + %#llx [ip=%#llx] [sp=%#llx]\n",
- i, procname, (long long)off,
- (long long)ip, (long long) sp));
- break;
- default:
- /* case -UNW_ENOINFO: */
- /* case -UNW_EUNSPEC: */
- /* No symbol name found. */
- DEBUGADD(0, (" #%u %s [ip=%#llx] [sp=%#llx]\n",
- i, "<unknown symbol>",
- (long long)ip, (long long) sp));
- }
- ++i;
- } while (unw_step(&cursor) > 0);
-
- return;
-
-libunwind_failed:
- DEBUG(0, ("unable to produce a stack trace with libunwind\n"));
-
-#elif HAVE_BACKTRACE_SYMBOLS
- void *backtrace_stack[BACKTRACE_STACK_SIZE];
- size_t backtrace_size;
- char **backtrace_strings;
-
- /* get the backtrace (stack frames) */
- backtrace_size = backtrace(backtrace_stack,BACKTRACE_STACK_SIZE);
- backtrace_strings = backtrace_symbols(backtrace_stack, backtrace_size);
-
- DEBUG(0, ("BACKTRACE: %lu stack frames:\n",
- (unsigned long)backtrace_size));
-
- if (backtrace_strings) {
- int i;
-
- for (i = 0; i < backtrace_size; i++)
- DEBUGADD(0, (" #%u %s\n", i, backtrace_strings[i]));
-
- /* Leak the backtrace_strings, rather than risk what free() might do */
- }
-
-#else
- DEBUG(0, ("unable to produce a stack trace on this platform\n"));
-#endif
-}
-
-/*******************************************************************
A readdir wrapper which just returns the file name.
********************************************************************/