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

Commit ce1c3333 authored by Christopher Ferris's avatar Christopher Ferris Committed by Automerger Merge Worker
Browse files

Merge "Use the new AndroidUnwinder object." am: af4db674

parents 0c13a360 af4db674
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -44,14 +44,6 @@ cc_library_headers {
    export_include_dirs: ["include"],

    target: {
        android: {
            header_libs: ["libbacktrace_headers"],
            export_header_lib_headers: ["libbacktrace_headers"],
        },
        host_linux: {
            header_libs: ["libbacktrace_headers"],
            export_header_lib_headers: ["libbacktrace_headers"],
        },
        linux_bionic: {
            enabled: true,
        },
@@ -196,7 +188,7 @@ cc_library {

    shared_libs: [
        "libutils",
        "libbacktrace",
        "libunwindstack",
    ],

    target: {
+17 −6
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
#include <utils/Errors.h>
#include <utils/Log.h>

#include <backtrace/Backtrace.h>
#include <unwindstack/AndroidUnwinder.h>

#define CALLSTACK_WEAK  // Don't generate weak definitions.
#include <utils/CallStack.h>
@@ -39,14 +39,25 @@ CallStack::~CallStack() {
}

void CallStack::update(int32_t ignoreDepth, pid_t tid) {
    if (ignoreDepth < 0) {
        ignoreDepth = 0;
    }

    mFrameLines.clear();

    std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, tid));
    if (!backtrace->Unwind(ignoreDepth)) {
        ALOGW("%s: Failed to unwind callstack.", __FUNCTION__);
    unwindstack::AndroidLocalUnwinder unwinder;
    unwindstack::AndroidUnwinderData data;
    std::optional<pid_t> tid_val;
    if (tid != -1) {
        *tid_val = tid;
    }
    if (!unwinder.Unwind(tid_val, data)) {
        ALOGW("%s: Failed to unwind callstack: %s", __FUNCTION__, data.GetErrorString().c_str());
    }
    for (size_t i = 0; i < backtrace->NumFrames(); i++) {
      mFrameLines.push_back(String8(backtrace->FormatFrameData(i).c_str()));
    for (size_t i = ignoreDepth; i < data.frames.size(); i++) {
        auto& frame = data.frames[i];
        frame.num -= ignoreDepth;
        mFrameLines.push_back(String8(unwinder.FormatFrame(frame).c_str()));
    }
}

+1 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#include <memory>

#include <android/log.h>
#include <backtrace/backtrace_constants.h>
#include <utils/String8.h>
#include <utils/Vector.h>

@@ -59,7 +58,7 @@ public:

    // Immediately collect the stack traces for the specified thread.
    // The default is to dump the stack of the current call.
    void update(int32_t ignoreDepth = 1, pid_t tid = BACKTRACE_CURRENT_THREAD);
    void update(int32_t ignoreDepth = 1, pid_t tid = -1);

    // Dump a stack trace to the log using the supplied logtag.
    void log(const char* logtag,