0f5daf51e975e48921aad56d637636503d704c71
[openbsd] /
1 import lldb
2 from lldbsuite.test.decorators import *
3 import lldbsuite.test.lldbtest as lldbtest
4 import lldbsuite.test.lldbutil as lldbutil
5 import os
6 import unittest2
7
8
9 class TestDSYMSourcePathRemapping(lldbtest.TestBase):
10
11     mydir = lldbtest.TestBase.compute_mydir(__file__)
12
13     def build(self):
14         botdir = self.getBuildArtifact('buildbot')
15         userdir = self.getBuildArtifact('user')
16         inputs = self.getSourcePath('Inputs')
17         lldbutil.mkdir_p(botdir)
18         lldbutil.mkdir_p(userdir)
19         import shutil
20         for f in ['main.c', 'relative.c']:
21             shutil.copyfile(os.path.join(inputs, f), os.path.join(botdir, f))
22             shutil.copyfile(os.path.join(inputs, f), os.path.join(userdir, f))
23
24         super(TestDSYMSourcePathRemapping, self).build()
25
26         # Remove the build sources.
27         self.assertTrue(os.path.isdir(botdir))
28         shutil.rmtree(botdir)
29
30         # Create a plist.
31         import subprocess
32         dsym = self.getBuildArtifact('a.out.dSYM')
33         uuid = subprocess.check_output(["/usr/bin/dwarfdump", "--uuid", dsym]
34                                       ).decode("utf-8").split(" ")[1]
35         import re
36         self.assertTrue(re.match(r'[0-9a-fA-F-]+', uuid))
37         plist = os.path.join(dsym, 'Contents', 'Resources', uuid + '.plist')
38         with open(plist, 'w') as f:
39             f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
40             f.write('<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n')
41             f.write('<plist version="1.0">\n')
42             f.write('<dict>\n')
43             f.write('  <key>DBGSourcePathRemapping</key>\n')
44             f.write('  <dict>\n')
45             f.write('    <key>' + botdir + '</key>\n')
46             f.write('    <string>' + userdir + '</string>\n')
47             f.write('  </dict>\n')
48             f.write('</dict>\n')
49             f.write('</plist>\n')
50
51
52     @skipIf(debug_info=no_match("dsym"))
53     def test(self):
54         self.build()
55
56         target, process, _, _ = lldbutil.run_to_name_breakpoint(
57             self, 'main')
58         self.expect("source list -n main", substrs=["Hello Absolute"])
59         bkpt = target.BreakpointCreateByName('relative')
60         lldbutil.continue_to_breakpoint(process, bkpt)
61         self.expect("source list -n relative", substrs=["Hello Relative"])