[Lldb-commits] [lldb] [lldb] Fix build on NetBSD (PR #74190)

2023-12-04 Thread Brad Smith via lldb-commits

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


[Lldb-commits] [lldb] c1e2457 - [lldb] Fix build on NetBSD (#74190)

2023-12-04 Thread via lldb-commits

Author: Brad Smith
Date: 2023-12-04T03:01:38-05:00
New Revision: c1e2457a14f865371bb2dcba260ace32e3a2f71b

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

LOG: [lldb] Fix build on NetBSD (#74190)

lldb/source/Host/netbsd/HostNetBSD.cpp:112:32: error: reinterpret_cast from 
'const uint8_t *' (aka 'const unsigned char *') to 'char *' casts away 
qualifiers
  {reinterpret_cast(buffer_sp->GetBytes()),
   ^~~
1 error generated.

Added: 


Modified: 
lldb/source/Host/netbsd/HostNetBSD.cpp

Removed: 




diff  --git a/lldb/source/Host/netbsd/HostNetBSD.cpp 
b/lldb/source/Host/netbsd/HostNetBSD.cpp
index c47b96a5ceda6..de8b2fd7cb0cc 100644
--- a/lldb/source/Host/netbsd/HostNetBSD.cpp
+++ b/lldb/source/Host/netbsd/HostNetBSD.cpp
@@ -108,10 +108,11 @@ static bool GetNetBSDProcessCPUType(ProcessInstanceInfo 
&process_info) {
 auto buffer_sp = FileSystem::Instance().CreateDataBuffer(
 process_info.GetExecutableFile(), 0x20, 0);
 if (buffer_sp) {
-  uint8_t exe_class = llvm::object::getElfArchType(
-  {reinterpret_cast(buffer_sp->GetBytes()),
-   size_t(buffer_sp->GetByteSize())})
-  .first;
+  uint8_t exe_class =
+  llvm::object::getElfArchType(
+  {reinterpret_cast(buffer_sp->GetBytes()),
+   size_t(buffer_sp->GetByteSize())})
+  .first;
 
   switch (exe_class) {
   case llvm::ELF::ELFCLASS32:



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


[Lldb-commits] [lldb] b96bae2 - [lldb] Fix building on NetBSD 8.x (#74191)

2023-12-04 Thread via lldb-commits

Author: Brad Smith
Date: 2023-12-04T03:02:13-05:00
New Revision: b96bae2887f276345f9c0ea9974703e8dd3b5ddf

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

LOG: [lldb] Fix building on NetBSD 8.x (#74191)

PT_STOP was introduced with NetBSD 9.0.

Added: 


Modified: 
lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp 
b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
index 26c562bd47905..451bb48660371 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -379,6 +379,29 @@ void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, 
int signal) {
   SetState(StateType::eStateStopped, true);
 }
 
+Status NativeProcessNetBSD::StopProcess(lldb::pid_t pid) {
+#ifdef PT_STOP
+  return PtraceWrapper(PT_STOP, pid);
+#else
+  Log *log = GetLog(POSIXLog::Ptrace);
+  Status error;
+  int ret;
+
+  errno = 0;
+  ret = kill(pid, SIGSTOP);
+
+  if (ret == -1)
+error.SetErrorToErrno();
+
+  LLDB_LOG(log, "kill({0}, SIGSTOP)", pid);
+
+  if (error.Fail())
+LLDB_LOG(log, "kill() failed: {0}", error);
+
+  return error;
+#endif
+}
+
 Status NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
   int data, int *result) {
   Log *log = GetLog(POSIXLog::Ptrace);
@@ -531,7 +554,7 @@ Status NativeProcessNetBSD::Resume(const ResumeActionList 
&resume_actions) {
   return ret;
 }
 
-Status NativeProcessNetBSD::Halt() { return PtraceWrapper(PT_STOP, GetID()); }
+Status NativeProcessNetBSD::Halt() { return StopProcess(GetID()); }
 
 Status NativeProcessNetBSD::Detach() {
   Status error;
@@ -555,9 +578,7 @@ Status NativeProcessNetBSD::Signal(int signo) {
   return error;
 }
 
-Status NativeProcessNetBSD::Interrupt() {
-  return PtraceWrapper(PT_STOP, GetID());
-}
+Status NativeProcessNetBSD::Interrupt() { return StopProcess(GetID()); }
 
 Status NativeProcessNetBSD::Kill() {
   Log *log = GetLog(POSIXLog::Process);

diff  --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h 
b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
index 86724fdd5b7e5..f3d07651384fe 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
+++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
@@ -88,6 +88,7 @@ class NativeProcessNetBSD : public NativeProcessELF {
   // Interface used by NativeRegisterContext-derived classes.
   static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
   int data = 0, int *result = nullptr);
+  static Status StopProcess(lldb::pid_t pid);
 
   llvm::Expected SaveCore(llvm::StringRef path_hint) override;
 



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


[Lldb-commits] [lldb] [lldb] Fix building on NetBSD 8.x (PR #74191)

2023-12-04 Thread Brad Smith via lldb-commits

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


[Lldb-commits] [lldb] [lld] [libc] [compiler-rt] [mlir] [libcxx] [openmp] [llvm] [clang-tools-extra] [libunwind] [flang] [clang] [libcxxabi] [C23] Implement N3018: The constexpr specifier for object d

2023-12-04 Thread Mariya Podchishchaeva via lldb-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/73099

>From 1d70b7726e7d1f11622a6d5c8246b0737e024c8d Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Tue, 19 Sep 2023 08:37:18 -0700
Subject: [PATCH 1/7] [C23] Implement N3018: The constexpr specifier for object
 definitions

The implementation mostly reuses C++ code paths where possible,
including narrowing check in order to provide diagnostic messages in
case initializer for constexpr variable is not exactly representable in
target type.

The following won't work due to lack of support for other features:
- Diagnosing of underspecified declarations involving constexpr
- Constexpr attached to compound literals

Also due to lack of support for char8_t some of examples with utf-8
strings don't work properly.
---
 clang/docs/ReleaseNotes.rst   |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  16 +
 clang/include/clang/Basic/TokenKinds.def  |   2 +-
 clang/lib/AST/Decl.cpp|  16 +-
 clang/lib/AST/ExprConstant.cpp|  17 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +
 clang/lib/Sema/SemaDecl.cpp   | 204 +++--
 clang/lib/Sema/SemaOverload.cpp   |  36 ++-
 clang/test/C/C2x/n3018.c  |  86 ++
 clang/test/Parser/c23-constexpr.c |   6 +
 clang/test/Sema/constexpr.c   | 275 ++
 clang/www/c_status.html   |   2 +-
 12 files changed, 627 insertions(+), 36 deletions(-)
 create mode 100644 clang/test/C/C2x/n3018.c
 create mode 100644 clang/test/Parser/c23-constexpr.c
 create mode 100644 clang/test/Sema/constexpr.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b65106b9106d4..cae1707f3e30f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -208,6 +208,7 @@ C23 Feature Support
 
 - Clang now supports  which defines several macros for 
performing
   checked integer arithmetic. It is also exposed in pre-C23 modes.
+- Clang now supports ``N3018 The constexpr specifier for object definitions``.
 
 - Completed the implementation of
   `N2508 `_. We
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 990692c06d7d3..11f24583dc55a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2932,6 +2932,22 @@ def warn_private_extern : Warning<
 def note_private_extern : Note<
   "use __attribute__((visibility(\"hidden\"))) attribute instead">;
 
+// C23 constexpr
+def err_c23_thread_local_constexpr : Error<
+  "thread-local storage is not allowed with constexpr">;
+def err_c23_extern_constexpr : Error<
+  "extern specifier is not allowed with constexpr">;
+def err_c23_constexpr_not_variable : Error<
+  "constexpr is only allowed in variable declarations">;
+def err_c23_constexpr_invalid_type : Error<
+  "constexpr variable cannot have type %0">;
+def err_c23_constexpr_init_not_representable : Error<
+  "constexpr initializer evaluates to %0 which is not exactly representable in 
type %1">;
+def err_c23_constexpr_init_type_mismatch : Error<
+  "constexpr initializer for type %0 is of type %1">;
+def err_c23_constexpr_pointer_not_null : Error<
+  "constexpr pointer initializer is not null">;
+
 // C++ Concepts
 def err_concept_decls_may_only_appear_in_global_namespace_scope : Error<
   "concept declarations may only appear in global or namespace scope">;
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 3ab420821d82b..e9e8f59247662 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -393,7 +393,7 @@ CXX11_KEYWORD(alignas   , KEYC23)
 CXX11_UNARY_EXPR_OR_TYPE_TRAIT(alignof, AlignOf, KEYC23)
 CXX11_KEYWORD(char16_t  , KEYNOMS18)
 CXX11_KEYWORD(char32_t  , KEYNOMS18)
-CXX11_KEYWORD(constexpr , 0)
+CXX11_KEYWORD(constexpr , KEYC23)
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , KEYC23)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index c5c2edf1bfe3a..678a366ed29ad 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2461,7 +2461,7 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // OpenCL permits const integral variables to be used in constant
   // expressions, like in C++98.
-  if (!Lang.CPlusPlus && !Lang.OpenCL)
+  if (!Lang.CPlusPlus && !Lang.OpenCL && !Lang.C23)
 return false;
 
   // Function parameters are never usable in constant expressions.
@@ -2485,12 +2485,12 @@ bool VarDecl::mightBeUsableInConstantExpressions(const 
ASTContext &C) const {
 
   // In C++, const, non-volatile var

[Lldb-commits] [lldb] [lld] [libc] [compiler-rt] [mlir] [libcxx] [openmp] [llvm] [clang-tools-extra] [libunwind] [flang] [clang] [libcxxabi] [C23] Implement N3018: The constexpr specifier for object d

2023-12-04 Thread Mariya Podchishchaeva via lldb-commits


@@ -14240,6 +14294,114 @@ StmtResult Sema::ActOnCXXForRangeIdentifier(Scope *S, 
SourceLocation IdentLoc,
   : IdentLoc);
 }
 
+static ImplicitConversionKind getConversionKind(QualType FromType,
+QualType ToType) {
+  if (ToType->isIntegerType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Integral;
+if (FromType->isIntegerType())
+  return ICK_Integral_Conversion;
+  }
+
+  if (ToType->isFloatingType()) {
+if (FromType->isComplexType())
+  return ICK_Complex_Real;
+if (FromType->isFloatingType())
+  return ICK_Floating_Conversion;
+if (FromType->isIntegerType())
+  return ICK_Floating_Integral;
+  }
+
+  return ICK_Identity;
+}
+
+static bool checkC23ConstexprInitConversion(Sema &S, const Expr *Init) {
+  assert(S.getLangOpts().C23);
+  const Expr *InitNoCast = Init->IgnoreImpCasts();
+  StandardConversionSequence SCS;
+  SCS.setAsIdentityConversion();
+  auto FromType = InitNoCast->getType();
+  auto ToType = Init->getType();
+  SCS.setToType(0, FromType);
+  SCS.setToType(1, ToType);
+  SCS.Second = getConversionKind(FromType, ToType);
+
+  APValue Value;
+  QualType PreNarrowingType;
+  // Reuse C++ narrowing check.
+  switch (SCS.getNarrowingKind(S.Context, Init, Value, PreNarrowingType,
+   /*IgnoreFloatToIntegralConversion*/ false)) {
+  // The value doesn't fit.
+  case NK_Constant_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_not_representable)
+<< Value.getAsString(S.Context, PreNarrowingType) << ToType;
+return true;
+
+  // Conversion to a narrower type.
+  case NK_Type_Narrowing:
+S.Diag(Init->getBeginLoc(), diag::err_c23_constexpr_init_type_mismatch)
+<< ToType << FromType;
+return true;
+
+  // Since we only reuse narrowing check for C23 constexpr variables here, 
we're
+  // not really interested in these cases.
+  case NK_Dependent_Narrowing:
+  case NK_Variable_Narrowing:
+  case NK_Not_Narrowing:
+return false;
+  }
+  llvm_unreachable("unhandled case in switch");
+}
+
+static bool checkC23ConstexprInitStringLiteral(const StringLiteral *SE,
+   Sema &SemaRef,
+   SourceLocation Loc) {
+  assert(SemaRef.getLangOpts().C23);
+  // String literals have the target type attached but underneath may contain
+  // values that don't really fit into the target type. Check that every
+  // character fits.
+  const ConstantArrayType *CAT =
+  SemaRef.Context.getAsConstantArrayType(SE->getType());
+  QualType CharType = CAT->getElementType();
+  uint32_t BitWidth = SemaRef.Context.getTypeSize(CharType);
+  bool isUnsigned = CharType->isUnsignedIntegerType();
+  llvm::APSInt Value(BitWidth, isUnsigned);
+  const StringRef S = SE->getBytes();
+  for (unsigned I = 0, N = SE->getLength(); I != N; ++I) {
+Value = S[I];
+if (Value != S[I]) {
+  SemaRef.Diag(Loc, diag::err_c23_constexpr_init_not_representable)
+  << S[I] << CharType;

Fznamznon wrote:

Ok, I tried to apply the idea, seems to be working and it made more examples 
from the paper work correctly. Thanks!

There is no `APValue::getExtValue`, there is either `getZExtValue` or 
`getSExtValue` I used the latter and it seems to be enough even without `sext` 
and `trunc`.

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


[Lldb-commits] [clang-tools-extra] [llvm] [lld] [libcxxabi] [flang] [clang] [lldb] [libcxx] [libc] [flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (PR #73254)

2023-12-04 Thread via lldb-commits

https://github.com/madanial0 updated 
https://github.com/llvm/llvm-project/pull/73254

>From 81d1e05dd084dd5bb88dab88d2f23008b8dc6cfb Mon Sep 17 00:00:00 2001
From: Mark Danial 
Date: Tue, 21 Nov 2023 12:18:40 -0500
Subject: [PATCH 1/2] Pass the correct path to getIntriniscDir and
 getOpenMPHeadersDir

---
 .../include/flang/Frontend/CompilerInvocation.h  |  6 ++
 flang/lib/Frontend/CompilerInvocation.cpp| 16 ++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/flang/include/flang/Frontend/CompilerInvocation.h 
b/flang/include/flang/Frontend/CompilerInvocation.h
index 229aa75748f72..b345806586e04 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -101,6 +101,8 @@ class CompilerInvocation : public CompilerInvocationBase {
 
   bool warnAsErr = false;
 
+  const char *argv0;
+
   /// This flag controls the unparsing and is used to decide whether to print
   /// out the semantically analyzed version of an object or expression or the
   /// plain version that does not include any information from semantic
@@ -190,6 +192,8 @@ class CompilerInvocation : public CompilerInvocationBase {
 return enableConformanceChecks;
   }
 
+  const char *getArgv0() { return argv0; }
+
   bool &getEnableUsageChecks() { return enableUsageChecks; }
   const bool &getEnableUsageChecks() const { return enableUsageChecks; }
 
@@ -223,6 +227,8 @@ class CompilerInvocation : public CompilerInvocationBase {
   void setEnableUsageChecks() { enableUsageChecks = true; }
 
   /// Useful setters
+  void setArgv0(const char *dir) { argv0 = dir; }
+
   void setModuleDir(std::string &dir) { moduleDir = dir; }
 
   void setModuleFileSuffix(const char *suffix) {
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index cb4f2d6a62252..2afea5ad6b9d9 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -687,19 +687,19 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
 }
 
 // Generate the path to look for intrinsic modules
-static std::string getIntrinsicDir() {
+static std::string getIntrinsicDir(const char *argv) {
   // TODO: Find a system independent API
   llvm::SmallString<128> driverPath;
-  driverPath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+  driverPath.assign(llvm::sys::fs::getMainExecutable(argv, nullptr));
   llvm::sys::path::remove_filename(driverPath);
   driverPath.append("/../include/flang/");
   return std::string(driverPath);
 }
 
 // Generate the path to look for OpenMP headers
-static std::string getOpenMPHeadersDir() {
+static std::string getOpenMPHeadersDir(const char *argv) {
   llvm::SmallString<128> includePath;
-  includePath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+  includePath.assign(llvm::sys::fs::getMainExecutable(argv, nullptr));
   llvm::sys::path::remove_filename(includePath);
   includePath.append("/../include/flang/OpenMP/");
   return std::string(includePath);
@@ -1203,6 +1203,8 @@ bool CompilerInvocation::createFromArgs(
 }
   }
 
+  res.setArgv0(argv0);
+
   return success;
 }
 
@@ -1245,7 +1247,8 @@ void CompilerInvocation::setDefaultFortranOpts() {
 
   // Add the location of omp_lib.h to the search directories. Currently this is
   // identical to the modules' directory.
-  fortranOptions.searchDirectories.emplace_back(getOpenMPHeadersDir());
+  fortranOptions.searchDirectories.emplace_back(
+  getOpenMPHeadersDir(getArgv0()));
 
   fortranOptions.isFixedForm = false;
 }
@@ -1310,7 +1313,8 @@ void CompilerInvocation::setFortranOpts() {
   preprocessorOptions.searchDirectoriesFromIntrModPath.end());
 
   //  Add the default intrinsic module directory
-  fortranOptions.intrinsicModuleDirectories.emplace_back(getIntrinsicDir());
+  fortranOptions.intrinsicModuleDirectories.emplace_back(
+  getIntrinsicDir(getArgv0()));
 
   // Add the directory supplied through -J/-module-dir to the list of search
   // directories

>From f7d6a719feea3e0f53db7163869747dda386b683 Mon Sep 17 00:00:00 2001
From: Mark Danial 
Date: Mon, 4 Dec 2023 12:54:00 -0500
Subject: [PATCH 2/2] Adding executable name as a comment

---
 flang/include/flang/Frontend/CompilerInvocation.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/flang/include/flang/Frontend/CompilerInvocation.h 
b/flang/include/flang/Frontend/CompilerInvocation.h
index b345806586e04..3fdc1ff435523 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -101,6 +101,7 @@ class CompilerInvocation : public CompilerInvocationBase {
 
   bool warnAsErr = false;
 
+  // Executable name
   const char *argv0;
 
   /// This flag controls the unparsing and is used to decide whether to print

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/c

[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread Jonas Devlieghere via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 



@@ -1593,6 +1595,7 @@ static uint32_t LookupSymbolInModule(CommandInterpreter 
&interpreter,
 return 0;
 
   SymbolContext sc;
+  bool use_color = interpreter.GetDebugger().GetUseColor();

JDevlieghere wrote:

Unlike in llvm we do `const` variables (and there's examples of that in the 
surrounding code) so let's make this `const bool use_color`. 

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread Jonas Devlieghere via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 


https://github.com/JDevlieghere commented:

This is an awesome feature, thank you for working on this! I left a few 
comments but overall this PR is in pretty good shape.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread Jonas Devlieghere via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 



@@ -70,6 +72,31 @@ size_t Stream::PutCString(llvm::StringRef str) {
   return bytes_written;
 }
 
+void Stream::PutCStringColorHighlighted(llvm::StringRef text,
+const char *pattern) {
+  if (!pattern) {
+PutCString(text);
+return;
+  }
+
+  // If pattern is not nullptr, we should use color

JDevlieghere wrote:

Nit: seems more informative to have the inverse of this comment at the start of 
the function where we have an early return for the trivial case of not having a 
patter to highlight. 

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread Jonas Devlieghere via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread Jonas Devlieghere via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 



@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;

JDevlieghere wrote:

Why is `pattern` a `const char*` and not a StringRef with an empty string as 
the default argument? Or potentially even better an 
`std::optional`?

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread Jonas Devlieghere via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>
Message-ID:
In-Reply-To: 



@@ -70,6 +72,31 @@ size_t Stream::PutCString(llvm::StringRef str) {
   return bytes_written;
 }
 
+void Stream::PutCStringColorHighlighted(llvm::StringRef text,
+const char *pattern) {
+  if (!pattern) {
+PutCString(text);
+return;
+  }
+
+  // If pattern is not nullptr, we should use color
+  llvm::Regex reg_pattern(pattern);
+  llvm::SmallVector matches;
+  llvm::StringRef remaining = text;
+  std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes(
+  "${ansi.fg.red}%.*s${ansi.normal}");

JDevlieghere wrote:

Most (all?) other colors are configurable. I think this one should be too. Some 
examples of this are the `show-autosuggestion-ansi-prefix` and 
`show-progress-ansi-prefix`. This pattern should work here as well. 

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


[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)

2023-12-04 Thread Michael Christensen via lldb-commits


@@ -1296,10 +1296,11 @@ enum CompletionType {
   eRemoteDiskFileCompletion = (1u << 22),
   eRemoteDiskDirectoryCompletion = (1u << 23),
   eTypeCategoryNameCompletion = (1u << 24),
+  eThreadIDCompletion = (1u << 25),

mdko wrote:

@jimingham What are your thoughts on putting eThreadIDCompletion before 
eCustomCompletion? (See @clayborg 's comments above)

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


[Lldb-commits] [lldb] 7a86cc6 - [lldb][NFC] Remove unnecessary std::string temporaries

2023-12-04 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-12-04T10:23:04-08:00
New Revision: 7a86cc6c4ca11e37d5985d4fc902658ab6ad0e22

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

LOG: [lldb][NFC] Remove unnecessary std::string temporaries

The existing code was taking three substrings from a regex match and converting
to std::strings prior to using them. This may have been done to address
null-termination concerns, but this is not the case:

1. `name` was being used to call `c_str()` and then implicitly converted back to
a `StringRef` on the call to `ToAddress`. While the path `const char *` ->
`StringRef` requires null-termination, we can simply use the original StringRef.
2. `str_offset` was being converted back to a StringRef in order to call a
member method. Member methods can't handle non-null termination.
3. `sign` simply had it's 0-th element accessed.

Added: 


Modified: 
lldb/source/Interpreter/OptionArgParser.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/OptionArgParser.cpp 
b/lldb/source/Interpreter/OptionArgParser.cpp
index ba2d3416e1838..933bc6514ca24 100644
--- a/lldb/source/Interpreter/OptionArgParser.cpp
+++ b/lldb/source/Interpreter/OptionArgParser.cpp
@@ -243,12 +243,12 @@ OptionArgParser::DoToAddress(const ExecutionContext 
*exe_ctx, llvm::StringRef s,
 llvm::SmallVector matches;
 if (g_symbol_plus_offset_regex.Execute(sref, &matches)) {
   uint64_t offset = 0;
-  std::string name = matches[1].str();
-  std::string sign = matches[2].str();
-  std::string str_offset = matches[3].str();
-  if (!llvm::StringRef(str_offset).getAsInteger(0, offset)) {
+  llvm::StringRef name = matches[1];
+  llvm::StringRef sign = matches[2];
+  llvm::StringRef str_offset = matches[3];
+  if (!str_offset.getAsInteger(0, offset)) {
 Status error;
-addr = ToAddress(exe_ctx, name.c_str(), LLDB_INVALID_ADDRESS, &error);
+addr = ToAddress(exe_ctx, name, LLDB_INVALID_ADDRESS, &error);
 if (addr != LLDB_INVALID_ADDRESS) {
   if (sign[0] == '+')
 return addr + offset;



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


[Lldb-commits] [lldb] 3e98a28 - [lldb][NFC] Remove else after return in OptionArgParse

2023-12-04 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-12-04T10:23:05-08:00
New Revision: 3e98a285138a517fd918ec0ac8397dc56330d8e7

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

LOG: [lldb][NFC] Remove else after return in OptionArgParse

This will enable us to prove that there is unreachable code in this function in
a subsequent commit.

Added: 


Modified: 
lldb/source/Interpreter/OptionArgParser.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/OptionArgParser.cpp 
b/lldb/source/Interpreter/OptionArgParser.cpp
index 933bc6514ca24..c61072dfafc19 100644
--- a/lldb/source/Interpreter/OptionArgParser.cpp
+++ b/lldb/source/Interpreter/OptionArgParser.cpp
@@ -168,7 +168,6 @@ lldb::addr_t OptionArgParser::ToAddress(const 
ExecutionContext *exe_ctx,
 std::optional
 OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef 
s,
  Status *error_ptr) {
-  bool error_set = false;
   if (s.empty()) {
 if (error_ptr)
   error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"",
@@ -212,6 +211,7 @@ OptionArgParser::DoToAddress(const ExecutionContext 
*exe_ctx, llvm::StringRef s,
   target->EvaluateExpression(s, exe_ctx->GetFramePtr(), valobj_sp, 
options);
 
   bool success = false;
+  bool error_set = false;
   if (expr_result == eExpressionCompleted) {
 if (valobj_sp)
   valobj_sp = valobj_sp->GetQualifiedRepresentationIfAvailable(
@@ -223,16 +223,14 @@ OptionArgParser::DoToAddress(const ExecutionContext 
*exe_ctx, llvm::StringRef s,
   if (error_ptr)
 error_ptr->Clear();
   return addr;
-} else {
-  if (error_ptr) {
-error_set = true;
-error_ptr->SetErrorStringWithFormat(
-"address expression \"%s\" resulted in a value whose type "
-"can't be converted to an address: %s",
-s.str().c_str(), valobj_sp->GetTypeName().GetCString());
-  }
 }
-
+if (error_ptr) {
+  error_set = true;
+  error_ptr->SetErrorStringWithFormat(
+  "address expression \"%s\" resulted in a value whose type "
+  "can't be converted to an address: %s",
+  s.str().c_str(), valobj_sp->GetTypeName().GetCString());
+}
   } else {
 // Since the compiler can't handle things like "main + 12" we should try to
 // do this for now. The compiler doesn't like adding offsets to function
@@ -252,8 +250,7 @@ OptionArgParser::DoToAddress(const ExecutionContext 
*exe_ctx, llvm::StringRef s,
 if (addr != LLDB_INVALID_ADDRESS) {
   if (sign[0] == '+')
 return addr + offset;
-  else
-return addr - offset;
+  return addr - offset;
 }
   }
 }



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


[Lldb-commits] [lldb] d24d7ed - [lldb][NFC] Delete unreachable code and dead variable in OptionArgParser

2023-12-04 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-12-04T10:23:05-08:00
New Revision: d24d7edaef9517edd9eb2ab26b02969e201bbcad

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

LOG: [lldb][NFC] Delete unreachable code and dead variable in OptionArgParser

With the combination of an early return and removing an else-after-return, it
becomes evident that there is unreachable code in the function being changed.

Added: 


Modified: 
lldb/source/Interpreter/OptionArgParser.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/OptionArgParser.cpp 
b/lldb/source/Interpreter/OptionArgParser.cpp
index c61072dfafc19..8a92c7d08c476 100644
--- a/lldb/source/Interpreter/OptionArgParser.cpp
+++ b/lldb/source/Interpreter/OptionArgParser.cpp
@@ -211,7 +211,6 @@ OptionArgParser::DoToAddress(const ExecutionContext 
*exe_ctx, llvm::StringRef s,
   target->EvaluateExpression(s, exe_ctx->GetFramePtr(), valobj_sp, 
options);
 
   bool success = false;
-  bool error_set = false;
   if (expr_result == eExpressionCompleted) {
 if (valobj_sp)
   valobj_sp = valobj_sp->GetQualifiedRepresentationIfAvailable(
@@ -224,48 +223,39 @@ OptionArgParser::DoToAddress(const ExecutionContext 
*exe_ctx, llvm::StringRef s,
 error_ptr->Clear();
   return addr;
 }
-if (error_ptr) {
-  error_set = true;
+if (error_ptr)
   error_ptr->SetErrorStringWithFormat(
   "address expression \"%s\" resulted in a value whose type "
   "can't be converted to an address: %s",
   s.str().c_str(), valobj_sp->GetTypeName().GetCString());
-}
-  } else {
-// Since the compiler can't handle things like "main + 12" we should try to
-// do this for now. The compiler doesn't like adding offsets to function
-// pointer types.
-static RegularExpression g_symbol_plus_offset_regex(
-"^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$");
-
-llvm::SmallVector matches;
-if (g_symbol_plus_offset_regex.Execute(sref, &matches)) {
-  uint64_t offset = 0;
-  llvm::StringRef name = matches[1];
-  llvm::StringRef sign = matches[2];
-  llvm::StringRef str_offset = matches[3];
-  if (!str_offset.getAsInteger(0, offset)) {
-Status error;
-addr = ToAddress(exe_ctx, name, LLDB_INVALID_ADDRESS, &error);
-if (addr != LLDB_INVALID_ADDRESS) {
-  if (sign[0] == '+')
-return addr + offset;
-  return addr - offset;
-}
-  }
-}
+return {};
+  }
 
-if (error_ptr) {
-  error_set = true;
-  error_ptr->SetErrorStringWithFormat(
-  "address expression \"%s\" evaluation failed", s.str().c_str());
+  // Since the compiler can't handle things like "main + 12" we should try to
+  // do this for now. The compiler doesn't like adding offsets to function
+  // pointer types.
+  static RegularExpression g_symbol_plus_offset_regex(
+  "^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$");
+
+  llvm::SmallVector matches;
+  if (g_symbol_plus_offset_regex.Execute(sref, &matches)) {
+uint64_t offset = 0;
+llvm::StringRef name = matches[1];
+llvm::StringRef sign = matches[2];
+llvm::StringRef str_offset = matches[3];
+if (!str_offset.getAsInteger(0, offset)) {
+  Status error;
+  addr = ToAddress(exe_ctx, name, LLDB_INVALID_ADDRESS, &error);
+  if (addr != LLDB_INVALID_ADDRESS) {
+if (sign[0] == '+')
+  return addr + offset;
+return addr - offset;
+  }
 }
   }
 
-  if (error_ptr) {
-if (!error_set)
-  error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"",
-  s.str().c_str());
-  }
+  if (error_ptr)
+error_ptr->SetErrorStringWithFormat(
+"address expression \"%s\" evaluation failed", s.str().c_str());
   return {};
 }



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


[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)

2023-12-04 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Delete unreachable code and unnecessary string conversions (PR #74119)

2023-12-04 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

Pushed as
```
* d24d7edaef95 (2 minu..) fpiove.. [lldb][NFC] Delete unreachable code and dead 
│
variable in OptionArgParser 
│
* 3e98a285138a (2 minu..) fpiove.. [lldb][NFC] Remove else after return in 
OptionArgParse   │
* 7a86cc6c4ca1 (2 minu..) fpiove.. [lldb][NFC] Remove unnecessary std::string 
temporaries
```

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


[Lldb-commits] [libc] [compiler-rt] [clang-tools-extra] [clang] [libunwind] [mlir] [lld] [flang] [libcxx] [llvm] [lldb] Fix clang to recognize new C23 modifiers %w and %wf when printing and scanning (

2023-12-04 Thread via lldb-commits

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

>From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 9 Nov 2023 02:21:46 +
Subject: [PATCH 1/4] Fix clang to recognize new C23 modifiers %w and %wf when
 printing

---
 clang/include/clang/AST/FormatString.h | 16 +++-
 clang/lib/AST/FormatString.cpp | 52 +-
 clang/lib/AST/PrintfFormatString.cpp   | 19 ++
 clang/test/Sema/format-strings-ms.c| 28 ++
 4 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/FormatString.h 
b/clang/include/clang/AST/FormatString.h
index 5c4ad9baaef60..6a886854650f1 100644
--- a/clang/include/clang/AST/FormatString.h
+++ b/clang/include/clang/AST/FormatString.h
@@ -81,8 +81,10 @@ class LengthModifier {
 AsLongDouble, // 'L'
 AsAllocate,   // for '%as', GNU extension to C90 scanf
 AsMAllocate,  // for '%ms', GNU extension to scanf
-AsWide,   // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
-AsWideChar = AsLong // for '%ls', only makes sense for printf
+AsWide,   // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on 
windows
+  // 2. for b, d, i, o, u, x, or X when a size followed(like 
8, 16, 32 or 64)
+AsWideFast,   // 'wf' (for b, d, i, o, u, x, or X)
+AsWideChar = AsLong, // for '%ls', only makes sense for printf
   };
 
   LengthModifier()
@@ -417,6 +419,7 @@ class FormatSpecifier {
   ///  http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
   bool UsesPositionalArg;
   unsigned argIndex;
+  unsigned size;
 public:
   FormatSpecifier(bool isPrintf)
 : CS(isPrintf), VectorNumElts(false),
@@ -460,6 +463,15 @@ class FormatSpecifier {
 FieldWidth = Amt;
   }
 
+  void setSize(unsigned s) {
+size = s;
+  }
+
+  unsigned getSize() const {
+return size;
+  }
+
+
   bool usesPositionalArg() const { return UsesPositionalArg; }
 
   bool hasValidLengthModifier(const TargetInfo &Target,
diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index e0c9e18cfe3a2..ebc136e780717 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};
+if (supported_list.count(s) == 0) {
+  return false;
+}
+FS.setSize(s);
+  }
+
+  break;
   }
   LengthModifier lm(lmPosition, lmKind);
   FS.setLengthModifier(lm);
@@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const {
 return "m";
   case AsWide:
 return "w";
+  case AsWideFast:
+return "wf";
   case None:
 return "";
   }
@@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const 
TargetInfo &Target,
 case ConversionSpecifier::SArg:
 case ConversionSpecifier::ZArg:
   return Target.getTriple().isOSMSVCRT();
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
+default:
+  return false;
+  }
+case LengthModifier::AsWideFast:
+  switch (CS.getKind()) {
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
 default:
   return false;
   }
@@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const {
 case LengthModifier::AsInt3264:
 case LengthModifier::AsInt64:
 case LengthModifier::AsWide:
+case LengthModifier::AsWideFast:
 case LengthModifier::AsShortLong: // ???
   return false;
   }
diff --git a/clang/lib/AST/PrintfFormatString.cpp 
b/clang/lib/AST/PrintfFormatString.cpp
index f0b9d0ecaf234..4b9111e8bcf50 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/Print

[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

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

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

We need to respect the setting `symbols.enable-external-lookup` and not do 
anything with debuginfod if this is set to false.

You can get this value by calling:
```
ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()
```
Otherwise I fear that the linux buildbots will start failing if we get extra 
system library symbols if debuginfod is enabled via the environment variable.

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


[Lldb-commits] [lldb] [lldb] Additional pieces towards OpenBSD support (PR #74198)

2023-12-04 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Additional pieces towards OpenBSD support (PR #74198)

2023-12-04 Thread Alex Langford via lldb-commits

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

LGTM overall, small nit

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


[Lldb-commits] [lldb] [lldb] Additional pieces towards OpenBSD support (PR #74198)

2023-12-04 Thread Alex Langford via lldb-commits


@@ -1,4 +1,7 @@
 #include 
+#ifdef __OpenBSD__

bulbazord wrote:

For consistency, can you change this to `if defined(__OpenBSD__)`? Not a big 
deal though

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-04 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/70996

>From 190fb1529bfe0ecdb5e5a30d335ccdca45463c32 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Wed, 18 Oct 2023 14:37:34 -0700
Subject: [PATCH 01/10] DEBUGINFOD based DWP acquisition for LLDB

Summary:
I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic 
downloading of
DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set 
to a
space delimited set of web servers, LLDB will try to use them as a last resort 
when
searching for DWP files. If you do *not* have that environment variable set, 
nothing
should be changed. There's also a setting, per Greg Clayton's request, that will
override the env variable, or can be used instead of the env var. This setting 
is the
reason for the additional API added to the llvm's Debuginfod library.

Test Plan:
Suggestions are welcome here. I should probably have some positive and negative 
tests,
but I wanted to get the diff up for people who have a clue what they're doing 
to rip it
to pieces before spending too much time validating my implementation.
---
 lldb/include/lldb/Target/Target.h |  3 +++
 lldb/source/Core/CoreProperties.td|  2 +-
 lldb/source/Core/Debugger.cpp |  5 
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  1 +
 lldb/source/Symbol/CMakeLists.txt |  1 +
 lldb/source/Target/Target.cpp | 19 +-
 lldb/source/Target/TargetProperties.td|  4 +++
 llvm/include/llvm/Debuginfod/Debuginfod.h |  4 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++-
 9 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a0385..7f10f0409fb13 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -258,6 +258,8 @@ class TargetProperties : public Properties {
 
   bool GetDebugUtilityExpression() const;
 
+  Args GetDebugInfoDURLs() const;
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();
@@ -270,6 +272,7 @@ class TargetProperties : public Properties {
   void DisableASLRValueChangedCallback();
   void InheritTCCValueChangedCallback();
   void DisableSTDIOValueChangedCallback();
+  void DebugInfoDURLsChangedCallback();
 
   // Settings checker for target.jit-save-objects-dir:
   void CheckJITObjectsDir();
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 92884258347e9..865030b0133bb 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -4,7 +4,7 @@ let Definition = "modulelist" in {
   def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">,
 Global,
 DefaultTrue,
-Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched.">;
+Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched. If all other methods fail, and 
the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol 
is used to acquire symbols from a compatible Debuginfod service.">;
   def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">,
 Global,
 DefaultFalse,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 21f71e449ca5e..9a3e82f3e6a2a 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -61,6 +61,8 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
+#include "llvm/Debuginfod/Debuginfod.h"
+#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Process.h"
@@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() 
const {
 void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) {
   assert(g_debugger_list_ptr == nullptr &&
  "Debugger::Initialize called more than once!");
+  // We might be using the Debuginfod service, so we have 

[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-04 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

> We need to respect the setting `symbols.enable-external-lookup` and not do 
> anything with debuginfod if this is set to false.
> 
> You can get this value by calling:
> 
> ```
> ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()
> ```
> 
> Otherwise I fear that the linux buildbots will start failing if we get extra 
> system library symbols if debuginfod is enabled via the environment variable.

Fixed that up, rebased and push -f 'ed

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


[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)

2023-12-04 Thread Alex Langford via lldb-commits


@@ -1296,10 +1296,11 @@ enum CompletionType {
   eRemoteDiskFileCompletion = (1u << 22),
   eRemoteDiskDirectoryCompletion = (1u << 23),
   eTypeCategoryNameCompletion = (1u << 24),
+  eThreadIDCompletion = (1u << 25),

bulbazord wrote:

Independent of the API standpoint, Greg is right. This is ABI-breaking, 
something we try hard to avoid in LLDB. Even though programs linked against 
older versions of LLDB will still be able to run against newer versions of 
LLDB, the semantics of these values have changed and the program may do the 
wrong thing. Even though I don't think it's likely that this will affect many 
folks, you can never be too sure.

https://lldb.llvm.org/resources/sbapi.html

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


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

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

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


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


[Lldb-commits] [lldb] c43c86c - DEBUGINFOD based DWP acquisition for LLDB (#70996)

2023-12-04 Thread via lldb-commits

Author: Kevin Frei
Date: 2023-12-04T11:45:40-08:00
New Revision: c43c86c285a39dcc6ec4a15b8f155152031b3997

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

LOG: DEBUGINFOD based DWP acquisition for LLDB (#70996)

I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic
downloading of DWP files to the SymbolFileDWARF.cpp plugin. If you have
DEBUGINFOD_URLS set to a space delimited set of web servers, LLDB will
try to use them as a last resort when searching for DWP files. If you do
*not* have that environment variable set, nothing should be changed.
There's also a setting, per @clayborg 's suggestion, that will override
the environment variable, or can be used instead of the environment
variable. The setting is why I also needed to add an API to the
llvm-debuginfod library

### Test Plan:

Suggestions are welcome here. I should probably have some positive and
negative tests, but I wanted to get the diff up for people who have a
clue what they're doing to rip it to pieces before spending too much
time validating the initial implementation.

-

Co-authored-by: Kevin Frei 
Co-authored-by: Alex Langford 

Added: 
lldb/source/Plugins/SymbolLocator/Debuginfod/CMakeLists.txt
lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.h

lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfodProperties.td

Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/Core/CoreProperties.td
lldb/source/Core/PluginManager.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/Debuginfod/Debuginfod.h
llvm/lib/Debuginfod/Debuginfod.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 318f8b63c251a..f2296e2920238 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -355,7 +355,8 @@ class PluginManager {
   nullptr,
   SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file =
   nullptr,
-  SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle = 
nullptr);
+  SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle = nullptr,
+  DebuggerInitializeCallback debugger_init_callback = nullptr);
 
   static bool UnregisterPlugin(SymbolLocatorCreateInstance create_callback);
 
@@ -528,6 +529,14 @@ class PluginManager {
   Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
   llvm::StringRef description, bool is_global_property);
 
+  static lldb::OptionValuePropertiesSP
+  GetSettingForSymbolLocatorPlugin(Debugger &debugger,
+   llvm::StringRef setting_name);
+
+  static bool CreateSettingForSymbolLocatorPlugin(
+  Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+  llvm::StringRef description, bool is_global_property);
+
   static bool CreateSettingForTracePlugin(
   Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
   llvm::StringRef description, bool is_global_property);

diff  --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 92884258347e9..0e0f468d3ecd7 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -4,7 +4,7 @@ let Definition = "modulelist" in {
   def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">,
 Global,
 DefaultTrue,
-Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched.">;
+Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched. If all other methods fail 
there may be symbol-locator plugins that, if configured properly, will als

[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

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

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


[Lldb-commits] [lldb] [lldb] Additional pieces towards OpenBSD support (PR #74198)

2023-12-04 Thread Brad Smith via lldb-commits


@@ -1,4 +1,7 @@
 #include 
+#ifdef __OpenBSD__

brad0 wrote:

Sure.

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


[Lldb-commits] [lldb] [lldb] Additional pieces towards OpenBSD support (PR #74198)

2023-12-04 Thread Brad Smith via lldb-commits

https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/74198

>From 312bd79cfbe847a7553534714649ff2a4b7979b5 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Sat, 2 Dec 2023 10:20:48 -0500
Subject: [PATCH] [lldb] Additional pieces towards OpenBSD support

---
 lldb/source/Core/FormatEntity.cpp  | 7 ---
 lldb/source/Host/common/SocketAddress.cpp  | 6 --
 lldb/source/Host/posix/DomainSocket.cpp| 3 ++-
 lldb/source/Initialization/SystemInitializerCommon.cpp | 6 --
 .../Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp| 1 +
 .../DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp| 3 ++-
 lldb/test/API/api/multithreaded/common.h   | 3 ++-
 lldb/test/API/tools/lldb-server/thread-name/main.cpp   | 5 +
 8 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index d8047b4242065..94986457552d9 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1245,9 +1245,10 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 llvm::Triple::OSType ostype = arch.IsValid()
   ? arch.GetTriple().getOS()
   : llvm::Triple::UnknownOS;
-if ((ostype == llvm::Triple::FreeBSD) ||
-(ostype == llvm::Triple::Linux) ||
-(ostype == llvm::Triple::NetBSD)) {
+if (ostype == llvm::Triple::FreeBSD ||
+ostype == llvm::Triple::Linux ||
+ostype == llvm::Triple::NetBSD ||
+ostype == llvm::Triple::OpenBSD) {
   format = "%" PRIu64;
 }
   } else {
diff --git a/lldb/source/Host/common/SocketAddress.cpp 
b/lldb/source/Host/common/SocketAddress.cpp
index 3f47d32d4652d..6a23c633e54bf 100644
--- a/lldb/source/Host/common/SocketAddress.cpp
+++ b/lldb/source/Host/common/SocketAddress.cpp
@@ -113,7 +113,8 @@ static socklen_t GetFamilyLength(sa_family_t family) {
 }
 
 socklen_t SocketAddress::GetLength() const {
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
   return m_socket_addr.sa.sa_len;
 #else
   return GetFamilyLength(GetFamily());
@@ -128,7 +129,8 @@ sa_family_t SocketAddress::GetFamily() const {
 
 void SocketAddress::SetFamily(sa_family_t family) {
   m_socket_addr.sa.sa_family = family;
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
   m_socket_addr.sa.sa_len = GetFamilyLength(family);
 #endif
 }
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index ddbd983abb81d..9b44c2a8368ed 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -48,7 +48,8 @@ static bool SetSockAddr(llvm::StringRef name, const size_t 
name_offset,
 saddr_un_len =
 offsetof(struct sockaddr_un, sun_path) + name_offset + name.size();
 
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
   saddr_un->sun_len = saddr_un_len;
 #endif
 
diff --git a/lldb/source/Initialization/SystemInitializerCommon.cpp 
b/lldb/source/Initialization/SystemInitializerCommon.cpp
index 40e54cd7f0e09..1a172a95aa147 100644
--- a/lldb/source/Initialization/SystemInitializerCommon.cpp
+++ b/lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -18,7 +18,8 @@
 #include "lldb/Utility/Timer.h"
 #include "lldb/Version/Version.h"
 
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
 #endif
 
@@ -77,7 +78,8 @@ llvm::Error SystemInitializerCommon::Initialize() {
 
   process_gdb_remote::ProcessGDBRemoteLog::Initialize();
 
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
   ProcessPOSIXLog::Initialize();
 #endif
 #if defined(_WIN32)
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index a0b6f44bed0e7..1a9c4593b1b4f 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -549,6 +549,7 @@ bool DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry 
&entry) {
   switch (triple.getOS()) {
   case llvm::Triple::FreeBSD:
   case llvm::Triple::NetBSD:
+  

[Lldb-commits] [lldb] [lldb] Additional pieces towards OpenBSD support (PR #74198)

2023-12-04 Thread Brad Smith via lldb-commits


@@ -1,4 +1,7 @@
 #include 
+#ifdef __OpenBSD__

brad0 wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Additional pieces towards OpenBSD support (PR #74198)

2023-12-04 Thread Ed Maste via lldb-commits

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


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


[Lldb-commits] [lldb] a2e61bc - [lldb] Additional pieces towards OpenBSD support (#74198)

2023-12-04 Thread via lldb-commits

Author: Brad Smith
Date: 2023-12-04T15:14:49-05:00
New Revision: a2e61bc2f3bc66124575c0abf9b8421073470202

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

LOG: [lldb] Additional pieces towards OpenBSD support (#74198)

Added: 


Modified: 
lldb/source/Core/FormatEntity.cpp
lldb/source/Host/common/SocketAddress.cpp
lldb/source/Host/posix/DomainSocket.cpp
lldb/source/Initialization/SystemInitializerCommon.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/test/API/api/multithreaded/common.h
lldb/test/API/tools/lldb-server/thread-name/main.cpp

Removed: 




diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index d8047b4242065..94986457552d9 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1245,9 +1245,10 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 llvm::Triple::OSType ostype = arch.IsValid()
   ? arch.GetTriple().getOS()
   : llvm::Triple::UnknownOS;
-if ((ostype == llvm::Triple::FreeBSD) ||
-(ostype == llvm::Triple::Linux) ||
-(ostype == llvm::Triple::NetBSD)) {
+if (ostype == llvm::Triple::FreeBSD ||
+ostype == llvm::Triple::Linux ||
+ostype == llvm::Triple::NetBSD ||
+ostype == llvm::Triple::OpenBSD) {
   format = "%" PRIu64;
 }
   } else {

diff  --git a/lldb/source/Host/common/SocketAddress.cpp 
b/lldb/source/Host/common/SocketAddress.cpp
index 3f47d32d4652d..6a23c633e54bf 100644
--- a/lldb/source/Host/common/SocketAddress.cpp
+++ b/lldb/source/Host/common/SocketAddress.cpp
@@ -113,7 +113,8 @@ static socklen_t GetFamilyLength(sa_family_t family) {
 }
 
 socklen_t SocketAddress::GetLength() const {
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
   return m_socket_addr.sa.sa_len;
 #else
   return GetFamilyLength(GetFamily());
@@ -128,7 +129,8 @@ sa_family_t SocketAddress::GetFamily() const {
 
 void SocketAddress::SetFamily(sa_family_t family) {
   m_socket_addr.sa.sa_family = family;
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
   m_socket_addr.sa.sa_len = GetFamilyLength(family);
 #endif
 }

diff  --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index ddbd983abb81d..9b44c2a8368ed 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -48,7 +48,8 @@ static bool SetSockAddr(llvm::StringRef name, const size_t 
name_offset,
 saddr_un_len =
 offsetof(struct sockaddr_un, sun_path) + name_offset + name.size();
 
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
   saddr_un->sun_len = saddr_un_len;
 #endif
 

diff  --git a/lldb/source/Initialization/SystemInitializerCommon.cpp 
b/lldb/source/Initialization/SystemInitializerCommon.cpp
index 40e54cd7f0e09..1a172a95aa147 100644
--- a/lldb/source/Initialization/SystemInitializerCommon.cpp
+++ b/lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -18,7 +18,8 @@
 #include "lldb/Utility/Timer.h"
 #include "lldb/Version/Version.h"
 
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
 #endif
 
@@ -77,7 +78,8 @@ llvm::Error SystemInitializerCommon::Initialize() {
 
   process_gdb_remote::ProcessGDBRemoteLog::Initialize();
 
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) ||   
\
+defined(__OpenBSD__)
   ProcessPOSIXLog::Initialize();
 #endif
 #if defined(_WIN32)

diff  --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index a0b6f44bed0e7..1a9c4593b1b4f 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -549,6 +549,7 @@ bool DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry 
&entry) {
   switch (triple.getOS()) {
   case llvm::Triple::Fre

[Lldb-commits] [lldb] [lldb] Additional pieces towards OpenBSD support (PR #74198)

2023-12-04 Thread Brad Smith via lldb-commits

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-04 Thread Nico Weber via lldb-commits

nico wrote:

This breaks targeting macOS versions older than 10.12 for unnecessary reason:

```
../../llvm/lib/Debuginfod/Debuginfod.cpp:54:6: error: 'shared_mutex' is 
unavailable: introduced in macOS 10.12
std::shared_mutex UrlsMutex;
 ^
```

You should be able to use llvm::sys::RWMutex so please switch to that. See 
https://reviews.llvm.org/D138423 for an example.

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


[Lldb-commits] [clang-tools-extra] [lldb] [libc] [mlir] [clang] [libcxx] [polly] [compiler-rt] [lld] [llvm] [flang] [NFC][asan] Inline ENSURE_ASAN_INITED macro (PR #74174)

2023-12-04 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/74174

>From 71e54faa238765cb9df656a3f6e347a2d04f989a Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Fri, 1 Dec 2023 19:20:37 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?=
 =?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/lib/asan/asan_interceptors.cpp | 54 ++
 compiler-rt/lib/asan/asan_interceptors.h   |  9 ++--
 compiler-rt/lib/asan/asan_internal.h   |  2 +-
 compiler-rt/lib/asan/asan_malloc_linux.cpp |  5 +-
 compiler-rt/lib/asan/asan_rtl.cpp  | 14 +-
 5 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index e80f66142b7a2..1a1a26a7cd8bf 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -96,14 +96,16 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
   ASAN_WRITE_RANGE(ctx, ptr, size)
 #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
   ASAN_READ_RANGE(ctx, ptr, size)
-#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)\
-ASAN_INTERCEPTOR_ENTER(ctx, func);\
-do {  \
-  if (AsanInitIsRunning())\
-return REAL(func)(__VA_ARGS__);   \
-  if (SANITIZER_APPLE && UNLIKELY(!AsanInited())) \
-return REAL(func)(__VA_ARGS__);   \
-  ENSURE_ASAN_INITED();   \
+#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \
+ASAN_INTERCEPTOR_ENTER(ctx, func); \
+do {   \
+  if constexpr (SANITIZER_APPLE) { \
+if (UNLIKELY(!AsanInited()))   \
+  return REAL(func)(__VA_ARGS__);  \
+  } else { \
+if (!TryAsanInitFromRtl()) \
+  return REAL(func)(__VA_ARGS__);  \
+  }\
 } while (false)
 #define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
   do {\
@@ -534,16 +536,16 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, 
uptr size) {
 INTERCEPTOR(char *, strcpy, char *to, const char *from) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strcpy);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
-return REAL(strcpy)(to, from);
-#endif
-  // strcpy is called from malloc_default_purgeable_zone()
-  // in __asan::ReplaceSystemAlloc() on Mac.
-  if (AsanInitIsRunning()) {
-return REAL(strcpy)(to, from);
+  if constexpr (SANITIZER_APPLE) {
+// strcpy is called from malloc_default_purgeable_zone()
+// in __asan::ReplaceSystemAlloc() on Mac.
+if (UNLIKELY(!AsanInited()))
+  return REAL(strcpy)(to, from);
+  } else {
+if (!TryAsanInitFromRtl())
+  return REAL(strcpy)(to, from);
   }
-  ENSURE_ASAN_INITED();
+
   if (flags()->replace_str) {
 uptr from_size = internal_strlen(from) + 1;
 CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size);
@@ -556,9 +558,8 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
 INTERCEPTOR(char*, strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!TryAsanInitFromRtl()))
 return internal_strdup(s);
-  ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
   if (flags()->replace_str) {
 ASAN_READ_RANGE(ctx, s, length + 1);
@@ -575,9 +576,8 @@ INTERCEPTOR(char*, strdup, const char *s) {
 INTERCEPTOR(char*, __strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!TryAsanInitFromRtl()))
 return internal_strdup(s);
-  ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
   if (flags()->replace_str) {
 ASAN_READ_RANGE(ctx, s, length + 1);
@@ -635,10 +635,8 @@ INTERCEPTOR_STRTO_BASE(long long, __isoc23_strtoll)
 INTERCEPTOR(int, atoi, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atoi);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(atoi)(nptr);
-#  endif
   ENSURE_ASAN_INITED();
   if (!flags()->replace_str) {
 return REAL(atoi)(nptr);
@@ -657,10 +655,8 @@ INTERCEPTOR(int, atoi, const char *nptr) {
 INTERCEPTOR(long, atol, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atol);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(atol)(nptr);
-#  endif
   ENSURE_ASAN_INITED();
   if (!flags()->replace_str) {
 return REAL(atol)(nptr);
@@ -696,10 +692,8 @@ static void AtCxaAtexit(v

[Lldb-commits] [clang-tools-extra] [lldb] [libc] [mlir] [clang] [libcxx] [polly] [compiler-rt] [lld] [llvm] [flang] [NFC][asan] Inline ENSURE_ASAN_INITED macro (PR #74174)

2023-12-04 Thread Vitaly Buka via lldb-commits

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


[Lldb-commits] [llvm] [compiler-rt] [flang] [clang] [libcxx] [lldb] [libc] [lld] [hwasan] Use ErrorAction::Recover in interceptors (PR #74000)

2023-12-04 Thread Vitaly Buka via lldb-commits

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-04 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

> This breaks targeting macOS versions older than 10.12 for unnecessary reasons:
> 
> ```
> ../../llvm/lib/Debuginfod/Debuginfod.cpp:54:6: error: 'shared_mutex' is 
> unavailable: introduced in macOS 10.12
> std::shared_mutex UrlsMutex;
>  ^
> ```
> 
> You should be able to use llvm::sys::RWMutex so please switch to that. See 
> https://reviews.llvm.org/D138423 for an example.

N!

I'll get this fixed up ASAP. Should I open an issue, or just put up a new PR? 
(Thanks for the example!)

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/69422

From c416443a93f7113a7f57d337682ec4862438522d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH 1/7] [lldb] colorize symbols in image lookup

This creates the method PutCStringColorHighlighted for Stream class,
which highlights searched symbols in red color for the image lookup command.

A new shell test was added to verify functionality. Relevant methods were
updated to accept the searched pattern/symbol as a parameter.

Co-authored-by: Talha 
---
 lldb/include/lldb/Core/Address.h  |  4 +-
 lldb/include/lldb/Symbol/Symbol.h |  4 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  8 ++--
 lldb/include/lldb/Utility/Stream.h| 16 
 lldb/source/Commands/CommandObjectTarget.cpp  | 16 +---
 lldb/source/Core/Address.cpp  | 21 ++
 lldb/source/Symbol/Symbol.cpp | 18 ++---
 lldb/source/Symbol/SymbolContext.cpp  | 16 +---
 lldb/source/Utility/Stream.cpp| 28 +
 .../Commands/command-image-lookup-color.test  | 39 +++
 10 files changed, 138 insertions(+), 32 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546..c3f2832be424e 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe..0e41cd95e0ef1 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope {
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a16..9567c3f4384c1 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -150,8 +150,8 @@ class SymbolContext {
   bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
const Address &so_addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
-   bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_arguments, bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -217,8 +217,8 @@ class SymbolContext {
   /// The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/include/lldb/Utility/Stream.h 
b/lldb/include/lldb/Utility/Stream.h
index 1a5fd343e4df0..8e3fd48dfe705 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -231,6 +231,22 @@ class Stream {
   /// The string to be output to the stream.
   size_t PutCString(llvm::StringRef cstr);
 
+  /// Output a C string to the stream with color highlighting.
+  ///
+  /// Print a C string \a text to the stream, applying red color highlighting 
to
+  /// the portions of the string that match the regex pattern \a pattern. The
+  /// pattern is matched as many times as possible throughout the string. If \a
+  /// pattern is nullptr, then no highlighting is applied.
+  ///
+  /// \param[in] text
+  /// The string to be output to the stream.
+  ///
+  /// \param[in] pattern
+  /// The regex pattern to match against the \a text string. Portions of \a
+  /// text matching this pattern will be colorized. If this parameter is
+  /// nullptr, highlighting is not performed.
+  voi

[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread José Lira Junior via lldb-commits


@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;

junior-jl wrote:

Changed to `StringRef`. I could not make it work with 
`std::optional`. Maybe I was doing something wrong.



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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread José Lira Junior via lldb-commits


@@ -1593,6 +1595,7 @@ static uint32_t LookupSymbolInModule(CommandInterpreter 
&interpreter,
 return 0;
 
   SymbolContext sc;
+  bool use_color = interpreter.GetDebugger().GetUseColor();

junior-jl wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread José Lira Junior via lldb-commits


@@ -70,6 +72,31 @@ size_t Stream::PutCString(llvm::StringRef str) {
   return bytes_written;
 }
 
+void Stream::PutCStringColorHighlighted(llvm::StringRef text,
+const char *pattern) {
+  if (!pattern) {
+PutCString(text);
+return;
+  }
+
+  // If pattern is not nullptr, we should use color

junior-jl wrote:

Nice. Changed this.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread José Lira Junior via lldb-commits


@@ -70,6 +72,31 @@ size_t Stream::PutCString(llvm::StringRef str) {
   return bytes_written;
 }
 
+void Stream::PutCStringColorHighlighted(llvm::StringRef text,
+const char *pattern) {
+  if (!pattern) {
+PutCString(text);
+return;
+  }
+
+  // If pattern is not nullptr, we should use color
+  llvm::Regex reg_pattern(pattern);
+  llvm::SmallVector matches;
+  llvm::StringRef remaining = text;
+  std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes(
+  "${ansi.fg.red}%.*s${ansi.normal}");

junior-jl wrote:

I'm not sure if I got this suggestion right. What I did was:

1. Defined these properties in `lldb/source/Core/CoreProperties.td`:

```
def ShowRegexMatchAnsiPrefix: Property<"show-regex-match-ansi-prefix", 
"String">,
Global,
DefaultStringValue<"${ansi.fg.red}">,
Desc<"When displaying a regex match in a color-enabled terminal, use the 
ANSI terminal code specified in this format immediately before the match.">;
def ShowRegexMatchAnsiSuffix: Property<"show-regex-match-ansi-suffix", 
"String">,
Global,
DefaultStringValue<"${ansi.normal}">,
Desc<"When displaying a regex match in a color-enabled terminal, use the 
ANSI terminal code specified in this format immediately after the match.">;
```

2. Declared the getter functions in `Debugger.h` and defined them in 
`Debugger.cpp` following the pattern:

```cpp
llvm::StringRef Debugger::GetRegexMatchAnsiPrefix() const {
  const uint32_t idx = ePropertyShowRegexMatchAnsiPrefix;
  return GetPropertyAtIndexAs(
  idx, g_debugger_properties[idx].default_cstr_value);
}

llvm::StringRef Debugger::GetRegexMatchAnsiSuffix() const {
  const uint32_t idx = ePropertyShowRegexMatchAnsiSuffix;
  return GetPropertyAtIndexAs(
  idx, g_debugger_properties[idx].default_cstr_value);
}

```

3. Added two parameters to `Stream::PutCStringColorHighlighted`: `prefix` and 
`suffix`.
4. In `Address.cpp` and `Symbol.cpp`, there was a `Target` object that I used 
to get the debugger and its properties. In `CommandObjectTarget.cpp`, there was 
an `CommandInterpreter` object that was used for the same. But in 
`SymbolContext.cpp`, there was a `TargetSP` object and I tried using it to get 
the debugger properties, I got a segmentation fault, that's why I put the 
following two lines hard coded (while we don't solve this):

```
llvm::StringRef ansi_prefix = "${ansi.fg.red}";
llvm::StringRef ansi_suffix = "${ansi.normal}";
```

Please let me know if there's a better way to do this or if I completely 
misunderstood the suggestion.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-04 Thread José Lira Junior via lldb-commits


@@ -70,6 +72,31 @@ size_t Stream::PutCString(llvm::StringRef str) {
   return bytes_written;
 }
 
+void Stream::PutCStringColorHighlighted(llvm::StringRef text,
+const char *pattern) {
+  if (!pattern) {
+PutCString(text);
+return;
+  }
+
+  // If pattern is not nullptr, we should use color
+  llvm::Regex reg_pattern(pattern);
+  llvm::SmallVector matches;
+  llvm::StringRef remaining = text;
+  std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes(
+  "${ansi.fg.red}%.*s${ansi.normal}");

junior-jl wrote:

Also, I was going to add a test case for different colors, but I will only add 
when that error is fixed.

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


[Lldb-commits] [lldb] 961d943 - [lldb] Remove unused variable

2023-12-04 Thread Brad Smith via lldb-commits

Author: Brad Smith
Date: 2023-12-04T19:51:31-05:00
New Revision: 961d943e396fa179988a160c2998f0bafc2a56c0

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

LOG: [lldb] Remove unused variable

lldb/source/Host/netbsd/HostInfoNetBSD.cpp:48:8: warning: unused variable 
'osrev_str' [-Wunused-variable]
  char osrev_str[12];
   ^
1 warning generated.

Added: 


Modified: 
lldb/source/Host/netbsd/HostInfoNetBSD.cpp

Removed: 




diff  --git a/lldb/source/Host/netbsd/HostInfoNetBSD.cpp 
b/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
index 0de4f2530bbaa..6a4aacc88f1e2 100644
--- a/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
+++ b/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -45,7 +45,6 @@ llvm::VersionTuple HostInfoNetBSD::GetOSVersion() {
 
 std::optional HostInfoNetBSD::GetOSBuildString() {
   int mib[2] = {CTL_KERN, KERN_OSREV};
-  char osrev_str[12];
   int osrev = 0;
   size_t osrev_len = sizeof(osrev);
 



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


[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)

2023-12-04 Thread via lldb-commits


@@ -1296,10 +1296,11 @@ enum CompletionType {
   eRemoteDiskFileCompletion = (1u << 22),
   eRemoteDiskDirectoryCompletion = (1u << 23),
   eTypeCategoryNameCompletion = (1u << 24),
+  eThreadIDCompletion = (1u << 25),

jimingham wrote:

Even though this was a public enum, there was never anything you could do with 
it from the SB API's.  The only place you could set completions at all from the 
outside was in `command script add` and that didn't use the enum values, it 
used string equivalents.
So I think at this point we can change it as we need.
We also don't add completions that extend this table anywhere in lldb that I 
can see, we use custom completion functions that we use by hand in the 
HandleCompletion's instead.  And anyway, all that is internal to lldb_private, 
that's not exposed.

So I think none of this is really designed or used at this point, and we should 
think of what we want to do with this.

I think eCustomCompletion should mean "this object implements a custom 
completion, use that instead of any of the built-in ones."  So overloading it 
to be the enum terminator is wrong, since its value cannot float, it has to 
have a definite meaning.

The terminator is useful for input validation.  The "parsed command" patch I'm 
working on WILL allow users to specify a completion for the arguments, and it 
would be useful to be able to say "that enum value you just passed me was out 
of the range of valid completions."  But I think that's all it's needed for.

So I'd suggest leaving eCustomCompletion where it is, adding the Thread ID one 
after and then adding a terminator for input validation.

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


[Lldb-commits] [lldb] [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (PR #74396)

2023-12-04 Thread Brad Smith via lldb-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/74396

Also eliminate an unused variable while here.

>From 2c5e7f0a514132a977a0b12484d47fa7e4dcdc8a Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Mon, 4 Dec 2023 20:05:52 -0500
Subject: [PATCH] [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function

Also eliminate an unused variable while here.
---
 lldb/source/Host/openbsd/HostInfoOpenBSD.cpp | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp 
b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
index 43f22be51ef95..b30c7a83243c0 100644
--- a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -20,19 +20,23 @@ using namespace lldb_private;
 llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() {
   struct utsname un;
 
-  ::memset(&un, 0, sizeof(utsname));
-  if (uname(&un) < 0)
+  ::memset(&un, 0, sizeof(un));
+  if (::uname(&un) < 0)
 return llvm::VersionTuple();
 
-  unsigned major, minor;
-  if (2 == sscanf(un.release, "%u.%u", &major, &minor))
+  uint32_t major, minor;
+  int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32, &major, &minor);
+  switch (status) {
+  case 1:
+return llvm::VersionTuple(major);
+  case 2:
 return llvm::VersionTuple(major, minor);
+  }
   return llvm::VersionTuple();
 }
 
 std::optional HostInfoOpenBSD::GetOSBuildString() {
   int mib[2] = {CTL_KERN, KERN_OSREV};
-  char osrev_str[12];
   uint32_t osrev = 0;
   size_t osrev_len = sizeof(osrev);
 

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


[Lldb-commits] [lldb] [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (PR #74396)

2023-12-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Brad Smith (brad0)


Changes

Also eliminate an unused variable while here.

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


1 Files Affected:

- (modified) lldb/source/Host/openbsd/HostInfoOpenBSD.cpp (+9-5) 


``diff
diff --git a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp 
b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
index 43f22be51ef95..b30c7a83243c0 100644
--- a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -20,19 +20,23 @@ using namespace lldb_private;
 llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() {
   struct utsname un;
 
-  ::memset(&un, 0, sizeof(utsname));
-  if (uname(&un) < 0)
+  ::memset(&un, 0, sizeof(un));
+  if (::uname(&un) < 0)
 return llvm::VersionTuple();
 
-  unsigned major, minor;
-  if (2 == sscanf(un.release, "%u.%u", &major, &minor))
+  uint32_t major, minor;
+  int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32, &major, &minor);
+  switch (status) {
+  case 1:
+return llvm::VersionTuple(major);
+  case 2:
 return llvm::VersionTuple(major, minor);
+  }
   return llvm::VersionTuple();
 }
 
 std::optional HostInfoOpenBSD::GetOSBuildString() {
   int mib[2] = {CTL_KERN, KERN_OSREV};
-  char osrev_str[12];
   uint32_t osrev = 0;
   size_t osrev_len = sizeof(osrev);
 

``




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


[Lldb-commits] [lldb] 98b4c1e - [lldb][NFC] Minor formatting nits with some of the NetBSD code

2023-12-04 Thread Brad Smith via lldb-commits

Author: Brad Smith
Date: 2023-12-04T23:21:45-05:00
New Revision: 98b4c1ee212901f6b6478a928ca74ed6edb311a9

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

LOG: [lldb][NFC] Minor formatting nits with some of the NetBSD code

Added: 


Modified: 
lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
lldb/source/Plugins/Process/Utility/NetBSDSignals.h
lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h

Removed: 




diff  --git a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h 
b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
index 01daefaedbada..d41be81242962 100644
--- a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
+++ b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -1,4 +1,4 @@
-//===-- HostInfoNetBSD.h ---*- C++ -*-===//
+//===-- HostInfoNetBSD.h *- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git a/lldb/source/Plugins/Process/Utility/NetBSDSignals.h 
b/lldb/source/Plugins/Process/Utility/NetBSDSignals.h
index e6740a304a024..94bad7c19a499 100644
--- a/lldb/source/Plugins/Process/Utility/NetBSDSignals.h
+++ b/lldb/source/Plugins/Process/Utility/NetBSDSignals.h
@@ -1,4 +1,4 @@
-//===-- NetBSDSignals.h *- C++ -*-===//
+//===-- NetBSDSignals.h -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
index ba089190bd220..a160c87db6cf9 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
@@ -1,10 +1,10 @@
-//===-- RegisterContextNetBSD_i386.cpp -*- C++ -*-===//
+//===-- RegisterContextNetBSD_i386.cpp --*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
-//===-===//
+//===--===//
 
 #include "RegisterContextNetBSD_i386.h"
 #include "RegisterContextPOSIX_x86.h"

diff  --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h 
b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
index b7b8d33b7c379..6f97875060131 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
@@ -1,4 +1,4 @@
-//===-- RegisterContextNetBSD_x86_64.h -*- C++ -*-===//
+//===-- RegisterContextNetBSD_x86_64.h --*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.



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


[Lldb-commits] [lldb] [lldb] Return index of element in ValueObject path instead of the element's value (PR #74413)

2023-12-04 Thread Pete Lawrence via lldb-commits

https://github.com/PortalPete created 
https://github.com/llvm/llvm-project/pull/74413



rdar://119169160

>From 26891e6fab2c6ecc13ee11b6c2f4adbb1c936058 Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Mon, 4 Dec 2023 18:29:37 -1000
Subject: [PATCH] [lldb] Return index of element in ValueObject path instead of
 the element's value

rdar://119169160
---
 lldb/source/Core/ValueObject.cpp | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index a7f7ee64282d8..b13bffa0ca809 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -398,13 +398,16 @@ ValueObject::GetChildAtIndexPath(llvm::ArrayRef 
idxs,
   if (idxs.size() == 0)
 return GetSP();
   ValueObjectSP root(GetSP());
+
+  size_t current_index = 0;
   for (size_t idx : idxs) {
 root = root->GetChildAtIndex(idx);
 if (!root) {
   if (index_of_error)
-*index_of_error = idx;
+*index_of_error = current_index;
   return root;
 }
+current_index += 1;
   }
   return root;
 }
@@ -414,13 +417,17 @@ lldb::ValueObjectSP ValueObject::GetChildAtIndexPath(
   if (idxs.size() == 0)
 return GetSP();
   ValueObjectSP root(GetSP());
+
+  size_t current_index = 0;
   for (std::pair idx : idxs) {
 root = root->GetChildAtIndex(idx.first, idx.second);
 if (!root) {
   if (index_of_error)
-*index_of_error = idx.first;
+*index_of_error = current_index;
   return root;
 }
+
+current_index += 1;
   }
   return root;
 }

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


[Lldb-commits] [lldb] [lldb] Correctly check and report error states in StackFrame.cpp (PR #74414)

2023-12-04 Thread Pete Lawrence via lldb-commits

https://github.com/PortalPete created 
https://github.com/llvm/llvm-project/pull/74414

rdar://119155810

>From 35a7dbc9e4005675273e573fe1d3217668e4a5a0 Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Mon, 4 Dec 2023 13:56:38 -1000
Subject: [PATCH] [lldb] Correctly check and report error states in
 StackFrame.cpp

rdar://119155810
---
 lldb/source/Target/StackFrame.cpp | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index f0d78d8aa5fef..50cf01e63cd49 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -652,7 +652,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 Status deref_error;
 if (valobj_sp->GetCompilerType().IsReferenceType()) {
   valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
-  if (error.Fail()) {
+  if (!valobj_sp || deref_error.Fail()) {
 error.SetErrorStringWithFormatv(
 "Failed to dereference reference type: %s", deref_error);
 return ValueObjectSP();
@@ -660,7 +660,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 }
 
 valobj_sp = valobj_sp->Dereference(deref_error);
-if (error.Fail()) {
+if (!valobj_sp || deref_error.Fail()) {
   error.SetErrorStringWithFormatv(
   "Failed to dereference sythetic value: {0}", deref_error);
   return ValueObjectSP();
@@ -795,9 +795,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
   // what we have is *ptr[low]. the most similar C++ syntax is to deref
   // ptr and extract bit low out of it. reading array item low would be
   // done by saying ptr[low], without a deref * sign
-  Status error;
-  ValueObjectSP temp(valobj_sp->Dereference(error));
-  if (error.Fail()) {
+  Status deref_error;
+  ValueObjectSP temp(valobj_sp->Dereference(deref_error));
+  if (!temp || deref_error.Fail()) {
 valobj_sp->GetExpressionPath(var_expr_path_strm);
 error.SetErrorStringWithFormat(
 "could not dereference \"(%s) %s\"",
@@ -813,9 +813,8 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
   // arr[0] (an operation that is equivalent to deref-ing arr) and
   // extract bit low out of it. reading array item low would be done by
   // saying arr[low], without a deref * sign
-  Status error;
   ValueObjectSP temp(valobj_sp->GetChildAtIndex(0));
-  if (error.Fail()) {
+  if (!temp) {
 valobj_sp->GetExpressionPath(var_expr_path_strm);
 error.SetErrorStringWithFormat(
 "could not get item 0 for \"(%s) %s\"",
@@ -994,9 +993,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 // deref ptr and extract bits low thru high out of it. reading array
 // items low thru high would be done by saying ptr[low-high], without a
 // deref * sign
-Status error;
-ValueObjectSP temp(valobj_sp->Dereference(error));
-if (error.Fail()) {
+Status deref_error;
+ValueObjectSP temp(valobj_sp->Dereference(deref_error));
+if (!temp || deref_error.Fail()) {
   valobj_sp->GetExpressionPath(var_expr_path_strm);
   error.SetErrorStringWithFormat(
   "could not dereference \"(%s) %s\"",
@@ -1011,9 +1010,8 @@ ValueObjectSP 
StackFrame::GetValueForVariableExpressionPath(
 // get arr[0] (an operation that is equivalent to deref-ing arr) and
 // extract bits low thru high out of it. reading array items low thru
 // high would be done by saying arr[low-high], without a deref * sign
-Status error;
 ValueObjectSP temp(valobj_sp->GetChildAtIndex(0));
-if (error.Fail()) {
+if (!temp) {
   valobj_sp->GetExpressionPath(var_expr_path_strm);
   error.SetErrorStringWithFormat(
   "could not get item 0 for \"(%s) %s\"",

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


[Lldb-commits] [lldb] [lldb] Correctly check and report error states in StackFrame.cpp (PR #74414)

2023-12-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pete Lawrence (PortalPete)


Changes

rdar://119155810

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


1 Files Affected:

- (modified) lldb/source/Target/StackFrame.cpp (+10-12) 


``diff
diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index f0d78d8aa5fef..50cf01e63cd49 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -652,7 +652,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 Status deref_error;
 if (valobj_sp->GetCompilerType().IsReferenceType()) {
   valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
-  if (error.Fail()) {
+  if (!valobj_sp || deref_error.Fail()) {
 error.SetErrorStringWithFormatv(
 "Failed to dereference reference type: %s", deref_error);
 return ValueObjectSP();
@@ -660,7 +660,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 }
 
 valobj_sp = valobj_sp->Dereference(deref_error);
-if (error.Fail()) {
+if (!valobj_sp || deref_error.Fail()) {
   error.SetErrorStringWithFormatv(
   "Failed to dereference sythetic value: {0}", deref_error);
   return ValueObjectSP();
@@ -795,9 +795,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
   // what we have is *ptr[low]. the most similar C++ syntax is to deref
   // ptr and extract bit low out of it. reading array item low would be
   // done by saying ptr[low], without a deref * sign
-  Status error;
-  ValueObjectSP temp(valobj_sp->Dereference(error));
-  if (error.Fail()) {
+  Status deref_error;
+  ValueObjectSP temp(valobj_sp->Dereference(deref_error));
+  if (!temp || deref_error.Fail()) {
 valobj_sp->GetExpressionPath(var_expr_path_strm);
 error.SetErrorStringWithFormat(
 "could not dereference \"(%s) %s\"",
@@ -813,9 +813,8 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
   // arr[0] (an operation that is equivalent to deref-ing arr) and
   // extract bit low out of it. reading array item low would be done by
   // saying arr[low], without a deref * sign
-  Status error;
   ValueObjectSP temp(valobj_sp->GetChildAtIndex(0));
-  if (error.Fail()) {
+  if (!temp) {
 valobj_sp->GetExpressionPath(var_expr_path_strm);
 error.SetErrorStringWithFormat(
 "could not get item 0 for \"(%s) %s\"",
@@ -994,9 +993,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
 // deref ptr and extract bits low thru high out of it. reading array
 // items low thru high would be done by saying ptr[low-high], without a
 // deref * sign
-Status error;
-ValueObjectSP temp(valobj_sp->Dereference(error));
-if (error.Fail()) {
+Status deref_error;
+ValueObjectSP temp(valobj_sp->Dereference(deref_error));
+if (!temp || deref_error.Fail()) {
   valobj_sp->GetExpressionPath(var_expr_path_strm);
   error.SetErrorStringWithFormat(
   "could not dereference \"(%s) %s\"",
@@ -1011,9 +1010,8 @@ ValueObjectSP 
StackFrame::GetValueForVariableExpressionPath(
 // get arr[0] (an operation that is equivalent to deref-ing arr) and
 // extract bits low thru high out of it. reading array items low thru
 // high would be done by saying arr[low-high], without a deref * sign
-Status error;
 ValueObjectSP temp(valobj_sp->GetChildAtIndex(0));
-if (error.Fail()) {
+if (!temp) {
   valobj_sp->GetExpressionPath(var_expr_path_strm);
   error.SetErrorStringWithFormat(
   "could not get item 0 for \"(%s) %s\"",

``




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


[Lldb-commits] [lldb] [lldb] Return index of element in ValueObject path instead of the element's value (PR #74413)

2023-12-04 Thread Pete Lawrence via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Return index of element in ValueObject path instead of the element's value (PR #74413)

2023-12-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pete Lawrence (PortalPete)


Changes



rdar://119169160

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


1 Files Affected:

- (modified) lldb/source/Core/ValueObject.cpp (+9-2) 


``diff
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index a7f7ee64282d8..b13bffa0ca809 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -398,13 +398,16 @@ ValueObject::GetChildAtIndexPath(llvm::ArrayRef 
idxs,
   if (idxs.size() == 0)
 return GetSP();
   ValueObjectSP root(GetSP());
+
+  size_t current_index = 0;
   for (size_t idx : idxs) {
 root = root->GetChildAtIndex(idx);
 if (!root) {
   if (index_of_error)
-*index_of_error = idx;
+*index_of_error = current_index;
   return root;
 }
+current_index += 1;
   }
   return root;
 }
@@ -414,13 +417,17 @@ lldb::ValueObjectSP ValueObject::GetChildAtIndexPath(
   if (idxs.size() == 0)
 return GetSP();
   ValueObjectSP root(GetSP());
+
+  size_t current_index = 0;
   for (std::pair idx : idxs) {
 root = root->GetChildAtIndex(idx.first, idx.second);
 if (!root) {
   if (index_of_error)
-*index_of_error = idx.first;
+*index_of_error = current_index;
   return root;
 }
+
+current_index += 1;
   }
   return root;
 }

``




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


[Lldb-commits] [lldb] [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (PR #74396)

2023-12-04 Thread Alex Langford via lldb-commits

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


https://github.com/llvm/llvm-project/pull/74396
___
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] [libcxx] [compiler-rt] [lld] [libunwind] [mlir] [clang] [lldb] [flang] Fix clang to recognize new C23 modifiers %w and %wf when printing and scanning (

2023-12-04 Thread via lldb-commits

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

>From 06c4cf02dfb4b20c8349c5f3c7209276f6d56edf Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 9 Nov 2023 02:21:46 +
Subject: [PATCH 1/5] Fix clang to recognize new C23 modifiers %w and %wf when
 printing

---
 clang/include/clang/AST/FormatString.h | 16 +++-
 clang/lib/AST/FormatString.cpp | 52 +-
 clang/lib/AST/PrintfFormatString.cpp   | 19 ++
 clang/test/Sema/format-strings-ms.c| 28 ++
 4 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/FormatString.h 
b/clang/include/clang/AST/FormatString.h
index 5c4ad9baaef60..6a886854650f1 100644
--- a/clang/include/clang/AST/FormatString.h
+++ b/clang/include/clang/AST/FormatString.h
@@ -81,8 +81,10 @@ class LengthModifier {
 AsLongDouble, // 'L'
 AsAllocate,   // for '%as', GNU extension to C90 scanf
 AsMAllocate,  // for '%ms', GNU extension to scanf
-AsWide,   // 'w' (MSVCRT, like l but only for c, C, s, S, or Z
-AsWideChar = AsLong // for '%ls', only makes sense for printf
+AsWide,   // 'w' (1. MSVCRT, like l but only for c, C, s, S, or Z on 
windows
+  // 2. for b, d, i, o, u, x, or X when a size followed(like 
8, 16, 32 or 64)
+AsWideFast,   // 'wf' (for b, d, i, o, u, x, or X)
+AsWideChar = AsLong, // for '%ls', only makes sense for printf
   };
 
   LengthModifier()
@@ -417,6 +419,7 @@ class FormatSpecifier {
   ///  http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
   bool UsesPositionalArg;
   unsigned argIndex;
+  unsigned size;
 public:
   FormatSpecifier(bool isPrintf)
 : CS(isPrintf), VectorNumElts(false),
@@ -460,6 +463,15 @@ class FormatSpecifier {
 FieldWidth = Amt;
   }
 
+  void setSize(unsigned s) {
+size = s;
+  }
+
+  unsigned getSize() const {
+return size;
+  }
+
+
   bool usesPositionalArg() const { return UsesPositionalArg; }
 
   bool hasValidLengthModifier(const TargetInfo &Target,
diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index e0c9e18cfe3a2..ebc136e780717 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -286,7 +286,33 @@ 
clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
   lmKind = LengthModifier::AsInt3264;
   break;
 case 'w':
-  lmKind = LengthModifier::AsWide; ++I; break;
+  ++I;
+  if (I == E) return false;
+  if (*I == 'f') {
+lmKind = LengthModifier::AsWideFast;
+++I;
+  } else {
+lmKind = LengthModifier::AsWide;
+  }
+
+  if (I == E) return false;
+  int s = 0;
+  while (unsigned(*I - '0') <= 9) {
+s = 10 * s + unsigned(*I - '0');
+++I;
+  }
+
+  // s == 0 is MSVCRT case, like l but only for c, C, s, S, or Z on windows
+  // s != 0 for b, d, i, o, u, x, or X when a size followed(like 8, 16, 32 
or 64)
+  if (s != 0) {
+std::set supported_list {8, 16, 32, 64};
+if (supported_list.count(s) == 0) {
+  return false;
+}
+FS.setSize(s);
+  }
+
+  break;
   }
   LengthModifier lm(lmPosition, lmKind);
   FS.setLengthModifier(lm);
@@ -703,6 +729,8 @@ analyze_format_string::LengthModifier::toString() const {
 return "m";
   case AsWide:
 return "w";
+  case AsWideFast:
+return "wf";
   case None:
 return "";
   }
@@ -970,6 +998,27 @@ bool FormatSpecifier::hasValidLengthModifier(const 
TargetInfo &Target,
 case ConversionSpecifier::SArg:
 case ConversionSpecifier::ZArg:
   return Target.getTriple().isOSMSVCRT();
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
+default:
+  return false;
+  }
+case LengthModifier::AsWideFast:
+  switch (CS.getKind()) {
+case ConversionSpecifier::bArg:
+case ConversionSpecifier::dArg:
+case ConversionSpecifier::iArg:
+case ConversionSpecifier::oArg:
+case ConversionSpecifier::uArg:
+case ConversionSpecifier::xArg:
+case ConversionSpecifier::XArg:
+  return true;
 default:
   return false;
   }
@@ -996,6 +1045,7 @@ bool FormatSpecifier::hasStandardLengthModifier() const {
 case LengthModifier::AsInt3264:
 case LengthModifier::AsInt64:
 case LengthModifier::AsWide:
+case LengthModifier::AsWideFast:
 case LengthModifier::AsShortLong: // ???
   return false;
   }
diff --git a/clang/lib/AST/PrintfFormatString.cpp 
b/clang/lib/AST/PrintfFormatString.cpp
index f0b9d0ecaf234..4b9111e8bcf50 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/Print

[Lldb-commits] [lldb] 5c70c18 - [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (#74396)

2023-12-04 Thread via lldb-commits

Author: Brad Smith
Date: 2023-12-05T02:50:21-05:00
New Revision: 5c70c181a359e651bc58f98a4654e32087abe417

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

LOG: [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (#74396)

Also eliminate an unused variable while here.

Added: 


Modified: 
lldb/source/Host/openbsd/HostInfoOpenBSD.cpp

Removed: 




diff  --git a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp 
b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
index 43f22be51ef95..b30c7a83243c0 100644
--- a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -20,19 +20,23 @@ using namespace lldb_private;
 llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() {
   struct utsname un;
 
-  ::memset(&un, 0, sizeof(utsname));
-  if (uname(&un) < 0)
+  ::memset(&un, 0, sizeof(un));
+  if (::uname(&un) < 0)
 return llvm::VersionTuple();
 
-  unsigned major, minor;
-  if (2 == sscanf(un.release, "%u.%u", &major, &minor))
+  uint32_t major, minor;
+  int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32, &major, &minor);
+  switch (status) {
+  case 1:
+return llvm::VersionTuple(major);
+  case 2:
 return llvm::VersionTuple(major, minor);
+  }
   return llvm::VersionTuple();
 }
 
 std::optional HostInfoOpenBSD::GetOSBuildString() {
   int mib[2] = {CTL_KERN, KERN_OSREV};
-  char osrev_str[12];
   uint32_t osrev = 0;
   size_t osrev_len = sizeof(osrev);
 



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


[Lldb-commits] [lldb] [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (PR #74396)

2023-12-04 Thread Brad Smith via lldb-commits

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