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

Commit 007d7941 authored by Josh Gao's avatar Josh Gao Committed by Gerrit Code Review
Browse files

Merge "debuggerd: store commandline instead of process name."

parents 911850ec 31348a74
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -96,7 +96,7 @@ static std::string get_wchan_data(pid_t pid) {


  if (std::string str = data.str(); !str.empty()) {
  if (std::string str = data.str(); !str.empty()) {
    buffer << "\n----- Waiting Channels: pid " << pid << " at " << get_timestamp() << " -----\n"
    buffer << "\n----- Waiting Channels: pid " << pid << " at " << get_timestamp() << " -----\n"
           << "Cmd line: " << get_process_name(pid) << "\n";
           << "Cmd line: " << android::base::Join(get_command_line(pid), " ") << "\n";
    buffer << "\n" << str << "\n";
    buffer << "\n" << str << "\n";
    buffer << "----- end " << std::to_string(pid) << " -----\n";
    buffer << "----- end " << std::to_string(pid) << " -----\n";
    buffer << "\n";
    buffer << "\n";
+2 −4
Original line number Original line Diff line number Diff line
@@ -450,9 +450,6 @@ int main(int argc, char** argv) {
  //       unwind, do not make this too small. b/62828735
  //       unwind, do not make this too small. b/62828735
  alarm(30 * android::base::HwTimeoutMultiplier());
  alarm(30 * android::base::HwTimeoutMultiplier());


  // Get the process name (aka cmdline).
  std::string process_name = get_process_name(g_target_thread);

  // Collect the list of open files.
  // Collect the list of open files.
  OpenFilesList open_files;
  OpenFilesList open_files;
  {
  {
@@ -489,7 +486,6 @@ int main(int argc, char** argv) {
      info.pid = target_process;
      info.pid = target_process;
      info.tid = thread;
      info.tid = thread;
      info.uid = getuid();
      info.uid = getuid();
      info.process_name = process_name;
      info.thread_name = get_thread_name(thread);
      info.thread_name = get_thread_name(thread);


      unique_fd attr_fd(openat(target_proc_fd, "attr/current", O_RDONLY | O_CLOEXEC));
      unique_fd attr_fd(openat(target_proc_fd, "attr/current", O_RDONLY | O_CLOEXEC));
@@ -517,6 +513,8 @@ int main(int argc, char** argv) {
        ReadCrashInfo(input_pipe, &siginfo, &info.registers, &process_info);
        ReadCrashInfo(input_pipe, &siginfo, &info.registers, &process_info);
        info.siginfo = &siginfo;
        info.siginfo = &siginfo;
        info.signo = info.siginfo->si_signo;
        info.signo = info.siginfo->si_signo;

        info.command_line = get_command_line(g_target_thread);
      } else {
      } else {
        info.registers.reset(unwindstack::Regs::RemoteGet(thread));
        info.registers.reset(unwindstack::Regs::RemoteGet(thread));
        if (!info.registers) {
        if (!info.registers) {
+7 −5
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@
#include <memory>
#include <memory>
#include <string>
#include <string>


#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <android-base/unique_fd.h>
#include <log/log.h>
#include <log/log.h>
#include <unwindstack/Unwinder.h>
#include <unwindstack/Unwinder.h>
@@ -42,11 +43,12 @@
#include "libdebuggerd/utility.h"
#include "libdebuggerd/utility.h"
#include "util.h"
#include "util.h"


static void dump_process_header(log_t* log, pid_t pid, const char* process_name) {
static void dump_process_header(log_t* log, pid_t pid,
                                const std::vector<std::string>& command_line) {
  _LOG(log, logtype::BACKTRACE, "\n\n----- pid %d at %s -----\n", pid, get_timestamp().c_str());
  _LOG(log, logtype::BACKTRACE, "\n\n----- pid %d at %s -----\n", pid, get_timestamp().c_str());


  if (process_name) {
  if (!command_line.empty()) {
    _LOG(log, logtype::BACKTRACE, "Cmd line: %s\n", process_name);
    _LOG(log, logtype::BACKTRACE, "Cmd line: %s\n", android::base::Join(command_line, " ").c_str());
  }
  }
  _LOG(log, logtype::BACKTRACE, "ABI: '%s'\n", ABI_STRING);
  _LOG(log, logtype::BACKTRACE, "ABI: '%s'\n", ABI_STRING);
}
}
@@ -89,7 +91,7 @@ void dump_backtrace(android::base::unique_fd output_fd, unwindstack::Unwinder* u
    return;
    return;
  }
  }


  dump_process_header(&log, target->second.pid, target->second.process_name.c_str());
  dump_process_header(&log, target->second.pid, target->second.command_line);


  dump_backtrace_thread(output_fd.get(), unwinder, target->second);
  dump_backtrace_thread(output_fd.get(), unwinder, target->second);
  for (const auto& [tid, info] : thread_info) {
  for (const auto& [tid, info] : thread_info) {
@@ -107,7 +109,7 @@ void dump_backtrace_header(int output_fd) {
  log.amfd_data = nullptr;
  log.amfd_data = nullptr;


  pid_t pid = getpid();
  pid_t pid = getpid();
  dump_process_header(&log, pid, get_process_name(pid).c_str());
  dump_process_header(&log, pid, get_command_line(pid));
}
}


void dump_backtrace_footer(int output_fd) {
void dump_backtrace_footer(int output_fd) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@


#include <memory>
#include <memory>
#include <string>
#include <string>
#include <vector>


#include <unwindstack/Regs.h>
#include <unwindstack/Regs.h>


@@ -32,13 +33,14 @@ struct ThreadInfo {


  pid_t pid;
  pid_t pid;


  std::string process_name;
  std::vector<std::string> command_line;
  std::string selinux_label;
  std::string selinux_label;


  int signo = 0;
  int signo = 0;
  siginfo_t* siginfo = nullptr;
  siginfo_t* siginfo = nullptr;
};
};


// This struct is written into a pipe from inside the crashing process.
struct ProcessInfo {
struct ProcessInfo {
  uintptr_t abort_msg_address = 0;
  uintptr_t abort_msg_address = 0;
  uintptr_t fdsan_table_address = 0;
  uintptr_t fdsan_table_address = 0;
+5 −5
Original line number Original line Diff line number Diff line
@@ -350,11 +350,11 @@ TEST_F(TombstoneTest, dump_header_info) {
}
}


TEST_F(TombstoneTest, dump_thread_info_uid) {
TEST_F(TombstoneTest, dump_thread_info_uid) {
  dump_thread_info(&log_, ThreadInfo{.uid = 1,
  std::vector<std::string> cmdline = {"some_process"};
                                     .tid = 3,
  dump_thread_info(
                                     .thread_name = "some_thread",
      &log_,
                                     .pid = 2,
      ThreadInfo{
                                     .process_name = "some_process"});
          .uid = 1, .tid = 3, .thread_name = "some_thread", .pid = 2, .command_line = cmdline});
  std::string expected = "pid: 2, tid: 3, name: some_thread  >>> some_process <<<\nuid: 1\n";
  std::string expected = "pid: 2, tid: 3, name: some_thread  >>> some_process <<<\nuid: 1\n";
  ASSERT_STREQ(expected.c_str(), amfd_data_.c_str());
  ASSERT_STREQ(expected.c_str(), amfd_data_.c_str());
}
}
Loading