[Lldb-commits] [lldb] ab27431 - [lldb][NFCI] Remove use of ConstString from UnixSignals::SignalCode

2023-06-01 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-06-01T10:03:56-07:00
New Revision: ab27431596c4f61f84ce41e27aad09a4dde3fc5a

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

LOG: [lldb][NFCI] Remove use of ConstString from UnixSignals::SignalCode

On llvm.org and all downstream forks that I'm aware of, SignalCodes are
always created from C string literals. They are never compared to
anything so they take up space in the ConstString StringPool for no
tangible benefit.

I've changed the type here to `const llvm::StringLiteral` instead of
using a `StringRef` or a `const char *` to express intent -- These
strings come from constant data whose lifetime is directly tied to that
of the running process (and are thus safe to store).

Differential Revision: https://reviews.llvm.org/D151516

Added: 


Modified: 
lldb/include/lldb/Target/UnixSignals.h
lldb/source/Target/UnixSignals.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/UnixSignals.h 
b/lldb/include/lldb/Target/UnixSignals.h
index 859cf0c814f69..74eb75fa23aa4 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -94,7 +94,7 @@ class UnixSignals {
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on the native platform.
   void AddSignalCode(
-  int signo, int code, const char *description,
+  int signo, int code, const llvm::StringLiteral description,
   SignalCodePrintOption print_option = SignalCodePrintOption::None);
 
   void RemoveSignal(int signo);
@@ -127,8 +127,8 @@ class UnixSignals {
   // Classes that inherit from UnixSignals can see and modify these
 
   struct SignalCode {
-ConstString m_description;
-SignalCodePrintOption m_print_option;
+const llvm::StringLiteral m_description;
+const SignalCodePrintOption m_print_option;
   };
 
   struct Signal {

diff  --git a/lldb/source/Target/UnixSignals.cpp 
b/lldb/source/Target/UnixSignals.cpp
index d754537cc4cf4..5d0f687b8ba6f 100644
--- a/lldb/source/Target/UnixSignals.cpp
+++ b/lldb/source/Target/UnixSignals.cpp
@@ -113,13 +113,14 @@ void UnixSignals::AddSignal(int signo, const char *name, 
bool default_suppress,
   ++m_version;
 }
 
-void UnixSignals::AddSignalCode(int signo, int code, const char *description,
+void UnixSignals::AddSignalCode(int signo, int code,
+const llvm::StringLiteral description,
 SignalCodePrintOption print_option) {
   collection::iterator signal = m_signals.find(signo);
   assert(signal != m_signals.end() &&
  "Tried to add code to signal that does not exist.");
   signal->second.m_codes.insert(
-  std::pair{code, SignalCode{ConstString(description), print_option}});
+  std::pair{code, SignalCode{description, print_option}});
   ++m_version;
 }
 
@@ -150,13 +151,13 @@ UnixSignals::GetSignalDescription(int32_t signo, 
std::optional code,
 str = pos->second.m_name.GetCString();
 
 if (code) {
-  std::map::const_iterator cpos =
+  std::map::const_iterator cpos =
   pos->second.m_codes.find(*code);
   if (cpos != pos->second.m_codes.end()) {
 const SignalCode &sc = cpos->second;
 str += ": ";
 if (sc.m_print_option != SignalCodePrintOption::Bounds)
-  str += sc.m_description.GetCString();
+  str += sc.m_description.str();
 
 std::stringstream strm;
 switch (sc.m_print_option) {
@@ -178,7 +179,7 @@ UnixSignals::GetSignalDescription(int32_t signo, 
std::optional code,
 strm << ", upper bound: 0x" << std::hex << *upper;
 strm << ")";
   } else
-strm << sc.m_description.GetCString();
+strm << sc.m_description.str();
 
   break;
 }



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


[Lldb-commits] [PATCH] D151516: [lldb][NFCI] Remove use of ConstString from UnixSignals::SignalCode

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab27431596c4: [lldb][NFCI] Remove use of ConstString from 
UnixSignals::SignalCode (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151516

Files:
  lldb/include/lldb/Target/UnixSignals.h
  lldb/source/Target/UnixSignals.cpp


Index: lldb/source/Target/UnixSignals.cpp
===
--- lldb/source/Target/UnixSignals.cpp
+++ lldb/source/Target/UnixSignals.cpp
@@ -113,13 +113,14 @@
   ++m_version;
 }
 
-void UnixSignals::AddSignalCode(int signo, int code, const char *description,
+void UnixSignals::AddSignalCode(int signo, int code,
+const llvm::StringLiteral description,
 SignalCodePrintOption print_option) {
   collection::iterator signal = m_signals.find(signo);
   assert(signal != m_signals.end() &&
  "Tried to add code to signal that does not exist.");
   signal->second.m_codes.insert(
-  std::pair{code, SignalCode{ConstString(description), print_option}});
+  std::pair{code, SignalCode{description, print_option}});
   ++m_version;
 }
 
@@ -150,13 +151,13 @@
 str = pos->second.m_name.GetCString();
 
 if (code) {
-  std::map::const_iterator cpos =
+  std::map::const_iterator cpos =
   pos->second.m_codes.find(*code);
   if (cpos != pos->second.m_codes.end()) {
 const SignalCode &sc = cpos->second;
 str += ": ";
 if (sc.m_print_option != SignalCodePrintOption::Bounds)
-  str += sc.m_description.GetCString();
+  str += sc.m_description.str();
 
 std::stringstream strm;
 switch (sc.m_print_option) {
@@ -178,7 +179,7 @@
 strm << ", upper bound: 0x" << std::hex << *upper;
 strm << ")";
   } else
-strm << sc.m_description.GetCString();
+strm << sc.m_description.str();
 
   break;
 }
Index: lldb/include/lldb/Target/UnixSignals.h
===
--- lldb/include/lldb/Target/UnixSignals.h
+++ lldb/include/lldb/Target/UnixSignals.h
@@ -94,7 +94,7 @@
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on the native platform.
   void AddSignalCode(
-  int signo, int code, const char *description,
+  int signo, int code, const llvm::StringLiteral description,
   SignalCodePrintOption print_option = SignalCodePrintOption::None);
 
   void RemoveSignal(int signo);
@@ -127,8 +127,8 @@
   // Classes that inherit from UnixSignals can see and modify these
 
   struct SignalCode {
-ConstString m_description;
-SignalCodePrintOption m_print_option;
+const llvm::StringLiteral m_description;
+const SignalCodePrintOption m_print_option;
   };
 
   struct Signal {


Index: lldb/source/Target/UnixSignals.cpp
===
--- lldb/source/Target/UnixSignals.cpp
+++ lldb/source/Target/UnixSignals.cpp
@@ -113,13 +113,14 @@
   ++m_version;
 }
 
-void UnixSignals::AddSignalCode(int signo, int code, const char *description,
+void UnixSignals::AddSignalCode(int signo, int code,
+const llvm::StringLiteral description,
 SignalCodePrintOption print_option) {
   collection::iterator signal = m_signals.find(signo);
   assert(signal != m_signals.end() &&
  "Tried to add code to signal that does not exist.");
   signal->second.m_codes.insert(
-  std::pair{code, SignalCode{ConstString(description), print_option}});
+  std::pair{code, SignalCode{description, print_option}});
   ++m_version;
 }
 
@@ -150,13 +151,13 @@
 str = pos->second.m_name.GetCString();
 
 if (code) {
-  std::map::const_iterator cpos =
+  std::map::const_iterator cpos =
   pos->second.m_codes.find(*code);
   if (cpos != pos->second.m_codes.end()) {
 const SignalCode &sc = cpos->second;
 str += ": ";
 if (sc.m_print_option != SignalCodePrintOption::Bounds)
-  str += sc.m_description.GetCString();
+  str += sc.m_description.str();
 
 std::stringstream strm;
 switch (sc.m_print_option) {
@@ -178,7 +179,7 @@
 strm << ", upper bound: 0x" << std::hex << *upper;
 strm << ")";
   } else
-strm << sc.m_description.GetCString();
+strm << sc.m_description.str();
 
   break;
 }
Index: lldb/include/lldb/Target/UnixSignals.h
===
--- lldb/include/lldb/Target/UnixSignals.h
+++ lldb/include/lldb/Target/UnixSignals.h
@@ -94,7 +94,7 @@
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on 

[Lldb-commits] [lldb] 620dc12 - Add EXC_SYSCALL to the set of ignorable mach exceptions.

2023-06-01 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2023-06-01T10:20:47-07:00
New Revision: 620dc1224ff9e4cb86e6e4d8e7c3941fc921887d

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

LOG: Add EXC_SYSCALL to the set of ignorable mach exceptions.
Add some more tests of what exceptions we accept and don't accept.

Differential Revision: https://reviews.llvm.org/D151843

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 60327fbe3124f..f3f0fd7de3751 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -63,7 +63,8 @@ static Status ExceptionMaskValidator(const char *string, void 
*unused) {
   || candidate == "EXC_BAD_INSTRUCTION"
   || candidate == "EXC_ARITHMETIC"
   || candidate == "EXC_RESOURCE"
-  || candidate == "EXC_GUARD")) {
+  || candidate == "EXC_GUARD"
+  || candidate == "EXC_SYSCALL")) {
   error.SetErrorStringWithFormat("invalid exception type: '%s'",
   candidate.str().c_str());
   return error;

diff  --git a/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py 
b/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
index 677e6315123fc..429f1dbb1beba 100644
--- a/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
+++ b/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
@@ -30,10 +30,22 @@ def suspended_thread_test(self):
 "EXC_BAD_AXESS",
 error=True,
 )
-# Now set ourselves to ignore some exceptions.  The test depends on 
ignoring EXC_BAD_ACCESS, but I passed a couple
-# to make sure they parse:
+# Make sure that we don't accept exceptions that lldb/debugserver need:
+self.match(
+"settings set platform.plugin.darwin.ignored-exceptions 
EXC_BREAKPOINT",
+"EXC_BREAKPOINT",
+error=True,
+)
+# Make sure that we don't accept exceptions that lldb/debugserver need:
+self.match(
+"settings set platform.plugin.darwin.ignored-exceptions 
EXC_SOFT_SIGNAL",
+"EXC_SOFT_SIGNAL",
+error=True,
+)
+# Now set ourselves to ignore some exceptions.  The test depends on 
ignoring EXC_BAD_ACCESS, but I passed all the
+# ones we currently accept to make sure they parse:
 self.runCmd(
-"settings set platform.plugin.darwin.ignored-exceptions 
EXC_BAD_ACCESS|EXC_ARITHMETIC"
+"settings set platform.plugin.darwin.ignored-exceptions 
EXC_BAD_ACCESS|EXC_BAD_INSTRUCTION|EXC_ARITHMETIC|EXC_RESOURCE|EXC_GUARD|EXC_SYSCALL"
 )
 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "Stop here to get things going", self.main_source_file



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


[Lldb-commits] [PATCH] D151843: Add EXC_SYSCALL to the allowable ignored exceptions for Darwin

2023-06-01 Thread Jim Ingham via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG620dc1224ff9: Add EXC_SYSCALL to the set of ignorable mach 
exceptions. (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151843

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py


Index: lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
===
--- lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
+++ lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
@@ -30,10 +30,22 @@
 "EXC_BAD_AXESS",
 error=True,
 )
-# Now set ourselves to ignore some exceptions.  The test depends on 
ignoring EXC_BAD_ACCESS, but I passed a couple
-# to make sure they parse:
+# Make sure that we don't accept exceptions that lldb/debugserver need:
+self.match(
+"settings set platform.plugin.darwin.ignored-exceptions 
EXC_BREAKPOINT",
+"EXC_BREAKPOINT",
+error=True,
+)
+# Make sure that we don't accept exceptions that lldb/debugserver need:
+self.match(
+"settings set platform.plugin.darwin.ignored-exceptions 
EXC_SOFT_SIGNAL",
+"EXC_SOFT_SIGNAL",
+error=True,
+)
+# Now set ourselves to ignore some exceptions.  The test depends on 
ignoring EXC_BAD_ACCESS, but I passed all the
+# ones we currently accept to make sure they parse:
 self.runCmd(
-"settings set platform.plugin.darwin.ignored-exceptions 
EXC_BAD_ACCESS|EXC_ARITHMETIC"
+"settings set platform.plugin.darwin.ignored-exceptions 
EXC_BAD_ACCESS|EXC_BAD_INSTRUCTION|EXC_ARITHMETIC|EXC_RESOURCE|EXC_GUARD|EXC_SYSCALL"
 )
 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "Stop here to get things going", self.main_source_file
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -63,7 +63,8 @@
   || candidate == "EXC_BAD_INSTRUCTION"
   || candidate == "EXC_ARITHMETIC"
   || candidate == "EXC_RESOURCE"
-  || candidate == "EXC_GUARD")) {
+  || candidate == "EXC_GUARD"
+  || candidate == "EXC_SYSCALL")) {
   error.SetErrorStringWithFormat("invalid exception type: '%s'",
   candidate.str().c_str());
   return error;


Index: lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
===
--- lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
+++ lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
@@ -30,10 +30,22 @@
 "EXC_BAD_AXESS",
 error=True,
 )
-# Now set ourselves to ignore some exceptions.  The test depends on ignoring EXC_BAD_ACCESS, but I passed a couple
-# to make sure they parse:
+# Make sure that we don't accept exceptions that lldb/debugserver need:
+self.match(
+"settings set platform.plugin.darwin.ignored-exceptions EXC_BREAKPOINT",
+"EXC_BREAKPOINT",
+error=True,
+)
+# Make sure that we don't accept exceptions that lldb/debugserver need:
+self.match(
+"settings set platform.plugin.darwin.ignored-exceptions EXC_SOFT_SIGNAL",
+"EXC_SOFT_SIGNAL",
+error=True,
+)
+# Now set ourselves to ignore some exceptions.  The test depends on ignoring EXC_BAD_ACCESS, but I passed all the
+# ones we currently accept to make sure they parse:
 self.runCmd(
-"settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS|EXC_ARITHMETIC"
+"settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS|EXC_BAD_INSTRUCTION|EXC_ARITHMETIC|EXC_RESOURCE|EXC_GUARD|EXC_SYSCALL"
 )
 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "Stop here to get things going", self.main_source_file
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -63,7 +63,8 @@
   || candidate == "EXC_BAD_INSTRUCTION"
   || candidate == "EXC_ARITHMETIC"
   || candidate == "EXC_RESOURCE"
-  || candidate == "EXC_GUARD")) {
+  || candidate == "EXC_G

[Lldb-commits] [lldb] 267a4cd - Prevent some spurious error messages in the debugserver logs.

2023-06-01 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2023-06-01T10:21:23-07:00
New Revision: 267a4cda82481da159492bc6d6597d11101f8abb

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

LOG: Prevent some spurious error messages in the debugserver logs.

DNBGetDeploymentInfo was calling GetPlatformString w/o checking that
the load command it was processing actually provided a platform string.
That caused a bunch of worrisome looking error messages in the debugserver
log output.

Differential Revision: https://reviews.llvm.org/D151861

Added: 


Modified: 
lldb/tools/debugserver/source/DNB.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/DNB.cpp 
b/lldb/tools/debugserver/source/DNB.cpp
index 8a8b1eeb355bd..7b86ca0bfb9dc 100644
--- a/lldb/tools/debugserver/source/DNB.cpp
+++ b/lldb/tools/debugserver/source/DNB.cpp
@@ -1456,9 +1456,13 @@ DNBGetDeploymentInfo(nub_process_t pid, bool 
is_executable,
 major_version = info.major_version;
 minor_version = info.minor_version;
 patch_version = info.patch_version;
+// MachProcess::DeploymentInfo has a bool operator to tell whether we have
+// set the platform.  If that's not true, don't report out the platform:
+if (!info)
+  return {};
 return procSP->GetPlatformString(info.platform);
   }
-  return nullptr;
+  return {};
 }
 
 // Get the current shared library information for a process. Only return



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


[Lldb-commits] [PATCH] D151861: Don't emit a bunch of spurious "Unknown platform 0" warnings from debugserver

2023-06-01 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG267a4cda8248: Prevent some spurious error messages in the 
debugserver logs. (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151861

Files:
  lldb/tools/debugserver/source/DNB.cpp


Index: lldb/tools/debugserver/source/DNB.cpp
===
--- lldb/tools/debugserver/source/DNB.cpp
+++ lldb/tools/debugserver/source/DNB.cpp
@@ -1456,9 +1456,13 @@
 major_version = info.major_version;
 minor_version = info.minor_version;
 patch_version = info.patch_version;
+// MachProcess::DeploymentInfo has a bool operator to tell whether we have
+// set the platform.  If that's not true, don't report out the platform:
+if (!info)
+  return {};
 return procSP->GetPlatformString(info.platform);
   }
-  return nullptr;
+  return {};
 }
 
 // Get the current shared library information for a process. Only return


