[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread David CARLIER via lldb-commits

https://github.com/devnexen updated 
https://github.com/llvm/llvm-project/pull/79662

>From 7cfed8b3440d9257598fe94e02adc4d926692850 Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Fri, 26 Jan 2024 22:47:15 +
Subject: [PATCH] [lldb] checks beforehand if lldb can trace/attach a process
 on FreeBSD.

before having the generic EINVAL message, we check if the
`security.bsd.unprivileged_proc_debug` allows process debugging.

close #79634
---
 .../Process/FreeBSD/NativeProcessFreeBSD.cpp  | 39 ---
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
index 19e0986ace31ff..9c620e4807e344 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -48,20 +48,38 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");
+
+  if (proc_debug < 1)
+return Status(
+"process debug disabled by security.bsd.unprivileged_proc_debug oid");
+
+  return {};
+}
+
 // Public Static Methods
 
 llvm::Expected>
 NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo _info,
   NativeDelegate _delegate) {
   Log *log = GetLog(POSIXLog::Process);
-
   Status status;
+
   ::pid_t pid = ProcessLauncherPosixFork()
 .LaunchProcess(launch_info, status)
 .GetProcessId();
   LLDB_LOG(log, "pid = {0:x}", pid);
   if (status.Fail()) {
+auto error = CanTrace();
 LLDB_LOG(log, "failed to launch process: {0}", status);
+if (status.Fail())
+  return error.ToError();
 return status.ToError();
   }
 
@@ -392,8 +410,11 @@ Status NativeProcessFreeBSD::PtraceWrapper(int req, 
lldb::pid_t pid, void *addr,
   ret =
   ptrace(req, static_cast<::pid_t>(pid), static_cast(addr), data);
 
-  if (ret == -1)
-error.SetErrorToErrno();
+  if (ret == -1) {
+error = CanTrace();
+if (error.Success())
+  error.SetErrorToErrno();
+  }
 
   if (result)
 *result = ret;
@@ -707,8 +728,12 @@ Status NativeProcessFreeBSD::SetBreakpoint(lldb::addr_t 
addr, uint32_t size,
 Status NativeProcessFreeBSD::GetLoadedModuleFileSpec(const char *module_path,
  FileSpec _spec) {
   Status error = PopulateMemoryRegionCache();
-  if (error.Fail())
+  if (error.Fail()) {
+auto status = CanTrace();
+if (status.Fail())
+  return status;
 return error;
+  }
 
   FileSpec module_file_spec(module_path);
   FileSystem::Instance().Resolve(module_file_spec);
@@ -729,8 +754,12 @@ NativeProcessFreeBSD::GetFileLoadAddress(const 
llvm::StringRef _name,
  lldb::addr_t _addr) {
   load_addr = LLDB_INVALID_ADDRESS;
   Status error = PopulateMemoryRegionCache();
-  if (error.Fail())
+  if (error.Fail()) {
+auto status = CanTrace();
+if (status.Fail())
+  return status;
 return error;
+  }
 
   FileSpec file(file_name);
   for (const auto  : m_mem_region_cache) {

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread David CARLIER via lldb-commits

https://github.com/devnexen updated 
https://github.com/llvm/llvm-project/pull/79662

>From 746a6959e270b086184ce095b11eb4df691dc4c9 Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Fri, 26 Jan 2024 22:47:15 +
Subject: [PATCH] [lldb] checks beforehand if lldb can trace/attach a process
 on FreeBSD.

before having the generic EINVAL message, we check if the
`security.bsd.unprivileged_proc_debug` allows process debugging.

close #79634
---
 .../Process/FreeBSD/NativeProcessFreeBSD.cpp  | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
index 19e0986ace31ff..24726832fa4598 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -48,20 +48,38 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");
+
+  if (proc_debug < 1)
+return Status(
+"process debug disabled by security.bsd.unprivileged_proc_debug oid");
+
+  return {};
+}
+
 // Public Static Methods
 
 llvm::Expected>
 NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo _info,
   NativeDelegate _delegate) {
   Log *log = GetLog(POSIXLog::Process);
-
   Status status;
+
   ::pid_t pid = ProcessLauncherPosixFork()
 .LaunchProcess(launch_info, status)
 .GetProcessId();
   LLDB_LOG(log, "pid = {0:x}", pid);
   if (status.Fail()) {
+auto error = CanTrace();
 LLDB_LOG(log, "failed to launch process: {0}", status);
+if (status.Fail())
+  return error.ToError();
 return status.ToError();
   }
 
@@ -392,8 +410,11 @@ Status NativeProcessFreeBSD::PtraceWrapper(int req, 
lldb::pid_t pid, void *addr,
   ret =
   ptrace(req, static_cast<::pid_t>(pid), static_cast(addr), data);
 
-  if (ret == -1)
-error.SetErrorToErrno();
+  if (ret == -1) {
+error = CanTrace();
+if (error.Success())
+  error.SetErrorToErrno();
+  }
 
   if (result)
 *result = ret;

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread Alex Langford via lldb-commits


@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");

bulbazord wrote:

Thanks for the explanation. Consider my concerns addressed, don't let my 
"Requested Changes" block this from going in after another approval. :)

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


[Lldb-commits] [lldb] [lldb] Remove obsolete signBinary helper (PR #79656)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] 7595287 - [lldb] Remove obsolete signBinary helper (#79656)

2024-01-26 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-01-26T20:37:44-08:00
New Revision: 75952873036fc9989fcf12c526d1a2deaeef596a

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

LOG: [lldb] Remove obsolete signBinary helper (#79656)

On Darwin, the Makefile already (ad-hoc) signs everything it builds.
There's also no need to use lldb_codesign for this.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/dotest_args.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/CMakeLists.txt
lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
lldb/test/API/api/multiple-targets/TestMultipleTargets.py
lldb/test/API/api/multithreaded/TestMultithreaded.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index a639714480cf4eb..4393e0caacaab88 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -442,8 +442,6 @@ def parseOptionsAndInitTestdirs():
 os.path.realpath(os.path.abspath(x)) for x in args.args
 ]
 
-lldbtest_config.codesign_identity = args.codesign_identity
-
 
 def registerFaulthandler():
 try:

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 70a65078f1d3a88..e4de786ec054894 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -217,12 +217,6 @@ def create_parser():
 action="store_true",
 help="Leave logs/traces even for successful test runs (useful for 
creating reference log files during debugging.)",
 )
-group.add_argument(
-"--codesign-identity",
-metavar="Codesigning identity",
-default="lldb_codesign",
-help="The codesigning identity to use",
-)
 group.add_argument(
 "--build-dir",
 dest="test_build_dir",

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 3abc713398490e7..d944b09cbcc4720 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1543,14 +1543,6 @@ def buildProgram(self, sources, exe_name):
 d = {"CXX_SOURCES": sources, "EXE": exe_name}
 self.build(dictionary=d)
 
-def signBinary(self, binary_path):
-if sys.platform.startswith("darwin"):
-codesign_cmd = 'codesign --force --sign "%s" %s' % (
-lldbtest_config.codesign_identity,
-binary_path,
-)
-call(codesign_cmd, shell=True)
-
 def findBuiltClang(self):
 """Tries to find and use Clang from the build directory as the 
compiler (instead of the system compiler)."""
 paths_to_try = [

diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 0b63ffdb4bd9ae3..4e02112c29e4cd5 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -98,12 +98,6 @@ if(CMAKE_HOST_APPLE)
 set(LLDB_FRAMEWORK_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)
   endif()
 
-  # Use the same identity for testing
-  get_property(code_sign_identity_used GLOBAL PROPERTY 
LLDB_DEBUGSERVER_CODESIGN_IDENTITY)
-  if(code_sign_identity_used)
-list(APPEND LLDB_TEST_COMMON_ARGS_VAR --codesign-identity 
"${code_sign_identity_used}")
-  endif()
-
   if(LLDB_USE_SYSTEM_DEBUGSERVER)
 lldb_find_system_debugserver(system_debugserver_path)
 if(LLDB_BUILD_FRAMEWORK)

diff  --git 
a/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py 
b/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
index 77f146f7bcb0389..98f089377363494 100644
--- a/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
+++ b/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
@@ -18,7 +18,6 @@ def test_sb_command_return_object(self):
 self.driver_exe = self.getBuildArtifact("command-return-object")
 self.buildDriver("main.cpp", self.driver_exe)
 self.addTearDownHook(lambda: os.remove(self.driver_exe))
-self.signBinary(self.driver_exe)
 
 if self.TraceOn():
 print("Running test %s" % self.driver_exe)

diff  --git a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py 
b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
index 889784ccc60b634..15b2012eee13b6b 100644
--- a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -24,7 

[Lldb-commits] [flang] [compiler-rt] [llvm] [clang-tools-extra] [clang] [lld] [libcxxabi] [lldb] [mlir] [libcxx] [libc] [mlir][complex] Prevent underflow in complex.abs (PR #76316)

2024-01-26 Thread Kai Sasaki via lldb-commits

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread Ed Maste via lldb-commits

emaste wrote:

Thanks for picking this up -- I was starting to take a look but was sidetracked 
with a lot of yak shaving.

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread Ed Maste via lldb-commits


@@ -48,14 +48,36 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");
+
+  if (proc_debug < 1)
+return Status(
+"process debug disabled by security.bsd.unprivileged_proc_debug oid");
+
+  return {};
+}
+
 // Public Static Methods
 
 llvm::Expected>
 NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo _info,
   NativeDelegate _delegate) {
   Log *log = GetLog(POSIXLog::Process);
-
   Status status;
+
+  status = CanTrace();

emaste wrote:

I might suggest moving these checks into the Fail case below, avoiding the 
extra syscall that's not necessary in the common case. Also, we may have other 
cases we could start checking for.

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread Ed Maste via lldb-commits


@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");

emaste wrote:

It's had the current name for over 2 decades, 
https://github.com/freebsd/freebsd-src/commit/e409590d0e0e57c6ec37d95bcb9fa3728051ebb1

The sysctl existed prior to that with a different name; I didn't bother looking 
to see when that was introduced.

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


[Lldb-commits] [libcxx] [clang-tools-extra] [llvm] [clang] [libc] [lld] [lldb] intrinsic to generate a bfi instruction (PR #79655)

2024-01-26 Thread Rama Malladi via lldb-commits

RamaMalladiAWS wrote:

Unable to get Windows build target machine allocated. Will reattempt another 
submission.

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


[Lldb-commits] [libc] [lld] [lldb] [libcxx] [llvm] [clang] [clang-tools-extra] intrinsic to generate a bfi instruction (PR #79655)

2024-01-26 Thread Rama Malladi via lldb-commits

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {
+lldb.eArgTypeAddressOrExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeArchitecture : lldb.eArchitectureCompletion,
+lldb.eArgTypeBreakpointID : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointIDRange : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointName : lldb.eBreakpointNameCompletion,
+lldb.eArgTypeClassName : lldb.eSymbolCompletion,
+lldb.eArgTypeDirectoryName : lldb.eDiskDirectoryCompletion,
+lldb.eArgTypeExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeExpressionPath : lldb.eVariablePathCompletion,
+lldb.eArgTypeFilename : lldb.eDiskFileCompletion,
+lldb.eArgTypeFrameIndex : lldb.eFrameIndexCompletion,
+lldb.eArgTypeFunctionName : lldb.eSymbolCompletion,
+lldb.eArgTypeFunctionOrSymbol : 

[Lldb-commits] [libcxx] [clang-tools-extra] [lldb] [llvm] [lld] [libc] [clang] intrinsic to generate a bfi instruction (PR #79655)

2024-01-26 Thread Rama Malladi via lldb-commits

https://github.com/RamaMalladiAWS updated 
https://github.com/llvm/llvm-project/pull/79655

>From 96aba7076392fb7f7479ec3a313ced5cfb714f81 Mon Sep 17 00:00:00 2001
From: Ubuntu 
Date: Fri, 26 Jan 2024 18:56:32 +
Subject: [PATCH 1/2] intrinsic to generate a bfi instruction

---
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  3 +++
 .../Target/AArch64/AArch64ISelDAGToDAG.cpp| 13 
 llvm/lib/Target/AArch64/AArch64InstrInfo.td   |  8 
 llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll | 20 +++
 4 files changed, 44 insertions(+)
 create mode 100644 llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll

diff --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td 
b/llvm/include/llvm/IR/IntrinsicsAArch64.td
index 921e5b95ae03e8..9eb5154c95138f 100644
--- a/llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -855,6 +855,9 @@ def int_aarch64_crc32x  : 
DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llv
 [IntrNoMem]>;
 def int_aarch64_crc32cx : DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, 
llvm_i64_ty],
 [IntrNoMem]>;
+def int_aarch64_bfi : DefaultAttrsIntrinsic<
+[llvm_anyint_ty], [llvm_anyint_ty, llvm_anyint_ty, llvm_anyint_ty, 
llvm_anyint_ty],
+[IntrNoMem, ImmArg>, ImmArg>]>;
 }
 
 
//===--===//
diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
index 163ed520a8a677..1fe3f95d54d131 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
@@ -5230,6 +5230,19 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) {
 switch (IntNo) {
 default:
   break;
+case Intrinsic::aarch64_bfi: {
+  SDLoc DL(Node);
+  auto lsb = cast(Node->getOperand(3))->getZExtValue();
+  auto width = cast(Node->getOperand(4))->getZExtValue();
+  auto ImmR = (VT.getSizeInBits() - lsb) % VT.getSizeInBits();
+  auto ImmS = width - 1;
+  SDValue Ops[] = {Node->getOperand(1), Node->getOperand(2),
+   CurDAG->getConstant(ImmR, DL, VT),
+   CurDAG->getConstant(ImmS, DL, VT)};
+  unsigned Opc = (VT == MVT::i32) ? AArch64::BFMWri : AArch64::BFMXri;
+  CurDAG->SelectNodeTo(Node, Opc, VT, Ops);
+  return;
+}
 case Intrinsic::aarch64_tagp:
   SelectTagP(Node);
   return;
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 03baa7497615e3..afa911abad7982 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -2558,6 +2558,14 @@ def : Pat<(rotr GPR32:$Rn, (i64 imm0_31:$imm)),
 def : Pat<(rotr GPR64:$Rn, (i64 imm0_63:$imm)),
   (EXTRXrri GPR64:$Rn, GPR64:$Rn, imm0_63:$imm)>;
 
+def SDT_AArch64BFI_32bit : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisVT<1, 
i32>,
+SDTCisVT<2, i32>]>;
+def SDT_AArch64BFI_64bit : SDTypeProfile<1, 2, [SDTCisVT<0, i64>, SDTCisVT<1, 
i64>,
+SDTCisVT<2, i64>]>;
+
+def aarch64_bfiw  : SDNode<"AArch64::BFMWri",  SDT_AArch64BFI_32bit>;
+def aarch64_bfix  : SDNode<"AArch64::BFMXri",  SDT_AArch64BFI_64bit>;
+
 
//===--===//
 // Other bitfield immediate instructions.
 
//===--===//
diff --git a/llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll 
b/llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll
new file mode 100644
index 00..99b23fb1101d6c
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll
@@ -0,0 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-none-linux-gnu < %s -o -| FileCheck %s
+
+define i32 @f32(i32 %A, i32 %B) nounwind {
+; CHECK-NEXT:bfi r0, r1, #4, #2
+entry:
+  %tmp32 = call i32 @llvm.aarch64.bfi.i32(i32 %A, i32 %B, i32 4, i32 2)
+  ret i32 %tmp32
+}
+
+define i64 @f64(i64 %A, i64 %B) nounwind {
+; CHECK-NEXT:bfi r0, r1, #23, #8
+entry:
+  %tmp64 = call i64 @llvm.aarch64.bfi.i64(i64 %A, i64 %B, i64 23, i64 8)
+  ret i64 %tmp64
+}
+
+declare i32 @llvm.aarch64.bfi.i32(i32, i32, i32, i32)
+declare i64 @llvm.aarch64.bfi.i64(i64, i64, i64, i64)
+

>From d5e3ad3893b03fc6c5dc1d4648c004125ac0dd5c Mon Sep 17 00:00:00 2001
From: Rama Malladi <98832537+ramamalladi...@users.noreply.github.com>
Date: Fri, 26 Jan 2024 18:09:25 -0600
Subject: [PATCH 2/2] Update bfi-64-intrinsic.ll

---
 llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll 
b/llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll
index 99b23fb1101d6c..11ecde6b6fab20 100644
--- a/llvm/test/CodeGen/AArch64/bfi-64-intrinsic.ll
+++ 

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {

jimingham wrote:

The C++ side of the option specification needs work.  When you actually define 
an option on the C++ side, you give it an eArgType, but that doesn't actually 
wire up completions directly.  Instead, you have to also do that by hand.  So 
writing the C++ based commands in inconvenient, and would make writing ones in 
Python tedious as well.  I don't want people to have to get in the habit of 
manually doing that, so I am just providing this shim.  The change to get the 
ArgType -> completer working correctly is much more work, and mostly orthogonal 
to the main purpose of this patch.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.

jimingham wrote:

I still think exceptions would be an inconvenient way to do this.  These aren't 
API's that users are going to call directly, so we aren't matching expectations 
for Python function behavior.  Rather, in the middle of parsing a command from 
lldb (happening in C++) the command parser will arrange to have this called.  
So if it raises a Python exception, the LLDB SWIG wrappers will have to catch 
that exception and turn it into a Status with the error we want to report.  I 
think it would be much less fragile to just pipe an SBError through directly 
and use that for error reporting.

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


[Lldb-commits] [flang] [mlir] [llvm] [openmp] [lldb] [mlir][Vector] Add patterns for efficient i4 -> i8 conversion emulation (PR #79494)

2024-01-26 Thread Diego Caballero via lldb-commits

dcaballe wrote:

Thanks for the info! I think making the interleave op at Vector level available 
to fixed vectors would also make sense. There is a point in knowing that a 
shuffle is actually implementing an interleave pattern.

I guess we should also be fine with this LLVM limitations for now:
```
While this intrinsic supports all vector types the recommended way to express 
this operation for fixed-width vectors is still to use a shufflevector, as that 
may allow for more optimization opportunities.
```

Again, if looks like we are building a small ad-hoc backend in here. Ultimately 
we may want this to be properly supported in LLVM.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation

jimingham wrote:

I don't think your version is grammatical.  You use it (a) for your... and (b) 
to do X.  "for" doesn't work with the fetch verb form.  You could say "for your 
option definition and fetching"...
But I actually don't see what's unclear about this form.

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


[Lldb-commits] [flang] [lldb] [clang] [libcxxabi] [libc] [llvm] [compiler-rt] [lld] [clang-tools-extra] [libcxx] [llvm] Set emulated-tls by default for x86_64-windows-gnu target (PR #79542)

2024-01-26 Thread via lldb-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/79542

>From 1039a36b2891f72192e77f2ef96736b1ab4315d8 Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Thu, 25 Jan 2024 21:47:43 -0500
Subject: [PATCH] [llvm] set emulated-tls by default for MinGW

x86_64-windows-gnu target by default enables emulated-tls on gcc,
we should do the same
---
 llvm/include/llvm/TargetParser/Triple.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index 870dc75b1c1f80f..2452ee58e1e807e 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -1030,7 +1030,7 @@ class Triple {
   /// Note: Android API level 29 (10) introduced ELF TLS.
   bool hasDefaultEmulatedTLS() const {
 return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
-   isWindowsCygwinEnvironment() || isOHOSFamily();
+   isOSCygMing() || isOHOSFamily();
   }
 
   /// Tests whether the target uses TLS Descriptor by default.

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


[Lldb-commits] [mlir] [lldb] [compiler-rt] [lld] [llvm] [libc] [clang-tools-extra] [clang] [libcxx] Fix Multiple Build Errors on different platforms (PR #77216)

2024-01-26 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread David CARLIER via lldb-commits

https://github.com/devnexen updated 
https://github.com/llvm/llvm-project/pull/79662

>From 7fccec625677e8cabe8c69ac2651c37716dc30bf Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Fri, 26 Jan 2024 22:47:15 +
Subject: [PATCH] [lldb] checks beforehand if lldb can trace/attach a process
 on FreeBSD.

before having the generic EINVAL message, we check if the
`security.bsd.unprivileged_proc_debug` allows process debugging.

close #79634
---
 .../Process/FreeBSD/NativeProcessFreeBSD.cpp  | 28 ++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
index 19e0986ace31ff6..9692670e851c77a 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -48,14 +48,36 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");
+
+  if (proc_debug < 1)
+return Status(
+"process debug disabled by security.bsd.unprivileged_proc_debug oid");
+
+  return {};
+}
+
 // Public Static Methods
 
 llvm::Expected>
 NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo _info,
   NativeDelegate _delegate) {
   Log *log = GetLog(POSIXLog::Process);
-
   Status status;
+
+  status = CanTrace();
+
+  if (status.Fail()) {
+LLDB_LOG(log, "failed to launch process: {0}", status);
+return status.ToError();
+  }
+
   ::pid_t pid = ProcessLauncherPosixFork()
 .LaunchProcess(launch_info, status)
 .GetProcessId();
@@ -388,6 +410,10 @@ Status NativeProcessFreeBSD::PtraceWrapper(int req, 
lldb::pid_t pid, void *addr,
   Status error;
   int ret;
 
+  error = CanTrace();
+  if (error.Fail())
+return error;
+
   errno = 0;
   ret =
   ptrace(req, static_cast<::pid_t>(pid), static_cast(addr), data);

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread David CARLIER via lldb-commits


@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;

devnexen wrote:

true

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread David CARLIER via lldb-commits


@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");

devnexen wrote:

since a long time :) e.g. even 9.0, EOL since more than a decade, had it.

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


[Lldb-commits] [libcxx] [libunwind] [lldb] [clang] [llvm] [libc] [libunwind] Fix build for wasm (PR #79667)

2024-01-26 Thread via lldb-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/79667

>From 39bc0171e7c07e367446dd1abdc56fd918013a9d Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Fri, 26 Jan 2024 18:44:41 -0500
Subject: [PATCH 1/2] [libunwind] Fix build for wasm

The wasm unwind build appears to be dysfunctional, likely because the author 
has only supplied a customized LLVM build on request, rather than a fully 
functional patch.

This patch fixes the build
---
 libunwind/include/__libunwind_config.h |  1 +
 libunwind/src/CMakeLists.txt   | 53 +++---
 libunwind/src/Unwind-wasm.c| 16 
 libunwind/src/config.h |  2 +-
 4 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 8db336b2d727ce7..75e00a75b7e04bf 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -180,6 +180,7 @@
 #endif
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER  
\
   _LIBUNWIND_HIGHEST_DWARF_REGISTER_LOONGARCH
+# elif defined(__wasm__)
 # else
 #  error "Unsupported architecture."
 # endif
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 9c6f5d908b09454..cce76eea007f434 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -1,31 +1,38 @@
 # Get sources
 
-set(LIBUNWIND_CXX_SOURCES
-libunwind.cpp
-Unwind-EHABI.cpp
-Unwind-seh.cpp
-)
+if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "wasm32" OR
+  ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "wasm64")
+  set(LIBUNWIND_C_SOURCES
+  Unwind-wasm.c
+  )
+else()
+  set(LIBUNWIND_CXX_SOURCES
+  libunwind.cpp
+  Unwind-EHABI.cpp
+  Unwind-seh.cpp
+  )
+
+  if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+list(APPEND LIBUNWIND_CXX_SOURCES
+  Unwind_AIXExtras.cpp
+  )
+  endif()
 
-if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
-  list(APPEND LIBUNWIND_CXX_SOURCES
-Unwind_AIXExtras.cpp
-)
-endif()
+  set(LIBUNWIND_C_SOURCES
+  UnwindLevel1.c
+  UnwindLevel1-gcc-ext.c
+  Unwind-sjlj.c
+  )
 
-set(LIBUNWIND_C_SOURCES
-UnwindLevel1.c
-UnwindLevel1-gcc-ext.c
-Unwind-sjlj.c
-Unwind-wasm.c
-)
-set_source_files_properties(${LIBUNWIND_C_SOURCES}
-PROPERTIES
-  COMPILE_FLAGS "-std=c99")
+  set(LIBUNWIND_ASM_SOURCES
+  UnwindRegistersRestore.S
+  UnwindRegistersSave.S
+  )
 
-set(LIBUNWIND_ASM_SOURCES
-UnwindRegistersRestore.S
-UnwindRegistersSave.S
-)
+  set_source_files_properties(${LIBUNWIND_C_SOURCES}
+  PROPERTIES
+COMPILE_FLAGS "-std=c99")
+endif()
 
 set(LIBUNWIND_HEADERS
 AddressSpace.hpp
diff --git a/libunwind/src/Unwind-wasm.c b/libunwind/src/Unwind-wasm.c
index f7f39d38b59c181..87be87e9fd92a86 100644
--- a/libunwind/src/Unwind-wasm.c
+++ b/libunwind/src/Unwind-wasm.c
@@ -10,14 +10,11 @@
 //
 
//===--===//
 
+#if __STDC_VERSION__ < 202311L
 #include 
-
+#endif
 #include "config.h"
-
-#ifdef __USING_WASM_EXCEPTIONS__
-
 #include "unwind.h"
-#include 
 
 _Unwind_Reason_Code __gxx_personality_wasm0(int version, _Unwind_Action 
actions,
 uint64_t exceptionClass,
@@ -35,7 +32,12 @@ struct _Unwind_LandingPadContext {
 
 // Communication channel between compiler-generated user code and personality
 // function
-thread_local struct _Unwind_LandingPadContext __wasm_lpad_context;
+#if __STDC_VERSION__ >= 202311L
+thread_local
+#else
+_Thread_local
+#endif
+struct _Unwind_LandingPadContext __wasm_lpad_context;
 
 /// Calls to this function is in landing pads in compiler-generated user code.
 /// In other EH schemes, stack unwinding is done by libunwind library, which
@@ -119,5 +121,3 @@ _LIBUNWIND_EXPORT uintptr_t
 _Unwind_GetRegionStart(struct _Unwind_Context *context) {
   return 0;
 }
-
-#endif // defined(__USING_WASM_EXCEPTIONS__)
diff --git a/libunwind/src/config.h b/libunwind/src/config.h
index deb5a4d4d73d467..4cc32392aa72aff 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -66,7 +66,7 @@
   #define _LIBUNWIND_EXPORT
   #define _LIBUNWIND_HIDDEN
 #else
-  #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX)
+  #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX) && 
!defined(__wasm__) 
 #define _LIBUNWIND_EXPORT __declspec(dllexport)
 #define _LIBUNWIND_HIDDEN
   #else

>From 2a2d662dc1d831bc40133c7596eba44e058df1a8 Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Fri, 26 Jan 2024 18:58:28 -0500
Subject: [PATCH 2/2] [libunwind]  Apply formatting patch proposed by github
 bot

---
 libunwind/include/__libunwind_config.h |  2 +-
 libunwind/src/config.h | 15 ---
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git 

[Lldb-commits] [lldb] [lldb] Remove obsolete signBinary helper (PR #79656)

2024-01-26 Thread Alex Langford via lldb-commits

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

Makes sense to me.

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread Alex Langford via lldb-commits


@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");

bulbazord wrote:

How long has FreeBSD had `security.bsd.unprivileged_proc_debug`? If you're 
debugging an older FreeBSD system that does not have it, this will prevent it 
from debugging anything.

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread Alex Langford via lldb-commits


@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;

bulbazord wrote:

Suggestion: You can remove this and just return {} below.

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [libc] [libcxx] [clang] [llvm] [libunwind] [libunwind] Fix build for wasm (PR #79667)

2024-01-26 Thread via lldb-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/79667

>From 39bc0171e7c07e367446dd1abdc56fd918013a9d Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Fri, 26 Jan 2024 18:44:41 -0500
Subject: [PATCH] [libunwind] Fix build for wasm

The wasm unwind build appears to be dysfunctional, likely because the author 
has only supplied a customized LLVM build on request, rather than a fully 
functional patch.

This patch fixes the build
---
 libunwind/include/__libunwind_config.h |  1 +
 libunwind/src/CMakeLists.txt   | 53 +++---
 libunwind/src/Unwind-wasm.c| 16 
 libunwind/src/config.h |  2 +-
 4 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 8db336b2d727ce7..75e00a75b7e04bf 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -180,6 +180,7 @@
 #endif
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER  
\
   _LIBUNWIND_HIGHEST_DWARF_REGISTER_LOONGARCH
+# elif defined(__wasm__)
 # else
 #  error "Unsupported architecture."
 # endif
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 9c6f5d908b09454..cce76eea007f434 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -1,31 +1,38 @@
 # Get sources
 
-set(LIBUNWIND_CXX_SOURCES
-libunwind.cpp
-Unwind-EHABI.cpp
-Unwind-seh.cpp
-)
+if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "wasm32" OR
+  ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "wasm64")
+  set(LIBUNWIND_C_SOURCES
+  Unwind-wasm.c
+  )
+else()
+  set(LIBUNWIND_CXX_SOURCES
+  libunwind.cpp
+  Unwind-EHABI.cpp
+  Unwind-seh.cpp
+  )
+
+  if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+list(APPEND LIBUNWIND_CXX_SOURCES
+  Unwind_AIXExtras.cpp
+  )
+  endif()
 
-if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
-  list(APPEND LIBUNWIND_CXX_SOURCES
-Unwind_AIXExtras.cpp
-)
-endif()
+  set(LIBUNWIND_C_SOURCES
+  UnwindLevel1.c
+  UnwindLevel1-gcc-ext.c
+  Unwind-sjlj.c
+  )
 
-set(LIBUNWIND_C_SOURCES
-UnwindLevel1.c
-UnwindLevel1-gcc-ext.c
-Unwind-sjlj.c
-Unwind-wasm.c
-)
-set_source_files_properties(${LIBUNWIND_C_SOURCES}
-PROPERTIES
-  COMPILE_FLAGS "-std=c99")
+  set(LIBUNWIND_ASM_SOURCES
+  UnwindRegistersRestore.S
+  UnwindRegistersSave.S
+  )
 
-set(LIBUNWIND_ASM_SOURCES
-UnwindRegistersRestore.S
-UnwindRegistersSave.S
-)
+  set_source_files_properties(${LIBUNWIND_C_SOURCES}
+  PROPERTIES
+COMPILE_FLAGS "-std=c99")
+endif()
 
 set(LIBUNWIND_HEADERS
 AddressSpace.hpp
diff --git a/libunwind/src/Unwind-wasm.c b/libunwind/src/Unwind-wasm.c
index f7f39d38b59c181..87be87e9fd92a86 100644
--- a/libunwind/src/Unwind-wasm.c
+++ b/libunwind/src/Unwind-wasm.c
@@ -10,14 +10,11 @@
 //
 
//===--===//
 
+#if __STDC_VERSION__ < 202311L
 #include 
-
+#endif
 #include "config.h"
-
-#ifdef __USING_WASM_EXCEPTIONS__
-
 #include "unwind.h"
-#include 
 
 _Unwind_Reason_Code __gxx_personality_wasm0(int version, _Unwind_Action 
actions,
 uint64_t exceptionClass,
@@ -35,7 +32,12 @@ struct _Unwind_LandingPadContext {
 
 // Communication channel between compiler-generated user code and personality
 // function
-thread_local struct _Unwind_LandingPadContext __wasm_lpad_context;
+#if __STDC_VERSION__ >= 202311L
+thread_local
+#else
+_Thread_local
+#endif
+struct _Unwind_LandingPadContext __wasm_lpad_context;
 
 /// Calls to this function is in landing pads in compiler-generated user code.
 /// In other EH schemes, stack unwinding is done by libunwind library, which
@@ -119,5 +121,3 @@ _LIBUNWIND_EXPORT uintptr_t
 _Unwind_GetRegionStart(struct _Unwind_Context *context) {
   return 0;
 }
-
-#endif // defined(__USING_WASM_EXCEPTIONS__)
diff --git a/libunwind/src/config.h b/libunwind/src/config.h
index deb5a4d4d73d467..4cc32392aa72aff 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -66,7 +66,7 @@
   #define _LIBUNWIND_EXPORT
   #define _LIBUNWIND_HIDDEN
 #else
-  #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX)
+  #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX) && 
!defined(__wasm__) 
 #define _LIBUNWIND_EXPORT __declspec(dllexport)
 #define _LIBUNWIND_HIDDEN
   #else

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 8f1d94aaea5c18b83cd3b0df3be3a48ef1d3833d 
3b490d6ef73c7ab3e8e1985a2cb25bb72a2c -- 
lldb/unittests/Core/ProgressReportTest.cpp 
lldb/include/lldb/Core/DebuggerEvents.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/unittests/Core/ProgressReportTest.cpp 
b/lldb/unittests/Core/ProgressReportTest.cpp
index f62aeda341..71728b6f18 100644
--- a/lldb/unittests/Core/ProgressReportTest.cpp
+++ b/lldb/unittests/Core/ProgressReportTest.cpp
@@ -21,14 +21,14 @@ using namespace lldb;
 using namespace lldb_private;
 
 class ProgressReportTest : public ::testing::Test {
-SubsystemRAII subsystems;
-
-// The debugger's initialization function can't be called with no arguments
-// so calling it using SubsystemRAII will cause the test build to fail as
-// SubsystemRAII will call Initialize with no arguments. As such we set it 
up
-// here the usual way.
-void SetUp() override { Debugger::Initialize(nullptr); }
-void TearDown() override { Debugger::Terminate(); }
+  SubsystemRAII subsystems;
+
+  // The debugger's initialization function can't be called with no arguments
+  // so calling it using SubsystemRAII will cause the test build to fail as
+  // SubsystemRAII will call Initialize with no arguments. As such we set it up
+  // here the usual way.
+  void SetUp() override { Debugger::Initialize(nullptr); }
+  void TearDown() override { Debugger::Terminate(); }
 };
 
 TEST_F(ProgressReportTest, TestReportCreation) {
@@ -52,7 +52,7 @@ TEST_F(ProgressReportTest, TestReportCreation) {
   listener_sp->StartListeningForEvents(,
Debugger::eBroadcastBitProgress);
   EXPECT_TRUE(
-broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
 
   EventSP event_sp;
   const ProgressEventData *data;

``




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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits


@@ -39,7 +39,7 @@ class ProgressEventData : public EventData {
   GetAsStructuredData(const Event *event_ptr);
 
   uint64_t GetID() const { return m_id; }
-  bool IsFinite() const { return m_total != UINT64_MAX; }
+  bool IsFinite() const { return m_total != 1; }

chelcassanova wrote:

I have this here but let me know if it's better to have this in its own PR

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits

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

>From 9274bcd897cd3ecdb3a842bc72ee660ba335aa57 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 25 Jan 2024 16:40:42 -0800
Subject: [PATCH 1/3] [lldb][progress][NFC] Add unit test for progress reports

This test is being added as a way to check the behaviour of how progress
events are broadcasted when reports are started and ended with the
current implementation of progress reports. Here we're mainly checking
and ensuring that the current behaviour is that progress events are
broadcasted individually and placed in the event queue in order of
their creation.
---
 lldb/unittests/Core/CMakeLists.txt |   1 +
 lldb/unittests/Core/ProgressReportTest.cpp | 105 +
 2 files changed, 106 insertions(+)
 create mode 100644 lldb/unittests/Core/ProgressReportTest.cpp

diff --git a/lldb/unittests/Core/CMakeLists.txt 
b/lldb/unittests/Core/CMakeLists.txt
index b3cddd150635b1..d40c357e3f463b 100644
--- a/lldb/unittests/Core/CMakeLists.txt
+++ b/lldb/unittests/Core/CMakeLists.txt
@@ -7,6 +7,7 @@ add_lldb_unittest(LLDBCoreTests
   FormatEntityTest.cpp
   MangledTest.cpp
   ModuleSpecTest.cpp
+  ProgressReportTest.cpp
   RichManglingContextTest.cpp
   SourceLocationSpecTest.cpp
   SourceManagerTest.cpp
diff --git a/lldb/unittests/Core/ProgressReportTest.cpp 
b/lldb/unittests/Core/ProgressReportTest.cpp
new file mode 100644
index 00..bdc168c9e077dd
--- /dev/null
+++ b/lldb/unittests/Core/ProgressReportTest.cpp
@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, ));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster  = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");
+
+std::this_thread::sleep_for(timeout);
+  }
+
+  // Progress report objects should be destroyed at this point so
+  // get each report from the queue and check that they've been
+  // destroyed in reverse order
+  std::this_thread::sleep_for(timeout);
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  ASSERT_EQ(data->GetTitle(), "Progress report 3");
+  ASSERT_TRUE(data->GetCompleted());
+
+  std::this_thread::sleep_for(timeout);
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  ASSERT_EQ(data->GetTitle(), "Progress report 2");
+  ASSERT_TRUE(data->GetCompleted());
+
+  

[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread via lldb-commits

jimingham wrote:

This is fine because the stl_summary_flags has skip pointers and skip 
references false.

This might be an observable change, because this formatter would have matched a 
reference to one of the types, but if the actual type was a pointer to a 
reference, etc, then we would also try to format that with this formatter 
because skip pointers and skip references is on?

That was probably wrong if it ever happened...

LGTM

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] 80bfac4 - [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (#79624)

2024-01-26 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-01-26T15:18:43-08:00
New Revision: 80bfac4327b6fb94cb9bf44eeb0d032799b9d418

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

LOG: [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (#79624)

This fixes two issues related to the DebugSymbols symbol locator:

1. Only the default symbol locator plugin reports progress. On Darwin,
which uses the DebugSymbols framework we need to report the same
progress form the corresponding SymbolLocator plugin.

2. Forceful dSYM lookups, for example when using `add-dsym`, use a
different code path that currently does not report progress, which is
confusing. Here the progress event can be more specific and specify its
downloading a symbol file rather than just locating it as we'll always
shell out to dsymForUUID or its equivalent.

rdar://121629777

Added: 


Modified: 
lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
index 9f32d252b22f5bd..f7df4650941a800 100644
--- 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
+++ 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",
+  module_spec.GetFileSpec().GetFilename().AsCString(""));
+
   FileSpec symbol_fspec;
   ModuleSpec dsym_module_spec;
   // First try and find the dSYM in the same directory as the executable or in
@@ -1045,33 +1049,28 @@ bool 
SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(
   if (!dsymForUUID_exe_spec)
 return false;
 
+  // Create the dsymForUUID command.
   const std::string dsymForUUID_exe_path = dsymForUUID_exe_spec.GetPath();
   const std::string uuid_str = uuid_ptr ? uuid_ptr->GetAsString() : "";
-  const std::string file_path_str =
-  file_spec_ptr ? file_spec_ptr->GetPath() : "";
 
-  Log *log = GetLog(LLDBLog::Host);
+  std::string lookup_arg = uuid_str;
+  if (lookup_arg.empty())
+lookup_arg = file_spec_ptr ? file_spec_ptr->GetPath() : "";
+  if (lookup_arg.empty())
+return false;
 
-  // Create the dsymForUUID command.
   StreamString command;
-  const char *copy_executable_arg = copy_executable ? "--copyExecutable " : "";
-  if (!uuid_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   uuid_str.c_str());
-LLDB_LOGF(log, "Calling %s with UUID %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), uuid_str.c_str(),
-  command.GetString().data());
-  } else if (!file_path_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   file_path_str.c_str());
-LLDB_LOGF(log, "Calling %s with file %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), file_path_str.c_str(),
-  command.GetString().data());
-  } else {
-return false;
-  }
+  command << dsymForUUID_exe_path << " --ignoreNegativeCache ";
+  if (copy_executable)
+command << "--copyExecutable ";
+  command << lookup_arg;
+
+  // Log and report progress.
+  Log *log = GetLog(LLDBLog::Host);
+  LLDB_LOG(log, "Calling {0} with {1} to find dSYM: {2}", dsymForUUID_exe_path,
+   lookup_arg, command.GetString());
+
+  Progress progress("Downloading symbol file", lookup_arg);
 
   // Invoke dsymForUUID.
   int exit_status = -1;



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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] 33860b2 - [lldb] Streamline ConstString -> std::string conversion (NFC) (#79649)

2024-01-26 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-01-26T15:04:11-08:00
New Revision: 33860b2f61a8a74141ae76ecd54742f9cfeb0d03

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

LOG: [lldb] Streamline ConstString -> std::string conversion (NFC) (#79649)

Make it easier to go from a ConstString to a std::string without having
to go through a C-String or a llvm::StringRef. I made the conversion
operator explicit as this is a relatively expensive operations (compared
to a StringRef or string_view).

Added: 


Modified: 
lldb/include/lldb/Utility/ConstString.h
lldb/unittests/Utility/ConstStringTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/ConstString.h 
b/lldb/include/lldb/Utility/ConstString.h
index cbea4cbf916a430..470a554ca04869d 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -167,8 +167,14 @@ class ConstString {
 
   // Implicitly convert \class ConstString instances to \class StringRef.
   operator llvm::StringRef() const { return GetStringRef(); }
-  // Implicitly convert \class ConstString instances to \calss 
std::string_view.
-  operator std::string_view() const { return std::string_view(m_string, 
GetLength()); }
+
+  // Implicitly convert \class ConstString instances to \class 
std::string_view.
+  operator std::string_view() const {
+return std::string_view(m_string, GetLength());
+  }
+
+  // Explicitly convert \class ConstString instances to \class std::string.
+  explicit operator std::string() const { return GetString(); }
 
   /// Get the string value as a C string.
   ///
@@ -192,6 +198,9 @@ class ConstString {
 return llvm::StringRef(m_string, GetLength());
   }
 
+  /// Get the string value as a std::string
+  std::string GetString() const { return std::string(m_string, GetLength()); }
+
   /// Get the string value as a C string.
   ///
   /// Get the value of the contained string as a NULL terminated C string

diff  --git a/lldb/unittests/Utility/ConstStringTest.cpp 
b/lldb/unittests/Utility/ConstStringTest.cpp
index 9affa927570a5c7..716f2d8d6c80428 100644
--- a/lldb/unittests/Utility/ConstStringTest.cpp
+++ b/lldb/unittests/Utility/ConstStringTest.cpp
@@ -137,3 +137,17 @@ TEST(ConstStringTest, CompareStringRef) {
   EXPECT_TRUE(null == static_cast(nullptr));
   EXPECT_TRUE(null != "bar");
 }
+
+TEST(ConstStringTest, StringConversions) {
+  ConstString foo("foo");
+
+  // Member functions.
+  EXPECT_EQ(llvm::StringRef("foo"), foo.GetStringRef());
+  EXPECT_EQ(std::string("foo"), foo.GetString());
+  EXPECT_STREQ("foo", foo.AsCString());
+
+  // Conversion operators.
+  EXPECT_EQ(llvm::StringRef("foo"), llvm::StringRef(foo));
+  EXPECT_EQ(std::string("foo"), std::string_view(foo));
+  EXPECT_EQ(std::string("foo"), std::string(foo));
+}



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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread David CARLIER via lldb-commits

https://github.com/devnexen updated 
https://github.com/llvm/llvm-project/pull/79662

>From 52618e6e6e028ea4a65728eda0c877dce176ccfa Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Fri, 26 Jan 2024 22:47:15 +
Subject: [PATCH] [lldb] checks beforehand if lldb can trace/attach a process
 on FreeBSD.

before having the generic EINVAL message, we check if the
`security.bsd.unprivileged_proc_debug` allows process debugging.

close #79634
---
 .../Process/FreeBSD/NativeProcessFreeBSD.cpp  | 29 ++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
index 19e0986ace31ff6..b676d536ca89495 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
+  if (ret != 0)
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");
+
+  if (proc_debug < 1)
+return Status(
+"process debug disabled by security.bsd.unprivileged_proc_debug oid");
+
+  return status;
+}
+
 // Public Static Methods
 
 llvm::Expected>
 NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo _info,
   NativeDelegate _delegate) {
   Log *log = GetLog(POSIXLog::Process);
-
   Status status;
+
+  status = CanTrace();
+
+  if (status.Fail()) {
+LLDB_LOG(log, "failed to launch process: {0}", status);
+return status.ToError();
+  }
+
   ::pid_t pid = ProcessLauncherPosixFork()
 .LaunchProcess(launch_info, status)
 .GetProcessId();
@@ -388,6 +411,10 @@ Status NativeProcessFreeBSD::PtraceWrapper(int req, 
lldb::pid_t pid, void *addr,
   Status error;
   int ret;
 
+  error = CanTrace();
+  if (error.Fail())
+return error;
+
   errno = 0;
   ret =
   ptrace(req, static_cast<::pid_t>(pid), static_cast(addr), data);

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff e4afffbe8cc31278a9006712e7323d49eae9dbb6 
492521e66288a497bf5b4a4a8ce554dffeb35727 -- 
lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
index 7540ba2965..a2062bd3a9 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -52,13 +52,15 @@ static Status CanTrace() {
   Status status;
   int proc_debug, ret;
   size_t len = sizeof(proc_debug);
-  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug, 
, nullptr, 0);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug,
+   , nullptr, 0);
   if (ret != 0) {
 return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");
   }
 
   if (proc_debug < 1) {
-return Status("process debug disabled by 
security.bsd.unprivileged_proc_debug oid");
+return Status(
+"process debug disabled by security.bsd.unprivileged_proc_debug oid");
   }
 
   return status;

``




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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David CARLIER (devnexen)


Changes

before having the generic EINVAL message, we check if the 
`security.bsd.unprivileged_proc_debug` allows process debugging.

close #79634

---
Full diff: https://github.com/llvm/llvm-project/pull/79662.diff


1 Files Affected:

- (modified) lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp 
(+28-1) 


``diff
diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
index 19e0986ace31ff6..7540ba296517821 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug, 
, nullptr, 0);
+  if (ret != 0) {
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");
+  }
+
+  if (proc_debug < 1) {
+return Status("process debug disabled by 
security.bsd.unprivileged_proc_debug oid");
+  }
+
+  return status;
+}
+
 // Public Static Methods
 
 llvm::Expected>
 NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo _info,
   NativeDelegate _delegate) {
   Log *log = GetLog(POSIXLog::Process);
-
   Status status;
+
+  status = CanTrace();
+
+  if (status.Fail()) {
+LLDB_LOG(log, "failed to launch process: {0}", status);
+return status.ToError();
+  }
+
   ::pid_t pid = ProcessLauncherPosixFork()
 .LaunchProcess(launch_info, status)
 .GetProcessId();
@@ -388,6 +411,10 @@ Status NativeProcessFreeBSD::PtraceWrapper(int req, 
lldb::pid_t pid, void *addr,
   Status error;
   int ret;
 
+  error = CanTrace();
+  if (error.Fail())
+return error;
+
   errno = 0;
   ret =
   ptrace(req, static_cast<::pid_t>(pid), static_cast(addr), data);

``




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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread Jonas Devlieghere via lldb-commits


@@ -192,6 +198,9 @@ class ConstString {
 return llvm::StringRef(m_string, GetLength());
   }
 
+  /// Get the string value as a std::string
+  std::string GetString() const { return std::string(m_string, GetLength()); }

JDevlieghere wrote:

It's not necessary, it's more for consistency with how we already do things 
(similar to how `StringRef` has the explicit operator and the `.str()` method 
on the llvm side). 

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


[Lldb-commits] [lldb] [lldb] checks beforehand if lldb can trace/attach a process on FreeBSD. (PR #79662)

2024-01-26 Thread David CARLIER via lldb-commits

https://github.com/devnexen created 
https://github.com/llvm/llvm-project/pull/79662

before having the generic EINVAL message, we check if the 
`security.bsd.unprivileged_proc_debug` allows process debugging.

close #79634

>From 492521e66288a497bf5b4a4a8ce554dffeb35727 Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Fri, 26 Jan 2024 22:47:15 +
Subject: [PATCH] [lldb] checks beforehand if lldb can trace/attach a process
 on FreeBSD.

before having the generic EINVAL message, we check if the
`security.bsd.unprivileged_proc_debug` allows process debugging.

close #79634
---
 .../Process/FreeBSD/NativeProcessFreeBSD.cpp  | 29 ++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
index 19e0986ace31ff..7540ba29651782 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -48,14 +48,37 @@ static Status EnsureFDFlags(int fd, int flags) {
   return error;
 }
 
+static Status CanTrace() {
+  Status status;
+  int proc_debug, ret;
+  size_t len = sizeof(proc_debug);
+  ret = ::sysctlbyname("security.bsd.unprivileged_proc_debug", _debug, 
, nullptr, 0);
+  if (ret != 0) {
+return Status("sysctlbyname() security.bsd.unprivileged_proc_debug 
failed");
+  }
+
+  if (proc_debug < 1) {
+return Status("process debug disabled by 
security.bsd.unprivileged_proc_debug oid");
+  }
+
+  return status;
+}
+
 // Public Static Methods
 
 llvm::Expected>
 NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo _info,
   NativeDelegate _delegate) {
   Log *log = GetLog(POSIXLog::Process);
-
   Status status;
+
+  status = CanTrace();
+
+  if (status.Fail()) {
+LLDB_LOG(log, "failed to launch process: {0}", status);
+return status.ToError();
+  }
+
   ::pid_t pid = ProcessLauncherPosixFork()
 .LaunchProcess(launch_info, status)
 .GetProcessId();
@@ -388,6 +411,10 @@ Status NativeProcessFreeBSD::PtraceWrapper(int req, 
lldb::pid_t pid, void *addr,
   Status error;
   int ret;
 
+  error = CanTrace();
+  if (error.Fail())
+return error;
+
   errno = 0;
   ret =
   ptrace(req, static_cast<::pid_t>(pid), static_cast(addr), data);

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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread Felipe de Azevedo Piovezan via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -192,6 +198,9 @@ class ConstString {
 return llvm::StringRef(m_string, GetLength());
   }
 
+  /// Get the string value as a std::string
+  std::string GetString() const { return std::string(m_string, GetLength()); }

felipepiovezan wrote:

why is this necessary, if we have the explicit operator?

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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/79649

>From b0abae7ac1208321a4a7033bcc456dba645b47bf Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 26 Jan 2024 14:35:52 -0800
Subject: [PATCH] [lldb] Streamline ConstString -> std::string conversion (NFC)

Make it easier to go from a ConstString to a std::string without having
to go through a C-String or a llvm::StringRef. I made the conversion
operator explicit as this is a relatively expensive operations (compared
to a StringRef or string_view).
---
 lldb/include/lldb/Utility/ConstString.h| 13 +++--
 lldb/unittests/Utility/ConstStringTest.cpp | 14 ++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Utility/ConstString.h 
b/lldb/include/lldb/Utility/ConstString.h
index cbea4cbf916a430..470a554ca04869d 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -167,8 +167,14 @@ class ConstString {
 
   // Implicitly convert \class ConstString instances to \class StringRef.
   operator llvm::StringRef() const { return GetStringRef(); }
-  // Implicitly convert \class ConstString instances to \calss 
std::string_view.
-  operator std::string_view() const { return std::string_view(m_string, 
GetLength()); }
+
+  // Implicitly convert \class ConstString instances to \class 
std::string_view.
+  operator std::string_view() const {
+return std::string_view(m_string, GetLength());
+  }
+
+  // Explicitly convert \class ConstString instances to \class std::string.
+  explicit operator std::string() const { return GetString(); }
 
   /// Get the string value as a C string.
   ///
@@ -192,6 +198,9 @@ class ConstString {
 return llvm::StringRef(m_string, GetLength());
   }
 
+  /// Get the string value as a std::string
+  std::string GetString() const { return std::string(m_string, GetLength()); }
+
   /// Get the string value as a C string.
   ///
   /// Get the value of the contained string as a NULL terminated C string
diff --git a/lldb/unittests/Utility/ConstStringTest.cpp 
b/lldb/unittests/Utility/ConstStringTest.cpp
index 9affa927570a5c7..716f2d8d6c80428 100644
--- a/lldb/unittests/Utility/ConstStringTest.cpp
+++ b/lldb/unittests/Utility/ConstStringTest.cpp
@@ -137,3 +137,17 @@ TEST(ConstStringTest, CompareStringRef) {
   EXPECT_TRUE(null == static_cast(nullptr));
   EXPECT_TRUE(null != "bar");
 }
+
+TEST(ConstStringTest, StringConversions) {
+  ConstString foo("foo");
+
+  // Member functions.
+  EXPECT_EQ(llvm::StringRef("foo"), foo.GetStringRef());
+  EXPECT_EQ(std::string("foo"), foo.GetString());
+  EXPECT_STREQ("foo", foo.AsCString());
+
+  // Conversion operators.
+  EXPECT_EQ(llvm::StringRef("foo"), llvm::StringRef(foo));
+  EXPECT_EQ(std::string("foo"), std::string_view(foo));
+  EXPECT_EQ(std::string("foo"), std::string(foo));
+}

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


[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] 074630e - [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (#79644)

2024-01-26 Thread via lldb-commits

Author: Dave Lee
Date: 2024-01-26T14:28:39-08:00
New Revision: 074630e8af94d839f6baf6378d7ed3d7a6d2753c

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

LOG: [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) 
(#79644)

The `(( )?&)?` appears to match types which are references. However lldb
can load the
correct data formatters without having to pattern match against a `&`
suffix.

The suffix may have been needed at one point, but it's no longer needed.

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index f0fe6c9e06d9d47..e0de80880376acb 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -744,46 +744,46 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxBitsetSyntheticFrontEndCreator,
   "libc++ std::bitset synthetic children",
-  "^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::bitset<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
   "libc++ std::vector synthetic children",
-  "^std::__[[:alnum:]]+::vector<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::vector<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdForwardListSyntheticFrontEndCreator,
   "libc++ std::forward_list synthetic children",
-  "^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$", stl_synth_flags, 
true);
+  "^std::__[[:alnum:]]+::forward_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
   "libc++ std::list synthetic children",
-  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( 
)?&)?$"
-  // so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
+  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>$"
+  // so that it does not clash with: "^std::(__cxx11::)?list<.+>$"
   "^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
-  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$",
+  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>$",
   stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::map synthetic children",
-  "^std::__[[:alnum:]]+::map<.+> >(( )?&)?$", stl_synth_flags, true);
+  "libc++ std::map synthetic children", "^std::__[[:alnum:]]+::map<.+> >$",
+  stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::set synthetic children",
-  "^std::__[[:alnum:]]+::set<.+> >(( )?&)?$", stl_deref_flags, true);
+  "libc++ std::set synthetic children", "^std::__[[:alnum:]]+::set<.+> >$",
+  stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multiset synthetic children",
-  "^std::__[[:alnum:]]+::multiset<.+> >(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::multiset<.+> >$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multimap synthetic children",
-  "^std::__[[:alnum:]]+::multimap<.+> >(( )?&)?$", stl_synth_flags, true);
+  "^std::__[[:alnum:]]+::multimap<.+> >$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
@@ -794,23 +794,19 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator,
   "libc++ std::initializer_list synthetic children",
-  "^std::initializer_list<.+>(( )?&)?$", stl_synth_flags, true);
+  "^std::initializer_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(cpp_category_sp, LibcxxQueueFrontEndCreator,
   "libc++ std::queue synthetic children",
-  "^std::__[[:alnum:]]+::queue<.+>(( )?&)?$", stl_synth_flags,
-  true);
+  "^std::__[[:alnum:]]+::queue<.+>$", stl_synth_flags, true);
   

[Lldb-commits] [clang-tools-extra] [lldb] [openmp] [compiler-rt] [libclc] [flang] [mlir] [llvm] [libc] [libcxx] [lld] [clang] [libc++][memory] P1132R8: `out_ptr` - a scalable output pointer abstractio

2024-01-26 Thread Louis Dionne via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove obsolete signBinary helper (PR #79656)

2024-01-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

On Darwin, the Makefile already (ad-hoc) signs everything it builds. There's 
also no need to use lldb_codesign for this.

---
Full diff: https://github.com/llvm/llvm-project/pull/79656.diff


8 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/dotest.py (-2) 
- (modified) lldb/packages/Python/lldbsuite/test/dotest_args.py (-6) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (-8) 
- (modified) lldb/test/API/CMakeLists.txt (-6) 
- (modified) 
lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py (-1) 
- (modified) lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py (-1) 
- (modified) lldb/test/API/api/multiple-targets/TestMultipleTargets.py (-1) 
- (modified) lldb/test/API/api/multithreaded/TestMultithreaded.py (-1) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index a639714480cf4eb..4393e0caacaab88 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -442,8 +442,6 @@ def parseOptionsAndInitTestdirs():
 os.path.realpath(os.path.abspath(x)) for x in args.args
 ]
 
-lldbtest_config.codesign_identity = args.codesign_identity
-
 
 def registerFaulthandler():
 try:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 70a65078f1d3a88..e4de786ec054894 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -217,12 +217,6 @@ def create_parser():
 action="store_true",
 help="Leave logs/traces even for successful test runs (useful for 
creating reference log files during debugging.)",
 )
-group.add_argument(
-"--codesign-identity",
-metavar="Codesigning identity",
-default="lldb_codesign",
-help="The codesigning identity to use",
-)
 group.add_argument(
 "--build-dir",
 dest="test_build_dir",
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 3abc713398490e7..d944b09cbcc4720 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1543,14 +1543,6 @@ def buildProgram(self, sources, exe_name):
 d = {"CXX_SOURCES": sources, "EXE": exe_name}
 self.build(dictionary=d)
 
-def signBinary(self, binary_path):
-if sys.platform.startswith("darwin"):
-codesign_cmd = 'codesign --force --sign "%s" %s' % (
-lldbtest_config.codesign_identity,
-binary_path,
-)
-call(codesign_cmd, shell=True)
-
 def findBuiltClang(self):
 """Tries to find and use Clang from the build directory as the 
compiler (instead of the system compiler)."""
 paths_to_try = [
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 0b63ffdb4bd9ae3..4e02112c29e4cd5 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -98,12 +98,6 @@ if(CMAKE_HOST_APPLE)
 set(LLDB_FRAMEWORK_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)
   endif()
 
-  # Use the same identity for testing
-  get_property(code_sign_identity_used GLOBAL PROPERTY 
LLDB_DEBUGSERVER_CODESIGN_IDENTITY)
-  if(code_sign_identity_used)
-list(APPEND LLDB_TEST_COMMON_ARGS_VAR --codesign-identity 
"${code_sign_identity_used}")
-  endif()
-
   if(LLDB_USE_SYSTEM_DEBUGSERVER)
 lldb_find_system_debugserver(system_debugserver_path)
 if(LLDB_BUILD_FRAMEWORK)
diff --git 
a/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py 
b/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
index 77f146f7bcb0389..98f089377363494 100644
--- a/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
+++ b/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
@@ -18,7 +18,6 @@ def test_sb_command_return_object(self):
 self.driver_exe = self.getBuildArtifact("command-return-object")
 self.buildDriver("main.cpp", self.driver_exe)
 self.addTearDownHook(lambda: os.remove(self.driver_exe))
-self.signBinary(self.driver_exe)
 
 if self.TraceOn():
 print("Running test %s" % self.driver_exe)
diff --git a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py 
b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
index 889784ccc60b634..15b2012eee13b6b 100644
--- a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -24,7 +24,6 @@ def test_multiple_debuggers(self):
 self.driver_exe = self.getBuildArtifact("multi-process-driver")
 self.buildDriver("multi-process-driver.cpp", 

[Lldb-commits] [lldb] [lldb] Remove obsolete signBinary helper (PR #79656)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/79656

On Darwin, the Makefile already (ad-hoc) signs everything it builds. There's 
also no need to use lldb_codesign for this.

>From 80d68ab889989ddae906af3b2042158a12a0ca46 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 26 Jan 2024 14:02:16 -0800
Subject: [PATCH] [lldb] Remove obsolote signBinary helper

On Darwin, the Makefile already (ad-hoc) signs everything it builds.
There's also no need to use lldb_codesign for this.
---
 lldb/packages/Python/lldbsuite/test/dotest.py | 2 --
 lldb/packages/Python/lldbsuite/test/dotest_args.py| 6 --
 lldb/packages/Python/lldbsuite/test/lldbtest.py   | 8 
 lldb/test/API/CMakeLists.txt  | 6 --
 .../command-return-object/TestSBCommandReturnObject.py| 1 -
 .../API/api/multiple-debuggers/TestMultipleDebuggers.py   | 1 -
 lldb/test/API/api/multiple-targets/TestMultipleTargets.py | 1 -
 lldb/test/API/api/multithreaded/TestMultithreaded.py  | 1 -
 8 files changed, 26 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index a639714480cf4e..4393e0caacaab8 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -442,8 +442,6 @@ def parseOptionsAndInitTestdirs():
 os.path.realpath(os.path.abspath(x)) for x in args.args
 ]
 
-lldbtest_config.codesign_identity = args.codesign_identity
-
 
 def registerFaulthandler():
 try:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 70a65078f1d3a8..e4de786ec05489 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -217,12 +217,6 @@ def create_parser():
 action="store_true",
 help="Leave logs/traces even for successful test runs (useful for 
creating reference log files during debugging.)",
 )
-group.add_argument(
-"--codesign-identity",
-metavar="Codesigning identity",
-default="lldb_codesign",
-help="The codesigning identity to use",
-)
 group.add_argument(
 "--build-dir",
 dest="test_build_dir",
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 3abc713398490e..d944b09cbcc472 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1543,14 +1543,6 @@ def buildProgram(self, sources, exe_name):
 d = {"CXX_SOURCES": sources, "EXE": exe_name}
 self.build(dictionary=d)
 
-def signBinary(self, binary_path):
-if sys.platform.startswith("darwin"):
-codesign_cmd = 'codesign --force --sign "%s" %s' % (
-lldbtest_config.codesign_identity,
-binary_path,
-)
-call(codesign_cmd, shell=True)
-
 def findBuiltClang(self):
 """Tries to find and use Clang from the build directory as the 
compiler (instead of the system compiler)."""
 paths_to_try = [
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 0b63ffdb4bd9ae..4e02112c29e4cd 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -98,12 +98,6 @@ if(CMAKE_HOST_APPLE)
 set(LLDB_FRAMEWORK_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)
   endif()
 
-  # Use the same identity for testing
-  get_property(code_sign_identity_used GLOBAL PROPERTY 
LLDB_DEBUGSERVER_CODESIGN_IDENTITY)
-  if(code_sign_identity_used)
-list(APPEND LLDB_TEST_COMMON_ARGS_VAR --codesign-identity 
"${code_sign_identity_used}")
-  endif()
-
   if(LLDB_USE_SYSTEM_DEBUGSERVER)
 lldb_find_system_debugserver(system_debugserver_path)
 if(LLDB_BUILD_FRAMEWORK)
diff --git 
a/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py 
b/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
index 77f146f7bcb038..98f08937736349 100644
--- a/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
+++ b/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
@@ -18,7 +18,6 @@ def test_sb_command_return_object(self):
 self.driver_exe = self.getBuildArtifact("command-return-object")
 self.buildDriver("main.cpp", self.driver_exe)
 self.addTearDownHook(lambda: os.remove(self.driver_exe))
-self.signBinary(self.driver_exe)
 
 if self.TraceOn():
 print("Running test %s" % self.driver_exe)
diff --git a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py 
b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
index 889784ccc60b63..15b2012eee13b6 100644
--- a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ 

[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread Med Ismail Bennani via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [libcxx] [mlir] [clang] [libcxxabi] [lld] [clang-tools-extra] [libc] [llvm] [flang] [lldb] [compiler-rt] [mlir][complex] Prevent underflow in complex.abs (PR #76316)

2024-01-26 Thread Kai Sasaki via lldb-commits

https://github.com/Lewuathe updated 
https://github.com/llvm/llvm-project/pull/76316

>From a5810363e546da073543cb2d62cceb956c46b2e6 Mon Sep 17 00:00:00 2001
From: Kai Sasaki 
Date: Fri, 15 Dec 2023 15:53:54 +0900
Subject: [PATCH 1/2] [mlir][complex] Prevent underflow in complex.abs

---
 .../ComplexToStandard/ComplexToStandard.cpp   |  56 ++---
 .../convert-to-standard.mlir  | 115 ++
 .../ComplexToStandard/full-conversion.mlir|  25 +++-
 .../Dialect/Complex/CPU/correctness.mlir  |  38 ++
 4 files changed, 194 insertions(+), 40 deletions(-)

diff --git a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp 
b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp
index bf753c7062f3664..7c1db57b55f996b 100644
--- a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp
+++ b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp
@@ -26,29 +26,57 @@ namespace mlir {
 using namespace mlir;
 
 namespace {
+// The algorithm is listed in https://dl.acm.org/doi/pdf/10.1145/363717.363780.
 struct AbsOpConversion : public OpConversionPattern {
   using OpConversionPattern::OpConversionPattern;
 
   LogicalResult
   matchAndRewrite(complex::AbsOp op, OpAdaptor adaptor,
   ConversionPatternRewriter ) const override {
-auto loc = op.getLoc();
-auto type = op.getType();
+mlir::ImplicitLocOpBuilder b(op.getLoc(), rewriter);
 
 arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
 
-Value real =
-rewriter.create(loc, type, adaptor.getComplex());
-Value imag =
-rewriter.create(loc, type, adaptor.getComplex());
-Value realSqr =
-rewriter.create(loc, real, real, fmf.getValue());
-Value imagSqr =
-rewriter.create(loc, imag, imag, fmf.getValue());
-Value sqNorm =
-rewriter.create(loc, realSqr, imagSqr, fmf.getValue());
-
-rewriter.replaceOpWithNewOp(op, sqNorm);
+Type elementType = op.getType();
+Value arg = adaptor.getComplex();
+
+Value zero =
+b.create(elementType, b.getZeroAttr(elementType));
+Value one = b.create(elementType,
+b.getFloatAttr(elementType, 1.0));
+
+Value real = b.create(elementType, arg);
+Value imag = b.create(elementType, arg);
+
+Value realIsZero =
+b.create(arith::CmpFPredicate::OEQ, real, zero);
+Value imagIsZero =
+b.create(arith::CmpFPredicate::OEQ, imag, zero);
+
+// Real > Imag
+Value imagDivReal = b.create(imag, real, fmf.getValue());
+Value imagSq =
+b.create(imagDivReal, imagDivReal, fmf.getValue());
+Value imagSqPlusOne = b.create(imagSq, one, fmf.getValue());
+Value imagSqrt = b.create(imagSqPlusOne, fmf.getValue());
+Value absImag = b.create(imagSqrt, real, fmf.getValue());
+
+// Real <= Imag
+Value realDivImag = b.create(real, imag, fmf.getValue());
+Value realSq =
+b.create(realDivImag, realDivImag, fmf.getValue());
+Value realSqPlusOne = b.create(realSq, one, fmf.getValue());
+Value realSqrt = b.create(realSqPlusOne, fmf.getValue());
+Value absReal = b.create(realSqrt, imag, fmf.getValue());
+
+rewriter.replaceOpWithNewOp(
+op, realIsZero, imag,
+b.create(
+imagIsZero, real,
+b.create(
+b.create(arith::CmpFPredicate::OGT, real, imag),
+absImag, absReal)));
+
 return success();
   }
 };
diff --git a/mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir 
b/mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir
index 3af28150fd5c3f3..1028c9aae92c056 100644
--- a/mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir
+++ b/mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir
@@ -7,13 +7,28 @@ func.func @complex_abs(%arg: complex) -> f32 {
   %abs = complex.abs %arg: complex
   return %abs : f32
 }
+
+// CHECK: %[[ZERO:.*]] = arith.constant 0.00e+00 : f32
+// CHECK: %[[ONE:.*]] = arith.constant 1.00e+00 : f32
 // CHECK: %[[REAL:.*]] = complex.re %[[ARG]] : complex
 // CHECK: %[[IMAG:.*]] = complex.im %[[ARG]] : complex
-// CHECK-DAG: %[[REAL_SQ:.*]] = arith.mulf %[[REAL]], %[[REAL]] : f32
-// CHECK-DAG: %[[IMAG_SQ:.*]] = arith.mulf %[[IMAG]], %[[IMAG]] : f32
-// CHECK: %[[SQ_NORM:.*]] = arith.addf %[[REAL_SQ]], %[[IMAG_SQ]] : f32
-// CHECK: %[[NORM:.*]] = math.sqrt %[[SQ_NORM]] : f32
-// CHECK: return %[[NORM]] : f32
+// CHECK: %[[IS_REAL_ZERO:.*]] = arith.cmpf oeq, %[[REAL]], %[[ZERO]] : f32
+// CHECK: %[[IS_IMAG_ZERO:.*]] = arith.cmpf oeq, %[[IMAG]], %[[ZERO]] : f32
+// CHECK: %[[IMAG_DIV_REAL:.*]] = arith.divf %[[IMAG]], %[[REAL]] : f32
+// CHECK: %[[IMAG_SQ:.*]] = arith.mulf %[[IMAG_DIV_REAL]], %[[IMAG_DIV_REAL]] 
: f32
+// CHECK: %[[IMAG_SQ_PLUS_ONE:.*]] = arith.addf %[[IMAG_SQ]], %[[ONE]] : f32
+// CHECK: %[[IMAG_SQRT:.*]] = math.sqrt %[[IMAG_SQ_PLUS_ONE]] : f32
+// CHECK: %[[ABS_IMAG:.*]] = arith.mulf %[[IMAG_SQRT]], %[[REAL]] : 

[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, ));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster  = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");

chelcassanova wrote:

I can check the events being delivered outside of the event queue as well as 
checking the other details from `ProgressEventData`. Per Jonas' [comment 
](https://github.com/llvm/llvm-project/pull/79533#issuecomment-1912560822) 
though since we're only testing the current behaviour maybe testing `Increment` 
could be done in another PR?

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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 84be954cb26ebde58d4ddd2255dfd99904d9ae1b 
fd1938e02a4e0394190d90792933e81fce7fc329 -- 
lldb/include/lldb/Utility/ConstString.h 
lldb/unittests/Utility/ConstStringTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Utility/ConstString.h 
b/lldb/include/lldb/Utility/ConstString.h
index 0ee3f0184b..470a554ca0 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -199,9 +199,7 @@ public:
   }
 
   /// Get the string value as a std::string
-  std::string GetString() const {
-return std::string(m_string, GetLength());
-  }
+  std::string GetString() const { return std::string(m_string, GetLength()); }
 
   /// Get the string value as a C string.
   ///

``




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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Make it easier to go from a ConstString to a std::string without having to go 
through a C-String or a llvm::StringRef. I made the conversion operator 
explicit as this is a relatively expensive operations (compared to a StringRef 
or string_view).

---
Full diff: https://github.com/llvm/llvm-project/pull/79649.diff


2 Files Affected:

- (modified) lldb/include/lldb/Utility/ConstString.h (+13-2) 
- (modified) lldb/unittests/Utility/ConstStringTest.cpp (+14) 


``diff
diff --git a/lldb/include/lldb/Utility/ConstString.h 
b/lldb/include/lldb/Utility/ConstString.h
index cbea4cbf916a430..0ee3f0184b0d08c 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -167,8 +167,14 @@ class ConstString {
 
   // Implicitly convert \class ConstString instances to \class StringRef.
   operator llvm::StringRef() const { return GetStringRef(); }
-  // Implicitly convert \class ConstString instances to \calss 
std::string_view.
-  operator std::string_view() const { return std::string_view(m_string, 
GetLength()); }
+
+  // Implicitly convert \class ConstString instances to \class 
std::string_view.
+  operator std::string_view() const {
+return std::string_view(m_string, GetLength());
+  }
+
+  // Explicitly convert \class ConstString instances to \class std::string.
+  explicit operator std::string() const { return GetString(); }
 
   /// Get the string value as a C string.
   ///
@@ -192,6 +198,11 @@ class ConstString {
 return llvm::StringRef(m_string, GetLength());
   }
 
+  /// Get the string value as a std::string
+  std::string GetString() const {
+return std::string(m_string, GetLength());
+  }
+
   /// Get the string value as a C string.
   ///
   /// Get the value of the contained string as a NULL terminated C string
diff --git a/lldb/unittests/Utility/ConstStringTest.cpp 
b/lldb/unittests/Utility/ConstStringTest.cpp
index 9affa927570a5c7..716f2d8d6c80428 100644
--- a/lldb/unittests/Utility/ConstStringTest.cpp
+++ b/lldb/unittests/Utility/ConstStringTest.cpp
@@ -137,3 +137,17 @@ TEST(ConstStringTest, CompareStringRef) {
   EXPECT_TRUE(null == static_cast(nullptr));
   EXPECT_TRUE(null != "bar");
 }
+
+TEST(ConstStringTest, StringConversions) {
+  ConstString foo("foo");
+
+  // Member functions.
+  EXPECT_EQ(llvm::StringRef("foo"), foo.GetStringRef());
+  EXPECT_EQ(std::string("foo"), foo.GetString());
+  EXPECT_STREQ("foo", foo.AsCString());
+
+  // Conversion operators.
+  EXPECT_EQ(llvm::StringRef("foo"), llvm::StringRef(foo));
+  EXPECT_EQ(std::string("foo"), std::string_view(foo));
+  EXPECT_EQ(std::string("foo"), std::string(foo));
+}

``




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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Jonas Devlieghere via lldb-commits


@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",
+  module_spec.GetFileSpec().GetFilename().AsCString(""));

JDevlieghere wrote:

https://github.com/llvm/llvm-project/pull/79649

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


[Lldb-commits] [lldb] [lldb] Streamline ConstString -> std::string conversion (NFC) (PR #79649)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/79649

Make it easier to go from a ConstString to a std::string without having to go 
through a C-String or a llvm::StringRef. I made the conversion operator 
explicit as this is a relatively expensive operations (compared to a StringRef 
or string_view).

>From fd1938e02a4e0394190d90792933e81fce7fc329 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 26 Jan 2024 13:08:23 -0800
Subject: [PATCH] [lldb] Streamline ConstString -> std::string conversion (NFC)

Make it easier to go from a ConstString to a std::string without having
to go through a C-String or a llvm::StringRef. I made the conversion
operator explicit as this is a relatively expensive operations (compared
to a StringRef or string_view).
---
 lldb/include/lldb/Utility/ConstString.h| 15 +--
 lldb/unittests/Utility/ConstStringTest.cpp | 14 ++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Utility/ConstString.h 
b/lldb/include/lldb/Utility/ConstString.h
index cbea4cbf916a430..0ee3f0184b0d08c 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -167,8 +167,14 @@ class ConstString {
 
   // Implicitly convert \class ConstString instances to \class StringRef.
   operator llvm::StringRef() const { return GetStringRef(); }
-  // Implicitly convert \class ConstString instances to \calss 
std::string_view.
-  operator std::string_view() const { return std::string_view(m_string, 
GetLength()); }
+
+  // Implicitly convert \class ConstString instances to \class 
std::string_view.
+  operator std::string_view() const {
+return std::string_view(m_string, GetLength());
+  }
+
+  // Explicitly convert \class ConstString instances to \class std::string.
+  explicit operator std::string() const { return GetString(); }
 
   /// Get the string value as a C string.
   ///
@@ -192,6 +198,11 @@ class ConstString {
 return llvm::StringRef(m_string, GetLength());
   }
 
+  /// Get the string value as a std::string
+  std::string GetString() const {
+return std::string(m_string, GetLength());
+  }
+
   /// Get the string value as a C string.
   ///
   /// Get the value of the contained string as a NULL terminated C string
diff --git a/lldb/unittests/Utility/ConstStringTest.cpp 
b/lldb/unittests/Utility/ConstStringTest.cpp
index 9affa927570a5c7..716f2d8d6c80428 100644
--- a/lldb/unittests/Utility/ConstStringTest.cpp
+++ b/lldb/unittests/Utility/ConstStringTest.cpp
@@ -137,3 +137,17 @@ TEST(ConstStringTest, CompareStringRef) {
   EXPECT_TRUE(null == static_cast(nullptr));
   EXPECT_TRUE(null != "bar");
 }
+
+TEST(ConstStringTest, StringConversions) {
+  ConstString foo("foo");
+
+  // Member functions.
+  EXPECT_EQ(llvm::StringRef("foo"), foo.GetStringRef());
+  EXPECT_EQ(std::string("foo"), foo.GetString());
+  EXPECT_STREQ("foo", foo.AsCString());
+
+  // Conversion operators.
+  EXPECT_EQ(llvm::StringRef("foo"), llvm::StringRef(foo));
+  EXPECT_EQ(std::string("foo"), std::string_view(foo));
+  EXPECT_EQ(std::string("foo"), std::string(foo));
+}

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


[Lldb-commits] [flang] [clang] [mlir] [llvm] [libcxx] [lld] [libc] [libunwind] [clang-tools-extra] [compiler-rt] [lldb] Reland: [libc++][format] P2637R3: Member visit (std::basic_format_arg) #76449 (P

2024-01-26 Thread Hristo Hristov via lldb-commits

https://github.com/Zingam updated 
https://github.com/llvm/llvm-project/pull/79032

>From e03452fda84a5284420bba1913299b68caabb6cd Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Mon, 22 Jan 2024 20:35:00 +0200
Subject: [PATCH 1/6] Revert "Revert "[libc++][format] P2637R3: Member `visit`
 (`std::basic_format_arg`) (#76449)""

This reverts commit 02f95b77515fe18ed1076b94cbb850ea0cf3c77e.
---
 libcxx/docs/ReleaseNotes/18.rst   |   1 +
 libcxx/docs/Status/Cxx2cPapers.csv|   2 +-
 libcxx/docs/Status/FormatIssues.csv   |   2 +-
 libcxx/include/__config   |   6 +
 libcxx/include/__format/format_arg.h  | 109 +-
 libcxx/include/__format/format_context.h  |  33 +-
 libcxx/include/format |   2 +-
 .../format.arg/visit.pass.cpp | 333 
 .../format.arg/visit.return_type.pass.cpp | 369 ++
 .../visit_format_arg.deprecated.verify.cpp|  38 ++
 .../format.arg/visit_format_arg.pass.cpp  |   6 +-
 .../format.arguments/format.args/get.pass.cpp |  48 ++-
 libcxx/test/support/test_basic_format_arg.h   |  20 +-
 libcxx/test/support/test_macros.h |   5 +
 .../generate_feature_test_macro_components.py |   1 +
 15 files changed, 927 insertions(+), 48 deletions(-)
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp

diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fd882bafe19a51..237a63022d55ff 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -79,6 +79,7 @@ Implemented Papers
 - P1759R6 - Native handles and file streams
 - P2868R3 - Remove Deprecated ``std::allocator`` Typedef From C++26
 - P2517R1 - Add a conditional ``noexcept`` specification to ``std::apply``
+- P2637R3 - Member ``visit``
 - P2447R6 - ``span`` over initializer list
 
 
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index f80b1f6b663f04..c45aa3c510072e 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -17,7 +17,7 @@
 "`P0792R14 `__","LWG","``function_ref``: a 
type-erased callable reference","Varna June 2023","","",""
 "`P2874R2 `__","LWG","Mandating Annex D Require No 
More","Varna June 2023","","",""
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
-"`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","|Partial|","18.0",""
+"`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","|Complete|","18.0",""
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
 "`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
diff --git a/libcxx/docs/Status/FormatIssues.csv 
b/libcxx/docs/Status/FormatIssues.csv
index 513988d08036ca..6e58e752191ea5 100644
--- a/libcxx/docs/Status/FormatIssues.csv
+++ b/libcxx/docs/Status/FormatIssues.csv
@@ -16,7 +16,7 @@ Number,Name,Standard,Assignee,Status,First released version
 "`P2693R1 `__","Formatting ``thread::id`` and 
``stacktrace``","C++23","Mark de Wever","|In Progress|"
 "`P2510R3 `__","Formatting pointers","C++26","Mark 
de Wever","|Complete|",17.0
 "`P2757R3 `__","Type-checking format 
args","C++26","","",
-"`P2637R3 `__","Member ``visit``","C++26","","",
+"`P2637R3 `__","Member ``visit``","C++26","Hristo 
Hristov","|Complete|",18.0
 "`P2905R2 `__","Runtime format strings","C++26 
DR","Mark de Wever","|Complete|",18.0
 "`P2918R2 `__","Runtime format strings 
II","C++26","Mark de Wever","|Complete|",18.0
 "`P2909R4 `__","Fix formatting of code units as 
integers (Dude, where’s my ``char``?)","C++26 DR","Mark de 
Wever","|Complete|",18.0
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 9a64cdb489119d..00489d971c296c 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -995,6 +995,12 @@ typedef __char32_t char32_t;
 #define _LIBCPP_DEPRECATED_IN_CXX23
 #  endif
 
+#  if _LIBCPP_STD_VER >= 26
+#define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
+#  else
+#define _LIBCPP_DEPRECATED_IN_CXX26
+#  endif
+
 #  if 

[Lldb-commits] [llvm] [lld] [mlir] [clang-tools-extra] [lldb] [libcxx] [clang] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: None (srcarroll)


Changes

As far as I am aware, there is no simple way to match on elementwise ops.  I 
propose to add an `elementwise` criteria to the `match.structured.body` op.  
Although my only hesitation is that elementwise is not only determined by the 
body, but also the indexing maps.  So if others find this too awkward,  I can 
implement a separate match op instead.

---
Full diff: https://github.com/llvm/llvm-project/pull/79626.diff


4 Files Affected:

- (modified) mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
(+4) 
- (modified) mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp (+8-1) 
- (modified) mlir/test/Dialect/Linalg/match-ops-interpreter.mlir (+57) 
- (modified) mlir/test/Dialect/Linalg/match-ops-invalid.mlir (+1-1) 


``diff
diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f..dfeb8ae5d5ddbc 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063a..fb18886c16b16d 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block  = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e..24c7bdd9e1050e 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,63 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.debug.emit_remark_at %arg0, "elementwise" : !transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+

[Lldb-commits] [llvm] [lld] [mlir] [clang-tools-extra] [lldb] [libcxx] [clang] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

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


[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/79626

>From ab475c9ffb7c3562bad4772389e97b82e9f110c0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Fri, 26 Jan 2024 11:55:06 -0600
Subject: [PATCH 1/3] Add elementwise criteria to match.structured.body

---
 .../Linalg/TransformOps/LinalgMatchOps.td |  4 +++
 .../Linalg/TransformOps/LinalgMatchOps.cpp|  9 -
 .../Dialect/Linalg/match-ops-interpreter.mlir | 34 +++
 .../Dialect/Linalg/match-ops-invalid.mlir |  2 +-
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f2..dfeb8ae5d5ddbcb 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063ac..fb18886c16b16d5 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block  = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e4..0efe70a7b9ae1eb 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,40 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.test_print_remark_at_operand %arg0, "elementwise" : 
!transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+@match_structured_body_elementwise -> @print_elementwise
+: (!transform.any_op) -> !transform.any_op
+transform.yield
+  }
+
+  func.func @payload(%in1: tensor<2xf32>, %in2: tensor<2xf32>, %out: 
tensor<2xf32>) -> tensor<2xf32> attributes { transform.target_tag = 

[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

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


[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/79626

>From ab475c9ffb7c3562bad4772389e97b82e9f110c0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Fri, 26 Jan 2024 11:55:06 -0600
Subject: [PATCH 1/3] Add elementwise criteria to match.structured.body

---
 .../Linalg/TransformOps/LinalgMatchOps.td |  4 +++
 .../Linalg/TransformOps/LinalgMatchOps.cpp|  9 -
 .../Dialect/Linalg/match-ops-interpreter.mlir | 34 +++
 .../Dialect/Linalg/match-ops-invalid.mlir |  2 +-
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f..dfeb8ae5d5ddbc 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063a..fb18886c16b16d 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block  = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e..0efe70a7b9ae1e 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,40 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.test_print_remark_at_operand %arg0, "elementwise" : 
!transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+@match_structured_body_elementwise -> @print_elementwise
+: (!transform.any_op) -> !transform.any_op
+transform.yield
+  }
+
+  func.func @payload(%in1: tensor<2xf32>, %in2: tensor<2xf32>, %out: 
tensor<2xf32>) -> tensor<2xf32> attributes { transform.target_tag = 

[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/79624

>From 7979269a57fc553a7b010a36b9c75bf570adf674 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 26 Jan 2024 09:34:11 -0800
Subject: [PATCH 1/2] [lldb] Fix progress reporting for
 SymbolLocatorDebugSymbols

This fixes two issues related to the DebugSymbols symbol locator:

  1. Only the default symbol locator plugin reports progress. On Darwin,
 which uses the DebugSymbols framework we need to report the same
 progress form the corresponding SymbolLocator plugin.

  2. Forceful dSYM lookups, for example when using `add-dsym`, use a
 different code path that currently does not report progress, which
 is confusing. Here the progress event can be more specific and
 specify its downloading a symbol file rather than just locating it
 as we'll always shell out to dsymForUUID or its equivalent.

rdar://121629777
---
 .../SymbolLocatorDebugSymbols.cpp | 39 ++-
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
index 9f32d252b22f5bd..24e563d6ee0f353 100644
--- 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
+++ 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",
+  module_spec.GetFileSpec().GetFilename().AsCString(""));
+
   FileSpec symbol_fspec;
   ModuleSpec dsym_module_spec;
   // First try and find the dSYM in the same directory as the executable or in
@@ -1050,28 +1054,25 @@ bool 
SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(
   const std::string file_path_str =
   file_spec_ptr ? file_spec_ptr->GetPath() : "";
 
-  Log *log = GetLog(LLDBLog::Host);
+  if (uuid_str.empty() && file_path_str.empty())
+return false;
 
   // Create the dsymForUUID command.
-  StreamString command;
+  const char *lookup_arg =
+  !uuid_str.empty() ? uuid_str.c_str() : file_path_str.c_str();
   const char *copy_executable_arg = copy_executable ? "--copyExecutable " : "";
-  if (!uuid_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   uuid_str.c_str());
-LLDB_LOGF(log, "Calling %s with UUID %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), uuid_str.c_str(),
-  command.GetString().data());
-  } else if (!file_path_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   file_path_str.c_str());
-LLDB_LOGF(log, "Calling %s with file %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), file_path_str.c_str(),
-  command.GetString().data());
-  } else {
-return false;
-  }
+
+  StreamString command;
+  command.Printf("%s --ignoreNegativeCache %s%s", dsymForUUID_exe_path.c_str(),
+ copy_executable_arg, lookup_arg);
+
+  // Log and report progress.
+  Log *log = GetLog(LLDBLog::Host);
+  LLDB_LOGF(log, "Calling %s with %s to find dSYM: %s",
+dsymForUUID_exe_path.c_str(), lookup_arg,
+command.GetString().data());
+
+  Progress progress("Downloading symbol file", lookup_arg);
 
   // Invoke dsymForUUID.
   int exit_status = -1;

>From 69015699499e23de26d61bd0faa16fcbc75bba49 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 26 Jan 2024 12:57:24 -0800
Subject: [PATCH 2/2] Avoid C-String Conversions

---
 .../SymbolLocatorDebugSymbols.cpp | 24 +--
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
index 24e563d6ee0f353..f7df4650941a800 100644
--- 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
+++ 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
@@ -1049,28 +1049,26 @@ bool 
SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(
   if (!dsymForUUID_exe_spec)
 return false;
 
+  // Create the dsymForUUID command.
   const std::string dsymForUUID_exe_path = dsymForUUID_exe_spec.GetPath();
   const std::string uuid_str = uuid_ptr ? uuid_ptr->GetAsString() : "";
-  const std::string file_path_str =
-  file_spec_ptr ? file_spec_ptr->GetPath() : "";
 
-  if (uuid_str.empty() && file_path_str.empty())
+  std::string lookup_arg = uuid_str;
+  if (lookup_arg.empty())
+

[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/79626

>From ab475c9ffb7c3562bad4772389e97b82e9f110c0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Fri, 26 Jan 2024 11:55:06 -0600
Subject: [PATCH 1/2] Add elementwise criteria to match.structured.body

---
 .../Linalg/TransformOps/LinalgMatchOps.td |  4 +++
 .../Linalg/TransformOps/LinalgMatchOps.cpp|  9 -
 .../Dialect/Linalg/match-ops-interpreter.mlir | 34 +++
 .../Dialect/Linalg/match-ops-invalid.mlir |  2 +-
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f2..dfeb8ae5d5ddbcb 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063ac..fb18886c16b16d5 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block  = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e4..0efe70a7b9ae1eb 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,40 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.test_print_remark_at_operand %arg0, "elementwise" : 
!transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+@match_structured_body_elementwise -> @print_elementwise
+: (!transform.any_op) -> !transform.any_op
+transform.yield
+  }
+
+  func.func @payload(%in1: tensor<2xf32>, %in2: tensor<2xf32>, %out: 
tensor<2xf32>) -> tensor<2xf32> attributes { transform.target_tag = 

[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/79626

>From ab475c9ffb7c3562bad4772389e97b82e9f110c0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Fri, 26 Jan 2024 11:55:06 -0600
Subject: [PATCH] Add elementwise criteria to match.structured.body

---
 .../Linalg/TransformOps/LinalgMatchOps.td |  4 +++
 .../Linalg/TransformOps/LinalgMatchOps.cpp|  9 -
 .../Dialect/Linalg/match-ops-interpreter.mlir | 34 +++
 .../Dialect/Linalg/match-ops-invalid.mlir |  2 +-
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f2..dfeb8ae5d5ddbcb 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063ac..fb18886c16b16d5 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block  = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e4..0efe70a7b9ae1eb 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,40 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.test_print_remark_at_operand %arg0, "elementwise" : 
!transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+@match_structured_body_elementwise -> @print_elementwise
+: (!transform.any_op) -> !transform.any_op
+transform.yield
+  }
+
+  func.func @payload(%in1: tensor<2xf32>, %in2: tensor<2xf32>, %out: 
tensor<2xf32>) -> tensor<2xf32> attributes { transform.target_tag = 

[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread lorenzo chelini via lldb-commits

chelini wrote:

Is it ready for review? Is marked as "draft".

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -831,6 +831,37 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   return true;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
+PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl _impl,
+lldb_private::CommandReturnObject _retobj,
+lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  PythonObject self(PyRefType::Borrowed, implementor);
+  auto pfunc = self.ResolveName("__call__");
+
+  if (!pfunc.IsAllocated())
+return false;
+
+  auto cmd_retobj_arg = SWIGBridge::ToSWIGWrapper(cmd_retobj);

jimingham wrote:

That must have been problematic in development.  This sort of compressed style 
is less good when you are debugging...

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


[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread Dave Lee via lldb-commits

kastiglione wrote:

Because of clang-format, the diff obscures the fact that this change only 
deletes `(( )?&)?` from these strings. There are no other changes.

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


[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes

The `(( )?)?` appears to match types which are references. However lldb 
can load the
correct data formatters without having to pattern match against a `` 
suffix.

The suffix may have been needed at one point, but it's no longer needed.


---
Full diff: https://github.com/llvm/llvm-project/pull/79644.diff


1 Files Affected:

- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
(+79-87) 


``diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index f0fe6c9e06d9d4..e0de80880376ac 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -744,46 +744,46 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxBitsetSyntheticFrontEndCreator,
   "libc++ std::bitset synthetic children",
-  "^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::bitset<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
   "libc++ std::vector synthetic children",
-  "^std::__[[:alnum:]]+::vector<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::vector<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdForwardListSyntheticFrontEndCreator,
   "libc++ std::forward_list synthetic children",
-  "^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$", stl_synth_flags, 
true);
+  "^std::__[[:alnum:]]+::forward_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
   "libc++ std::list synthetic children",
-  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( 
)?&)?$"
-  // so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
+  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>$"
+  // so that it does not clash with: "^std::(__cxx11::)?list<.+>$"
   "^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
-  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$",
+  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>$",
   stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::map synthetic children",
-  "^std::__[[:alnum:]]+::map<.+> >(( )?&)?$", stl_synth_flags, true);
+  "libc++ std::map synthetic children", "^std::__[[:alnum:]]+::map<.+> >$",
+  stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::set synthetic children",
-  "^std::__[[:alnum:]]+::set<.+> >(( )?&)?$", stl_deref_flags, true);
+  "libc++ std::set synthetic children", "^std::__[[:alnum:]]+::set<.+> >$",
+  stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multiset synthetic children",
-  "^std::__[[:alnum:]]+::multiset<.+> >(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::multiset<.+> >$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multimap synthetic children",
-  "^std::__[[:alnum:]]+::multimap<.+> >(( )?&)?$", stl_synth_flags, true);
+  "^std::__[[:alnum:]]+::multimap<.+> >$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
@@ -794,23 +794,19 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator,
   "libc++ std::initializer_list synthetic children",
-  "^std::initializer_list<.+>(( )?&)?$", stl_synth_flags, true);
+  "^std::initializer_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(cpp_category_sp, LibcxxQueueFrontEndCreator,
   "libc++ std::queue synthetic children",
-  "^std::__[[:alnum:]]+::queue<.+>(( )?&)?$", stl_synth_flags,
-  true);
+  "^std::__[[:alnum:]]+::queue<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(cpp_category_sp, LibcxxTupleFrontEndCreator,
   "libc++ std::tuple synthetic children",
-  "^std::__[[:alnum:]]+::tuple<.*>(( )?&)?$", stl_synth_flags,
-  true);
+  "^std::__[[:alnum:]]+::tuple<.*>$", 

[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Adrian Prantl via lldb-commits


@@ -1050,28 +1054,25 @@ bool 
SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(
   const std::string file_path_str =
   file_spec_ptr ? file_spec_ptr->GetPath() : "";
 
-  Log *log = GetLog(LLDBLog::Host);
+  if (uuid_str.empty() && file_path_str.empty())
+return false;
 
   // Create the dsymForUUID command.
-  StreamString command;
+  const char *lookup_arg =
+  !uuid_str.empty() ? uuid_str.c_str() : file_path_str.c_str();
   const char *copy_executable_arg = copy_executable ? "--copyExecutable " : "";
-  if (!uuid_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   uuid_str.c_str());
-LLDB_LOGF(log, "Calling %s with UUID %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), uuid_str.c_str(),
-  command.GetString().data());
-  } else if (!file_path_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   file_path_str.c_str());
-LLDB_LOGF(log, "Calling %s with file %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), file_path_str.c_str(),
-  command.GetString().data());
-  } else {
-return false;
-  }
+
+  StreamString command;

adrian-prantl wrote:

more unnecessary comments about unnecessary c string conversions :-)
```
llvm::SmallString<64> buf;
llvm::raw_svector_ostream(buf) << ...;
```

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Adrian Prantl via lldb-commits


@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",
+  module_spec.GetFileSpec().GetFilename().AsCString(""));

adrian-prantl wrote:

Aside: Looks like we're missing a AsString() method in ConstString so we can 
avoid the roundtrip through `char *`

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


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


[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/79644

The `(( )?&)?` appears to match types which are references. However lldb can 
load the
correct data formatters without having to pattern match against a `&` suffix.

The suffix may have been needed at one point, but it's no longer needed.


>From a5e72e90edb907c287df219eb2abeee67f4eb115 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 25 Jan 2024 15:55:51 -0800
Subject: [PATCH] [lldb] Remove unnecessary suffix from libc++ type name
 patterns (NFC)

The `(( )?&)?` appears to match types which are references. However lldb can 
load the
correct data formatters without having to pattern match against a `&` suffix.

The suffix may have been needed at one point, but it's no longer needed.
---
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 166 +-
 1 file changed, 79 insertions(+), 87 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index f0fe6c9e06d9d47..e0de80880376acb 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -744,46 +744,46 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxBitsetSyntheticFrontEndCreator,
   "libc++ std::bitset synthetic children",
-  "^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::bitset<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
   "libc++ std::vector synthetic children",
-  "^std::__[[:alnum:]]+::vector<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::vector<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdForwardListSyntheticFrontEndCreator,
   "libc++ std::forward_list synthetic children",
-  "^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$", stl_synth_flags, 
true);
+  "^std::__[[:alnum:]]+::forward_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
   "libc++ std::list synthetic children",
-  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( 
)?&)?$"
-  // so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
+  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>$"
+  // so that it does not clash with: "^std::(__cxx11::)?list<.+>$"
   "^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
-  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$",
+  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>$",
   stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::map synthetic children",
-  "^std::__[[:alnum:]]+::map<.+> >(( )?&)?$", stl_synth_flags, true);
+  "libc++ std::map synthetic children", "^std::__[[:alnum:]]+::map<.+> >$",
+  stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::set synthetic children",
-  "^std::__[[:alnum:]]+::set<.+> >(( )?&)?$", stl_deref_flags, true);
+  "libc++ std::set synthetic children", "^std::__[[:alnum:]]+::set<.+> >$",
+  stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multiset synthetic children",
-  "^std::__[[:alnum:]]+::multiset<.+> >(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::multiset<.+> >$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multimap synthetic children",
-  "^std::__[[:alnum:]]+::multimap<.+> >(( )?&)?$", stl_synth_flags, true);
+  "^std::__[[:alnum:]]+::multimap<.+> >$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
@@ -794,23 +794,19 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator,
   "libc++ std::initializer_list synthetic children",
-  "^std::initializer_list<.+>(( )?&)?$", stl_synth_flags, true);
+  "^std::initializer_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(cpp_category_sp, LibcxxQueueFrontEndCreator,
   "libc++ std::queue synthetic children",
-  "^std::__[[:alnum:]]+::queue<.+>(( )?&)?$", stl_synth_flags,
-   

[Lldb-commits] [flang] [lldb] [lld] [clang-tools-extra] [libunwind] [llvm] [mlir] [compiler-rt] [libcxx] [clang] [libc] Reland: [libc++][format] P2637R3: Member visit (std::basic_format_arg) #76449 (P

2024-01-26 Thread Hristo Hristov via lldb-commits

Zingam wrote:

@petrhosek According to the log, the tests in this patch pass. Could you please 
try again. I'll wait a while and if there is not negative feedback I'll reland 
the patch.

> https://logs.chromium.org/logs/fuchsia/led/phosek_google.com/62644843c966785c9dedf065a79d80df8734b4df5ff7703ea3c2a2b5643cec05/+/u/clang/test/stdout
>  is the full log.

```
 PASS: llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit.pass.cpp (8505 of 9639)
 PASS: llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp 
(8506 of 9639)
 PASS: llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp 
(8537 of 9639)
 PASS: llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp
 (8439 of 9639)
```



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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Jonas Devlieghere via lldb-commits


@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",

JDevlieghere wrote:

We're looking for the symbol file (although dsymForUUID can also get you the 
symbol rich binary). This is the same message already emitted by 
`SymbolLocatorDefault::LocateExecutableSymbolFile`. 

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -831,6 +831,37 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   return true;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
+PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl _impl,
+lldb_private::CommandReturnObject _retobj,
+lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  PythonObject self(PyRefType::Borrowed, implementor);
+  auto pfunc = self.ResolveName("__call__");
+
+  if (!pfunc.IsAllocated())
+return false;

jimingham wrote:

I added this here, but we really need a more general mechanism for informing 
the user when the python code we've been handed is lacking some affordance.  
Most of these wrappers don't have a CommandReturnObject to complain through.

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Greg Clayton via lldb-commits


@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",

clayborg wrote:

Are we looking for an executable here, or the dSYM file? Should be title be 
"Locating executable file"?

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


[Lldb-commits] [flang] [lldb] [lld] [clang-tools-extra] [libunwind] [llvm] [mlir] [compiler-rt] [libcxx] [clang] [libc] Reland: [libc++][format] P2637R3: Member visit (std::basic_format_arg) #76449 (P

2024-01-26 Thread Hristo Hristov via lldb-commits

https://github.com/Zingam updated 
https://github.com/llvm/llvm-project/pull/79032

>From e03452fda84a5284420bba1913299b68caabb6cd Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Mon, 22 Jan 2024 20:35:00 +0200
Subject: [PATCH 1/6] Revert "Revert "[libc++][format] P2637R3: Member `visit`
 (`std::basic_format_arg`) (#76449)""

This reverts commit 02f95b77515fe18ed1076b94cbb850ea0cf3c77e.
---
 libcxx/docs/ReleaseNotes/18.rst   |   1 +
 libcxx/docs/Status/Cxx2cPapers.csv|   2 +-
 libcxx/docs/Status/FormatIssues.csv   |   2 +-
 libcxx/include/__config   |   6 +
 libcxx/include/__format/format_arg.h  | 109 +-
 libcxx/include/__format/format_context.h  |  33 +-
 libcxx/include/format |   2 +-
 .../format.arg/visit.pass.cpp | 333 
 .../format.arg/visit.return_type.pass.cpp | 369 ++
 .../visit_format_arg.deprecated.verify.cpp|  38 ++
 .../format.arg/visit_format_arg.pass.cpp  |   6 +-
 .../format.arguments/format.args/get.pass.cpp |  48 ++-
 libcxx/test/support/test_basic_format_arg.h   |  20 +-
 libcxx/test/support/test_macros.h |   5 +
 .../generate_feature_test_macro_components.py |   1 +
 15 files changed, 927 insertions(+), 48 deletions(-)
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp

diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fd882bafe19a51..237a63022d55ff 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -79,6 +79,7 @@ Implemented Papers
 - P1759R6 - Native handles and file streams
 - P2868R3 - Remove Deprecated ``std::allocator`` Typedef From C++26
 - P2517R1 - Add a conditional ``noexcept`` specification to ``std::apply``
+- P2637R3 - Member ``visit``
 - P2447R6 - ``span`` over initializer list
 
 
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index f80b1f6b663f04..c45aa3c510072e 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -17,7 +17,7 @@
 "`P0792R14 `__","LWG","``function_ref``: a 
type-erased callable reference","Varna June 2023","","",""
 "`P2874R2 `__","LWG","Mandating Annex D Require No 
More","Varna June 2023","","",""
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
-"`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","|Partial|","18.0",""
+"`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","|Complete|","18.0",""
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
 "`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
diff --git a/libcxx/docs/Status/FormatIssues.csv 
b/libcxx/docs/Status/FormatIssues.csv
index 513988d08036ca..6e58e752191ea5 100644
--- a/libcxx/docs/Status/FormatIssues.csv
+++ b/libcxx/docs/Status/FormatIssues.csv
@@ -16,7 +16,7 @@ Number,Name,Standard,Assignee,Status,First released version
 "`P2693R1 `__","Formatting ``thread::id`` and 
``stacktrace``","C++23","Mark de Wever","|In Progress|"
 "`P2510R3 `__","Formatting pointers","C++26","Mark 
de Wever","|Complete|",17.0
 "`P2757R3 `__","Type-checking format 
args","C++26","","",
-"`P2637R3 `__","Member ``visit``","C++26","","",
+"`P2637R3 `__","Member ``visit``","C++26","Hristo 
Hristov","|Complete|",18.0
 "`P2905R2 `__","Runtime format strings","C++26 
DR","Mark de Wever","|Complete|",18.0
 "`P2918R2 `__","Runtime format strings 
II","C++26","Mark de Wever","|Complete|",18.0
 "`P2909R4 `__","Fix formatting of code units as 
integers (Dude, where’s my ``char``?)","C++26 DR","Mark de 
Wever","|Complete|",18.0
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 9a64cdb489119d..00489d971c296c 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -995,6 +995,12 @@ typedef __char32_t char32_t;
 #define _LIBCPP_DEPRECATED_IN_CXX23
 #  endif
 
+#  if _LIBCPP_STD_VER >= 26
+#define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
+#  else
+#define _LIBCPP_DEPRECATED_IN_CXX26
+#  endif
+
 #  if 

[Lldb-commits] [clang] [libcxx] [flang] [lld] [libunwind] [libc] [compiler-rt] [lldb] [clang-tools-extra] [llvm] [mlir] Reland: [libc++][format] P2637R3: Member visit (std::basic_format_arg) #76449 (P

2024-01-26 Thread Hristo Hristov via lldb-commits

Zingam wrote:

@petrhosek It is not related. It was supposedly fixed by this: 
https://github.com/llvm/llvm-project/pull/79619
I've been observing the chromium Windows CI failing for a while. Let's see if 
the above patch fixes it. I'll rebase now this one now.

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


[Lldb-commits] [lldb] [lldb] Fix a crash when using .dwp files and make type lookup reliable with the index cache (PR #79544)

2024-01-26 Thread Greg Clayton via lldb-commits

clayborg wrote:

> I'm not following all of this, but it appears to be based on the premise that 
> it's OK that sometimes split units inside a DWP file are parsed before their 
> skeleton unit? Why is that OK/when/why/where is that happening?

When we have accelerator tables from lldb index cache being loaded from disk, 
we have a DIERef object for each matching name. This DIERef objects has a magic 
file index that specifies that this is from the .dwp file. When we do a type 
lookup and get these kinds of entries, we go straight to the `.dwp` file and 
load `.dwo` in the `.dwp` and this causes the issue. 

> I'd think any case where that happens would be a performance (& possibly 
> correctness bug) & it'd be better to maintain the invariant that the only way 
> you ever parse a split unit is starting from the skeleton - rather than 
> adding maps/etc to be able to backtrack to parsing the skeleton when you 
> already have the split unit.

That might mean that anytime we use _any_ DWARFDie, we will need to add 
functionality that checks with the DWARFUnit to verify if it is a .dwo unit, 
and if so, make sure its skeleton unit has been parsed. The current solution 
allows anyone to just work with the existing APIs and they will do the right 
thing and will only grab the backlink if it isn't already set. With DWARF5 it 
is cheap as the info is in the unit headers. 

Without this solution we will have to always parse the skeleton unit headers 
for the main executable and need to parse at least the first DIE in order to 
fill in the .dwo file's skeleton backlink pointer. So this can cause us to pull 
in more DWARF during type lookups.

If you are really against this approach I can search for a solution that avoids 
the maps, but I fear more hidden bugs will arise in the future without an 
approach similar to what this PR does. The current bugs either crashed the 
debug session or stopped type lookups from working. 


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


[Lldb-commits] [libc] [llvm] [clang-tools-extra] [flang] [libunwind] [lld] [lldb] [mlir] [libcxx] [compiler-rt] [clang] Reland: [libc++][format] P2637R3: Member visit (std::basic_format_arg) #76449 (P

2024-01-26 Thread Petr Hosek via lldb-commits

petrhosek wrote:

I tried this branch on our Windows builders although I'm not sure if it's 
related or not to this patch:
```
# COMPILED WITH
C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp
 --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
-nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
C:/b/s/w/ir/x/w/github-H-G-Hristov-llvm-project/libcxx/test/support 
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall 
-Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings  -llibc++experimental -nostdlib -L 
C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\libcxx\fuzzing\Output\random.pass.cpp.dir\t.tmp.exe
# executed command: C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
'C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp'
 --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
-nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
C:/b/s/w/ir/x/w/github-H-G-Hristov-llvm-project/libcxx/test/support 
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall 
-Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings -llibc++experimental -nostdlib -L 
C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
'C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\libcxx\fuzzing\Output\random.pass.cpp.dir\t.tmp.exe'
# .---command stderr
# | In file included from 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:16:
# | In file included from C:/b/s/w/ir/x/w/llvm_build/include/c++/v1\cmath:319:
# | In file included from C:/b/s/w/ir/x/w/llvm_build/include/c++/v1\math.h:301:
# | In file included from C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\math.h:11:
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:413:16: error: call to 
'fpclassify' is ambiguous
# |   413 | return fpclassify(_X) == FP_NAN;
# |   |^~
# | 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:166:12:
 note: in instantiation of function template specialization 'isnan' 
requested here
# |   166 |   if (std::isnan(res)) {
# |   |^
# | 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:178:10:
 note: in instantiation of function template specialization 
'helper>' requested here
# |   178 |   return helper>(data, 
size)   ||
# |   |  ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:288:31: note: candidate 
function
# |   288 | _Check_return_ inline int fpclassify(_In_ float _X) throw()
# |   |   ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:293:31: note: candidate 
function
# |   293 | _Check_return_ inline int fpclassify(_In_ double _X) throw()
# |   |   ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:298:31: note: candidate 
function
# |   298 | 

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -831,6 +831,37 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   return true;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
+PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl _impl,
+lldb_private::CommandReturnObject _retobj,
+lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  PythonObject self(PyRefType::Borrowed, implementor);
+  auto pfunc = self.ResolveName("__call__");

jimingham wrote:

We don't do any checking for arguments in any of the `pfunc` lookups in the 
python wrapper, except in one or two cases where we support overloaded 
implementation functions.  I don't think doing this piecemeal is a great idea.  
It would be better to have some kind of `check_pfunc` feature that does the 
lookup and takes some specification about what to expect of the found function. 
 Then we can insert this in all the current lookups.
But this patch is long enough already, it would be better to do that as a 
separate patch.

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


[Lldb-commits] [clang-tools-extra] [libcxx] [clang] [lld] [lldb] [llvm] [mlir] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/79626

>From ab475c9ffb7c3562bad4772389e97b82e9f110c0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Fri, 26 Jan 2024 11:55:06 -0600
Subject: [PATCH] Add elementwise criteria to match.structured.body

---
 .../Linalg/TransformOps/LinalgMatchOps.td |  4 +++
 .../Linalg/TransformOps/LinalgMatchOps.cpp|  9 -
 .../Dialect/Linalg/match-ops-interpreter.mlir | 34 +++
 .../Dialect/Linalg/match-ops-invalid.mlir |  2 +-
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f..dfeb8ae5d5ddbc 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063a..fb18886c16b16d 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block  = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e..0efe70a7b9ae1e 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,40 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.test_print_remark_at_operand %arg0, "elementwise" : 
!transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+@match_structured_body_elementwise -> @print_elementwise
+: (!transform.any_op) -> !transform.any_op
+transform.yield
+  }
+
+  func.func @payload(%in1: tensor<2xf32>, %in2: tensor<2xf32>, %out: 
tensor<2xf32>) -> tensor<2xf32> attributes { transform.target_tag = 
"start_here" 

[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, ));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster  = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");
+
+std::this_thread::sleep_for(timeout);
+  }
+
+  // Progress report objects should be destroyed at this point so
+  // get each report from the queue and check that they've been
+  // destroyed in reverse order
+  std::this_thread::sleep_for(timeout);
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  ASSERT_EQ(data->GetTitle(), "Progress report 3");
+  ASSERT_TRUE(data->GetCompleted());

clayborg wrote:

Add a few more tests for each complete event
```
ASSERT_FALSE(data->IsFinite());
ASSERT_EQ(data->GetMessage(), "...");
```

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, ));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster  = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");

clayborg wrote:

If we are looking to verify things are delivered in the order that they were 
supplied, do you want to do all of the event checking outside of this loop? 
Otherwise the only thing on the event queue here is the data we are looking for 
so this doesn't help us to verify that we got things in the order that they 
were pushed onto the queue. We should be able to do:
```
{
  Progress progress1("Progress report 1", "Starting report 1");
  Progress progress2("Progress report 2", "Starting report 2");
  Progress progress3("Progress report 3", "Starting report 3");
}
// Now check that we got all events in the right order for both the start and 
completed
// check progress started for "Progress report 1"
// check progress started for "Progress report 2"
// check progress started for "Progress report 3"
// check progress completed for "Progress report 1"
// check progress completed for "Progress report 2"
// check progress completed for "Progress report 3"
```
This will help us verify the order of things. 

Might be a good idea to do a check for progress reports with a valid total as 
well, and test that if we increment too many times that we don't deliver 
multiple completed events
```
{
  Progress progress1("Progress report 1", "Starting report 1");
  Progress progress2("Progress report 2", "Starting report 2");
  Progress progress3("Progress report 3", "Starting report 3");
  Progress progress4("Progress report 4", "Starting report 4", 2);
  progress4.Increment(1, "progress detail 1");
  // This should cause the progress to complete
  progress4.Increment(1, "progress detail 2"); 
  // The progress is already completed, I would expect to not see any more 
events for this progress
  progress4.Increment(1, "too many, we shouldn't see this!");
}
```
And when verifying the events for `progress4`:
```
ASSERT_TRUE(data->IsFinite());
ASSERT_FALSE|ASSERT_TRUE(data->GetCompleted()); // Make sure this is correct 
for each event
ASSERT_EQ(data->GetTotal(), 2);
ASSERT_EQ(data->GetMessage(), "..."); // Make sure this is correct for each 
increment
```

https://github.com/llvm/llvm-project/pull/79533
___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, ));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster  = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");

clayborg wrote:

It would be good to verify a few more things here for each start event:
```
ASSERT_FALSE(data->IsFinite());
ASSERT_FALSE(data->GetCompleted());
ASSERT_EQ(data->GetTotal(), 1);
ASSERT_EQ(data->GetMessage(), "Progress report 1: Starting report 1");
```

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

It is great to have unit tests for this. I remember with your previous patch we 
caught an issue where the completed event might not be delivered, or it would 
be delivered without the values being set correctly, so this will be great to 
be able to catch this kind of stuff when we make changes.

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -831,6 +831,37 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   return true;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
+PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl _impl,

jimingham wrote:

It's spelled incorrectly in the whole rest of this file except for the thread 
plan instances.  We should either get rid of all of these by using 
ScriptedPythonInterface, or fix all the spellings to be consistent, but that 
seems better as a separate commit.

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits

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

>From 9274bcd897cd3ecdb3a842bc72ee660ba335aa57 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 25 Jan 2024 16:40:42 -0800
Subject: [PATCH 1/2] [lldb][progress][NFC] Add unit test for progress reports

This test is being added as a way to check the behaviour of how progress
events are broadcasted when reports are started and ended with the
current implementation of progress reports. Here we're mainly checking
and ensuring that the current behaviour is that progress events are
broadcasted individually and placed in the event queue in order of
their creation.
---
 lldb/unittests/Core/CMakeLists.txt |   1 +
 lldb/unittests/Core/ProgressReportTest.cpp | 105 +
 2 files changed, 106 insertions(+)
 create mode 100644 lldb/unittests/Core/ProgressReportTest.cpp

diff --git a/lldb/unittests/Core/CMakeLists.txt 
b/lldb/unittests/Core/CMakeLists.txt
index b3cddd150635b1..d40c357e3f463b 100644
--- a/lldb/unittests/Core/CMakeLists.txt
+++ b/lldb/unittests/Core/CMakeLists.txt
@@ -7,6 +7,7 @@ add_lldb_unittest(LLDBCoreTests
   FormatEntityTest.cpp
   MangledTest.cpp
   ModuleSpecTest.cpp
+  ProgressReportTest.cpp
   RichManglingContextTest.cpp
   SourceLocationSpecTest.cpp
   SourceManagerTest.cpp
diff --git a/lldb/unittests/Core/ProgressReportTest.cpp 
b/lldb/unittests/Core/ProgressReportTest.cpp
new file mode 100644
index 00..bdc168c9e077dd
--- /dev/null
+++ b/lldb/unittests/Core/ProgressReportTest.cpp
@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, ));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster  = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");
+
+std::this_thread::sleep_for(timeout);
+  }
+
+  // Progress report objects should be destroyed at this point so
+  // get each report from the queue and check that they've been
+  // destroyed in reverse order
+  std::this_thread::sleep_for(timeout);
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  ASSERT_EQ(data->GetTitle(), "Progress report 3");
+  ASSERT_TRUE(data->GetCompleted());
+
+  std::this_thread::sleep_for(timeout);
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  ASSERT_EQ(data->GetTitle(), "Progress report 2");
+  ASSERT_TRUE(data->GetCompleted());
+
+  

[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> This is only testing the `Progress` class constructor behavior. Could you 
> check that the `Progress::Increment` method works as expected ?

While it would be nice to have full test coverage, the goal was to cover the 
existing behavior which we'll modify/extend to coalesce events as discussed in 
the 
[RFC](https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717/). 
Increments are orthogonal to that so I think it's fine to keep that for a 
separate PR. 

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"

chelcassanova wrote:

Will do! I told myself I'd add it at the end then I fully forgot to do that  

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


[Lldb-commits] [lldb] 02d3a79 - [lldb][NFCI] Remove EventData* parameter from BroadcastEventIfUnique (#79045)

2024-01-26 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-26T10:40:33-08:00
New Revision: 02d3a799e7eb2997950d6a288a08a5e51ff0ff59

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

LOG: [lldb][NFCI] Remove EventData* parameter from BroadcastEventIfUnique 
(#79045)

Instead of passing the data to BroadcastEventIfUnique to create an Event
object on the behalf of the caller, the caller can create the Event
up-front.

Added: 


Modified: 
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Utility/Broadcaster.h
lldb/source/Target/Process.cpp
lldb/source/Utility/Broadcaster.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 24c599e044c78fa..4599a0dc8821966 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -3216,6 +3216,8 @@ void PruneThreadPlans();
   Status LaunchPrivate(ProcessLaunchInfo _info, lldb::StateType ,
lldb::EventSP _sp);
 
+  lldb::EventSP CreateEventFromProcessState(uint32_t event_type);
+
   Process(const Process &) = delete;
   const Process =(const Process &) = delete;
 };

diff  --git a/lldb/include/lldb/Utility/Broadcaster.h 
b/lldb/include/lldb/Utility/Broadcaster.h
index c8127f0a921d882..f39e677fe9ee041 100644
--- a/lldb/include/lldb/Utility/Broadcaster.h
+++ b/lldb/include/lldb/Utility/Broadcaster.h
@@ -181,9 +181,8 @@ class Broadcaster {
 m_broadcaster_sp->BroadcastEvent(event_type);
   }
 
-  void BroadcastEventIfUnique(uint32_t event_type,
-  EventData *event_data = nullptr) {
-m_broadcaster_sp->BroadcastEventIfUnique(event_type, event_data);
+  void BroadcastEventIfUnique(uint32_t event_type) {
+m_broadcaster_sp->BroadcastEventIfUnique(event_type);
   }
 
   void Clear() { m_broadcaster_sp->Clear(); }
@@ -351,8 +350,7 @@ class Broadcaster {
 void BroadcastEvent(uint32_t event_type,
 const lldb::EventDataSP _data_sp);
 
-void BroadcastEventIfUnique(uint32_t event_type,
-EventData *event_data = nullptr);
+void BroadcastEventIfUnique(uint32_t event_type);
 
 void Clear();
 

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index e1c16ca21643227..23a8a66645c02d6 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4281,25 +4281,31 @@ void 
Process::CalculateExecutionContext(ExecutionContext _ctx) {
 //return Host::GetArchSpecForExistingProcess (process_name);
 //}
 
+EventSP Process::CreateEventFromProcessState(uint32_t event_type) {
+  auto event_data_sp =
+  std::make_shared(shared_from_this(), GetState());
+  return std::make_shared(event_type, event_data_sp);
+}
+
 void Process::AppendSTDOUT(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stdout_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDOUT,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDOUT);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::AppendSTDERR(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stderr_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDERR,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDERR);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::BroadcastAsyncProfileData(const std::string _profile_data) {
   std::lock_guard guard(m_profile_data_comm_mutex);
   m_profile_data.push_back(one_profile_data);
-  BroadcastEventIfUnique(eBroadcastBitProfileData,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitProfileData);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::BroadcastStructuredData(const StructuredData::ObjectSP 
_sp,

diff  --git a/lldb/source/Utility/Broadcaster.cpp 
b/lldb/source/Utility/Broadcaster.cpp
index 33cd49963e7c74c..12903edc36b1b98 100644
--- a/lldb/source/Utility/Broadcaster.cpp
+++ b/lldb/source/Utility/Broadcaster.cpp
@@ -311,9 +311,8 @@ void Broadcaster::BroadcasterImpl::BroadcastEvent(
   PrivateBroadcastEvent(event_sp, false);
 }
 
-void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(
-uint32_t event_type, EventData *event_data) {
-  auto event_sp = std::make_shared(event_type, event_data);
+void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(uint32_t event_type) 
{
+  auto event_sp = std::make_shared(event_type, /*data = */ nullptr);
   PrivateBroadcastEvent(event_sp, true);
 }
 



___

  1   2   >