[libcxx-commits] [libcxx] [llvm] [libcxx][lldb] Add initial LLDB data-formatters (PR #187677)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 20 04:19:59 PDT 2026
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 origin/main...HEAD libcxx/utils/libcxx/test/features/lldb.py libcxx/utils/lldb/libcxx/libcxx.py libcxx/utils/lldb/libcxx/libcxx_map_formatter.py libcxx/utils/lldb/libcxx/libcxx_vector_formatter.py libcxx/utils/libcxx/test/features/__init__.py libcxx/utils/libcxx/test/features/misc.py
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- libcxx/test/features/__init__.py 2026-03-20 11:17:16.000000 +0000
+++ libcxx/test/features/__init__.py 2026-03-20 11:19:27.334960 +0000
@@ -4,11 +4,20 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# ===----------------------------------------------------------------------===##
-from . import availability, compiler, gdb, lldb, libcxx_macros, localization, misc, platform
+from . import (
+ availability,
+ compiler,
+ gdb,
+ lldb,
+ libcxx_macros,
+ localization,
+ misc,
+ platform,
+)
# Lit features are evaluated in order. Some features depend on other features, so
# we are careful to define them in the correct order. For example, several features
# require the compiler detection to have been performed.
DEFAULT_FEATURES = []
--- libcxx/test/features/lldb.py 2026-03-20 11:17:16.000000 +0000
+++ libcxx/test/features/lldb.py 2026-03-20 11:19:27.350394 +0000
@@ -11,18 +11,24 @@
import subprocess
# Detect whether LLDB is on the system and has Python scripting support.
# If so add a substitution to access it.
+
def check_lldb(cfg):
lldb_path = shutil.which("lldb")
if lldb_path is None:
return False
try:
stdout = subprocess.check_output(
- [lldb_path, "--batch", "-o", "script -l python -- print(\"Has\", \"Python\", \"!\")"],
+ [
+ lldb_path,
+ "--batch",
+ "-o",
+ 'script -l python -- print("Has", "Python", "!")',
+ ],
stderr=subprocess.DEVNULL,
universal_newlines=True,
)
except subprocess.CalledProcessError:
return False
--- libcxx/test/features/misc.py 2026-03-20 11:17:16.000000 +0000
+++ libcxx/test/features/misc.py 2026-03-20 11:19:27.407053 +0000
@@ -294,20 +294,19 @@
return 0;
}
""",
),
),
-
# Whether a `FileCheck` executable is available. Note that we intend not to depend
# on how that executable has been installed: we can either use the LLVM FileCheck
# executable or the `filecheck` Python port of the same utility.
Feature(
name="has-filecheck",
when=lambda cfg: runScriptExitCode(cfg, ["filecheck --version"]) == 0,
- actions=[AddSubstitution("%{filecheck}", "filecheck")]
+ actions=[AddSubstitution("%{filecheck}", "filecheck")],
),
Feature(
name="has-filecheck",
when=lambda cfg: runScriptExitCode(cfg, ["FileCheck --version"]) == 0,
- actions=[AddSubstitution("%{filecheck}", "FileCheck")]
+ actions=[AddSubstitution("%{filecheck}", "FileCheck")],
),
]
--- lldb/libcxx/libcxx.py 2026-03-20 11:17:16.000000 +0000
+++ lldb/libcxx/libcxx.py 2026-03-20 11:19:27.422798 +0000
@@ -1,17 +1,41 @@
import lldb
from libcxx_map_formatter import *
from libcxx_vector_formatter import *
+
def register_synthetic(debugger: lldb.SBDebugger, regex: str, class_name: str):
- debugger.HandleCommand(f'type synthetic add -x "{regex}" -l {__name__}.{class_name} -w "cplusplus-py"')
+ debugger.HandleCommand(
+ f'type synthetic add -x "{regex}" -l {__name__}.{class_name} -w "cplusplus-py"'
+ )
+
def __lldb_init_module(debugger, dict):
- register_synthetic(debugger, "^std::__[[:alnum:]]+::map<.+> >$", "LibcxxStdMapSyntheticProvider")
- register_synthetic(debugger, "^std::__[[:alnum:]]+::set<.+> >$", "LibcxxStdMapSyntheticProvider")
- register_synthetic(debugger, "^std::__[[:alnum:]]+::multiset<.+> >$", "LibcxxStdMapSyntheticProvider")
- register_synthetic(debugger, "^std::__[[:alnum:]]+::multimap<.+> >$", "LibcxxStdMapSyntheticProvider")
- register_synthetic(debugger, "^std::__[[:alnum:]]+::__map_(const_)?iterator<.+>$", "LibCxxMapIteratorSyntheticProvider")
- register_synthetic(debugger, "^std::__[[:alnum:]]+::vector<.+>$", "LibCxxStdVectorSyntheticFrontendCreator")
+ register_synthetic(
+ debugger, "^std::__[[:alnum:]]+::map<.+> >$", "LibcxxStdMapSyntheticProvider"
+ )
+ register_synthetic(
+ debugger, "^std::__[[:alnum:]]+::set<.+> >$", "LibcxxStdMapSyntheticProvider"
+ )
+ register_synthetic(
+ debugger,
+ "^std::__[[:alnum:]]+::multiset<.+> >$",
+ "LibcxxStdMapSyntheticProvider",
+ )
+ register_synthetic(
+ debugger,
+ "^std::__[[:alnum:]]+::multimap<.+> >$",
+ "LibcxxStdMapSyntheticProvider",
+ )
+ register_synthetic(
+ debugger,
+ "^std::__[[:alnum:]]+::__map_(const_)?iterator<.+>$",
+ "LibCxxMapIteratorSyntheticProvider",
+ )
+ register_synthetic(
+ debugger,
+ "^std::__[[:alnum:]]+::vector<.+>$",
+ "LibCxxStdVectorSyntheticFrontendCreator",
+ )
# Enables registered formatters in LLDB.
- debugger.HandleCommand('type category enable cplusplus-py')
+ debugger.HandleCommand("type category enable cplusplus-py")
``````````
</details>
https://github.com/llvm/llvm-project/pull/187677
More information about the libcxx-commits
mailing list