jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a dependency: D40475: DWZ 10/11: DWZ test mode.

So far `/usr/lib/debug/.build-id/**.debug` files could be opened any way.  But 
with DWZ they can contain relative filename reference to 
`/usr/lib/debug/.dwz/*` files which then depends on whether the build-id .debug 
file is a symlink or not.  Resolve the symlinks first before storing the 
filename for later references.

All DWZ patches are also applied in: git clone -b dwz 
git://git.jankratochvil.net/lldb


https://reviews.llvm.org/D43512

Files:
  packages/Python/lldbsuite/test/decorators.py
  packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile
  
packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py
  packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===================================================================
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -280,6 +280,11 @@
         const std::string &filename = files[idx_file];
         FileSpec file_spec(filename, true);
 
+        if (llvm::sys::fs::equivalent(file_spec.GetPath(),
+                                      module_file_spec.GetPath()))
+          continue;
+        if (FileSystem::ResolveSymbolicLink(file_spec, file_spec).Fail())
+          continue;
         if (llvm::sys::fs::equivalent(file_spec.GetPath(),
                                       module_file_spec.GetPath()))
           continue;
Index: packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
@@ -0,0 +1,6 @@
+struct s {
+  int i1, i2, i3, i4, i5, i6, i7, i8, i9;
+} v;
+int main() {
+  return 0;
+}
Index: packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py
@@ -0,0 +1,24 @@
+""" Testing separate debug info loading for base binary with a symlink. """
+import os
+import time
+import lldb
+import sys
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestTargetSymbolsBuildidSymlink(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @no_debug_info_test  # Prevent the genaration of the dwarf version of this test
+    @skipUnlessPlatform(['linux'])
+    @skipIf(hostoslist=["windows"])
+    @skipIfRemote # llvm.org/pr36237
+    @skipUnlessDWZInstalled
+    def test_target_symbols_buildid_symlink(self):
+        self.build(clean=True)
+        exe = self.getBuildArtifact("stripped.out")
+
+        lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe)
Index: packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile
@@ -0,0 +1,24 @@
+LEVEL = ../../make
+C_SOURCES := main.c
+LD_EXTRAS += -Wl,--build-id=sha1
+
+all: .build-id
+
+.PHONY: .build-id
+stripped.out stripped.debug stripped.debug.dwz: a.out
+	eu-strip --remove-comment -f stripped.debug -F stripped.debugx -o stripped.out $<
+	cp -p stripped.debug stripped.debug.dup
+	dwz -m stripped.debug.dwz stripped.debug stripped.debug.dup
+
+.build-id: stripped.debug
+	$(OBJCOPY) -j .note.gnu.build-id -O binary $< tmp
+	rm -rf .build-id
+	fn=`od -An -tx1 <tmp|tr -d ' \n'|sed -e 's/^.\{32\}//' -e 's#^..#.build-id/&/#' -e 's#$$#.debug#'` && \
+	mkdir -p `dirname $$fn` && \
+	ln -s ../../$< $$fn
+	$(RM) tmp
+
+clean::
+	$(RM) -r stripped.out .build-id stripped.debug stripped.debug.dup stripped.debug.dwz
+
+include $(LEVEL)/Makefile.rules
Index: packages/Python/lldbsuite/test/decorators.py
===================================================================
--- packages/Python/lldbsuite/test/decorators.py
+++ packages/Python/lldbsuite/test/decorators.py
@@ -10,6 +10,7 @@
 import re
 import sys
 import tempfile
+import distutils.spawn
 
 # Third-party modules
 import six
@@ -771,3 +772,18 @@
     fail_value = True # More likely to notice if something goes wrong
     have_xml = xml.GetValueForKey("value").GetBooleanValue(fail_value)
     return unittest2.skipIf(not have_xml, "requires xml support")(func)
+
+def skipUnlessDWZInstalled(func):
+    """Decorate the item to skip tests when no DWZ optimization tool is available.
+       /usr/lib/rpm/sepdebugcrcfix is not tested here but it may be needed
+       when build-ids cannot be used."""
+
+    def is_dwz_missing(self):
+        if distutils.spawn.find_executable("dwz") is None:
+            return "skipping because dwz is not found"
+        # dwz has a bug it can process only separate debug info files.
+        # Moreover dwz is compatible only with debug infos created by eu-strip.
+        if distutils.spawn.find_executable("eu-strip") is None:
+            return "skipping because eu-strip is not found"
+        return None
+    return skipTestIfFn(is_dwz_missing)(func)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to