[Lldb-commits] [lldb] Add a new affordance that the Python module in a dSYM (PR #133290)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 27 11:16:27 PDT 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 960615954e4cb3150ae4a479fa7f9d0d17035eea...effad9525461611ed47598b53a77ee5aabb0e4cf lldb/test/API/macosx/dsym_modules/TestdSYMModuleInit.py lldb/test/API/macosx/dsym_modules/has_dsym.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- TestdSYMModuleInit.py 2025-03-27 18:04:26.000000 +0000
+++ TestdSYMModuleInit.py 2025-03-27 18:15:57.132143 +0000
@@ -8,61 +8,56 @@
import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
+
@skipUnlessDarwin
class TestdSYMModuleInit(TestBase):
-
@no_debug_info_test
def test_add_module(self):
"""This loads a file into a target and ensures that the python module was
- correctly added and the two intialization functions are called."""
+ correctly added and the two intialization functions are called."""
self.exe_name = "has_dsym"
- self.py_name = self.exe_name+".py"
+ self.py_name = self.exe_name + ".py"
# Now load the target the first time into the debugger:
self.runCmd("settings set target.load-script-from-symbol-file true")
self.interp = self.dbg.GetCommandInterpreter()
- executable = self.build_dsym(self.exe_name+"_1")
+ executable = self.build_dsym(self.exe_name + "_1")
target = self.createTestTarget(file_path=executable)
- self.check_answers(executable, ['1', '1', "has_dsym_1"])
+ self.check_answers(executable, ["1", "1", "has_dsym_1"])
# Now make a second target and make sure both get called:
- executable_2 = self.build_dsym(self.exe_name+"_2")
+ executable_2 = self.build_dsym(self.exe_name + "_2")
target_2 = self.createTestTarget(file_path=executable_2)
- self.check_answers(executable_2, ['2', '2', "has_dsym_2"])
-
+ self.check_answers(executable_2, ["2", "2", "has_dsym_2"])
+
def check_answers(self, name, answers):
result = lldb.SBCommandReturnObject()
self.interp.HandleCommand("report_command", result)
- self.assertTrue(result.Succeeded(), f"report_command succeeded {result.GetError()}")
+ self.assertTrue(
+ result.Succeeded(), f"report_command succeeded {result.GetError()}"
+ )
cmd_results = result.GetOutput().split()
self.assertEqual(answers[0], cmd_results[0], "Right number of module imports")
self.assertEqual(answers[1], cmd_results[1], "Right number of target notices")
self.assertIn(answers[2], name, "Right target name")
-
def build_dsym(self, name):
- self.build(debug_info="dsym", dictionary={"EXE" : name})
+ self.build(debug_info="dsym", dictionary={"EXE": name})
executable = self.getBuildArtifact(name)
- dsym_path = self.getBuildArtifact(name+".dSYM")
+ dsym_path = self.getBuildArtifact(name + ".dSYM")
python_dir_path = dsym_path
- python_dir_path = os.path.join(
- dsym_path, "Contents", "Resources", "Python"
- )
+ python_dir_path = os.path.join(dsym_path, "Contents", "Resources", "Python")
if not os.path.exists(python_dir_path):
os.mkdir(python_dir_path)
- python_file_name = name+".py"
-
- module_dest_path = os.path.join(
- python_dir_path, python_file_name
- )
+ python_file_name = name + ".py"
+
+ module_dest_path = os.path.join(python_dir_path, python_file_name)
module_origin_path = os.path.join(self.getSourceDir(), self.py_name)
shutil.copy(module_origin_path, module_dest_path)
return executable
-
-
--- has_dsym.py 2025-03-27 18:04:26.000000 +0000
+++ has_dsym.py 2025-03-27 18:15:57.144762 +0000
@@ -1,21 +1,28 @@
import lldb
+
def report_command(debugger, command, exe_ctx, result, internal_dict):
- result.AppendMessage(f"{lldb.num_module_inits} {lldb.num_target_inits} \"{lldb.target_name}\"")
+ result.AppendMessage(
+ f'{lldb.num_module_inits} {lldb.num_target_inits} "{lldb.target_name}"'
+ )
result.SetStatus(lldb.eReturnStatusSuccessFinishResult)
-
+
+
def __lldb_init_module(debugger, internal_dict):
# We only want to make one copy of the report command so it will be shared
if "has_dsym_1" in __name__:
# lldb is a convenient place to store our counters.
lldb.num_module_inits = 0
lldb.num_target_inits = 0
lldb.target_name = "<unknown>"
-
- debugger.HandleCommand(f"command script add -o -f '{__name__}.report_command' report_command")
+
+ debugger.HandleCommand(
+ f"command script add -o -f '{__name__}.report_command' report_command"
+ )
lldb.num_module_inits += 1
+
def __lldb_module_added_to_target(target, internal_dict):
lldb.num_target_inits += 1
target_name = target.executable.fullpath
``````````
</details>
https://github.com/llvm/llvm-project/pull/133290
More information about the lldb-commits
mailing list