Remove --native-debuggable compiler option.

Check if both --debuggable and --generate-debug-info are set instead.

History: I have recently added the --native-debuggable flag to control
whether extra stack maps are generated in order to produce accurate
native line number mapping of all generated code. I didn't want to
include it into --debuggable since we compile boot.oat as debuggable
and so it would be affected.

On second thought, it would have been reasonable to generate the extra
stackmaps only if both --debuggable and --generate-debug-info are set,
instead of introducing another compiler flag. This means we do not
affect boot.oat but we still get the extra stack maps if DWARF debug
information is explicitly requested.

Change-Id: I7e5e557e4850a88b3b6f86178d2cb645fb1e1110
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
index 3bf8921..43bdbf3 100644
--- a/compiler/driver/compiler_options.cc
+++ b/compiler/driver/compiler_options.cc
@@ -35,7 +35,6 @@
       include_patch_information_(kDefaultIncludePatchInformation),
       top_k_profile_threshold_(kDefaultTopKProfileThreshold),
       debuggable_(false),
-      native_debuggable_(kDefaultNativeDebuggable),
       generate_debug_info_(kDefaultGenerateDebugInfo),
       generate_mini_debug_info_(kDefaultGenerateMiniDebugInfo),
       implicit_null_checks_(true),
@@ -92,7 +91,6 @@
     include_patch_information_(include_patch_information),
     top_k_profile_threshold_(top_k_profile_threshold),
     debuggable_(debuggable),
-    native_debuggable_(kDefaultNativeDebuggable),
     generate_debug_info_(generate_debug_info),
     generate_mini_debug_info_(kDefaultGenerateMiniDebugInfo),
     implicit_null_checks_(implicit_null_checks),
@@ -226,9 +224,6 @@
     generate_mini_debug_info_ = false;
   } else if (option == "--debuggable") {
     debuggable_ = true;
-  } else if (option == "--native-debuggable") {
-    native_debuggable_ = true;
-    debuggable_ = true;
   } else if (option.starts_with("--top-k-profile-threshold=")) {
     ParseDouble(option.data(), '=', 0.0, 100.0, &top_k_profile_threshold_, Usage);
   } else if (option == "--include-patch-information") {
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 4db82a6..fbfa7c8 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -49,7 +49,6 @@
   static const size_t kDefaultTinyMethodThreshold = 20;
   static const size_t kDefaultNumDexMethodsThreshold = 900;
   static constexpr double kDefaultTopKProfileThreshold = 90.0;
-  static const bool kDefaultNativeDebuggable = false;
   static const bool kDefaultGenerateDebugInfo = false;
   static const bool kDefaultGenerateMiniDebugInfo = false;
   static const bool kDefaultIncludePatchInformation = false;
@@ -179,7 +178,7 @@
   }
 
   bool GetNativeDebuggable() const {
-    return native_debuggable_;
+    return GetDebuggable() && GetGenerateDebugInfo();
   }
 
   // This flag controls whether the compiler collects debugging information.
@@ -292,7 +291,6 @@
   // When using a profile file only the top K% of the profiled samples will be compiled.
   double top_k_profile_threshold_;
   bool debuggable_;
-  bool native_debuggable_;
   bool generate_debug_info_;
   bool generate_mini_debug_info_;
   bool implicit_null_checks_;
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index ce4f38a..a5d0c27 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -317,7 +317,7 @@
   UsageError("  -g");
   UsageError("  --generate-debug-info: Generate debug information for native debugging,");
   UsageError("      such as stack unwinding information, ELF symbols and DWARF sections.");
-  UsageError("      If used without --native-debuggable, it will be best-effort only.");
+  UsageError("      If used without --debuggable, it will be best-effort only.");
   UsageError("      This option does not affect the generated code. (disabled by default)");
   UsageError("");
   UsageError("  --no-generate-debug-info: Do not generate debug information for native debugging.");
@@ -325,13 +325,10 @@
   UsageError("  --generate-mini-debug-info: Generate minimal amount of LZMA-compressed");
   UsageError("      debug information necessary to print backtraces. (disabled by default)");
   UsageError("");
-  UsageError("  --no-generate-mini-debug-info: Do do generated backtrace info.");
+  UsageError("  --no-generate-mini-debug-info: Do not generate backtrace info.");
   UsageError("");
   UsageError("  --debuggable: Produce code debuggable with Java debugger.");
   UsageError("");
-  UsageError("  --native-debuggable: Produce code debuggable with native debugger (like LLDB).");
-  UsageError("      Implies --debuggable.");
-  UsageError("");
   UsageError("  --runtime-arg <argument>: used to specify various arguments for the runtime,");
   UsageError("      such as initial heap size, maximum heap size, and verbose output.");
   UsageError("      Use a separate --runtime-arg switch for each argument.");
@@ -1037,7 +1034,7 @@
         compiler_options_->debuggable_ ? OatHeader::kTrueValue : OatHeader::kFalseValue);
     key_value_store_->Put(
         OatHeader::kNativeDebuggableKey,
-        compiler_options_->native_debuggable_ ? OatHeader::kTrueValue : OatHeader::kFalseValue);
+        compiler_options_->GetNativeDebuggable() ? OatHeader::kTrueValue : OatHeader::kFalseValue);
     if (compiler_options_->IsExtractOnly()) {
       key_value_store_->Put(OatHeader::kCompilationType, OatHeader::kExtractOnlyValue);
     } else if (UseProfileGuidedCompilation()) {
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index a092b9f..65002df 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -119,7 +119,8 @@
   }
 
   if ((debug_flags & DEBUG_NATIVE_DEBUGGABLE) != 0) {
-    runtime->AddCompilerOption("--native-debuggable");
+    runtime->AddCompilerOption("--debuggable");
+    runtime->AddCompilerOption("--generate-debug-info");
     debug_flags &= ~DEBUG_NATIVE_DEBUGGABLE;
   }