Index: lldb/tools/debugserver/source/DNB.cpp
===
--- lldb/tools/debugserver/source/DNB.cpp
+++ lldb/tools/debugserver/source/DNB.cpp
@@ -1456,9 +1456,13 @@
 major_version = info.major_version;
 minor_version = info.minor_version;
 patch_version = info.patch_version;
+// MachProcess::DeploymentInfo has a bool operator to tell whether we have
+// set the platform.  If that's not true, don't report out the platform:
+if (!info)
+  return {};
 return procSP->GetPlatformString(info.platform);
   }
-  return nullptr;
+  return {};
 }
 
 // Get the current shared library information for a process. Only return
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151003: [Damangle] convert dlangDemangle to use std::string_view

2023-06-01 Thread Nick Desaulniers via Phabricator via lldb-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers added a comment.

needs rebasing for presubmit tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151003

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


[Lldb-commits] [PATCH] D149784: [Damangle] convert rustDemangle to use std::string_view

2023-06-01 Thread Nick Desaulniers via Phabricator via lldb-commits
nickdesaulniers updated this revision to Diff 527502.
nickdesaulniers added a comment.

- rebase, reformat for presubmit tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149784

Files:
  lldb/include/lldb/Utility/ConstString.h
  lldb/source/Core/Mangled.cpp
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/Demangle/RustDemangle.cpp
  llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp

Index: llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
===
--- llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
+++ llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
@@ -13,7 +13,7 @@
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   std::string NullTerminatedString((const char *)Data, Size);
-  char *Demangled = llvm::rustDemangle(NullTerminatedString.c_str());
+  char *Demangled = llvm::rustDemangle(NullTerminatedString);
   std::free(Demangled);
   return 0;
 }
Index: llvm/lib/Demangle/RustDemangle.cpp
===
--- llvm/lib/Demangle/RustDemangle.cpp
+++ llvm/lib/Demangle/RustDemangle.cpp
@@ -20,11 +20,13 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 
 using llvm::itanium_demangle::OutputBuffer;
 using llvm::itanium_demangle::ScopedOverride;
+using llvm::itanium_demangle::starts_with;
 
 namespace {
 
@@ -146,17 +148,13 @@
 
 } // namespace
 
-char *llvm::rustDemangle(const char *MangledName) {
-  if (MangledName == nullptr)
-return nullptr;
-
+char *llvm::rustDemangle(std::string_view MangledName) {
   // Return early if mangled name doesn't look like a Rust symbol.
-  std::string_view Mangled(MangledName);
-  if (!llvm::itanium_demangle::starts_with(Mangled, "_R"))
+  if (MangledName.empty() || !starts_with(MangledName, "_R"))
 return nullptr;
 
   Demangler D;
-  if (!D.demangle(Mangled)) {
+  if (!D.demangle(MangledName)) {
 std::free(D.Output.getBuffer());
 return nullptr;
   }
@@ -196,7 +194,7 @@
   RecursionLevel = 0;
   BoundLifetimes = 0;
 
-  if (!llvm::itanium_demangle::starts_with(Mangled, "_R")) {
+  if (!starts_with(Mangled, "_R")) {
 Error = true;
 return false;
   }
Index: llvm/include/llvm/Demangle/Demangle.h
===
--- llvm/include/llvm/Demangle/Demangle.h
+++ llvm/include/llvm/Demangle/Demangle.h
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 
 namespace llvm {
 /// This is a llvm local version of __cxa_demangle. Other than the name and
@@ -54,7 +55,7 @@
 MSDemangleFlags Flags = MSDF_None);
 
 // Demangles a Rust v0 mangled symbol.
-char *rustDemangle(const char *MangledName);
+char *rustDemangle(std::string_view MangledName);
 
 // Demangles a D mangled symbol.
 char *dlangDemangle(const char *MangledName);
Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -25,6 +25,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -150,7 +151,7 @@
   return demangled_cstr;
 }
 
-static char *GetRustV0DemangledStr(const char *M) {
+static char *GetRustV0DemangledStr(std::string_view M) {
   char *demangled_cstr = llvm::rustDemangle(M);
 
   if (Log *log = GetLog(LLDBLog::Demangle)) {
@@ -259,7 +260,7 @@
 break;
   }
   case eManglingSchemeRustV0:
-demangled_name = GetRustV0DemangledStr(mangled_name);
+demangled_name = GetRustV0DemangledStr(m_mangled);
 break;
   case eManglingSchemeD:
 demangled_name = GetDLangDemangledStr(mangled_name);
Index: lldb/include/lldb/Utility/ConstString.h
===
--- lldb/include/lldb/Utility/ConstString.h
+++ lldb/include/lldb/Utility/ConstString.h
@@ -14,6 +14,7 @@
 #include "llvm/Support/FormatVariadic.h"
 
 #include 
+#include 
 
 namespace lldb_private {
 class Stream;
@@ -182,6 +183,10 @@
 
   // Implicitly convert \class ConstString instances to \class StringRef.
   operator llvm::StringRef() const { return GetStringRef(); }
+  // Implicitly convert \class ConstString instances to \calss std::string_view.
+  operator std::string_view() const {
+return std::string_view(m_string, GetLength());
+  }
 
   /// Get the string value as a C string.
   ///
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D149784: [Damangle] convert rustDemangle to use std::string_view

2023-06-01 Thread Nick Desaulniers via Phabricator via lldb-commits
nickdesaulniers updated this revision to Diff 527507.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.

- update comments as per @Maskray


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149784

Files:
  lldb/include/lldb/Utility/ConstString.h
  lldb/source/Core/Mangled.cpp
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/Demangle/RustDemangle.cpp
  llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp

Index: llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
===
--- llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
+++ llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
@@ -13,7 +13,7 @@
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   std::string NullTerminatedString((const char *)Data, Size);
-  char *Demangled = llvm::rustDemangle(NullTerminatedString.c_str());
+  char *Demangled = llvm::rustDemangle(NullTerminatedString);
   std::free(Demangled);
   return 0;
 }
Index: llvm/lib/Demangle/RustDemangle.cpp
===
--- llvm/lib/Demangle/RustDemangle.cpp
+++ llvm/lib/Demangle/RustDemangle.cpp
@@ -20,11 +20,13 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 
 using llvm::itanium_demangle::OutputBuffer;
 using llvm::itanium_demangle::ScopedOverride;
+using llvm::itanium_demangle::starts_with;
 
 namespace {
 
@@ -146,17 +148,13 @@
 
 } // namespace
 
-char *llvm::rustDemangle(const char *MangledName) {
-  if (MangledName == nullptr)
-return nullptr;
-
+char *llvm::rustDemangle(std::string_view MangledName) {
   // Return early if mangled name doesn't look like a Rust symbol.
-  std::string_view Mangled(MangledName);
-  if (!llvm::itanium_demangle::starts_with(Mangled, "_R"))
+  if (MangledName.empty() || !starts_with(MangledName, "_R"))
 return nullptr;
 
   Demangler D;
-  if (!D.demangle(Mangled)) {
+  if (!D.demangle(MangledName)) {
 std::free(D.Output.getBuffer());
 return nullptr;
   }
@@ -196,7 +194,7 @@
   RecursionLevel = 0;
   BoundLifetimes = 0;
 
-  if (!llvm::itanium_demangle::starts_with(Mangled, "_R")) {
+  if (!starts_with(Mangled, "_R")) {
 Error = true;
 return false;
   }
Index: llvm/include/llvm/Demangle/Demangle.h
===
--- llvm/include/llvm/Demangle/Demangle.h
+++ llvm/include/llvm/Demangle/Demangle.h
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 
 namespace llvm {
 /// This is a llvm local version of __cxa_demangle. Other than the name and
@@ -54,7 +55,7 @@
 MSDemangleFlags Flags = MSDF_None);
 
 // Demangles a Rust v0 mangled symbol.
-char *rustDemangle(const char *MangledName);
+char *rustDemangle(std::string_view MangledName);
 
 // Demangles a D mangled symbol.
 char *dlangDemangle(const char *MangledName);
Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -25,6 +25,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -150,7 +151,7 @@
   return demangled_cstr;
 }
 
-static char *GetRustV0DemangledStr(const char *M) {
+static char *GetRustV0DemangledStr(std::string_view M) {
   char *demangled_cstr = llvm::rustDemangle(M);
 
   if (Log *log = GetLog(LLDBLog::Demangle)) {
@@ -259,7 +260,7 @@
 break;
   }
   case eManglingSchemeRustV0:
-demangled_name = GetRustV0DemangledStr(mangled_name);
+demangled_name = GetRustV0DemangledStr(m_mangled);
 break;
   case eManglingSchemeD:
 demangled_name = GetDLangDemangledStr(mangled_name);
Index: lldb/include/lldb/Utility/ConstString.h
===
--- lldb/include/lldb/Utility/ConstString.h
+++ lldb/include/lldb/Utility/ConstString.h
@@ -14,6 +14,7 @@
 #include "llvm/Support/FormatVariadic.h"
 
 #include 
+#include 
 
 namespace lldb_private {
 class Stream;
@@ -180,8 +181,11 @@
 
   bool operator<(ConstString rhs) const;
 
-  // Implicitly convert \class ConstString instances to \class StringRef.
+  // Implicit conversion functions.
   operator llvm::StringRef() const { return GetStringRef(); }
+  operator std::string_view() const {
+return std::string_view(m_string, GetLength());
+  }
 
   /// Get the string value as a C string.
   ///
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151003: [Damangle] convert dlangDemangle to use std::string_view

2023-06-01 Thread Nick Desaulniers via Phabricator via lldb-commits
nickdesaulniers updated this revision to Diff 527514.
nickdesaulniers added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151003

Files:
  lldb/source/Core/Mangled.cpp
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/Demangle/DLangDemangle.cpp
  llvm/lib/Demangle/Demangle.cpp
  llvm/tools/llvm-dlang-demangle-fuzzer/llvm-dlang-demangle-fuzzer.cpp
  llvm/unittests/Demangle/DLangDemangleTest.cpp

Index: llvm/unittests/Demangle/DLangDemangleTest.cpp
===
--- llvm/unittests/Demangle/DLangDemangleTest.cpp
+++ llvm/unittests/Demangle/DLangDemangleTest.cpp
@@ -11,10 +11,11 @@
 #include "gtest/gtest.h"
 
 #include 
+#include 
 #include 
 
 struct DLangDemangleTestFixture
-: public testing::TestWithParam> {
+: public testing::TestWithParam> {
   char *Demangled;
 
   void SetUp() override { Demangled = llvm::dlangDemangle(GetParam().first); }
@@ -29,9 +30,8 @@
 INSTANTIATE_TEST_SUITE_P(
 DLangDemangleTest, DLangDemangleTestFixture,
 testing::Values(
-std::make_pair("_Dmain", "D main"), std::make_pair(nullptr, nullptr),
-std::make_pair("_Z", nullptr), std::make_pair("_DDD", nullptr),
-std::make_pair("_D88", nullptr),
+std::make_pair("_Dmain", "D main"), std::make_pair("_Z", nullptr),
+std::make_pair("_DDD", nullptr), std::make_pair("_D88", nullptr),
 std::make_pair("_D8demangleZ", "demangle"),
 std::make_pair("_D8demangle4testZ", "demangle.test"),
 std::make_pair("_D8demangle4test5test2Z", "demangle.test.test2"),
Index: llvm/tools/llvm-dlang-demangle-fuzzer/llvm-dlang-demangle-fuzzer.cpp
===
--- llvm/tools/llvm-dlang-demangle-fuzzer/llvm-dlang-demangle-fuzzer.cpp
+++ llvm/tools/llvm-dlang-demangle-fuzzer/llvm-dlang-demangle-fuzzer.cpp
@@ -13,7 +13,7 @@
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   std::string NullTerminatedString((const char *)Data, Size);
-  char *Demangled = llvm::dlangDemangle(NullTerminatedString.c_str());
+  char *Demangled = llvm::dlangDemangle(NullTerminatedString);
   std::free(Demangled);
   return 0;
 }
Index: llvm/lib/Demangle/Demangle.cpp
===
--- llvm/lib/Demangle/Demangle.cpp
+++ llvm/lib/Demangle/Demangle.cpp
@@ -46,6 +46,9 @@
 }
 
 bool llvm::nonMicrosoftDemangle(const char *MangledName, std::string &Result) {
+  if (!MangledName)
+return false;
+
   char *Demangled = nullptr;
   if (isItaniumEncoding(MangledName))
 Demangled = itaniumDemangle(MangledName);
Index: llvm/lib/Demangle/DLangDemangle.cpp
===
--- llvm/lib/Demangle/DLangDemangle.cpp
+++ llvm/lib/Demangle/DLangDemangle.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "llvm/Demangle/Demangle.h"
+#include "llvm/Demangle/StringViewExtras.h"
 #include "llvm/Demangle/Utility.h"
 
 #include 
@@ -22,6 +23,7 @@
 
 using namespace llvm;
 using llvm::itanium_demangle::OutputBuffer;
+using llvm::itanium_demangle::starts_with;
 
 namespace {
 
@@ -541,20 +543,20 @@
   return parseMangle(Demangled, this->Str);
 }
 
-char *llvm::dlangDemangle(const char *MangledName) {
-  if (MangledName == nullptr || strncmp(MangledName, "_D", 2) != 0)
+char *llvm::dlangDemangle(std::string_view MangledName) {
+  if (MangledName.empty() || !starts_with(MangledName, "_D"))
 return nullptr;
 
   OutputBuffer Demangled;
-  if (strcmp(MangledName, "_Dmain") == 0) {
+  if (MangledName == "_Dmain") {
 Demangled << "D main";
   } else {
 
-Demangler D = Demangler(MangledName);
-MangledName = D.parseMangle(&Demangled);
+Demangler D(MangledName.data());
+const char *M = D.parseMangle(&Demangled);
 
 // Check that the entire symbol was successfully demangled.
-if (MangledName == nullptr || *MangledName != '\0') {
+if (M == nullptr || *M != '\0') {
   std::free(Demangled.getBuffer());
   return nullptr;
 }
Index: llvm/include/llvm/Demangle/Demangle.h
===
--- llvm/include/llvm/Demangle/Demangle.h
+++ llvm/include/llvm/Demangle/Demangle.h
@@ -58,7 +58,7 @@
 char *rustDemangle(std::string_view MangledName);
 
 // Demangles a D mangled symbol.
-char *dlangDemangle(const char *MangledName);
+char *dlangDemangle(std::string_view MangledName);
 
 /// Attempt to demangle a string using different demangling schemes.
 /// The function uses heuristics to determine which demangling scheme to use.
Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -164,7 +164,7 @@
   return demangled_cstr;
 }
 
-static cha

[Lldb-commits] [PATCH] D151843: Add EXC_SYSCALL to the allowable ignored exceptions for Darwin

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

LGTM! Sorry I didn't look at this earlier...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151843

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


[Lldb-commits] [PATCH] D151919: [lldb][NFCI] Apply IndexEntry to DWARFUnitHeader outside of extraction

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: aprantl, fdeazeve, rastogishubham, JDevlieghere.
Herald added a subscriber: arphaman.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I plan on replacing LLDB's DWARFUnitHeader implementation with LLVM's.
LLVM's DWARFUnitHeader::extract applies the DWARFUnitIndex::Entry to a
given DWARFUnitHeader outside of the extraction because the index entry
is only relevant to one place where we may parse DWARFUnitHeaders
(specifically when we're creating a DWARFUnit in a DWO context). To ease
the transition, I've reshaped LLDB's implementation to look closer to
LLVM's.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151919

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -75,6 +75,8 @@
   }
   uint32_t GetNextUnitOffset() const { return m_offset + m_length + 4; }
 
+  llvm::Error ApplyIndexEntry(const llvm::DWARFUnitIndex::Entry *index_entry);
+
   static llvm::Expected
   extract(const lldb_private::DWARFDataExtractor &data, DIERef::Section section,
   lldb_private::DWARFContext &dwarf_context,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -875,11 +875,37 @@
   return *m_func_aranges_up;
 }
 
-llvm::Expected
-DWARFUnitHeader::extract(const DWARFDataExtractor &data,
- DIERef::Section section,
- lldb_private::DWARFContext &context,
- lldb::offset_t *offset_ptr) {
+llvm::Error DWARFUnitHeader::ApplyIndexEntry(
+const llvm::DWARFUnitIndex::Entry *index_entry) {
+  // We should only be calling this function when the index entry is not set and
+  // we have a valid one to set it to.
+  assert(index_entry);
+  assert(!m_index_entry);
+
+  if (m_abbr_offset)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Package unit with a non-zero abbreviation offset");
+
+  auto *unit_contrib = index_entry->getContribution();
+  if (!unit_contrib || unit_contrib->getLength32() != m_length + 4)
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Inconsistent DWARF package unit index");
+
+  auto *abbr_entry = index_entry->getContribution(llvm::DW_SECT_ABBREV);
+  if (!abbr_entry)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"DWARF package index missing abbreviation column");
+
+  m_abbr_offset = abbr_entry->getOffset();
+  m_index_entry = index_entry;
+  return llvm::Error::success();
+}
+
+llvm::Expected DWARFUnitHeader::extract(
+const DWARFDataExtractor &data, DIERef::Section section,
+lldb_private::DWARFContext &context, lldb::offset_t *offset_ptr) {
   DWARFUnitHeader header;
   header.m_offset = *offset_ptr;
   header.m_length = data.GetDWARFInitialLength(offset_ptr);
@@ -903,42 +929,6 @@
 header.m_type_offset = data.GetDWARFOffset(offset_ptr);
   }
 
-  if (context.isDwo()) {
-const llvm::DWARFUnitIndex *Index;
-if (header.IsTypeUnit()) {
-  Index = &context.GetAsLLVM().getTUIndex();
-  if (*Index)
-header.m_index_entry = Index->getFromHash(header.m_type_hash);
-} else {
-  Index = &context.GetAsLLVM().getCUIndex();
-  if (*Index && header.m_version >= 5 && header.m_dwo_id)
-header.m_index_entry = Index->getFromHash(*header.m_dwo_id);
-}
-if (!header.m_index_entry)
-  header.m_index_entry = Index->getFromOffset(header.m_offset);
-  }
-
-  if (header.m_index_entry) {
-if (header.m_abbr_offset) {
-  return llvm::createStringError(
-  llvm::inconvertibleErrorCode(),
-  "Package unit with a non-zero abbreviation offset");
-}
-auto *unit_contrib = header.m_index_entry->getContribution();
-if (!unit_contrib || unit_contrib->getLength32() != header.m_length + 4) {
-  return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "Inconsistent DWARF package unit index");
-}
-auto *abbr_entry =
-header.m_index_entry->getContribution(llvm::DW_SECT_ABBREV);
-if (!abbr_entry) {
-  return llvm::createStringError(
-  llvm::inconvertibleErrorCode(),
-  "DWARF package index missing abbreviation column");
-}
-header.m_abbr_offset = abbr_entry->getOffset();
-  }
-
   bool length_OK = data.ValidOffset(header.GetNextUnitOffset() - 1);
   bool version_OK = SymbolFileDWARF::SupportedVersion(he

[Lldb-commits] [PATCH] D151849: [lldb/crashlog] Create interactive crashlog with no binary

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 527575.
mib marked an inline comment as done.
mib added a subscriber: jingham.
mib added a comment.

Address @bulbazord & @jingham's comments:

- Rename name -> label
- Add test
- Add sanity check to avoid having integer only labels
- Add target index when label already exist for another target


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

https://reviews.llvm.org/D151849

Files:
  lldb/include/lldb/API/SBTarget.h
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/Target/TargetList.h
  lldb/source/API/SBTarget.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetList.cpp
  lldb/test/Shell/Target/target-label.test

Index: lldb/test/Shell/Target/target-label.test
===
--- /dev/null
+++ lldb/test/Shell/Target/target-label.test
@@ -0,0 +1,44 @@
+# RUN: %lldb -b -s %s  | FileCheck %s
+
+target create -l "ls" /bin/ls
+target list
+# CHECK: * target #0 (ls): /bin/ls
+
+script lldb.target.SetLabel("")
+target list
+# CHECK: * target #0: /bin/ls
+
+target create -l "cat" /bin/cat
+target list
+# CHECK: target #0 (ls): /bin/ls
+# CHECK-NEXT: * target #1 (cat): /bin/cat
+
+target create -l "cat" /bin/cat
+target list
+# CHECK: target #0 (ls): /bin/ls
+# CHECK-NEXT: target #1 (cat): /bin/cat
+# CHECK-NEXT: * target #2 (cat 2): /bin/cat
+
+target create -l 42 /bin/cat
+# CHECK: error: Cannot use integer as target label.
+
+target select 0
+# CHECK: * target #0 (ls): /bin/ls
+# CHECK-NEXT: target #1 (cat): /bin/cat
+# CHECK-NEXT: target #2 (cat 2): /bin/cat
+
+target select cat
+# CHECK: target #0 (ls): /bin/ls
+# CHECK-NEXT: * target #1 (cat): /bin/cat
+# CHECK-NEXT: target #2 (cat 2): /bin/cat
+
+script lldb.target.GetLabel()
+# CHECK: 'cat'
+
+script lldb.debugger.GetTargetAtIndex(2).SetLabel("The other cat")
+# CHECK: 'The other cat'
+
+target list
+# CHECK: target #0 (ls): /bin/ls
+# CHECK-NEXT: * target #1 (cat): /bin/cat
+# CHECK-NEXT: target #2 (The other cat): /bin/cat
Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -489,7 +489,7 @@
   return num_signals_sent;
 }
 
-int TargetList::GetNumTargets() const {
+size_t TargetList::GetNumTargets() const {
   std::lock_guard guard(m_target_list_mutex);
   return m_target_list.size();
 }
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -69,6 +69,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -2536,6 +2537,21 @@
   Target::GetGlobalProperties().SetDefaultArchitecture(arch);
 }
 
+const std::string &Target::SetLabel(llvm::StringRef label) {
+  std::ostringstream formatted_label(label.str(), std::ios_base::ate);
+  TargetList &targets = GetDebugger().GetTargetList();
+  for (size_t i = 0; i < targets.GetNumTargets(); i++) {
+TargetSP target_sp = targets.GetTargetAtIndex(i);
+if (target_sp && target_sp->GetLabel() == label) {
+formatted_label << " " << targets.GetIndexOfTarget(shared_from_this());
+break;
+}
+  }
+
+  m_label = formatted_label.str();
+  return m_label;
+}
+
 Target *Target::GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
   const SymbolContext *sc_ptr) {
   // The target can either exist in the "process" of ExecutionContext, or in
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -82,8 +82,14 @@
   if (!exe_valid)
 ::strcpy(exe_path, "");
 
-  strm.Printf("%starget #%u: %s", prefix_cstr ? prefix_cstr : "", target_idx,
-  exe_path);
+  std::string formatted_label = "";
+  const std::string &label = target->GetLabel();
+  if (!label.empty()) {
+formatted_label = " (" + label + ")";
+  }
+
+  strm.Printf("%starget #%u%s: %s", prefix_cstr ? prefix_cstr : "", target_idx,
+  formatted_label.data(), exe_path);
 
   uint32_t properties = 0;
   if (target_arch.IsValid()) {
@@ -209,6 +215,8 @@
 m_platform_options(true), // Include the --platform option.
 m_core_file(LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename,
 "Fullpath to a core file to use for this target."),
+m_label(LLDB_OPT_SET_1, false, "label", 'l', 0, eArgTypeName,
+"Optional name for this target.", nullptr),
 m_symbol_file(LLDB_OPT_SET_1, false, "symfile", 's', 0,
   eArgTypeFilename,
   "Fullpath to a stand alone debug "
@@ -234,6 +242,7 @@
 m_option_group.Append(&m_arch_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1)

[Lldb-commits] [PATCH] D151849: [lldb/crashlog] Create interactive crashlog with no binary

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 527576.
mib added a comment.

Reload the previous version of this diff


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

https://reviews.llvm.org/D151849

Files:
  lldb/examples/python/crashlog.py
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2515,7 +2515,7 @@
 
   FileSpec exe_spec_to_use;
   if (!exe_module) {
-if (!launch_info.GetExecutableFile()) {
+if (!launch_info.GetExecutableFile() && !launch_info.IsScriptedProcess()) {
   error.SetErrorString("executable module does not exist");
   return error;
 }
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -395,6 +395,10 @@
 self.version = -1
 self.target = None
 self.verbose = verbose
+self.process_id = None
+self.process_identifier = None
+self.process_path = None
+self.process_arch = None
 
 def dump(self):
 print("Crash Log File: %s" % (self.path))
@@ -484,9 +488,9 @@
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
 self.verbose = verbose
-self.crashlog = CrashLog(debugger, self.path, self.verbose)
 # List of DarwinImages sorted by their index.
 self.images = list()
+self.crashlog = CrashLog(debugger, self.path, self.verbose)
 
 @abc.abstractmethod
 def parse(self):
@@ -547,6 +551,8 @@
 def parse_process_info(self, json_data):
 self.crashlog.process_id = json_data["pid"]
 self.crashlog.process_identifier = json_data["procName"]
+if "procPath" in json_data:
+self.crashlog.process_path = json_data["procPath"]
 
 def parse_crash_reason(self, json_exception):
 self.crashlog.exception = json_exception
@@ -574,6 +580,10 @@
 darwin_image = self.crashlog.DarwinImage(
 low, high, name, version, img_uuid, path, self.verbose
 )
+if "arch" in json_image:
+darwin_image.arch = json_image["arch"]
+if path == self.crashlog.process_path:
+self.crashlog.process_arch = darwin_image.arch
 self.images.append(darwin_image)
 self.crashlog.images.append(darwin_image)
 
@@ -740,6 +750,13 @@
 gpr_dict = {str(idx): reg for idx, reg in enumerate(state)}
 registers.update(self.parse_thread_registers(gpr_dict, key))
 continue
+if key == "flavor":
+if not self.crashlog.process_arch:
+if state == "ARM_THREAD_STATE64":
+self.crashlog.process_arch = "arm64"
+elif state == "X86_THREAD_STATE":
+self.crashlog.process_arch = "x86_64"
+continue
 try:
 value = int(state["value"])
 registers["{}{}".format(prefix or "", key)] = value
@@ -912,6 +929,8 @@
 line[8:].strip().split(" [")
 )
 self.crashlog.process_id = pid_with_brackets.strip("[]")
+elif line.startswith("Path:"):
+self.crashlog.process_path = line[5:].strip()
 elif line.startswith("Identifier:"):
 self.crashlog.process_identifier = line[11:].strip()
 elif line.startswith("Version:"):
@@ -923,6 +942,11 @@
 else:
 self.crashlog.process = version_string
 self.crashlog.process_compatability_version = version_string
+elif line.startswith("Code Type:"):
+if "ARM-64" in line:
+self.crashlog.process_arch = "arm64"
+elif "X86-64" in line:
+self.crashlog.process_arch = "x86_64"
 elif self.parent_process_regex.search(line):
 parent_process_match = self.parent_process_regex.search(line)
 self.crashlog.parent_process_name = parent_process_match.group(1)
@@ -1343,9 +1367,12 @@
 # 2. If the user didn't provide a target, try to create a target using the symbolicator
 if not target or not target.IsValid():
 target = crashlog.create_target()
-# 3. If that didn't work, and a target is already loaded, use it
-if (target is None or not target.IsValid()) and debugger.GetNumTargets() > 0:
-target = debugger.GetTargetAtIndex(0)
+# 3. If that didn't work, create a dummy target
+if target is None or not target.IsValid():
+arch = crashlog.process_arch
+if not arch:
+arch = platform.machine()
+target = debugger.CreateTargetWithFileAndArch(None, arch)
 # 4. Fail
 if target is None or not target.IsValid():
 raise Interacti

[Lldb-commits] [PATCH] D151859: [lldb/Target] Add ability to set name to targets

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib marked 3 inline comments as done.
mib added inline comments.



Comment at: lldb/source/Commands/CommandObjectTarget.cpp:546-551
+if (!name.empty()) {
+  if (name == target_idx_arg) {
+target_idx = i;
+break;
+  }
+}

bulbazord wrote:
> nit:
> 
> Also, do we need the empty check? Or is it possible that `target_idx_arg` 
> could be an empty string?
We need to keep the empty check otherwise `target select ""` would select the 
first non-labeled target which would be wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151859

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


[Lldb-commits] [PATCH] D151859: [lldb/Target] Add ability to set a label to targets

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 527580.
mib marked an inline comment as done.
mib retitled this revision from "[lldb/Target] Add ability to set name to 
targets" to "[lldb/Target] Add ability to set a label to targets".
mib edited the summary of this revision.
mib added a comment.

Address @bulbazord & @jingham's comments:

- Rename name -> label
- Add test
- Add sanity check to avoid having integer only labels
- Add target index when label already exist for another target


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

https://reviews.llvm.org/D151859

Files:
  lldb/include/lldb/API/SBTarget.h
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/Target/TargetList.h
  lldb/source/API/SBTarget.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetList.cpp
  lldb/test/Shell/Target/target-label.test

Index: lldb/test/Shell/Target/target-label.test
===
--- /dev/null
+++ lldb/test/Shell/Target/target-label.test
@@ -0,0 +1,44 @@
+# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -s %s 2>&1 | FileCheck %s
+
+target create -l "ls" /bin/ls
+target list
+# CHECK: * target #0 (ls): /bin/ls
+
+script lldb.target.SetLabel("")
+target list
+# CHECK: * target #0: /bin/ls
+
+target create -l "cat" /bin/cat
+target list
+# CHECK: target #0: /bin/ls
+# CHECK-NEXT: * target #1 (cat): /bin/cat
+
+target create -l "cat" /bin/cat
+target list
+# CHECK: target #0: /bin/ls
+# CHECK-NEXT: target #1 (cat): /bin/cat
+# CHECK-NEXT: * target #2 (cat 2): /bin/cat
+
+target create -l 42 /bin/cat
+# CHECK: error: Cannot use integer as target label.
+
+target select 0
+# CHECK: * target #0: /bin/ls
+# CHECK-NEXT: target #1 (cat): /bin/cat
+# CHECK-NEXT: target #2 (cat 2): /bin/cat
+
+target select cat
+# CHECK: target #0: /bin/ls
+# CHECK-NEXT: * target #1 (cat): /bin/cat
+# CHECK-NEXT: target #2 (cat 2): /bin/cat
+
+script lldb.target.GetLabel()
+# CHECK: 'cat'
+
+script lldb.debugger.GetTargetAtIndex(2).SetLabel("The other cat")
+# CHECK: 'The other cat'
+
+target list
+# CHECK: target #0: /bin/ls
+# CHECK-NEXT: * target #1 (cat): /bin/cat
+# CHECK-NEXT: target #2 (The other cat): /bin/cat
Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -489,7 +489,7 @@
   return num_signals_sent;
 }
 
-int TargetList::GetNumTargets() const {
+size_t TargetList::GetNumTargets() const {
   std::lock_guard guard(m_target_list_mutex);
   return m_target_list.size();
 }
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -69,6 +69,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -2536,6 +2537,21 @@
   Target::GetGlobalProperties().SetDefaultArchitecture(arch);
 }
 
+const std::string &Target::SetLabel(llvm::StringRef label) {
+  std::ostringstream formatted_label(label.str(), std::ios_base::ate);
+  TargetList &targets = GetDebugger().GetTargetList();
+  for (size_t i = 0; i < targets.GetNumTargets(); i++) {
+TargetSP target_sp = targets.GetTargetAtIndex(i);
+if (target_sp && target_sp->GetLabel() == label) {
+formatted_label << " " << targets.GetIndexOfTarget(shared_from_this());
+break;
+}
+  }
+
+  m_label = formatted_label.str();
+  return m_label;
+}
+
 Target *Target::GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
   const SymbolContext *sc_ptr) {
   // The target can either exist in the "process" of ExecutionContext, or in
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -82,8 +82,14 @@
   if (!exe_valid)
 ::strcpy(exe_path, "");
 
-  strm.Printf("%starget #%u: %s", prefix_cstr ? prefix_cstr : "", target_idx,
-  exe_path);
+  std::string formatted_label = "";
+  const std::string &label = target->GetLabel();
+  if (!label.empty()) {
+formatted_label = " (" + label + ")";
+  }
+
+  strm.Printf("%starget #%u%s: %s", prefix_cstr ? prefix_cstr : "", target_idx,
+  formatted_label.data(), exe_path);
 
   uint32_t properties = 0;
   if (target_arch.IsValid()) {
@@ -209,6 +215,8 @@
 m_platform_options(true), // Include the --platform option.
 m_core_file(LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename,
 "Fullpath to a core file to use for this target."),
+m_label(LLDB_OPT_SET_1, false, "label", 'l', 0, eArgTypeName,
+"Optional name for this target.", nullptr),
 m_symbol_file(LLDB_OPT_SET_1, false, "symfile", 's', 0,
 

[Lldb-commits] [PATCH] D151859: [lldb/Target] Add ability to set a label to targets

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

I feel a little strange about having `SBTarget::SetLabel` give a label to a 
target that is anything other than what the user specified. In the test, you 
attempt to name 2 targets `cat`. The first one succeeds, the second one also 
succeeds but names it `cat 2` (where 2 is the index of the target). I think we 
should probably give some kind of error instead of doing that.




Comment at: lldb/source/API/SBTarget.cpp:1614-1620
+const char *SBTarget::SetLabel(const char *label) {
+  LLDB_INSTRUMENT_VA(this, label);
+
+  llvm::StringRef label_ref(label);
+  size_t label_is_integral = LLDB_INVALID_INDEX32;
+  if (!label_ref.empty() && llvm::to_integer(label_ref, label_is_integral))
+return nullptr;

What if this method returned an SBError that communicated the issue? 
Specifically, something like `target labels cannot be integral values` or 
something?

I see you doing that below in the lldb_private code.



Comment at: lldb/source/Target/Target.cpp:2546
+if (target_sp && target_sp->GetLabel() == label) {
+formatted_label << " " << targets.GetIndexOfTarget(shared_from_this());
+break;

nit: I know I'm arguing against this implementation, but in case this does go 
in with this implementation, you can probably just use `i` instead of getting 
the index of the target again.


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

https://reviews.llvm.org/D151859

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


[Lldb-commits] [PATCH] D151940: Fix regex & startsWith name lookup in SBTarget::FindGlobalVariables

2023-06-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: aprantl, jasonmolenda, mib, JDevlieghere.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

There were two bugs here.

1. eMatchTypeStartsWith searched for "symbol_name" by adding ".*" to the end of 
the symbol name and treating that as a regex, which isn't actually a regex for 
"starts with".  The ".*" is in fact a no-op.

2. When we finally get to comparing the name, we compare against whatever form 
of the name was in the accelerator table.  But for C++ that might be the 
mangled name.  We should also try demangled names here, since most users are 
going the see demangled not mangled names.

I fixed these two bugs and added a bunch of tests for FindGlobalVariables.

This change is in the DWARF parser code, so there may be a similar bug in PDB, 
but the test for this was already skipped for Windows, so I don't know about 
this.

You might theoretically need to do this Mangled comparison in

DWARFMappedHash::MemoryTable::FindByName

except when we have names we always chop them before looking them up so I 
couldn't see any code paths that fail without that change.  So I didn't add 
that to this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151940

Files:
  lldb/source/API/SBTarget.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
  lldb/test/API/lang/cpp/class_static/main.cpp

Index: lldb/test/API/lang/cpp/class_static/main.cpp
===
--- lldb/test/API/lang/cpp/class_static/main.cpp
+++ lldb/test/API/lang/cpp/class_static/main.cpp
@@ -21,23 +21,37 @@
 static PointType g_points[];
 };
 
+// Make sure similar names don't confuse us:
+
+class AA
+{
+public:
+  static PointType g_points[];
+};
+
 PointType A::g_points[] = 
 {
 {1,2 },
 {   11,   22 }
 };
-
 static PointType g_points[] = 
 {
 {3,4 },
 {   33,   44 }
 };
 
+PointType AA::g_points[] = 
+{
+{5,6 },
+{   55,   66 }
+};
+
 int
 main (int argc, char const *argv[])
 {
 const char *hello_world = "Hello, world!";
 printf ("A::g_points[1].x = %i\n", A::g_points[1].x); // Set break point at this line.
+printf ("AA::g_points[1].x = %i\n", AA::g_points[1].x);
 printf ("::g_points[1].x = %i\n", g_points[1].x);
 printf ("%s\n", hello_world);
 return 0;
Index: lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
===
--- lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
+++ lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
@@ -106,6 +106,20 @@
 ],
 )
 
+def build_value_check(self, var_name, values):
+children_1 = [ValueCheck(name = "x", value = values[0], type = "int"),
+  ValueCheck(name = "y", value = values[1], type = "int")]
+children_2 = [ValueCheck(name = "x", value = values[2], type = "int"),
+  ValueCheck(name = "y", value = values[3], type = "int")]
+elem_0 = ValueCheck(name = "[0]", value=None, type = "PointType",
+children=children_1)
+elem_1 = ValueCheck(name = "[1]", value=None, type = "PointType",
+children=children_2)
+value_check = ValueCheck(name=var_name, value = None, type = "PointType[2]",
+ children = [elem_0, elem_1])
+
+return value_check
+
 @expectedFailureAll(
 compiler=["gcc"], bugnumber="Compiler emits incomplete debug info"
 )
@@ -142,27 +156,30 @@
 # in_scope_only => False
 valList = frame.GetVariables(False, False, True, False)
 
-for val in valList:
+# Build ValueCheckers for the values we're going to find:
+value_check_A = self.build_value_check("A::g_points", ["1", "2", "11", "22"])
+value_check_none = self.build_value_check("g_points", ["3", "4", "33", "44"])
+value_check_AA = self.build_value_check("AA::g_points", ["5", "6", "55", "66"])
+
+for val in valList: 
 self.DebugSBValue(val)
 name = val.GetName()
-self.assertIn(name, ["g_points", "A::g_points"])
+self.assertIn(name, ["g_points", "A::g_points", "AA::g_points"])
+
+if name == "A::g_points":
+self.assertEqual(val.GetValueType(), lldb.eValueTypeVariableGlobal)
+value_check_A.check_value(self, val, "Got A::g_points right")
 if name == "g_points":
 self.assertEqual(val.GetValueType(), lldb.eValueTypeVariableStatic)
-self.assertEqual(val.GetNumChildren(), 2)
-elif name == "A::g_points":
+value_check_none.check_value(self, val, "Got g_points right")
+if name 

[Lldb-commits] [PATCH] D151919: [lldb][NFCI] Apply IndexEntry to DWARFUnitHeader outside of extraction

2023-06-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:889
+"Package unit with a non-zero abbreviation offset");
+
+  auto *unit_contrib = index_entry->getContribution();

I know this was also in the original code, so you may not know either: Should 
these error messages be limited to dwarf packages (.dwp) or should they be more 
generic?



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:980
+  entry = index.getFromOffset(expected_header->GetOffset());
+if (entry) {
+  if (llvm::Error err = expected_header->ApplyIndexEntry(entry)) {

llvm coding style would delete most of these {} ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151919

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


[Lldb-commits] [PATCH] D151919: [lldb][NFCI] Apply IndexEntry to DWARFUnitHeader outside of extraction

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:889
+"Package unit with a non-zero abbreviation offset");
+
+  auto *unit_contrib = index_entry->getContribution();

aprantl wrote:
> I know this was also in the original code, so you may not know either: Should 
> these error messages be limited to dwarf packages (.dwp) or should they be 
> more generic?
I'm not sure, but my understanding is that we only apply the index entry to the 
header in DWO contexts, so I assume DWP is involved.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:980
+  entry = index.getFromOffset(expected_header->GetOffset());
+if (entry) {
+  if (llvm::Error err = expected_header->ApplyIndexEntry(entry)) {

aprantl wrote:
> llvm coding style would delete most of these {} ?
Sounds good, I'll update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151919

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


[Lldb-commits] [PATCH] D151940: Fix regex & startsWith name lookup in SBTarget::FindGlobalVariables

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.

LGTM!




Comment at: lldb/test/API/lang/cpp/class_static/TestStaticVariables.py:182
 self.DebugSBValue(val)
-self.assertEqual(val.GetName(), "A::g_points")
+value_check_A.check_value(self, val, "FiindValue also works")
 

typo ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151940

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


[Lldb-commits] [lldb] 22667e3 - Fix regex & startsWith name lookup in SBTarget::FindGlobalVariables

2023-06-01 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2023-06-01T16:15:06-07:00
New Revision: 22667e3220de5ead353a2148265d841644b63824

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

LOG: Fix regex & startsWith name lookup in SBTarget::FindGlobalVariables

There were two bugs here.

eMatchTypeStartsWith searched for "symbol_name" by adding ".*" to the
end of the symbol name and treating that as a regex, which isn't
actually a regex for "starts with". The ".*" is in fact a no-op.  When
we finally get to comparing the name, we compare against whatever form
of the name was in the accelerator table. But for C++ that might be
the mangled name. We should also try demangled names here, since most
users are going the see demangled not mangled names.  I fixed these
two bugs and added a bunch of tests for FindGlobalVariables.

This change is in the DWARF parser code, so there may be a similar bug
in PDB, but the test for this was already skipped for Windows, so I
don't know about this.

You might theoretically need to do this Mangled comparison in

DWARFMappedHash::MemoryTable::FindByName

except when we have names we always chop them before looking them up
so I couldn't see any code paths that fail without that change. So I
didn't add that to this patch.

Differential Revision: https://reviews.llvm.org/D151940

Added: 


Modified: 
lldb/source/API/SBTarget.cpp
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
lldb/test/API/lang/cpp/class_static/main.cpp

Removed: 




diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 980cb7788bf51..53af5b1d7a477 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1892,7 +1892,7 @@ SBValueList SBTarget::FindGlobalVariables(const char 
*name,
  max_matches, variable_list);
   break;
 case eMatchTypeStartsWith:
-  regexstr = llvm::Regex::escape(name) + ".*";
+  regexstr = "^" + llvm::Regex::escape(name) + ".*";
   target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr),
  max_matches, variable_list);
   break;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
index f530993381a93..9b1497d955bcf 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -9,6 +9,8 @@
 #include "HashedNameToDIE.h"
 #include "llvm/ADT/StringRef.h"
 
+#include "lldb/Core/Mangled.h"
+
 using namespace lldb_private::dwarf;
 
 bool DWARFMappedHash::ExtractDIEArray(
@@ -423,7 +425,11 @@ 
DWARFMappedHash::MemoryTable::AppendHashDataForRegularExpression(
   count * m_header.header_data.GetMinimumHashDataByteSize();
   if (count > 0 && m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr,
min_total_hash_data_size)) {
-const bool match = regex.Execute(llvm::StringRef(strp_cstr));
+// The name in the name table may be a mangled name, in which case we
+// should also compare against the demangled version.  The simplest way to
+// do that is to use the Mangled class:
+lldb_private::Mangled mangled_name((llvm::StringRef(strp_cstr)));
+const bool match = mangled_name.NameMatches(regex);
 
 if (!match && m_header.header_data.HashDataHasFixedByteSize()) {
   // If the regex doesn't match and we have fixed size data, we can just

diff  --git a/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py 
b/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
index 05c45142fec77..6fd4a8c9b3018 100644
--- a/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
+++ b/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
@@ -106,6 +106,20 @@ def test_with_run_command_complete(self):
 ],
 )
 
+def build_value_check(self, var_name, values):
+children_1 = [ValueCheck(name = "x", value = values[0], type = "int"),
+  ValueCheck(name = "y", value = values[1], type = "int")]
+children_2 = [ValueCheck(name = "x", value = values[2], type = "int"),
+  ValueCheck(name = "y", value = values[3], type = "int")]
+elem_0 = ValueCheck(name = "[0]", value=None, type = "PointType",
+children=children_1)
+elem_1 = ValueCheck(name = "[1]", value=None, type = "PointType",
+children=children_2)
+value_check = ValueCheck(name=var_name, value = None, type = 
"PointType[2]",
+ children = [elem_0, elem_1])
+
+return value_check
+
 

[Lldb-commits] [PATCH] D151940: Fix regex & startsWith name lookup in SBTarget::FindGlobalVariables

2023-06-01 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22667e3220de: Fix regex & startsWith name lookup in 
SBTarget::FindGlobalVariables (authored by jingham).

Changed prior to commit:
  https://reviews.llvm.org/D151940?vs=527606&id=527657#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151940

Files:
  lldb/source/API/SBTarget.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
  lldb/test/API/lang/cpp/class_static/main.cpp

Index: lldb/test/API/lang/cpp/class_static/main.cpp
===
--- lldb/test/API/lang/cpp/class_static/main.cpp
+++ lldb/test/API/lang/cpp/class_static/main.cpp
@@ -21,23 +21,37 @@
 static PointType g_points[];
 };
 
+// Make sure similar names don't confuse us:
+
+class AA
+{
+public:
+  static PointType g_points[];
+};
+
 PointType A::g_points[] = 
 {
 {1,2 },
 {   11,   22 }
 };
-
 static PointType g_points[] = 
 {
 {3,4 },
 {   33,   44 }
 };
 
+PointType AA::g_points[] = 
+{
+{5,6 },
+{   55,   66 }
+};
+
 int
 main (int argc, char const *argv[])
 {
 const char *hello_world = "Hello, world!";
 printf ("A::g_points[1].x = %i\n", A::g_points[1].x); // Set break point at this line.
+printf ("AA::g_points[1].x = %i\n", AA::g_points[1].x);
 printf ("::g_points[1].x = %i\n", g_points[1].x);
 printf ("%s\n", hello_world);
 return 0;
Index: lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
===
--- lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
+++ lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
@@ -106,6 +106,20 @@
 ],
 )
 
+def build_value_check(self, var_name, values):
+children_1 = [ValueCheck(name = "x", value = values[0], type = "int"),
+  ValueCheck(name = "y", value = values[1], type = "int")]
+children_2 = [ValueCheck(name = "x", value = values[2], type = "int"),
+  ValueCheck(name = "y", value = values[3], type = "int")]
+elem_0 = ValueCheck(name = "[0]", value=None, type = "PointType",
+children=children_1)
+elem_1 = ValueCheck(name = "[1]", value=None, type = "PointType",
+children=children_2)
+value_check = ValueCheck(name=var_name, value = None, type = "PointType[2]",
+ children = [elem_0, elem_1])
+
+return value_check
+
 @expectedFailureAll(
 compiler=["gcc"], bugnumber="Compiler emits incomplete debug info"
 )
@@ -142,27 +156,30 @@
 # in_scope_only => False
 valList = frame.GetVariables(False, False, True, False)
 
-for val in valList:
+# Build ValueCheckers for the values we're going to find:
+value_check_A = self.build_value_check("A::g_points", ["1", "2", "11", "22"])
+value_check_none = self.build_value_check("g_points", ["3", "4", "33", "44"])
+value_check_AA = self.build_value_check("AA::g_points", ["5", "6", "55", "66"])
+
+for val in valList: 
 self.DebugSBValue(val)
 name = val.GetName()
-self.assertIn(name, ["g_points", "A::g_points"])
+self.assertIn(name, ["g_points", "A::g_points", "AA::g_points"])
+
+if name == "A::g_points":
+self.assertEqual(val.GetValueType(), lldb.eValueTypeVariableGlobal)
+value_check_A.check_value(self, val, "Got A::g_points right")
 if name == "g_points":
 self.assertEqual(val.GetValueType(), lldb.eValueTypeVariableStatic)
-self.assertEqual(val.GetNumChildren(), 2)
-elif name == "A::g_points":
+value_check_none.check_value(self, val, "Got g_points right")
+if name == "AA::g_points":
 self.assertEqual(val.GetValueType(), lldb.eValueTypeVariableGlobal)
-self.assertEqual(val.GetNumChildren(), 2)
-child1 = val.GetChildAtIndex(1)
-self.DebugSBValue(child1)
-child1_x = child1.GetChildAtIndex(0)
-self.DebugSBValue(child1_x)
-self.assertEqual(child1_x.GetTypeName(), "int")
-self.assertEqual(child1_x.GetValue(), "11")
+value_check_AA.check_value(self, val, "Got AA::g_points right")
 
 # SBFrame.FindValue() should also work.
 val = frame.FindValue("A::g_points", lldb.eValueTypeVariableGlobal)
 self.DebugSBValue(val)
-self.assertEqual(val.GetName(), "A::g_points")
+value_check_A.check_value(self, val, "FindValue also works")
 
 # Also exercise the "parameter" and "local" scopes while we ar

[Lldb-commits] [PATCH] D151949: [lldb][NFCI] Use size_t in OptionValueProperties

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: jingham, mib.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

In many places we're using uint32_t where we should be using size_t.
We should be consistent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151949

Files:
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/source/Interpreter/OptionValueProperties.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/Thread.cpp

Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -79,7 +79,7 @@
   ThreadOptionValueProperties(ConstString name) : Cloneable(name) {}
 
   const Property *
-  GetPropertyAtIndex(uint32_t idx,
+  GetPropertyAtIndex(size_t idx,
  const ExecutionContext *exe_ctx) const override {
 // When getting the value for a key from the thread options, we will always
 // try and grab the setting from the current thread if there is one. Else
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -4008,7 +4008,7 @@
   TargetOptionValueProperties(ConstString name) : Cloneable(name) {}
 
   const Property *
-  GetPropertyAtIndex(uint32_t idx,
+  GetPropertyAtIndex(size_t idx,
  const ExecutionContext *exe_ctx = nullptr) const override {
 // When getting the value for a key from the target options, we will always
 // try and grab the setting from the current target if there is one. Else
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -93,7 +93,7 @@
   ProcessOptionValueProperties(ConstString name) : Cloneable(name) {}
 
   const Property *
-  GetPropertyAtIndex(uint32_t idx,
+  GetPropertyAtIndex(size_t idx,
  const ExecutionContext *exe_ctx) const override {
 // When getting the value for a key from the process options, we will
 // always try and grab the setting from the current process if there is
Index: lldb/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -35,7 +35,7 @@
 }
 
 void OptionValueProperties::SetValueChangedCallback(
-uint32_t property_idx, std::function callback) {
+size_t property_idx, std::function callback) {
   Property *property = ProtectedGetPropertyAtIndex(property_idx);
   if (property)
 property->SetValueChangedCallback(std::move(callback));
@@ -138,7 +138,7 @@
   return error;
 }
 
-uint32_t OptionValueProperties::GetPropertyIndex(ConstString name) const {
+size_t OptionValueProperties::GetPropertyIndex(ConstString name) const {
   return m_name_to_index.Find(name, SIZE_MAX);
 }
 
@@ -149,7 +149,7 @@
 }
 
 lldb::OptionValueSP OptionValueProperties::GetPropertyValueAtIndex(
-uint32_t idx, const ExecutionContext *exe_ctx) const {
+size_t idx, const ExecutionContext *exe_ctx) const {
   const Property *setting = GetPropertyAtIndex(idx, exe_ctx);
   if (setting)
 return setting->GetValue();
@@ -158,7 +158,7 @@
 
 OptionValuePathMappings *
 OptionValueProperties::GetPropertyAtIndexAsOptionValuePathMappings(
-uint32_t idx, const ExecutionContext *exe_ctx) const {
+size_t idx, const ExecutionContext *exe_ctx) const {
   OptionValueSP value_sp(GetPropertyValueAtIndex(idx, exe_ctx));
   if (value_sp)
 return value_sp->GetAsPathMappings();
@@ -167,7 +167,7 @@
 
 OptionValueFileSpecList *
 OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpecList(
-uint32_t idx, const ExecutionContext *exe_ctx) const {
+size_t idx, const ExecutionContext *exe_ctx) const {
   OptionValueSP value_sp(GetPropertyValueAtIndex(idx, exe_ctx));
   if (value_sp)
 return value_sp->GetAsFileSpecList();
@@ -175,7 +175,7 @@
 }
 
 bool OptionValueProperties::GetPropertyAtIndexAsArgs(
-uint32_t idx, Args &args, const ExecutionContext *exe_ctx) const {
+size_t idx, Args &args, const ExecutionContext *exe_ctx) const {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
   if (!property)
 return false;
@@ -206,7 +206,7 @@
 }
 
 bool OptionValueProperties::SetPropertyAtIndexFromArgs(
-uint32_t idx, const Args &args, const ExecutionContext *exe_ctx) {
+size_t idx, const Args &args, const ExecutionContext *exe_ctx) {
   const Property *property = GetPropertyAtIndex(idx, exe_ctx);
   if (!property)
 return false;
@@ -232,7 +232,7 @@
 
 OptionValueDictionary *
 OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary(
-uint32_t id

[Lldb-commits] [PATCH] D151950: [lldb] Unconditionally increment depth when printing children

2023-06-01 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 created this revision.
augusto2112 added reviewers: kastiglione, aprantl, DavidSpickett.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The `target.max-children-depth` setting and `--depth` flag would be
ignored if treating pointer as arrays, fix that by always incrementing
the current depth when printing a new child.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151950

Files:
  lldb/source/DataFormatters/ValueObjectPrinter.cpp


Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -590,7 +590,7 @@
 void ValueObjectPrinter::PrintChild(
 ValueObjectSP child_sp,
 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
-  const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
+  const uint32_t consumed_depth = m_options.m_pointer_as_array ? 0 : 1;
   const bool does_consume_ptr_depth =
   ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
 
@@ -611,7 +611,7 @@
 ValueObjectPrinter child_printer(
 child_sp.get(), m_stream, child_options,
 does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
-m_curr_depth + consumed_depth, m_printed_instance_pointers);
+m_curr_depth + 1, m_printed_instance_pointers);
 child_printer.PrintValueObject();
   }
 }


Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -590,7 +590,7 @@
 void ValueObjectPrinter::PrintChild(
 ValueObjectSP child_sp,
 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
-  const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
+  const uint32_t consumed_depth = m_options.m_pointer_as_array ? 0 : 1;
   const bool does_consume_ptr_depth =
   ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
 
@@ -611,7 +611,7 @@
 ValueObjectPrinter child_printer(
 child_sp.get(), m_stream, child_options,
 does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
-m_curr_depth + consumed_depth, m_printed_instance_pointers);
+m_curr_depth + 1, m_printed_instance_pointers);
 child_printer.PrintValueObject();
   }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151950: [lldb] Unconditionally increment depth when printing children

2023-06-01 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 updated this revision to Diff 527670.
augusto2112 added a comment.
Herald added a subscriber: JDevlieghere.

Add radar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151950

Files:
  lldb/source/DataFormatters/ValueObjectPrinter.cpp


Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -590,7 +590,7 @@
 void ValueObjectPrinter::PrintChild(
 ValueObjectSP child_sp,
 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
-  const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
+  const uint32_t consumed_depth = m_options.m_pointer_as_array ? 0 : 1;
   const bool does_consume_ptr_depth =
   ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
 
@@ -611,7 +611,7 @@
 ValueObjectPrinter child_printer(
 child_sp.get(), m_stream, child_options,
 does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
-m_curr_depth + consumed_depth, m_printed_instance_pointers);
+m_curr_depth + 1, m_printed_instance_pointers);
 child_printer.PrintValueObject();
   }
 }


Index: lldb/source/DataFormatters/ValueObjectPrinter.cpp
===
--- lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -590,7 +590,7 @@
 void ValueObjectPrinter::PrintChild(
 ValueObjectSP child_sp,
 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth) {
-  const uint32_t consumed_depth = (!m_options.m_pointer_as_array) ? 1 : 0;
+  const uint32_t consumed_depth = m_options.m_pointer_as_array ? 0 : 1;
   const bool does_consume_ptr_depth =
   ((IsPtr() && !m_options.m_pointer_as_array) || IsRef());
 
@@ -611,7 +611,7 @@
 ValueObjectPrinter child_printer(
 child_sp.get(), m_stream, child_options,
 does_consume_ptr_depth ? --curr_ptr_depth : curr_ptr_depth,
-m_curr_depth + consumed_depth, m_printed_instance_pointers);
+m_curr_depth + 1, m_printed_instance_pointers);
 child_printer.PrintValueObject();
   }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151951: [lldb][NFCI] Change return type of Properties::GetExperimentalSettingsName

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: jingham, jasonmolenda, mib.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Most users of this stick it into a StringRef. The one user that doesn't
just tries to get the length out of it, which we can precompute by
putting it in a constexpr StringLiteral.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151951

Files:
  lldb/include/lldb/Core/UserSettingsController.h
  lldb/source/Core/UserSettingsController.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp


Index: lldb/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -88,8 +88,8 @@
 value_sp->GetSubValue(exe_ctx, sub_name.drop_front(), error);
 if (!return_val_sp) {
   if (Properties::IsSettingExperimental(sub_name.drop_front())) {
-size_t experimental_len =
-strlen(Properties::GetExperimentalSettingsName());
+const size_t experimental_len =
+Properties::GetExperimentalSettingsName().size();
 if (sub_name[experimental_len + 1] == '.')
   return_val_sp = value_sp->GetSubValue(
   exe_ctx, sub_name.drop_front(experimental_len + 2), error);
Index: lldb/source/Core/UserSettingsController.cpp
===
--- lldb/source/Core/UserSettingsController.cpp
+++ lldb/source/Core/UserSettingsController.cpp
@@ -107,7 +107,10 @@
   return lldb::OptionValuePropertiesSP();
 }
 
-const char *Properties::GetExperimentalSettingsName() { return "experimental"; 
}
+llvm::StringRef Properties::GetExperimentalSettingsName() {
+  static constexpr llvm::StringLiteral g_experimental("experimental");
+  return g_experimental;
+}
 
 bool Properties::IsSettingExperimental(llvm::StringRef setting) {
   if (setting.empty())
Index: lldb/include/lldb/Core/UserSettingsController.h
===
--- lldb/include/lldb/Core/UserSettingsController.h
+++ lldb/include/lldb/Core/UserSettingsController.h
@@ -79,7 +79,7 @@
   // don't find the name will not be treated as errors.  Also, if you decide to
   // keep the settings just move them into the containing properties, and we
   // will auto-forward the experimental settings to the real one.
-  static const char *GetExperimentalSettingsName();
+  static llvm::StringRef GetExperimentalSettingsName();
 
   static bool IsSettingExperimental(llvm::StringRef setting);
 


Index: lldb/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -88,8 +88,8 @@
 value_sp->GetSubValue(exe_ctx, sub_name.drop_front(), error);
 if (!return_val_sp) {
   if (Properties::IsSettingExperimental(sub_name.drop_front())) {
-size_t experimental_len =
-strlen(Properties::GetExperimentalSettingsName());
+const size_t experimental_len =
+Properties::GetExperimentalSettingsName().size();
 if (sub_name[experimental_len + 1] == '.')
   return_val_sp = value_sp->GetSubValue(
   exe_ctx, sub_name.drop_front(experimental_len + 2), error);
Index: lldb/source/Core/UserSettingsController.cpp
===
--- lldb/source/Core/UserSettingsController.cpp
+++ lldb/source/Core/UserSettingsController.cpp
@@ -107,7 +107,10 @@
   return lldb::OptionValuePropertiesSP();
 }
 
-const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
+llvm::StringRef Properties::GetExperimentalSettingsName() {
+  static constexpr llvm::StringLiteral g_experimental("experimental");
+  return g_experimental;
+}
 
 bool Properties::IsSettingExperimental(llvm::StringRef setting) {
   if (setting.empty())
Index: lldb/include/lldb/Core/UserSettingsController.h
===
--- lldb/include/lldb/Core/UserSettingsController.h
+++ lldb/include/lldb/Core/UserSettingsController.h
@@ -79,7 +79,7 @@
   // don't find the name will not be treated as errors.  Also, if you decide to
   // keep the settings just move them into the containing properties, and we
   // will auto-forward the experimental settings to the real one.
-  static const char *GetExperimentalSettingsName();
+  static llvm::StringRef GetExperimentalSettingsName();
 
   static bool IsSettingExperimental(llvm::StringRef setting);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D151849: [lldb/crashlog] Create interactive crashlog with no binary

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 527672.
mib marked 2 inline comments as done.
mib added a comment.

Address @bulbazord last comments


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

https://reviews.llvm.org/D151849

Files:
  lldb/examples/python/crashlog.py
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2515,7 +2515,7 @@
 
   FileSpec exe_spec_to_use;
   if (!exe_module) {
-if (!launch_info.GetExecutableFile()) {
+if (!launch_info.GetExecutableFile() && !launch_info.IsScriptedProcess()) {
   error.SetErrorString("executable module does not exist");
   return error;
 }
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -395,6 +395,10 @@
 self.version = -1
 self.target = None
 self.verbose = verbose
+self.process_id = None
+self.process_identifier = None
+self.process_path = None
+self.process_arch = None
 
 def dump(self):
 print("Crash Log File: %s" % (self.path))
@@ -484,9 +488,9 @@
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
 self.verbose = verbose
-self.crashlog = CrashLog(debugger, self.path, self.verbose)
 # List of DarwinImages sorted by their index.
 self.images = list()
+self.crashlog = CrashLog(debugger, self.path, self.verbose)
 
 @abc.abstractmethod
 def parse(self):
@@ -547,6 +551,8 @@
 def parse_process_info(self, json_data):
 self.crashlog.process_id = json_data["pid"]
 self.crashlog.process_identifier = json_data["procName"]
+if "procPath" in json_data:
+self.crashlog.process_path = json_data["procPath"]
 
 def parse_crash_reason(self, json_exception):
 self.crashlog.exception = json_exception
@@ -574,6 +580,10 @@
 darwin_image = self.crashlog.DarwinImage(
 low, high, name, version, img_uuid, path, self.verbose
 )
+if "arch" in json_image:
+darwin_image.arch = json_image["arch"]
+if path == self.crashlog.process_path:
+self.crashlog.process_arch = darwin_image.arch
 self.images.append(darwin_image)
 self.crashlog.images.append(darwin_image)
 
@@ -740,6 +750,13 @@
 gpr_dict = {str(idx): reg for idx, reg in enumerate(state)}
 registers.update(self.parse_thread_registers(gpr_dict, key))
 continue
+if key == "flavor":
+if not self.crashlog.process_arch:
+if state == "ARM_THREAD_STATE64":
+self.crashlog.process_arch = "arm64"
+elif state == "X86_THREAD_STATE":
+self.crashlog.process_arch = "x86_64"
+continue
 try:
 value = int(state["value"])
 registers["{}{}".format(prefix or "", key)] = value
@@ -912,6 +929,8 @@
 line[8:].strip().split(" [")
 )
 self.crashlog.process_id = pid_with_brackets.strip("[]")
+elif line.startswith("Path:"):
+self.crashlog.process_path = line[5:].strip()
 elif line.startswith("Identifier:"):
 self.crashlog.process_identifier = line[11:].strip()
 elif line.startswith("Version:"):
@@ -923,6 +942,11 @@
 else:
 self.crashlog.process = version_string
 self.crashlog.process_compatability_version = version_string
+elif line.startswith("Code Type:"):
+if "ARM-64" in line:
+self.crashlog.process_arch = "arm64"
+elif "X86-64" in line:
+self.crashlog.process_arch = "x86_64"
 elif self.parent_process_regex.search(line):
 parent_process_match = self.parent_process_regex.search(line)
 self.crashlog.parent_process_name = parent_process_match.group(1)
@@ -1343,9 +1367,12 @@
 # 2. If the user didn't provide a target, try to create a target using the symbolicator
 if not target or not target.IsValid():
 target = crashlog.create_target()
-# 3. If that didn't work, and a target is already loaded, use it
-if (target is None or not target.IsValid()) and debugger.GetNumTargets() > 0:
-target = debugger.GetTargetAtIndex(0)
+# 3. If that didn't work, create a dummy target
+if target is None or not target.IsValid():
+arch = crashlog.process_arch
+if not arch:
+raise InteractiveCrashLogException("couldn't create find the architecture to create the target")
+target = debugger.CreateTargetWithFileAndArc

[Lldb-commits] [lldb] a5a6c03 - [lldb/crashlog] Fix crash when loading non-symbolicated report

2023-06-01 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-06-01T17:10:57-07:00
New Revision: a5a6c03c448ba1ab404b58673eef1f7b68498dff

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

LOG: [lldb/crashlog] Fix crash when loading non-symbolicated report

This patch should address the crashes when parsing a the crash report
frame dictionary.

If the crash report is not symbolicated, the `symbolLocation` key will
be missing. In that case, we should just use the `imageOffset`.

rdar://109836386

Differential Revision: https://reviews.llvm.org/D151844

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index f6505c1f68e21..387f84cca33d4 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -598,7 +598,9 @@ def parse_frames(self, thread, json_frames):
 
 if "symbol" in json_frame:
 symbol = json_frame["symbol"]
-location = int(json_frame["symbolLocation"])
+location = 0
+if "symbolLocation" in json_frame and 
json_frame["symbolLocation"]:
+location = int(json_frame["symbolLocation"])
 image = self.images[image_id]
 image.symbols[symbol] = {
 "name": symbol,



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


[Lldb-commits] [PATCH] D151844: [lldb/crashlog] Fix crash when loading non-symbolicated report

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5a6c03c448b: [lldb/crashlog] Fix crash when loading 
non-symbolicated report (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D151844?vs=527212&id=527673#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151844

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -598,7 +598,9 @@
 
 if "symbol" in json_frame:
 symbol = json_frame["symbol"]
-location = int(json_frame["symbolLocation"])
+location = 0
+if "symbolLocation" in json_frame and 
json_frame["symbolLocation"]:
+location = int(json_frame["symbolLocation"])
 image = self.images[image_id]
 image.symbols[symbol] = {
 "name": symbol,


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -598,7 +598,9 @@
 
 if "symbol" in json_frame:
 symbol = json_frame["symbol"]
-location = int(json_frame["symbolLocation"])
+location = 0
+if "symbolLocation" in json_frame and json_frame["symbolLocation"]:
+location = int(json_frame["symbolLocation"])
 image = self.images[image_id]
 image.symbols[symbol] = {
 "name": symbol,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 032d91c - [lldb/crashlog] Create interactive crashlog with no binary

2023-06-01 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-06-01T17:10:57-07:00
New Revision: 032d91cb2fb539a541f24558a8c61a40b1577dfd

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

LOG: [lldb/crashlog] Create interactive crashlog with no binary

This patch changes the way we load a crash report into a scripted
process by creating a empty target.

To do so, it parses the architecture information from the report (for
both the legacy and json format) and uses that to create a target that
doesn't have any executable, like what we do when attaching to a process.

For the legacy format, we mostly rely on the `Code Type` line, since the
architure is an optional field on the `Binary Images` sections.

However for the json format, we first try to get the architecture while
parsing the image dictionary if we couldn't find it, we try to infer it
using the "flavor" key when parsing the frame's registers.

If the architecture is still not set after parsing the report, we raise
an exception.

rdar://107850263

Differential Revision: https://reviews.llvm.org/D151849

Differential

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 387f84cca33d4..9978c70d0bfdf 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -395,6 +395,10 @@ def __init__(self, debugger, path, verbose):
 self.version = -1
 self.target = None
 self.verbose = verbose
+self.process_id = None
+self.process_identifier = None
+self.process_path = None
+self.process_arch = None
 
 def dump(self):
 print("Crash Log File: %s" % (self.path))
@@ -484,9 +488,9 @@ def create(debugger, path, verbose):
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
 self.verbose = verbose
-self.crashlog = CrashLog(debugger, self.path, self.verbose)
 # List of DarwinImages sorted by their index.
 self.images = list()
+self.crashlog = CrashLog(debugger, self.path, self.verbose)
 
 @abc.abstractmethod
 def parse(self):
@@ -547,6 +551,8 @@ def get_used_image(self, idx):
 def parse_process_info(self, json_data):
 self.crashlog.process_id = json_data["pid"]
 self.crashlog.process_identifier = json_data["procName"]
+if "procPath" in json_data:
+self.crashlog.process_path = json_data["procPath"]
 
 def parse_crash_reason(self, json_exception):
 self.crashlog.exception = json_exception
@@ -574,6 +580,10 @@ def parse_images(self, json_images):
 darwin_image = self.crashlog.DarwinImage(
 low, high, name, version, img_uuid, path, self.verbose
 )
+if "arch" in json_image:
+darwin_image.arch = json_image["arch"]
+if path == self.crashlog.process_path:
+self.crashlog.process_arch = darwin_image.arch
 self.images.append(darwin_image)
 self.crashlog.images.append(darwin_image)
 
@@ -740,6 +750,13 @@ def parse_thread_registers(self, json_thread_state, 
prefix=None):
 gpr_dict = {str(idx): reg for idx, reg in enumerate(state)}
 registers.update(self.parse_thread_registers(gpr_dict, key))
 continue
+if key == "flavor":
+if not self.crashlog.process_arch:
+if state == "ARM_THREAD_STATE64":
+self.crashlog.process_arch = "arm64"
+elif state == "X86_THREAD_STATE":
+self.crashlog.process_arch = "x86_64"
+continue
 try:
 value = int(state["value"])
 registers["{}{}".format(prefix or "", key)] = value
@@ -912,6 +929,8 @@ def parse_normal(self, line):
 line[8:].strip().split(" [")
 )
 self.crashlog.process_id = pid_with_brackets.strip("[]")
+elif line.startswith("Path:"):
+self.crashlog.process_path = line[5:].strip()
 elif line.startswith("Identifier:"):
 self.crashlog.process_identifier = line[11:].strip()
 elif line.startswith("Version:"):
@@ -923,6 +942,11 @@ def parse_normal(self, line):
 else:
 self.crashlog.process = version_string
 self.crashlog.process_compatability_version = version_string
+elif line.startswith("Code Type:"):
+if "ARM-64" in line:
+self.crashlog.process_arch = "arm64"
+elif "X86-64" in line:
+self.crashlog.proces

[Lldb-commits] [PATCH] D151849: [lldb/crashlog] Create interactive crashlog with no binary

2023-06-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG032d91cb2fb5: [lldb/crashlog] Create interactive crashlog 
with no binary (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151849

Files:
  lldb/examples/python/crashlog.py
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2527,7 +2527,7 @@
 
   FileSpec exe_spec_to_use;
   if (!exe_module) {
-if (!launch_info.GetExecutableFile()) {
+if (!launch_info.GetExecutableFile() && !launch_info.IsScriptedProcess()) {
   error.SetErrorString("executable module does not exist");
   return error;
 }
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -395,6 +395,10 @@
 self.version = -1
 self.target = None
 self.verbose = verbose
+self.process_id = None
+self.process_identifier = None
+self.process_path = None
+self.process_arch = None
 
 def dump(self):
 print("Crash Log File: %s" % (self.path))
@@ -484,9 +488,9 @@
 def __init__(self, debugger, path, verbose):
 self.path = os.path.expanduser(path)
 self.verbose = verbose
-self.crashlog = CrashLog(debugger, self.path, self.verbose)
 # List of DarwinImages sorted by their index.
 self.images = list()
+self.crashlog = CrashLog(debugger, self.path, self.verbose)
 
 @abc.abstractmethod
 def parse(self):
@@ -547,6 +551,8 @@
 def parse_process_info(self, json_data):
 self.crashlog.process_id = json_data["pid"]
 self.crashlog.process_identifier = json_data["procName"]
+if "procPath" in json_data:
+self.crashlog.process_path = json_data["procPath"]
 
 def parse_crash_reason(self, json_exception):
 self.crashlog.exception = json_exception
@@ -574,6 +580,10 @@
 darwin_image = self.crashlog.DarwinImage(
 low, high, name, version, img_uuid, path, self.verbose
 )
+if "arch" in json_image:
+darwin_image.arch = json_image["arch"]
+if path == self.crashlog.process_path:
+self.crashlog.process_arch = darwin_image.arch
 self.images.append(darwin_image)
 self.crashlog.images.append(darwin_image)
 
@@ -740,6 +750,13 @@
 gpr_dict = {str(idx): reg for idx, reg in enumerate(state)}
 registers.update(self.parse_thread_registers(gpr_dict, key))
 continue
+if key == "flavor":
+if not self.crashlog.process_arch:
+if state == "ARM_THREAD_STATE64":
+self.crashlog.process_arch = "arm64"
+elif state == "X86_THREAD_STATE":
+self.crashlog.process_arch = "x86_64"
+continue
 try:
 value = int(state["value"])
 registers["{}{}".format(prefix or "", key)] = value
@@ -912,6 +929,8 @@
 line[8:].strip().split(" [")
 )
 self.crashlog.process_id = pid_with_brackets.strip("[]")
+elif line.startswith("Path:"):
+self.crashlog.process_path = line[5:].strip()
 elif line.startswith("Identifier:"):
 self.crashlog.process_identifier = line[11:].strip()
 elif line.startswith("Version:"):
@@ -923,6 +942,11 @@
 else:
 self.crashlog.process = version_string
 self.crashlog.process_compatability_version = version_string
+elif line.startswith("Code Type:"):
+if "ARM-64" in line:
+self.crashlog.process_arch = "arm64"
+elif "X86-64" in line:
+self.crashlog.process_arch = "x86_64"
 elif self.parent_process_regex.search(line):
 parent_process_match = self.parent_process_regex.search(line)
 self.crashlog.parent_process_name = parent_process_match.group(1)
@@ -1343,9 +1367,12 @@
 # 2. If the user didn't provide a target, try to create a target using the symbolicator
 if not target or not target.IsValid():
 target = crashlog.create_target()
-# 3. If that didn't work, and a target is already loaded, use it
-if (target is None or not target.IsValid()) and debugger.GetNumTargets() > 0:
-target = debugger.GetTargetAtIndex(0)
+# 3. If that didn't work, create a dummy target
+if target is None or not target.IsValid():
+arch = crashlog.process_arch
+if not arch:
+raise

[Lldb-commits] [PATCH] D151849: [lldb/crashlog] Create interactive crashlog with no binary

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

LGTM modulo typo




Comment at: lldb/examples/python/crashlog.py:1374
+if not arch:
+raise InteractiveCrashLogException("couldn't create find the 
architecture to create the target")
+target = debugger.CreateTargetWithFileAndArch(None, arch)

Typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151849

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


[Lldb-commits] [lldb] 0b08026 - [lldb/crashlog] Run python formatter (nfc)

2023-06-01 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-06-01T17:13:16-07:00
New Revision: 0b080260541dc7942500092b300aee6901647056

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

LOG: [lldb/crashlog] Run python formatter (nfc)

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 9978c70d0bfd..8f7bde3429b8 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1371,7 +1371,9 @@ def load_crashlog_in_scripted_process(debugger, 
crash_log_file, options, result)
 if target is None or not target.IsValid():
 arch = crashlog.process_arch
 if not arch:
-raise InteractiveCrashLogException("couldn't create find the 
architecture to create the target")
+raise InteractiveCrashLogException(
+"couldn't create find the architecture to create the target"
+)
 target = debugger.CreateTargetWithFileAndArch(None, arch)
 # 4. Fail
 if target is None or not target.IsValid():



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


[Lldb-commits] [lldb] 78ecb42 - [lldb/crashlog] Add test for non-symbolicated report crash

2023-06-01 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-06-01T17:50:55-07:00
New Revision: 78ecb428d564d618d785a85743528c2f14397bbf

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

LOG: [lldb/crashlog] Add test for non-symbolicated report crash

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.ips

Removed: 




diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.ips
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.ips
index 23ce9d06886af..b5fbe74c7bf9f 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.ips
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.ips
@@ -279,7 +279,7 @@
   "sourceFile": "thread",
   "sourceLine": 298,
   "symbol": "void* 
std::__1::__thread_proxy >, void (*)(int&), 
std::__1::reference_wrapper > >(void*)",
-  "symbolLocation": 84
+  "symbolLocation": null
 },
 {
   "imageIndex": 1,



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


[Lldb-commits] [PATCH] D151960: [lldb][NFCI] Change the way Process stores StructuredData plugins

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: jingham, mib, jasonmolenda.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Instead of having a map from ConstString to StructuredDataPluginSP, we
can use an llvm::StringMap. The keys themselves don't need to be
ConstStrings, so an llvm::StringMap feels most natural.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151960

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -4301,7 +4301,7 @@
 }
 
 StructuredDataPluginSP
-Process::GetStructuredDataPlugin(ConstString type_name) const {
+Process::GetStructuredDataPlugin(llvm::StringRef type_name) const {
   auto find_it = m_structured_data_plugin_map.find(type_name);
   if (find_it != m_structured_data_plugin_map.end())
 return find_it->second;
@@ -5782,7 +5782,7 @@
 LoadOperatingSystemPlugin(false);
 
   // Inform the structured-data plugins of the modified modules.
-  for (auto pair : m_structured_data_plugin_map) {
+  for (auto &pair : m_structured_data_plugin_map) {
 if (pair.second)
   pair.second->ModulesDidLoad(*this, module_list);
   }
@@ -5977,34 +5977,29 @@
 
   // Bail out early if there are no type names to map.
   if (supported_type_names.GetSize() == 0) {
-LLDB_LOGF(log, "Process::%s(): no structured data types supported",
-  __FUNCTION__);
+LLDB_LOG(log, "no structured data types supported");
 return;
   }
 
-  // Convert StructuredData type names to ConstString instances.
-  std::set const_type_names;
+  // These StringRefs are backed by the input parameter.
+  std::set type_names;
 
-  LLDB_LOGF(log,
-"Process::%s(): the process supports the following async "
-"structured data types:",
-__FUNCTION__);
+  LLDB_LOG(log,
+   "the process supports the following async structured data types:");
 
   supported_type_names.ForEach(
-  [&const_type_names, &log](StructuredData::Object *object) {
-if (!object) {
-  // Invalid - shouldn't be null objects in the array.
+  [&type_names, &log](StructuredData::Object *object) {
+// There shouldn't be null objects in the array.
+if (!object)
   return false;
-}
 
-auto type_name = object->GetAsString();
-if (!type_name) {
-  // Invalid format - all type names should be strings.
+// All type names should be strings.
+const llvm::StringRef type_name = object->GetStringValue();
+if (type_name.empty())
   return false;
-}
 
-const_type_names.insert(ConstString(type_name->GetValue()));
-LLDB_LOG(log, "- {0}", type_name->GetValue());
+type_names.insert(type_name);
+LLDB_LOG(log, "- {0}", type_name);
 return true;
   });
 
@@ -6013,10 +6008,10 @@
   // we've consumed all the type names.
   // FIXME: should we return an error if there are type names nobody
   // supports?
-  for (uint32_t plugin_index = 0; !const_type_names.empty(); plugin_index++) {
+  for (uint32_t plugin_index = 0; !type_names.empty(); plugin_index++) {
 auto create_instance =
-   PluginManager::GetStructuredDataPluginCreateCallbackAtIndex(
-   plugin_index);
+PluginManager::GetStructuredDataPluginCreateCallbackAtIndex(
+plugin_index);
 if (!create_instance)
   break;
 
@@ -6029,9 +6024,9 @@
 }
 
 // For any of the remaining type names, map any that this plugin supports.
-std::vector names_to_remove;
-for (auto &type_name : const_type_names) {
-  if (plugin_sp->SupportsStructuredDataType(type_name)) {
+std::vector names_to_remove;
+for (llvm::StringRef type_name : type_names) {
+  if (plugin_sp->SupportsStructuredDataType(ConstString(type_name))) {
 m_structured_data_plugin_map.insert(
 std::make_pair(type_name, plugin_sp));
 names_to_remove.push_back(type_name);
@@ -6041,8 +6036,8 @@
 }
 
 // Remove the type names that were consumed by this plugin.
-for (auto &type_name : names_to_remove)
-  const_type_names.erase(type_name);
+for (llvm::StringRef type_name : names_to_remove)
+  type_names.erase(type_name);
   }
 }
 
@@ -6059,7 +6054,7 @@
 return false;
 
   // Grab the async structured type name (i.e. the feature/plugin name).
-  ConstString type_name;
+  llvm::StringRef type_name;
   if (!dictionary->GetValueForKeyAsString("type", type_name))
 return false;
 
@@ -6071,7 +6066,8 @@
   }
 
   // Route the structured data to the plugin.
-  find_it->second->HandleArrivalOfStructuredData(*this, type_name, object_sp);
+  find_it->second->HandleArrivalOfStructuredData(*this, ConstString(type_n

[Lldb-commits] [PATCH] D151962: [lldb][NFCI] Change return type of REPL::GetSourceFileBasename

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: wallace, jingham, mib.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

These don't really need to be in the ConstString StringPool. I've
changed the return type to StringRef because on llvm.org and downstream
in the swift fork, this returns a constant value. We could change it to
return a std::string or something else if it needs to be able to change
between calls.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151962

Files:
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/REPL.cpp
  lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
  lldb/source/Plugins/REPL/Clang/ClangREPL.h


Index: lldb/source/Plugins/REPL/Clang/ClangREPL.h
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.h
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.h
@@ -36,7 +36,7 @@
 protected:
   Status DoInitialization() override;
 
-  ConstString GetSourceFileBasename() override;
+  llvm::StringRef GetSourceFileBasename() override;
 
   const char *GetAutoIndentCharacters() override;
 
Index: lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
@@ -62,8 +62,9 @@
 
 Status ClangREPL::DoInitialization() { return Status(); }
 
-ConstString ClangREPL::GetSourceFileBasename() {
-  return ConstString("repl.c");
+llvm::StringRef ClangREPL::GetSourceFileBasename() {
+  static constexpr llvm::StringLiteral g_repl("repl.c");
+  return g_repl;
 }
 
 const char *ClangREPL::GetAutoIndentCharacters() { return "  "; }
Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -57,14 +57,14 @@
 }
 
 std::string REPL::GetSourcePath() {
-  ConstString file_basename = GetSourceFileBasename();
+  llvm::StringRef file_basename = GetSourceFileBasename();
   FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir();
   if (tmpdir_file_spec) {
 tmpdir_file_spec.SetFilename(file_basename);
 m_repl_source_path = tmpdir_file_spec.GetPath();
   } else {
 tmpdir_file_spec = FileSpec("/tmp");
-tmpdir_file_spec.AppendPathComponent(file_basename.GetStringRef());
+tmpdir_file_spec.AppendPathComponent(file_basename);
   }
 
   return tmpdir_file_spec.GetPath();
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -131,7 +131,7 @@
 
   virtual Status DoInitialization() = 0;
 
-  virtual ConstString GetSourceFileBasename() = 0;
+  virtual llvm::StringRef GetSourceFileBasename() = 0;
 
   virtual const char *GetAutoIndentCharacters() = 0;
 


Index: lldb/source/Plugins/REPL/Clang/ClangREPL.h
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.h
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.h
@@ -36,7 +36,7 @@
 protected:
   Status DoInitialization() override;
 
-  ConstString GetSourceFileBasename() override;
+  llvm::StringRef GetSourceFileBasename() override;
 
   const char *GetAutoIndentCharacters() override;
 
Index: lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
===
--- lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
+++ lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
@@ -62,8 +62,9 @@
 
 Status ClangREPL::DoInitialization() { return Status(); }
 
-ConstString ClangREPL::GetSourceFileBasename() {
-  return ConstString("repl.c");
+llvm::StringRef ClangREPL::GetSourceFileBasename() {
+  static constexpr llvm::StringLiteral g_repl("repl.c");
+  return g_repl;
 }
 
 const char *ClangREPL::GetAutoIndentCharacters() { return "  "; }
Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -57,14 +57,14 @@
 }
 
 std::string REPL::GetSourcePath() {
-  ConstString file_basename = GetSourceFileBasename();
+  llvm::StringRef file_basename = GetSourceFileBasename();
   FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir();
   if (tmpdir_file_spec) {
 tmpdir_file_spec.SetFilename(file_basename);
 m_repl_source_path = tmpdir_file_spec.GetPath();
   } else {
 tmpdir_file_spec = FileSpec("/tmp");
-tmpdir_file_spec.AppendPathComponent(file_basename.GetStringRef());
+tmpdir_file_spec.AppendPathComponent(file_basename);
   }
 
   return tmpdir_file_spec.GetPath();
Index: lldb/include/lldb/Expression/REPL.h
===
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@

[Lldb-commits] [PATCH] D151962: [lldb][NFCI] Change return type of REPL::GetSourceFileBasename

2023-06-01 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

LGTM. It also works with the mojo REPL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151962

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


[Lldb-commits] [lldb] df1bb2e - Restrict the test from 22667e3220de5ead353a2148265d841644b63824

2023-06-01 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2023-06-01T18:45:45-07:00
New Revision: df1bb2e65bf4b2ca1140f4c9d19ff2a36ab94e6e

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

LOG: Restrict the test from 22667e3220de5ead353a2148265d841644b63824

I fixed some long-standing failures in SBTarget::FindGlobalVariables
but the fix is in the the accelerator table lookups.  I fixed it in
the DWARF mappable tables but not everyone uses those, so I had to
restrict the test to systems I know did.

Added: 


Modified: 
lldb/test/API/lang/cpp/class_static/TestStaticVariables.py

Removed: 




diff  --git a/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py 
b/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
index 6fd4a8c9b301..c7e38feeb13c 100644
--- a/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
+++ b/lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
@@ -128,7 +128,7 @@ def build_value_check(self, var_name, values):
 )
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 @add_test_categories(["pyapi"])
-def test_with_python_api(self):
+def test_with_python_FindValue(self):
 """Test Python APIs on file and class static variables."""
 self.build()
 exe = self.getBuildArtifact("a.out")
@@ -194,6 +194,44 @@ def test_with_python_api(self):
 self.DebugSBValue(val)
 self.assertEqual(val.GetName(), "hello_world")
 
+# This test tests behavior that's been broken for a very long time..
+# The fix for it is in the accelerator table part of the DWARF reader,
+# and I fixed the version that the names accelerator uses, but I don't
+# know how to fix it on systems that don't use that. There isn't a
+# decorator for that - not sure how to construct that so I'm limiting the
+# test do Darwin for now.
+@expectedFailureAll(
+compiler=["gcc"], bugnumber="Compiler emits incomplete debug info"
+)
+@skipUnlessDarwin
+@add_test_categories(["pyapi"])
+def test_with_python_FindGlobalVariables(self):
+"""Test Python APIs on file and class static variables."""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
+self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+# Now launch the process, and do not stop at entry point.
+process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# The stop reason of the thread should be breakpoint.
+thread = lldbutil.get_stopped_thread(process, 
lldb.eStopReasonBreakpoint)
+self.assertIsNotNone(thread)
+
+# Get the SBValue of 'A::g_points' and 'g_points'.
+frame = thread.GetFrameAtIndex(0)
+
+# Build ValueCheckers for the values we're going to find:
+value_check_A = self.build_value_check("A::g_points", ["1", "2", "11", 
"22"])
+value_check_none = self.build_value_check("g_points", ["3", "4", "33", 
"44"])
+value_check_AA = self.build_value_check("AA::g_points", ["5", "6", 
"55", "66"])
+
 # We should also be able to get class statics from FindGlobalVariables.
 # eMatchTypeStartsWith should only find A:: not AA::
 val_list = target.FindGlobalVariables("A::", 10, 
lldb.eMatchTypeStartsWith)
@@ -227,3 +265,4 @@ def test_with_python_api(self):
 # between file statics and globals:
 val_list = target.FindGlobalVariables("g_points", 10, 
lldb.eMatchTypeNormal)
 self.assertEqual(val_list.GetSize(), 3, "Found all three g_points")
+



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


[Lldb-commits] [PATCH] D151811: [lldb] Take StringRef name in GetIndexOfChildWithName (NFC)

2023-06-01 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Core/ValueObjectSyntheticFilter.cpp:338
   if (!did_find && m_synth_filter_up != nullptr) {
 uint32_t index = m_synth_filter_up->GetIndexOfChildWithName(name);
 if (index == UINT32_MAX)

Michael137 wrote:
> Could pass name_ref directly now, instead of doing the implicit conversion
This is a different `GetIndexOfChildWithName`, in the 
`SyntheticChildrenFrontEnd` class. It still takes a `ConstString`, changing it 
is a follow up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151811

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


[Lldb-commits] [lldb] 5dae706 - [lldb] Take StringRef name in GetIndexOfChildWithName (NFC)

2023-06-01 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-06-01T20:24:01-07:00
New Revision: 5dae706259da2ef8d51439e29a8764461da63cf7

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

LOG: [lldb] Take StringRef name in GetIndexOfChildWithName (NFC)

As with D151615, which changed `GetIndexOfChildMemberWithName` to take a 
`StringRef`
instead of a `ConstString`, this change does the same for 
`GetIndexOfChildWithName`.

Differential Revision: https://reviews.llvm.org/D151811

Added: 


Modified: 
lldb/include/lldb/Core/ValueObject.h
lldb/include/lldb/Core/ValueObjectRegister.h
lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBValue.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectRegister.cpp
lldb/source/Core/ValueObjectSyntheticFilter.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index 00fdb87c79279..e422deeab0142 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -490,7 +490,7 @@ class ValueObject {
   virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
  bool can_create);
 
-  virtual size_t GetIndexOfChildWithName(ConstString name);
+  virtual size_t GetIndexOfChildWithName(llvm::StringRef name);
 
   size_t GetNumChildren(uint32_t max = UINT32_MAX);
 

diff  --git a/lldb/include/lldb/Core/ValueObjectRegister.h 
b/lldb/include/lldb/Core/ValueObjectRegister.h
index 96e8b3067efb4..9859b9e8d645f 100644
--- a/lldb/include/lldb/Core/ValueObjectRegister.h
+++ b/lldb/include/lldb/Core/ValueObjectRegister.h
@@ -55,7 +55,7 @@ class ValueObjectRegisterSet : public ValueObject {
   lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
  bool can_create) override;
 
-  size_t GetIndexOfChildWithName(ConstString name) override;
+  size_t GetIndexOfChildWithName(llvm::StringRef name) override;
 
 protected:
   bool UpdateValue() override;

diff  --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h 
b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
index a65e7eb1b8081..8e20e05c27522 100644
--- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -56,7 +56,7 @@ class ValueObjectSynthetic : public ValueObject {
   lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
  bool can_create) override;
 
-  size_t GetIndexOfChildWithName(ConstString name) override;
+  size_t GetIndexOfChildWithName(llvm::StringRef name) override;
 
   lldb::ValueObjectSP
   GetDynamicValue(lldb::DynamicValueType valueType) override;

diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index ba75eb9abd4b3..1d2244297cb0a 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -387,7 +387,7 @@ class CompilerType {
 
   /// Lookup a child given a name. This function will match base class names 
and
   /// member member names in "clang_type" only, not descendants.
-  uint32_t GetIndexOfChildWithName(const char *name,
+  uint32_t GetIndexOfChildWithName(llvm::StringRef name,
bool omit_empty_base_classes) const;
 
   /// Lookup a child member given a name. This function will match member names

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 21e5915fab0ce..7b5be3aabaf58 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -348,7 +348,7 @@ class TypeSystem : public PluginInterface,
   // Lookup a child given a name. This function will match base class names and
   // member member names in "clang_type" only, not descendants.
   virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
-   const char *name,
+   llvm::StringRef name,
bool omit_empty_base_classes) = 0;
 
   // Lookup a child member given a name. This function will match member names

diff  --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 573ee3a82fa03..aee9e86fdde12 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -687,7 +687,7 @@ uint32_t SBValue::GetIndexOfChildWithN

[Lldb-commits] [PATCH] D151811: [lldb] Take StringRef name in GetIndexOfChildWithName (NFC)

2023-06-01 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5dae706259da: [lldb] Take StringRef name in 
GetIndexOfChildWithName (NFC) (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151811

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/include/lldb/Core/ValueObjectRegister.h
  lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBValue.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectRegister.cpp
  lldb/source/Core/ValueObjectSyntheticFilter.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp

Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -810,12 +810,12 @@
 // matches can include base class names.
 
 uint32_t
-CompilerType::GetIndexOfChildWithName(const char *name,
+CompilerType::GetIndexOfChildWithName(llvm::StringRef name,
   bool omit_empty_base_classes) const {
-  if (IsValid() && name && name[0]) {
+  if (IsValid() && !name.empty()) {
 if (auto type_system_sp = GetTypeSystem())
   return type_system_sp->GetIndexOfChildWithName(m_type, name,
-  omit_empty_base_classes);
+ omit_empty_base_classes);
   }
   return UINT32_MAX;
 }
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -877,7 +877,7 @@
   // Lookup a child given a name. This function will match base class names and
   // member member names in "clang_type" only, not descendants.
   uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
-   const char *name,
+   llvm::StringRef name,
bool omit_empty_base_classes) override;
 
   // Lookup a child member given a name. This function will match member names
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6966,9 +6966,9 @@
 
 uint32_t
 TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
- const char *name,
+ llvm::StringRef name,
  bool omit_empty_base_classes) {
-  if (type && name && name[0]) {
+  if (type && !name.empty()) {
 clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
 
 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -7013,11 +7013,10 @@
 
 // Try and find a field that matches NAME
 clang::RecordDecl::field_iterator field, field_end;
-llvm::StringRef name_sref(name);
 for (field = record_decl->field_begin(),
 field_end = record_decl->field_end();
  field != field_end; ++field, ++child_idx) {
-  if (field->getName().equals(name_sref))
+  if (field->getName().equals(name))
 return child_idx;
 }
   }
@@ -7026,7 +7025,6 @@
 case clang::Type::ObjCObject:
 case clang::Type::ObjCInterface:
   if (GetCompleteType(type)) {
-llvm::StringRef name_sref(name);
 const clang::ObjCObjectType *objc_class_type =
 llvm::dyn_cast(qual_type.getTypePtr());
 assert(objc_class_type);
@@ -7045,7 +7043,7 @@
  ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
   const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
 
-  if (ivar_decl->getName().equals(name_sref)) {
+  if (ivar_decl->getName().equals(name)) {
 if ((!omit_empty_base_classes && superclass_interface_decl) ||
 (omit_empty_base_classes &&
  ObjCDeclHasIVars(superclass_interface_decl, true)))
@@ -7056,7 +7054,7 @@
 }
 
 if (superclass_interface_decl) {
-  if (superclass_interface_decl->getName().equals(name_sref))
+  if (superclass_interface_decl->getName().equals(name))
 return 0;
 }
   }
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
=

[Lldb-commits] [PATCH] D151813: [lldb] Take StringRef names in GetChildAtNamePath (NFC)

2023-06-01 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 527715.
kastiglione added a comment.

Change auto to StringRef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151813

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp

Index: lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -437,9 +437,8 @@
   if (!ptr_sp)
 return false;
 
-  ValueObjectSP usecount_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("_M_refcount"), ConstString("_M_pi"),
-   ConstString("_M_use_count")}));
+  ValueObjectSP usecount_sp(
+  valobj_sp->GetChildAtNamePath({"_M_refcount", "_M_pi", "_M_use_count"}));
   if (!usecount_sp)
 return false;
 
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -112,8 +112,7 @@
 ValueObjectSP hash_sp = node_sp->GetChildMemberWithName("__hash_", true);
 if (!hash_sp || !value_sp) {
   if (!m_element_type) {
-auto p1_sp = m_backend.GetChildAtNamePath({ConstString("__table_"),
-   ConstString("__p1_")});
+auto p1_sp = m_backend.GetChildAtNamePath({"__table_", "__p1_"});
 if (!p1_sp)
   return nullptr;
 
@@ -199,21 +198,19 @@
 
   ValueObjectSP p2_sp = table_sp->GetChildMemberWithName("__p2_", true);
   ValueObjectSP num_elements_sp = nullptr;
-  llvm::SmallVector next_path;
+  llvm::SmallVector next_path;
   switch (p2_sp->GetCompilerType().GetNumDirectBaseClasses()) {
   case 1:
 // Assume a pre llvm r300140 __compressed_pair implementation:
 num_elements_sp = p2_sp->GetChildMemberWithName("__first_", true);
-next_path.append({ConstString("__p1_"), ConstString("__first_"),
-  ConstString("__next_")});
+next_path.append({"__p1_", "__first_", "__next_"});
 break;
   case 2: {
 // Assume a post llvm r300140 __compressed_pair implementation:
 ValueObjectSP first_elem_parent = p2_sp->GetChildAtIndex(0, true);
 num_elements_sp =
 first_elem_parent->GetChildMemberWithName("__value_", true);
-next_path.append({ConstString("__p1_"), ConstString("__value_"),
-  ConstString("__next_")});
+next_path.append({"__p1_", "__value_", "__next_"});
 break;
   }
   default:
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -241,9 +241,6 @@
 }
 
 bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
-  static ConstString g_tree_("__tree_");
-  static ConstString g_pair3("__pair3_");
-
   if (m_element_type.IsValid())
 return true;
   m_element_type.Clear();
@@ -257,7 +254,7 @@
 m_element_type = deref->GetCompilerType();
 return true;
   }
-  deref = m_backend.GetChildAtNamePath({g_tree_, g_pair3});
+  deref = m_backend.GetChildAtNamePath({"__tree_", "__pair3_"});
   if (!deref)
 return false;
   m_element_type = deref->GetCompilerType()
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -153,10 +153,10 @@
   if (!valobj_sp)
 return false;
   ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_", true));
-  ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("__cntrl_"), ConstString("__shared_owners_")}));
-  ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("__cntrl_"), ConstString("__shared_weak_owners_")}));
+  ValueObjectSP count_sp(
+  valobj_sp->GetChildAtNamePath({"__cntrl_", "__shared_owners_"}));
+  ValueObjectSP weakcount_sp(
+  valobj_sp->GetChildAtNamePath({"__cntrl_", "__shared_weak_owners_"}));
 
   if (!ptr_sp)
 return false;
@@ -810,8 +810,7 @@
 return {};
 
   ValueObjectSP is_long = short_sp->GetChildMemberWithName("__is_long_", true);
-  ValueObjectSP size_sp =
-  short_sp->GetChildAtNamePath({ConstString("__size_")});
+  ValueObjectSP size_sp = short_sp->GetChildMemberWithName("__size_", true);
   if (!size_sp)
 return {};
 
Index: lldb/source/Core/ValueObject.cpp

[Lldb-commits] [lldb] 00e52cc - [lldb] Take StringRef names in GetChildAtNamePath (NFC)

2023-06-01 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-06-01T20:42:29-07:00
New Revision: 00e52cc4a8cc06cfafe787caea686810ac6c37ac

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

LOG: [lldb] Take StringRef names in GetChildAtNamePath (NFC)

Following D151810, this changes `GetChildAtNamePath` to take a path of 
`StringRef`
values instead of `ConstString`.

Differential Revision: https://reviews.llvm.org/D151813

Added: 


Modified: 
lldb/include/lldb/Core/ValueObject.h
lldb/source/Core/ValueObject.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index e422deeab0142..9f7bdf61e402b 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -480,8 +480,7 @@ class ValueObject {
   size_t *index_of_error = nullptr);
 
   // this will always create the children if necessary
-  lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef names,
- ConstString *name_of_error = nullptr);
+  lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef 
names);
 
   lldb::ValueObjectSP
   GetChildAtNamePath(llvm::ArrayRef> names,

diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index 2a11d9724a226..1e18210a72379 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -427,16 +427,13 @@ lldb::ValueObjectSP ValueObject::GetChildAtIndexPath(
 }
 
 lldb::ValueObjectSP
-ValueObject::GetChildAtNamePath(llvm::ArrayRef names,
-ConstString *name_of_error) {
+ValueObject::GetChildAtNamePath(llvm::ArrayRef names) {
   if (names.size() == 0)
 return GetSP();
   ValueObjectSP root(GetSP());
-  for (ConstString name : names) {
+  for (llvm::StringRef name : names) {
 root = root->GetChildMemberWithName(name, true);
 if (!root) {
-  if (name_of_error)
-*name_of_error = name;
   return root;
 }
   }

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 127ce07f2ff35..16f3688303f75 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -153,10 +153,10 @@ bool 
lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
   if (!valobj_sp)
 return false;
   ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_", true));
-  ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("__cntrl_"), ConstString("__shared_owners_")}));
-  ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("__cntrl_"), ConstString("__shared_weak_owners_")}));
+  ValueObjectSP count_sp(
+  valobj_sp->GetChildAtNamePath({"__cntrl_", "__shared_owners_"}));
+  ValueObjectSP weakcount_sp(
+  valobj_sp->GetChildAtNamePath({"__cntrl_", "__shared_weak_owners_"}));
 
   if (!ptr_sp)
 return false;
@@ -810,8 +810,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
 return {};
 
   ValueObjectSP is_long = short_sp->GetChildMemberWithName("__is_long_", true);
-  ValueObjectSP size_sp =
-  short_sp->GetChildAtNamePath({ConstString("__size_")});
+  ValueObjectSP size_sp = short_sp->GetChildMemberWithName("__size_", true);
   if (!size_sp)
 return {};
 

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index 6a29abee8181d..deaa25deb8856 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -241,9 +241,6 @@ size_t 
lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
 }
 
 bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
-  static ConstString g_tree_("__tree_");
-  static ConstString g_pair3("__pair3_");
-
   if (m_element_type.IsValid())
 return true;
   m_element_type.Clear();
@@ -257,7 +254,7 @@ bool 
lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
 m_element_type = deref->GetCompilerType();
 return true;
   }
-  deref = m_backend.GetChildAtNamePath({g_tree_, g_pair3});
+  deref = m_backend.GetChildAtNamePath({"__tree_", "__pair3_"});
   if (!deref)
 return false;
   m_element_type = deref->GetCompilerType()

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index d681b7066efcf..a4c632cb6 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Li

[Lldb-commits] [PATCH] D151813: [lldb] Take StringRef names in GetChildAtNamePath (NFC)

2023-06-01 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG00e52cc4a8cc: [lldb] Take StringRef names in 
GetChildAtNamePath (NFC) (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151813

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp

Index: lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -437,9 +437,8 @@
   if (!ptr_sp)
 return false;
 
-  ValueObjectSP usecount_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("_M_refcount"), ConstString("_M_pi"),
-   ConstString("_M_use_count")}));
+  ValueObjectSP usecount_sp(
+  valobj_sp->GetChildAtNamePath({"_M_refcount", "_M_pi", "_M_use_count"}));
   if (!usecount_sp)
 return false;
 
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -112,8 +112,7 @@
 ValueObjectSP hash_sp = node_sp->GetChildMemberWithName("__hash_", true);
 if (!hash_sp || !value_sp) {
   if (!m_element_type) {
-auto p1_sp = m_backend.GetChildAtNamePath({ConstString("__table_"),
-   ConstString("__p1_")});
+auto p1_sp = m_backend.GetChildAtNamePath({"__table_", "__p1_"});
 if (!p1_sp)
   return nullptr;
 
@@ -199,21 +198,19 @@
 
   ValueObjectSP p2_sp = table_sp->GetChildMemberWithName("__p2_", true);
   ValueObjectSP num_elements_sp = nullptr;
-  llvm::SmallVector next_path;
+  llvm::SmallVector next_path;
   switch (p2_sp->GetCompilerType().GetNumDirectBaseClasses()) {
   case 1:
 // Assume a pre llvm r300140 __compressed_pair implementation:
 num_elements_sp = p2_sp->GetChildMemberWithName("__first_", true);
-next_path.append({ConstString("__p1_"), ConstString("__first_"),
-  ConstString("__next_")});
+next_path.append({"__p1_", "__first_", "__next_"});
 break;
   case 2: {
 // Assume a post llvm r300140 __compressed_pair implementation:
 ValueObjectSP first_elem_parent = p2_sp->GetChildAtIndex(0, true);
 num_elements_sp =
 first_elem_parent->GetChildMemberWithName("__value_", true);
-next_path.append({ConstString("__p1_"), ConstString("__value_"),
-  ConstString("__next_")});
+next_path.append({"__p1_", "__value_", "__next_"});
 break;
   }
   default:
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -241,9 +241,6 @@
 }
 
 bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
-  static ConstString g_tree_("__tree_");
-  static ConstString g_pair3("__pair3_");
-
   if (m_element_type.IsValid())
 return true;
   m_element_type.Clear();
@@ -257,7 +254,7 @@
 m_element_type = deref->GetCompilerType();
 return true;
   }
-  deref = m_backend.GetChildAtNamePath({g_tree_, g_pair3});
+  deref = m_backend.GetChildAtNamePath({"__tree_", "__pair3_"});
   if (!deref)
 return false;
   m_element_type = deref->GetCompilerType()
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -153,10 +153,10 @@
   if (!valobj_sp)
 return false;
   ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_", true));
-  ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("__cntrl_"), ConstString("__shared_owners_")}));
-  ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
-  {ConstString("__cntrl_"), ConstString("__shared_weak_owners_")}));
+  ValueObjectSP count_sp(
+  valobj_sp->GetChildAtNamePath({"__cntrl_", "__shared_owners_"}));
+  ValueObjectSP weakcount_sp(
+  valobj_sp->GetChildAtNamePath({"__cntrl_", "__shared_weak_owners_"}));
 
   if (!ptr_sp)
 return false;
@@ -810,8 +810,7 @@
 return {};
 
   ValueObjectSP is_long = short_sp->GetChildMemberWithName("__is_long_", true);
-  ValueObjectSP size_sp =
-  short_sp->GetChildAtNamePath({ConstString("__size_")});
+  ValueObjectSP size_sp = short_sp->GetChildMemberWithName("__size_", true);
   if 

[Lldb-commits] [PATCH] D151966: [lldb] Default can_create to true in GetChildMemberWithName (NFC)

2023-06-01 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: jingham, bulbazord.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

It turns out all existing callers of `GetChildMemberWithName` pass true for 
`can_create`.
This change makes `true` the default value, callers don't have to pass an 
opaque true.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151966

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/include/lldb/Core/ValueObjectRegister.h
  lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
  lldb/source/API/SBValue.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionUtil.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  lldb/source/Target/StackFrame.cpp

Index: lldb/source/Target/StackFrame.cpp
===
--- lldb/source/Target/StackFrame.cpp
+++ lldb/source/Target/StackFrame.cpp
@@ -604,7 +604,7 @@
   valobj_sp = GetValueObjectForFrameVariable(variable_sp, use_dynamic);
   if (!valobj_sp)
 return valobj_sp;
-  valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string, true);
+  valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string);
   if (valobj_sp)
 break;
 }
@@ -705,13 +705,13 @@
   return ValueObjectSP();
 }
   }
-  child_valobj_sp = valobj_sp->GetChildMemberWithName(child_name, true);
+  child_valobj_sp = valobj_sp->GetChildMemberWithName(child_name);
   if (!child_valobj_sp) {
 if (!no_synth_child) {
   child_valobj_sp = valobj_sp->GetSyntheticValue();
   if (child_valobj_sp)
 child_valobj_sp =
-child_valobj_sp->GetChildMemberWithName(child_name, true);
+child_valobj_sp->GetChildMemberWithName(child_name);
 }
 
 if (no_synth_child || !child_valobj_sp) {
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -514,7 +514,7 @@
 ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 lldb::ValueObjectSP exception_sp) {
   ValueObjectSP reserved_dict =
-  exception_sp->GetChildMemberWithName("reserved", true);
+  exception_sp->GetChildMemberWithName("reserved");
   if (!reserved_dict)
 return FailExceptionParsing("Failed to get 'reserved' member.");
 
@@ -567,15 +567,15 @@
 
   if (!return_addresses)
 return FailExceptionParsing("Failed to get return addresses.");
-  auto frames_value = return_addresses->GetChildMemberWithName("_frames", true);
+  auto frames_value = return_addresses->GetChildMemberWithName("_frames");
   if (!frames_value)
 return FailExceptionParsing("Failed to get frames_value.");
   addr_t frames_addr = frames_value->GetValueAsUnsigned(0);
-  auto count_value = return_addresses->GetChildMemberWithName("_cnt", true);
+  auto count_value = return_addresses->GetChildMemberWithName("_cnt");
   if (!count_value)
 return FailExceptionParsing("Failed to get count_value.");
   size_t count = count_value->GetValueAsUnsigned(0);
-  auto ignore_value = return_addresses->GetChildMemberWithName("_ignore", true);
+  auto ignore_value = return_addresses->GetChildMemberWithName("_ignore");
   if (!ignore_value)
 return FailExceptionParsing("Failed to get ignore_value.");
   size_t ignore = ignore_value->GetValueAsUnsigned(0);
Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
===
--- lldb/sourc

[Lldb-commits] [PATCH] D151003: [Damangle] convert dlangDemangle to use std::string_view

2023-06-01 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: llvm/lib/Demangle/Demangle.cpp:49
 bool llvm::nonMicrosoftDemangle(const char *MangledName, std::string &Result) {
+  if (!MangledName)
+return false;

Why is this change? The original contract is that `MangledName` must be 
non-null.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151003

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


[Lldb-commits] [PATCH] D151966: [lldb] Default can_create to true in GetChildMemberWithName (NFC)

2023-06-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

If every caller sets this to true, why not remove the argument altogether? It 
looks like `ValueObjectRegister::GetChildMemberWithName` doesn't use the 
argument, `ValueObject::GetChildMemberWithName` and 
`ValueObjectSynthetic::GetChildMemberWithName` just pass it along to 
`GetChildAtIndex`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151966

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


Re: [Lldb-commits] [PATCH] D151966: [lldb] Default can_create to true in GetChildMemberWithName (NFC)

2023-06-01 Thread Dave Lee via lldb-commits
That's an option too, which I considered. I went with this as a more
conservative change. If there's agreement to remove it then I can change it.

On Thursday, June 1, 2023, Alex Langford via Phabricator <
revi...@reviews.llvm.org> wrote:

> bulbazord added a comment.
>
> If every caller sets this to true, why not remove the argument altogether?
> It looks like `ValueObjectRegister::GetChildMemberWithName` doesn't use
> the argument, `ValueObject::GetChildMemberWithName` and
> `ValueObjectSynthetic::GetChildMemberWithName` just pass it along to
> `GetChildAtIndex`.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D151966/new/
>
> https://reviews.llvm.org/D151966
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits