Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BasedOnStyle: Google
---
Language: Cpp
IndentWidth: 4
DerivePointerAlignment: false
PointerAlignment: Right
AllowShortFunctionsOnASingleLine: None
BinPackParameters: false
---

1 change: 1 addition & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"includePath": [
"${workspaceFolder}/**",
"../crashpad-Darwin/include/",
"./include",
"../mpack-amalgamation-1.0/",
"../mpack-amalgamation-1.0/src/mpack",
"../crashpad-Darwin/include/mini_chromium"
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"list": "cpp",
"optional": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp"
"unordered_set": "cpp",
"mpack.c": "cpp"
}
}
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
libsentry.dylib:
g++ -g -dynamiclib \
-o libsentry.dylib sentry.cpp crashpad_wrapper.cpp \
-o libsentry.dylib src/sentry.cpp src/crashpad_wrapper.cpp src/vendor/mpack.c \
-I ../crashpad-Darwin/include/ -I ../crashpad-Darwin/include/mini_chromium/ \
-I ../mpack-amalgamation-1.0/ -I ../mpack-amalgamation-1.0/src/mpack \
-I ./include \
-fvisibility=hidden \
-std=c++11 -L../crashpad-Darwin/lib -lclient -lbase -lutil \
-framework Foundation -framework Security -framework CoreText \
-framework CoreGraphics -framework IOKit -lbsm \
-D SENTRY_CRASHPAD
example: example.c libsentry.dylib
gcc -g -o example example.c -L . -lsentry
gcc -g -o example example.c -I ./include -L . -lsentry
build-example: example
clean:
rm -rf example libsentry.dylib completed new pending *.dSYM *.mp
rm -rf example libsentry.dylib completed new pending *.dSYM *.mp *.dmp *.dat
11 changes: 0 additions & 11 deletions crashpad_wrapper.hpp

This file was deleted.

14 changes: 10 additions & 4 deletions example.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include <string.h>
#include "sentry.h"

int main(void)
{
int main(void) {
sentry_options_t option;
sentry_options_init(&option);
option.dsn = "https://sentry.garcia.in/api/3/minidump/?sentry_key=93b6c4c0c1a14bec977f0f1adf8525e6";
option.dsn = "https://93b6c4c0c1a14bec977f0f1adf8525e6@sentry.garcia.in/3";
option.handler_path = "../crashpad-Darwin/bin/crashpad_handler";
option.environment = "Production";
option.release = "5fd7a6cd";
option.dist = "12345";
option.database_path = ".";
option.debug = 1;

sentry_init(&option);

Expand All @@ -22,5 +22,11 @@ int main(void)
sentry_set_tag("not-expected-tag", "some value");
sentry_remove_tag("not-expected-tag");

// memset((char *)0x0, 1, 100);
sentry_user_t user;
sentry_user_clear(&user);
user.id = "blafasel";
user.username = "asdfasfsadf";
sentry_set_user(&user);

memset((char *)0x0, 1, 100);
}
102 changes: 102 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#ifndef SENTRY_H
#define SENTRY_H

#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

#ifndef SENTRY_API
#ifdef _WIN32
#if defined(SENTRY_BUILD_SHARED) /* build dll */
#define SENTRY_API __declspec(dllexport)
#elif !defined(SENTRY_BUILD_STATIC) /* use dll */
#define SENTRY_API __declspec(dllimport)
#else /* static library */
#define SENTRY_API
#endif
#else
#if __GNUC__ >= 4
#define SENTRY_API __attribute__((visibility("default")))
#else
#define SENTRY_API
#endif
#endif
#endif

enum sentry_error_t {
SENTRY_ERROR_NULL_ARGUMENT = 1,
SENTRY_ERROR_HANDLER_STARTUP_FAIL = 2,
SENTRY_ERROR_NO_DSN = 3,
SENTRY_ERROR_NO_MINIDUMP_URL = 4,
SENTRY_ERROR_INVALID_URL_SCHEME = 5,
SENTRY_ERROR_INVALID_URL_MISSING_HOST = 6,
};

typedef struct sentry_options_s {
// Unified API
const char *dsn;
const char *release;
const char *environment;
const char *dist;
int debug;
// Crashpad
const char *handler_path;
const char *database_path;
// TODO hook/callback to crashpad configuration object.
// Breakpad
// TODO: whatever breakpad needs
} sentry_options_t;

typedef struct sentry_breadcrumb_s {
} sentry_breadcrumb_t;

typedef struct sentry_user_s {
const char *username;
const char *email;
const char *id;
const char *ip_address;
} sentry_user_t;

enum sentry_level_t {
SENTRY_LEVEL_DEBUG = 0,
SENTRY_LEVEL_INFO = 1,
SENTRY_LEVEL_WARNING = 2,
SENTRY_LEVEL_ERROR = 3
};

// Unified API
SENTRY_API int sentry_init(const sentry_options_t *options);
SENTRY_API int sentry_add_breadcrumb(sentry_breadcrumb_t *breadcrumb);
SENTRY_API int sentry_push_scope();
SENTRY_API int sentry_pop_scope();
SENTRY_API int sentry_set_user(const sentry_user_t *user);
SENTRY_API int sentry_remove_user();
SENTRY_API int sentry_set_tag(const char *key, const char *value);
SENTRY_API int sentry_remove_tag(const char *key);
SENTRY_API int sentry_set_extra(const char *key, const char *value);
SENTRY_API int sentry_remove_extra(const char *key);
SENTRY_API int sentry_set_release(const char *release);
SENTRY_API int sentry_remove_release();
SENTRY_API int sentry_set_fingerprint(const char **fingerprint, size_t len);
SENTRY_API int sentry_remove_fingerprint();
SENTRY_API int sentry_set_transaction(const char *transaction);
SENTRY_API int sentry_remove_transaction();
SENTRY_API int sentry_set_level(enum sentry_level_t level);

/* helpers */
SENTRY_API void sentry_user_clear(sentry_user_t *user);

/* Sentrypad custom API */
SENTRY_API int sentry_shutdown(void);
SENTRY_API int sentry_attach_file_by_path(const char *path);
SENTRY_API int sentry_attach_file_with_contents(const char *filename,
const char *buf,
size_t len);
SENTRY_API int sentry_capture_minidump(const char *optional_message);
SENTRY_API void sentry_options_init(sentry_options_t *options);

#ifdef __cplusplus
}
#endif
#endif
Loading