Add --include-cfi compiler option.

Decouple generation of CFI from the rest of debug symbols.
This makes it possible to generate oat with CFI but without
the rest of debug symbols.

This is in line with intention of the .eh_frame section.
The section does not have the .debug_ prefix because it
is considered somewhat different to the rest of debug symbols.

Change-Id: I32816ecd4f30ac4e0dc69d69a4993e349c737f96
diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc
index 6df5ea9..f7811dd 100644
--- a/compiler/elf_writer_debug.cc
+++ b/compiler/elf_writer_debug.cc
@@ -149,6 +149,25 @@
   UNREACHABLE();
 }
 
+void WriteEhFrame(const CompilerDriver* compiler,
+                  OatWriter* oat_writer,
+                  uint32_t text_section_offset,
+                  std::vector<uint8_t>* eh_frame) {
+  const auto& method_infos = oat_writer->GetMethodDebugInfo();
+  const InstructionSet isa = compiler->GetInstructionSet();
+  size_t cie_offset = eh_frame->size();
+  auto* eh_frame_patches = oat_writer->GetAbsolutePatchLocationsFor(".eh_frame");
+  WriteEhFrameCIE(isa, eh_frame);
+  for (const OatWriter::DebugInfo& mi : method_infos) {
+    const SwapVector<uint8_t>* opcodes = mi.compiled_method_->GetCFIInfo();
+    if (opcodes != nullptr) {
+      WriteEhFrameFDE(Is64BitInstructionSet(isa), cie_offset,
+                      text_section_offset + mi.low_pc_, mi.high_pc_ - mi.low_pc_,
+                      opcodes, eh_frame, eh_frame_patches);
+    }
+  }
+}
+
 /*
  * @brief Generate the DWARF sections.
  * @param oat_writer The Oat file Writer.
@@ -161,7 +180,6 @@
 void WriteDebugSections(const CompilerDriver* compiler,
                         OatWriter* oat_writer,
                         uint32_t text_section_offset,
-                        std::vector<uint8_t>* eh_frame,
                         std::vector<uint8_t>* debug_info,
                         std::vector<uint8_t>* debug_abbrev,
                         std::vector<uint8_t>* debug_str,
@@ -175,19 +193,6 @@
     cunit_high_pc = std::max(cunit_high_pc, method_info.high_pc_);
   }
 
-  // Write .eh_frame section.
-  auto* eh_frame_patches = oat_writer->GetAbsolutePatchLocationsFor(".eh_frame");
-  size_t cie_offset = eh_frame->size();
-  WriteEhFrameCIE(isa, eh_frame);
-  for (const OatWriter::DebugInfo& mi : method_infos) {
-    const SwapVector<uint8_t>* opcodes = mi.compiled_method_->GetCFIInfo();
-    if (opcodes != nullptr) {
-      WriteEhFrameFDE(Is64BitInstructionSet(isa), cie_offset,
-                      text_section_offset + mi.low_pc_, mi.high_pc_ - mi.low_pc_,
-                      opcodes, eh_frame, eh_frame_patches);
-    }
-  }
-
   // Write .debug_info section.
   size_t debug_abbrev_offset = debug_abbrev->size();
   DebugInfoEntryWriter<> info(false /* 32 bit */, debug_abbrev);