Skip to content

Commit

Permalink
feat: capture build id for ndk stacktraces
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Oct 24, 2023
1 parent 009b076 commit f8eefab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion embrace-android-sdk/src/main/cpp/file_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static const char *kFrameAddrKey = "fa";
static const char *kOffsetAddrKey = "oa";
static const char *kModuleAddrKey = "ma";
static const char *kLineNumKey = "ln";
static const char *kBuildIdKey = "build_id";
static const char *kCrashKey = "crash";
static const char *kVersionKey = "v";

Expand Down Expand Up @@ -203,7 +204,7 @@ char *emb_crash_to_json(emb_crash *crash) {
json_object_set_number(frame_object, kOffsetAddrKey, frame.offset_addr);
json_object_set_number(frame_object, kModuleAddrKey, frame.module_addr);
json_object_set_number(frame_object, kLineNumKey, frame.line_num);

json_object_set_string(frame_object, kBuildIdKey, frame.build_id);
json_array_append_value(frames_object, frame_value);
}
EMB_LOGDEV("Finished serializing stackframes.");
Expand Down
5 changes: 5 additions & 0 deletions embrace-android-sdk/src/main/cpp/stack_frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@
#define EMB_SESSION_ID_SIZE 256
#endif

#ifndef EMB_BUILD_ID_SIZE
#define EMB_BUILD_ID_SIZE 512
#endif

#ifndef EMB_PATH_SIZE
#define EMB_PATH_SIZE 512
#endif

typedef struct {
char filename[256];
char method[256];
char build_id[EMB_BUILD_ID_SIZE];

uintptr_t frame_addr;
uintptr_t offset_addr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ emb_process_stack(emb_env *env, siginfo_t *info, void *user_context) {
if (unwindSuccessful) {
int i = 0;
for (const auto &frame: android_unwinder_data.frames) {
stacktrace[i++].frame_addr = frame.pc;
emb_sframe *data = &stacktrace[i++];
data->frame_addr = frame.pc;
const auto map_info = frame.map_info;
emb_strncpy(data->build_id, map_info->GetPrintableBuildID().c_str(), EMB_BUILD_ID_SIZE);
}
} else {
return 0;
Expand Down

0 comments on commit f8eefab

Please sign in to comment.