[Lldb-commits] [lldb] 6bf6c47 - Reland "[lldb] Improve completion tests (#65973)"

2023-09-12 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-09-12T08:40:43+01:00
New Revision: 6bf6c4762c355ce4f4fb976039375a2c8ff6038f

URL: 
https://github.com/llvm/llvm-project/commit/6bf6c4762c355ce4f4fb976039375a2c8ff6038f
DIFF: 
https://github.com/llvm/llvm-project/commit/6bf6c4762c355ce4f4fb976039375a2c8ff6038f.diff

LOG: Reland "[lldb] Improve completion tests (#65973)"

This reverts commit 8012518f600bebaa4ed99a57d553eeea25c2d0c9.

The x86 register write test had one that expected "\$rax" so on.
As these patterns were previously regex, the $ had to be escaped.
Now they are just plain strings to this is not needed.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/commands/expression/completion/TestExprCompletion.py
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..50e8ad08a9d8e89 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,12 +2223,15 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
-where patterns could be a pattern-string or a list of 
pattern-strings"""
+where patterns could be a single pattern-string or a list of
+pattern-strings.
+
+If there is only one pattern and it is exactly equal to str_input, this
+assumes that there should be no completions provided and that the 
result
+should be the same as the input."""
+
 # Patterns should not be None in order to proceed.
 self.assertFalse(patterns is None)
 # And should be either a string or list of strings.  Check for list 
type
@@ -2254,21 +2257,16 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the

diff  --git 
a/lldb/test/API/commands/expression/completion/TestExprCompletion.py 
b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index 3c354a3bce1a9b5..ada818989c789a1 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -29,34 +29,34 @@ def test_expr_completion(self):
 )
 
 # Completing member functions
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithMultipleArgs",
 "expr some_expr.FooWithMultipleArgsBar(",
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooUnderscore", "expr 
some_expr.FooUnderscoreBar_()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.StaticMemberMethod",
 "expr some_expr.StaticMemberMethodBar()",
 )
 
 # Completing static functions
