alur updated this revision to Diff 142875.
alur marked an inline comment as done.
alur added a comment.
Changed the diff to be against the NFCs.
https://reviews.llvm.org/D45628
Files:
packages/Python/lldbsuite/test/linux/compressed-debug-info/Makefile
packages/Python/lldbsuite/test/linux/compressed-debug-info/TestCompressedDebugInfo.py
packages/Python/lldbsuite/test/linux/compressed-debug-info/a.c
source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1775,13 +1775,20 @@
return eSectionTypeOther;
}
+ llvm::StringRef mapped_name;
+ if (section_name.startswith(".zdebug")) {
+ mapped_name = section_name.drop_front(2);
+ } else {
+ mapped_name = section_name.drop_front(1);
+ }
+
// MISSING? .gnu_debugdata - "mini debuginfo / MiniDebugInfo" section,
// http://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html
// MISSING? .debug-index -
// http://src.chromium.org/viewvc/chrome/trunk/src/build/gdb-add-index?pathrev=144644
// MISSING? .debug_types - Type descriptions from DWARF 4? See
// http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
- return llvm::StringSwitch<SectionType>(section_name.drop_front(1))
+ return llvm::StringSwitch<SectionType>(mapped_name)
.Case("text", eSectionTypeCode)
.Case("data", eSectionTypeData)
.Case("bss", eSectionTypeZeroFill)
@@ -2823,6 +2830,7 @@
void ObjectFileELF::RelocateSection(lldb_private::Section *section)
{
static const llvm::StringRef debug_prefix(".debug");
+ static const llvm::StringRef zdebug_prefix(".zdebug");
// Set relocated bit so we stop getting called, regardless of
// whether we actually relocate.
@@ -2838,7 +2846,8 @@
return;
// We don't relocate non-debug sections at the moment
- if (section_name.startswith(debug_prefix))
+ if (section_name.startswith(debug_prefix) ||
+ section_name.startswith(zdebug_prefix))
return;
// Relocation section names to look for
@@ -2869,7 +2878,7 @@
// First we save the new symbols into a separate list and add them to the
// symbol table after
- // we colleced all symbols we want to add. This is necessary because adding a
+ // we colleced all symbols we want to add. This is neccessary because adding a
// new symbol
// invalidates the internal index of the symtab what causing the next lookup
// to be slow because
@@ -3333,7 +3342,8 @@
return section->GetObjectFile()->ReadSectionData(section, section_offset,
dst, dst_len);
- if (!section->Test(SHF_COMPRESSED))
+ if (!llvm::object::Decompressor::isCompressedELFSection(
+ section->Get(), section->GetName().GetStringRef()))
return ObjectFile::ReadSectionData(section, section_offset, dst, dst_len);
// For compressed sections we need to read to full data to be able to
@@ -3352,7 +3362,8 @@
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES);
size_t result = ObjectFile::ReadSectionData(section, section_data);
- if (result == 0 || !section->Test(SHF_COMPRESSED))
+ if (result == 0 || !llvm::object::Decompressor::isCompressedELFSection(
+ section->Get(), section->GetName().GetStringRef()))
return result;
auto Decompressor = llvm::object::Decompressor::create(
Index: packages/Python/lldbsuite/test/linux/compressed-debug-info/a.c
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/compressed-debug-info/a.c
@@ -0,0 +1,4 @@
+int main() {
+ int z = 2;
+ return z;
+}
Index: packages/Python/lldbsuite/test/linux/compressed-debug-info/TestCompressedDebugInfo.py
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/compressed-debug-info/TestCompressedDebugInfo.py
@@ -0,0 +1,67 @@
+""" Tests that compressed debug info sections are used. """
+import os
+import lldb
+import sys
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCompressedDebugInfo(TestBase):
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ @no_debug_info_test # Prevent the genaration of the dwarf version of this test
+ @skipUnlessPlatform(["linux"])
+ def test_compressed_debug_info(self):
+ """Tests that we 'frame variable' works with compressed debug info."""
+
+ self.build()
+ exe = self.getBuildArtifact("compressed.out")
+
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ main_bp = self.target.BreakpointCreateByName("main", "compressed.out")
+ self.assertTrue(main_bp, VALID_BREAKPOINT)
+
+ self.process = self.target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(self.process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.assertTrue(self.process.GetState() == lldb.eStateStopped,
+ STOPPED_DUE_TO_BREAKPOINT)
+
+ frame = self.process.GetThreadAtIndex(0).GetFrameAtIndex(0)
+ z = frame.FindVariable("z")
+ self.assertTrue(z.IsValid(), "z is not valid")
+
+ @no_debug_info_test # Prevent the genaration of the dwarf version of this test
+ @skipUnlessPlatform(["linux"])
+ def test_compressed_debug_info_gnu(self):
+ """Tests that we 'frame variable' works with gnu-style compressed debug info."""
+
+ self.build()
+ exe = self.getBuildArtifact("compressed.gnu.out")
+
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ main_bp = self.target.BreakpointCreateByName("main", "compressed.gnu.out")
+ self.assertTrue(main_bp, VALID_BREAKPOINT)
+
+ self.process = self.target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertTrue(self.process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ self.assertTrue(self.process.GetState() == lldb.eStateStopped,
+ STOPPED_DUE_TO_BREAKPOINT)
+
+ frame = self.process.GetThreadAtIndex(0).GetFrameAtIndex(0)
+ z = frame.FindVariable("z")
+ self.assertTrue(z.IsValid(), "z is not valid")
+
Index: packages/Python/lldbsuite/test/linux/compressed-debug-info/Makefile
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/compressed-debug-info/Makefile
@@ -0,0 +1,16 @@
+LEVEL := ../../make
+
+C_SOURCES := a.c
+
+all: compressed.out compressed.gnu.out
+
+compressed.out: a.out
+ $(OBJCOPY) --compress-debug-sections=zlib $< $@
+
+compressed.gnu.out: a.out
+ $(OBJCOPY) --compress-debug-sections=zlib-gnu $< $@
+
+include $(LEVEL)/Makefile.rules
+
+clean::
+ $(RM) -f a.o main compressed.out compressed.gnu.out
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits