fuchsia: Get crashpad_snapshot_test building

ProcessSnapshotFuchsia is just a stub, so running fails immediately.

Bug: crashpad:196
Change-Id: Ie281cc13c4ff4a6e9699e882dbd6207daaab346d
Reviewed-on: https://chromium-review.googlesource.com/809234
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
Scott Graham 2017-12-05 15:43:23 -08:00 committed by Commit Bot
parent bfeb194b01
commit 6719610b8c
7 changed files with 209 additions and 7 deletions

View File

@ -174,6 +174,7 @@ def main(args):
tests = [
'crashpad_minidump_test',
'crashpad_snapshot_test',
'crashpad_test_test',
'crashpad_util_test',
]
@ -184,7 +185,6 @@ def main(args):
# are building and running successfully.
'crashpad_client_test',
'crashpad_handler_test',
'crashpad_snapshot_test',
])
if is_fuchsia:

View File

@ -128,6 +128,13 @@ static_library("snapshot") {
]
}
if (is_fuchsia) {
sources += [
"fuchsia/process_snapshot_fuchsia.cc",
"fuchsia/process_snapshot_fuchsia.h",
]
}
if (target_cpu == "x86" || target_cpu == "x64") {
sources += [
"x86/cpuid_reader.cc",

View File

@ -31,6 +31,9 @@
#elif defined(OS_WIN)
#include <windows.h>
#include "snapshot/win/process_snapshot_win.h"
#elif defined(OS_FUCHSIA)
#include <zircon/process.h>
#include "snapshot/fuchsia/process_snapshot_fuchsia.h"
#endif
namespace crashpad {
@ -81,6 +84,9 @@ CrashpadInfoClientOptions SelfProcessSnapshotAndGetCrashpadOptions() {
ProcessSnapshotWin process_snapshot;
EXPECT_TRUE(process_snapshot.Initialize(
GetCurrentProcess(), ProcessSuspensionState::kRunning, 0, 0));
#elif defined(OS_FUCHSIA)
ProcessSnapshotFuchsia process_snapshot;
EXPECT_TRUE(process_snapshot.Initialize(zx_process_self()));
#else
#error Port.
#endif // OS_MACOSX
@ -146,7 +152,7 @@ TEST(CrashpadInfoClientOptions, TwoModules) {
TestPaths::BuildArtifact(FILE_PATH_LITERAL("snapshot"),
FILE_PATH_LITERAL("module"),
TestPaths::FileType::kLoadableModule);
#if defined(OS_MACOSX)
#if defined(OS_POSIX)
ScopedModuleHandle module(
dlopen(module_path.value().c_str(), RTLD_LAZY | RTLD_LOCAL));
ASSERT_TRUE(module.valid()) << "dlopen " << module_path.value() << ": "
@ -244,7 +250,7 @@ TEST_P(CrashpadInfoSizes_ClientOptions, DifferentlySizedStruct) {
TestPaths::BuildArtifact(FILE_PATH_LITERAL("snapshot"),
artifact,
TestPaths::FileType::kLoadableModule);
#if defined(OS_MACOSX)
#if defined(OS_POSIX)
ScopedModuleHandle module(
dlopen(module_path.value().c_str(), RTLD_LAZY | RTLD_LOCAL));
ASSERT_TRUE(module.valid())

View File

@ -70,11 +70,11 @@ struct TestCrashpadInfo {
__attribute__((
#if defined(OS_MACOSX)
section(SEG_DATA ",crashpad_info"),
#elif defined(OS_LINUX) || defined(OS_ANDROID)
#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FUCHSIA)
section("crashpad_info"),
#else // !defined(OS_MACOSX) && !defined(OS_LINUX) && !defined(OS_ANDROID)
#else
#error Port
#endif // !defined(OS_MACOSX) && !defined(OS_LINUX) && !defined(OS_ANDROID)
#endif
#if defined(ADDRESS_SANITIZER)
aligned(64),
#endif // defined(ADDRESS_SANITIZER)

View File

@ -0,0 +1,114 @@
// Copyright 2017 The Crashpad 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.
#include "snapshot/fuchsia/process_snapshot_fuchsia.h"
#include "base/logging.h"
namespace crashpad {
ProcessSnapshotFuchsia::ProcessSnapshotFuchsia() {}
ProcessSnapshotFuchsia::~ProcessSnapshotFuchsia() {}
bool ProcessSnapshotFuchsia::Initialize(zx_handle_t process) {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return false;
}
void ProcessSnapshotFuchsia::GetCrashpadOptions(
CrashpadInfoClientOptions* options) {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
}
pid_t ProcessSnapshotFuchsia::ProcessID() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return 0;
}
pid_t ProcessSnapshotFuchsia::ParentProcessID() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return 0;
}
void ProcessSnapshotFuchsia::SnapshotTime(timeval* snapshot_time) const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
}
void ProcessSnapshotFuchsia::ProcessStartTime(timeval* start_time) const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
}
void ProcessSnapshotFuchsia::ProcessCPUTimes(timeval* user_time,
timeval* system_time) const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
}
void ProcessSnapshotFuchsia::ReportID(UUID* report_id) const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
}
void ProcessSnapshotFuchsia::ClientID(UUID* client_id) const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
}
const std::map<std::string, std::string>&
ProcessSnapshotFuchsia::AnnotationsSimpleMap() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return annotations_simple_map_;
}
const SystemSnapshot* ProcessSnapshotFuchsia::System() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return nullptr;
}
std::vector<const ThreadSnapshot*> ProcessSnapshotFuchsia::Threads() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return std::vector<const ThreadSnapshot*>();
}
std::vector<const ModuleSnapshot*> ProcessSnapshotFuchsia::Modules() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return std::vector<const ModuleSnapshot*>();
}
std::vector<UnloadedModuleSnapshot> ProcessSnapshotFuchsia::UnloadedModules()
const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return std::vector<UnloadedModuleSnapshot>();
}
const ExceptionSnapshot* ProcessSnapshotFuchsia::Exception() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return nullptr;
}
std::vector<const MemoryMapRegionSnapshot*> ProcessSnapshotFuchsia::MemoryMap()
const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return std::vector<const MemoryMapRegionSnapshot*>();
}
std::vector<HandleSnapshot> ProcessSnapshotFuchsia::Handles() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return std::vector<HandleSnapshot>();
}
std::vector<const MemorySnapshot*> ProcessSnapshotFuchsia::ExtraMemory() const {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return std::vector<const MemorySnapshot*>();
}
} // namespace crashpad

