Skip to content

Instantly share code, notes, and snippets.

@pcapriotti
Created July 2, 2009 16:39
Show Gist options
  • Select an option

  • Save pcapriotti/139587 to your computer and use it in GitHub Desktop.

Select an option

Save pcapriotti/139587 to your computer and use it in GitHub Desktop.
Show a ruby backtrace on a native code crash
#include "extensions.h"
#include <QCoreApplication>
#include <kdemacros.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <ruby.h>
Extensions::Extensions(QObject* parent)
: QObject(parent) { }
static void init()
{
Extensions* ext = new Extensions(QCoreApplication::instance());
ext->setObjectName("kaya extensions");
}
static void crash_handler(int signum)
{
rb_raise(rb_eException, "Native code crash!");
}
extern "C" KDE_EXPORT void Init_extensions() {
init();
signal(SIGSEGV, crash_handler);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment