1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3*     Copyright 2015 Couchbase, Inc
4*
5*   Licensed under the Apache License, Version 2.0 (the "License");
6*   you may not use this file except in compliance with the License.
7*   You may obtain a copy of the License at
8*
9*       http://www.apache.org/licenses/LICENSE-2.0
10*
11*   Unless required by applicable law or agreed to in writing, software
12*   distributed under the License is distributed on an "AS IS" BASIS,
13*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*   See the License for the specific language governing permissions and
15*   limitations under the License.
16*/
17
18/*
19* A set of "extern C" functions to allow non-C++ applications to invoke
20* Breakpad.
21*/
22
23#pragma once
24
25#include <platform/visibility.h>
26
27#include <stdbool.h>
28#include <stdint.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/* Setup Breakpad, specifying the directory where any minidumps should be
35 * written. Should be invoked as part of program initialization, to reserve
36 * memory for Breakpad's operation. *MUST* have been called before attempting
37 * to write a minidump with breakpad_write_minidump().
38 *
39 * Note: Breakpad is configured to *NOT* automatically handle crashes and
40 *       write a minidump file, users must call breakpad_write_minidump() when
41 *       they wish to create a dump file.
42 *
43 * @param minidump_dir Path to an existing, writable directory which
44 *        minidumps will be written to.
45 */
46PLATFORM_PUBLIC_API
47void breakpad_initialize(const char* minidump_dir);
48
49/* Writes a minidump of the current application state, to the directory
50 * previously specified to breakpad_initialize().
51 * @return True if the minidump was successfully written, else false.
52 */
53PLATFORM_PUBLIC_API
54bool breakpad_write_minidump();
55
56/* Returns the address of breakpad_write_minidump() function.
57 * Provided to facilite passing that symbol into foreign environments
58 * (e.g. Golang) for later use as a C function pointer.
59 */
60PLATFORM_PUBLIC_API
61uintptr_t breakpad_get_write_minidump_addr();
62
63#ifdef __cplusplus
64} // extern "C"
65#endif
66