diff --git a/tools/BUILD.gn b/tools/BUILD.gn index cd1e95f4..ffcd08f3 100644 --- a/tools/BUILD.gn +++ b/tools/BUILD.gn @@ -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 + } } } diff --git a/tools/generate_dump.cc b/tools/generate_dump.cc index 76bb86e4..2113a1ab 100644 --- a/tools/generate_dump.cc +++ b/tools/generate_dump.cc @@ -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 - -#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 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; diff --git a/util/fuchsia/koid_utilities.cc b/util/fuchsia/koid_utilities.cc index 288f04b9..09c7e541 100644 --- a/util/fuchsia/koid_utilities.cc +++ b/util/fuchsia/koid_utilities.cc @@ -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(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 @@ -92,35 +65,6 @@ T GetChildHandleByKoid(const U& parent, zx_koid_t child_koid, bool* was_found) { return CastHandle(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(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(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 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 diff --git a/util/fuchsia/koid_utilities.h b/util/fuchsia/koid_utilities.h index 9848dced..8859bc51 100644 --- a/util/fuchsia/koid_utilities.h +++ b/util/fuchsia/koid_utilities.h @@ -71,13 +71,6 @@ std::vector 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.