-
Notifications
You must be signed in to change notification settings - Fork 15k
/
crashpad_support.cc
39 lines (31 loc) · 1.05 KB
/
crashpad_support.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2022 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
#if BUILDFLAG(IS_LINUX)
#include "components/crash/core/app/crashpad.h" // nogncheck
#endif
namespace {
#if BUILDFLAG(IS_LINUX)
int GetCrashdumpSignalFD() {
int fd;
return crash_reporter::GetHandlerSocket(&fd, nullptr) ? fd : -1;
}
int GetCrashpadHandlerPID() {
int pid;
return crash_reporter::GetHandlerSocket(nullptr, &pid) ? pid : -1;
}
#endif
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
gin_helper::Dictionary dict(context->GetIsolate(), exports);
#if BUILDFLAG(IS_LINUX)
dict.SetMethod("getCrashdumpSignalFD", &GetCrashdumpSignalFD);
dict.SetMethod("getCrashpadHandlerPID", &GetCrashpadHandlerPID);
#endif
}
} // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_crashpad_support, Initialize)