Changeset 94955 in webkit


Ignore:
Timestamp:
Sep 12, 2011 7:20:07 AM (13 years ago)
Author:
kbalazs@webkit.org
Message:

[Qt][WK2] WebKitTestRunner does not produce crash logs
https://bugs.webkit.org/show_bug.cgi?id=67714

Added a simple way of generating backtrace on crash
to the web process. The implementation is similar what
we have in DRT. It depends on GNU libc functionality
so it is only enabled where we are running in such an environment.

  • WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp:

(WTR::printBacktrace):
(WTR::crashHandler):
(WTR::InjectedBundle::platformInitialize):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r94923 r94955  
     12011-09-12  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt][WK2] WebKitTestRunner does not produce crash logs
     4        https://bugs.webkit.org/show_bug.cgi?id=67714
     5
     6        Added a simple way of generating backtrace on crash
     7        to the web process. The implementation is similar what
     8        we have in DRT. It depends on GNU libc functionality
     9        so it is only enabled where we are running in such an environment.
     10
     11        * WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp:
     12        (WTR::printBacktrace):
     13        (WTR::crashHandler):
     14        (WTR::InjectedBundle::platformInitialize):
     15
    1162011-09-11  Filip Pizlo  <fpizlo@apple.com>
    217
  • trunk/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp

    r81135 r94955  
    11/*
    22 * Copyright (C) 2011 Apple Inc. All rights reserved.
     3 * Copyright (C) 2011 University of Szeged. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2627#include "config.h"
    2728#include "InjectedBundle.h"
     29#include <stdio.h>
     30#include <stdlib.h>
     31#include <wtf/AlwaysInline.h>
     32
     33#if HAVE(SIGNAL_H)
     34#include <signal.h>
     35#endif
     36
     37#if defined(__GLIBC__) && !defined(__UCLIBC__)
     38#include <execinfo.h>
     39#endif
    2840
    2941namespace WTR {
    3042
     43static inline void printBacktrace()
     44{
     45#if defined(__GLIBC__) && !defined(__UCLIBC__)
     46    void* frames[256];
     47    size_t size = backtrace(frames, 256);
     48    if (!size)
     49        return;
     50
     51    char** symbols = backtrace_symbols(frames, size);
     52    if (!symbols)
     53        return;
     54
     55    for (unsigned i = 0; i < size; ++i)
     56        fprintf(stderr, "%u: %s\n", i, symbols[i]);
     57
     58    fflush(stderr);
     59    free(symbols);
     60#endif
     61}
     62
     63#if HAVE(SIGNAL_H)
     64static NO_RETURN void crashHandler(int signal)
     65{
     66    fprintf(stderr, "%s\n", strsignal(signal));
     67    printBacktrace();
     68    exit(128 + signal);
     69}
     70#endif
     71
    3172void InjectedBundle::platformInitialize(WKTypeRef)
    3273{
     74#if HAVE(SIGNAL_H)
     75    signal(SIGILL, crashHandler);    /* 4:   illegal instruction (not reset when caught) */
     76    signal(SIGTRAP, crashHandler);   /* 5:   trace trap (not reset when caught) */
     77    signal(SIGFPE, crashHandler);    /* 8:   floating point exception */
     78    signal(SIGBUS, crashHandler);    /* 10:  bus error */
     79    signal(SIGSEGV, crashHandler);   /* 11:  segmentation violation */
     80    signal(SIGSYS, crashHandler);    /* 12:  bad argument to system call */
     81    signal(SIGPIPE, crashHandler);   /* 13:  write on a pipe with no reader */
     82    signal(SIGXCPU, crashHandler);   /* 24:  exceeded CPU time limit */
     83    signal(SIGXFSZ, crashHandler);   /* 25:  exceeded file size limit */
     84#endif
    3385}
    3486
Note: See TracChangeset for help on using the changeset viewer.