[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-05-02 Thread Erik Welander via Phabricator via lldb-commits
alur updated this revision to Diff 144889.

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
@@ -1762,13 +1762,22 @@
 return eSectionTypeOther;
   }
 
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+// .zdebug* are compressed equivalents of .debug* sections, and should map
+// to the same corresponding type.
+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(section_name.drop_front(1))
+  return llvm::StringSwitch(mapped_name)
   .Case("text", eSectionTypeCode)
   .Case("data", eSectionTypeData)
   .Case("bss", eSectionTypeZeroFill)
@@ -2794,6 +2803,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.
@@ -2809,7 +2819,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
@@ -3301,7 +3312,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
@@ -3320,7 +3332,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,46 @@
+""" 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 the 'frame variable' works with compressed debug info."""
+
+self.build()
+process = lldbutil.run_to_source_breakpoint(
+self, "main", lldb.SBFileSpec("a.c"), exe_name="compressed.out")[1]
+
+# The process should be stopped at a breakpoint, and the z variable should
+# be in the top frame.
+self.assertTrue(process.GetState() == lldb.eStateStopped,
+STOPPED_DUE_TO_BREAKPOINT)
+frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0)
+self.assertTrue(frame.FindVariable("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 the 'frame variable' works with gnu-style compressed debug 

[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-05-01 Thread Erik Welander via Phabricator via lldb-commits
alur updated this revision to Diff 144834.
alur edited the summary of this revision.
alur added a comment.

Since there was some changes to the file during the last couple of days I've 
updated the patches to be against HEAD again.


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
@@ -1762,13 +1762,22 @@
 return eSectionTypeOther;
   }
 
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+// .zdebug* are compressed equivalents of .debug* sections, and should map
+// to the same corresponding type.
+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(section_name.drop_front(1))
+  return llvm::StringSwitch(mapped_name)
   .Case("text", eSectionTypeCode)
   .Case("data", eSectionTypeData)
   .Case("bss", eSectionTypeZeroFill)
@@ -2794,6 +2803,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.
@@ -2809,7 +2819,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
@@ -3301,7 +3312,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
@@ -3320,7 +3332,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,46 @@
+""" 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 the 'frame variable' works with compressed debug info."""
+
+self.build()
+process = lldbutil.run_to_source_breakpoint(
+self, "main", lldb.SBFileSpec("a.c"), exe_name="compressed.out")[1]
+
+# The process should be stopped at a breakpoint, and the z variable should
+# be in the top frame.
+self.assertTrue(process.GetState() == lldb.eStateStopped,
+STOPPED_DUE_TO_BREAKPOINT)
+frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0)
+self.assertTrue(frame.FindVariable("z").IsValid(), "z is not valid")
+
+  @no_debug_info_test  # Prevent the genaration 

[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-27 Thread Erik Welander via Phabricator via lldb-commits
alur added a comment.

Thank you David.

This is still based on the latest revision of the file (+ the non functional 
change patch).

F6048729: nfc.patch 


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-27 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

This is fine, I'll commit it for you today.


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-24 Thread Leonard Mosescu via Phabricator via lldb-commits
lemo added subscribers: bgianfo, clayborg, alur, labath, penryu, lemo.
lemo added a comment.

Hi Erik, the review is still marked as requiring changes. Once that is
sorted out I'd be happy to submit this on your behalf (what is the base SVN
revision for the latest patch?)

Davide Italiano, is all the CR feedback addressed in the latest revision?


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-24 Thread Leonard Mosescu via lldb-commits
Hi Erik, the review is still marked as requiring changes. Once that is
sorted out I'd be happy to submit this on your behalf (what is the base SVN
revision for the latest patch?)

Davide Italiano, is all the CR feedback addressed in the latest revision?

On Tue, Apr 24, 2018 at 1:38 PM, Erik Welander via Phabricator via
lldb-commits  wrote:

