[Lldb-commits] [lldb] d24bce5 - Add a testcase for .dSYM path remapping dictionaries.

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 11 12:24:03 PST 2019


Author: Adrian Prantl
Date: 2019-11-11T12:21:38-08:00
New Revision: d24bce57c3ca2414ff5e53d8f7f3f007d6a946fe

URL: https://github.com/llvm/llvm-project/commit/d24bce57c3ca2414ff5e53d8f7f3f007d6a946fe
DIFF: https://github.com/llvm/llvm-project/commit/d24bce57c3ca2414ff5e53d8f7f3f007d6a946fe.diff

LOG: Add a testcase for .dSYM path remapping dictionaries.

rdar://problem/56924558

Added: 
    lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Inputs/main.c
    lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Makefile
    lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Inputs/main.c b/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Inputs/main.c
new file mode 100644
index 000000000000..556bda3c17d1
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Inputs/main.c
@@ -0,0 +1,8 @@
+void stop() {}
+
+int main()
+{
+  stop();
+  // Hello World!
+  return 0;
+}

diff  --git a/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Makefile b/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Makefile
new file mode 100644
index 000000000000..f36a8dc1e671
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Makefile
@@ -0,0 +1,5 @@
+BOTDIR = $(BUILDDIR)/buildbot
+USERDIR = $(BUILDDIR)/user
+C_SOURCES = $(BOTDIR)/main.c
+
+include Makefile.rules

diff  --git a/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py b/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py
new file mode 100644
index 000000000000..d13a04748672
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py
@@ -0,0 +1,56 @@
+import lldb
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbtest as lldbtest
+import lldbsuite.test.lldbutil as lldbutil
+import os
+import unittest2
+
+
+class TestDSYMSourcePathRemapping(lldbtest.TestBase):
+
+    mydir = lldbtest.TestBase.compute_mydir(__file__)
+
+    def build(self):
+        botdir = self.getBuildArtifact('buildbot')
+        userdir = self.getBuildArtifact('user')
+        inputs = self.getSourcePath('Inputs')
+        lldbutil.mkdir_p(botdir)
+        lldbutil.mkdir_p(userdir)
+        import shutil
+        for f in ['main.c']:
+            shutil.copyfile(os.path.join(inputs, f), os.path.join(botdir, f))
+            shutil.copyfile(os.path.join(inputs, f), os.path.join(userdir, f))
+
+        super(TestDSYMSourcePathRemapping, self).build()
+
+        # Remove the build sources.
+        self.assertTrue(os.path.isdir(botdir))
+        shutil.rmtree(botdir)
+
+        # Create a plist.
+        import subprocess
+        dsym = self.getBuildArtifact('a.out.dSYM')
+        uuid = subprocess.check_output(["/usr/bin/dwarfdump", "--uuid", dsym]
+                                      ).decode("utf-8").split(" ")[1]
+        import re
+        self.assertTrue(re.match(r'[0-9a-fA-F-]+', uuid))
+        plist = os.path.join(dsym, 'Contents', 'Resources', uuid + '.plist')
+	with open(plist, 'w') as f:
+            f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
+            f.write('<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n')
+	    f.write('<plist version="1.0">\n')
+	    f.write('<dict>\n')
+	    f.write('  <key>DBGSourcePathRemapping</key>\n')
+	    f.write('  <dict>\n')
+	    f.write('	 <key>' + botdir + '</key>\n')
+	    f.write('	 <string>' + userdir + '</string>\n')
+	    f.write('  </dict>\n')
+	    f.write('</dict>\n')
+	    f.write('</plist>\n')
+
+
+    @skipIf(debug_info=no_match("dsym"))
+    def test(self):
+        self.build()
+        lldbutil.run_to_name_breakpoint(self, 'main')
+        self.expect("source list", substrs=["Hello World"])


        


More information about the lldb-commits mailing list