[Lldb-commits] [lldb] 15149e4 - Fix debugserver reporting of deployment target

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 8 17:21:55 PDT 2020


Author: Adrian Prantl
Date: 2020-07-08T17:21:43-07:00
New Revision: 15149e406486092a3665791545ab9474471c0f14

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

LOG: Fix debugserver reporting of deployment target

This patch fixes debugserver incorrectly returning the SDK version
instead of the minimum deployment target version.

rdar://problem/65001691

Differential Revision: https://reviews.llvm.org/D83443

Added: 
    

Modified: 
    lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
    lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index c12e920e3b82..6e67fdc879be 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -23,14 +23,43 @@ def check_load_commands(self, expected_load_command):
               found += 1
         self.assertEquals(found, 1, "wrong load command")
 
-
-    def run_with(self, arch, os, env, expected_load_command):
-        self.build(dictionary={'TRIPLE': arch+'-apple-'+os+'-'+env})
+    def check_debugserver(self, log, expected_platform, expected_version):
+        """scan the debugserver packet log"""
+        logfile = open(log, "r")
+        dylib_info = None
+        response = False
+        for line in logfile:
+            if response:
+                while line[0] != '$':
+                    line = line[1:]
+                line = line[1:]
+                # Unescape '}'.
+                dylib_info = json.loads(line.replace('}]','}')[:-4])
+                response = False
+            if 'send packet: $jGetLoadedDynamicLibrariesInfos:{' in line:
+                response = True
+
+        self.assertTrue(dylib_info)
+        aout_info = None
+        for image in dylib_info['images']:
+            if image['pathname'].endswith('a.out'):
+                aout_info = image
+        self.assertTrue(aout_info)
+        self.assertEquals(aout_info['min_version_os_name'], expected_platform)
+        if expected_version:
+            self.assertEquals(aout_info['min_version_os_sdk'], expected_version)
+
+
+    def run_with(self, arch, os, vers, env, expected_load_command):
+        self.build(dictionary={'TRIPLE': arch+'-apple-'+os+vers+'-'+env})
+        self.check_load_commands(expected_load_command)
+        log = self.getBuildArtifact('packets.log')
+        self.expect("log enable gdb-remote packets -f "+log)
         lldbutil.run_to_source_breakpoint(self, "break here",
                                           lldb.SBFileSpec("hello.c"))
-        self.check_load_commands(expected_load_command)
         self.expect('image list -b -t',
-                    patterns=['a\.out '+arch+'-apple-'+os+'.*-'+env])
+                    patterns=['a\.out '+arch+'-apple-'+os+vers+'.*-'+env])
+        self.check_debugserver(log, os+env, vers)
 
     @skipUnlessDarwin
     @skipIfDarwinEmbedded
@@ -38,7 +67,7 @@ def run_with(self, arch, os, env, expected_load_command):
     def test_ios(self):
         """Test running an iOS simulator binary"""
         self.run_with(arch=self.getArchitecture(),
-                      os='ios', env='simulator',
+                      os='ios', vers='', env='simulator',
                       expected_load_command='LC_BUILD_VERSION')
 
     @skipUnlessDarwin
@@ -47,7 +76,7 @@ def test_ios(self):
     def test_tvos(self):
         """Test running an tvOS simulator binary"""
         self.run_with(arch=self.getArchitecture(),
-                      os='tvos', env='simulator',
+                      os='tvos', vers='', env='simulator',
                       expected_load_command='LC_BUILD_VERSION')
 
     @skipUnlessDarwin
@@ -58,7 +87,7 @@ def test_tvos(self):
     def test_watchos_i386(self):
         """Test running a 32-bit watchOS simulator binary"""
         self.run_with(arch='i386',
-                      os='watchos', env='simulator',
+                      os='watchos', vers='', env='simulator',
                       expected_load_command='LC_BUILD_VERSION')
 
     @skipUnlessDarwin
@@ -69,7 +98,7 @@ def test_watchos_i386(self):
     def test_watchos_armv7k(self):
         """Test running a 32-bit watchOS simulator binary"""
         self.run_with(arch='armv7k',
-                      os='watchos', env='simulator',
+                      os='watchos', vers='', env='simulator',
                       expected_load_command='LC_BUILD_VERSION')
 
 
