mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Fuchsia: de-port generate_dump
generate_dump is not being used on Fuchsia (because only the system-reporter version of Fuchsia Crashpad is actively used). GetProcessFromKoid() is becoming increasingly difficult to implement, so simply de-port generate_dump until we actually need it again in the future (if ever). Removes GetRootJob(). Change-Id: Ib5e5d8e79177506da4b2e0e0382f3fdd2502840b Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1726695 Commit-Queue: Scott Graham <scottmg@chromium.org> Reviewed-by: Francois Rousseau <frousseau@google.com>
This commit is contained in:
parent
2faae40e8e
commit
1b2f448720
@ -56,38 +56,40 @@ crashpad_executable("crashpad_http_upload") {
|
||||
]
|
||||
}
|
||||
|
||||
crashpad_executable("generate_dump") {
|
||||
sources = [
|
||||
"generate_dump.cc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":tool_support",
|
||||
"../build:default_exe_manifest_win",
|
||||
"../compat",
|
||||
"../minidump",
|
||||
"../snapshot",
|
||||
"../third_party/mini_chromium:base",
|
||||
"../util",
|
||||
]
|
||||
|
||||
if (crashpad_is_mac) {
|
||||
# This would be better as a config so that it could be shared with
|
||||
# exception_port_tool, but configs can’t alter “inputs”.
|
||||
# https://crbug.com/781858.
|
||||
inputs = [
|
||||
"mac/sectaskaccess_info.plist",
|
||||
if (!crashpad_is_fuchsia) {
|
||||
crashpad_executable("generate_dump") {
|
||||
sources = [
|
||||
"generate_dump.cc",
|
||||
]
|
||||
ldflags = [
|
||||
"-sectcreate",
|
||||
"__TEXT",
|
||||
"__info_plist",
|
||||
rebase_path(inputs[0], root_build_dir),
|
||||
]
|
||||
}
|
||||
|
||||
if (crashpad_is_win) {
|
||||
cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union
|
||||
deps = [
|
||||
":tool_support",
|
||||
"../build:default_exe_manifest_win",
|
||||
"../compat",
|
||||
"../minidump",
|
||||
"../snapshot",
|
||||
"../third_party/mini_chromium:base",
|
||||
"../util",
|
||||
]
|
||||
|
||||
if (crashpad_is_mac) {
|
||||
# This would be better as a config so that it could be shared with
|
||||
# exception_port_tool, but configs can’t alter “inputs”.
|
||||
# https://crbug.com/781858.
|
||||
inputs = [
|
||||
"mac/sectaskaccess_info.plist",
|
||||
]
|
||||
ldflags = [
|
||||
"-sectcreate",
|
||||
"__TEXT",
|
||||
"__info_plist",
|
||||
rebase_path(inputs[0], root_build_dir),
|
||||
]
|
||||
}
|
||||
|
||||
if (crashpad_is_win) {
|
||||
cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,12 +47,6 @@
|
||||
#include "snapshot/win/process_snapshot_win.h"
|
||||
#include "util/win/scoped_process_suspend.h"
|
||||
#include "util/win/xp_compat.h"
|
||||
#elif defined(OS_FUCHSIA)
|
||||
#include <lib/zx/process.h>
|
||||
|
||||
#include "snapshot/fuchsia/process_snapshot_fuchsia.h"
|
||||
#include "util/fuchsia/koid_utilities.h"
|
||||
#include "util/fuchsia/scoped_task_suspend.h"
|
||||
#elif defined(OS_LINUX) || defined(OS_ANDROID)
|
||||
#include "snapshot/linux/process_snapshot_linux.h"
|
||||
#endif // OS_MACOSX
|
||||
@ -167,12 +161,6 @@ int GenerateDumpMain(int argc, char* argv[]) {
|
||||
PLOG(ERROR) << "could not open process " << options.pid;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#elif defined(OS_FUCHSIA)
|
||||
zx::process process = GetProcessFromKoid(options.pid);
|
||||
if (!process.is_valid()) {
|
||||
LOG(ERROR) << "could not open process " << options.pid;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif // OS_MACOSX
|
||||
|
||||
if (options.dump_path.empty()) {
|
||||
@ -191,11 +179,6 @@ int GenerateDumpMain(int argc, char* argv[]) {
|
||||
if (options.suspend) {
|
||||
suspend.reset(new ScopedProcessSuspend(process.get()));
|
||||
}
|
||||
#elif defined(OS_FUCHSIA)
|
||||
std::unique_ptr<ScopedTaskSuspend> suspend;
|
||||
if (options.suspend) {
|
||||
suspend.reset(new ScopedTaskSuspend(process));
|
||||
}
|
||||
#endif // OS_MACOSX
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
@ -213,11 +196,6 @@ int GenerateDumpMain(int argc, char* argv[]) {
|
||||
0)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#elif defined(OS_FUCHSIA)
|
||||
ProcessSnapshotFuchsia process_snapshot;
|
||||
if (!process_snapshot.Initialize(process)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#elif defined(OS_LINUX) || defined(OS_ANDROID)
|
||||
// TODO(jperaza): https://crashpad.chromium.org/bug/30.
|
||||
ProcessSnapshotLinux process_snapshot;
|
||||
|
@ -48,33 +48,6 @@ T CastHandle(zx::handle handle) {
|
||||
return T(std::move(handle));
|
||||
}
|
||||
|
||||
zx::job GetRootJob() {
|
||||
ScopedFileHandle sysinfo(
|
||||
LoggingOpenFileForRead(base::FilePath("/dev/misc/sysinfo")));
|
||||
if (!sysinfo.is_valid())
|
||||
return zx::job();
|
||||
|
||||
zx::channel channel;
|
||||
zx_status_t status = fdio_get_service_handle(sysinfo.release(),
|
||||
channel.reset_and_get_address());
|
||||
if (status != ZX_OK) {
|
||||
ZX_LOG(ERROR, status) << "fdio_get_service_handle";
|
||||
return zx::job();
|
||||
}
|
||||
|
||||
zx::handle root_job;
|
||||
zx_status_t fidl_status = fuchsia_sysinfo_DeviceGetRootJob(
|
||||
channel.get(), &status, root_job.reset_and_get_address());
|
||||
if (fidl_status != ZX_OK) {
|
||||
ZX_LOG(ERROR, fidl_status) << "fuchsia_sysinfo_DeviceGetRootJob";
|
||||
return zx::job();
|
||||
} else if (status != ZX_OK) {
|
||||
ZX_LOG(ERROR, status) << "fuchsia_sysinfo_DeviceGetRootJob";
|
||||
return zx::job();
|
||||
}
|
||||
return CastHandle<zx::job>(std::move(root_job));
|
||||
}
|
||||
|
||||
// Returns null handle if |koid| is not found or an error occurs. If |was_found|
|
||||
// is non-null then it will be set, to distinguish not-found from other errors.
|
||||
template <typename T, typename U>
|
||||
@ -92,35 +65,6 @@ T GetChildHandleByKoid(const U& parent, zx_koid_t child_koid, bool* was_found) {
|
||||
return CastHandle<T>(std::move(handle));
|
||||
}
|
||||
|
||||
// Returns an invalid handle if the |koid| was found, but was of the wrong
|
||||
// type, or we could not open a handle to it.
|
||||
zx::process FindProcess(const zx::job& job, zx_koid_t koid, bool* was_found) {
|
||||
DCHECK(!*was_found);
|
||||
|
||||
// Look for |koid| as a direct descendent of |job|.
|
||||
auto process = GetChildHandleByKoid<zx::process>(job, koid, was_found);
|
||||
if (*was_found) {
|
||||
// |koid| was found. |process| may still be null, e.g. if a handle could not
|
||||
// be opened to it.
|
||||
return process;
|
||||
}
|
||||
|
||||
// |koid| was not found under |job|, so search child jobs, if any.
|
||||
// Since we only hold a handle to the job we are currently enumerating, child
|
||||
// jobs may go away mid-enumeration.
|
||||
for (auto child_koid : GetChildKoids(job, ZX_INFO_JOB_CHILDREN)) {
|
||||
zx::job child_job = GetChildHandleByKoid<zx::job>(job, child_koid, nullptr);
|
||||
if (!child_job.is_valid())
|
||||
continue;
|
||||
zx::process process = FindProcess(child_job, koid, was_found);
|
||||
if (*was_found)
|
||||
return process;
|
||||
}
|
||||
|
||||
DCHECK(!*was_found);
|
||||
return zx::process();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::vector<zx_koid_t> GetChildKoids(const zx::object_base& parent_object,
|
||||
@ -195,16 +139,4 @@ zx_koid_t GetKoidForHandle(const zx::object_base& object) {
|
||||
return info.koid;
|
||||
}
|
||||
|
||||
// TODO(scottmg): This implementation uses some debug/temporary/hacky APIs and
|
||||
// ioctls that are currently the only way to go from pid to handle. This should
|
||||
// hopefully eventually be replaced by more or less a single
|
||||
// zx_debug_something() syscall.
|
||||
zx::process GetProcessFromKoid(zx_koid_t koid) {
|
||||
bool was_found = false;
|
||||
zx::process result = FindProcess(GetRootJob(), koid, &was_found);
|
||||
if (!result.is_valid())
|
||||
LOG(ERROR) << "process " << koid << " not found";
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace crashpad
|
||||
|
@ -71,13 +71,6 @@ std::vector<zx::thread> GetHandlesForThreadKoids(
|
||||
zx::thread GetThreadHandleByKoid(const zx::process& parent,
|
||||
zx_koid_t child_koid);
|
||||
|
||||
//! \brief Gets a process handle given the process' koid.
|
||||
//!
|
||||
//! \param[in] koid The process id.
|
||||
//! \return A zx_handle_t (owned by a base::ScopedZxHandle) for the process. If
|
||||
//! the handle is invalid, an error will have been logged.
|
||||
zx::process GetProcessFromKoid(zx_koid_t koid);
|
||||
|
||||
//! \brief Retrieves the koid for a given object handle.
|
||||
//!
|
||||
//! \param[in] object The handle for which the koid is to be retrieved.
|
||||
|
Loading…
x
Reference in New Issue
Block a user