Skip to content

Commit

Permalink
Move Crashpad wrapper under starboard
Browse files Browse the repository at this point in the history
Issue: 365546355
  • Loading branch information
dahlstrom-g committed Oct 7, 2024
2 parents f9b34d1 + 96e82a5 commit 50263ac
Show file tree
Hide file tree
Showing 23 changed files with 535 additions and 25 deletions.
4 changes: 2 additions & 2 deletions starboard/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ group("starboard_group") {
if (!sb_is_modular || sb_is_evergreen) {
if (sb_is_evergreen_compatible &&
current_toolchain == starboard_toolchain) {
public_deps += [ "//third_party/crashpad/crashpad/wrapper" ]
public_deps += [ "//starboard/crashpad_wrapper" ]
} else {
public_deps +=
[ "//third_party/crashpad/crashpad/wrapper:wrapper_stub" ]
[ "//starboard/crashpad_wrapper:wrapper_stub" ]
}
}

Expand Down
2 changes: 1 addition & 1 deletion starboard/android/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static_library("starboard_platform") {
"//starboard/loader_app:pending_restart",
]

deps += [ "//third_party/crashpad/crashpad/wrapper" ]
deps += [ "//starboard/crashpad_wrapper" ]
}

if (sb_evergreen_compatible_use_libunwind) {
Expand Down
2 changes: 1 addition & 1 deletion starboard/android/shared/android_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "starboard/shared/starboard/command_line.h"
#include "starboard/thread.h"
#if SB_IS(EVERGREEN_COMPATIBLE)
#include "third_party/crashpad/crashpad/wrapper/wrapper.h" // nogncheck
#include "starboard/crashpad_wrapper/wrapper.h" // nogncheck
#endif

namespace starboard {
Expand Down
2 changes: 1 addition & 1 deletion starboard/build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ template("evergreen_loader") {
]

if (!sb_is_evergreen_compatible) {
deps += [ "//third_party/crashpad/crashpad/wrapper:wrapper_stub" ]
deps += [ "//starboard/crashpad_wrapper:wrapper_stub" ]
}
}
if (separate_install_targets_for_bundling) {
Expand Down
4 changes: 2 additions & 2 deletions starboard/build/config/starboard_target_type.gni
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ template("starboard_platform_target") {
]
if (sb_is_evergreen_compatible &&
current_toolchain == starboard_toolchain) {
public_deps += [ "//third_party/crashpad/crashpad/wrapper" ]
public_deps += [ "//starboard/crashpad_wrapper" ]
} else {
public_deps += [ "//third_party/crashpad/crashpad/wrapper:wrapper_stub" ]
public_deps += [ "//starboard/crashpad_wrapper:wrapper_stub" ]
}
if (!sb_is_evergreen) {
public_deps += [ "//$starboard_path:starboard_platform" ]
Expand Down
40 changes: 40 additions & 0 deletions starboard/crashpad_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# The common "starboard" target. Any target that depends on Starboard should
# depend on this common target, and not any of the specific "starboard_platform"
# targets.

if (sb_is_evergreen_compatible && current_toolchain == starboard_toolchain) {
static_library("crashpad_wrapper") {
check_includes = false

sources = [
"wrapper.cc",
"wrapper.h",
]

deps = [
"//starboard/elf_loader:evergreen_info",
"//third_party/crashpad/crashpad/client",
]
}
}

static_library("wrapper_stub") {
sources = [
"wrapper_stub.cc",
"wrapper.h",
]
}
37 changes: 37 additions & 0 deletions starboard/crashpad_wrapper/annotations.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2021 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef THIRD_PARTY_CRASHPAD_WRAPPER_ANNOTATIONS_H_
#define THIRD_PARTY_CRASHPAD_WRAPPER_ANNOTATIONS_H_

#define CRASHPAD_ANNOTATION_DEFAULT_LENGTH 64
#define USER_AGENT_STRING_MAX_SIZE 2048

#ifdef __cplusplus
extern "C" {
#endif

// Annotations that Evergreen will add to Crashpad for more detailed crash
// reports.
typedef struct CrashpadAnnotations {
char product[CRASHPAD_ANNOTATION_DEFAULT_LENGTH];
char version[CRASHPAD_ANNOTATION_DEFAULT_LENGTH];
char user_agent_string[USER_AGENT_STRING_MAX_SIZE];
} CrashpadAnnotations;

#ifdef __cplusplus
} // extern "C"
#endif

#endif // THIRD_PARTY_CRASHPAD_WRAPPER_ANNOTATIONS_H_
20 changes: 20 additions & 0 deletions starboard/crashpad_wrapper/proto/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2022 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//third_party/protobuf/proto_library.gni")

proto_library("crashpad_annotations_proto") {
sources = [ "crashpad_annotations.proto" ]
generate_python = false
}
39 changes: 39 additions & 0 deletions starboard/crashpad_wrapper/proto/crashpad_annotations.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2022 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

option optimize_for = LITE_RUNTIME;

package crashpad.wrapper;

// Annotations that can be shared between Cobalt and Crashpad handler processes.
// Next id: 6
message CrashpadAnnotations {
// The product name.
string prod = 1;

// The product version.
string ver = 2;

// The User-Agent string that identifies brand, model, etc.
string user_agent_string = 3;

// The device series identifier that is used for device authentication.
string cert_scope = 5;

// Annotations with keys that are unknown at compile time.
map<string, string> runtime_annotations = 4;
}

Loading

0 comments on commit 50263ac

Please sign in to comment.