@@ -90,9 +119,20 @@ def test_lc_version_min_iphoneos(self):
         """Test running a back-deploying iOS simulator binary
            with a legacy iOS load command"""
         self.run_with(arch=self.getArchitecture(),
-                      os='ios11.0', env='simulator',
+                      os='ios', vers='11.0', env='simulator',
                       expected_load_command='LC_VERSION_MIN_IPHONEOS')
 
+    @skipUnlessDarwin
+    @skipIfDarwinEmbedded
+    @apple_simulator_test('iphone')
+    @skipIf(archs=['arm64','arm64e'])
+    def test_ios_backdeploy_x86(self):
+        """Test running a back-deploying iOS simulator binary
+           with a legacy iOS load command"""
+        self.run_with(arch=self.getArchitecture(),
+                      os='ios', vers='13.0', env='simulator',
+                      expected_load_command='LC_BUILD_VERSION')
+
     @skipUnlessDarwin
     @skipIfDarwinEmbedded
     @apple_simulator_test('iphone')
@@ -100,7 +140,7 @@ def test_lc_version_min_iphoneos(self):
     def test_ios_backdeploy_apple_silicon(self):
         """Test running a back-deploying iOS simulator binary"""
         self.run_with(arch=self.getArchitecture(),
-                      os='ios11.0', env='simulator',
+                      os='ios', vers='11.0', env='simulator',
                       expected_load_command='LC_BUILD_VERSION')
 
     @skipUnlessDarwin
@@ -111,7 +151,7 @@ def test_lc_version_min_tvos(self):
         """Test running a back-deploying tvOS simulator binary
            with a legacy tvOS load command"""
         self.run_with(arch=self.getArchitecture(),
-                      os='tvos11.0', env='simulator',
+                      os='tvos', vers='11.0', env='simulator',
                       expected_load_command='LC_VERSION_MIN_TVOS')
 
     @skipUnlessDarwin
@@ -121,7 +161,7 @@ def test_lc_version_min_tvos(self):
     def test_tvos_backdeploy_apple_silicon(self):
         """Test running a back-deploying tvOS simulator binary"""
         self.run_with(arch=self.getArchitecture(),
-                      os='tvos11.0', env='simulator',
+                      os='tvos', vers='11.0', env='simulator',
                       expected_load_command='LC_BUILD_VERSION')
 
     @skipUnlessDarwin
@@ -133,7 +173,7 @@ def test_lc_version_min_watchos(self):
         """Test running a back-deploying watchOS simulator binary
            with a legacy watchOS load command"""
         self.run_with(arch='i386',
-                      os='watchos4.0', env='simulator',
+                      os='watchos', vers='4.0', env='simulator',
                       expected_load_command='LC_VERSION_MIN_WATCHOS')
 
     @skipUnlessDarwin
@@ -144,5 +184,5 @@ def test_lc_version_min_watchos(self):
     def test_watchos_backdeploy_apple_silicon(self):
         """Test running a back-deploying watchOS simulator binary"""
         self.run_with(arch='armv7k',
-                      os='watchos4.0', env='simulator',
+                      os='watchos', vers='4.0', env='simulator',
                       expected_load_command='LC_BUILD_VERSION')

diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index d0001527f343..4bf5305cd67b 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -614,9 +614,9 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
                    &vers_cmd) != sizeof(struct version_min_command))
       return;
     info.platform = platform;
-    info.major_version = vers_cmd.sdk >> 16;
-    info.minor_version = (vers_cmd.sdk >> 8) & 0xffu;
-    info.patch_version = vers_cmd.sdk & 0xffu;
+    info.major_version = vers_cmd.version >> 16;
+    info.minor_version = (vers_cmd.version >> 8) & 0xffu;
+    info.patch_version = vers_cmd.version & 0xffu;
     info.maybe_simulator = true;
   };
   switch (cmd) {
@@ -639,9 +639,9 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
                    &build_vers) != sizeof(struct build_version_command))
       break;
     info.platform = build_vers.platform;
-    info.major_version = build_vers.sdk >> 16;
-    info.minor_version = (build_vers.sdk >> 8) & 0xffu;
-    info.patch_version = build_vers.sdk & 0xffu;
+    info.major_version = build_vers.minos >> 16;
+    info.minor_version = (build_vers.minos >> 8) & 0xffu;
+    info.patch_version = build_vers.minos & 0xffu;
     break;
   }
 #endif


        


More information about the lldb-commits mailing list