Skip to content

shinichy/conan-breakpad

Repository files navigation

conan-breakpad

Conan package for the breakpad library (https://chromium.googlesource.com/breakpad/breakpad/).

badge

Build status

Example

The following example shows how to use this Conan package with CMake. See Conan's documentation for other generators if you are not using CMake.

Add the package to your project's conanfile.txt:

[requires]
breakpad/1.0.0@shinichy/stable

[generators]
cmake

Your CMakeLists.txt:

cmake_minimum_required( VERSION 2.8.12 )
project( PackageTest )

include( ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake )
conan_basic_setup()

if (APPLE)
  find_library(BREAKPAD NAMES Breakpad)
  if (NOT BREAKPAD)
    message(FATAL_ERROR "Breakpad not found")
  endif()
elseif (MSVC)
  find_package(BREAKPAD)
  if(NOT BREAKPAD_FOUND)
    message(FATAL_ERROR "Breakpad not found")
  endif ()
  set(CMAKE_CXX_FLAGS "/wd4091 /wd4577")
endif ()

add_executable( example example.cpp )

if (APPLE)
  target_link_libraries( example ${BREAKPAD} )
  file(COPY ${BREAKPAD} DESTINATION Frameworks)
elseif (MSVC)
  include_directories(${BREAKPAD_INCLUDE_DIRS})
  target_link_libraries( example ${BREAKPAD_LIBRARIES} )
endif ()

And then your example.cpp:

#ifdef __APPLE__
#include "client/mac/handler/exception_handler.h"

static bool dumpCallback(const char* _dump_dir, const char* _minidump_id, void* context, bool success) {
  printf("Dump path: %s\n", _dump_dir);
  return success;
}
#endif

#ifdef _WIN32
#include "client/windows/handler/exception_handler.h"

bool dumpCallback(const wchar_t* _dump_dir,
                  const wchar_t* _minidump_id,
                  void* context,
                  EXCEPTION_POINTERS* exinfo,
                  MDRawAssertionInfo* assertion,
                  bool success) {
  wprintf(L"Dump path: %s\n", _dump_dir);
  return true;
}
#endif

void makeCrash() { volatile int* a = (int*)(NULL); *a = 1; }

int main(int argc, char* argv[]) {
#ifdef __APPLE__
  std::string path = "/tmp";
  google_breakpad::ExceptionHandler eh(path, NULL, dumpCallback, NULL, true, NULL);
#endif

#ifdef _WIN32
  std::wstring path = L"C:\\tmp";
  google_breakpad::ExceptionHandler eh(path, 0, dumpCallback, 0, google_breakpad::ExceptionHandler::HandlerType::HANDLER_ALL);
#endif

  makeCrash();
  return 0;
}

Then you can use it as:

$ mkdir build && cd build
$ conan install ..
$ cmake .. -G "Visual Studio 14 Win64"
$ cmake --build . --config Release
$ bin/example

About

Conan.io package for the breakpad library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published