-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose active and available platform lists via SBDebugger API
Summary: The available platform list was previously only accessible via the `platform list` command, this patch makes it possible to access that list via the SBDebugger API. The active platform list has likewise been exposed via the SBDebugger API. Differential Revision: https://reviews.llvm.org/D35760 llvm-svn: 310452
- Loading branch information
Showing
6 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
Test the lldb platform Python API. | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
|
||
import os | ||
import time | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class PlatformPythonTestCase(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
@add_test_categories(['pyapi']) | ||
@no_debug_info_test | ||
def test_platform_list(self): | ||
"""Test SBDebugger::GetNumPlatforms() & GetPlatformAtIndex() API""" | ||
# Verify there's only the host platform present by default. | ||
self.assertEqual(self.dbg.GetNumPlatforms(), 1) | ||
host_platform = self.dbg.GetPlatformAtIndex(0) | ||
self.assertTrue(host_platform.IsValid() and | ||
host_platform.GetName() == 'host', | ||
'Only the host platform is available') | ||
# Select another platform and verify that the platform is added to | ||
# the platform list. | ||
platform_idx = self.dbg.GetNumAvailablePlatforms() - 1 | ||
if platform_idx < 1: | ||
self.fail('No platforms other than host are available') | ||
platform_data = self.dbg.GetAvailablePlatformInfoAtIndex(platform_idx) | ||
platform_name = platform_data.GetValueForKey('name').GetStringValue(100) | ||
self.assertNotEqual(platform_name, 'host') | ||
self.dbg.SetCurrentPlatform(platform_name) | ||
selected_platform = self.dbg.GetSelectedPlatform() | ||
self.assertTrue(selected_platform.IsValid()) | ||
self.assertEqual(selected_platform.GetName(), platform_name) | ||
self.assertEqual(self.dbg.GetNumPlatforms(), 2) | ||
platform = self.dbg.GetPlatformAtIndex(1) | ||
self.assertEqual(platform.GetName(), platform_name) | ||
|
||
@add_test_categories(['pyapi']) | ||
@no_debug_info_test | ||
def test_available_platform_list(self): | ||
"""Test SBDebugger::GetNumAvailablePlatforms() and GetAvailablePlatformInfoAtIndex() API""" | ||
num_platforms = self.dbg.GetNumAvailablePlatforms() | ||
self.assertGreater( | ||
num_platforms, 0, | ||
'There should be at least one platform available') | ||
|
||
for i in range(num_platforms): | ||
platform_data = self.dbg.GetAvailablePlatformInfoAtIndex(i) | ||
name_data = platform_data.GetValueForKey('name') | ||
desc_data = platform_data.GetValueForKey('description') | ||
self.assertTrue( | ||
name_data and name_data.IsValid(), | ||
'Platform has a name') | ||
self.assertEqual( | ||
name_data.GetType(), lldb.eStructuredDataTypeString, | ||
'Platform name is a string') | ||
self.assertTrue( | ||
desc_data and desc_data.IsValid(), | ||
'Platform has a description') | ||
self.assertEqual( | ||
desc_data.GetType(), lldb.eStructuredDataTypeString, | ||
'Platform description is a string') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters