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

Commit 2a2d7ba8 authored by Andreas Gampe's avatar Andreas Gampe
Browse files

Installd: Emit minidebug-info

If globally enabled, pass --generate-mini-debug-info to dex2oat
when dalvik.vm.dex2oat-minidebuginfo is set to annotate compiled code
with unwind information.

Test: m
Test: adb shell setprop dalvik.vm.dex2oat-minidebuginfo false && adb shell cmd package compile -f -a
Test: adb shell setprop dalvik.vm.dex2oat-minidebuginfo true && adb shell cmd package compile -f -a
Change-Id: I0ff0c4f40d2cb8a14816b4a967e5707170845080
parent a73a0cbc
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -53,6 +53,15 @@ using android::base::unique_fd;
namespace android {
namespace installd {

// Should minidebug info be included in compiled artifacts? Even if this value is
// "true," usage might still be conditional to other constraints, e.g., system
// property overrides.
static constexpr bool kEnableMinidebugInfo = true;

static constexpr const char* kMinidebugInfoSystemProperty = "dalvik.vm.dex2oat-minidebuginfo";
static constexpr bool kMinidebugInfoSystemPropertyDefault = false;
static constexpr const char* kMinidebugDex2oatFlag = "--generate-mini-debug-info";

// Deleter using free() for use with std::unique_ptr<>. See also UniqueCPtr<> below.
struct FreeDelete {
  // NOTE: Deleting a const object is valid but free() takes a non-const pointer.
@@ -286,6 +295,10 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd
        dex2oat_bin = kDex2oatDebugPath;
    }

    bool generate_minidebug_info = kEnableMinidebugInfo &&
            android::base::GetBoolProperty(kMinidebugInfoSystemProperty,
                                           kMinidebugInfoSystemPropertyDefault);

    static const char* RUNTIME_ARG = "--runtime-arg";

    static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
@@ -413,7 +426,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd
                     + (profile_fd == -1 ? 0 : 1)
                     + (class_loader_context != nullptr ? 1 : 0)
                     + (has_base_dir ? 1 : 0)
                     + (have_dex2oat_large_app_threshold ? 1 : 0)];
                     + (have_dex2oat_large_app_threshold ? 1 : 0)
                     + (generate_minidebug_info ? 1 : 0)];
    int i = 0;
    argv[i++] = dex2oat_bin;
    argv[i++] = zip_fd_arg;
@@ -477,6 +491,9 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd
    if (class_loader_context != nullptr) {
        argv[i++] = class_loader_context_arg;
    }
    if (generate_minidebug_info) {
        argv[i++] = kMinidebugDex2oatFlag;
    }

    // Do not add after dex2oat_flags, they should override others for debugging.
    argv[i] = NULL;