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

Commit 0915f23d authored by Josh Gao's avatar Josh Gao
Browse files

debuggerd: diagnostics for dumps that are guaranteed to fail.

Print diagnostics when the user requests a dump that is guaranteed to
fail, such as trying to dump a process you can't send a signal to.

Bug: http://b/63008395
Change-Id: I5c6bf2a5751f858e0534990b8d2ab6932eb9f11d
Test: manually tested
parent 9cb2e2eb
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -274,6 +274,7 @@ cc_binary {
        "libbase",
        "libbase",
        "libdebuggerd_client",
        "libdebuggerd_client",
        "liblog",
        "liblog",
        "libprocinfo",
        "libselinux",
        "libselinux",
    ],
    ],


+19 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@
#include <android-base/parseint.h>
#include <android-base/parseint.h>
#include <android-base/unique_fd.h>
#include <android-base/unique_fd.h>
#include <debuggerd/client.h>
#include <debuggerd/client.h>
#include <procinfo/process.h>
#include <selinux/selinux.h>
#include <selinux/selinux.h>
#include "util.h"
#include "util.h"


@@ -66,6 +67,24 @@ int main(int argc, char* argv[]) {
    usage(1);
    usage(1);
  }
  }


  if (getuid() != 0) {
    errx(1, "root is required");
  }

  // Check to see if the process exists and that we can actually send a signal to it.
  android::procinfo::ProcessInfo proc_info;
  if (!android::procinfo::GetProcessInfo(pid, &proc_info)) {
    err(1, "failed to fetch info for process %d", pid);
  }

  if (proc_info.state == android::procinfo::kProcessStateZombie) {
    errx(1, "process %d is a zombie", pid);
  }

  if (kill(pid, 0) != 0) {
    err(1, "cannot send signal to process %d", pid);
  }

  unique_fd piperead, pipewrite;
  unique_fd piperead, pipewrite;
  if (!Pipe(&piperead, &pipewrite)) {
  if (!Pipe(&piperead, &pipewrite)) {
    err(1, "failed to create pipe");
    err(1, "failed to create pipe");