1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2001-2009 Oracle. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12#if defined(HAVE_SYSTEM_INCLUDE_FILES) && defined(HAVE_BACKTRACE) && \ 13 defined(HAVE_BACKTRACE_SYMBOLS) && defined(HAVE_EXECINFO_H) 14#include <execinfo.h> 15#endif 16 17/* 18 * __os_stack -- 19 * Output a stack trace to the message file handle. 20 * 21 * PUBLIC: void __os_stack __P((ENV *)); 22 */ 23void 24__os_stack(env) 25 ENV *env; 26{ 27#if defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS) 28 void *array[200]; 29 size_t i, size; 30 char **strings; 31 32 /* 33 * Solaris and the GNU C library support this interface. Solaris 34 * has additional interfaces (printstack and walkcontext), I don't 35 * know if they offer any additional value or not. 36 */ 37 size = backtrace(array, sizeof(array) / sizeof(array[0])); 38 strings = backtrace_symbols(array, size); 39 40 for (i = 0; i < size; ++i) 41 __db_errx(env, "%s", strings[i]); 42 free(strings); 43#endif 44 COMPQUIET(env, NULL); 45} 46