diff options
-rw-r--r-- | libs/binder/RpcSession.cpp | 12 | ||||
-rw-r--r-- | opengl/libs/Android.bp | 2 | ||||
-rw-r--r-- | opengl/libs/EGL/CallStack.h | 15 |
3 files changed, 14 insertions, 15 deletions
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp index d40778a3d8..16991db58d 100644 --- a/libs/binder/RpcSession.cpp +++ b/libs/binder/RpcSession.cpp @@ -152,13 +152,7 @@ status_t RpcSession::setupInetClient(const char* addr, unsigned int port) { } status_t RpcSession::setupPreconnectedClient(unique_fd fd, std::function<unique_fd()>&& request) { - // Why passing raw fd? When fd is passed as reference, Clang analyzer sees that the variable - // `fd` is a moved-from object. To work-around the issue, unwrap the raw fd from the outer `fd`, - // pass the raw fd by value to the lambda, and then finally wrap it in unique_fd inside the - // lambda. - return setupClient([&, raw = fd.release()](const std::vector<uint8_t>& sessionId, - bool incoming) -> status_t { - unique_fd fd(raw); + return setupClient([&](const std::vector<uint8_t>& sessionId, bool incoming) -> status_t { if (!fd.ok()) { fd = request(); if (!fd.ok()) return BAD_VALUE; @@ -167,7 +161,9 @@ status_t RpcSession::setupPreconnectedClient(unique_fd fd, std::function<unique_ ALOGE("setupPreconnectedClient: %s", res.error().message().c_str()); return res.error().code() == 0 ? UNKNOWN_ERROR : -res.error().code(); } - return initAndAddConnection(std::move(fd), sessionId, incoming); + status_t status = initAndAddConnection(std::move(fd), sessionId, incoming); + fd = unique_fd(); // Explicitly reset after move to avoid analyzer warning. + return status; }); } diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp index c9fce8ad52..c1e935aab0 100644 --- a/opengl/libs/Android.bp +++ b/opengl/libs/Android.bp @@ -108,7 +108,6 @@ cc_defaults { // In particular, DO NOT add libutils nor anything "above" libui "libgraphicsenv", "libnativewindow", - "libbacktrace", "libbase", ], } @@ -165,6 +164,7 @@ cc_library_shared { "libnativeloader_lazy", "libutils", "libSurfaceFlingerProp", + "libunwindstack", ], static_libs: [ "libEGL_getProcAddress", diff --git a/opengl/libs/EGL/CallStack.h b/opengl/libs/EGL/CallStack.h index b7fdf97cbe..96437c37d9 100644 --- a/opengl/libs/EGL/CallStack.h +++ b/opengl/libs/EGL/CallStack.h @@ -16,8 +16,8 @@ #pragma once -#include <backtrace/Backtrace.h> #include <log/log.h> +#include <unwindstack/AndroidUnwinder.h> #include <memory> @@ -26,12 +26,15 @@ public: // Create a callstack with the current thread's stack trace. // Immediately dump it to logcat using the given logtag. static void log(const char* logtag) noexcept { - std::unique_ptr<Backtrace> backtrace( - Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD)); - if (backtrace->Unwind(2)) { - for (size_t i = 0, c = backtrace->NumFrames(); i < c; i++) { + unwindstack::AndroidLocalUnwinder unwinder; + unwindstack::AndroidUnwinderData data; + if (unwinder.Unwind(data)) { + for (size_t i = 2, c = data.frames.size(); i < c; i++) { + auto& frame = data.frames[i]; + // Trim the first two frames. + frame.num -= 2; __android_log_print(ANDROID_LOG_DEBUG, logtag, "%s", - backtrace->FormatFrameData(i).c_str()); + unwinder.FormatFrame(frame).c_str()); } } } |