From 2bbc4fdd8fa0ed58d610ab6260cb664c7cfef204 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 8 Nov 2019 14:05:45 -0800 Subject: [PATCH] Add a testcase for .dSYM path remapping dictionaries. rdar://problem/56924558 --- .../macosx/DBGSourcePathRemapping/Inputs/main.c | 8 ++++ .../test/macosx/DBGSourcePathRemapping/Makefile | 5 ++ .../TestDSYMSourcePathRemapping.py | 56 ++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Inputs/main.c create mode 100644 lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py 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 0000000..556bda3 --- /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 0000000..f36a8dc --- /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 0000000..d13a047 --- /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('\n') + f.write('\n') + f.write('\n') + f.write('\n') + f.write(' DBGSourcePathRemapping\n') + f.write(' \n') + f.write(' ' + botdir + '\n') + f.write(' ' + userdir + '\n') + f.write(' \n') + f.write('\n') + f.write('\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"]) -- 2.7.4