Google breakpad for Linux step by step

Google breakpad for Linux step by step
======================================

$ ( cd google-breakpad; ./configure; make; )
$ ( cd google-breakpad/src/tools/linux/dump_syms/; make; )
  # remove "-m32" in dump_syms/Makefile if on 64-bit OS
$ ( cd google-breakpad/src/tools/linux/md2core/;
    g++ -I http://www.cnblogs.com/../ -o md2core minidump-2-core.cc; )

$ cat test.cpp
#include <iostream>
#include "client/linux/handler/exception_handler.h"


static bool dumpCallback(const char* dump_path,
                         const char* minidump_id,
                         void* context,
                         bool succeeded)
{
    std::cerr << "Minidump file created: " << dump_path << "/" << minidump_id << ".dmp\n";
    return succeeded;
}

void hello()
{
    int a = 2/0;
}

int main(int argc, char* argv[])
{
    google_breakpad::ExceptionHandler eh(".", NULL, dumpCallback, NULL, true);

    hello();

    return 0;
}

$ g++ -g -I google-breakpad/src -o test test.cpp google-breakpad/src/client/linux/libbreakpad_client.a
$ ./test

    $ google-breakpad/src/tools/linux/md2core/md2core ./test > core
    $ gdb ./test core
    (gdb) bt

    or

    $ google-breakpad/src/tools/linux/dump_syms/dump_syms ./test | head -1
    MODULE Linux x86_64 6EDC6ACDB282125843FD59DA9C81BD830 test
    $ mkdir -p ./symbols/test/6EDC6ACDB282125843FD59DA9C81BD830
    $ google-breakpad/src/tools/linux/dump_syms/dump_syms ./test > symbols/test/6EDC6ACDB282125843FD59DA9C81BD830/test.sym
    $ google-breakpad/src/processor/minidump_stackwalk ./328eaddc-c1d5-9eee-3ca1e6a4-0ce3f6a6.dmp symbols

    or (see http://groups.google.com/group/google-breakpad-discuss/browse_thread/thread/153ba641904d95ec )

    $ wget -O symbolstore.py http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/tools/symbolstore.py?raw=1
    $ python ./symbolstore.py google-breakpad/src/tools/linux/dump_syms/dump_syms ./symbols ./test
    $ google-breakpad/src/processor/minidump_stackwalk ./328eaddc-c1d5-9eee-3ca1e6a4-0ce3f6a6.dmp symbols


Also reference:
http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/

你可能感兴趣的:(Google)