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

Commit 4f600fe0 authored by Christopher Ferris's avatar Christopher Ferris
Browse files

Add two new crash commands.

One is intentionally seeting the abort message. The other is to set
the abort message to null.

Also, make the libseccomp_policy static so that the crasher
executable can be copied to the system afterwards without
requiring libseccomp_policy.so.

Test: Ran both new crash commands on device.
Test: Ran the seccomp crash command to verify seccomp still works.
Change-Id: I255b5f37e6eb188719e5b72302ca3f5911c8d821
parent 64f953e2
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,8 @@ cc_binary {
    shared_libs: [
    shared_libs: [
        "libbase",
        "libbase",
        "liblog",
        "liblog",
    ],
    static_libs: [
        "libseccomp_policy",
        "libseccomp_policy",
    ],
    ],
    multilib: {
    multilib: {
+10 −0
Original line number Original line Diff line number Diff line
@@ -39,6 +39,8 @@
#include "debuggerd/handler.h"
#include "debuggerd/handler.h"
#endif
#endif


extern "C" void android_set_abort_message(const char* msg);

#if defined(__arm__)
#if defined(__arm__)
// See https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt for details.
// See https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt for details.
#define __kuser_helper_version (*(int32_t*) 0xffff0ffc)
#define __kuser_helper_version (*(int32_t*) 0xffff0ffc)
@@ -182,6 +184,8 @@ static int usage() {
    fprintf(stderr, "  leak                  leak memory until we get OOM-killed\n");
    fprintf(stderr, "  leak                  leak memory until we get OOM-killed\n");
    fprintf(stderr, "\n");
    fprintf(stderr, "\n");
    fprintf(stderr, "  abort                 call abort()\n");
    fprintf(stderr, "  abort                 call abort()\n");
    fprintf(stderr, "  abort_with_msg        call abort() setting an abort message\n");
    fprintf(stderr, "  abort_with_null_msg   call abort() setting a null abort message\n");
    fprintf(stderr, "  assert                call assert() without a function\n");
    fprintf(stderr, "  assert                call assert() without a function\n");
    fprintf(stderr, "  assert2               call assert() with a function\n");
    fprintf(stderr, "  assert2               call assert() with a function\n");
    fprintf(stderr, "  exit                  call exit(1)\n");
    fprintf(stderr, "  exit                  call exit(1)\n");
@@ -259,6 +263,12 @@ noinline int do_action(const char* arg) {
      return crash(42);
      return crash(42);
    } else if (!strcasecmp(arg, "abort")) {
    } else if (!strcasecmp(arg, "abort")) {
      maybe_abort();
      maybe_abort();
    } else if (!strcasecmp(arg, "abort_with_msg")) {
      android_set_abort_message("Aborting due to crasher");
      maybe_abort();
    } else if (!strcasecmp(arg, "abort_with_null")) {
      android_set_abort_message(nullptr);
      maybe_abort();
    } else if (!strcasecmp(arg, "assert")) {
    } else if (!strcasecmp(arg, "assert")) {
      __assert("some_file.c", 123, "false");
      __assert("some_file.c", 123, "false");
    } else if (!strcasecmp(arg, "assert2")) {
    } else if (!strcasecmp(arg, "assert2")) {