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

Commit 1e45d3f2 authored by Jerome Gaillard's avatar Jerome Gaillard
Browse files

Revert "libdebuggerd: add protobuf implementation."

Revert "Let crash_dump read /proc/$PID."

Revert submission 1556807-tombstone_proto

Reason for revert: b/178455196, Broken test: android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls on git_master on cf_x86_64_phone-userdebug

Reverted Changes:
Ide6811297:tombstoned: switch from goto to RAII.
I8d285c4b4:tombstoned: make it easier to add more types of ou...
Id0f0fa285:tombstoned: support for protobuf fds.
I6be6082ab:Let crash_dump read /proc/$PID.
Id812ca390:Make protobuf vendor_ramdisk_available.
Ieeece6e6d:libdebuggerd: add protobuf implementation.

Change-Id: Ia0a1ee57e7630e01c495dc166218f665340aad7f
parent a50f61f8
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -176,8 +176,6 @@ cc_library_static {
        "libdebuggerd/open_files_list.cpp",
        "libdebuggerd/scudo.cpp",
        "libdebuggerd/tombstone.cpp",
        "libdebuggerd/tombstone_proto.cpp",
        "libdebuggerd/tombstone_proto_to_text.cpp",
        "libdebuggerd/utility.cpp",
    ],

@@ -208,8 +206,6 @@ cc_library_static {
    whole_static_libs: [
        "gwp_asan_crash_handler",
        "libscudo",
        "libtombstone_proto",
        "libprotobuf-cpp-lite",
    ],

    target: {
@@ -232,20 +228,6 @@ cc_library_static {
    },
}

cc_binary {
    name: "pbtombstone",
    defaults: ["debuggerd_defaults"],
    srcs: ["pbtombstone.cpp"],
    static_libs: [
        "libbase",
        "libdebuggerd",
        "liblog",
        "libprotobuf-cpp-lite",
        "libtombstone_proto",
        "libunwindstack",
    ],
}

cc_test {
    name: "debuggerd_test",
    defaults: ["debuggerd_defaults"],
@@ -350,9 +332,6 @@ cc_binary {
        "libtombstoned_client_static",
        "libdebuggerd",
        "libcutils",

        "libtombstone_proto",
        "libprotobuf-cpp-lite",
    ],

    shared_libs: [
+6 −22
Original line number Diff line number Diff line
@@ -195,7 +195,6 @@ static pid_t g_target_thread = -1;
static bool g_tombstoned_connected = false;
static unique_fd g_tombstoned_socket;
static unique_fd g_output_fd;
static unique_fd g_proto_fd;

static void DefuseSignalHandlers() {
  // Don't try to dump ourselves.
@@ -216,7 +215,7 @@ static void Initialize(char** argv) {
    // If we abort before we get an output fd, contact tombstoned to let any
    // potential listeners know that we failed.
    if (!g_tombstoned_connected) {
      if (!tombstoned_connect(g_target_thread, &g_tombstoned_socket, &g_output_fd, &g_proto_fd,
      if (!tombstoned_connect(g_target_thread, &g_tombstoned_socket, &g_output_fd,
                              kDebuggerdAnyIntercept)) {
        // We failed to connect, not much we can do.
        LOG(ERROR) << "failed to connected to tombstoned to report failure";
@@ -249,20 +248,10 @@ static void ParseArgs(int argc, char** argv, pid_t* pseudothread_tid, DebuggerdD
  }

  int dump_type_int;
  if (!android::base::ParseInt(argv[3], &dump_type_int, 0)) {
  if (!android::base::ParseInt(argv[3], &dump_type_int, 0, 1)) {
    LOG(FATAL) << "invalid requested dump type: " << argv[3];
  }

  *dump_type = static_cast<DebuggerdDumpType>(dump_type_int);
  switch (*dump_type) {
    case kDebuggerdNativeBacktrace:
    case kDebuggerdTombstone:
    case kDebuggerdTombstoneProto:
      break;

    default:
      LOG(FATAL) << "invalid requested dump type: " << dump_type_int;
  }
}

static void ReadCrashInfo(unique_fd& fd, siginfo_t* siginfo,
@@ -491,11 +480,6 @@ int main(int argc, char** argv) {
      info.process_name = process_name;
      info.thread_name = get_thread_name(thread);

      unique_fd attr_fd(openat(target_proc_fd, "attr/current", O_RDONLY | O_CLOEXEC));
      if (!android::base::ReadFdToString(attr_fd, &info.selinux_label)) {
        PLOG(WARNING) << "failed to read selinux label";
      }

      if (!ptrace_interrupt(thread, &info.signo)) {
        PLOG(WARNING) << "failed to ptrace interrupt thread " << thread;
        ptrace(PTRACE_DETACH, thread, 0, 0);
@@ -574,8 +558,8 @@ int main(int argc, char** argv) {
  {
    ATRACE_NAME("tombstoned_connect");
    LOG(INFO) << "obtaining output fd from tombstoned, type: " << dump_type;
    g_tombstoned_connected = tombstoned_connect(g_target_thread, &g_tombstoned_socket, &g_output_fd,
                                                &g_proto_fd, dump_type);
    g_tombstoned_connected =
        tombstoned_connect(g_target_thread, &g_tombstoned_socket, &g_output_fd, dump_type);
  }

  if (g_tombstoned_connected) {
@@ -628,8 +612,8 @@ int main(int argc, char** argv) {

    {
      ATRACE_NAME("engrave_tombstone");
      engrave_tombstone(std::move(g_output_fd), std::move(g_proto_fd), &unwinder, thread_info,
                        g_target_thread, process_info, &open_files, &amfd_data);
      engrave_tombstone(std::move(g_output_fd), &unwinder, thread_info, g_target_thread, process_info,
                        &open_files, &amfd_data);
    }
  }

+9 −10
Original line number Diff line number Diff line
@@ -92,15 +92,15 @@ static void debuggerd_fallback_trace(int output_fd, ucontext_t* ucontext) {
  __linker_disable_fallback_allocator();
}

static void debuggerd_fallback_tombstone(int output_fd, int proto_fd, ucontext_t* ucontext,
                                         siginfo_t* siginfo, void* abort_message) {
static void debuggerd_fallback_tombstone(int output_fd, ucontext_t* ucontext, siginfo_t* siginfo,
                                         void* abort_message) {
  if (!__linker_enable_fallback_allocator()) {
    async_safe_format_log(ANDROID_LOG_ERROR, "libc", "fallback allocator already in use");
    return;
  }

  engrave_tombstone_ucontext(output_fd, proto_fd, reinterpret_cast<uintptr_t>(abort_message),
                             siginfo, ucontext);
  engrave_tombstone_ucontext(output_fd, reinterpret_cast<uintptr_t>(abort_message), siginfo,
                             ucontext);
  __linker_disable_fallback_allocator();
}

@@ -232,8 +232,7 @@ static void trace_handler(siginfo_t* info, ucontext_t* ucontext) {

  // Fetch output fd from tombstoned.
  unique_fd tombstone_socket, output_fd;
  if (!tombstoned_connect(getpid(), &tombstone_socket, &output_fd, nullptr,
                          kDebuggerdNativeBacktrace)) {
  if (!tombstoned_connect(getpid(), &tombstone_socket, &output_fd, kDebuggerdNativeBacktrace)) {
    async_safe_format_log(ANDROID_LOG_ERROR, "libc",
                          "missing crash_dump_fallback() in selinux policy?");
    goto exit;
@@ -326,10 +325,10 @@ static void crash_handler(siginfo_t* info, ucontext_t* ucontext, void* abort_mes
    _exit(1);
  }

  unique_fd tombstone_socket, output_fd, proto_fd;
  bool tombstoned_connected = tombstoned_connect(getpid(), &tombstone_socket, &output_fd, &proto_fd,
                                                 kDebuggerdTombstoneProto);
  debuggerd_fallback_tombstone(output_fd.get(), proto_fd.get(), ucontext, info, abort_message);
  unique_fd tombstone_socket, output_fd;
  bool tombstoned_connected =
      tombstoned_connect(getpid(), &tombstone_socket, &output_fd, kDebuggerdTombstone);
  debuggerd_fallback_tombstone(output_fd.get(), ucontext, info, abort_message);
  if (tombstoned_connected) {
    tombstoned_notify_completion(tombstone_socket.get());
  }
+1 −1
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ static DebuggerdDumpType get_dump_type(const debugger_thread_info* thread_info)
    return kDebuggerdNativeBacktrace;
  }

  return kDebuggerdTombstoneProto;
  return kDebuggerdTombstone;
}

static int debuggerd_dispatch_pseudothread(void* arg) {
+3 −14
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <stddef.h>
#include <sys/types.h>

#include <functional>
#include <map>
#include <string>

@@ -31,8 +30,6 @@
#include "types.h"

// Forward declarations
class Tombstone;

namespace unwindstack {
class Unwinder;
}
@@ -47,21 +44,13 @@ constexpr size_t kMaxFrames = 256;
int open_tombstone(std::string* path);

/* Creates a tombstone file and writes the crash dump to it. */
void engrave_tombstone(android::base::unique_fd output_fd, android::base::unique_fd proto_fd,
                       unwindstack::Unwinder* unwinder,
void engrave_tombstone(android::base::unique_fd output_fd, unwindstack::Unwinder* unwinder,
                       const std::map<pid_t, ThreadInfo>& thread_info, pid_t target_thread,
                       const ProcessInfo& process_info, OpenFilesList* open_files,
                       std::string* amfd_data);

void engrave_tombstone_ucontext(int tombstone_fd, int proto_fd, uint64_t abort_msg_address,
                                siginfo_t* siginfo, ucontext_t* ucontext);

void engrave_tombstone_proto(Tombstone* tombstone, unwindstack::Unwinder* unwinder,
                             const std::map<pid_t, ThreadInfo>& threads, pid_t target_thread,
                             const ProcessInfo& process_info, const OpenFilesList* open_files);
void engrave_tombstone_ucontext(int tombstone_fd, uint64_t abort_msg_address, siginfo_t* siginfo,
                                ucontext_t* ucontext);

bool tombstone_proto_to_text(
    const Tombstone& tombstone,
    std::function<void(const std::string& line, bool should_log)> callback);

#endif  // _DEBUGGERD_TOMBSTONE_H
Loading