View File

@ -0,0 +1,76 @@
// Copyright 2017 The Crashpad 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 CRASHPAD_SNAPSHOT_FUCHSIA_PROCESS_SNAPSHOT_FUCHSIA_H_
#define CRASHPAD_SNAPSHOT_FUCHSIA_PROCESS_SNAPSHOT_FUCHSIA_H_
#include <zircon/types.h>
#include "base/macros.h"
#include "snapshot/crashpad_info_client_options.h"
#include "snapshot/process_snapshot.h"
#include "snapshot/unloaded_module_snapshot.h"
namespace crashpad {
//! \brief A ProcessSnapshot of a running (or crashed) process running on a
//! Fuchsia system. This class is not yet implemented.
class ProcessSnapshotFuchsia : public ProcessSnapshot {
public:
ProcessSnapshotFuchsia();
~ProcessSnapshotFuchsia() override;
//! \brief Initializes the object.
//!
//! \param[in] process The process handle to create a snapshot from.
//!
//! \return `true` if the snapshot could be created, `false` otherwise with
//! an appropriate message logged.
bool Initialize(zx_handle_t process);
//! \brief Returns options from CrashpadInfo structures found in modules in
//! the process.
//!
//! \param[out] options Options set in CrashpadInfo structures in modules in
//! the process.
void GetCrashpadOptions(CrashpadInfoClientOptions* options);
// ProcessSnapshot:
pid_t ProcessID() const override;
pid_t ParentProcessID() const override;
void SnapshotTime(timeval* snapshot_time) const override;
void ProcessStartTime(timeval* start_time) const override;
void ProcessCPUTimes(timeval* user_time, timeval* system_time) const override;
void ReportID(UUID* report_id) const override;
void ClientID(UUID* client_id) const override;
const std::map<std::string, std::string>& AnnotationsSimpleMap()
const override;
const SystemSnapshot* System() const override;
std::vector<const ThreadSnapshot*> Threads() const override;
std::vector<const ModuleSnapshot*> Modules() const override;
std::vector<UnloadedModuleSnapshot> UnloadedModules() const override;
const ExceptionSnapshot* Exception() const override;
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
std::vector<HandleSnapshot> Handles() const override;
std::vector<const MemorySnapshot*> ExtraMemory() const override;
private:
std::map<std::string, std::string> annotations_simple_map_;
DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotFuchsia);
};
} // namespace crashpad
#endif // CRASHPAD_SNAPSHOT_FUCHSIA_PROCESS_SNAPSHOT_FUCHSIA_H_

View File

@ -15,7 +15,6 @@
#include "snapshot/posix/timezone.h"
#include <stdlib.h>
#include <sys/cdefs.h>
#include <sys/time.h>
#include <time.h>