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
pc_rel_temp_(nullptr),
dex_cache_arrays_min_offset_(std::numeric_limits<uint32_t>::max()),
cfi_(&last_lir_insn_,
- cu->compiler_driver->GetCompilerOptions().GetIncludeDebugSymbols(),
+ cu->compiler_driver->GetCompilerOptions().GetIncludeCFI(),
arena),
in_to_reg_storage_mapping_(arena) {
switch_tables_.reserve(4);
CompilerOptions::kDefaultTopKProfileThreshold,
false,
true, // include_debug_symbols.
+ true, // include_cfi
false,
false,
false,
top_k_profile_threshold_(kDefaultTopKProfileThreshold),
debuggable_(false),
include_debug_symbols_(kDefaultIncludeDebugSymbols),
+ include_cfi_(false),
implicit_null_checks_(true),
implicit_so_checks_(true),
implicit_suspend_checks_(false),
double top_k_profile_threshold,
bool debuggable,
bool include_debug_symbols,
+ bool include_cfi,
bool implicit_null_checks,
bool implicit_so_checks,
bool implicit_suspend_checks,
top_k_profile_threshold_(top_k_profile_threshold),
debuggable_(debuggable),
include_debug_symbols_(include_debug_symbols),
+ include_cfi_(include_cfi),
implicit_null_checks_(implicit_null_checks),
implicit_so_checks_(implicit_so_checks),
implicit_suspend_checks_(implicit_suspend_checks),
double top_k_profile_threshold,
bool debuggable,
bool include_debug_symbols,
+ bool include_cfi,
bool implicit_null_checks,
bool implicit_so_checks,
bool implicit_suspend_checks,
return include_debug_symbols_;
}
+ bool GetIncludeCFI() const {
+ // include-debug-symbols implies include-cfi.
+ return include_cfi_ || include_debug_symbols_;
+ }
+
bool GetImplicitNullChecks() const {
return implicit_null_checks_;
}
const double top_k_profile_threshold_;
const bool debuggable_;
const bool include_debug_symbols_;
+ const bool include_cfi_;
const bool implicit_null_checks_;
const bool implicit_so_checks_;
const bool implicit_suspend_checks_;
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.
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,
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);
namespace art {
namespace dwarf {
+void WriteEhFrame(const CompilerDriver* compiler,
+ OatWriter* oat_writer,
+ uint32_t text_section_offset,
+ std::vector<uint8_t>* eh_frame);
+
void WriteDebugSections(const CompilerDriver* compiler,
OatWriter* oat_writer,
uint32_t text_section_offset,
- std::vector<uint8_t>* eh_frame_data,
- std::vector<uint8_t>* debug_info_data,
- std::vector<uint8_t>* debug_abbrev_data,
- std::vector<uint8_t>* debug_str_data,
- std::vector<uint8_t>* debug_line_data);
+ std::vector<uint8_t>* debug_info,
+ std::vector<uint8_t>* debug_abbrev,
+ std::vector<uint8_t>* debug_str,
+ std::vector<uint8_t>* debug_line);
} // namespace dwarf
} // namespace art
return false;
}
+ if (compiler_driver_->GetCompilerOptions().GetIncludeCFI() &&
+ !oat_writer->GetMethodDebugInfo().empty()) {
+ ElfRawSectionBuilder<Elf_Word, Elf_Sword, Elf_Shdr> eh_frame(
+ ".eh_frame", SHT_PROGBITS, SHF_ALLOC, nullptr, 0, 4, 0);
+ dwarf::WriteEhFrame(compiler_driver_, oat_writer,
+ builder->GetTextBuilder().GetSection()->sh_addr,
+ eh_frame.GetBuffer());
+ builder->RegisterRawSection(eh_frame);
+ }
+
if (compiler_driver_->GetCompilerOptions().GetIncludeDebugSymbols() &&
!oat_writer->GetMethodDebugInfo().empty()) {
WriteDebugSymbols(compiler_driver_, builder.get(), oat_writer);
}
typedef ElfRawSectionBuilder<Elf_Word, Elf_Sword, Elf_Shdr> Section;
- Section eh_frame(".eh_frame", SHT_PROGBITS, SHF_ALLOC, nullptr, 0, 4, 0);
Section debug_info(".debug_info", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
Section debug_abbrev(".debug_abbrev", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
Section debug_str(".debug_str", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
dwarf::WriteDebugSections(compiler_driver,
oat_writer,
builder->GetTextBuilder().GetSection()->sh_addr,
- eh_frame.GetBuffer(),
debug_info.GetBuffer(),
debug_abbrev.GetBuffer(),
debug_str.GetBuffer(),
debug_line.GetBuffer());
- builder->RegisterRawSection(eh_frame);
builder->RegisterRawSection(debug_info);
builder->RegisterRawSection(debug_abbrev);
builder->RegisterRawSection(debug_str);
false,
false,
false,
+ false,
false, // pic
nullptr,
pass_manager_options,
// Assembler that holds generated instructions
std::unique_ptr<Assembler> jni_asm(Assembler::Create(instruction_set));
- jni_asm->cfi().SetEnabled(driver->GetCompilerOptions().GetIncludeDebugSymbols());
+ jni_asm->cfi().SetEnabled(driver->GetCompilerOptions().GetIncludeCFI());
// Offsets into data structures
// TODO: if cross compiling these offsets are for the host not the target
}
}
- if (writer_->compiler_driver_->GetCompilerOptions().GetIncludeDebugSymbols()) {
+ if (writer_->compiler_driver_->GetCompilerOptions().GetIncludeDebugSymbols() ||
+ writer_->compiler_driver_->GetCompilerOptions().GetIncludeCFI()) {
// Record debug information for this function if we are doing that.
const uint32_t quick_code_start = quick_code_offset -
writer_->oat_header_->GetExecutableOffset() - thumb_offset;
return nullptr;
}
codegen->GetAssembler()->cfi().SetEnabled(
- compiler_driver->GetCompilerOptions().GetIncludeDebugSymbols());
+ compiler_driver->GetCompilerOptions().GetIncludeCFI());
PassInfoPrinter pass_info_printer(graph,
method_name.c_str(),
UsageError("");
UsageError(" --no-include-debug-symbols: Do not include ELF symbols in this oat file");
UsageError("");
+ UsageError(" --include-cfi: Include call frame information in the .eh_frame section.");
+ UsageError(" The --include-debug-symbols option implies --include-cfi.");
+ UsageError("");
+ UsageError(" --no-include-cfi: Do not include call frame information in the .eh_frame section.");
+ 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.");
bool debuggable = false;
bool include_patch_information = CompilerOptions::kDefaultIncludePatchInformation;
bool include_debug_symbols = kIsDebugBuild;
+ bool include_cfi = kIsDebugBuild;
bool watch_dog_enabled = true;
bool abort_on_hard_verifier_error = false;
bool requested_specific_compiler = false;
include_debug_symbols = true;
} else if (option == "--no-include-debug-symbols" || option == "--strip-symbols") {
include_debug_symbols = false;
+ } else if (option == "--include-cfi") {
+ include_cfi = true;
+ } else if (option == "--no-include-cfi") {
+ include_cfi = false;
} else if (option == "--debuggable") {
debuggable = true;
} else if (option.starts_with("--profile-file=")) {
top_k_profile_threshold,
debuggable,
include_debug_symbols,
+ include_cfi,
implicit_null_checks,
implicit_so_checks,
implicit_suspend_checks,