[Lldb-commits] [lldb] Allow option to ignore module load errors in ScriptedProcess (PR #127153)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Feb 13 17:20:48 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r ff79d83caeeea8457f69406f38801fe8893bbfd8...a4fdb2d54e76aefb771fe8ad8399494bb5fa8b70 lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- TestStackCoreScriptedProcess.py 2025-02-13 23:00:37.000000 +0000
+++ TestStackCoreScriptedProcess.py 2025-02-14 01:20:21.869706 +0000
@@ -76,11 +76,13 @@
)
self.assertTrue(corefile_process, PROCESS_IS_VALID)
# Create a random lib which does not exist in the corefile.
random_dylib = self.get_module_with_name(corefile_target, "random.dylib")
- self.assertFalse(random_dylib, "Dynamic library random.dylib should not be found.")
+ self.assertFalse(
+ random_dylib, "Dynamic library random.dylib should not be found."
+ )
structured_data = lldb.SBStructuredData()
structured_data.SetFromJSON(
json.dumps(
{
@@ -92,13 +94,13 @@
"path": self.getBuildArtifact("libbaz.dylib"),
},
{
"path": "/random/path/random.dylib",
"load_addr": 12345678,
- "ignore_module_load_error": True
- }
- ]
+ "ignore_module_load_error": True,
+ },
+ ],
}
)
)
launch_info = lldb.SBLaunchInfo(None)
launch_info.SetProcessPluginName("ScriptedProcess")
--- stack_core_scripted_process.py 2025-02-13 23:00:37.000000 +0000
+++ stack_core_scripted_process.py 2025-02-14 01:20:21.957178 +0000
@@ -49,35 +49,57 @@
custom_modules = args.GetValueForKey("custom_modules")
if custom_modules.GetType() == lldb.eStructuredDataTypeArray:
for id in range(custom_modules.GetSize()):
custom_module = custom_modules.GetItemAtIndex(id)
- if not custom_module or not custom_module.IsValid() or not custom_module.GetType() == lldb.eStructuredDataTypeDictionary:
+ if (
+ not custom_module
+ or not custom_module.IsValid()
+ or not custom_module.GetType() == lldb.eStructuredDataTypeDictionary
+ ):
continue
# Get custom module path from args
module_path_arg = custom_module.GetValueForKey("path")
module_path = None
- if not module_path_arg or not module_path_arg.IsValid() or not module_path_arg.GetType() == lldb.eStructuredDataTypeString:
+ if (
+ not module_path_arg
+ or not module_path_arg.IsValid()
+ or not module_path_arg.GetType() == lldb.eStructuredDataTypeString
+ ):
return
module_path = module_path_arg.GetStringValue(100)
module_name = os.path.basename(module_path)
# Get ignore_module_load_error boolean from args
ignore_module_load_error = False
- ignore_module_load_error_arg = custom_module.GetValueForKey("ignore_module_load_error")
- if ignore_module_load_error_arg and ignore_module_load_error_arg.IsValid() and ignore_module_load_error_arg.GetType() == lldb.eStructuredDataTypeBoolean:
- ignore_module_load_error = ignore_module_load_error_arg.GetBooleanValue()
+ ignore_module_load_error_arg = custom_module.GetValueForKey(
+ "ignore_module_load_error"
+ )
+ if (
+ ignore_module_load_error_arg
+ and ignore_module_load_error_arg.IsValid()
+ and ignore_module_load_error_arg.GetType()
+ == lldb.eStructuredDataTypeBoolean
+ ):
+ ignore_module_load_error = (
+ ignore_module_load_error_arg.GetBooleanValue()
+ )
if not os.path.exists(module_path) and not ignore_module_load_error:
return
# Get custom module load address from args
module_load_addr = None
module_load_addr_arg = custom_module.GetValueForKey("load_addr")
- if module_load_addr_arg and module_load_addr_arg.IsValid() and module_load_addr_arg.GetType() == lldb.eStructuredDataTypeInteger:
+ if (
+ module_load_addr_arg
+ and module_load_addr_arg.IsValid()
+ and module_load_addr_arg.GetType()
+ == lldb.eStructuredDataTypeInteger
+ ):
module_load_addr = module_load_addr_arg.GetIntegerValue()
# If module load address is not specified/valid, try to find it from corefile module
if module_load_addr is None:
corefile_module = self.get_module_with_name(
@@ -85,15 +107,23 @@
)
if not corefile_module or not corefile_module.IsValid():
return
- module_load_addr = corefile_module.GetObjectFileHeaderAddress().GetLoadAddress(
- self.corefile_target
- )
-
- self.loaded_images.append({"path": module_path, "load_addr": module_load_addr, "ignore_module_load_error": ignore_module_load_error})
+ module_load_addr = (
+ corefile_module.GetObjectFileHeaderAddress().GetLoadAddress(
+ self.corefile_target
+ )
+ )
+
+ self.loaded_images.append(
+ {
+ "path": module_path,
+ "load_addr": module_load_addr,
+ "ignore_module_load_error": ignore_module_load_error,
+ }
+ )
def get_memory_region_containing_address(
self, addr: int
) -> lldb.SBMemoryRegionInfo:
mem_region = lldb.SBMemoryRegionInfo()
``````````
</details>
https://github.com/llvm/llvm-project/pull/127153
More information about the lldb-commits
mailing list