diff options
author | 2015-05-06 18:27:35 +0100 | |
---|---|---|
committer | 2015-05-19 15:36:53 +0100 | |
commit | ad5fa8c5b26a325dc2a9521b87188755046c17f3 (patch) | |
tree | 1be28a827fe9e186196ad744eaa3438c1bea3f0a /compiler/dwarf/dwarf_test.cc | |
parent | cfee0507f26375fe048ed35f402e61f904db0095 (diff) |
Support generation of CFI in .debug_frame format.
.debug_frame section is almost identical to .eh_frame section.
There are only minor differences in the CIE and FDE headers.
The main difference is that .eh_frame is intended to be used
at runtime for exception handling and is therefore allocated
within the running program whereas .debug_frame is not.
This makes .debug_frame easier to remove using standard tools.
"objcopy --strip-debug" removes .debug_frame, but not .eh_frame.
(although objcopy can be still be forced to remove .eh_frame)
Similarly, we might want to separate the CFI to separate debug
file or include it as compressed .gnu_debugdata section.
It is more appropriate to use .debug_frame for this purpose.
Bug:20556771
Change-Id: I9d91a333b9fb37523fd6fafccfad89b21d2477af
Diffstat (limited to 'compiler/dwarf/dwarf_test.cc')
-rw-r--r-- | compiler/dwarf/dwarf_test.cc | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/compiler/dwarf/dwarf_test.cc b/compiler/dwarf/dwarf_test.cc index edba00aeaa..4971f0ef10 100644 --- a/compiler/dwarf/dwarf_test.cc +++ b/compiler/dwarf/dwarf_test.cc @@ -26,6 +26,8 @@ namespace art { namespace dwarf { +constexpr CFIFormat kCFIFormat = DW_DEBUG_FRAME_FORMAT; + // Run the tests only on host since we need objdump. #ifndef HAVE_ANDROID_OS @@ -120,30 +122,30 @@ TEST_F(DwarfTest, DebugFrame) { DW_CHECK_NEXT("DW_CFA_restore: r5 (ebp)"); DebugFrameOpCodeWriter<> initial_opcodes; - WriteEhFrameCIE(is64bit, DW_EH_PE_absptr, Reg(is64bit ? 16 : 8), - initial_opcodes, &eh_frame_data_); - std::vector<uintptr_t> eh_frame_patches; + WriteDebugFrameCIE(is64bit, DW_EH_PE_absptr, Reg(is64bit ? 16 : 8), + initial_opcodes, kCFIFormat, &debug_frame_data_); + std::vector<uintptr_t> debug_frame_patches; std::vector<uintptr_t> expected_patches { 28 }; // NOLINT - WriteEhFrameFDE(is64bit, 0, 0x01000000, 0x01000000, opcodes.data(), - &eh_frame_data_, &eh_frame_patches); + WriteDebugFrameFDE(is64bit, 0, 0x01000000, 0x01000000, opcodes.data(), + kCFIFormat, &debug_frame_data_, &debug_frame_patches); - EXPECT_EQ(expected_patches, eh_frame_patches); + EXPECT_EQ(expected_patches, debug_frame_patches); CheckObjdumpOutput(is64bit, "-W"); } TEST_F(DwarfTest, DebugFrame64) { constexpr bool is64bit = true; DebugFrameOpCodeWriter<> initial_opcodes; - WriteEhFrameCIE(is64bit, DW_EH_PE_absptr, Reg(16), - initial_opcodes, &eh_frame_data_); + WriteDebugFrameCIE(is64bit, DW_EH_PE_absptr, Reg(16), + initial_opcodes, kCFIFormat, &debug_frame_data_); DebugFrameOpCodeWriter<> opcodes; - std::vector<uintptr_t> eh_frame_patches; + std::vector<uintptr_t> debug_frame_patches; std::vector<uintptr_t> expected_patches { 32 }; // NOLINT - WriteEhFrameFDE(is64bit, 0, 0x0100000000000000, 0x0200000000000000, - opcodes.data(), &eh_frame_data_, &eh_frame_patches); + WriteDebugFrameFDE(is64bit, 0, 0x0100000000000000, 0x0200000000000000, + opcodes.data(), kCFIFormat, &debug_frame_data_, &debug_frame_patches); DW_CHECK("FDE cie=00000000 pc=100000000000000..300000000000000"); - EXPECT_EQ(expected_patches, eh_frame_patches); + EXPECT_EQ(expected_patches, debug_frame_patches); CheckObjdumpOutput(is64bit, "-W"); } @@ -173,11 +175,11 @@ TEST_F(DwarfTest, x86_64_RegisterMapping) { DW_CHECK_NEXT("DW_CFA_offset: r14 (r14)"); DW_CHECK_NEXT("DW_CFA_offset: r15 (r15)"); DebugFrameOpCodeWriter<> initial_opcodes; - WriteEhFrameCIE(is64bit, DW_EH_PE_absptr, Reg(16), - initial_opcodes, &eh_frame_data_); - std::vector<uintptr_t> eh_frame_patches; - WriteEhFrameFDE(is64bit, 0, 0x0100000000000000, 0x0200000000000000, - opcodes.data(), &eh_frame_data_, &eh_frame_patches); + WriteDebugFrameCIE(is64bit, DW_EH_PE_absptr, Reg(16), + initial_opcodes, kCFIFormat, &debug_frame_data_); + std::vector<uintptr_t> debug_frame_patches; + WriteDebugFrameFDE(is64bit, 0, 0x0100000000000000, 0x0200000000000000, + opcodes.data(), kCFIFormat, &debug_frame_data_, &debug_frame_patches); CheckObjdumpOutput(is64bit, "-W"); } |