> alur added a comment.
>
> Friendly ping, is there anything else I need to do for this to get
> submitted?
>
>
> https://reviews.llvm.org/D45628
>
>
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-24 Thread Erik Welander via Phabricator via lldb-commits
alur added a comment.

Friendly ping, is there anything else I need to do for this to get submitted?


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-18 Thread Erik Welander via Phabricator via lldb-commits
alur marked 3 inline comments as done.
alur added a comment.

Thank you, I do need someone to push this on my behalf.


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-18 Thread Erik Welander via Phabricator via lldb-commits
alur updated this revision to Diff 142962.

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,22 @@
 return eSectionTypeOther;
   }
 
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+// .zdebug* are compressed equivalents of .debug* sections, and should map
+// to the same corresponding type.
+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(section_name.drop_front(1))
+  return llvm::StringSwitch(mapped_name)
   .Case("text", eSectionTypeCode)
   .Case("data", eSectionTypeData)
   .Case("bss", eSectionTypeZeroFill)
@@ -2823,6 +2832,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 +2848,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
@@ -,7 +3344,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 +3364,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,47 @@
+""" 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 the 'frame variable' works with compressed debug info."""
+
+self.build()
+process = lldbutil.run_to_source_breakpoint(
+self, "main", lldb.SBFileSpec("a.c"), exe_name="compressed.out")[1]
+
+# The process should be stopped at a breakpoint, and the z variable should
+# be in the top frame.
+self.assertTrue(process.GetState() == lldb.eStateStopped,
+STOPPED_DUE_TO_BREAKPOINT)
+frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0)
+self.assertTrue(frame.FindVariable("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 the 'frame variable' works with gnu-style compressed debug 

[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-18 Thread Davide Italiano via Phabricator via lldb-commits
davide requested changes to this revision.
davide added a comment.
This revision now requires changes to proceed.

Some minor comments, almost ready to go. Do you have commit access or you need 
somebody to push this on your behalf?




Comment at: 
packages/Python/lldbsuite/test/linux/compressed-debug-info/TestCompressedDebugInfo.py:22-40
+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)

This test is too much boilerplate. We moved to a new, more concise style. You 
might consider using
```
(target, process, thread, main_breakpoint) = 
lldbutil.run_to_source_breakpoint(self, 
"break here", src_file_spec, exe_name = exe)
```

instead.



Comment at: 
packages/Python/lldbsuite/test/linux/compressed-debug-info/TestCompressedDebugInfo.py:47-64
+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")

ditto.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1778-1781
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+mapped_name = section_name.drop_front(2);
+  } else {

Can you add a comment to explain why are you dropping the first two character 
here? 



https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-18 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

Very nice!


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-17 Thread Erik Welander via Phabricator via lldb-commits
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(section_name.drop_front(1))
+  return llvm::StringSwitch(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
@@ -,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)
+
+

[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-17 Thread Erik Welander via Phabricator via lldb-commits
alur marked an inline comment as done.
alur added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1773-1781
+static SectionType getSectionType(llvm::StringRef section_name) {
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+mapped_name = section_name.drop_front(2);
+  } else if (!section_name.startswith(".")) {
+return eSectionTypeOther;
+  } else {

davide wrote:
> Thanks! This was exactly what I had in mind. Do you mind to split the NFC 
> changes into a separate patch (that can be committed without review)? This 
> will make this patch much easier to review.
Sure, attached it here.
{F5970155}


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-17 Thread Erik Welander via Phabricator via lldb-commits
alur updated this revision to Diff 142869.

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
@@ -1770,6 +1770,70 @@
   return 0;
 }
 
+static SectionType getSectionType(llvm::StringRef section_name) {
+  if (!section_name.startswith(".")) {
+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(mapped_name)
+  .Case("text", eSectionTypeCode)
+  .Case("data", eSectionTypeData)
+  .Case("bss", eSectionTypeZeroFill)
+  .Case("tdata", eSectionTypeData)
+  .Case("tbss", eSectionTypeZeroFill)
+  // Abbreviations used in the .debug_info section
+  .Case("debug_abbrev", eSectionTypeDWARFDebugAbbrev)
+  .Case("debug_abbrev.dwo", eSectionTypeDWARFDebugAbbrev)
+  .Case("debug_addr", eSectionTypeDWARFDebugAddr)
+  // Lookup table for mapping addresses to compilation units
+  .Case("debug_aranges", eSectionTypeDWARFDebugAranges)
+  .Case("debug_cu_index", eSectionTypeDWARFDebugCuIndex)
+  // Call frame information
+  .Case("debug_frame", eSectionTypeDWARFDebugFrame)
+  // The core DWARF information section
+  .Case("debug_info", eSectionTypeDWARFDebugInfo)
+  .Case("debug_info.dwo", eSectionTypeDWARFDebugInfo)
+  // Line number information
+  .Case("debug_line", eSectionTypeDWARFDebugLine)
+  .Case("debug_line.dwo", eSectionTypeDWARFDebugLine)
+  // Location lists used in DW_AT_location attributes
+  .Case("debug_loc", eSectionTypeDWARFDebugLoc)
+  .Case("debug_loc.dwo", eSectionTypeDWARFDebugLoc)
+  // Macro information
+  .Case("debug_macinfo", eSectionTypeDWARFDebugMacInfo)
+  .Case("debug_macro", eSectionTypeDWARFDebugMacro)
+  .Case("debug_macro.dwo", eSectionTypeDWARFDebugMacro)
+  // Lookup table for mapping object and function names to compilation units
+  .Case("debug_pubnames", eSectionTypeDWARFDebugPubNames)
+  // Lookup table for mapping type names to compilation units
+  .Case("debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
+  // Address ranges used in DW_AT_ranges attributes
+  .Case("debug_ranges", eSectionTypeDWARFDebugRanges)
+  // String table used in .debug_info
+  .Case("debug_str", eSectionTypeDWARFDebugStr)
+  .Case("debug_str.dwo", eSectionTypeDWARFDebugStr)
+  .Case("debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
+  .Case("debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsets)
+  .Case("eh_frame", eSectionTypeEHFrame)
+  .Case("ARM.exidx", eSectionTypeARMexidx)
+  .Case("ARM.extab", eSectionTypeARMextab)
+  .Case("gosymtab", eSectionTypeGoSymtab)
+  .Default(eSectionTypeOther);
+}
+
 void ObjectFileELF::CreateSections(SectionList _section_list) {
   if (!m_sections_ap.get() && ParseSectionHeaders()) {
 m_sections_ap.reset(new SectionList());
@@ -1784,135 +1848,14 @@
  I != m_section_headers.end(); ++I) {
   const ELFSectionHeaderInfo  = *I;
 
-  ConstString  = I->section_name;
+  llvm::StringRef section_name = I->section_name.GetStringRef();
   const uint64_t file_size =
   header.sh_type == SHT_NOBITS ? 0 : header.sh_size;
   const uint64_t vm_size = header.sh_flags & SHF_ALLOC ? header.sh_size : 0;
 
-  static ConstString g_sect_name_text(".text");
-  static ConstString g_sect_name_data(".data");
-  static ConstString g_sect_name_bss(".bss");
-  static ConstString g_sect_name_tdata(".tdata");
-  static ConstString g_sect_name_tbss(".tbss");
-  static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev");
-  static ConstString g_sect_name_dwarf_debug_addr(".debug_addr");
-  static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges");
-  static ConstString g_sect_name_dwarf_debug_cu_index(".debug_cu_index");
-  static ConstString g_sect_name_dwarf_debug_frame(".debug_frame");
-  static ConstString g_sect_name_dwarf_debug_info(".debug_info");
-  static 

[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-17 Thread Erik Welander via Phabricator via lldb-commits
alur updated this revision to Diff 142862.

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
@@ -1770,6 +1770,70 @@
   return 0;
 }
 
+static SectionType getSectionType(llvm::StringRef section_name) {
+  if (!section_name.startswith(".")) {
+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(mapped_name)
+  .Case("text", eSectionTypeCode)
+  .Case("data", eSectionTypeData)
+  .Case("bss", eSectionTypeZeroFill)
+  .Case("tdata", eSectionTypeData)
+  .Case("tbss", eSectionTypeZeroFill)
+  // Abbreviations used in the .debug_info section
+  .Case("debug_abbrev", eSectionTypeDWARFDebugAbbrev)
+  .Case("debug_abbrev.dwo", eSectionTypeDWARFDebugAbbrev)
+  .Case("debug_addr", eSectionTypeDWARFDebugAddr)
+  // Lookup table for mapping addresses to compilation units
+  .Case("debug_aranges", eSectionTypeDWARFDebugAranges)
+  .Case("debug_cu_index", eSectionTypeDWARFDebugCuIndex)
+  // Call frame information
+  .Case("debug_frame", eSectionTypeDWARFDebugFrame)
+  // The core DWARF information section
+  .Case("debug_info", eSectionTypeDWARFDebugInfo)
+  .Case("debug_info.dwo", eSectionTypeDWARFDebugInfo)
+  // Line number information
+  .Case("debug_line", eSectionTypeDWARFDebugLine)
+  .Case("debug_line.dwo", eSectionTypeDWARFDebugLine)
+  // Location lists used in DW_AT_location attributes
+  .Case("debug_loc", eSectionTypeDWARFDebugLoc)
+  .Case("debug_loc.dwo", eSectionTypeDWARFDebugLoc)
+  // Macro information
+  .Case("debug_macinfo", eSectionTypeDWARFDebugMacInfo)
+  .Case("debug_macro", eSectionTypeDWARFDebugMacro)
+  .Case("debug_macro.dwo", eSectionTypeDWARFDebugMacro)
+  // Lookup table for mapping object and function names to compilation units
+  .Case("debug_pubnames", eSectionTypeDWARFDebugPubNames)
+  // Lookup table for mapping type names to compilation units
+  .Case("debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
+  // Address ranges used in DW_AT_ranges attributes
+  .Case("debug_ranges", eSectionTypeDWARFDebugRanges)
+  // String table used in .debug_info
+  .Case("debug_str", eSectionTypeDWARFDebugStr)
+  .Case("debug_str.dwo", eSectionTypeDWARFDebugStr)
+  .Case("debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
+  .Case("debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsets)
+  .Case("eh_frame", eSectionTypeEHFrame)
+  .Case("ARM.exidx", eSectionTypeARMexidx)
+  .Case("ARM.extab", eSectionTypeARMextab)
+  .Case("gosymtab", eSectionTypeGoSymtab)
+  .Default(eSectionTypeOther);
+}
+
 void ObjectFileELF::CreateSections(SectionList _section_list) {
   if (!m_sections_ap.get() && ParseSectionHeaders()) {
 m_sections_ap.reset(new SectionList());
@@ -1784,135 +1848,14 @@
  I != m_section_headers.end(); ++I) {
   const ELFSectionHeaderInfo  = *I;
 
-  ConstString  = I->section_name;
+  llvm::StringRef section_name = I->section_name.GetStringRef();
   const uint64_t file_size =
   header.sh_type == SHT_NOBITS ? 0 : header.sh_size;
   const uint64_t vm_size = header.sh_flags & SHF_ALLOC ? header.sh_size : 0;
 
-  static ConstString g_sect_name_text(".text");
-  static ConstString g_sect_name_data(".data");
-  static ConstString g_sect_name_bss(".bss");
-  static ConstString g_sect_name_tdata(".tdata");
-  static ConstString g_sect_name_tbss(".tbss");
-  static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev");
-  static ConstString g_sect_name_dwarf_debug_addr(".debug_addr");
-  static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges");
-  static ConstString g_sect_name_dwarf_debug_cu_index(".debug_cu_index");
-  static ConstString g_sect_name_dwarf_debug_frame(".debug_frame");
-  static ConstString g_sect_name_dwarf_debug_info(".debug_info");
-  static 

[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thank you for the patch. For testing I'd recommend taking a look at r320813 
https://reviews.llvm.org/D40616, which implemented the SHF_COMPRESSED part of 
the compressed section support. It looks like we should add a new field to the 
"lldb-test module-sections" output, so that we can test the section type 
computation code.


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Davide Italiano via Phabricator via lldb-commits
davide added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1773-1781
+static SectionType getSectionType(llvm::StringRef section_name) {
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+mapped_name = section_name.drop_front(2);
+  } else if (!section_name.startswith(".")) {
+return eSectionTypeOther;
+  } else {

Thanks! This was exactly what I had in mind. Do you mind to split the NFC 
changes into a separate patch (that can be committed without review)? This will 
make this patch much easier to review.


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Erik Welander via Phabricator via lldb-commits
alur added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1893
 sect_type = eSectionTypeDWARFDebugAbbrev;
-  else if (name == g_sect_name_dwarf_debug_addr)
+  else if (name == g_sect_name_dwarf_debug_addr ||
+   name == g_sect_name_dwarf_zdebug_addr)

aprantl wrote:
> Could this entire device be replaced by a llvm::StringSwitch or something 
> else more elegant?
I moved it out into a separate method with a StringSwitch



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3451
+  if (!llvm::object::Decompressor::isCompressedELFSection(
+  section->Get(), section->GetName().GetStringRef()))
 return ObjectFile::ReadSectionData(section, section_offset, dst, dst_len);

clayborg wrote:
> use "section_name" here instead of "section->GetName().GetStringRef()" since 
> we switched it to a StringRef
This is a separate method, which doesn't have a section_name variable.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3472
+ section->Get(), section->GetName().GetStringRef()))
 return result;
 

clayborg wrote:
> Ditto
Same here.


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Erik Welander via Phabricator via lldb-commits
alur updated this revision to Diff 142478.
alur marked 7 inline comments as done.
alur added a comment.

I refactored the code to address the comments on it. I'll add those tests once 
I get the test runner to work.


https://reviews.llvm.org/D45628

Files:
  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
@@ -1770,6 +1770,68 @@
   return 0;
 }
 
+static SectionType getSectionType(llvm::StringRef section_name) {
+  llvm::StringRef mapped_name;
+  if (section_name.startswith(".zdebug")) {
+mapped_name = section_name.drop_front(2);
+  } else if (!section_name.startswith(".")) {
+return eSectionTypeOther;
+  } 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(mapped_name)
+  .Case("text", eSectionTypeCode)
+  .Case("data", eSectionTypeData)
+  .Case("bss", eSectionTypeZeroFill)
+  .Case("tdata", eSectionTypeData)
+  .Case("tbss", eSectionTypeZeroFill)
+  // Abbreviations used in the .debug_info section
+  .Case("debug_abbrev", eSectionTypeDWARFDebugAbbrev)
+  .Case("debug_abbrev.dwo", eSectionTypeDWARFDebugAbbrev)
+  .Case("debug_addr", eSectionTypeDWARFDebugAddr)
+  // Lookup table for mapping addresses to compilation units
+  .Case("debug_aranges", eSectionTypeDWARFDebugAranges)
+  .Case("debug_cu_index", eSectionTypeDWARFDebugCuIndex)
+  // Call frame information
+  .Case("debug_frame", eSectionTypeDWARFDebugFrame)
+  // The core DWARF information section
+  .Case("debug_info", eSectionTypeDWARFDebugInfo)
+  .Case("debug_info.dwo", eSectionTypeDWARFDebugInfo)
+  // Line number information
+  .Case("debug_line", eSectionTypeDWARFDebugLine)
+  .Case("debug_line.dwo", eSectionTypeDWARFDebugLine)
+  // Location lists used in DW_AT_location attributes
+  .Case("debug_loc", eSectionTypeDWARFDebugLoc)
+  .Case("debug_loc.dwo", eSectionTypeDWARFDebugLoc)
+  // Macro information
+  .Case("debug_macinfo", eSectionTypeDWARFDebugMacInfo)
+  .Case("debug_macro", eSectionTypeDWARFDebugMacro)
+  .Case("debug_macro.dwo", eSectionTypeDWARFDebugMacro)
+  // Lookup table for mapping object and function names to compilation units
+  .Case("debug_pubnames", eSectionTypeDWARFDebugPubNames)
+  // Lookup table for mapping type names to compilation units
+  .Case("debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
+  // Address ranges used in DW_AT_ranges attributes
+  .Case("debug_ranges", eSectionTypeDWARFDebugRanges)
+  // String table used in .debug_info
+  .Case("debug_str", eSectionTypeDWARFDebugStr)
+  .Case("debug_str.dwo", eSectionTypeDWARFDebugStr)
+  .Case("debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
+  .Case("debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsets)
+  .Case("eh_frame", eSectionTypeEHFrame)
+  .Case("ARM.exidx", eSectionTypeARMexidx)
+  .Case("ARM.extab", eSectionTypeARMextab)
+  .Case("gosymtab", eSectionTypeGoSymtab)
+  .Default(eSectionTypeOther);
+}
+
 void ObjectFileELF::CreateSections(SectionList _section_list) {
   if (!m_sections_ap.get() && ParseSectionHeaders()) {
 m_sections_ap.reset(new SectionList());
@@ -1784,135 +1846,14 @@
  I != m_section_headers.end(); ++I) {
   const ELFSectionHeaderInfo  = *I;
 
-  ConstString  = I->section_name;
+  llvm::StringRef section_name = I->section_name.GetStringRef();
   const uint64_t file_size =
   header.sh_type == SHT_NOBITS ? 0 : header.sh_size;
   const uint64_t vm_size = header.sh_flags & SHF_ALLOC ? header.sh_size : 0;
 
-  static ConstString g_sect_name_text(".text");
-  static ConstString g_sect_name_data(".data");
-  static ConstString g_sect_name_bss(".bss");
-  static ConstString g_sect_name_tdata(".tdata");
-  static ConstString g_sect_name_tbss(".tbss");
-  static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev");
-  static ConstString g_sect_name_dwarf_debug_addr(".debug_addr");
-  static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges");
-  static ConstString g_sect_name_dwarf_debug_cu_index(".debug_cu_index");
-  static ConstString g_sect_name_dwarf_debug_frame(".debug_frame");
-  static ConstString g_sect_name_dwarf_debug_info(".debug_info");
-  static ConstString g_sect_name_dwarf_debug_line(".debug_line");
-   

[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

We should test both ways: using normal DWARF section names with SHF_COMPRESSED, 
and with ".zdebug" prefixed section names.


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Thanks for clarifying. You'll also need to add a testcase. If clang supports 
this then I don't have a problem with supporting this in LLDB and adding a 
testcase should be easy.




Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1893
 sect_type = eSectionTypeDWARFDebugAbbrev;
-  else if (name == g_sect_name_dwarf_debug_addr)
+  else if (name == g_sect_name_dwarf_debug_addr ||
+   name == g_sect_name_dwarf_zdebug_addr)

Could this entire device be replaced by a llvm::StringSwitch or something else 
more elegant?


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In https://reviews.llvm.org/D45628#1067375, @aprantl wrote:

> Which compilers / platforms generate / support this? Is this an ELF-only 
> feature?


Clang/LLVM do (-Wa,--compress-debug-sections). Yeah, it's ELF only so far as I 
know. There's a couple of variations (-compress-debug-sections=zlib or 
zlib-gnu) the ".zdebug_foo" is zlib-gnu style, but a more modern variant (zlib) 
uses a section attribute SHF_COMPRESSED instead of the name mangling.

In https://reviews.llvm.org/D45628#1067382, @clayborg wrote:

> If this is for current and future debugging, it would be nice to change the 
> tool to just use the normal .debug prefixes and just specify SHF_COMPRESSED???


At least for now, zlib-gnu style is used at Google - I don't actually know what 
it'd cost to switch to the more modern zlib (using SHF_COMPRESSED) style. No 
doubt there are a variety of tools that may not have been updated/improved to 
support the new format - hard to say.


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

If this is for current and future debugging, it would be nice to change the 
tool to just use the normal .debug prefixes and just specify SHF_COMPRESSED???


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2937-2938
 {
   static const char *debug_prefix = ".debug";
+  static const char *zdebug_prefix = ".zdebug";
 

Might be worth making these llvm::StringRef, then see comments below..



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2948
 
   const char *section_name = section->GetName().GetCString();
   // Can't relocate that which can't be named

Make this a StringRef:

```
llvm::StringRef section_name = section->GetName().GetStringRef();
```



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2954-2955
   // We don't relocate non-debug sections at the moment
-  if (strncmp(section_name, debug_prefix, strlen(debug_prefix)))
+  if (strncmp(section_name, debug_prefix, strlen(debug_prefix)) ||
+  strncmp(section_name, zdebug_prefix, strlen(zdebug_prefix)))
 return;

use StringRef::startswith:

```
if (section_name.startswith(debug_prefix) || 
section_name.startswith(zdebug_prefix))
```



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3451
+  if (!llvm::object::Decompressor::isCompressedELFSection(
+  section->Get(), section->GetName().GetStringRef()))
 return ObjectFile::ReadSectionData(section, section_offset, dst, dst_len);

use "section_name" here instead of "section->GetName().GetStringRef()" since we 
switched it to a StringRef



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3472
+ section->Get(), section->GetName().GetStringRef()))
 return result;
 

Ditto


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Which compilers / platforms generate / support this? Is this an ELF-only 
feature?


https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Davide Italiano via Phabricator via lldb-commits
davide added subscribers: jasonmolenda, davide.
davide requested changes to this revision.
davide added a comment.
This revision now requires changes to proceed.

This requires an unittest (or an lldb-test test). Some comments inline.
I think @clayborg or @jasonmolenda are in a better position to review the 
structure, I can take a look at the ELF specific details.




Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1890-1891
   // http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
-  else if (name == g_sect_name_dwarf_debug_abbrev)
+  else if (name == g_sect_name_dwarf_debug_abbrev ||
+   name == g_sect_name_dwarf_zdebug_abbrev)
 sect_type = eSectionTypeDWARFDebugAbbrev;

this whole cascade is really not ideal. Maybe we should factor the checks out 
or move this to be a switch?



Comment at: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2113-2115
+  // GOOGLE3: never use hash or hash.
+#if 0
+

Please remove references to GOOGLE3.


Repository:
  rL LLVM

https://reviews.llvm.org/D45628



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D45628: [LLDB] Support compressed debug info sections (.zdebug*)

2018-04-13 Thread Erik Welander via Phabricator via lldb-commits
alur created this revision.
alur added reviewers: labath, clayborg.
alur added a project: LLDB.
Herald added subscribers: llvm-commits, JDevlieghere, arichardson, aprantl, 
emaste.
Herald added a reviewer: espindola.

Repository:
  rL LLVM

https://reviews.llvm.org/D45628

Files:
  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
@@ -1819,6 +1819,32 @@
   static ConstString g_sect_name_dwarf_debug_str_dwo(".debug_str.dwo");
   static ConstString g_sect_name_dwarf_debug_str_offsets_dwo(
   ".debug_str_offsets.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_abbrev(".zdebug_abbrev");
+  static ConstString g_sect_name_dwarf_zdebug_addr(".zdebug_addr");
+  static ConstString g_sect_name_dwarf_zdebug_aranges(".zdebug_aranges");
+  static ConstString g_sect_name_dwarf_zdebug_cu_index(".zdebug_cu_index");
+  static ConstString g_sect_name_dwarf_zdebug_frame(".zdebug_frame");
+  static ConstString g_sect_name_dwarf_zdebug_info(".zdebug_info");
+  static ConstString g_sect_name_dwarf_zdebug_line(".zdebug_line");
+  static ConstString g_sect_name_dwarf_zdebug_loc(".zdebug_loc");
+  static ConstString g_sect_name_dwarf_zdebug_macinfo(".zdebug_macinfo");
+  static ConstString g_sect_name_dwarf_zdebug_macro(".zdebug_macro");
+  static ConstString g_sect_name_dwarf_zdebug_pubnames(".zdebug_pubnames");
+  static ConstString g_sect_name_dwarf_zdebug_pubtypes(".zdebug_pubtypes");
+  static ConstString g_sect_name_dwarf_zdebug_ranges(".zdebug_ranges");
+  static ConstString g_sect_name_dwarf_zdebug_str(".zdebug_str");
+  static ConstString g_sect_name_dwarf_zdebug_str_offsets(
+  ".zdebug_str_offsets");
+  static ConstString g_sect_name_dwarf_zdebug_abbrev_dwo(
+  ".zdebug_abbrev.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_info_dwo(".zdebug_info.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_line_dwo(".zdebug_line.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_macro_dwo(
+  ".zdebug_macro.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_loc_dwo(".zdebug_loc.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_str_dwo(".zdebug_str.dwo");
+  static ConstString g_sect_name_dwarf_zdebug_str_offsets_dwo(
+  ".zdebug_str_offsets.dwo");
   static ConstString g_sect_name_eh_frame(".eh_frame");
   static ConstString g_sect_name_arm_exidx(".ARM.exidx");
   static ConstString g_sect_name_arm_extab(".ARM.extab");
@@ -1861,49 +1887,71 @@
   // 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
-  else if (name == g_sect_name_dwarf_debug_abbrev)
+  else if (name == g_sect_name_dwarf_debug_abbrev ||
+   name == g_sect_name_dwarf_zdebug_abbrev)
 sect_type = eSectionTypeDWARFDebugAbbrev;
-  else if (name == g_sect_name_dwarf_debug_addr)
+  else if (name == g_sect_name_dwarf_debug_addr ||
+   name == g_sect_name_dwarf_zdebug_addr)
 sect_type = eSectionTypeDWARFDebugAddr;
-  else if (name == g_sect_name_dwarf_debug_aranges)
+  else if (name == g_sect_name_dwarf_debug_aranges ||
+   name == g_sect_name_dwarf_zdebug_aranges)
 sect_type = eSectionTypeDWARFDebugAranges;
-  else if (name == g_sect_name_dwarf_debug_cu_index)
+  else if (name == g_sect_name_dwarf_debug_cu_index ||
+   name == g_sect_name_dwarf_zdebug_cu_index)
 sect_type = eSectionTypeDWARFDebugCuIndex;
-  else if (name == g_sect_name_dwarf_debug_frame)
+  else if (name == g_sect_name_dwarf_debug_frame ||
+   name == g_sect_name_dwarf_zdebug_frame)
 sect_type = eSectionTypeDWARFDebugFrame;
-  else if (name == g_sect_name_dwarf_debug_info)
+  else if (name == g_sect_name_dwarf_debug_info ||
+   name == g_sect_name_dwarf_zdebug_info)
 sect_type = eSectionTypeDWARFDebugInfo;
-  else if (name == g_sect_name_dwarf_debug_line)
+  else if (name == g_sect_name_dwarf_debug_line ||
+   name == g_sect_name_dwarf_zdebug_line)
 sect_type = eSectionTypeDWARFDebugLine;
-  else if (name == g_sect_name_dwarf_debug_loc)
+  else if (name == g_sect_name_dwarf_debug_loc ||
+   name == g_sect_name_dwarf_zdebug_loc)
 sect_type = eSectionTypeDWARFDebugLoc;
-  else if (name == g_sect_name_dwarf_debug_macinfo)
+  else if (name == g_sect_name_dwarf_debug_macinfo ||
+   name == g_sect_name_dwarf_zdebug_macinfo)
 sect_type = eSectionTypeDWARFDebugMacInfo;
-  else if (name ==