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

Commit 38488907 authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Move libbacktrace off cutils.

There's still <cutils/atomic.h> in a test, but I don't understand why
that isn't just std::atomic.

Also add a shared tgkill wrapper to libbase.

Bug: N/A
Test: ran tests
Change-Id: Idd4baa1e1670a84b3a8f35803cc5ffe5aae008a6
parent 1db37892
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -23,3 +23,8 @@ namespace base {
uint64_t GetThreadId();
}
}  // namespace android

#if defined(__GLIBC__)
// bionic has this Linux-specifix call, but glibc doesn't.
extern "C" int tgkill(int tgid, int tid, int sig);
#endif
+6 −0
Original line number Diff line number Diff line
@@ -46,3 +46,9 @@ uint64_t GetThreadId() {

}  // namespace base
}  // namespace android

#if defined(__GLIBC__)
int tgkill(int tgid, int tid, int sig) {
  return syscall(__NR_tgkill, tgid, tid, sig);
}
#endif
+0 −4
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ libbacktrace_sources = [
    "Backtrace.cpp",
    "BacktraceCurrent.cpp",
    "BacktracePtrace.cpp",
    "thread_utils.c",
    "ThreadEntry.cpp",
    "UnwindStack.cpp",
    "UnwindStackMap.cpp",
@@ -94,7 +93,6 @@ cc_library {
            ],

            static_libs: [
                "libcutils",
                "libprocinfo",
            ],

@@ -145,7 +143,6 @@ cc_test {
        "backtrace_offline_test.cpp",
        "backtrace_test.cpp",
        "GetPss.cpp",
        "thread_utils.c",
    ],

    cflags: [
@@ -159,7 +156,6 @@ cc_test {
        "libbacktrace",
        "libdexfile",
        "libbase",
        "libcutils",
        "liblog",
        "libunwindstack",
    ],
+2 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <string>

#include <android-base/stringprintf.h>
#include <android-base/threads.h>

#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>
@@ -31,7 +32,6 @@

#include "BacktraceLog.h"
#include "UnwindStack.h"
#include "thread_utils.h"

using android::base::StringPrintf;

@@ -124,7 +124,7 @@ Backtrace* Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) {
  if (pid == BACKTRACE_CURRENT_PROCESS) {
    pid = getpid();
    if (tid == BACKTRACE_CURRENT_THREAD) {
      tid = gettid();
      tid = android::base::GetThreadId();
    }
  } else if (tid == BACKTRACE_CURRENT_THREAD) {
    tid = pid;
+7 −6
Original line number Diff line number Diff line
@@ -28,13 +28,13 @@

#include <string>

#include <android-base/threads.h>
#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>

#include "BacktraceAsyncSafeLog.h"
#include "BacktraceCurrent.h"
#include "ThreadEntry.h"
#include "thread_utils.h"

bool BacktraceCurrent::ReadWord(uint64_t ptr, word_t* out_value) {
  if (!VerifyReadWordArgs(ptr, out_value)) {
@@ -76,7 +76,7 @@ bool BacktraceCurrent::Unwind(size_t num_ignore_frames, void* ucontext) {
    return UnwindFromContext(num_ignore_frames, ucontext);
  }

  if (Tid() != gettid()) {
  if (Tid() != android::base::GetThreadId()) {
    return UnwindThread(num_ignore_frames);
  }

@@ -114,16 +114,17 @@ class ErrnoRestorer {
static void SignalLogOnly(int, siginfo_t*, void*) {
  ErrnoRestorer restore;

  BACK_ASYNC_SAFE_LOGE("pid %d, tid %d: Received a spurious signal %d\n", getpid(), gettid(),
                       THREAD_SIGNAL);
  BACK_ASYNC_SAFE_LOGE("pid %d, tid %d: Received a spurious signal %d\n", getpid(),
                       static_cast<int>(android::base::GetThreadId()), THREAD_SIGNAL);
}

static void SignalHandler(int, siginfo_t*, void* sigcontext) {
  ErrnoRestorer restore;

  ThreadEntry* entry = ThreadEntry::Get(getpid(), gettid(), false);
  ThreadEntry* entry = ThreadEntry::Get(getpid(), android::base::GetThreadId(), false);
  if (!entry) {
    BACK_ASYNC_SAFE_LOGE("pid %d, tid %d entry not found", getpid(), gettid());
    BACK_ASYNC_SAFE_LOGE("pid %d, tid %d entry not found", getpid(),
                         static_cast<int>(android::base::GetThreadId()));
    return;
  }

Loading