-self.complete_exactly(
+self.complete_from_t

[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-12 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65979:

>From 251eaf5271db6ef9646f843ef037d54406544f8d Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 16:52:05 +
Subject: [PATCH] [lldb] Format more Python files with black

By running this from lldb/

$ black --exclude "third_party/|scripts/|utils/" ./
---
 lldb/bindings/python/createPythonInit.py  |   6 +-
 lldb/bindings/python/get-python-config.py |  21 +-
 lldb/docs/conf.py |   8 +-
 .../Python/lldbsuite/test/lldbtest.py |   5 +-
 .../test/tools/lldb-vscode/vscode.py  |   6 +-
 .../Interpreter/embedded_interpreter.py   |  26 ++-
 .../intel-mpx/test/TestMPXTable.py| 199 +++---
 lldb/use_lldb_suite_root.py   |   4 +-
 8 files changed, 164 insertions(+), 111 deletions(-)

diff --git a/lldb/bindings/python/createPythonInit.py 
b/lldb/bindings/python/createPythonInit.py
index 4ad7320675f45b2..f343832b949bafe 100644
--- a/lldb/bindings/python/createPythonInit.py
+++ b/lldb/bindings/python/createPythonInit.py
@@ -5,7 +5,7 @@
 pkgFiles = sys.argv[2:]
 
 getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
-importNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles)
+importNames = ", ".join('"{}"'.format(getFileName(f)) for f in pkgFiles)
 
 script = """__all__ = [{import_names}]
 for x in __all__:
@@ -18,7 +18,9 @@ def __lldb_init_module(debugger, internal_dict):
 lldb_init = getattr(submodule, '__lldb_init_module', None)
 if lldb_init:
   lldb_init(debugger, internal_dict)
-""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
+""".format(
+import_names=importNames, pkg_name=pkgRelDir.replace("/", ".")
+)
 
 pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
 with open(pkgIniFile, "w") as f:
diff --git a/lldb/bindings/python/get-python-config.py 
b/lldb/bindings/python/get-python-config.py
index 6369e32a49168c7..ae84cbb1215a9e3 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -10,10 +10,11 @@ def relpath_nodots(path, base):
 rel = os.path.normpath(os.path.relpath(path, base))
 assert not os.path.isabs(rel)
 parts = rel.split(os.path.sep)
-if parts and parts[0] == '..':
+if parts and parts[0] == "..":
 raise ValueError(f"{path} is not under {base}")
 return rel
 
+
 def main():
 parser = argparse.ArgumentParser(description="extract cmake variables from 
python")
 parser.add_argument("variable_name")
@@ -35,10 +36,10 @@ def main():
 except ValueError:
 # Try to fall back to something reasonable if sysconfig's platlib
 # is outside of sys.prefix
-if os.name == 'posix':
-print('lib/python%d.%d/site-packages' % sys.version_info[:2])
-elif os.name == 'nt':
-print('Lib\\site-packages')
+if os.name == "posix":
+print("lib/python%d.%d/site-packages" % sys.version_info[:2])
+elif os.name == "nt":
+print("Lib\\site-packages")
 else:
 raise
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
@@ -57,16 +58,20 @@ def main():
 exe = os.path.realpath(exe)
 continue
 else:
-print("Could not find a relative path to sys.executable 
under sys.prefix", file=sys.stderr)
+print(
+"Could not find a relative path to sys.executable 
under sys.prefix",
+file=sys.stderr,
+)
 for e in tried:
 print("tried:", e, file=sys.stderr)
 print("realpath(sys.prefix):", prefix, file=sys.stderr)
 print("sys.prefix:", sys.prefix, file=sys.stderr)
 sys.exit(1)
 elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
-print(sysconfig.get_config_var('EXT_SUFFIX'))
+print(sysconfig.get_config_var("EXT_SUFFIX"))
 else:
 parser.error(f"unknown variable {args.variable_name}")
 
-if __name__ == '__main__':
+
+if __name__ == "__main__":
 main()
diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index 730a8608b5ba44f..ec7f93710ab6f20 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -42,9 +42,7 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ["sphinx.ext.todo", "sphinx.ext.mathjax", 
"sphinx.ext.intersphinx"]
 
-autodoc_default_options = {
-"special-members": True
-}
+autodoc_default_options = {"special-members": True}
 
 # Unless we only generate the basic manpage we need the plugin for generating
 # the Python API documentation.
@@ -60,9 +58,7 @@
 try:
 import furo
 except ModuleNotFoundError:
-print(
-f"install sphinx fu

[Lldb-commits] [lldb] c8387a3 - [lldb] Format more Python files with black (#65979)

2023-09-12 Thread via lldb-commits

Author: David Spickett
Date: 2023-09-12T08:46:34+01:00
New Revision: c8387a31a4adfa9c29a578cf67321f756d3b4ac1

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

LOG: [lldb] Format more Python files with black (#65979)

By running this from lldb/

$ black --exclude "third_party/|scripts/|utils/" ./

Added: 


Modified: 
lldb/bindings/python/createPythonInit.py
lldb/bindings/python/get-python-config.py
lldb/docs/conf.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/source/Interpreter/embedded_interpreter.py
lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py
lldb/use_lldb_suite_root.py

Removed: 




diff  --git a/lldb/bindings/python/createPythonInit.py 
b/lldb/bindings/python/createPythonInit.py
index 4ad7320675f45b2..f343832b949bafe 100644
--- a/lldb/bindings/python/createPythonInit.py
+++ b/lldb/bindings/python/createPythonInit.py
@@ -5,7 +5,7 @@
 pkgFiles = sys.argv[2:]
 
 getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
-importNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles)
+importNames = ", ".join('"{}"'.format(getFileName(f)) for f in pkgFiles)
 
 script = """__all__ = [{import_names}]
 for x in __all__:
@@ -18,7 +18,9 @@ def __lldb_init_module(debugger, internal_dict):
 lldb_init = getattr(submodule, '__lldb_init_module', None)
 if lldb_init:
   lldb_init(debugger, internal_dict)
-""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
+""".format(
+import_names=importNames, pkg_name=pkgRelDir.replace("/", ".")
+)
 
 pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
 with open(pkgIniFile, "w") as f:

diff  --git a/lldb/bindings/python/get-python-config.py 
b/lldb/bindings/python/get-python-config.py
index 6369e32a49168c7..ae84cbb1215a9e3 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -10,10 +10,11 @@ def relpath_nodots(path, base):
 rel = os.path.normpath(os.path.relpath(path, base))
 assert not os.path.isabs(rel)
 parts = rel.split(os.path.sep)
-if parts and parts[0] == '..':
+if parts and parts[0] == "..":
 raise ValueError(f"{path} is not under {base}")
 return rel
 
+
 def main():
 parser = argparse.ArgumentParser(description="extract cmake variables from 
python")
 parser.add_argument("variable_name")
@@ -35,10 +36,10 @@ def main():
 except ValueError:
 # Try to fall back to something reasonable if sysconfig's platlib
 # is outside of sys.prefix
-if os.name == 'posix':
-print('lib/python%d.%d/site-packages' % sys.version_info[:2])
-elif os.name == 'nt':
-print('Lib\\site-packages')
+if os.name == "posix":
+print("lib/python%d.%d/site-packages" % sys.version_info[:2])
+elif os.name == "nt":
+print("Lib\\site-packages")
 else:
 raise
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
@@ -57,16 +58,20 @@ def main():
 exe = os.path.realpath(exe)
 continue
 else:
-print("Could not find a relative path to sys.executable 
under sys.prefix", file=sys.stderr)
+print(
+"Could not find a relative path to sys.executable 
under sys.prefix",
+file=sys.stderr,
+)
 for e in tried:
 print("tried:", e, file=sys.stderr)
 print("realpath(sys.prefix):", prefix, file=sys.stderr)
 print("sys.prefix:", sys.prefix, file=sys.stderr)
 sys.exit(1)
 elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
-print(sysconfig.get_config_var('EXT_SUFFIX'))
+print(sysconfig.get_config_var("EXT_SUFFIX"))
 else:
 parser.error(f"unknown variable {args.variable_name}")
 
-if __name__ == '__main__':
+
+if __name__ == "__main__":
 main()

diff  --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index 730a8608b5ba44f..ec7f93710ab6f20 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -42,9 +42,7 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ["sphinx.ext.todo", "sphinx.ext.mathjax", 
"sphinx.ext.intersphinx"]
 
-autodoc_default_options = {
-"special-members": True
-}
+autodoc_default_options = {"special-members": True}
 
 # Unless we only generate the basic manpage we need the plugin for generating
 # the Python API documentation.
@@ -60,9 +58,7 @@
 try:
 import furo
 except ModuleNotFou

[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-12 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/65979
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format Python files in scripts and utils (PR #66053)

2023-09-12 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett review_requested 
https://github.com/llvm/llvm-project/pull/66053
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format Python files in scripts and utils (PR #66053)

2023-09-12 Thread via lldb-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66053
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format Python files in scripts and utils (PR #66053)

2023-09-12 Thread via lldb-commits

llvmbot wrote:

@llvm/pr-subscribers-lldb


Changes

Using:
black --exclude "third_party/" ./lldb/
--

Patch is 108.25 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66053.diff

17 Files Affected:

- (modified) lldb/scripts/analyze-project-deps.py (+42-24) 
- (modified) lldb/scripts/android/host_art_bt.py (+146-83) 
- (modified) lldb/scripts/install_custom_python.py (+72-74) 
- (modified) lldb/scripts/reproducer-replay.py (+50-48) 
- (modified) lldb/scripts/use_lldb_suite.py (+3-1) 
- (modified) lldb/scripts/verify_api.py (+57-42) 
- (modified) lldb/utils/lldb-repro/lldb-repro.py (+17-13) 
- (modified) lldb/utils/lui/breakwin.py (+7-7) 
- (modified) lldb/utils/lui/commandwin.py (+16-19) 
- (modified) lldb/utils/lui/cui.py (+25-30) 
- (modified) lldb/utils/lui/debuggerdriver.py (+40-36) 
- (modified) lldb/utils/lui/eventwin.py (+1-2) 
- (modified) lldb/utils/lui/lldbutil.py (+204-168) 
- (modified) lldb/utils/lui/lui.py (+25-29) 
- (modified) lldb/utils/lui/sandbox.py (+6-6) 
- (modified) lldb/utils/lui/sourcewin.py (+37-25) 
- (modified) lldb/utils/lui/statuswin.py (+6-6) 



diff --git a/lldb/scripts/analyze-project-deps.py 
b/lldb/scripts/analyze-project-deps.py
index 89da3dc9df7b3c6..4724367e2e722d0 100755
--- a/lldb/scripts/analyze-project-deps.py
+++ b/lldb/scripts/analyze-project-deps.py
@@ -10,12 +10,21 @@
 from use_lldb_suite import lldb_root
 
 parser = argparse.ArgumentParser(
-description='Analyze LLDB project #include dependencies.')
-parser.add_argument('--show-counts', default=False, action='store_true', 
-help='When true, show the number of dependencies from each subproject')
-parser.add_argument('--discover-cycles', default=False, action='store_true',
-help='When true, find and display all project dependency cycles.  Note,'
- 'this option is very slow')
+description="Analyze LLDB project #include dependencies."
+)
+parser.add_argument(
+"--show-counts",
+default=False,
+action="store_true",
+help="When true, show the number of dependencies from each subproject",
+)
+parser.add_argument(
+"--discover-cycles",
+default=False,
+action="store_true",
+help="When true, find and display all project dependency cycles.  Note,"
+"this option is very slow",
+)
 
 args = parser.parse_args()
 
@@ -24,12 +33,14 @@
 
 src_map = {}
 
-include_regex = re.compile('#include \"((lldb|Plugins|clang)(.*/)+).*\"')
+include_regex = re.compile('#include "((lldb|Plugins|clang)(.*/)+).*"')
+
 
 def is_sublist(small, big):
 it = iter(big)
 return all(c in it for c in small)
 
+
 def normalize_host(str):
 if str.startswith("lldb/Host"):
 return "lldb/Host"
@@ -39,6 +50,7 @@ def normalize_host(str):
 return str.replace("lldb/../../source", "lldb")
 return str
 
+
 def scan_deps(this_dir, file):
 global src_map
 deps = {}
@@ -62,7 +74,8 @@ def scan_deps(this_dir, file):
 if this_dir not in src_map and len(deps) > 0:
 src_map[this_dir] = deps
 
-for (base, dirs, files) in os.walk(inc_dir):
+
+for base, dirs, files in os.walk(inc_dir):
 dir = os.path.basename(base)
 relative = os.path.relpath(base, inc_dir)
 inc_files = [x for x in files if os.path.splitext(x)[1] in [".h"]]
@@ -71,7 +84,7 @@ def scan_deps(this_dir, file):
 inc_path = os.path.join(base, inc)
 scan_deps(relative, inc_path)
 
-for (base, dirs, files) in os.walk(src_dir):
+for base, dirs, files in os.walk(src_dir):
 dir = os.path.basename(base)
 relative = os.path.relpath(base, src_dir)
 src_files = [x for x in files if os.path.splitext(x)[1] in [".cpp", ".h", 
".mm"]]
@@ -82,6 +95,7 @@ def scan_deps(this_dir, file):
 scan_deps(norm_base_path, src_path)
 pass
 
+
 def is_existing_cycle(path, cycles):
 # If we have a cycle like # A -> B -> C (with an implicit -> A at the end)
 # then we don't just want to check for an occurrence of A -> B -> C in the
@@ -90,12 +104,13 @@ def is_existing_cycle(path, cycles):
 # at the end), then A -> B -> C is also a cycle.  This is an important
 # optimization which reduces the search space by multiple orders of
 # magnitude.
-for i in range(0,len(path)):
+for i in range(0, len(path)):
 if any(is_sublist(x, path) for x in cycles):
 return True
 path = [path[-1]] + path[0:-1]
 return False
 
+
 def expand(path_queue, path_lengths, cycles, src_map):
 # We do a breadth first search, to make sure we visit all paths in order
 # of ascending length.  This is an important optimization to make sure that
@@ -127,54 +142,57 @@ def expand(path_queue, path_lengths, cycles, src_map):
 path_queue.append(cur_path + [item])
 pass
 
+
 cycles = []
 
 path_queue = [[x] for x in iter(src_map)]
 path_lens = [1] * len(path_queue)
 
 items = list(src_map.items())
-items.sort(key = lambda A : A[0])
+items.sort(key=lambda A: A[0])
 
-for (path, deps) in items:
+f

[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread David Spickett via lldb-commits


@@ -2462,6 +2483,93 @@ class CommandObjectTargetModulesDumpLineTable
   CommandOptions m_options;
 };
 
+#pragma mark CommandObjectTargetModulesDumpSeparateDebugInfoFiles
+
+// Image debug dwo dumping command
+
+class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
+: public CommandObjectTargetModulesModuleAutoComplete {
+public:
+  CommandObjectTargetModulesDumpSeparateDebugInfoFiles(
+  CommandInterpreter &interpreter)
+  : CommandObjectTargetModulesModuleAutoComplete(
+interpreter, "target modules dump separate-debug-info",
+"Dump the separate debug info symbol files for one or more target "

DavidSpickett wrote:

This is minor but "Dump the details of separate debug info" is more 
accurate. As it is it could be taken for dumping the files themselves like 
llvm-dwarfdump would.

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread David Spickett via lldb-commits


@@ -2005,9 +2021,10 @@ class CommandObjectTargetModulesDumpSymtab
 result.GetOutputStream().EOL();
 result.GetOutputStream().EOL();
   }
-  if (INTERRUPT_REQUESTED(GetDebugger(), 
+  if (INTERRUPT_REQUESTED(GetDebugger(),

DavidSpickett wrote:

Seems like you formatted the whole file, which is a good idea in general but 
not within the same commit as "real" changes. You could push a commit 
formatting it if you like.

You can use the script 
https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting to 
format just the bits you've changed.

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread David Spickett via lldb-commits


@@ -282,6 +283,10 @@ class SymbolFileDWARF : public 
lldb_private::SymbolFileCommon {
 
   void DumpClangAST(lldb_private::Stream &s) override;
 
+  /// Retrieve the external dwo files.

DavidSpickett wrote:

"external dwo file details." ?

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread David Spickett via lldb-commits


@@ -2462,6 +2483,93 @@ class CommandObjectTargetModulesDumpLineTable
   CommandOptions m_options;
 };
 
+#pragma mark CommandObjectTargetModulesDumpSeparateDebugInfoFiles
+
+// Image debug dwo dumping command
+
+class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
+: public CommandObjectTargetModulesModuleAutoComplete {
+public:
+  CommandObjectTargetModulesDumpSeparateDebugInfoFiles(
+  CommandInterpreter &interpreter)
+  : CommandObjectTargetModulesModuleAutoComplete(
+interpreter, "target modules dump separate-debug-info",
+"Dump the separate debug info symbol files for one or more target "
+"modules.",
+//"target modules dump separate-debug-info [ ...]")
+nullptr, eCommandRequiresTarget) {}
+
+  ~CommandObjectTargetModulesDumpSeparateDebugInfoFiles() override = default;
+
+protected:
+  bool DoExecute(Args &command, CommandReturnObject &result) override {
+Target &target = GetSelectedTarget();
+uint32_t num_dumped = 0;
+
+uint32_t addr_byte_size = target.GetArchitecture().GetAddressByteSize();
+result.GetOutputStream().SetAddressByteSize(addr_byte_size);
+result.GetErrorStream().SetAddressByteSize(addr_byte_size);
+
+StructuredData::Array separate_debug_info_files;
+if (command.GetArgumentCount() == 0) {
+  // Dump all sections for all modules images
+  const ModuleList &target_modules = target.GetImages();
+  std::lock_guard guard(target_modules.GetMutex());
+  const size_t num_modules = target_modules.GetSize();
+  if (num_modules == 0) {
+result.AppendError("the target has no associated executable images");
+return false;
+  }
+  for (ModuleSP module_sp : target_modules.ModulesNoLocking()) {
+if (INTERRUPT_REQUESTED(
+GetDebugger(),
+"Interrupted in dumping all "
+"separate debug info with {0} of {1} modules dumped",
+num_dumped, num_modules))
+  break;
+
+if (DumpModuleSeparateDebugInfoFiles(separate_debug_info_files,
+ module_sp.get()))
+  num_dumped++;
+  }
+} else {
+  // Dump specified images (by basename or fullpath)
+  const char *arg_cstr;
+  for (int arg_idx = 0;
+   (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr;
+   ++arg_idx) {
+ModuleList module_list;
+const size_t num_matches =
+FindModulesByName(&target, arg_cstr, module_list, true);
+if (num_matches > 0) {
+  for (size_t i = 0; i < num_matches; ++i) {
+if (INTERRUPT_REQUESTED(GetDebugger(),
+"Interrupted dumping {0} "
+"of {1} requested modules",
+i, num_matches))
+  break;
+Module *module = module_list.GetModulePointerAtIndex(i);
+if (DumpModuleSeparateDebugInfoFiles(separate_debug_info_files,
+ module))
+  num_dumped++;
+  }
+} else
+  result.AppendWarningWithFormat(
+  "Unable to find an image that matches '%s'.\n", arg_cstr);
+  }
+}
+
+if (num_dumped > 0) {
+  separate_debug_info_files.Dump(result.GetOutputStream(),
+ /* pretty_print */ true);

DavidSpickett wrote:

`/*pretty_print=*/` in case someone runs 
https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html 
against this, and it's generally the style in lldb.

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread David Spickett via lldb-commits


@@ -4214,6 +4216,62 @@ void SymbolFileDWARF::DumpClangAST(Stream &s) {
   clang->Dump(s.AsRawOstream());
 }
 
+bool SymbolFileDWARF::GetSeparateDebugInfoFiles(StructuredData::Array &array) {
+  DWARFDebugInfo &info = DebugInfo();
+  const size_t num_cus = info.GetNumUnits();
+  for (size_t cu_idx = 0; cu_idx < num_cus; cu_idx++) {
+DWARFUnit *unit = info.GetUnitAtIndex(cu_idx);
+DWARFCompileUnit *dwarf_cu = llvm::dyn_cast(unit);
+if (dwarf_cu == nullptr) {
+  continue;
+}

DavidSpickett wrote:

lldb prefers to drop the `{}` if there's just one line
```
if (dwarf_cu == nullptr)
  continue;
```

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread David Spickett via lldb-commits


@@ -2462,6 +2483,93 @@ class CommandObjectTargetModulesDumpLineTable
   CommandOptions m_options;
 };
 
+#pragma mark CommandObjectTargetModulesDumpSeparateDebugInfoFiles
+
+// Image debug dwo dumping command
+
+class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
+: public CommandObjectTargetModulesModuleAutoComplete {
+public:
+  CommandObjectTargetModulesDumpSeparateDebugInfoFiles(
+  CommandInterpreter &interpreter)
+  : CommandObjectTargetModulesModuleAutoComplete(
+interpreter, "target modules dump separate-debug-info",
+"Dump the separate debug info symbol files for one or more target "
+"modules.",
+//"target modules dump separate-debug-info [ ...]")

DavidSpickett wrote:

This is commented out why?

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread David Spickett via lldb-commits

DavidSpickett wrote:

FYI I committed https://reviews.llvm.org/D157609 recently. Looks like your test 
cases are pretty straightforward but just in case you are confused why lldb 
manages to find a file when it didn't previously.

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157883: [lldb][AArch64] Add SME's Array Storage (ZA) and streaming vector length (SVG) registers

2023-09-12 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid requested changes to this revision.
omjavaid added a comment.
This revision now requires changes to proceed.

The patch looks to implement all stuff needed at once lets break it down into 
three patches instead:

1. First patch that just adds SME register set and does not implement 
RegisterContext Read/Write routines.
2. Implement register context read/write for SME registers
3. Implement size re-configuration after changing size of the SME vector.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157883/new/

https://reviews.llvm.org/D157883

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157846: [lldb][AArch64] Add SME's SVE register state to TestArm64DynamicRegsets

2023-09-12 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

Can you add more description to this patch. at the moment reading it without 
SME context in mind does not provide enough information to figure out what we 
are doing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157846/new/

https://reviews.llvm.org/D157846

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157846: [lldb][AArch64] Add SME's SVE register state to TestArm64DynamicRegsets

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556541.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157846/new/

https://reviews.llvm.org/D157846

Files:
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c


Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
@@ -1,5 +1,9 @@
 #include 
 
+#ifndef HWCAP2_SME
+#define HWCAP2_SME (1 << 23)
+#endif
+
 void set_sve_registers() {
   // AArch64 SVE extension ISA adds a new set of vector and predicate 
registers:
   // 32 Z registers, 16 P registers, and 1 FFR register.
@@ -64,8 +68,14 @@
   asm volatile("cpy  z31.b, p15/z, #32\n\t");
 }
 
-int main() {
-  if (getauxval(AT_HWCAP) & HWCAP_SVE) // check if SVE is present
+int main(int argc, char *argv[]) {
+  if (argc > 1) {
+// Enable streaming mode SVE and the ZA array storage.
+asm volatile("msr  s0_3_c4_c7_3, xzr" /*smstart*/);
+  }
+
+  // If we have SVE or SME, set the SVE registers.
+  if ((getauxval(AT_HWCAP) & HWCAP_SVE) || (getauxval(AT_HWCAP2) & HWCAP2_SME))
 set_sve_registers();
 
   return 0; // Set a break point here.
Index: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
===
--- 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
+++ 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
@@ -120,3 +120,42 @@
 )
 self.expect("register read data_mask", substrs=["data_mask = 
0x"])
 self.expect("register read code_mask", substrs=["code_mask = 
0x"])
+
+@no_debug_info_test
+@skipIf(archs=no_match(["aarch64"]))
+@skipIf(oslist=no_match(["linux"]))
+def test_aarch64_dynamic_regset_config_sme(self):
+"""Test AArch64 Dynamic Register sets configuration, but only SME
+   registers."""
+if not self.isAArch64SME():
+self.skipTest("SME must be present.")
+
+self.build()
+self.line = line_number("main.c", "// Set a break point here.")
+
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line, num_expected_locations=1
+)
+self.runCmd("settings set target.run-args sme")
+self.runCmd("run", RUN_SUCCEEDED)
+
+self.expect(
+"thread backtrace",
+STOPPED_DUE_TO_BREAKPOINT,
+substrs=["stop reason = breakpoint 1."],
+)
+
+target = self.dbg.GetSelectedTarget()
+process = target.GetProcess()
+thread = process.GetThreadAtIndex(0)
+currentFrame = thread.GetFrameAtIndex(0)
+
+register_sets = currentFrame.GetRegisters()
+
+ssve_registers = register_sets.GetFirstValueByName(
+"Scalable Vector Extension Registers")
+self.assertTrue(ssve_registers.IsValid())
+self.sve_regs_read_dynamic(ssve_registers)


Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
@@ -1,5 +1,9 @@
 #include 
 
+#ifndef HWCAP2_SME
+#define HWCAP2_SME (1 << 23)
+#endif
+
 void set_sve_registers() {
   // AArch64 SVE extension ISA adds a new set of vector and predicate registers:
   // 32 Z registers, 16 P registers, and 1 FFR register.
@@ -64,8 +68,14 @@
   asm volatile("cpy  z31.b, p15/z, #32\n\t");
 }
 
-int main() {
-  if (getauxval(AT_HWCAP) & HWCAP_SVE) // check if SVE is present
+int main(int argc, char *argv[]) {
+  if (argc > 1) {
+// Enable streaming mode SVE and the ZA array storage.
+asm volatile("msr  s0_3_c4_c7_3, xzr" /*smstart*/);
+  }
+
+  // If we have SVE or SME, set the SVE registers.
+  if ((getauxval(AT_HWCAP) & HWCAP_SVE) || (getauxval(AT_HWCAP2) & HWCAP2_SME))
 set_sve_registers();
 
   return 0; // Set a break point here.
Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
@@ -120,3 +120,42 @@
 )
 self.expect("register read da

[Lldb-commits] [PATCH] D157846: [lldb][AArch64] Add SME's tests for SVE register state to TestArm64DynamicRegsets

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Did my best to update the commit message.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157846/new/

https://reviews.llvm.org/D157846

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D159502: [lldb][AArch64] Add SME's Array Storage (ZA) register

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: ctetreau, kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added subscribers: lldb-commits, alextsao1999.
Herald added a project: LLDB.

Note: This requires later commits for ZA to function properly,
it is split for ease of review. Testing is also in a later patch.

The "Matrix" part of the Scalable Matrix Extension is a new register
"ZA". You can think of this as a square matrix made up of scalable rows,
where each row is one scalable vector long. However it is not made
of the existing scalable vector registers, it is its own register.
Meaning that the size of ZA is the vector length in bytes * the vector
length in bytes.

https://developer.arm.com/documentation/ddi0616/latest/

It uses the streaming vector length, even when streaming mode itself
is not active. For this reason, it's register data header always
includes the streaming vector length.

Due to it's size I've changed kMaxRegisterByteSize to the maximum
possible ZA size and kTypicalRegisterByteSize will be the maximum
possible scalable vector size. Therefore ZA transactions will cause heap
allocations, and non ZA registers will perform exactly as before.

ZA can be enabled and disabled independently of streaming mode. The way
this works in ptrace is different to SVE versus streaming SVE. Writing
NT_ARM_ZA without register data disables ZA, writing NT_ARM_ZA with
register data enables ZA (LLDB will only support the latter, and only
because it's convenient for us to do so).

https://kernel.org/doc/html/v6.2/arm64/sme.html

LLDB does not handle registers that can appear and dissappear at
runtime. Rather than add complexity to implement that, LLDB will
show a block of 0s when ZA is disabled.

The alternative is not only updating the vector lengths every stop,
but every register definition. It's possible but I'm not sure it's worth
pursuing.

Users should refer to the SVCR register (added in later patches)
for the final word on whether ZA is active or not.

Writing to "VG" during streaming mode will change the size of the
streaming sve registers and ZA. LLDB will not attempt to preserve
register values in this case, we'll just read back the undefined
content the kernel shows. This is in line with, as stated, the
kernel ABIs and the prospective software ABIs look like.

ZA is defined as a vector of size SVL*SVL, so the display in lldb
is very basic. A giant block of values. This is no worse than SVE,
just larger. There is scope to improve this but that can wait
until we see some use cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159502

Files:
  lldb/include/lldb/Utility/RegisterValue.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h

Index: lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -119,6 +119,10 @@
 {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_SVE},
 };
 
+constexpr RegsetDesc AARCH64_ZA_Desc[] = {
+{llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_ZA},
+};
+
 constexpr RegsetDesc AARCH64_PAC_Desc[] = {
 {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_PAC_MASK},
 };
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -30,6 +30,7 @@
 eRegsetMaskPAuth = 4,
 eRegsetMaskMTE = 8,
 eRegsetMaskTLS = 16,
+eRegsetMaskZA = 32,
 eRegsetMaskDynamic = ~1,
   };
 
@@ -106,8 +107,12 @@
 
   void AddRegSetTLS(bool has_tpidr2);
 
+  void AddRegSetZA();
+
   uint32_t ConfigureVectorLength(uint32_t sve_vq);
 
+  void ConfigureVectorLengthZA(uint32_t za_vq);
+
   bool VectorSizeIsValid(uint32_t vq) {
 // coverity[unsigned_compare]
 if (vq >= eVectorQuadwordAArch64 && vq <= eVectorQuadwordAArch64SVEMax)
@@ -117,6 +122,7 @@
 
   bool IsSVEEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskSVE); }
   bool IsSSVEEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskSSVE); }
+  bool IsZAEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskZA); }
   bool IsPAuthEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskPAuth); }
   bool IsMTE

[Lldb-commits] [PATCH] D159503: [lldb][AArch64] Add SME streaming vector length pseduo register

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: sunshaoce, ctetreau, kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This adds a register "svg" which mirrors SVE's "vg" register.
This reports the streaming vector length at all times, read
from the ZA ptrace header.

This register is needed first to implement ZA resizing as
the streaming vector length changes. Like vg, svg will be
expedited to the client so it can reconfigure its register
definitions.

The other use is for users to be able to know the streaming
vector length without resorting to counting the (many, many)
bytes in ZA, or temporarily entering streaming mode (which
would be destructive).

Testing for this will come in a later patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159503

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h

Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -109,6 +109,8 @@
 
   void AddRegSetZA();
 
+  void AddRegSetSME();
+
   uint32_t ConfigureVectorLength(uint32_t sve_vq);
 
   void ConfigureVectorLengthZA(uint32_t za_vq);
@@ -147,6 +149,7 @@
   uint32_t GetMTEOffset() const;
   uint32_t GetTLSOffset() const;
   uint32_t GetZAOffset() const;
+  uint32_t GetSMEOffset() const;
 
 private:
   typedef std::map>
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -88,6 +88,9 @@
 {{"za", nullptr, 16, 0, lldb::eEncodingVector, lldb::eFormatVectorOfUInt8,
   KIND_ALL_INVALID, nullptr, nullptr, nullptr}};
 
+static lldb_private::RegisterInfo g_register_infos_sme[] = {
+DEFINE_EXTENSION_REG(svg)};
+
 // Number of register sets provided by this context.
 enum {
   k_num_gpr_registers = gpr_w28 - gpr_x0 + 1,
@@ -255,8 +258,10 @@
   // present.
   AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE));
 
-  if (m_opt_regsets.AnySet(eRegsetMaskSSVE))
+  if (m_opt_regsets.AnySet(eRegsetMaskSSVE)) {
 AddRegSetZA();
+AddRegSetSME();
+  }
 
   m_register_info_count = m_dynamic_reg_infos.size();
   m_register_info_p = m_dynamic_reg_infos.data();
@@ -377,6 +382,24 @@
   m_dynamic_reg_sets.back().registers = m_za_regnum_collection.data();
 }
 
+void RegisterInfoPOSIX_arm64::AddRegSetSME() {
+  uint32_t sme_regnum = m_dynamic_reg_infos.size();
+  for (uint32_t i = 0; i < k_num_sme_register; i++) {
+m_sme_regnum_collection.push_back(sme_regnum + i);
+m_dynamic_reg_infos.push_back(g_register_infos_sme[i]);
+m_dynamic_reg_infos[sme_regnum + i].byte_offset =
+m_dynamic_reg_infos[sme_regnum + i - 1].byte_offset +
+m_dynamic_reg_infos[sme_regnum + i - 1].byte_size;
+m_dynamic_reg_infos[sme_regnum + i].kinds[lldb::eRegisterKindLLDB] =
+sme_regnum + i;
+  }
+
+  m_per_regset_regnum_range[m_register_set_count] =
+  std::make_pair(sme_regnum, m_dynamic_reg_infos.size());
+  m_dynamic_reg_sets.push_back(g_reg_set_sme_arm64);
+  m_dynamic_reg_sets.back().registers = m_sme_regnum_collection.data();
+}
+
 uint32_t RegisterInfoPOSIX_arm64::ConfigureVectorLength(uint32_t sve_vq) {
   // sve_vq contains SVE Quad vector length in context of AArch64 SVE.
   // SVE register infos if enabled cannot be disabled by selecting sve_vq = 0.
@@ -523,3 +546,7 @@
 uint32_t RegisterInfoPOSIX_arm64::GetZAOffset() const {
   return m_register_info_p[m_za_regnum_collection[0]].byte_offset;
 }
+
+uint32_t RegisterInfoPOSIX_arm64::GetSMEOffset() const {
+  return m_register_info_p[m_sme_regnum_collection[0]].byte_offset;
+}
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
@@ -114,6 +114,12 @@
 
   uint64_t m_mte_ctrl_reg;
 
+  struct sme_regs {
+uint64_t svg_reg;
+  };
+
+  struct sme_regs m_sme_regs;
+
   struct tls_regs {
 uint64_t tpidr_reg;
 // Only valid when SME is present.
@@ -144,6 +150,8 @@
 
   Status WriteTLS();
 
+  Status ReadSMESVG();
+
   Status ReadZAHeader();
 
   Status ReadZA();
@@ -159,6 +167,7 @@
   bool IsPAuth(unsigned reg) const;
   bool IsMTE(unsigned reg) const;
   bool IsTLS(unsigned

[Lldb-commits] [PATCH] D159504: [lldb][AArch64] Implement resizing of SME's ZA register

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: ctetreau, kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The size of ZA depends on the streamnig vector length regardless
of the active mode. So in addition to vg (which reports the active
mode) we must send the client svg.

Otherwise the mechanics are the same as for non-streaming SVE.
Use the svg value to update the defined size of ZA, accounting
for the fact that ZA is not a single vector but a suqare matrix.

So if svg is 8, a single streaming vector would be 8*8 = 64 bytes.
ZA is that squared, so 64*64 = 4096 bytes.

Testing is included in a later patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159504

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp

Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -614,10 +614,11 @@
   ConfigureOffsets();
 
   // Check if register info is reconfigurable
-  // AArch64 SVE register set has configurable register sizes
+  // AArch64 SVE register set has configurable register sizes, as does the ZA
+  // register that SME added (the streaming state of SME reuses the SVE state).
   if (arch.GetTriple().isAArch64()) {
 for (const auto ® : m_regs) {
-  if (strcmp(reg.name, "vg") == 0) {
+  if ((strcmp(reg.name, "vg") == 0) || (strcmp(reg.name, "svg") == 0)) {
 m_is_reconfigurable = true;
 break;
   }
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1660,17 +1660,19 @@
 gdb_thread->PrivateSetRegisterValue(lldb_regnum, buffer_sp->GetData());
   }
 
-  // AArch64 SVE specific code below calls AArch64SVEReconfigure to update
-  // SVE register sizes and offsets if value of VG register has changed
-  // since last stop.
+  // AArch64 SVE/SME specific code below updates SVE and ZA register sizes and
+  // offsets if value of VG or SVG registers has changed since last stop.
   const ArchSpec &arch = GetTarget().GetArchitecture();
   if (arch.IsValid() && arch.GetTriple().isAArch64()) {
 GDBRemoteRegisterContext *reg_ctx_sp =
 static_cast(
 gdb_thread->GetRegisterContext().get());
 
-if (reg_ctx_sp)
+if (reg_ctx_sp) {
   reg_ctx_sp->AArch64SVEReconfigure();
+  reg_ctx_sp->AArch64SMEReconfigure();
+  reg_ctx_sp->InvalidateAllRegisters();
+}
   }
 
   thread_sp->SetName(thread_name.empty() ? nullptr : thread_name.c_str());
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -39,6 +39,7 @@
   ~GDBRemoteDynamicRegisterInfo() override = default;
 
   void UpdateARM64SVERegistersInfos(uint64_t vg);
+  void UpdateARM64SMERegistersInfos(uint64_t vg);
 };
 
 class GDBRemoteRegisterContext : public RegisterContext {
@@ -77,7 +78,9 @@
   uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
uint32_t num) override;
 
-  bool AArch64SVEReconfigure();
+  void AArch64SVEReconfigure();
+
+  void AArch64SMEReconfigure();
 
 protected:
   friend class ThreadGDBRemote;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -373,14 +373,14 @@
   if (dst == nullptr)
 return false;
 
-  // Code below is specific to AArch64 target in SVE state
+  // Code below is specific to AArch64 target in SVE or SMEstate
   // If vector granule (vg) register is being written then thread's
   // register context reconfiguration is triggered on success.
-  bool do_reconfigure_arm64_sve = false;
+  // We do not allow writes to SVG so it is not mentioned here.
   const ArchSpec &arch = process->GetTarget().GetArchitecture();
-  if (arch.IsValid() && arch.GetTriple().isAArch64())
-if (strcmp(reg_info->name, "vg") == 0)
-  do_reconfigure_arm64_sve = true;
+  bool do_reconfigure_arm64_sve = arch.IsValid() &&
+  arch.GetTriple().isAArch64() &&
+  (strcmp(reg_info->name,

[Lldb-commits] [PATCH] D159505: [lldb][AArch64] Add testing for SME's ZA and SVG registers

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: ctetreau, kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

An SME enabled program has the following extra state:

- Streaming mode or non-streaming mode.
- ZA enabled or disabled.
- The active vector length.

Covering the transition between all possible states and all other
possible states is not viable, therefore the testing added here is a cross
section of that, all of which found real bugs in LLDB and the Linux
Kernel during development.

Many of those transitions will not be possible via LLDB
(e.g. disabling ZA) and many more are possible but unlikely to be
used in normal use.

Added testing:

- TestSVEThreadedDynamic now checks for correct SVG values.
- New test TestZAThreadedDynamic creates 3 threads with different ZA sizes and 
states and switches between them verifying the register value (derived from the 
existing threaded SVE test).
- New test TestZARegisterSaveRestore starts in a given SME state, runs a set of 
expressions in various orders, then checks that the original state has been 
restored.
- TestArm64DynamicRegsets has ZA and SVG checks added, including writing to ZA 
to enable it.

Running these tests will as usual require QEMU as there is no
real SME hardware available at this time, and a very recent
kernel.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159505

Files:
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/main.c
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/TestZARegisterSaveRestore.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c

Index: lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c
@@ -0,0 +1,226 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Important details for this program:
+// * Making a syscall will disable streaming mode if it is active.
+// * Changing the vector length will make streaming mode and ZA inactive.
+// * ZA can be active independent of streaming mode.
+// * ZA's size is the streaming vector length squared.
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#ifndef PR_SME_GET_VL
+#define PR_SME_GET_VL 64
+#endif
+
+#ifndef PR_SME_VL_LEN_MASK
+#define PR_SME_VL_LEN_MASK 0x
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART SM_INST(7)
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+#define SMSTOP SM_INST(6)
+#define SMSTOP_SM SM_INST(2)
+#define SMSTOP_ZA SM_INST(4)
+
+int start_vl = 0;
+int other_vl = 0;
+
+void write_sve_regs() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatil

[Lldb-commits] [PATCH] D157883: [lldb][AArch64] Add SME's Array Storage (ZA) and streaming vector length (SVG) registers

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett abandoned this revision.
DavidSpickett added a comment.

I've split them. I didn't split ZA definition and read/write because the former 
would be almost nothing, but otherwise it's into a few commits now ending with 
testing.

I won't fold the ZA bugfix into this as I think it's weird enough to warrant 
its own commit and therefore blame entry (and it doesn't show up in testing 
anyway).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157883/new/

https://reviews.llvm.org/D157883

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

> Any chance we could simplify this situation and have dwo searches use exactly 
> the same/shared logic as source file searches?

I'm not sure what exactly this means, can you clarify?

I know that DWP and DWO have different search functions, that could certainly 
be unified. Not sure how source files work.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157609/new/

https://reviews.llvm.org/D157609

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D159505: [lldb][AArch64] Add testing for SME's ZA and SVG registers

2023-09-12 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

This patch requires rebasing does not apply cleanly on top of its parent.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159505/new/

https://reviews.llvm.org/D159505

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-12 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65974:

>From 2e415b3d0bca50b4c172e12a27697b8adf6fabf0 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 11:42:45 +
Subject: [PATCH 1/3] [lldb] Treat user aliases the same as built-ins when tab
 completing

Previously we would check all built-ins first for suggestions,
then check built-ins and aliases. This meant that if you had
an alias brkpt -> breakpoint, "br" would complete to "breakpoint".

Instead of giving you the choice of "brkpt" or "breakpoint".
---
 .../source/Interpreter/CommandInterpreter.cpp | 35 +++
 .../abbreviation/TestAbbreviations.py |  2 +-
 .../completion/TestCompletion.py  | 18 --
 3 files changed, 13 insertions(+), 42 deletions(-)

diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 6d1ad799f2d10fb..fc94bf6fbfe117c 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1227,36 +1227,11 @@ CommandObject *
 CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
  StringList *matches,
  StringList *descriptions) const {
-  CommandObject *command_obj =
-  GetCommandSP(cmd_str, false, true, matches, descriptions).get();
-
-  // If we didn't find an exact match to the command string in the commands,
-  // look in the aliases.
-
-  if (command_obj)
-return command_obj;
-
-  command_obj = GetCommandSP(cmd_str, true, true, matches, descriptions).get();
-
-  if (command_obj)
-return command_obj;
-
-  // If there wasn't an exact match then look for an inexact one in just the
-  // commands
-  command_obj = GetCommandSP(cmd_str, false, false, nullptr).get();
-
-  // Finally, if there wasn't an inexact match among the commands, look for an
-  // inexact match in both the commands and aliases.
-
-  if (command_obj) {
-if (matches)
-  matches->AppendString(command_obj->GetCommandName());
-if (descriptions)
-  descriptions->AppendString(command_obj->GetHelp());
-return command_obj;
-  }
-
-  return GetCommandSP(cmd_str, true, false, matches, descriptions).get();
+  // Try to find a match among commands and aliases. Allowing inexact matches,
+  // but perferring exact matches.
+  return GetCommandSP(cmd_str, /*include_aliases=*/true, /*exact=*/false,
+ matches, descriptions)
+.get();
 }
 
 CommandObject *CommandInterpreter::GetUserCommandObject(
diff --git a/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py 
b/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
index 10431e41dc81a2e..cade8d87e7f76f5 100644
--- a/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
+++ b/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)
 self.assertTrue(result.Succeeded())
 self.assertEqual("help", result.GetOutput())
 
diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 302b461b61d0d4d..f71bc73928f0f4e 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -618,19 +618,15 @@ def test_command_unalias(self):
 
 def test_command_aliases(self):
 self.runCmd("command alias brkpt breakpoint")
-# If there is an unambiguous completion from the built-in commands,
-# we choose that.
-self.complete_from_to("br", "breakpoint")
-# Only if there is not, do we then look for an unambiguous completion
-# from the user defined aliases.
+# Exact matches are chosen if possible, even if there are longer
+# completions we could use.
+self.complete_from_to("b", "b ")
+# Aliases are included in possible completions.
+self.complete_from_to("br", ["breakpoint", "brkpt"])
+# An alias can be the chosen completion.
 self.complete_from_to("brk", "brkpt")
 
-# Aliases are included when there's no exact match.
-self.runCmd("command alias play breakpoint")
-self.complete_from_to("pl", ["plugin", "platform", "play"])
-
-# That list can also contain only aliases if there's no built-ins to
-# match.
+# The list can contain only aliases if there's no built-ins to match.
 self.runCmd("command alias test_1 breakpoint")
 self.runCmd("command alias test_2 breakpoint")
 self.complete_from_to("test_", ["test_1", "test_2"])

>From

[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-12 Thread David Spickett via lldb-commits


@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)

DavidSpickett wrote:

I figured it out. Previously, when you start with "h":
* exact match commands - fails
* exact match aliases - fails
* inexact match commands - succeeds

And we would skip looking in the aliases for an inexact match. That's why 
"history" never shows up.

Now I'm treating aliases and commands on the same level, when the inexact match 
is looked for both show up.

I've added an explicit alias h -> help to fix this, and restored the test to 
what it was.

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-12 Thread David Spickett via lldb-commits


@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)

DavidSpickett wrote:

So it never was an intentional alias because it never needed aliasing, now it 
does.

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157846: [lldb][AArch64] Add SME's tests for SVE register state to TestArm64DynamicRegsets

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556555.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157846/new/

https://reviews.llvm.org/D157846

Files:
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c


Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
@@ -1,5 +1,9 @@
 #include 
 
+#ifndef HWCAP2_SME
+#define HWCAP2_SME (1 << 23)
+#endif
+
 void set_sve_registers() {
   // AArch64 SVE extension ISA adds a new set of vector and predicate 
registers:
   // 32 Z registers, 16 P registers, and 1 FFR register.
@@ -64,8 +68,14 @@
   asm volatile("cpy  z31.b, p15/z, #32\n\t");
 }
 
-int main() {
-  if (getauxval(AT_HWCAP) & HWCAP_SVE) // check if SVE is present
+int main(int argc, char *argv[]) {
+  if (argc > 1) {
+// Enable streaming mode SVE and the ZA array storage.
+asm volatile("msr  s0_3_c4_c7_3, xzr" /*smstart*/);
+  }
+
+  // If we have SVE or SME, set the SVE registers.
+  if ((getauxval(AT_HWCAP) & HWCAP_SVE) || (getauxval(AT_HWCAP2) & HWCAP2_SME))
 set_sve_registers();
 
   return 0; // Set a break point here.
Index: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
===
--- 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
+++ 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
@@ -120,3 +120,42 @@
 )
 self.expect("register read data_mask", substrs=["data_mask = 
0x"])
 self.expect("register read code_mask", substrs=["code_mask = 
0x"])
+
+@no_debug_info_test
+@skipIf(archs=no_match(["aarch64"]))
+@skipIf(oslist=no_match(["linux"]))
+def test_aarch64_dynamic_regset_config_sme(self):
+"""Test AArch64 Dynamic Register sets configuration, but only SME
+   registers."""
+if not self.isAArch64SME():
+self.skipTest("SME must be present.")
+
+self.build()
+self.line = line_number("main.c", "// Set a break point here.")
+
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line, num_expected_locations=1
+)
+self.runCmd("settings set target.run-args sme")
+self.runCmd("run", RUN_SUCCEEDED)
+
+self.expect(
+"thread backtrace",
+STOPPED_DUE_TO_BREAKPOINT,
+substrs=["stop reason = breakpoint 1."],
+)
+
+target = self.dbg.GetSelectedTarget()
+process = target.GetProcess()
+thread = process.GetThreadAtIndex(0)
+currentFrame = thread.GetFrameAtIndex(0)
+
+register_sets = currentFrame.GetRegisters()
+
+ssve_registers = register_sets.GetFirstValueByName(
+"Scalable Vector Extension Registers")
+self.assertTrue(ssve_registers.IsValid())
+self.sve_regs_read_dynamic(ssve_registers)


Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
@@ -1,5 +1,9 @@
 #include 
 
+#ifndef HWCAP2_SME
+#define HWCAP2_SME (1 << 23)
+#endif
+
 void set_sve_registers() {
   // AArch64 SVE extension ISA adds a new set of vector and predicate registers:
   // 32 Z registers, 16 P registers, and 1 FFR register.
@@ -64,8 +68,14 @@
   asm volatile("cpy  z31.b, p15/z, #32\n\t");
 }
 
-int main() {
-  if (getauxval(AT_HWCAP) & HWCAP_SVE) // check if SVE is present
+int main(int argc, char *argv[]) {
+  if (argc > 1) {
+// Enable streaming mode SVE and the ZA array storage.
+asm volatile("msr  s0_3_c4_c7_3, xzr" /*smstart*/);
+  }
+
+  // If we have SVE or SME, set the SVE registers.
+  if ((getauxval(AT_HWCAP) & HWCAP_SVE) || (getauxval(AT_HWCAP2) & HWCAP2_SME))
 set_sve_registers();
 
   return 0; // Set a break point here.
Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
@@ -120,3 +120,42 @@
 )
 self.expect("register read da

[Lldb-commits] [PATCH] D159502: [lldb][AArch64] Add SME's Array Storage (ZA) register

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556556.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159502/new/

https://reviews.llvm.org/D159502

Files:
  lldb/include/lldb/Utility/RegisterValue.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h

Index: lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -119,6 +119,10 @@
 {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_SVE},
 };
 
+constexpr RegsetDesc AARCH64_ZA_Desc[] = {
+{llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_ZA},
+};
+
 constexpr RegsetDesc AARCH64_PAC_Desc[] = {
 {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_PAC_MASK},
 };
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -30,6 +30,7 @@
 eRegsetMaskPAuth = 4,
 eRegsetMaskMTE = 8,
 eRegsetMaskTLS = 16,
+eRegsetMaskZA = 32,
 eRegsetMaskDynamic = ~1,
   };
 
@@ -106,8 +107,12 @@
 
   void AddRegSetTLS(bool has_tpidr2);
 
+  void AddRegSetZA();
+
   uint32_t ConfigureVectorLength(uint32_t sve_vq);
 
+  void ConfigureVectorLengthZA(uint32_t za_vq);
+
   bool VectorSizeIsValid(uint32_t vq) {
 // coverity[unsigned_compare]
 if (vq >= eVectorQuadwordAArch64 && vq <= eVectorQuadwordAArch64SVEMax)
@@ -117,6 +122,7 @@
 
   bool IsSVEEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskSVE); }
   bool IsSSVEEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskSSVE); }
+  bool IsZAEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskZA); }
   bool IsPAuthEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskPAuth); }
   bool IsMTEEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskMTE); }
   bool IsTLSEnabled() const { return m_opt_regsets.AnySet(eRegsetMaskTLS); }
@@ -128,15 +134,19 @@
   bool IsPAuthReg(unsigned reg) const;
   bool IsMTEReg(unsigned reg) const;
   bool IsTLSReg(unsigned reg) const;
+  bool IsZAReg(unsigned reg) const;
+  bool IsSMEReg(unsigned reg) const;
 
   uint32_t GetRegNumSVEZ0() const;
   uint32_t GetRegNumSVEFFR() const;
   uint32_t GetRegNumFPCR() const;
   uint32_t GetRegNumFPSR() const;
   uint32_t GetRegNumSVEVG() const;
+  uint32_t GetRegNumSMEVG() const;
   uint32_t GetPAuthOffset() const;
   uint32_t GetMTEOffset() const;
   uint32_t GetTLSOffset() const;
+  uint32_t GetZAOffset() const;
 
 private:
   typedef std::map>
@@ -145,7 +155,10 @@
   per_vq_register_infos m_per_vq_reg_infos;
 
   uint32_t m_vector_reg_vq = eVectorQuadwordAArch64;
+  uint32_t m_za_reg_vq = eVectorQuadwordAArch64;
 
+  // In normal operation this is const. Only when SVE or SME registers change
+  // size is it either replaced or the content modified.
   const lldb_private::RegisterInfo *m_register_info_p;
   uint32_t m_register_info_count;
 
@@ -164,6 +177,8 @@
   std::vector pauth_regnum_collection;
   std::vector m_mte_regnum_collection;
   std::vector m_tls_regnum_collection;
+  std::vector m_za_regnum_collection;
+  std::vector m_sme_regnum_collection;
 };
 
 #endif
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -83,6 +83,11 @@
 // Only present when SME is present
 DEFINE_EXTENSION_REG(tpidr2)};
 
+static lldb_private::RegisterInfo g_register_infos_za[] =
+// 16 is a default size we will change later.
+{{"za", nullptr, 16, 0, lldb::eEncodingVector, lldb::eFormatVectorOfUInt8,
+  KIND_ALL_INVALID, nullptr, nullptr, nullptr}};
+
 // Number of register sets provided by this context.
 enum {
   k_num_gpr_registers = gpr_w28 - gpr_x0 + 1,
@@ -91,6 +96,8 @@
   k_num_mte_register = 1,
   // Number of TLS registers is dynamic so it is not listed here.
   k_num_pauth_register = 2,
+  k_num_za_register = 1,
+  k_num_sme_register = 1,
   k_num_register_sets_default = 2,
   k_num_register_sets = 3
 };
@@ -197,6 +204,13 @@
 
 // The size of the TLS set is dynamic, so not listed

[Lldb-commits] [PATCH] D159503: [lldb][AArch64] Add SME streaming vector length pseduo register

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556557.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159503/new/

https://reviews.llvm.org/D159503

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h

Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -109,6 +109,8 @@
 
   void AddRegSetZA();
 
+  void AddRegSetSME();
+
   uint32_t ConfigureVectorLength(uint32_t sve_vq);
 
   void ConfigureVectorLengthZA(uint32_t za_vq);
@@ -147,6 +149,7 @@
   uint32_t GetMTEOffset() const;
   uint32_t GetTLSOffset() const;
   uint32_t GetZAOffset() const;
+  uint32_t GetSMEOffset() const;
 
 private:
   typedef std::map>
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -88,6 +88,9 @@
 {{"za", nullptr, 16, 0, lldb::eEncodingVector, lldb::eFormatVectorOfUInt8,
   KIND_ALL_INVALID, nullptr, nullptr, nullptr}};
 
+static lldb_private::RegisterInfo g_register_infos_sme[] = {
+DEFINE_EXTENSION_REG(svg)};
+
 // Number of register sets provided by this context.
 enum {
   k_num_gpr_registers = gpr_w28 - gpr_x0 + 1,
@@ -255,8 +258,10 @@
   // present.
   AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE));
 
-  if (m_opt_regsets.AnySet(eRegsetMaskSSVE))
+  if (m_opt_regsets.AnySet(eRegsetMaskSSVE)) {
 AddRegSetZA();
+AddRegSetSME();
+  }
 
   m_register_info_count = m_dynamic_reg_infos.size();
   m_register_info_p = m_dynamic_reg_infos.data();
@@ -377,6 +382,24 @@
   m_dynamic_reg_sets.back().registers = m_za_regnum_collection.data();
 }
 
+void RegisterInfoPOSIX_arm64::AddRegSetSME() {
+  uint32_t sme_regnum = m_dynamic_reg_infos.size();
+  for (uint32_t i = 0; i < k_num_sme_register; i++) {
+m_sme_regnum_collection.push_back(sme_regnum + i);
+m_dynamic_reg_infos.push_back(g_register_infos_sme[i]);
+m_dynamic_reg_infos[sme_regnum + i].byte_offset =
+m_dynamic_reg_infos[sme_regnum + i - 1].byte_offset +
+m_dynamic_reg_infos[sme_regnum + i - 1].byte_size;
+m_dynamic_reg_infos[sme_regnum + i].kinds[lldb::eRegisterKindLLDB] =
+sme_regnum + i;
+  }
+
+  m_per_regset_regnum_range[m_register_set_count] =
+  std::make_pair(sme_regnum, m_dynamic_reg_infos.size());
+  m_dynamic_reg_sets.push_back(g_reg_set_sme_arm64);
+  m_dynamic_reg_sets.back().registers = m_sme_regnum_collection.data();
+}
+
 uint32_t RegisterInfoPOSIX_arm64::ConfigureVectorLength(uint32_t sve_vq) {
   // sve_vq contains SVE Quad vector length in context of AArch64 SVE.
   // SVE register infos if enabled cannot be disabled by selecting sve_vq = 0.
@@ -523,3 +546,7 @@
 uint32_t RegisterInfoPOSIX_arm64::GetZAOffset() const {
   return m_register_info_p[m_za_regnum_collection[0]].byte_offset;
 }
+
+uint32_t RegisterInfoPOSIX_arm64::GetSMEOffset() const {
+  return m_register_info_p[m_sme_regnum_collection[0]].byte_offset;
+}
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
@@ -114,6 +114,12 @@
 
   uint64_t m_mte_ctrl_reg;
 
+  struct sme_regs {
+uint64_t svg_reg;
+  };
+
+  struct sme_regs m_sme_regs;
+
   struct tls_regs {
 uint64_t tpidr_reg;
 // Only valid when SME is present.
@@ -144,6 +150,8 @@
 
   Status WriteTLS();
 
+  Status ReadSMESVG();
+
   Status ReadZAHeader();
 
   Status ReadZA();
@@ -159,6 +167,7 @@
   bool IsPAuth(unsigned reg) const;
   bool IsMTE(unsigned reg) const;
   bool IsTLS(unsigned reg) const;
+  bool IsSME(unsigned reg) const;
 
   uint64_t GetSVERegVG() { return m_sve_header.vl / 8; }
 
@@ -176,6 +185,8 @@
 
   void *GetTLSBuffer() { return &m_tls_regs; }
 
+  void *GetSMEBuffer() { return &m_sme_regs; }
+
   void *GetSVEBuffer() { return m_sve_ptrace_payload.data(); }
 
   size_t GetSVEHeaderSize() { return sizeof(m_sve_header); }
@@ -194,6 +205,8 @@
 
   size_t GetTLSBufferSize() { return m_tls_size; }
 
+  size_t GetSMEBufferSize() { return sizeof(m_sme_regs); }
+
   llvm::Error ReadHardwareDebugInfo() override;
 
   llvm::Error WriteHardwareDebugRegs(DREGType hwbType) override;
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLi

[Lldb-commits] [PATCH] D159504: [lldb][AArch64] Implement resizing of SME's ZA register

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556558.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159504/new/

https://reviews.llvm.org/D159504

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp

Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -614,10 +614,11 @@
   ConfigureOffsets();
 
   // Check if register info is reconfigurable
-  // AArch64 SVE register set has configurable register sizes
+  // AArch64 SVE register set has configurable register sizes, as does the ZA
+  // register that SME added (the streaming state of SME reuses the SVE state).
   if (arch.GetTriple().isAArch64()) {
 for (const auto ® : m_regs) {
-  if (strcmp(reg.name, "vg") == 0) {
+  if ((strcmp(reg.name, "vg") == 0) || (strcmp(reg.name, "svg") == 0)) {
 m_is_reconfigurable = true;
 break;
   }
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1660,17 +1660,19 @@
 gdb_thread->PrivateSetRegisterValue(lldb_regnum, buffer_sp->GetData());
   }
 
-  // AArch64 SVE specific code below calls AArch64SVEReconfigure to update
-  // SVE register sizes and offsets if value of VG register has changed
-  // since last stop.
+  // AArch64 SVE/SME specific code below updates SVE and ZA register sizes and
+  // offsets if value of VG or SVG registers has changed since last stop.
   const ArchSpec &arch = GetTarget().GetArchitecture();
   if (arch.IsValid() && arch.GetTriple().isAArch64()) {
 GDBRemoteRegisterContext *reg_ctx_sp =
 static_cast(
 gdb_thread->GetRegisterContext().get());
 
-if (reg_ctx_sp)
+if (reg_ctx_sp) {
   reg_ctx_sp->AArch64SVEReconfigure();
+  reg_ctx_sp->AArch64SMEReconfigure();
+  reg_ctx_sp->InvalidateAllRegisters();
+}
   }
 
   thread_sp->SetName(thread_name.empty() ? nullptr : thread_name.c_str());
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -39,6 +39,7 @@
   ~GDBRemoteDynamicRegisterInfo() override = default;
 
   void UpdateARM64SVERegistersInfos(uint64_t vg);
+  void UpdateARM64SMERegistersInfos(uint64_t vg);
 };
 
 class GDBRemoteRegisterContext : public RegisterContext {
@@ -77,7 +78,9 @@
   uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
uint32_t num) override;
 
-  bool AArch64SVEReconfigure();
+  void AArch64SVEReconfigure();
+
+  void AArch64SMEReconfigure();
 
 protected:
   friend class ThreadGDBRemote;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -373,14 +373,14 @@
   if (dst == nullptr)
 return false;
 
-  // Code below is specific to AArch64 target in SVE state
+  // Code below is specific to AArch64 target in SVE or SMEstate
   // If vector granule (vg) register is being written then thread's
   // register context reconfiguration is triggered on success.
-  bool do_reconfigure_arm64_sve = false;
+  // We do not allow writes to SVG so it is not mentioned here.
   const ArchSpec &arch = process->GetTarget().GetArchitecture();
-  if (arch.IsValid() && arch.GetTriple().isAArch64())
-if (strcmp(reg_info->name, "vg") == 0)
-  do_reconfigure_arm64_sve = true;
+  bool do_reconfigure_arm64_sve = arch.IsValid() &&
+  arch.GetTriple().isAArch64() &&
+  (strcmp(reg_info->name, "vg") == 0);
 
   if (data.CopyByteOrderedData(data_offset,// src offset
reg_info->byte_size,// src length
@@ -400,10 +400,12 @@
 {m_reg_data.GetDataStart(), size_t(m_reg_data.GetByteSize())}))
 
 {
-  SetAllRegisterValid(false);
-
-  if (do_reconfigure_arm64_sve)
+  if (do_reconfigure_arm64_sve) {
 AArch64SVEReconfigure();
+AArch64SMEReconfigure();
+  }
+
+  InvalidateAllRegisters();
 
   return true;
 }
@@ -435,8 +437,11 @

[Lldb-commits] [PATCH] D159505: [lldb][AArch64] Add testing for SME's ZA and SVG registers

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556559.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159505/new/

https://reviews.llvm.org/D159505

Files:
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/main.c
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/TestZARegisterSaveRestore.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c

Index: lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c
@@ -0,0 +1,226 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Important details for this program:
+// * Making a syscall will disable streaming mode if it is active.
+// * Changing the vector length will make streaming mode and ZA inactive.
+// * ZA can be active independent of streaming mode.
+// * ZA's size is the streaming vector length squared.
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#ifndef PR_SME_GET_VL
+#define PR_SME_GET_VL 64
+#endif
+
+#ifndef PR_SME_VL_LEN_MASK
+#define PR_SME_VL_LEN_MASK 0x
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART SM_INST(7)
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+#define SMSTOP SM_INST(6)
+#define SMSTOP_SM SM_INST(2)
+#define SMSTOP_ZA SM_INST(4)
+
+int start_vl = 0;
+int other_vl = 0;
+
+void write_sve_regs() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatile("cpy  z19.b, p15/z, #20\n\t");
+  asm volatile("cpy  z20.b, p0/z, #21\n\t");
+  asm volatile("cpy  z21.b, p5/z, #22\n\t");
+  asm volatile("cpy  z22.b, p10/z, #23\n\t");
+  asm volatile("cpy  z23.b, p15/z, #24\n\t");
+  asm volatile("cpy  z24.b, p0/z, #25\n\t");
+  asm volatile("cpy  z25.b, p5/z, #26\n\t");
+  asm volatile("cpy  z26.b, p10/z, #27\n\t");
+  asm volatile("cpy  z27.b, p15/z, #28\n\t");
+  asm volatile("cpy  z28.b, p0/z, #29\n\t");
+  asm volatile("cpy  z29.b, p5/z, #30\n\t");
+  asm volatile("cpy  z30.b, p10/z, #31\n\t");
+  asm volatile("cpy  z31.b, p15/z, #32\n\t");
+}
+
+// Write something different so we will know if we didn't restore them
+// correctly.
+void write_sve_regs_expr() {
+  asm volatile("pfalse p0.b\n\t");
+  asm volatile("wrffr p0.b\n\t");
+  asm volatile("pfalse p1.b\n\t");
+  asm volatile("pfalse p2.b\n\t");
+  asm volatile("pfalse p3.b\n\t");
+  asm volatile("ptrue p4.b\n\t");
+  asm volatile("pfalse p5.b\n\t");
+  asm volatile("pfalse p6.b\n\t");
+  asm volatile("pfalse p7.b\n\t");
+  asm volatile("pfalse p8.b\n\t");
+  asm volatile("ptrue p9.b\n\t");
+  asm volatile("pfalse p10.b\n\t");
+  asm volatile("pfalse p11.b\n\t");
+  asm volatile("pfalse p12.b\n\t");
+  asm volatile("pfalse p13.b\n\t");
+  asm volatile

[Lldb-commits] [PATCH] D154927: [lldb][AArch64] Add SME's streaming vector control register

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556560.
DavidSpickett added a comment.
Herald added a subscriber: sunshaoce.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154927/new/

https://reviews.llvm.org/D154927

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/main.c
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/TestZARegisterSaveRestore.py

Index: lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/TestZARegisterSaveRestore.py
===
--- lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/TestZARegisterSaveRestore.py
+++ lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/TestZARegisterSaveRestore.py
@@ -149,6 +149,10 @@
 self.runCmd("register read " + sve_reg_names)
 sve_values = self.res.GetOutput()
 
+svcr_value = 1 if sve_mode == Mode.SSVE else 0
+if za_state == ZA.Enabled:
+svcr_value += 2
+
 def check_regs():
 if za_state == ZA.Enabled:
 self.check_za(start_vl)
@@ -160,6 +164,7 @@
 self.assertEqual(start_vg, self.read_vg())
 
 self.expect("register read " + sve_reg_names, substrs=[sve_values])
+self.expect("register read svcr", substrs=["0x{:016x}".format(svcr_value)])
 
 for expr in exprs:
 expr_cmd = "expression {}()".format(expr)
Index: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/main.c
===
--- lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/main.c
+++ lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/main.c
@@ -5,7 +5,7 @@
 #define PR_SME_SET_VL 63
 #endif
 
-#define SMSTART() asm volatile("msr  s0_3_c4_c7_3, xzr" /*smstart*/)
+#define SMSTART_SM() asm volatile("msr  s0_3_c4_c3_3, xzr" /*smstart sm*/)
 
 void write_sve_regs() {
   // We assume the smefa64 feature is present, which allows ffr access
@@ -126,18 +126,18 @@
   // Note that doing a syscall brings you back to non-streaming mode, so we
   // don't need to SMSTOP here.
   if (streaming)
-SMSTART();
+SMSTART_SM();
   write_sve_regs_expr();
   prctl(SET_VL_OPT, 8 * 4);
   if (streaming)
-SMSTART();
+SMSTART_SM();
   write_sve_regs_expr();
   return 1;
 }
 
 int main() {
 #ifdef START_SSVE
-  SMSTART();
+  SMSTART_SM();
 #endif
   write_sve_regs();
 
Index: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
===
--- lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
+++ lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
@@ -24,7 +24,14 @@
 reg_value.GetByteSize(), expected, 'Verify "%s" == %i' % (name, expected)
 )
 
-def check_sve_regs_read(self, z_reg_size):
+def check_sve_regs_read(self, z_reg_size, expected_mode):
+if self.isAArch64SME():
+# This test uses SMSTART SM, which only enables streaming mode,
+# leaving ZA disabled.
+expected_value = "1" if expected_mode == Mode.SSVE else "0"
+self.expect("register read svcr", substrs=[
+"0x000" + expected_value])
+
 p_reg_size = int(z_reg_size / 8)
 
 for i in range(32):
@@ -168,7 +175,7 @@
 
 vg_reg_value = sve_registers.GetChildMemberWithName("vg").GetValueAsUnsigned()
 z_reg_size = vg_reg_value * 8
-self.check_sve_regs_read(z_reg_size)
+self.check_sve_regs_read(z_reg_size, start_mode)
 
 # Evaluate simple expression and print function expr_eval_func address.
 self.expect("expression expr_eval_func", substrs=["= 0x"])
@@ -184,7 +191,7 @@
 
 # We called a jitted function above which must not have changed SVE
 # vector length or register values.
-self.check_sve_regs_read(z_reg_size)
+self.check_sve_regs_read(z_reg_size, start_mode)
 
 self.check_sve_regs_read_after_write(z_reg_size)
 
Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
===

[Lldb-commits] [PATCH] D158500: [lldb][AArch64] Linux corefile support for SME

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556561.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158500/new/

https://reviews.llvm.org/D158500

Files:
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
  lldb/test/API/linux/aarch64/sme_core_file/TestAArch64LinuxSMECoreFile.py
  lldb/test/API/linux/aarch64/sme_core_file/core_0_16_32_1
  lldb/test/API/linux/aarch64/sme_core_file/core_0_32_16_0
  lldb/test/API/linux/aarch64/sme_core_file/core_1_16_32_0
  lldb/test/API/linux/aarch64/sme_core_file/core_1_32_16_1
  lldb/test/API/linux/aarch64/sme_core_file/main.c

Index: lldb/test/API/linux/aarch64/sme_core_file/main.c
===
--- /dev/null
+++ lldb/test/API/linux/aarch64/sme_core_file/main.c
@@ -0,0 +1,140 @@
+// clang-format off
+// Compile with:
+// clang -target aarch64-unknown-linux-gnu main.c -o a.out -g -march=armv8.6-a+sve+sme
+//
+// For minimal corefile size, do this before running the program:
+// echo 0x20 > /proc/self/coredeump_filter
+//
+// Must be run on a system that has SVE and SME, including the smefa64
+// extension. Example command:
+// main 0 32 64 1
+//
+// This would not enter streaming mode, set non-streaming VL to 32
+// bytes, streaming VL to 64 bytes and enable ZA.
+// clang-format on
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+
+void set_sve_registers() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatile("cpy  z19.b, p15/z, #20\n\t");
+  asm volatile("cpy  z20.b, p0/z, #21\n\t");
+  asm volatile("cpy  z21.b, p5/z, #22\n\t");
+  asm volatile("cpy  z22.b, p10/z, #23\n\t");
+  asm volatile("cpy  z23.b, p15/z, #24\n\t");
+  asm volatile("cpy  z24.b, p0/z, #25\n\t");
+  asm volatile("cpy  z25.b, p5/z, #26\n\t");
+  asm volatile("cpy  z26.b, p10/z, #27\n\t");
+  asm volatile("cpy  z27.b, p15/z, #28\n\t");
+  asm volatile("cpy  z28.b, p0/z, #29\n\t");
+  asm volatile("cpy  z29.b, p5/z, #30\n\t");
+  asm volatile("cpy  z30.b, p10/z, #31\n\t");
+  asm volatile("cpy  z31.b, p15/z, #32\n\t");
+}
+
+void set_za_register(int streaming_vl) {
+#define MAX_VL_BYTES 256
+  uint8_t data[MAX_VL_BYTES];
+
+  for (unsigned i = 0; i < streaming_vl; ++i) {
+for (unsigned j = 0; j < MAX_VL_BYTES; ++j)
+  data[j] = i + 1;
+asm volatile("mov w12, %w0\n\t"
+ "ldr za[w12, 0], [%1]\n\t" ::"r"(i),
+ "r"(&data)
+ : "w12");
+  }
+}
+
+void set_tpidr2(uint64_t value) {
+  __asm__ volatile("msr S3_3_C13_C0_5, %0" ::"r"(value));
+}
+
+int main(int argc, char **argv) {
+  // Arguments:
+  //  SVE mode: 1 for streaming SVE (SSVE), any other value
+  //  for non-streaming SVE mode.
+  //   Non-Streaming Vector length: In bytes, an integer e.g. "32".
+  //   Streaming Vector length: As above, but for streaming mode.
+  //   ZA mode: 1 for enabled, any other value for disable

[Lldb-commits] [PATCH] D157846: [lldb][AArch64] Add SME's tests for SVE register state to TestArm64DynamicRegsets

2023-09-12 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

In this test can we figure out whether SVE was read from Streaming mode or 
normal SVE mode?? and if yes may be add a check for that.




Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py:156
+
+register_sets = currentFrame.GetRegisters()
+

can we use self.thread().GetSelectedFrame().GetRegisters() ?? or are you going 
to use target process thread and current frame variables in later patches?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157846/new/

https://reviews.llvm.org/D157846

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158506: [lldb][AArch64] Add release notes and documentation for SME

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556562.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158506/new/

https://reviews.llvm.org/D158506

Files:
  lldb/docs/index.rst
  lldb/docs/use/aarch64-linux.rst
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -175,6 +175,10 @@
 * Methods in SBHostOS related to threads have had their implementations
   removed. These methods will return a value indicating failure.
 
+* LLDB now supports debugging the Scalable Matrix Extension (SME) on AArch64
+  Linux for both running processes and core files. For details refer to the
+  `AArch64 Linux documentation `_.
+
 Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.
Index: lldb/docs/use/aarch64-linux.rst
===
--- /dev/null
+++ lldb/docs/use/aarch64-linux.rst
@@ -0,0 +1,190 @@
+Using LLDB On AArch64 Linux
+===
+
+This page explains the details of debugging certain AArch64 extensions using
+LLDB. If something is not mentioned here, it likely works as you would expect.
+
+This is not a replacement for ptrace and Linux Kernel documentation. This covers
+how LLDB has chosen to use those things and how that effects your experience as
+a user.
+
+Scalable Vector Extension (SVE)
+---
+
+See `here `__
+to learn about the extension and `here `__
+for the Linux Kernel's handling of it.
+
+In LLDB you will be able to see the following new registers:
+
+* ``z0-z31`` vector registers, each one has size equal to the vector length.
+* ``p0-p15`` predicate registers, each one containing 1 bit per byte in the vector
+  length. Making each one vector length / 8 sized.
+* ``ffr`` the first fault register, same size as a predicate register.
+* ``vg``, the vector length in "granules". Each granule is 8 bytes.
+
+.. code-block::
+
+   Scalable Vector Extension Registers:
+ vg = 0x0002
+ z0 = {0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 <...> }
+   <...>
+ p0 = {0xff 0xff}
+   <...>
+ffr = {0xff 0xff}
+
+The example above has a vector length of 16 bytes. Within LLDB you will always
+see "vg" as in the ``vg`` register, which is 2 in this case (8*2 = 16).
+Elsewhere you may see "vq" which is the vector length in quadwords (16 bytes)
+elsewhere. Where you see "vl", it is in bytes.
+
+Changing the Vector Length
+..
+
+While you can count the size of a P or Z register, it is intended that ``vg`` be
+used to find the current vector length.
+
+vg can be written. Writing the current vector length changes nothing. If you
+increase the vector length, the registers will likely be reset to 0. If you
+decrease it, LLDB will truncate the Z registers but everything else will be reset
+to 0.
+
+Generally you should not assume that SVE state after changing the vector length
+is in any way the same as it was previously. If you need to do it, do it before
+a function's first use of SVE.
+
+Z Register Presentation
+...
+
+LLDB makes no attempt to predict how an SVE Z register will be used. Even if the
+next SVE instruction (which may some distance away) would use, for example, 32
+bit elements, LLDB prints ``z0`` as single bytes.
+
+If you know what format you are going to use, give a format option::
+
+  (lldb) register read z0 -f uint32_t[]
+  z0 = {0x01010101 0x01010101 0x01010101 0x01010101}
+
+FPSIMD and SVE Modes
+
+
+Prior to the debugee's first use of SVE, it is in what the Linux Kernel terms
+SIMD mode. Only the FPU is being used. In this state LLDB will still show the
+SVE registers however the values are simply the FPU values zero extended up to
+the vector length.
+
+On first access to SVE, the process goes into SVE mode. Now the Z values are
+in the real Z registers.
+
+You can also trigger this with LLDB by writing to an SVE register. Note that
+there is no way to undo this change from within LLDB. However, the debugee
+itself could do something to end up back in SIMD mode.
+
+Expression evaluation
+.
+
+If you evaluate an expression, all SVE state is saved prior to, and restored
+after the expression has been evaluated. Including the register values and
+vector length.
+
+Scalable Matrix Extension (SME)
+---
+
+See `here `__
+to learn about the extension and `h

[Lldb-commits] [PATCH] D158514: [lldb][AArch64] Invalidate SVG prior to reconfiguring ZA regdef

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556563.
DavidSpickett added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158514/new/

https://reviews.llvm.org/D158514

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py


Index: 
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
===
--- 
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
+++ 
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
@@ -125,11 +125,13 @@
 self.runCmd("thread select %d" % (idx + 1))
 self.check_za_register(4, 2)
 self.runCmd("register write vg 2")
+self.check_disabled_za_register(2)
 
 elif stopped_at_line_number == thY_break_line1:
 self.runCmd("thread select %d" % (idx + 1))
 self.check_za_register(2, 3)
 self.runCmd("register write vg 4")
+self.check_disabled_za_register(4)
 
 self.runCmd("thread continue 2")
 self.runCmd("thread continue 3")
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -799,6 +799,11 @@
   if (!reg_info)
 return;
 
+  // When vg is written it is automatically made invalid. Writing vg will also
+  // change svg if we're in streaming mode, so we must fetch the latest value
+  // from the remote.
+  SetRegisterIsValid(reg_info, false);
+
   uint64_t fail_value = LLDB_INVALID_ADDRESS;
   uint32_t svg_reg_num = reg_info->kinds[eRegisterKindLLDB];
   uint64_t svg_reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);


Index: lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
===
--- lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
+++ lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
@@ -125,11 +125,13 @@
 self.runCmd("thread select %d" % (idx + 1))
 self.check_za_register(4, 2)
 self.runCmd("register write vg 2")
+self.check_disabled_za_register(2)
 
 elif stopped_at_line_number == thY_break_line1:
 self.runCmd("thread select %d" % (idx + 1))
 self.check_za_register(2, 3)
 self.runCmd("register write vg 4")
+self.check_disabled_za_register(4)
 
 self.runCmd("thread continue 2")
 self.runCmd("thread continue 3")
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -799,6 +799,11 @@
   if (!reg_info)
 return;
 
+  // When vg is written it is automatically made invalid. Writing vg will also
+  // change svg if we're in streaming mode, so we must fetch the latest value
+  // from the remote.
+  SetRegisterIsValid(reg_info, false);
+
   uint64_t fail_value = LLDB_INVALID_ADDRESS;
   uint32_t svg_reg_num = reg_info->kinds[eRegisterKindLLDB];
   uint64_t svg_reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D159505: [lldb][AArch64] Add testing for SME's ZA and SVG registers

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Should all be updated now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159505/new/

https://reviews.llvm.org/D159505

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157846: [lldb][AArch64] Add SME's tests for SVE register state to TestArm64DynamicRegsets

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

> In this test can we figure out whether SVE was read from Streaming mode or 
> normal SVE mode?? and if yes may be add a check for that.

Not sure what you mean.

If you mean:

- write non-streaming SVE with one set of values
- write streaming SVE with another
- assert that lldb read the correct one

There are a couple of issues there:

- If lldb read the inactive mode, it would fail with unavailable register due 
to a failure down in lldb-sever. These tests would already catch that.
- The kernel and the architecture say that the values of the registers for the 
mode you are coming from are wiped out on mode switch. So we wouldn't be able 
to truly read those values even if we were able to make the ptrace call and get 
some data.

So it's covered, but does not/ can not be covered by checking values. It'll be 
correct values, or a complete failure to read.




Comment at: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py:156
+
+register_sets = currentFrame.GetRegisters()
+

omjavaid wrote:
> can we use self.thread().GetSelectedFrame().GetRegisters() ?? or are you 
> going to use target process thread and current frame variables in later 
> patches?
No I just copied this from the original test, in fact later I wrap this all 
into a function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157846/new/

https://reviews.llvm.org/D157846

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157846: [lldb][AArch64] Add SME's tests for SVE register state to TestArm64DynamicRegsets

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556564.
DavidSpickett added a comment.

Use the simpler way to get the register sets.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157846/new/

https://reviews.llvm.org/D157846

Files:
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c


Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
@@ -1,5 +1,9 @@
 #include 
 
+#ifndef HWCAP2_SME
+#define HWCAP2_SME (1 << 23)
+#endif
+
 void set_sve_registers() {
   // AArch64 SVE extension ISA adds a new set of vector and predicate 
registers:
   // 32 Z registers, 16 P registers, and 1 FFR register.
@@ -64,8 +68,14 @@
   asm volatile("cpy  z31.b, p15/z, #32\n\t");
 }
 
-int main() {
-  if (getauxval(AT_HWCAP) & HWCAP_SVE) // check if SVE is present
+int main(int argc, char *argv[]) {
+  if (argc > 1) {
+// Enable streaming mode SVE and the ZA array storage.
+asm volatile("msr  s0_3_c4_c7_3, xzr" /*smstart*/);
+  }
+
+  // If we have SVE or SME, set the SVE registers.
+  if ((getauxval(AT_HWCAP) & HWCAP_SVE) || (getauxval(AT_HWCAP2) & HWCAP2_SME))
 set_sve_registers();
 
   return 0; // Set a break point here.
Index: 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
===
--- 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
+++ 
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
@@ -120,3 +120,37 @@
 )
 self.expect("register read data_mask", substrs=["data_mask = 
0x"])
 self.expect("register read code_mask", substrs=["code_mask = 
0x"])
+
+@no_debug_info_test
+@skipIf(archs=no_match(["aarch64"]))
+@skipIf(oslist=no_match(["linux"]))
+def test_aarch64_dynamic_regset_config_sme(self):
+"""Test AArch64 Dynamic Register sets configuration, but only SME
+   registers."""
+if not self.isAArch64SME():
+self.skipTest("SME must be present.")
+
+self.build()
+self.line = line_number("main.c", "// Set a break point here.")
+
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line, num_expected_locations=1
+)
+self.runCmd("settings set target.run-args sme")
+self.runCmd("run", RUN_SUCCEEDED)
+
+self.expect(
+"thread backtrace",
+STOPPED_DUE_TO_BREAKPOINT,
+substrs=["stop reason = breakpoint 1."],
+)
+
+register_sets = self.thread().GetSelectedFrame().GetRegisters()
+
+ssve_registers = register_sets.GetFirstValueByName(
+"Scalable Vector Extension Registers")
+self.assertTrue(ssve_registers.IsValid())
+self.sve_regs_read_dynamic(ssve_registers)


Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
@@ -1,5 +1,9 @@
 #include 
 
+#ifndef HWCAP2_SME
+#define HWCAP2_SME (1 << 23)
+#endif
+
 void set_sve_registers() {
   // AArch64 SVE extension ISA adds a new set of vector and predicate registers:
   // 32 Z registers, 16 P registers, and 1 FFR register.
@@ -64,8 +68,14 @@
   asm volatile("cpy  z31.b, p15/z, #32\n\t");
 }
 
-int main() {
-  if (getauxval(AT_HWCAP) & HWCAP_SVE) // check if SVE is present
+int main(int argc, char *argv[]) {
+  if (argc > 1) {
+// Enable streaming mode SVE and the ZA array storage.
+asm volatile("msr  s0_3_c4_c7_3, xzr" /*smstart*/);
+  }
+
+  // If we have SVE or SME, set the SVE registers.
+  if ((getauxval(AT_HWCAP) & HWCAP_SVE) || (getauxval(AT_HWCAP2) & HWCAP2_SME))
 set_sve_registers();
 
   return 0; // Set a break point here.
Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
===
--- lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
@@ -120,3 +120,37 @@
 )
 self.expect("register read data_mask", substrs=["data_mask = 0x"])
 self.expect("register read code_mask", substrs=["code_mask = 0x"])
+
+

[Lldb-commits] [PATCH] D159505: [lldb][AArch64] Add testing for SME's ZA and SVG registers

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556565.
DavidSpickett added a comment.

Rebase after changes to previous patch to arm64 regsets test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159505/new/

https://reviews.llvm.org/D159505

Files:
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/TestZAThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/main.c
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/TestZARegisterSaveRestore.py
  
lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c

Index: lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_za_register/za_save_restore/main.c
@@ -0,0 +1,226 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Important details for this program:
+// * Making a syscall will disable streaming mode if it is active.
+// * Changing the vector length will make streaming mode and ZA inactive.
+// * ZA can be active independent of streaming mode.
+// * ZA's size is the streaming vector length squared.
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#ifndef PR_SME_GET_VL
+#define PR_SME_GET_VL 64
+#endif
+
+#ifndef PR_SME_VL_LEN_MASK
+#define PR_SME_VL_LEN_MASK 0x
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART SM_INST(7)
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+#define SMSTOP SM_INST(6)
+#define SMSTOP_SM SM_INST(2)
+#define SMSTOP_ZA SM_INST(4)
+
+int start_vl = 0;
+int other_vl = 0;
+
+void write_sve_regs() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatile("cpy  z19.b, p15/z, #20\n\t");
+  asm volatile("cpy  z20.b, p0/z, #21\n\t");
+  asm volatile("cpy  z21.b, p5/z, #22\n\t");
+  asm volatile("cpy  z22.b, p10/z, #23\n\t");
+  asm volatile("cpy  z23.b, p15/z, #24\n\t");
+  asm volatile("cpy  z24.b, p0/z, #25\n\t");
+  asm volatile("cpy  z25.b, p5/z, #26\n\t");
+  asm volatile("cpy  z26.b, p10/z, #27\n\t");
+  asm volatile("cpy  z27.b, p15/z, #28\n\t");
+  asm volatile("cpy  z28.b, p0/z, #29\n\t");
+  asm volatile("cpy  z29.b, p5/z, #30\n\t");
+  asm volatile("cpy  z30.b, p10/z, #31\n\t");
+  asm volatile("cpy  z31.b, p15/z, #32\n\t");
+}
+
+// Write something different so we will know if we didn't restore them
+// correctly.
+void write_sve_regs_expr() {
+  asm volatile("pfalse p0.b\n\t");
+  asm volatile("wrffr p0.b\n\t");
+  asm volatile("pfalse p1.b\n\t");
+  asm volatile("pfalse p2.b\n\t");
+  asm volatile("pfalse p3.b\n\t");
+  asm volatile("ptrue p4.b\n\t");
+  asm volatile("pfalse p5.b\n\t");
+  asm volatile("pfalse p6.b\n\t");
+  asm volatile("pfalse p7.b\n\t");
+  asm volatile("pfalse p8.b\n\t");
+  asm volatile("ptrue p9.b\n\t");
+  asm volatile("pfalse p10.b\n\t");
+  asm volatile("pfalse p11.b\n\t");
+  asm volatile("pfalse p12.b\n\t"

[Lldb-commits] [PATCH] D159101: [RISC-V] Add RISC-V ABI plugin

2023-09-12 Thread Ted Woodward via Phabricator via lldb-commits
ted added a comment.

@DavidSpickett update on testing: I'm running tests. I found an issue in the IR 
Interpreter when calling class methods. Somehow a 32 bit pointer gets the upper 
32 bits in the 64 bit uint it's stored in set to 0x, which causes an 
assert. The assert should probably be an error, and not crash, but for now I'm 
skipping the tests that cause this. Progress is slow, but steady.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159101/new/

https://reviews.llvm.org/D159101

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D159101: [RISC-V] Add RISC-V ABI plugin

2023-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

> I can make this change here, but I wonder if it should be a separate change.

Sounds like bitness confusion, so yes it's worth making a patch for that. We 
don't test that scenario on the build bots but people do do this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159101/new/

https://reviews.llvm.org/D159101

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format Python files in scripts and utils (PR #66053)

2023-09-12 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Have (should we) we documented that we format all python code with black 
somewhere and how to install the tool?

https://github.com/llvm/llvm-project/pull/66053
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl review_requested 
https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-12 Thread via lldb-commits

jimingham wrote:

Excellent, thanks for chasing that logic down.  This is the correct solution, 
since we really do want `h` to mean `help` not just accidentally.

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-12 Thread via lldb-commits

jimingham wrote:

I don't see where you approve a PR in this UI but this is approved.


https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread via lldb-commits

jimingham wrote:

> > I don't think the lldb command line dumps raw JSON anywhere as a command 
> > result. Can we make something a little more human readable?
> 
> It was my idea to make this JSON. The problem is each debug info (.dwo and 
> DWARF in .o files for Mac) has very different fields and pretty printing 
> these items free form looked like it should be JSON. For DWO we have the 
> DW_AT_dwo_name, DW_AT_comp_dir, and DW_AT_dwo_id to display, and for OSO we 
> have .o file path + mod time. I wanted the ability to be able to parse the 
> output and use it in a script so the JSON was nice for that end game. It also 
> allows us to include this information in "statistics dump".
> 
> > BTW, the idea seems useful to me, but particularly if you're doing OSO you 
> > can get a whole lot of these so a space efficient presentation where you 
> > can scan the names easily, etc, will be important as well.
> 
> Maybe we can add an extra "flavor" to the JSON output, and then have a format 
> string for how the output can look akin to the "frame-format" that the 
> command would use by default? That would allow us to format the output in a 
> nice human readable way for the command output, and also add a --json option 
> to the command. The format string could use the "flavor" ("oso" or "dwo") to 
> format the output string as needed?

Emitting it as JSON seems a fine option for scripting.  If you know that this 
is an array of dictionaries with all the same keys (that's true for an given 
output, right?), it shouldn't be hard to write a generic "JSON -> table" 
routine to convert the output.  Having that driven by a format is an 
interesting idea, but you'd have to standardize the key values at least 
somewhat for that to be generally useful.

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread via lldb-commits


@@ -2005,9 +2021,10 @@ class CommandObjectTargetModulesDumpSymtab
 result.GetOutputStream().EOL();
 result.GetOutputStream().EOL();
   }
-  if (INTERRUPT_REQUESTED(GetDebugger(), 
+  if (INTERRUPT_REQUESTED(GetDebugger(),

jimingham wrote:

BTW, I don't really agree that reformatting whole files is a great idea.  
clang-format keeps changing it's mind on how it wants to lay out code, and so 
you just keep introducing little pointless changes that make history grubbing 
harder, etc, to very little benefit.

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] [lldb] Format Python files in scripts and utils (PR #66053)

2023-09-12 Thread Jim Ingham via lldb-commits
Is there any chance we can use something other than black.  I would never never 
write Python code that ugly.

Jim


> On Sep 12, 2023, at 8:47 AM, Adrian Prantl via lldb-commits 
>  wrote:
> 
> 
> adrian-prantl wrote:
> 
> Have (should we) we documented that we format all python code with black 
> somewhere and how to install the tool?
> 
> https://github.com/llvm/llvm-project/pull/66053
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format Python files in scripts and utils (PR #66053)

2023-09-12 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Have (should we) we documented that we format all python code with black 
> somewhere and how to install the tool?

https://llvm.org/docs/CodingStandards.html#python-version-and-source-code-formatting

https://github.com/llvm/llvm-project/pull/66053
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread Jim Ingham via lldb-commits
Not necessary for this review, but it might be nice to have a --missing or 
similar flag to this command that filters the output to only the ones that are 
missing.  Seems like a lot of the time I would want to use this command it 
would be to find missing dwo or oso files.

Jim


> On Sep 11, 2023, at 5:59 PM, Greg Clayton via lldb-commits 
>  wrote:
> 
> 
> clayborg wrote:
> 
> We also want to show the .dwo error or OSO error strings that explain why the 
> file wasn't loaded as we see when we do "frame variable" and the OSO or DWO 
> are missing. 
> 
> https://github.com/llvm/llvm-project/pull/66035
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format Python files in scripts and utils (PR #66053)

2023-09-12 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Oh nice! I was unsuccessfully looking in the LLDb subdir because I had assumed 
this was LLDB-specific!

https://github.com/llvm/llvm-project/pull/66053
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [AMDGPU] Port AMDGPURewriteUndefForPHI to new pass manager (PR #66008)

2023-09-12 Thread via lldb-commits

https://github.com/jwanggit86 updated 
https://github.com/llvm/llvm-project/pull/66008:

>From c68ad692f9d4c657f5dfaeb5d8c52c5331ebbb64 Mon Sep 17 00:00:00 2001
From: Jun Wang 
Date: Mon, 11 Sep 2023 15:25:42 -0500
Subject: [PATCH 1/2] [AMDGPU] Port AMDGPURewriteUndefForPHI to new pass
 manager

This patch ports the AMDGPURewriteUndefForPHI pass to the new pass
manager. With this, the pass is supported under both the legacy and
the new pass managers.
---
 llvm/lib/Target/AMDGPU/AMDGPU.h| 10 ++
 .../lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp | 14 ++
 llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp |  4 
 llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll  |  1 +
 4 files changed, 29 insertions(+)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 157a02ec31b2ec6..434943490caeab3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -291,6 +291,16 @@ FunctionPass *createAMDGPURewriteUndefForPHIPass();
 void initializeAMDGPURewriteUndefForPHIPass(PassRegistry &);
 extern char &AMDGPURewriteUndefForPHIPassID;
 
+class AMDGPURewriteUndefForPHIPass
+: public PassInfoMixin {
+private:
+  TargetMachine &TM;
+
+public:
+  AMDGPURewriteUndefForPHIPass(TargetMachine &TM) : TM(TM){};
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
 void initializeSIAnnotateControlFlowPass(PassRegistry&);
 extern char &SIAnnotateControlFlowPassID;
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp
index 9c07851243c9173..3e9625e954ea653 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp
@@ -177,6 +177,20 @@ bool AMDGPURewriteUndefForPHI::runOnFunction(Function &F) {
   return rewritePHIs(F, UA, DT);
 }
 
+PreservedAnalyses
+AMDGPURewriteUndefForPHIPass::run(Function &F, FunctionAnalysisManager &AM) {
+  UniformityInfo &UA = AM.getResult(F);
+  DominatorTree *DT = &AM.getResult(F);
+  bool Changed = rewritePHIs(F, UA, DT);
+  if (Changed) {
+PreservedAnalyses PA;
+PA.preserveSet();
+return PA;
+  }
+
+  return PreservedAnalyses::all();
+}
+
 FunctionPass *llvm::createAMDGPURewriteUndefForPHIPass() {
   return new AMDGPURewriteUndefForPHI();
 }
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 991681dafedaad1..befa036ee32df14 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -663,6 +663,10 @@ void 
AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
   PM.addPass(AMDGPULowerKernelArgumentsPass(*this));
   return true;
 }
+if (PassName == "amdgpu-rewrite-undef-for-phi") {
+  PM.addPass(AMDGPURewriteUndefForPHIPass(*this));
+  return true;
+}
 return false;
   });
 
diff --git a/llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll 
b/llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll
index c0f6c5ae0240a69..4f6b9f474c13171 100644
--- a/llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll
+++ b/llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -mtriple=amdgcn-- -S -amdgpu-rewrite-undef-for-phi %s | FileCheck 
-check-prefix=OPT %s
+; RUN: opt -mtriple=amdgcn-- -S -passes=amdgpu-rewrite-undef-for-phi %s | 
FileCheck -check-prefix=OPT %s
 
 define amdgpu_ps float @basic(float inreg %c, i32 %x) #0 {
 ; OPT-LABEL: @basic(

>From 15343db5c33e403c189b0f693a9332bcea60cf7b Mon Sep 17 00:00:00 2001
From: Jun Wang 
Date: Tue, 12 Sep 2023 13:13:43 -0500
Subject: [PATCH 2/2] [AMDGPU] Port AMDGPURewriteUndefForPHI to new pass
 manager

This patch ports the AMDGPURewriteUndefForPHI pass to the new pass
manager. With this, the pass is supported under both the legacy and
the new pass managers.
---
 llvm/lib/Target/AMDGPU/AMDGPU.h|  6 +++---
 .../Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp | 18 +-
 llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp |  4 ++--
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 434943490caeab3..6234c109969 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -287,9 +287,9 @@ extern char &AMDGPURemoveIncompatibleFunctionsID;
 void initializeAMDGPULateCodeGenPreparePass(PassRegistry &);
 extern char &AMDGPULateCodeGenPrepareID;
 
-FunctionPass *createAMDGPURewriteUndefForPHIPass();
-void initializeAMDGPURewriteUndefForPHIPass(PassRegistry &);
-extern char &AMDGPURewriteUndefForPHIPassID;
+FunctionPass *createAMDGPURewriteUndefForPHILegacyPass();
+void initializeAMDGPURewriteUndefForPHILegacyPass(PassRegistry &);
+extern char &AMDGPURewriteUndefForPHILegacyPassID;
 
 class AMDGPUR

[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-12 Thread Nishant Patel via lldb-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

nbpatel wrote:

the upstream GPUToLLVMConversion lowering does not support lowering of 
gpu.alloc which is not async? 
https://github.com/llvm/llvm-project/blob/main/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp#L797
 


https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-12 Thread Nishant Patel via lldb-commits

https://github.com/nbpatel edited 
https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156774: [lldb][DWARFASTParserClang] Resolve nested types when parsing structures

2023-09-12 Thread Vlad Serebrennikov via Phabricator via lldb-commits
Endill added a comment.

Ping @Michael137


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156774/new/

https://reviews.llvm.org/D156774

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-12 Thread Ronan Keryell via lldb-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

keryell wrote:

I guess that if the runtime uses actually synchronous allocation behind the 
scene and produces an always-ready async token, it works, even if non optimal.

https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-12 Thread Tom Yang via lldb-commits


@@ -2462,6 +2483,93 @@ class CommandObjectTargetModulesDumpLineTable
   CommandOptions m_options;
 };
 
+#pragma mark CommandObjectTargetModulesDumpSeparateDebugInfoFiles
+
+// Image debug dwo dumping command
+
+class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
+: public CommandObjectTargetModulesModuleAutoComplete {
+public:
+  CommandObjectTargetModulesDumpSeparateDebugInfoFiles(
+  CommandInterpreter &interpreter)
+  : CommandObjectTargetModulesModuleAutoComplete(
+interpreter, "target modules dump separate-debug-info",
+"Dump the separate debug info symbol files for one or more target "
+"modules.",
+//"target modules dump separate-debug-info [ ...]")

zhyty wrote:

I was following the pattern I noticed for some of the other classes like 
`CommandObjectTargetModulesDumpSections` where they add the help message as a 
comment. I don't mind removing it though, since it doesn't seem like *all* of 
the classes do it.

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-12 Thread Guray Ozen via lldb-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

grypp wrote:

> the upstream GPUToLLVMConversion lowering does not support lowering of 
> gpu.alloc which is not async.

Would that work if omit that check when `host_shared` is present? 




https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156774: [lldb][DWARFASTParserClang] Resolve nested types when parsing structures

2023-09-12 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

In D156774#4644503 , @Endill wrote:

> Ping @Michael137

Sorry for the delay, just came back from vacation

The change itself LGTM. Can we add a test though? We do have 
DWARFASTParserClang unittests: 
https://github.com/llvm/llvm-project/blob/main/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp

If the yaml input file becomes tedious to write you could also just an API 
test. E.g., under 
https://github.com/llvm/llvm-project/tree/main/lldb/test/API/lang/cpp

Let me know if you need some pointers in writing the tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156774/new/

https://reviews.llvm.org/D156774

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156774: [lldb][DWARFASTParserClang] Resolve nested types when parsing structures

2023-09-12 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

Also, I assume the extra changes to make the PointerIntPair formatter work will 
be in a follow-up patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156774/new/

https://reviews.llvm.org/D156774

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/66144:

This exposes the `eBroadcastBitSymbolChange` bit to the SB API to show when a 
symbol change event has been broadcast as this wasn't being done before. Also 
refactors `eBroadcastSymbolChange` to `eBroadcastBitSymbolChange` to match the 
naming convention for other event bits used in the debugger.

>From 1a544b9085c3a643b4880b239161fe6ed777fc71 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 12 Sep 2023 13:49:50 -0700
Subject: [PATCH] [lldb][Commands] Show symbol change bit in SB API

This exposes the `eBroadcastBitSymbolChange` bit to the SB
API to show when a symbol change event has been broadcast as
this wasn't being done before. Also refactors `eBroadcastSymbolChange`
to `eBroadcastBitSymbolChange` to match the naming convention
for other event bits used in the debugger.
---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Core/Debugger.h |  2 +-
 lldb/source/Commands/CommandObjectTarget.cpp  |  4 
 lldb/source/Core/Debugger.cpp |  4 ++--
 .../add-dsym/uuid/TestAddDsymCommand.py   | 24 +++
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 29cf2c16fad4bd7..abb08e93d197a18 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -46,6 +47,7 @@ class LLDB_API SBDebugger {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
+  eBroadcastBitSymbolChange = (1 << 3),
   };
 
   SBDebugger();
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 5532cace606bfed..6cdf1a183b18e54 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -83,7 +83,7 @@ class Debugger : public 
std::enable_shared_from_this,
 eBroadcastBitProgress = (1 << 0),
 eBroadcastBitWarning = (1 << 1),
 eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
+eBroadcastBitSymbolChange = (1 << 3),
   };
 
   using DebuggerList = std::vector;
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 3e024ff91b382d7..8051b3826294ab3 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4504,6 +4504,10 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
   if (process)
 process->Flush();
 }
+
+if (result.Succeeded())
+  Debugger::ReportSymbolChange(module_spec);
+
 return result.Succeeded();
   }
 
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 7ec1efc64fe9383..924741f45040bf0 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1536,7 +1536,7 @@ void Debugger::ReportSymbolChange(const ModuleSpec 
&module_spec) {
 std::lock_guard guard(*g_debugger_list_mutex_ptr);
 for (DebuggerSP debugger_sp : *g_debugger_list_ptr) {
   EventSP event_sp = std::make_shared(
-  Debugger::eBroadcastSymbolChange,
+  Debugger::eBroadcastBitSymbolChange,
   new SymbolChangeEventData(debugger_sp, module_spec));
   debugger_sp->GetBroadcaster().BroadcastEvent(event_sp);
 }
@@ -1844,7 +1844,7 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
 
   listener_sp->StartListeningForEvents(
   &m_broadcaster, eBroadcastBitProgress | eBroadcastBitWarning |
-  eBroadcastBitError | eBroadcastSymbolChange);
+  eBroadcastBitError | eBroadcastBitSymbolChange);
 
   // Let the thread that spawned us know that we have started up and that we
   // are now listening to all required events so no events get missed
diff --git a/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py 
b/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
index d16ca32d79e6808..1d7caf3122dcccb 100644
--- a/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
+++ b/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
@@ -57,6 +57,30 @@ def test_add_dsym_with_dSYM_bundle(self):
 self.exe_name = "a.out"
 self.do_add_dsym_with_dSYM_bundle(self.exe_name)
 
+@no_debug_info_test
+def test_report_symbol_change(self):
+"""Test that when adding a symbol file, the eBroadcastBitSymbolChange 
event gets broadcasted."""
+self.generate_main_cpp(version=1)
+self.build(debug_info="dsym")
+
+self.exe_name = "a.out"
+
+# Get the broadcaster and listen for the symbol change event
+self.broadcaster = self.dbg.GetBroadcaster()
+self.liste

[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova review_requested 
https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread via lldb-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb


Changes
This exposes the `eBroadcastBitSymbolChange` bit to the SB API to show when a 
symbol change event has been broadcast as this wasn't being done before. Also 
refactors `eBroadcastSymbolChange` to `eBroadcastBitSymbolChange` to match the 
naming convention for other event bits used in the debugger.
--
Full diff: https://github.com/llvm/llvm-project/pull/66144.diff

5 Files Affected:

- (modified) lldb/include/lldb/API/SBDebugger.h (+2) 
- (modified) lldb/include/lldb/Core/Debugger.h (+1-1) 
- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+4) 
- (modified) lldb/source/Core/Debugger.cpp (+2-2) 
- (modified) lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py (+24) 



diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 29cf2c16fad4bd7..abb08e93d197a18 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -46,6 +47,7 @@ class LLDB_API SBDebugger {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
+  eBroadcastBitSymbolChange = (1 << 3),
   };
 
   SBDebugger();
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 5532cace606bfed..6cdf1a183b18e54 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -83,7 +83,7 @@ class Debugger : public 
std::enable_shared_from_this,
 eBroadcastBitProgress = (1 << 0),
 eBroadcastBitWarning = (1 << 1),
 eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
+eBroadcastBitSymbolChange = (1 << 3),
   };
 
   using DebuggerList = std::vector;
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 3e024ff91b382d7..8051b3826294ab3 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4504,6 +4504,10 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
   if (process)
 process->Flush();
 }
+
+if (result.Succeeded())
+  Debugger::ReportSymbolChange(module_spec);
+
 return result.Succeeded();
   }
 
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 7ec1efc64fe9383..924741f45040bf0 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1536,7 +1536,7 @@ void Debugger::ReportSymbolChange(const ModuleSpec 
&module_spec) {
 std::lock_guard 
guard(*g_debugger_list_mutex_ptr);
 for (DebuggerSP debugger_sp : *g_debugger_list_ptr) {
   EventSP event_sp = std::make_shared(
-  Debugger::eBroadcastSymbolChange,
+  Debugger::eBroadcastBitSymbolChange,
   new SymbolChangeEventData(debugger_sp, module_spec));
   debugger_sp->GetBroadcaster().BroadcastEvent(event_sp);
 }
@@ -1844,7 +1844,7 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
 
   listener_sp->StartListeningForEvents(
   &m_broadcaster, eBroadcastBitProgress | eBroadcastBitWarning |
-  eBroadcastBitError | eBroadcastSymbolChange);
+  eBroadcastBitError | eBroadcastBitSymbolChange);
 
   // Let the thread that spawned us know that we have started up and that we
   // are now listening to all required events so no events get missed
diff --git a/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py 
b/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
index d16ca32d79e6808..1d7caf3122dcccb 100644
--- a/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
+++ b/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
@@ -57,6 +57,30 @@ def test_add_dsym_with_dSYM_bundle(self):
 self.exe_name = "a.out"
 self.do_add_dsym_with_dSYM_bundle(self.exe_name)
 
+@no_debug_info_test
+def test_report_symbol_change(self):
+"""Test that when adding a symbol file, the 
eBroadcastBitSymbolChange event gets broadcasted."""
+self.generate_main_cpp(version=1)
+self.build(debug_info="dsym")
+
+self.exe_name = "a.out"
+
+# Get the broadcaster and listen for the symbol change event
+self.broadcaster = self.dbg.GetBroadcaster()
+self.listener = lldbutil.start_listening_from(
+self.broadcaster, lldb.SBDebugger.eBroadcastBitSymbolChange
+)
+
+# Add the dSYM
+self.do_add_dsym_with_success(self.exe_name)
+
+# Get the next event
+event = lldbutil.fetch_next_event(self, self.listener, 
self.broadcaster)
+
+# Check that the event is valid
+self.assertTrue(event.IsValid(), "Got a valid event.")
+
+

[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Jonas Devlieghere via lldb-commits


@@ -57,6 +57,30 @@ def test_add_dsym_with_dSYM_bundle(self):
 self.exe_name = "a.out"
 self.do_add_dsym_with_dSYM_bundle(self.exe_name)
 
+@no_debug_info_test
+def test_report_symbol_change(self):
+"""Test that when adding a symbol file, the eBroadcastBitSymbolChange 
event gets broadcasted."""
+self.generate_main_cpp(version=1)
+self.build(debug_info="dsym")
+
+self.exe_name = "a.out"
+
+# Get the broadcaster and listen for the symbol change event
+self.broadcaster = self.dbg.GetBroadcaster()
+self.listener = lldbutil.start_listening_from(
+self.broadcaster, lldb.SBDebugger.eBroadcastBitSymbolChange
+)
+
+# Add the dSYM
+self.do_add_dsym_with_success(self.exe_name)
+
+# Get the next event
+event = lldbutil.fetch_next_event(self, self.listener, 
self.broadcaster)
+
+# Check that the event is valid
+self.assertTrue(event.IsValid(), "Got a valid event.")

JDevlieghere wrote:

"Got a valid eBroadcastBitSymbolChange event."

https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.


https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-09-12 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 01/10] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 
a/libcxx/test/libcxx/algorithms/ranges_robust_against_

[Lldb-commits] [lldb] [libc++] Implement ranges::contains (PR #65148)

2023-09-12 Thread via lldb-commits


@@ -0,0 +1,190 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsIt = requires(Iter iter, Sent sent) { 
std::ranges::contains(iter, sent, *iter); };
+
+static_assert(HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt, 
SentinelForNotSemiregular>);
+static_assert(!HasContainsIt, 
InputRangeNotSentinelEqualityComparableWith>);
+
+static_assert(!HasContainsIt);
+static_assert(!HasContainsIt);
+
+template 
+concept HasContainsR = requires(Range range) { std::ranges::contains(range, 
ValT{}); };
+
+static_assert(HasContainsR, int>);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR, 
NotEqualityComparable>);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+static_assert(!HasContainsR);
+
+static std::vector comparable_data;
+
+// clang-format off
+template 
+constexpr void test_iterators() {
+  using ValueT = std::iter_value_t;
+  {  // simple tests
+{
+  ValueT a[] = {1, 2, 3, 4, 5, 6};
+  std::same_as auto ret =
+std::ranges::contains(Iter(a), Sent(Iter(a + 6)), 3);
+  assert(ret);
+}
+{
+  ValueT a[] = {1, 2, 3, 4, 5, 6};
+  auto range = std::ranges::subrange(Iter(a), Sent(Iter(a + 6)));
+  std::same_as decltype(auto) ret =
+std::ranges::contains(range, 3);
+  assert(ret);
+}
+  }
+
+  { // check that an empty range works
+{
+  ValueT a[] = {};
+  auto ret = std::ranges::contains(Iter(a), Sent(Iter(a)), 1);
+  assert(!ret);
+}
+{
+  ValueT a[] = {};
+  auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+  auto ret = std::ranges::contains(range, 1);
+  assert(!ret);
+}
+  }
+
+  { // check that no match
+{
+  ValueT a[] = {13, 1, 21, 4, 5};
+  auto ret = std::ranges::contains(Iter(a), Sent(Iter(a + 5)), 10);
+  assert(!ret);
+}
+{
+  ValueT a[] = {13, 1, 21, 4, 5};
+  auto range = std::ranges::subrange(Iter(a), Sent(Iter(a + 5)));
+  auto ret = std::ranges::contains(range, 10);
+  assert(!ret);
+}
+  }
+
+  if (!std::is_constant_evaluated())
+comparable_data.clear();
+}
+template 
+class TriviallyComparable {
+  ElementT el_;
+
+public:
+  TEST_CONSTEXPR TriviallyComparable(ElementT el) : el_(el) {}
+  bool operator==(const TriviallyComparable&) const = default;
+};
+
+template 
+class Comparable {
+  IndexT index_;
+
+public:
+  Comparable(IndexT i)
+  : index_([&]() {
+  IndexT size = static_cast(comparable_data.size());
+  comparable_data.push_back(i);
+  return size;
+}()) {}
+
+  bool operator==(const Comparable& other) const {
+return comparable_data[other.index_] == comparable_data[index_];
+  }
+
+  friend bool operator==(const Comparable& lhs, long long rhs) { return 
comparable_data[lhs.index_] == rhs; }
+};
+
+constexpr bool test() {
+  types::for_each(types::type_list, TriviallyComparable>{},
+  [] {
+types::for_each(types::cpp20_input_iterator_list{}, 
+  [] {
+  if constexpr (std::forward_iterator)
+test_iterators();
+  test_iterators>();
+  test_iterators>();
+});
+  });
+
+  {
+// count invocations of the projection
+{
+  int a[] = {1, 9, 0, 13, 25};
+  int projection_count = 0;
+  auto ret = std::ranges::contains(a, a + 5, 0,
+[&](int i) { ++projection_count; return i; });
+  assert(ret);
+  assert(projection_count == 3);
+}
+{
+  int a[] ={1, 9, 0, 13, 25};
+  int projection_count = 0;
+  auto range = std::ranges::subrange(a, a + 5);
+  auto ret = std::ranges::contains(range, 0, [&](int i) { 
++projection_count; return

[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Greg Clayton via lldb-commits


@@ -83,7 +83,7 @@ class Debugger : public 
std::enable_shared_from_this,
 eBroadcastBitProgress = (1 << 0),
 eBroadcastBitWarning = (1 << 1),
 eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
+eBroadcastBitSymbolChange = (1 << 3),

clayborg wrote:

This name led me to believe that a Symbol from a symbol table was changed, so 
it confused me just reading the code. Do we want this to be 
"eBroadcastBitSymbolFileAdded"?

https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Greg Clayton via lldb-commits

https://github.com/clayborg edited 
https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Greg Clayton via lldb-commits


@@ -46,6 +47,7 @@ class LLDB_API SBDebugger {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
+  eBroadcastBitSymbolChange = (1 << 3),

clayborg wrote:

See comment below about possible name change to "eBroadcastBitSymbolFileAdded"

https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

We should be able to extract the SBModuleSpec from the event in response to the 
eBroadcastBitSymbolChange event. This will require adding a static method to 
SBDebugger.h/.cpp to get the SBModuleSpec from the event:
```
  static lldb::SBModuleSpec
  GetModuleSpecFromEvent(const lldb::SBEvent &event);
```
You are passing a module specification to the Debugger::ReportSymbolChange(), 
so it should be easy to package this into a custom event and extract the data. 
Plenty of example of extracting data from events in SBDebugger, SBTarget and 
SBProcess

https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Greg Clayton via lldb-commits


@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"

clayborg wrote:

This isn't needed in the header file right? Move to SBDebugger.cpp if it is 
still needed? No mention of SBStructuredData in SBDebugger.h

https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/66144:

>From 8754d93a72bdff94f95f991d9bf1112e5f9fe692 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 12 Sep 2023 13:49:50 -0700
Subject: [PATCH] [lldb][Commands] Show symbol change bit in SB API

This exposes the `eBroadcastBitSymbolChange` bit to the SB
API to show when a symbol change event has been broadcast as
this wasn't being done before. Also refactors `eBroadcastSymbolChange`
to `eBroadcastBitSymbolChange` to match the naming convention
for other event bits used in the debugger.
---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Core/Debugger.h |  2 +-
 lldb/source/Commands/CommandObjectTarget.cpp  |  4 
 lldb/source/Core/Debugger.cpp |  4 ++--
 .../add-dsym/uuid/TestAddDsymCommand.py   | 24 +++
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 29cf2c16fad4bd7..abb08e93d197a18 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -46,6 +47,7 @@ class LLDB_API SBDebugger {
   eBroadcastBitProgress = (1 << 0),
   eBroadcastBitWarning = (1 << 1),
   eBroadcastBitError = (1 << 2),
+  eBroadcastBitSymbolChange = (1 << 3),
   };
 
   SBDebugger();
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 5532cace606bfed..6cdf1a183b18e54 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -83,7 +83,7 @@ class Debugger : public 
std::enable_shared_from_this,
 eBroadcastBitProgress = (1 << 0),
 eBroadcastBitWarning = (1 << 1),
 eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
+eBroadcastBitSymbolChange = (1 << 3),
   };
 
   using DebuggerList = std::vector;
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 3e024ff91b382d7..8051b3826294ab3 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4504,6 +4504,10 @@ class CommandObjectTargetSymbolsAdd : public 
CommandObjectParsed {
   if (process)
 process->Flush();
 }
+
+if (result.Succeeded())
+  Debugger::ReportSymbolChange(module_spec);
+
 return result.Succeeded();
   }
 
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 7ec1efc64fe9383..924741f45040bf0 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1536,7 +1536,7 @@ void Debugger::ReportSymbolChange(const ModuleSpec 
&module_spec) {
 std::lock_guard guard(*g_debugger_list_mutex_ptr);
 for (DebuggerSP debugger_sp : *g_debugger_list_ptr) {
   EventSP event_sp = std::make_shared(
-  Debugger::eBroadcastSymbolChange,
+  Debugger::eBroadcastBitSymbolChange,
   new SymbolChangeEventData(debugger_sp, module_spec));
   debugger_sp->GetBroadcaster().BroadcastEvent(event_sp);
 }
@@ -1844,7 +1844,7 @@ lldb::thread_result_t Debugger::DefaultEventHandler() {
 
   listener_sp->StartListeningForEvents(
   &m_broadcaster, eBroadcastBitProgress | eBroadcastBitWarning |
-  eBroadcastBitError | eBroadcastSymbolChange);
+  eBroadcastBitError | eBroadcastBitSymbolChange);
 
   // Let the thread that spawned us know that we have started up and that we
   // are now listening to all required events so no events get missed
diff --git a/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py 
b/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
index d16ca32d79e6808..01b7d41f85c1185 100644
--- a/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
+++ b/lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
@@ -57,6 +57,30 @@ def test_add_dsym_with_dSYM_bundle(self):
 self.exe_name = "a.out"
 self.do_add_dsym_with_dSYM_bundle(self.exe_name)
 
+@no_debug_info_test
+def test_report_symbol_change(self):
+"""Test that when adding a symbol file, the eBroadcastBitSymbolChange 
event gets broadcasted."""
+self.generate_main_cpp(version=1)
+self.build(debug_info="dsym")
+
+self.exe_name = "a.out"
+
+# Get the broadcaster and listen for the symbol change event
+self.broadcaster = self.dbg.GetBroadcaster()
+self.listener = lldbutil.start_listening_from(
+self.broadcaster, lldb.SBDebugger.eBroadcastBitSymbolChange
+)
+
+# Add the dSYM
+self.do_add_dsym_with_success(self.exe_name)
+
+# Get the next event
+event = lldbutil.fetch_next_event(self, self.listener, 
se

[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Chelsea Cassanova via lldb-commits


@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"

chelcassanova wrote:

Correct, I left this in here by mistake.

https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix a bug with cancelling "attach -w" after you have run a process previously (PR #65822)

2023-09-12 Thread Greg Clayton via lldb-commits

clayborg wrote:

> It seems a bit weird to have an Execution context with a thread and a stack 
> frame but not the process they belong to. I don't know that it would really 
> help either. Even if you removed the process so that you no longer had to 
> check for that being invalid, if a thread or frame had been set in the 
> execution context, you'd still have to check for them being from the wrong 
> process. So I don't think we would made things significantly simpler by 
> leaving out the process. I think it's easier to deal with it when we hand 
> them out. Jim

Or we can have ExecutionContext have a single element so that it is always 
correct:
```
ExecutionContext {
...
   std::shared_ptr m_exe_scope_sp;
```
Since target, proces, thread and frames all inherit from ExecutionContextScope, 
all we need to do is store one item. The ExecutionContextScope API has:
```
  virtual lldb::TargetSP CalculateTarget() = 0;
  virtual lldb::ProcessSP CalculateProcess() = 0;
  virtual lldb::ThreadSP CalculateThread() = 0;
  virtual lldb::StackFrameSP CalculateStackFrame() = 0;
```
So then everything would always be correct.


https://github.com/llvm/llvm-project/pull/65822
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Jonas Devlieghere via lldb-commits


@@ -83,7 +83,7 @@ class Debugger : public 
std::enable_shared_from_this,
 eBroadcastBitProgress = (1 << 0),
 eBroadcastBitWarning = (1 << 1),
 eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
+eBroadcastBitSymbolChange = (1 << 3),

JDevlieghere wrote:

If we change the name of the broadcast bit, we should also rename the 
`SymbolChangeEventData`. 

https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 6412258 - [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (#66001)

2023-09-12 Thread via lldb-commits

Author: Alex
Date: 2023-09-12T15:32:06-07:00
New Revision: 64122580c0809fc6fc15bd955fea4e9ace80a135

URL: 
https://github.com/llvm/llvm-project/commit/64122580c0809fc6fc15bd955fea4e9ace80a135
DIFF: 
https://github.com/llvm/llvm-project/commit/64122580c0809fc6fc15bd955fea4e9ace80a135.diff

LOG: [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data 
(#66001)

Instead of creating a copy of the vector, we should just pass a
reference along. The only method that calls this Ctor also holds onto a
non-mutable reference to the vector of strings so a copy should be
unnecessary.

Added: 


Modified: 
lldb/include/lldb/Breakpoint/BreakpointResolverName.h
lldb/source/Breakpoint/BreakpointResolverName.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
index 7a9fc466076799a..cbfcbc9af0ea1cb 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -38,7 +38,7 @@ class BreakpointResolverName : public BreakpointResolver {
 
   // This one takes a C++ array of names.  It is always MatchType = Exact.
   BreakpointResolverName(const lldb::BreakpointSP &bkpt,
- std::vector names,
+ const std::vector &names,
  lldb::FunctionNameType name_type_mask,
  lldb::LanguageType language, lldb::addr_t offset,
  bool skip_prologue);

diff  --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp 
b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index b533bdfb9c11ce5..861377a5ddabfb5 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -56,12 +56,10 @@ BreakpointResolverName::BreakpointResolverName(
   }
 }
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
-   std::vector names,
-   FunctionNameType name_type_mask,
-   LanguageType language,
-   lldb::addr_t offset,
-   bool skip_prologue)
+BreakpointResolverName::BreakpointResolverName(
+const BreakpointSP &bkpt, const std::vector &names,
+FunctionNameType name_type_mask, LanguageType language, lldb::addr_t 
offset,
+bool skip_prologue)
 : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
   m_match_type(Breakpoint::Exact), m_language(language),
   m_skip_prologue(skip_prologue) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (PR #66001)

2023-09-12 Thread via lldb-commits

https://github.com/bulbazord closed 
https://github.com/llvm/llvm-project/pull/66001
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Jonas Devlieghere via lldb-commits


@@ -83,7 +83,7 @@ class Debugger : public 
std::enable_shared_from_this,
 eBroadcastBitProgress = (1 << 0),
 eBroadcastBitWarning = (1 << 1),
 eBroadcastBitError = (1 << 2),
-eBroadcastSymbolChange = (1 << 3),
+eBroadcastBitSymbolChange = (1 << 3),

JDevlieghere wrote:

Should it be `SymbolFileAdded` or `SymbolFileChanged`? You can (re)load a 
symbol file, which is something I've done with the JSON symbol file format. 

https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix a bug with cancelling "attach -w" after you have run a process previously (PR #65822)

2023-09-12 Thread Greg Clayton via lldb-commits

clayborg wrote:

So if we use the ExecutionContextScope and init a ExectionContext with a 
target, it can calculate the process and target. If you init it with a thread, 
it can calculate the thread, process and target. And if you init it with a 
frame, it can get the frame, thread, process and target. 

https://github.com/llvm/llvm-project/pull/65822
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-09-12 Thread via lldb-commits

https://github.com/pizzud updated 
https://github.com/llvm/llvm-project/pull/66139:

>From b699129b21c95571410a809d16fdf8cfcf1526c5 Mon Sep 17 00:00:00 2001
From: David Pizzuto 
Date: Tue, 12 Sep 2023 13:24:48 -0700
Subject: [PATCH 1/2] [clang-tidy] Add performance-move-smart-pointer-contents
 check.

This check detects moves of the contents of a smart pointer as opposed to the
smart pointer itself. For unique_ptr this is a performance issue, as the 
underlying
type is presumably not cheap to move, but for shared_ptr it's actually dangerous
as other code that also has access to the shared_ptr is probably not expecting 
the
move.

The set of "unique" and "shared" pointer classes are configurable via options to
allow individual projects to add additional classes of each type.
---
 .../clang-tidy/performance/CMakeLists.txt |   1 +
 .../MoveSmartPointerContentsCheck.cpp |  80 
 .../MoveSmartPointerContentsCheck.h   |  39 ++
 .../performance/PerformanceTidyModule.cpp |   3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   5 +
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../move-smart-pointer-contents.rst   |  23 
 .../move-smart-pointer-contents.cpp   | 119 ++
 8 files changed, 271 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/performance/move-smart-pointer-contents.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/performance/move-smart-pointer-contents.cpp

diff --git a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
index 81128ff086021ed..35435a951c0717b 100644
--- a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
@@ -14,6 +14,7 @@ add_clang_library(clangTidyPerformanceModule
   InefficientVectorOperationCheck.cpp
   MoveConstArgCheck.cpp
   MoveConstructorInitCheck.cpp
+  MoveSmartPointerContentsCheck.cpp
   NoAutomaticMoveCheck.cpp
   NoIntToPtrCheck.cpp
   NoexceptDestructorCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.cpp
new file mode 100644
index 000..8c1170641e5c718
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.cpp
@@ -0,0 +1,80 @@
+//===--- MoveSmartPointerContentsCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+
+#include "MoveSmartPointerContentsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+MoveSmartPointerContentsCheck::MoveSmartPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  UniquePointerClasses(utils::options::parseStringList(
+  Options.get("UniquePointerClasses", "std::unique_ptr"))),
+  IsAUniquePointer(namedDecl(hasAnyName(UniquePointerClasses))),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))),
+  IsASharedPointer(namedDecl(hasAnyName(SharedPointerClasses))) {}
+
+void MoveSmartPointerContentsCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "UniquePtrClasses",
+utils::options::serializeStringList(UniquePointerClasses));
+  Options.store(Opts, "SharedPtrClasses",
+utils::options::serializeStringList(SharedPointerClasses));
+}
+
+void MoveSmartPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(hasName("std::move"))),
+  hasArgument(0, cxxOperatorCallExpr(hasOperatorName("*"),
+ 
hasDeclaration(cxxMethodDecl(ofClass(IsAUniquePointer.bind("unique_op")))   
+  .bind("unique_call"),
+  this);
+
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(hasName("std::move"))),
+  hasArgument(0, cxxOperatorCallExpr(hasOperatorName("*"),
+ 
hasDeclaration(cxxMethodDecl(ofClass(IsASharedPointer.bind("shared_op")))   
+  .bind("shared_call"),
+  this);
+}
+  
+void MoveSmartPointerCon

[Lldb-commits] [lldb] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-09-12 Thread via lldb-commits


@@ -0,0 +1,80 @@
+//===--- MoveSmartPointerContentsCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+
+#include "MoveSmartPointerContentsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+MoveSmartPointerContentsCheck::MoveSmartPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  UniquePointerClasses(utils::options::parseStringList(
+  Options.get("UniquePointerClasses", "std::unique_ptr"))),
+  IsAUniquePointer(namedDecl(hasAnyName(UniquePointerClasses))),

pizzud wrote:

Done.

https://github.com/llvm/llvm-project/pull/66139
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-09-12 Thread via lldb-commits


@@ -0,0 +1,80 @@
+//===--- MoveSmartPointerContentsCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+
+#include "MoveSmartPointerContentsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+MoveSmartPointerContentsCheck::MoveSmartPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  UniquePointerClasses(utils::options::parseStringList(
+  Options.get("UniquePointerClasses", "std::unique_ptr"))),
+  IsAUniquePointer(namedDecl(hasAnyName(UniquePointerClasses))),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))),
+  IsASharedPointer(namedDecl(hasAnyName(SharedPointerClasses))) {}
+
+void MoveSmartPointerContentsCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "UniquePtrClasses",
+utils::options::serializeStringList(UniquePointerClasses));
+  Options.store(Opts, "SharedPtrClasses",
+utils::options::serializeStringList(SharedPointerClasses));
+}
+
+void MoveSmartPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(

pizzud wrote:

Done.

https://github.com/llvm/llvm-project/pull/66139
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-09-12 Thread via lldb-commits

https://github.com/pizzud updated 
https://github.com/llvm/llvm-project/pull/66139:

>From b699129b21c95571410a809d16fdf8cfcf1526c5 Mon Sep 17 00:00:00 2001
From: David Pizzuto 
Date: Tue, 12 Sep 2023 13:24:48 -0700
Subject: [PATCH 1/3] [clang-tidy] Add performance-move-smart-pointer-contents
 check.

This check detects moves of the contents of a smart pointer as opposed to the
smart pointer itself. For unique_ptr this is a performance issue, as the 
underlying
type is presumably not cheap to move, but for shared_ptr it's actually dangerous
as other code that also has access to the shared_ptr is probably not expecting 
the
move.

The set of "unique" and "shared" pointer classes are configurable via options to
allow individual projects to add additional classes of each type.
---
 .../clang-tidy/performance/CMakeLists.txt |   1 +
 .../MoveSmartPointerContentsCheck.cpp |  80 
 .../MoveSmartPointerContentsCheck.h   |  39 ++
 .../performance/PerformanceTidyModule.cpp |   3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   5 +
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../move-smart-pointer-contents.rst   |  23 
 .../move-smart-pointer-contents.cpp   | 119 ++
 8 files changed, 271 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/performance/move-smart-pointer-contents.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/performance/move-smart-pointer-contents.cpp

diff --git a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
index 81128ff086021ed..35435a951c0717b 100644
--- a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
@@ -14,6 +14,7 @@ add_clang_library(clangTidyPerformanceModule
   InefficientVectorOperationCheck.cpp
   MoveConstArgCheck.cpp
   MoveConstructorInitCheck.cpp
+  MoveSmartPointerContentsCheck.cpp
   NoAutomaticMoveCheck.cpp
   NoIntToPtrCheck.cpp
   NoexceptDestructorCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.cpp
new file mode 100644
index 000..8c1170641e5c718
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/performance/MoveSmartPointerContentsCheck.cpp
@@ -0,0 +1,80 @@
+//===--- MoveSmartPointerContentsCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+
+#include "MoveSmartPointerContentsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+MoveSmartPointerContentsCheck::MoveSmartPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  UniquePointerClasses(utils::options::parseStringList(
+  Options.get("UniquePointerClasses", "std::unique_ptr"))),
+  IsAUniquePointer(namedDecl(hasAnyName(UniquePointerClasses))),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))),
+  IsASharedPointer(namedDecl(hasAnyName(SharedPointerClasses))) {}
+
+void MoveSmartPointerContentsCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "UniquePtrClasses",
+utils::options::serializeStringList(UniquePointerClasses));
+  Options.store(Opts, "SharedPtrClasses",
+utils::options::serializeStringList(SharedPointerClasses));
+}
+
+void MoveSmartPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(hasName("std::move"))),
+  hasArgument(0, cxxOperatorCallExpr(hasOperatorName("*"),
+ 
hasDeclaration(cxxMethodDecl(ofClass(IsAUniquePointer.bind("unique_op")))   
+  .bind("unique_call"),
+  this);
+
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(hasName("std::move"))),
+  hasArgument(0, cxxOperatorCallExpr(hasOperatorName("*"),
+ 
hasDeclaration(cxxMethodDecl(ofClass(IsASharedPointer.bind("shared_op")))   
+  .bind("shared_call"),
+  this);
+}
+  
+void MoveSmartPointerCon

[Lldb-commits] [lldb] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-09-12 Thread via lldb-commits

pizzud wrote:

> I don't see problem described by this check as an performance issue. For 
> example:
> 
> ```
> std::unique_ptr> ptr;
> std::vector local = std::move(*ptr);
> ```
> 
> No performance issue here, simply value may need to be moved, do not expect 
> that someone have to always keep object in unique_ptr, at some point it may 
> need to be moved/copied. And some types may be cheap to move.
> 
> As for std::shared_ptr, yes this could be a problem.
> 
> My suggestion is:
> 
> * Part related to moving object from a std::shared_ptr should be a 
> bugprone-moved-from-shared check (or some other name).
> * As for current check, I fear that it may cause lot of false-positives, and 
> basicly it should work only on "heavy" types,  but it could be hard to detect 
> such heavy types. But still I don't think why that part should be reduced to 
> just shared ptr, check that would detect std::move calls that are still 
> heavy, simply because moved class is above XYZ bytes in size.
> 

@martinboehme internally suggested putting this in the performance category; 
perhaps he has a more detailed rationale or some relevant thoughts?

> Fix provided by this check `*std::move(p)` is also questionable... Move will 
> still be called, and this check will still detect such issue, in that case 
> fix does not fix anything.

This check won't re-flag it (see the `correctUnique` and `correctShared` test 
cases)...but by applying this fix, bugprone-use-after-move will recognize the 
more standard idiom and can catch the issues it looks at. A pattern like 

```
void f() {
  std::unique_ptr p = ...;
  LargeProtocolBuffer m = std::move(*p);
  std::cout << p->some_method() << std::endl;
}
```

slipped through bugprone-use-after-move because it assumes the `*std::move()` 
pattern. Discussion internally led to this check being proposed.

https://github.com/llvm/llvm-project/pull/66139
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread via lldb-commits

jimingham wrote:

Okay, here's my understanding of what's going on here:

So what's going on here is that in order to support background fetching of 
dSYM's, there's a thread that calls dsymForUUID when someone tells it there's a 
binary with an unknown UUID, then when it gets the dSYM it needs to notify the 
system that the symbols for this module have changed.  It was inconvenient to 
call the Target::SymbolsDidLoad for all the targets from the background thread, 
so we instead made an event (eBroadcastSymbolChange, should be 
eBroadcastBitSymbolChange) whose whole reason for being is that its DoOnRemoval 
is the one that calls Target::SymbolsDidLoad, and then we can make a Listener 
that just polls continuously for this event.  It is just pulling and discarding 
the event to cause SymbolsDidLoad, so it is really an internal event, it should 
not be exposed to other clients.
Instead, what will happen is that then the Debugger::eBroadcastBitSymbolChange 
event gets pulled from the event queue, it will run through the targets and 
call their SymbolsDidLoad if they have the UUID that just got loaded.  
Target::SymbolsDidLoad will in turn broadcast a 
Target::eBroadcastBitSymbolsLoaded event, that's the public one, and is 
correctly going to the Target's involved.
I think the only things that need doing here are:

1. Debugger::eBroadcastBitSymbolChange should NOT be public, it's internal to 
lldb and not useful to clients.
2. We should either have a Target::SymbolsDidChange that does the same work as 
Target::SymbolsDidLoad but sends Target::eBroadcastBitSymbolsChanged, or pass a 
bool in for changed vrs. load and dispatch the right event based on that.








https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix a bug with cancelling "attach -w" after you have run a process previously (PR #65822)

2023-09-12 Thread via lldb-commits

jimingham wrote:

> > It seems a bit weird to have an Execution context with a thread and a stack 
> > frame but not the process they belong to. I don't know that it would really 
> > help either. Even if you removed the process so that you no longer had to 
> > check for that being invalid, if a thread or frame had been set in the 
> > execution context, you'd still have to check for them being from the wrong 
> > process. So I don't think we would made things significantly simpler by 
> > leaving out the process. I think it's easier to deal with it when we hand 
> > them out. Jim
> 
> Or we can have ExecutionContext have a single element so that it is always 
> correct:
> 
> ```
> ExecutionContext {
> ...
>std::shared_ptr m_exe_scope_sp;
> ```
> 
> Since target, proces, thread and frames all inherit from 
> ExecutionContextScope, all we need to do is store one item. The 
> ExecutionContextScope API has:
> 
> ```
>   virtual lldb::TargetSP CalculateTarget() = 0;
>   virtual lldb::ProcessSP CalculateProcess() = 0;
>   virtual lldb::ThreadSP CalculateThread() = 0;
>   virtual lldb::StackFrameSP CalculateStackFrame() = 0;
> ```
> 
> So then everything would always be correct.

The only time this will be incorrect in this way is if you make an execution 
context filling in the current target & process and then hold onto it over the 
process in the target changing.  Internally, we only hold onto execution 
context's while executing a command, and we return that to ourselves in the API 
I fixed.  So we really don't have to fix this anywhere else to solve actual 
problems.

This seems like a much wider ranging change than is required to fix this bug.  
I'm all for rethinking the 
ExecutionContextScope/ExecutionContext/ExecutionContextRef nexus, but I don't 
think that's a trivial rethink, and I don't have the time to undertake that 
right now.

https://github.com/llvm/llvm-project/pull/65822
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-09-12 Thread Congcong Cai via lldb-commits

https://github.com/HerrCai0907 requested changes to this pull request.

This check has some issue in my opinion, the semantic of `std::move(*p)` are 
not same as `*std::move(p)`

```c++
#include 
#include 
#include 

using std::unique_ptr;

void f1() {
  unique_ptr p{new std::string("demo")};
  std::cout << p.get() << " *p=" << *p << "\n";
  auto x = std::move(*p);
  std::cout << p.get() << " *p=" << *p << " x=" << x << "\n";
}

void f2() {
  unique_ptr p{new std::string("demo")};
  std::cout << p.get() << " *p=" << *p << "\n";
  auto x = *std::move(p);
  std::cout << p.get() << " *p=" << *p << " x=" << x << "\n";
}

int main() {
  std::cout << "std::move(*p)\n";
  f1();
  std::cout << "*std::move(p)\n";
  f2();
}
```

The output is 
```
std::move(*p)
0x60301b40 *p=demo
0x60301b40 *p= x=demo
*std::move(p)
0x60301b70 *p=demo
0x60301b70 *p=demo x=demo
```

In `*std::move(p)`, move constructor does not happen, it is same as *p.

https://github.com/llvm/llvm-project/pull/66139
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-09-12 Thread Congcong Cai via lldb-commits

https://github.com/HerrCai0907 edited 
https://github.com/llvm/llvm-project/pull/66139
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][Commands] Show symbol change bit in SB API (PR #66144)

2023-09-12 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova resolved 
https://github.com/llvm/llvm-project/pull/66144
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156774: [lldb][DWARFASTParserClang] Resolve nested types when parsing structures

2023-09-12 Thread Vlad Serebrennikov via Phabricator via lldb-commits
Endill added a comment.

In D156774#4644623 , @Michael137 
wrote:

> Also, I assume the extra changes to make the PointerIntPair formatter work 
> will be in a follow-up patch?

Yes. That work is not finished yet.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156774/new/

https://reviews.llvm.org/D156774

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits