Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2bd6c5f authored by Christopher Ferris's avatar Christopher Ferris
Browse files

Use new AndroidUnwinder object.

Replace libbacktrace with the new AndroidUnwinder object.

Bug: 120606663

Test: Ran unit tests.
Test: Added call of UnwindMainThreadStack() in DebugRebootLogging()
Test: and verified unwind data is logged properly.
Change-Id: Ia724f9485377d6d2c894283242a3c5653bf82768
parent af4db674
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -178,7 +178,6 @@ libinit_cc_defaults {
        "update_metadata-protos",
    ],
    shared_libs: [
        "libbacktrace",
        "libbase",
        "libbootloader_message",
        "libcrypto",
@@ -195,6 +194,7 @@ libinit_cc_defaults {
        "libprocessgroup",
        "libprocessgroup_setup",
        "libselinux",
        "libunwindstack",
        "libutils",
        "libziparchive",
    ],
@@ -352,7 +352,6 @@ cc_binary {
        "libgsi",
        "liblzma",
        "libunwindstack_no_dex",
        "libbacktrace_no_dex",
        "libmodprobe",
        "libext2_uuid",
        "libprotobuf-cpp-lite",
+9 −7
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <backtrace/Backtrace.h>
#include <fs_avb/fs_avb.h>
#include <fs_mgr_vendor_overlay.h>
#include <keyutils.h>
@@ -58,6 +57,7 @@
#include <processgroup/processgroup.h>
#include <processgroup/setup.h>
#include <selinux/android.h>
#include <unwindstack/AndroidUnwinder.h>

#include "action_parser.h"
#include "builtins.h"
@@ -253,12 +253,14 @@ static class ShutdownState {
} shutdown_state;

static void UnwindMainThreadStack() {
    std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, 1));
    if (!backtrace->Unwind(0)) {
        LOG(ERROR) << __FUNCTION__ << "sys.powerctl: Failed to unwind callstack.";
    }
    for (size_t i = 0; i < backtrace->NumFrames(); i++) {
        LOG(ERROR) << "sys.powerctl: " << backtrace->FormatFrameData(i);
    unwindstack::AndroidLocalUnwinder unwinder;
    unwindstack::AndroidUnwinderData data;
    if (!unwinder.Unwind(data)) {
        LOG(ERROR) << __FUNCTION__
                   << "sys.powerctl: Failed to unwind callstack: " << data.GetErrorString();
    }
    for (const auto& frame : data.frames) {
        LOG(ERROR) << "sys.powerctl: " << unwinder.FormatFrame(frame);
    }
}

+7 −7
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <backtrace/Backtrace.h>
#include <cutils/android_reboot.h>
#include <unwindstack/AndroidUnwinder.h>

#include "capabilities.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.
    LOG(ERROR) << __FUNCTION__ << ": signal " << signal_number;
    std::unique_ptr<Backtrace> backtrace(
            Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
    if (!backtrace->Unwind(0)) {
        LOG(ERROR) << __FUNCTION__ << ": Failed to unwind callstack.";
    unwindstack::AndroidLocalUnwinder unwinder;
    unwindstack::AndroidUnwinderData data;
    if (!unwinder.Unwind(data)) {
        LOG(ERROR) << __FUNCTION__ << ": Failed to unwind callstack: " << data.GetErrorString();
    }
    for (size_t i = 0; i < backtrace->NumFrames(); i++) {
        LOG(ERROR) << backtrace->FormatFrameData(i);
    for (const auto& frame : data.frames) {
        LOG(ERROR) << unwinder.FormatFrame(frame);
    }
    if (init_fatal_panic) {
        LOG(ERROR) << __FUNCTION__ << ": Trigger crash";