59 #include "qplatformdefs.h" 60 #include "private/qcrashhandler_p.h" 63 #ifndef QT_NO_CRASHHANDLER 73 #if defined(__GLIBC__) && (__GLIBC__ >= 2) && !defined(__UCLIBC__) && !defined(QT_LINUXBASE) 76 # include <execinfo.h> 82 int stack_size = backtrace(stack,
sizeof(stack) /
sizeof(
void *));
83 char **stack_symbols = backtrace_symbols(stack, stack_size);
84 fprintf(outb,
"Stack [%d]:\n", stack_size);
85 if(FILE *cppfilt = popen(
"c++filt",
"rw")) {
86 dup2(fileno(outb), fileno(cppfilt));
87 for(
int i = stack_size-1; i>=0; --i)
88 fwrite(stack_symbols[i], 1, strlen(stack_symbols[i]), cppfilt);
91 for(
int i = stack_size-1; i>=0; --i)
92 fprintf(outb,
"#%d %p [%s]\n", i, stack[i], stack_symbols[i]);
105 #include <sys/types.h> 106 #include <sys/wait.h> 107 #if defined(Q_OS_IRIX) && defined(USE_LIBEXC) 128 va_start(args, format);
136 if(FILE *inb = popen(foo,
"r")) {
138 int len = fread(buffer, 1,
sizeof(buffer), inb);
142 fwrite(
"Output from ", 1, strlen(
"Output from "), outb);
144 fwrite(cmd, 1, strlen(cmd), outb);
145 fwrite(
"\n", 1, 1, outb);
148 fwrite(buffer, 1, len, outb);
158 globalProgName = argv[0];
168 #if defined(Q_OS_AIX) 181 globalProgName, (
int)getpid()))
183 #elif defined(Q_OS_FREEBSD) 193 "shell kill -CONT %d\n" 196 globalProgName, (
int)getpid(), (
int)getpid()))
198 #elif defined(Q_OS_HPUX) 214 (
int)getpid(), globalProgName))
222 globalProgName, (
int)getpid()))
224 #elif defined(Q_OS_IRIX) 232 #
if !defined(__GNUC__)
241 # if defined(USE_LIBEXC) 242 if(trace_back_stack_and_print())
260 globalProgName, (
int)getpid()))
262 #elif defined(Q_OS_OSF) 268 (
int)getpid(), globalProgName))
276 globalProgName, (
int)getpid()))
278 #elif defined(Q_OS_SCO) 293 globalProgName, (
int)getpid()))
301 globalProgName, (
int)getpid()))
303 #elif defined(Q_OS_SOLARIS) 308 globalProgName, (
int)getpid()))
325 globalProgName, (
int)getpid()))
340 globalProgName, (
int)getpid()))
342 #elif defined(Q_OS_INTEGRITY) 344 CheckSuccess(Failure);
350 # if !defined(__GNUC__) 355 globalProgName, (
int)getpid()))
375 globalProgName, (
int)getpid()))
378 const char debug_err[] =
"No debugger found\n";
379 fwrite(debug_err, strlen(debug_err), 1, outb);
387 signal(sig, SIG_DFL);
389 (*QSegfaultHandler::callback)();
393 if(
char *crash_loc = ::getenv(
"QT_CRASH_OUTPUT")) {
394 if(FILE *new_outb = fopen(crash_loc,
"w")) {
395 fprintf(stderr,
"Crash (backtrace written to %s)!!!\n", crash_loc);
399 fprintf(outb,
"Crash!!!\n");
414 SignalAction.sa_flags = 0;
416 sigemptyset(&SignalAction.sa_mask);
423 #endif // QT_NO_CRASHHANDLER #define QT_END_NAMESPACE
This macro expands to.
static QtCrashHandler callback
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
static char * globalProgName
friend void qt_signal_handler(int)
static void initialize(char **, int)
#define QT_BEGIN_NAMESPACE
This macro expands to.
void qt_signal_handler(int sig)
static bool backtrace_command(FILE *outb, const char *format,...)
int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
A portable vsnprintf() function.
int sigaction(int, const struct sigaction *, struct sigaction *)
static void print_backtrace(FILE *outb)
static void init_backtrace(char **argv, int argc)
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.