Merge "Use new AndroidUnwinder object." am: dbe14f2f73

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2095788

Change-Id: Ib7e1125d08abef2fabc887dab9b5c77f5df61d47
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Christopher Ferris 2022-05-12 04:03:37 +00:00 committed by Automerger Merge Worker
commit 32cfdb4be7
3 changed files with 16 additions and 15 deletions

View file

@ -178,7 +178,6 @@ libinit_cc_defaults {
"update_metadata-protos", "update_metadata-protos",
], ],
shared_libs: [ shared_libs: [
"libbacktrace",
"libbase", "libbase",
"libbootloader_message", "libbootloader_message",
"libcrypto", "libcrypto",
@ -195,6 +194,7 @@ libinit_cc_defaults {
"libprocessgroup", "libprocessgroup",
"libprocessgroup_setup", "libprocessgroup_setup",
"libselinux", "libselinux",
"libunwindstack",
"libutils", "libutils",
"libziparchive", "libziparchive",
], ],
@ -352,7 +352,6 @@ cc_binary {
"libgsi", "libgsi",
"liblzma", "liblzma",
"libunwindstack_no_dex", "libunwindstack_no_dex",
"libbacktrace_no_dex",
"libmodprobe", "libmodprobe",
"libext2_uuid", "libext2_uuid",
"libprotobuf-cpp-lite", "libprotobuf-cpp-lite",

View file

@ -48,7 +48,6 @@
#include <android-base/properties.h> #include <android-base/properties.h>
#include <android-base/stringprintf.h> #include <android-base/stringprintf.h>
#include <android-base/strings.h> #include <android-base/strings.h>
#include <backtrace/Backtrace.h>
#include <fs_avb/fs_avb.h> #include <fs_avb/fs_avb.h>
#include <fs_mgr_vendor_overlay.h> #include <fs_mgr_vendor_overlay.h>
#include <keyutils.h> #include <keyutils.h>
@ -58,6 +57,7 @@
#include <processgroup/processgroup.h> #include <processgroup/processgroup.h>
#include <processgroup/setup.h> #include <processgroup/setup.h>
#include <selinux/android.h> #include <selinux/android.h>
#include <unwindstack/AndroidUnwinder.h>
#include "action_parser.h" #include "action_parser.h"
#include "builtins.h" #include "builtins.h"
@ -253,12 +253,14 @@ static class ShutdownState {
} shutdown_state; } shutdown_state;
static void UnwindMainThreadStack() { static void UnwindMainThreadStack() {
std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, 1)); unwindstack::AndroidLocalUnwinder unwinder;
if (!backtrace->Unwind(0)) { unwindstack::AndroidUnwinderData data;
LOG(ERROR) << __FUNCTION__ << "sys.powerctl: Failed to unwind callstack."; if (!unwinder.Unwind(data)) {
LOG(ERROR) << __FUNCTION__
<< "sys.powerctl: Failed to unwind callstack: " << data.GetErrorString();
} }
for (size_t i = 0; i < backtrace->NumFrames(); i++) { for (const auto& frame : data.frames) {
LOG(ERROR) << "sys.powerctl: " << backtrace->FormatFrameData(i); LOG(ERROR) << "sys.powerctl: " << unwinder.FormatFrame(frame);
} }
} }

View file

@ -26,8 +26,8 @@
#include <android-base/logging.h> #include <android-base/logging.h>
#include <android-base/properties.h> #include <android-base/properties.h>
#include <android-base/strings.h> #include <android-base/strings.h>
#include <backtrace/Backtrace.h>
#include <cutils/android_reboot.h> #include <cutils/android_reboot.h>
#include <unwindstack/AndroidUnwinder.h>
#include "capabilities.h" #include "capabilities.h"
#include "reboot_utils.h" #include "reboot_utils.h"
@ -157,13 +157,13 @@ void __attribute__((noreturn)) InitFatalReboot(int signal_number) {
// In the parent, let's try to get a backtrace then shutdown. // In the parent, let's try to get a backtrace then shutdown.
LOG(ERROR) << __FUNCTION__ << ": signal " << signal_number; LOG(ERROR) << __FUNCTION__ << ": signal " << signal_number;
std::unique_ptr<Backtrace> backtrace( unwindstack::AndroidLocalUnwinder unwinder;
Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD)); unwindstack::AndroidUnwinderData data;
if (!backtrace->Unwind(0)) { if (!unwinder.Unwind(data)) {
LOG(ERROR) << __FUNCTION__ << ": Failed to unwind callstack."; LOG(ERROR) << __FUNCTION__ << ": Failed to unwind callstack: " << data.GetErrorString();
} }
for (size_t i = 0; i < backtrace->NumFrames(); i++) { for (const auto& frame : data.frames) {
LOG(ERROR) << backtrace->FormatFrameData(i); LOG(ERROR) << unwinder.FormatFrame(frame);
} }
if (init_fatal_panic) { if (init_fatal_panic) {
LOG(ERROR) << __FUNCTION__ << ": Trigger crash"; LOG(ERROR) << __FUNCTION__ << ": Trigger crash";