Giter Club home page Giter Club logo

conan-breakpad's Introduction

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

conan-breakpad's People

Contributors

shinichy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

conan-breakpad's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.