[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-01 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

@jwnhy Let me know which name and email I should attribute the patch to


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

https://reviews.llvm.org/D147370

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


[Lldb-commits] [lldb] c46d9af - Revert "Host: generalise `GetXcodeSDKPath`"

2023-05-01 Thread Douglas Yung via lldb-commits

Author: Douglas Yung
Date: 2023-05-01T10:22:53-07:00
New Revision: c46d9af26cefb0b24646d3235b75ae7a1b8548d4

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

LOG: Revert "Host: generalise `GetXcodeSDKPath`"

This reverts commit ade3c6a6a88ed3a9b06c076406f196da9d3cc1b9.

This breaks the build with GCC and affects at least 2 build bots:
https://lab.llvm.org/buildbot/#/builders/217/builds/20568
https://lab.llvm.org/buildbot/#/builders/243/builds/5576

Added: 


Modified: 
lldb/include/lldb/Host/HostInfoBase.h
lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/source/Core/Module.cpp
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/unittests/Host/HostInfoTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/HostInfoBase.h 
b/lldb/include/lldb/Host/HostInfoBase.h
index 28f809398d5b4..42f71d91f9bf9 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -31,23 +31,6 @@ struct SharedCacheImageInfo {
   lldb::DataBufferSP data_sp;
 };
 
-namespace {
-struct HostInfoError : public llvm::ErrorInfo {
-  static char ID;
-  const std::string message_;
-
-  HostInfoError(const std::string message) : message_(std::move(message)) {}
-
-  void log(llvm::raw_ostream &OS) const override { OS << "HostInfoError"; }
-
-  std::error_code convertToErrorCode() const override {
-return llvm::inconvertibleErrorCode();
-  }
-};
-
-char HostInfoError::ID = 0;
-} // namespace
-
 class HostInfoBase {
 private:
   // Static class, unconstructable.
@@ -125,14 +108,10 @@ class HostInfoBase {
 
   static FileSpec GetXcodeContentsDirectory() { return {}; }
   static FileSpec GetXcodeDeveloperDirectory() { return {}; }
-
-  struct SDKOptions {
-std::optional XcodeSDK;
-  };
-
-  /// Return the directory containing something like a SDK (reused for Swift).
-  static llvm::Expected GetSDKRoot(SDKOptions options) {
-return llvm::make_error("cannot determine SDK root");
+  
+  /// Return the directory containing a specific Xcode SDK.
+  static llvm::Expected GetXcodeSDKPath(XcodeSDK sdk) {
+return "";
   }
 
   /// Return information about module \p image_name if it is loaded in

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h 
b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index 74d979d965a73..0402509cfa261 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -31,7 +31,7 @@ class HostInfoMacOSX : public HostInfoPosix {
   static FileSpec GetXcodeDeveloperDirectory();
 
   /// Query xcrun to find an Xcode SDK directory.
-  static llvm::Expected GetSDKRoot(SDKOptions options);
+  static llvm::Expected GetXcodeSDKPath(XcodeSDK sdk);
 
   /// Shared cache utilities
   static SharedCacheImageInfo

diff  --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 6293cc7853f53..17d8043852ab7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1607,8 +1607,8 @@ std::optional 
Module::RemapSourceFile(llvm::StringRef path) const {
 
 void Module::RegisterXcodeSDK(llvm::StringRef sdk_name,
   llvm::StringRef sysroot) {
-  auto sdk_path_or_err =
-  HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk_name.str()});
+  XcodeSDK sdk(sdk_name.str());
+  auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(sdk);
 
   if (!sdk_path_or_err) {
 Debugger::ReportError("Error while searching for Xcode SDK: " +

diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 6569013044513..5a39ed370747a 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -338,8 +338,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   }
 }
 
-auto sdk_path_or_err =
-HostInfo::GetSDKRoot(SDKOptions{XcodeSDK::GetAnyMacOS()});
+auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS());
 if (!sdk_path_or_err) {
   Log *log = GetLog(LLDBLog::Host);
   LLDB_LOGF(log, "Error while searching for Xcode SDK: %s",
@@ -520,7 +519,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   return path;
 }
 
-llvm::Expected HostInfoMacOSX::GetSDKRoot(SDKOptions options) 
{
+llvm::Expected HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
   struct ErrorOrPath {
 std::string str;
 bool is_error;
@@ -531,11 +530,6 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   std::lock_guard guard(g_sdk_path_mutex);
   LLDB_SCOPED_TIMER();
 
-  if (!options.XcodeSDK)
-return 

[Lldb-commits] [PATCH] D149262: [lldb] Add settings for expression evaluation memory allocations.

2023-05-01 Thread Ilia Kuklin via Phabricator via lldb-commits
kuilpd updated this revision to Diff 518520.
kuilpd added a comment.

Rebased and added a test.

Instead of just getting a variable's address from allocated inside an 
expression, I decided to check for memory allocations inside logs. Exact 
variable address could change with the compilation changes, so this should be 
more reliable.


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

https://reviews.llvm.org/D149262

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Expression/IRMemoryMap.cpp
  lldb/source/Expression/LLVMUserExpression.cpp
  lldb/source/Plugins/ABI/MSP430/ABISysV_msp430.h
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/API/commands/expression/memory-allocation/Makefile
  lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
  lldb/test/API/commands/expression/memory-allocation/main.cpp

Index: lldb/test/API/commands/expression/memory-allocation/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0;
+}
Index: lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/TestMemoryAllocSettings.py
@@ -0,0 +1,35 @@
+"""
+Test changing setting for expression memory allocation.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestMemoryAllocSettings(TestBase):
+
+def test(self):
+"""Test changing settings for expression memory allocation."""
+self.build()
+target = self.createTestTarget()
+
+self.log_file = self.getBuildArtifact("log-expr.txt")
+
+self.runCmd("settings set target.expr-alloc-address 0xdead")
+self.runCmd("settings set target.expr-alloc-size 1")
+self.runCmd("settings set target.expr-alloc-align 0x1000")
+
+self.runCmd("log enable lldb expr -f " + self.log_file)
+self.runCmd("expression -- int foo; &foo")
+
+self.assertTrue(os.path.isfile(self.log_file))
+with open(self.log_file, 'r') as f:
+log = f.read()
+
+alloc0 = re.search('^.*IRMemoryMap::Malloc.+?0xdead.*$', log, re.MULTILINE)
+# Malloc adds additional bytes to allocation size, hence 10007
+alloc1 = re.search('^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$', log, re.MULTILINE)
+self.assertTrue(alloc0, "Couldn't find an allocation at a given address.")
+self.assertTrue(alloc1, "Couldn't find an allocation of a given size at a given address.")
+
Index: lldb/test/API/commands/expression/memory-allocation/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/memory-allocation/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -24,6 +24,15 @@
 DefaultUnsignedValue<5>,
 Desc<"The maximum amount of errors to emit while parsing an expression. "
  "A value of 0 means to always continue parsing if possible.">;
+  def ExprAllocAddress: Property<"expr-alloc-address", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Start address within the process address space of memory allocation for expression evaluation.">;
+  def ExprAllocSize: Property<"expr-alloc-size", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Amount of memory in bytes to allocate for expression evaluation.">;
+  def ExprAllocAlign: Property<"expr-alloc-align", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Alignment for each memory allocation for expression evaluation.">;
   def PreferDynamic: Property<"prefer-dynamic-value", "Enum">,
 DefaultEnumValue<"eDynamicDontRunTarget">,
 EnumValues<"OptionEnumValues(g_dynamic_value_types)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -4589,6 +4589,24 @@
   nullptr, idx, g_target_properties[idx].default_uint_value);
 }
 
+uint64_t TargetProperties::GetExprAllocAddress() const {
+  const uint32_t idx = ePropertyExprAllocAddress;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_target_properties[idx].default_uint_value);
+}
+
+uint64_t TargetProperties::GetExprAllocSize() const {
+  const uint32_t idx = ePropertyExprAllocSize;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_target_properties[idx].default_uint_value);
+}
+
+uint64_t TargetPropert

[Lldb-commits] [PATCH] D148662: [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

2023-05-01 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe updated this revision to Diff 518540.
jgorbe added a comment.

Addressed review comments:

- Check pair values before attempting to call `GetChildMemberWithName` on them
- Rename first child from `__value_` to `pointer`. This is friendlier and also 
matches the name used by the libstdcxx unique_ptr prettyprinter.


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

https://reviews.llvm.org/D148662

Files:
  lldb/include/lldb/DataFormatters/FormattersHelpers.h
  lldb/source/DataFormatters/FormattersHelpers.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
@@ -6,6 +6,15 @@
   std::string name = "steph";
 };
 
+// libc++ stores unique_ptr data in a compressed pair, which has a specialized
+// representation when the type of the second element is an empty class. So
+// we need a deleter class with a dummy data member to trigger the other path.
+struct NonEmptyIntDeleter {
+  void operator()(int* ptr) { delete ptr; }
+
+  int dummy_ = ;
+};
+
 int main() {
   std::unique_ptr up_empty;
   std::unique_ptr up_int = std::make_unique(10);
@@ -13,6 +22,8 @@
   std::unique_ptr &up_int_ref = up_int;
   std::unique_ptr &&up_int_ref_ref = std::make_unique(10);
   std::unique_ptr up_user = std::make_unique();
+  auto up_non_empty_deleter =
+  std::unique_ptr(new int(1234));
 
   return 0; // break here
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -40,7 +40,7 @@
 "up_empty",
 type=self.make_expected_type("int"),
 summary="nullptr",
-children=[ValueCheck(name="__value_")],
+children=[ValueCheck(name="pointer")],
 )
 self.assertEqual(
 valobj.child[0].GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS), 0
@@ -54,7 +54,7 @@
 "up_int",
 type=self.make_expected_type("int"),
 summary="10",
-children=[ValueCheck(name="__value_")],
+children=[ValueCheck(name="pointer")],
 )
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
@@ -62,7 +62,7 @@
 "up_int_ref",
 type=self.make_expected_type("int", qualifiers="&"),
 summary="10",
-children=[ValueCheck(name="__value_")],
+children=[ValueCheck(name="pointer")],
 )
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
@@ -70,7 +70,7 @@
 "up_int_ref_ref",
 type=self.make_expected_type("int", qualifiers="&&"),
 summary="10",
-children=[ValueCheck(name="__value_")],
+children=[ValueCheck(name="pointer")],
 )
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
@@ -78,7 +78,7 @@
 "up_str",
 type=self.make_expected_basic_string_ptr(),
 summary='"hello"',
-children=[ValueCheck(name="__value_", summary='"hello"')],
+children=[ValueCheck(name="pointer", summary='"hello"')],
 )
 
 valobj = self.expect_var_path(
@@ -95,7 +95,20 @@
 ValueCheck(name="name", summary='"steph"'),
 ],
 )
-self.assertEqual(str(valobj), '(User) *__value_ = (id = 30, name = "steph")')
+self.assertEqual(str(valobj), '(User) *pointer = (id = 30, name = "steph")')
+
+valobj = self.expect_var_path(
+"up_non_empty_deleter",
+type="std::unique_ptr",
+summary="1234",
+children=[
+ValueCheck(name="pointer"),
+ValueCheck(name="deleter", children=[
+ValueCheck(name="dummy_", value="")
+]),
+],
+)
+self.assertNotEqual(valobj.child[0].unsigned, 0)
 
 self.expect_var_path("up_user->id", type="int", value="30")
 self.expect_var_path("up_user->name", type="std::string", summary='"steph"')
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
===

[Lldb-commits] [PATCH] D149482: [lldb] Change ObjectValueDictionary to use a StringMap

2023-05-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord updated this revision to Diff 518542.
bulbazord added a comment.

Sort output for dumping to be deterministic (based on alphabetical order like 
previous implementation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149482

Files:
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/source/Core/Disassembler.cpp
  lldb/source/Interpreter/OptionValueDictionary.cpp
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
  lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/API/commands/settings/TestSettings.py
  lldb/unittests/Interpreter/TestOptionValue.cpp

Index: lldb/unittests/Interpreter/TestOptionValue.cpp
===
--- lldb/unittests/Interpreter/TestOptionValue.cpp
+++ lldb/unittests/Interpreter/TestOptionValue.cpp
@@ -146,12 +146,12 @@
   ASSERT_TRUE(dict_copy_ptr->OptionWasSet());
   ASSERT_EQ(dict_copy_ptr->GetNumValues(), 2U);
 
-  auto value_ptr = dict_copy_ptr->GetValueForKey(ConstString("A"));
+  auto value_ptr = dict_copy_ptr->GetValueForKey("A");
   ASSERT_TRUE(value_ptr);
   ASSERT_EQ(value_ptr->GetParent().get(), dict_copy_ptr);
   ASSERT_EQ(value_ptr->GetUInt64Value(), 1U);
 
-  value_ptr = dict_copy_ptr->GetValueForKey(ConstString("B"));
+  value_ptr = dict_copy_ptr->GetValueForKey("B");
   ASSERT_TRUE(value_ptr);
   ASSERT_EQ(value_ptr->GetParent().get(), dict_copy_ptr);
   ASSERT_EQ(value_ptr->GetUInt64Value(), 2U);
Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -60,7 +60,7 @@
 self.assertEqual(self.dbg.GetSelectedTarget().GetNumBreakpoints(), 1)
 
 def test_append_target_env_vars(self):
-"""Test that 'append target.run-args' works."""
+"""Test that 'append target.env-vars' works."""
 # Append the env-vars.
 self.runCmd('settings append target.env-vars MY_ENV_VAR=YES')
 # And add hooks to restore the settings during tearDown().
@@ -268,7 +268,7 @@
 found_env_var = True
 break
 self.assertTrue(found_env_var,
-"MY_ENV_VAR was not set in LunchInfo object")
+"MY_ENV_VAR was not set in LaunchInfo object")
 
 self.assertEqual(launch_info.GetNumArguments(), 3)
 self.assertEqual(launch_info.GetArgumentAtIndex(0), "A")
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -300,20 +300,18 @@
 if (!module_env_option) {
   // Step 2: Try with the file name in lowercase.
   auto name_lower = name.GetStringRef().lower();
-  module_env_option =
-  map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
+  module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
 }
 if (!module_env_option) {
   // Step 3: Try with the file name with ".debug" suffix stripped.
   auto name_stripped = name.GetStringRef();
   if (name_stripped.consume_back_insensitive(".debug")) {
-module_env_option = map->GetValueForKey(ConstString(name_stripped));
+module_env_option = map->GetValueForKey(name_stripped);
 if (!module_env_option) {
   // Step 4: Try with the file name in lowercase with ".debug" suffix
   // stripped.
   auto name_lower = name_stripped.lower();
-  module_env_option =
-  map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
+  module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
 }
   }
 }
Index: lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
===
--- lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -12,7 +12,6 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Utility/ArchSpec.h"
-#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/Stream.h"
 
Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -264,8 +264,7 @@
   for (int i = 0; i < num; ++i) {
  

[Lldb-commits] [lldb] d366da9 - [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

2023-05-01 Thread Jorge Gorbe Moya via lldb-commits

Author: Jorge Gorbe Moya
Date: 2023-05-01T13:08:04-07:00
New Revision: d366da97bd24ddfb91c9f260fa0aaf105d947652

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

LOG: [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

The unique_ptr prettyprinter calls `GetValueOfLibCXXCompressedPair`,
which looks for a `__value_` child. However, when the second value in
the compressed pair is not an empty class, there are two `__value_`
children because `__compressed_pair` derives twice from
`__compressed_pair_elem`, one for each member of the pair. And then the
lookup fails because it's ambiguous.

This patch makes the following changes:

- Rename `GetValueOfLibCXXCompressedPair` to
  `GetFirstValueOfLibCXXCompressedPair`, and add a similar function to
  get the second value. Put both functions in
  Plugin/Language/CPlusPlus/LibCxx.cpp because it seems inappropriate to
  have libcxx-specific helpers separate from all the libcxx-dependent
  code.

- Read the second value of the `__ptr_` pair and display a "deleter"
  child in the unique_ptr synthetic child provider, when available.

- Add a test case for the non-empty deleter case.

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

Added: 


Modified: 
lldb/include/lldb/DataFormatters/FormattersHelpers.h
lldb/source/DataFormatters/FormattersHelpers.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h 
b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index e9af6656e3d7d..a2e8521d96651 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -58,8 +58,6 @@ size_t ExtractIndexFromString(const char *item_name);
 
 Address GetArrayAddressOrPointerValue(ValueObject &valobj);
 
-lldb::ValueObjectSP GetValueOfLibCXXCompressedPair(ValueObject &pair);
-
 time_t GetOSXEpoch();
 
 struct InferiorSizedWord {

diff  --git a/lldb/source/DataFormatters/FormattersHelpers.cpp 
b/lldb/source/DataFormatters/FormattersHelpers.cpp
index 87da31769ff12..085ed3d0a2f29 100644
--- a/lldb/source/DataFormatters/FormattersHelpers.cpp
+++ b/lldb/source/DataFormatters/FormattersHelpers.cpp
@@ -126,14 +126,3 @@ 
lldb_private::formatters::GetArrayAddressOrPointerValue(ValueObject &valobj) {
 
   return data_addr;
 }
-
-lldb::ValueObjectSP
-lldb_private::formatters::GetValueOfLibCXXCompressedPair(ValueObject &pair) {
-  ValueObjectSP value =
-  pair.GetChildMemberWithName(ConstString("__value_"), true);
-  if (!value) {
-// pre-r300140 member name
-value = pair.GetChildMemberWithName(ConstString("__first_"), true);
-  }
-  return value;
-}

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index faa33ecefc2d0..236a8129eeb34 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -46,6 +46,38 @@ lldb::ValueObjectSP 
lldb_private::formatters::GetChildMemberWithName(
   return {};
 }
 
+lldb::ValueObjectSP
+lldb_private::formatters::GetFirstValueOfLibCXXCompressedPair(
+ValueObject &pair) {
+  ValueObjectSP value;
+  ValueObjectSP first_child = pair.GetChildAtIndex(0, true);
+  if (first_child)
+value = first_child->GetChildMemberWithName(ConstString("__value_"), true);
+  if (!value) {
+// pre-r300140 member name
+value = pair.GetChildMemberWithName(ConstString("__first_"), true);
+  }
+  return value;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair(
+ValueObject &pair) {
+  ValueObjectSP value;
+  if (pair.GetNumChildren() > 1) {
+ValueObjectSP second_child = pair.GetChildAtIndex(1, true);
+if (second_child) {
+  value =
+  second_child->GetChildMemberWithName(ConstString("__value_"), true);
+}
+  }
+  if (!value) {
+// pre-r300140 member name
+value = pair.GetChildMemberWithName(ConstString("__second_"), true);
+  }
+  return value;
+}
+
 bool lldb_private::formatters::LibcxxOptionalSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
   ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
@@ -170,7 +202,7 @@ bool 
lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
   if (!ptr_sp)
 return false;
 
-  ptr_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
+  ptr_sp = GetFi

[Lldb-commits] [PATCH] D148662: [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

2023-05-01 Thread Jorge Gorbe Moya 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 rGd366da97bd24: [lldb] Make the libcxx unique_ptr 
prettyprinter support custom deleters. (authored by jgorbe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148662

Files:
  lldb/include/lldb/DataFormatters/FormattersHelpers.h
  lldb/source/DataFormatters/FormattersHelpers.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
@@ -6,6 +6,15 @@
   std::string name = "steph";
 };
 
+// libc++ stores unique_ptr data in a compressed pair, which has a specialized
+// representation when the type of the second element is an empty class. So
+// we need a deleter class with a dummy data member to trigger the other path.
+struct NonEmptyIntDeleter {
+  void operator()(int* ptr) { delete ptr; }
+
+  int dummy_ = ;
+};
+
 int main() {
   std::unique_ptr up_empty;
   std::unique_ptr up_int = std::make_unique(10);
@@ -13,6 +22,8 @@
   std::unique_ptr &up_int_ref = up_int;
   std::unique_ptr &&up_int_ref_ref = std::make_unique(10);
   std::unique_ptr up_user = std::make_unique();
+  auto up_non_empty_deleter =
+  std::unique_ptr(new int(1234));
 
   return 0; // break here
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -40,7 +40,7 @@
 "up_empty",
 type=self.make_expected_type("int"),
 summary="nullptr",
-children=[ValueCheck(name="__value_")],
+children=[ValueCheck(name="pointer")],
 )
 self.assertEqual(
 valobj.child[0].GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS), 0
@@ -54,7 +54,7 @@
 "up_int",
 type=self.make_expected_type("int"),
 summary="10",
-children=[ValueCheck(name="__value_")],
+children=[ValueCheck(name="pointer")],
 )
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
@@ -62,7 +62,7 @@
 "up_int_ref",
 type=self.make_expected_type("int", qualifiers="&"),
 summary="10",
-children=[ValueCheck(name="__value_")],
+children=[ValueCheck(name="pointer")],
 )
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
@@ -70,7 +70,7 @@
 "up_int_ref_ref",
 type=self.make_expected_type("int", qualifiers="&&"),
 summary="10",
-children=[ValueCheck(name="__value_")],
+children=[ValueCheck(name="pointer")],
 )
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
@@ -78,7 +78,7 @@
 "up_str",
 type=self.make_expected_basic_string_ptr(),
 summary='"hello"',
-children=[ValueCheck(name="__value_", summary='"hello"')],
+children=[ValueCheck(name="pointer", summary='"hello"')],
 )
 
 valobj = self.expect_var_path(
@@ -95,7 +95,20 @@
 ValueCheck(name="name", summary='"steph"'),
 ],
 )
-self.assertEqual(str(valobj), '(User) *__value_ = (id = 30, name = "steph")')
+self.assertEqual(str(valobj), '(User) *pointer = (id = 30, name = "steph")')
+
+valobj = self.expect_var_path(
+"up_non_empty_deleter",
+type="std::unique_ptr",
+summary="1234",
+children=[
+ValueCheck(name="pointer"),
+ValueCheck(name="deleter", children=[
+ValueCheck(name="dummy_", value="")
+]),
+],
+)
+self.assertNotEqual(valobj.child[0].unsigned, 0)
 
 self.expect_var_path("up_user->id", type="int", value="30")
 self.expect_var_path("up_user->name", type="std::string", summary='"steph"')
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp

[Lldb-commits] [PATCH] D149565: [lldb] Add debugger.external-editor setting

2023-05-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord requested changes to this revision.
bulbazord added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/source/Host/macosx/objcxx/Host.mm:395-396
 
-  static std::optional g_app_fsref;
-  static std::string g_app_error;
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, [&]() {
-if (const char *external_editor = ::getenv("LLDB_EXTERNAL_EDITOR")) {
-  LLDB_LOG(log, "Looking for external editor: {0}", external_editor);
-
-  FSRef app_fsref;
-  CFCString editor_name(external_editor, kCFStringEncodingUTF8);
-  long app_error = ::LSFindApplicationForInfo(
-  /*inCreator=*/kLSUnknownCreator, /*inBundleID=*/NULL,
-  /*inName=*/editor_name.get(), /*outAppRef=*/&app_fsref,
-  /*outAppURL=*/NULL);
-  if (app_error == noErr) {
-g_app_fsref = app_fsref;
-  } else {
-g_app_error =
-llvm::formatv("could not find external editor \"{0}\": "
-  "LSFindApplicationForInfo returned error {1}",
-  external_editor, app_error)
-.str();
+  if (const char *lldb_external_editor = ::getenv("LLDB_EXTERNAL_EDITOR")) {
+if (!editor.empty()) {
+  if (editor != llvm::StringRef(lldb_external_editor)) {

JDevlieghere wrote:
> mib wrote:
> > Should we even check for the env variable is the user set the editor 
> > setting ?
> I asked that question in D149472  and this was Jim's suggestion: 
> https://reviews.llvm.org/D149472#inline-1443754
This is a hard error and not a warning, which I don't think is a good idea. I 
think the point of a setting here is to be able to change behavior during a 
debugging session instead of needing to start over. If these 2 values conflict, 
I would have to restart my session to unset LLDB_EXTERNAL_EDITOR to actually 
get the desired behavior.


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

https://reviews.llvm.org/D149565

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


[Lldb-commits] [PATCH] D149262: [lldb] Add settings for expression evaluation memory allocations.

2023-05-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.
This revision is now accepted and ready to land.

Thanks for adding the test. The test itself doesn't seem portable and likely 
will fail on several platforms though I'm not sure which off the top of my 
head. After landing this, please watch the buildbots and be prepared to add the 
necessary decorators to the test to skip those platforms.


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

https://reviews.llvm.org/D149262

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


[Lldb-commits] [PATCH] D149482: [lldb] Change ObjectValueDictionary to use a StringMap

2023-05-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lldb/source/Core/Disassembler.cpp:805
 
-  ConstString const_key(key.c_str());
+  llvm::StringRef key_ref(key);
   // Check value to see if it's the start of an array or dictionary.

I don't think you need this: `key` is a `std::string` that can be used 
directly. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149482

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


[Lldb-commits] [PATCH] D148662: [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

2023-05-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Looks like this broke on the Darwin incremental bot:

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/54508/

Can you please take a look and revert in the mean time?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148662

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


[Lldb-commits] [PATCH] D149565: [lldb] Add debugger.external-editor setting

2023-05-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 518558.
JDevlieghere marked 2 inline comments as done.
JDevlieghere added a comment.

Make `external-editor` setting take precedence over `LLDB_EXTRENAL_EDITOR`


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

https://reviews.llvm.org/D149565

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Host/Host.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Host/common/Host.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Thread.cpp
  lldb/test/Shell/Settings/TestExternalEditor.test

Index: lldb/test/Shell/Settings/TestExternalEditor.test
===
--- /dev/null
+++ lldb/test/Shell/Settings/TestExternalEditor.test
@@ -0,0 +1,4 @@
+REQUIRES: system-darwin
+RUN: %lldb -o 'settings set use-external-editor true' -o 'setting set external-editor foo' -o 'session save' -b 2>&1 | FileCheck %s
+RUN: LLDB_EXTERNAL_EDITOR="foo" %lldb -o 'settings set use-external-editor true' -o 'session save' -b 2>&1 | FileCheck %s
+CHECK: error: could not find external editor "foo": LSFindApplicationForInfo returned error
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -303,10 +303,12 @@
   bool already_shown = false;
   SymbolContext frame_sc(
   frame_sp->GetSymbolContext(eSymbolContextLineEntry));
-  if (GetProcess()->GetTarget().GetDebugger().GetUseExternalEditor() &&
-  frame_sc.line_entry.file && frame_sc.line_entry.line != 0) {
+  const Debugger &debugger = GetProcess()->GetTarget().GetDebugger();
+  if (debugger.GetUseExternalEditor() && frame_sc.line_entry.file &&
+  frame_sc.line_entry.line != 0) {
 if (llvm::Error e = Host::OpenFileInExternalEditor(
-frame_sc.line_entry.file, frame_sc.line_entry.line)) {
+debugger.GetExternalEditor(), frame_sc.line_entry.file,
+frame_sc.line_entry.line)) {
   LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(e),
  "OpenFileInExternalEditor failed: {0}");
 } else {
@@ -1731,6 +1733,7 @@
 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
 if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file) {
   if (llvm::Error e = Host::OpenFileInExternalEditor(
+  target->GetDebugger().GetExternalEditor(),
   frame_sc.line_entry.file, frame_sc.line_entry.line)) {
 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(e),
"OpenFileInExternalEditor failed: {0}");
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3272,7 +3272,8 @@
 const FileSpec file_spec;
 error = file->GetFileSpec(const_cast(file_spec));
 if (error.Success()) {
-  if (llvm::Error e = Host::OpenFileInExternalEditor(file_spec, 1))
+  if (llvm::Error e = Host::OpenFileInExternalEditor(
+  m_debugger.GetExternalEditor(), file_spec, 1))
 result.AppendError(llvm::toString(std::move(e)));
 }
   }
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -325,7 +325,8 @@
 
 #endif // TARGET_OS_OSX
 
-llvm::Error Host::OpenFileInExternalEditor(const FileSpec &file_spec,
+llvm::Error Host::OpenFileInExternalEditor(llvm::StringRef editor,
+   const FileSpec &file_spec,
uint32_t line_no) {
 #if !TARGET_OS_OSX
   return llvm::errorCodeToError(
@@ -391,41 +392,36 @@
   auto on_exit = llvm::make_scope_exit(
   [&]() { AEDisposeDesc(&(file_and_line_desc.descContent)); });
 
-  static std::optional g_app_fsref;
-  static std::string g_app_error;
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, [&]() {
-if (const char *external_editor = ::getenv("LLDB_EXTERNAL_EDITOR")) {
-  LLDB_LOG(log, "Looking for external editor: {0}", external_editor);
-
-  FSRef app_fsref;
-  CFCString editor_name(external_editor, kCFStringEncodingUTF8);
-  long app_error = ::LSFindApplicationForInfo(
-  /*inCreator=*/kLSUnknownCreator, /*inBundleID=*/NULL,
-  /*inName=*/editor_name.get(), /*outAppRef=*/&app_fsref,
-  /*outAppURL=*/NULL);
-  if (app_error == noErr) {
-g_app_fsref = app_fsref;
-  } else {
-g_app_error =
-llvm::formatv("could not find external editor \"{0}\": "
-  "LSFindApplicationForInfo returned error {1}

[Lldb-commits] [PATCH] D149565: [lldb] Add debugger.external-editor setting

2023-05-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D149565

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


[Lldb-commits] [lldb] b12b35a - [lldb] Add debugger.external-editor setting

2023-05-01 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-01T14:11:11-07:00
New Revision: b12b35ad4bec98c028a1926e4891e746b1f55d2f

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

LOG: [lldb] Add debugger.external-editor setting

Add a new setting (debugger.external-editor) to specify an external
editor. The setting takes precedence over the existing
LLDB_EXTERNAL_EDITOR environment variable.

Differential revision: https://reviews.llvm.org/D149565

Added: 
lldb/test/Shell/Settings/TestExternalEditor.test

Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/include/lldb/Host/Host.h
lldb/source/Core/CoreProperties.td
lldb/source/Core/Debugger.cpp
lldb/source/Host/common/Host.cpp
lldb/source/Host/macosx/objcxx/Host.mm
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Target/Thread.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 1d9d691bc2b06..12c1c046fbcef 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -293,9 +293,12 @@ class Debugger : public 
std::enable_shared_from_this,
   void SetPrompt(const char *) = delete;
 
   bool GetUseExternalEditor() const;
-
   bool SetUseExternalEditor(bool use_external_editor_p);
 
+  llvm::StringRef GetExternalEditor() const;
+
+  bool SetExternalEditor(llvm::StringRef editor);
+
   bool GetUseColor() const;
 
   bool SetUseColor(bool use_color);

diff  --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 3fdf59dfb2324..30549cd789149 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -236,7 +236,8 @@ class Host {
 bool run_in_shell = true,
 bool hide_stderr = false);
 
-  static llvm::Error OpenFileInExternalEditor(const FileSpec &file_spec,
+  static llvm::Error OpenFileInExternalEditor(llvm::StringRef editor,
+  const FileSpec &file_spec,
   uint32_t line_no);
 
   /// Check if we're running in an interactive graphical session.

diff  --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 62729923f366b..ccee2a64fcbae 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -135,6 +135,10 @@ let Definition = "debugger" in {
 Global,
 DefaultFalse,
 Desc<"Whether to use an external editor or not.">;
+  def ExternalEditor: Property<"external-editor", "String">,
+Global,
+DefaultStringValue<"">,
+Desc<"External editor to use when use-external-editor is enabled.">;
   def UseColor: Property<"use-color", "Boolean">,
 Global,
 DefaultTrue,

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 581b29e6bc1ef..ee51dd75a9ff7 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -372,6 +372,16 @@ bool Debugger::SetUseExternalEditor(bool b) {
   return m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+llvm::StringRef Debugger::GetExternalEditor() const {
+  const uint32_t idx = ePropertyExternalEditor;
+  return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
+bool Debugger::SetExternalEditor(llvm::StringRef editor) {
+  const uint32_t idx = ePropertyExternalEditor;
+  return m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, editor);
+}
+
 bool Debugger::GetUseColor() const {
   const uint32_t idx = ePropertyUseColor;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(

diff  --git a/lldb/source/Host/common/Host.cpp 
b/lldb/source/Host/common/Host.cpp
index c8ebb6f84c004..49eac0b0fa7b0 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -546,7 +546,8 @@ void Host::Kill(lldb::pid_t pid, int signo) { ::kill(pid, 
signo); }
 #endif
 
 #if !defined(__APPLE__)
-llvm::Error Host::OpenFileInExternalEditor(const FileSpec &file_spec,
+llvm::Error Host::OpenFileInExternalEditor(llvm::StringRef editor,
+   const FileSpec &file_spec,
uint32_t line_no) {
   return llvm::errorCodeToError(
   std::error_code(ENOTSUP, std::system_category()));

diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 848fa0d79f4da..5a151b9ecc8ff 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -325,7 +325,8 @@ repeat with the_window in (get windows)\n\
 
 #endif // TARGET_OS_OSX
 
-llvm::Error Host::OpenFileInExternalEditor(const FileSpec &file_spec,
+llvm::Error Host::OpenFileInExternalEditor(llvm::StringRef editor,
+  

[Lldb-commits] [PATCH] D149565: [lldb] Add debugger.external-editor setting

2023-05-01 Thread Jonas Devlieghere 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 rGb12b35ad4bec: [lldb] Add debugger.external-editor setting 
(authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D149565?vs=518558&id=518562#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149565

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Host/Host.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Host/common/Host.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Thread.cpp
  lldb/test/Shell/Settings/TestExternalEditor.test

Index: lldb/test/Shell/Settings/TestExternalEditor.test
===
--- /dev/null
+++ lldb/test/Shell/Settings/TestExternalEditor.test
@@ -0,0 +1,4 @@
+REQUIRES: system-darwin
+RUN: %lldb -o 'settings set use-external-editor true' -o 'setting set external-editor foo' -o 'session save' -b 2>&1 | FileCheck %s
+RUN: LLDB_EXTERNAL_EDITOR="foo" %lldb -o 'settings set use-external-editor true' -o 'session save' -b 2>&1 | FileCheck %s
+CHECK: error: could not find external editor "foo": LSFindApplicationForInfo returned error
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -303,10 +303,12 @@
   bool already_shown = false;
   SymbolContext frame_sc(
   frame_sp->GetSymbolContext(eSymbolContextLineEntry));
-  if (GetProcess()->GetTarget().GetDebugger().GetUseExternalEditor() &&
-  frame_sc.line_entry.file && frame_sc.line_entry.line != 0) {
+  const Debugger &debugger = GetProcess()->GetTarget().GetDebugger();
+  if (debugger.GetUseExternalEditor() && frame_sc.line_entry.file &&
+  frame_sc.line_entry.line != 0) {
 if (llvm::Error e = Host::OpenFileInExternalEditor(
-frame_sc.line_entry.file, frame_sc.line_entry.line)) {
+debugger.GetExternalEditor(), frame_sc.line_entry.file,
+frame_sc.line_entry.line)) {
   LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(e),
  "OpenFileInExternalEditor failed: {0}");
 } else {
@@ -1731,6 +1733,7 @@
 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
 if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file) {
   if (llvm::Error e = Host::OpenFileInExternalEditor(
+  target->GetDebugger().GetExternalEditor(),
   frame_sc.line_entry.file, frame_sc.line_entry.line)) {
 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(e),
"OpenFileInExternalEditor failed: {0}");
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3272,7 +3272,8 @@
 const FileSpec file_spec;
 error = file->GetFileSpec(const_cast(file_spec));
 if (error.Success()) {
-  if (llvm::Error e = Host::OpenFileInExternalEditor(file_spec, 1))
+  if (llvm::Error e = Host::OpenFileInExternalEditor(
+  m_debugger.GetExternalEditor(), file_spec, 1))
 result.AppendError(llvm::toString(std::move(e)));
 }
   }
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -325,7 +325,8 @@
 
 #endif // TARGET_OS_OSX
 
-llvm::Error Host::OpenFileInExternalEditor(const FileSpec &file_spec,
+llvm::Error Host::OpenFileInExternalEditor(llvm::StringRef editor,
+   const FileSpec &file_spec,
uint32_t line_no) {
 #if !TARGET_OS_OSX
   return llvm::errorCodeToError(
@@ -391,41 +392,36 @@
   auto on_exit = llvm::make_scope_exit(
   [&]() { AEDisposeDesc(&(file_and_line_desc.descContent)); });
 
-  static std::optional g_app_fsref;
-  static std::string g_app_error;
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, [&]() {
-if (const char *external_editor = ::getenv("LLDB_EXTERNAL_EDITOR")) {
-  LLDB_LOG(log, "Looking for external editor: {0}", external_editor);
-
-  FSRef app_fsref;
-  CFCString editor_name(external_editor, kCFStringEncodingUTF8);
-  long app_error = ::LSFindApplicationForInfo(
-  /*inCreator=*/kLSUnknownCreator, /*inBundleID=*/NULL,
-  /*inName=*/editor_name.get(), /*outAppRef=*/&app_fsref,
-  /*outAppURL=*/NULL);
-  if (app_error == noErr) {
-g_app_fsref = app_fs

[Lldb-commits] [PATCH] D148662: [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

2023-05-01 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe added a comment.

Sure, I'll revert. Thanks for notifying me of the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148662

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


[Lldb-commits] [lldb] 4535112 - Revert "[lldb] Make the libcxx unique_ptr prettyprinter support custom deleters."

2023-05-01 Thread Jorge Gorbe Moya via lldb-commits

Author: Jorge Gorbe Moya
Date: 2023-05-01T14:14:09-07:00
New Revision: 45351120105a7257ccb1e38ec1b1f8a452269da2

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

LOG: Revert "[lldb] Make the libcxx unique_ptr prettyprinter support custom 
deleters."

This reverts commit d366da97bd24ddfb91c9f260fa0aaf105d947652.

Added: 


Modified: 
lldb/include/lldb/DataFormatters/FormattersHelpers.h
lldb/source/DataFormatters/FormattersHelpers.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h 
b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index a2e8521d96651..e9af6656e3d7d 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -58,6 +58,8 @@ size_t ExtractIndexFromString(const char *item_name);
 
 Address GetArrayAddressOrPointerValue(ValueObject &valobj);
 
+lldb::ValueObjectSP GetValueOfLibCXXCompressedPair(ValueObject &pair);
+
 time_t GetOSXEpoch();
 
 struct InferiorSizedWord {

diff  --git a/lldb/source/DataFormatters/FormattersHelpers.cpp 
b/lldb/source/DataFormatters/FormattersHelpers.cpp
index 085ed3d0a2f29..87da31769ff12 100644
--- a/lldb/source/DataFormatters/FormattersHelpers.cpp
+++ b/lldb/source/DataFormatters/FormattersHelpers.cpp
@@ -126,3 +126,14 @@ 
lldb_private::formatters::GetArrayAddressOrPointerValue(ValueObject &valobj) {
 
   return data_addr;
 }
+
+lldb::ValueObjectSP
+lldb_private::formatters::GetValueOfLibCXXCompressedPair(ValueObject &pair) {
+  ValueObjectSP value =
+  pair.GetChildMemberWithName(ConstString("__value_"), true);
+  if (!value) {
+// pre-r300140 member name
+value = pair.GetChildMemberWithName(ConstString("__first_"), true);
+  }
+  return value;
+}

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 236a8129eeb34..faa33ecefc2d0 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -46,38 +46,6 @@ lldb::ValueObjectSP 
lldb_private::formatters::GetChildMemberWithName(
   return {};
 }
 
-lldb::ValueObjectSP
-lldb_private::formatters::GetFirstValueOfLibCXXCompressedPair(
-ValueObject &pair) {
-  ValueObjectSP value;
-  ValueObjectSP first_child = pair.GetChildAtIndex(0, true);
-  if (first_child)
-value = first_child->GetChildMemberWithName(ConstString("__value_"), true);
-  if (!value) {
-// pre-r300140 member name
-value = pair.GetChildMemberWithName(ConstString("__first_"), true);
-  }
-  return value;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair(
-ValueObject &pair) {
-  ValueObjectSP value;
-  if (pair.GetNumChildren() > 1) {
-ValueObjectSP second_child = pair.GetChildAtIndex(1, true);
-if (second_child) {
-  value =
-  second_child->GetChildMemberWithName(ConstString("__value_"), true);
-}
-  }
-  if (!value) {
-// pre-r300140 member name
-value = pair.GetChildMemberWithName(ConstString("__second_"), true);
-  }
-  return value;
-}
-
 bool lldb_private::formatters::LibcxxOptionalSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
   ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
@@ -202,7 +170,7 @@ bool 
lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
   if (!ptr_sp)
 return false;
 
-  ptr_sp = GetFirstValueOfLibCXXCompressedPair(*ptr_sp);
+  ptr_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
   if (!ptr_sp)
 return false;
 
@@ -690,9 +658,7 @@ 
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator(
 
 size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
 CalculateNumChildren() {
-  if (m_value_ptr_sp)
-return m_deleter_sp ? 2 : 1;
-  return 0;
+  return (m_value_ptr_sp ? 1 : 0);
 }
 
 lldb::ValueObjectSP
@@ -704,10 +670,7 @@ 
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex(
   if (idx == 0)
 return m_value_ptr_sp;
 
-  if (idx == 1)
-return m_deleter_sp;
-
-  if (idx == 2) {
+  if (idx == 1) {
 Status status;
 auto value_sp = m_value_ptr_sp->Dereference(status);
 if (status.Success()) {
@@ -728,15 +691,7 @@ bool 
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
   if (!ptr_sp)
 return false;
 
-  // Retrieve the actual point

[Lldb-commits] [lldb] 930c8ac - Improve the help output for `type XXX delete` where XXX is summary, format,

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

Author: Jim Ingham
Date: 2023-05-01T14:21:27-07:00
New Revision: 930c8ac5f56122251fc5fe7cb8584360924af62f

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

LOG: Improve the help output for `type XXX delete` where XXX is summary, format,
etc...

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectType.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectType.cpp 
b/lldb/source/Commands/CommandObjectType.cpp
index ae52808793660..2c2973a6272f3 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -39,9 +39,6 @@
 #include 
 #include 
 
-#define CHECK_FORMATTER_KIND_MASK(VAL) 
\
-  ((m_formatter_kind_mask & (VAL)) == (VAL))
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -100,6 +97,22 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args 
&command,
   return false;
 }
 
+const char *FormatCategoryToString(FormatCategoryItem item, bool long_name) {
+  switch (item) {
+  case eFormatCategoryItemSummary:
+return "summary";
+  case eFormatCategoryItemFilter:
+return "filter";
+  case eFormatCategoryItemSynth:
+if (long_name)
+  return "synthetic child provider";
+return "synthetic";
+  case eFormatCategoryItemFormat:
+return "format";
+  }
+  llvm_unreachable("Fully covered switch above!");
+};
+
 #define LLDB_OPTIONS_type_summary_add
 #include "CommandOptions.inc"
 
@@ -754,16 +767,25 @@ class CommandObjectTypeFormatterDelete : public 
CommandObjectParsed {
   };
 
   CommandOptions m_options;
-  uint32_t m_formatter_kind_mask;
+  FormatCategoryItem m_formatter_kind;
 
   Options *GetOptions() override { return &m_options; }
+  
+  static constexpr const char *g_short_help_template  = 
+  "Delete an existing %s for a type.";
+
+  static constexpr const char *g_long_help_template =  
+  "Delete an existing %s for a type.  Unless you specify a "
+  "specific category or all categories, only the "
+  "'default' category is searched.  The names must be exactly as "
+  "shown in the 'type %s list' output";
 
 public:
   CommandObjectTypeFormatterDelete(CommandInterpreter &interpreter,
-   uint32_t formatter_kind_mask,
-   const char *name, const char *help)
-  : CommandObjectParsed(interpreter, name, help, nullptr),
-m_formatter_kind_mask(formatter_kind_mask) {
+   FormatCategoryItem formatter_kind)
+  : CommandObjectParsed(interpreter, 
+FormatCategoryToString(formatter_kind, false)),
+m_formatter_kind(formatter_kind) {
 CommandArgumentEntry type_arg;
 CommandArgumentData type_style_arg;
 
@@ -773,6 +795,19 @@ class CommandObjectTypeFormatterDelete : public 
CommandObjectParsed {
 type_arg.push_back(type_style_arg);
 
 m_arguments.push_back(type_arg);
+
+const char *kind = FormatCategoryToString(formatter_kind, true);
+const char *short_kind = FormatCategoryToString(formatter_kind, false);
+  
+StreamString s;
+s.Printf(g_short_help_template, kind);
+SetHelp(s.GetData());
+s.Clear();
+s.Printf(g_long_help_template, kind, short_kind);
+SetHelpLong(s.GetData());
+s.Clear();
+s.Printf("type %s delete", short_kind);
+SetCommandName(s.GetData());
   }
 
   ~CommandObjectTypeFormatterDelete() override = default;
@@ -785,7 +820,7 @@ class CommandObjectTypeFormatterDelete : public 
CommandObjectParsed {
 
 DataVisualization::Categories::ForEach(
 [this, &request](const lldb::TypeCategoryImplSP &category_sp) {
-  category_sp->AutoComplete(request, m_formatter_kind_mask);
+  category_sp->AutoComplete(request, m_formatter_kind);
   return true;
 });
   }
@@ -812,7 +847,7 @@ class CommandObjectTypeFormatterDelete : public 
CommandObjectParsed {
 if (m_options.m_delete_all) {
   DataVisualization::Categories::ForEach(
   [this, typeCS](const lldb::TypeCategoryImplSP &category_sp) -> bool {
-category_sp->Delete(typeCS, m_formatter_kind_mask);
+category_sp->Delete(typeCS, m_formatter_kind);
 return true;
   });
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -827,14 +862,14 @@ class CommandObjectTypeFormatterDelete : public 
CommandObjectParsed {
   DataVisualization::Categories::GetCategory(m_options.m_language,
  category);
   if (category)
-delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+delete_category = category->Delete(typeCS, m_formatt

[Lldb-commits] [PATCH] D148282: Fix the help for "type X delete" to make the -a & -w behaviors clear

2023-05-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 landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
jingham marked an inline comment as done.
Closed by commit rG930c8ac5f561: Improve the help output for `type XXX delete` 
where XXX is summary, format, (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148282

Files:
  lldb/source/Commands/CommandObjectType.cpp

Index: lldb/source/Commands/CommandObjectType.cpp
===
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -39,9 +39,6 @@
 #include 
 #include 
 
-#define CHECK_FORMATTER_KIND_MASK(VAL) \
-  ((m_formatter_kind_mask & (VAL)) == (VAL))
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -100,6 +97,22 @@
   return false;
 }
 
+const char *FormatCategoryToString(FormatCategoryItem item, bool long_name) {
+  switch (item) {
+  case eFormatCategoryItemSummary:
+return "summary";
+  case eFormatCategoryItemFilter:
+return "filter";
+  case eFormatCategoryItemSynth:
+if (long_name)
+  return "synthetic child provider";
+return "synthetic";
+  case eFormatCategoryItemFormat:
+return "format";
+  }
+  llvm_unreachable("Fully covered switch above!");
+};
+
 #define LLDB_OPTIONS_type_summary_add
 #include "CommandOptions.inc"
 
@@ -754,16 +767,25 @@
   };
 
   CommandOptions m_options;
-  uint32_t m_formatter_kind_mask;
+  FormatCategoryItem m_formatter_kind;
 
   Options *GetOptions() override { return &m_options; }
+  
+  static constexpr const char *g_short_help_template  = 
+  "Delete an existing %s for a type.";
+
+  static constexpr const char *g_long_help_template =  
+  "Delete an existing %s for a type.  Unless you specify a "
+  "specific category or all categories, only the "
+  "'default' category is searched.  The names must be exactly as "
+  "shown in the 'type %s list' output";
 
 public:
   CommandObjectTypeFormatterDelete(CommandInterpreter &interpreter,
-   uint32_t formatter_kind_mask,
-   const char *name, const char *help)
-  : CommandObjectParsed(interpreter, name, help, nullptr),
-m_formatter_kind_mask(formatter_kind_mask) {
+   FormatCategoryItem formatter_kind)
+  : CommandObjectParsed(interpreter, 
+FormatCategoryToString(formatter_kind, false)),
+m_formatter_kind(formatter_kind) {
 CommandArgumentEntry type_arg;
 CommandArgumentData type_style_arg;
 
@@ -773,6 +795,19 @@
 type_arg.push_back(type_style_arg);
 
 m_arguments.push_back(type_arg);
+
+const char *kind = FormatCategoryToString(formatter_kind, true);
+const char *short_kind = FormatCategoryToString(formatter_kind, false);
+  
+StreamString s;
+s.Printf(g_short_help_template, kind);
+SetHelp(s.GetData());
+s.Clear();
+s.Printf(g_long_help_template, kind, short_kind);
+SetHelpLong(s.GetData());
+s.Clear();
+s.Printf("type %s delete", short_kind);
+SetCommandName(s.GetData());
   }
 
   ~CommandObjectTypeFormatterDelete() override = default;
@@ -785,7 +820,7 @@
 
 DataVisualization::Categories::ForEach(
 [this, &request](const lldb::TypeCategoryImplSP &category_sp) {
-  category_sp->AutoComplete(request, m_formatter_kind_mask);
+  category_sp->AutoComplete(request, m_formatter_kind);
   return true;
 });
   }
@@ -812,7 +847,7 @@
 if (m_options.m_delete_all) {
   DataVisualization::Categories::ForEach(
   [this, typeCS](const lldb::TypeCategoryImplSP &category_sp) -> bool {
-category_sp->Delete(typeCS, m_formatter_kind_mask);
+category_sp->Delete(typeCS, m_formatter_kind);
 return true;
   });
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -827,14 +862,14 @@
   DataVisualization::Categories::GetCategory(m_options.m_language,
  category);
   if (category)
-delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+delete_category = category->Delete(typeCS, m_formatter_kind);
   extra_deletion = FormatterSpecificDeletion(typeCS);
 } else {
   lldb::TypeCategoryImplSP category;
   DataVisualization::Categories::GetCategory(
   ConstString(m_options.m_category.c_str()), category);
   if (category)
-delete_category = category->Delete(typeCS, m_formatter_kind_mask);
+delete_category = category->Delete(typeCS, m_formatter_kind);
   extra_deletion = FormatterSpecificDeletion(typeCS);
 }
 
@@ -88

[Lldb-commits] [PATCH] D149482: [lldb] Change ObjectValueDictionary to use a StringMap

2023-05-01 Thread Alex Langford via Phabricator via lldb-commits
bulbazord updated this revision to Diff 518569.
bulbazord added a comment.

Remove unneeded StringRef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149482

Files:
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/source/Core/Disassembler.cpp
  lldb/source/Interpreter/OptionValueDictionary.cpp
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
  lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/API/commands/settings/TestSettings.py
  lldb/unittests/Interpreter/TestOptionValue.cpp

Index: lldb/unittests/Interpreter/TestOptionValue.cpp
===
--- lldb/unittests/Interpreter/TestOptionValue.cpp
+++ lldb/unittests/Interpreter/TestOptionValue.cpp
@@ -146,12 +146,12 @@
   ASSERT_TRUE(dict_copy_ptr->OptionWasSet());
   ASSERT_EQ(dict_copy_ptr->GetNumValues(), 2U);
 
-  auto value_ptr = dict_copy_ptr->GetValueForKey(ConstString("A"));
+  auto value_ptr = dict_copy_ptr->GetValueForKey("A");
   ASSERT_TRUE(value_ptr);
   ASSERT_EQ(value_ptr->GetParent().get(), dict_copy_ptr);
   ASSERT_EQ(value_ptr->GetUInt64Value(), 1U);
 
-  value_ptr = dict_copy_ptr->GetValueForKey(ConstString("B"));
+  value_ptr = dict_copy_ptr->GetValueForKey("B");
   ASSERT_TRUE(value_ptr);
   ASSERT_EQ(value_ptr->GetParent().get(), dict_copy_ptr);
   ASSERT_EQ(value_ptr->GetUInt64Value(), 2U);
Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -60,7 +60,7 @@
 self.assertEqual(self.dbg.GetSelectedTarget().GetNumBreakpoints(), 1)
 
 def test_append_target_env_vars(self):
-"""Test that 'append target.run-args' works."""
+"""Test that 'append target.env-vars' works."""
 # Append the env-vars.
 self.runCmd('settings append target.env-vars MY_ENV_VAR=YES')
 # And add hooks to restore the settings during tearDown().
@@ -268,7 +268,7 @@
 found_env_var = True
 break
 self.assertTrue(found_env_var,
-"MY_ENV_VAR was not set in LunchInfo object")
+"MY_ENV_VAR was not set in LaunchInfo object")
 
 self.assertEqual(launch_info.GetNumArguments(), 3)
 self.assertEqual(launch_info.GetArgumentAtIndex(0), "A")
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -300,20 +300,18 @@
 if (!module_env_option) {
   // Step 2: Try with the file name in lowercase.
   auto name_lower = name.GetStringRef().lower();
-  module_env_option =
-  map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
+  module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
 }
 if (!module_env_option) {
   // Step 3: Try with the file name with ".debug" suffix stripped.
   auto name_stripped = name.GetStringRef();
   if (name_stripped.consume_back_insensitive(".debug")) {
-module_env_option = map->GetValueForKey(ConstString(name_stripped));
+module_env_option = map->GetValueForKey(name_stripped);
 if (!module_env_option) {
   // Step 4: Try with the file name in lowercase with ".debug" suffix
   // stripped.
   auto name_lower = name_stripped.lower();
-  module_env_option =
-  map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
+  module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
 }
   }
 }
Index: lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
===
--- lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -12,7 +12,6 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Utility/ArchSpec.h"
-#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/Stream.h"
 
Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -264,8 +264,7 @@
   for (int i = 0; i < num; ++i) {
 sstr.Clear();
 sstr.Printf("%c%d", kind, i);
-OptionValueSP value_s

[Lldb-commits] [lldb] e53e1de - [lldb] Change ObjectValueDictionary to use a StringMap

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

Author: Alex Langford
Date: 2023-05-01T16:17:24-07:00
New Revision: e53e1de57eccda49a93c4368eabbd95d01c5b854

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

LOG: [lldb] Change ObjectValueDictionary to use a StringMap

llvm has a structure for maps where the key's type is a string. Using
that also means that the keys for OptionValueDictionary don't stick
around forever in ConstString's StringPool (even after they are gone).

The only thing we lose here is ordering: iterating over the map where the keys
are ConstStrings guarantees that we iterate in alphabetical order.
StringMap makes no guarantees about the ordering when you iterate over
the entire map.

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

Added: 


Modified: 
lldb/include/lldb/Interpreter/OptionValueDictionary.h
lldb/source/Core/Disassembler.cpp
lldb/source/Interpreter/OptionValueDictionary.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/test/API/commands/settings/TestSettings.py
lldb/unittests/Interpreter/TestOptionValue.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/OptionValueDictionary.h 
b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
index 1fdccdeccef50..4c250468b3cda 100644
--- a/lldb/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
@@ -9,11 +9,11 @@
 #ifndef LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H
 #define LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H
 
-#include 
-
 #include "lldb/Interpreter/OptionValue.h"
 #include "lldb/lldb-private-types.h"
 
+#include "llvm/ADT/StringMap.h"
+
 namespace lldb_private {
 
 class OptionValueDictionary
@@ -58,7 +58,7 @@ class OptionValueDictionary
 
   size_t GetNumValues() const { return m_values.size(); }
 
-  lldb::OptionValueSP GetValueForKey(ConstString key) const;
+  lldb::OptionValueSP GetValueForKey(llvm::StringRef key) const;
 
   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
   llvm::StringRef name, bool will_modify,
@@ -67,21 +67,19 @@ class OptionValueDictionary
   Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
  llvm::StringRef name, llvm::StringRef value) override;
 
-  bool SetValueForKey(ConstString key,
-  const lldb::OptionValueSP &value_sp,
+  bool SetValueForKey(llvm::StringRef key, const lldb::OptionValueSP &value_sp,
   bool can_replace = true);
 
-  bool DeleteValueForKey(ConstString key);
+  bool DeleteValueForKey(llvm::StringRef key);
 
   size_t GetArgs(Args &args) const;
 
   Status SetArgs(const Args &args, VarSetOperationType op);
 
 protected:
-  typedef std::map collection;
   uint32_t m_type_mask;
   OptionEnumValues m_enum_values;
-  collection m_values;
+  llvm::StringMap m_values;
   bool m_raw_value_dump;
 };
 

diff  --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 570332f582df2..0d9a83993e53a 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -755,7 +755,7 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, 
Stream *out_stream) {
   char buffer[1024];
 
   auto option_value_sp = std::make_shared();
-  static ConstString encoding_key("data_encoding");
+  static constexpr llvm::StringLiteral encoding_key("data_encoding");
   OptionValue::Type data_type = OptionValue::eTypeInvalid;
 
   while (!done) {
@@ -802,7 +802,6 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, 
Stream *out_stream) {
 return option_value_sp;
   }
 
-  ConstString const_key(key.c_str());
   // Check value to see if it's the start of an array or dictionary.
 
   lldb::OptionValueSP value_sp;
@@ -838,15 +837,14 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, 
Stream *out_stream) {
 value_sp = std::make_shared(value.c_str(), "");
   }
 
-  if (const_key == encoding_key) {
+  if (key == encoding_key) {
 // A 'data_encoding=..." is NOT a normal key-value pair; it is 
meta-data
-// indicating the
-// data type of an upcoming array (usually the next bit of data to be
-// read in).
-if (strcmp(value.c_str(), "uint32_t") == 0)
+// indicating the data type of an upcoming array (usually the next bit
+// of data to be read in).
+if (llvm::StringRef(value) == "uint32_t")
   data_type = OptionValue::eTypeUInt64;
   } else
-optio

[Lldb-commits] [PATCH] D149482: [lldb] Change ObjectValueDictionary to use a StringMap

2023-05-01 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe53e1de57ecc: [lldb] Change ObjectValueDictionary to use a 
StringMap (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149482

Files:
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/source/Core/Disassembler.cpp
  lldb/source/Interpreter/OptionValueDictionary.cpp
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
  lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/API/commands/settings/TestSettings.py
  lldb/unittests/Interpreter/TestOptionValue.cpp

Index: lldb/unittests/Interpreter/TestOptionValue.cpp
===
--- lldb/unittests/Interpreter/TestOptionValue.cpp
+++ lldb/unittests/Interpreter/TestOptionValue.cpp
@@ -146,12 +146,12 @@
   ASSERT_TRUE(dict_copy_ptr->OptionWasSet());
   ASSERT_EQ(dict_copy_ptr->GetNumValues(), 2U);
 
-  auto value_ptr = dict_copy_ptr->GetValueForKey(ConstString("A"));
+  auto value_ptr = dict_copy_ptr->GetValueForKey("A");
   ASSERT_TRUE(value_ptr);
   ASSERT_EQ(value_ptr->GetParent().get(), dict_copy_ptr);
   ASSERT_EQ(value_ptr->GetUInt64Value(), 1U);
 
-  value_ptr = dict_copy_ptr->GetValueForKey(ConstString("B"));
+  value_ptr = dict_copy_ptr->GetValueForKey("B");
   ASSERT_TRUE(value_ptr);
   ASSERT_EQ(value_ptr->GetParent().get(), dict_copy_ptr);
   ASSERT_EQ(value_ptr->GetUInt64Value(), 2U);
Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -60,7 +60,7 @@
 self.assertEqual(self.dbg.GetSelectedTarget().GetNumBreakpoints(), 1)
 
 def test_append_target_env_vars(self):
-"""Test that 'append target.run-args' works."""
+"""Test that 'append target.env-vars' works."""
 # Append the env-vars.
 self.runCmd('settings append target.env-vars MY_ENV_VAR=YES')
 # And add hooks to restore the settings during tearDown().
@@ -268,7 +268,7 @@
 found_env_var = True
 break
 self.assertTrue(found_env_var,
-"MY_ENV_VAR was not set in LunchInfo object")
+"MY_ENV_VAR was not set in LaunchInfo object")
 
 self.assertEqual(launch_info.GetNumArguments(), 3)
 self.assertEqual(launch_info.GetArgumentAtIndex(0), "A")
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -300,20 +300,18 @@
 if (!module_env_option) {
   // Step 2: Try with the file name in lowercase.
   auto name_lower = name.GetStringRef().lower();
-  module_env_option =
-  map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
+  module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
 }
 if (!module_env_option) {
   // Step 3: Try with the file name with ".debug" suffix stripped.
   auto name_stripped = name.GetStringRef();
   if (name_stripped.consume_back_insensitive(".debug")) {
-module_env_option = map->GetValueForKey(ConstString(name_stripped));
+module_env_option = map->GetValueForKey(name_stripped);
 if (!module_env_option) {
   // Step 4: Try with the file name in lowercase with ".debug" suffix
   // stripped.
   auto name_lower = name_stripped.lower();
-  module_env_option =
-  map->GetValueForKey(ConstString(llvm::StringRef(name_lower)));
+  module_env_option = map->GetValueForKey(llvm::StringRef(name_lower));
 }
   }
 }
Index: lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
===
--- lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -12,7 +12,6 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Utility/ArchSpec.h"
-#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/Stream.h"
 
Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -264,8 +264,7 @@
   for (int i = 0; i < num; ++

[Lldb-commits] [lldb] d69518b - Re-land "[lldb] Make the libcxx unique_ptr prettyprinter support custom deleters."

2023-05-01 Thread Jorge Gorbe Moya via lldb-commits

Author: Jorge Gorbe Moya
Date: 2023-05-01T16:19:01-07:00
New Revision: d69518b4e52d527b3f8fcc41e90ae21f1f234555

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

LOG: Re-land "[lldb] Make the libcxx unique_ptr prettyprinter support custom 
deleters."

This reverts commit 45351120105a7257ccb1e38ec1b1f8a452269da2.

Added: 


Modified: 
lldb/include/lldb/DataFormatters/FormattersHelpers.h
lldb/source/DataFormatters/FormattersHelpers.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp

lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h 
b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index e9af6656e3d7d..a2e8521d96651 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -58,8 +58,6 @@ size_t ExtractIndexFromString(const char *item_name);
 
 Address GetArrayAddressOrPointerValue(ValueObject &valobj);
 
-lldb::ValueObjectSP GetValueOfLibCXXCompressedPair(ValueObject &pair);
-
 time_t GetOSXEpoch();
 
 struct InferiorSizedWord {

diff  --git a/lldb/source/DataFormatters/FormattersHelpers.cpp 
b/lldb/source/DataFormatters/FormattersHelpers.cpp
index 87da31769ff12..085ed3d0a2f29 100644
--- a/lldb/source/DataFormatters/FormattersHelpers.cpp
+++ b/lldb/source/DataFormatters/FormattersHelpers.cpp
@@ -126,14 +126,3 @@ 
lldb_private::formatters::GetArrayAddressOrPointerValue(ValueObject &valobj) {
 
   return data_addr;
 }
-
-lldb::ValueObjectSP
-lldb_private::formatters::GetValueOfLibCXXCompressedPair(ValueObject &pair) {
-  ValueObjectSP value =
-  pair.GetChildMemberWithName(ConstString("__value_"), true);
-  if (!value) {
-// pre-r300140 member name
-value = pair.GetChildMemberWithName(ConstString("__first_"), true);
-  }
-  return value;
-}

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index faa33ecefc2d0..236a8129eeb34 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -46,6 +46,38 @@ lldb::ValueObjectSP 
lldb_private::formatters::GetChildMemberWithName(
   return {};
 }
 
+lldb::ValueObjectSP
+lldb_private::formatters::GetFirstValueOfLibCXXCompressedPair(
+ValueObject &pair) {
+  ValueObjectSP value;
+  ValueObjectSP first_child = pair.GetChildAtIndex(0, true);
+  if (first_child)
+value = first_child->GetChildMemberWithName(ConstString("__value_"), true);
+  if (!value) {
+// pre-r300140 member name
+value = pair.GetChildMemberWithName(ConstString("__first_"), true);
+  }
+  return value;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair(
+ValueObject &pair) {
+  ValueObjectSP value;
+  if (pair.GetNumChildren() > 1) {
+ValueObjectSP second_child = pair.GetChildAtIndex(1, true);
+if (second_child) {
+  value =
+  second_child->GetChildMemberWithName(ConstString("__value_"), true);
+}
+  }
+  if (!value) {
+// pre-r300140 member name
+value = pair.GetChildMemberWithName(ConstString("__second_"), true);
+  }
+  return value;
+}
+
 bool lldb_private::formatters::LibcxxOptionalSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
   ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
@@ -170,7 +202,7 @@ bool 
lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
   if (!ptr_sp)
 return false;
 
-  ptr_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
+  ptr_sp = GetFirstValueOfLibCXXCompressedPair(*ptr_sp);
   if (!ptr_sp)
 return false;
 
@@ -658,7 +690,9 @@ 
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator(
 
 size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
 CalculateNumChildren() {
-  return (m_value_ptr_sp ? 1 : 0);
+  if (m_value_ptr_sp)
+return m_deleter_sp ? 2 : 1;
+  return 0;
 }
 
 lldb::ValueObjectSP
@@ -670,7 +704,10 @@ 
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex(
   if (idx == 0)
 return m_value_ptr_sp;
 
-  if (idx == 1) {
+  if (idx == 1)
+return m_deleter_sp;
+
+  if (idx == 2) {
 Status status;
 auto value_sp = m_value_ptr_sp->Dereference(status);
 if (status.Success()) {
@@ -691,7 +728,15 @@ bool 
lldb_private::formatters::LibcxxUniquePt

[Lldb-commits] [PATCH] D148662: [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

2023-05-01 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe added a comment.

Landed again, with a fix for the test that was failing on Darwin, as 
https://github.com/llvm/llvm-project/commit/d69518b4e52d527b3f8fcc41e90ae21f1f234555.
 I'll keep an eye on the build bot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148662

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


[Lldb-commits] [PATCH] D148662: [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

2023-05-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Thanks for the quick response!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148662

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


[Lldb-commits] [PATCH] D149625: [lldb] Refactor SBFileSpec::GetDirectory

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

There's no reason to create an entire new filespec to mutate and grab
data from when we can just grab the data directly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149625

Files:
  lldb/source/API/SBFileSpec.cpp


Index: lldb/source/API/SBFileSpec.cpp
===
--- lldb/source/API/SBFileSpec.cpp
+++ lldb/source/API/SBFileSpec.cpp
@@ -114,9 +114,7 @@
 const char *SBFileSpec::GetDirectory() const {
   LLDB_INSTRUMENT_VA(this);
 
-  FileSpec directory{*m_opaque_up};
-  directory.ClearFilename();
-  return directory.GetPathAsConstString().GetCString();
+  return m_opaque_up->GetDirectory().GetCString();
 }
 
 void SBFileSpec::SetFilename(const char *filename) {


Index: lldb/source/API/SBFileSpec.cpp
===
--- lldb/source/API/SBFileSpec.cpp
+++ lldb/source/API/SBFileSpec.cpp
@@ -114,9 +114,7 @@
 const char *SBFileSpec::GetDirectory() const {
   LLDB_INSTRUMENT_VA(this);
 
-  FileSpec directory{*m_opaque_up};
-  directory.ClearFilename();
-  return directory.GetPathAsConstString().GetCString();
+  return m_opaque_up->GetDirectory().GetCString();
 }
 
 void SBFileSpec::SetFilename(const char *filename) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D147831: [lldb-vscode] Implement RestartRequest

2023-05-01 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe added inline comments.



Comment at: lldb/tools/lldb-vscode/VSCode.h:152
   bool is_attach;
+  // The process event thread normally responds to process exited events by
+  // shutting down the entire adapter. When we're restarting, we keep the id of

labath wrote:
> So, it's not possible to restart a process if it has already terminated? 
> I.e., if the debugged process unexpectedly exits, the user will have to 
> restart lldb-vscode from scratch (so he can e.g., set a breakpoint in before 
> the exit).
I don't know if it's //possible// (as in, if the protocol allows it), but it's 
what lldb-vscode does.

It also matches the behavior I remember when I used Visual Studio back in the 
day: when the debugged process exits, the debugging session ends and the UI 
switches back to "editing" mode automatically. If you need to re-run, you hit 
F5 and run it again. It's usually not a big deal because the IDE keeps the list 
of breakpoints and will transparently start lldb-vscode and set everything up 
again when you click "Run". It's also what VS Code does when a debug adapter 
doesn't support the RestartRequest, it just kills the adapter and restarts 
everything transparently (which is how restart works on lldb-vscode so far).



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1976
+if (state != lldb::eStateConnected) {
+  process.Kill();
+}

wallace wrote:
> Kill actually detaches if lldb originally attached to the debuggee. The 
> actual implementation says
> 
> ```
>   /// Kills the process and shuts down all threads that were spawned to track
>   /// and monitor the process.
>   ///
>   /// This function is not meant to be overridden by Process subclasses.
>   ///
>   /// \param[in] force_kill
>   /// Whether lldb should force a kill (instead of a detach) from
>   /// the inferior process.  Normally if lldb launched a binary and
>   /// Destory is called, lldb kills it.  If lldb attached to a
>   /// running process and Destory is called, lldb detaches.  If
>   /// this behavior needs to be over-ridden, this is the bool that
>   /// can be used.
>   ///
>   /// \return
>   /// Returns an error object.
>   Status Destroy(bool force_kill);
> ```
> You could have the restart command reattach to the process instead of failing 
> if the user originally attached. 
> 
> What do you think of this?
I think it's something you *could* do, but it's not restarting. As I mention in 
a code comment above, I don't think "restart" is even well defined in the 
attach case.

As a user I would be really confused if I clicked on restart and the debugger 
deattached from the process, then immediately reattached, but nothing 
restarted. I can't think of a case where this would be useful.

Looking for some references, I started Visual Studio (not Code) and it simply 
grays out the "restart" button when attaching. Visual Studio Code, however, 
allows you to restart. I found [this 
issue](https://github.com/microsoft/debug-adapter-protocol/issues/73) where 
someone asked for clarification on the meaning of Restart in the protocol and 
got this explanation:

> "restart sequence" means:
> terminate current debug session via the disconnect request and immediately 
> start a new session via the launch or attach request
> 
> For the "launch" case "restart" can be used to pickup source changes that are 
> not automatically picked up while the program is running.
> 
> For the "attach" case "restart" has no direct effect on the debug target 
> because the debug target continues running. But it still might have an effect 
> on debugging because the debug adapter is restarted and this could pick up 
> changes to files that the debug adapter uses, e.g. source maps.

But I'm not very convinced by this because we're implementing RestartRequest, 
which means precisely that the adapter won't be restarted.



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1983
+  g_vsc.debugger.SetAsync(true);
+  LaunchProcess(*g_vsc.last_launch_or_attach_request);
+

labath wrote:
> I have no idea if that's a good idea or not, but I'm wondering if, instead of 
> from the last attach request, we should be taking the arguments from lldb. So 
> that if the user say changes the `target.run-args` setting, then the new 
> restart request will take that into account...
I think the intended way to allow the user to modify the configuration is to 
use the optional `arguments` field in `RestartRequest`, which the client can 
use to send the latest version of the config.

https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Restart

> ```
> interface RestartRequest extends Request {
>   command: 'restart';
> 
>   arguments?: RestartArguments;
> }
> ```
> Arguments for restart request.
> 
> ```
> interface RestartArguments {
>   /**
>* The latest version of the `launch` or `attach` configuration.
>*/
>

[Lldb-commits] [PATCH] D147831: [lldb-vscode] Implement RestartRequest

2023-05-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!




Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1983
+  g_vsc.debugger.SetAsync(true);
+  LaunchProcess(*g_vsc.last_launch_or_attach_request);
+

jgorbe wrote:
> labath wrote:
> > I have no idea if that's a good idea or not, but I'm wondering if, instead 
> > of from the last attach request, we should be taking the arguments from 
> > lldb. So that if the user say changes the `target.run-args` setting, then 
> > the new restart request will take that into account...
> I think the intended way to allow the user to modify the configuration is to 
> use the optional `arguments` field in `RestartRequest`, which the client can 
> use to send the latest version of the config.
> 
> https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Restart
> 
> > ```
> > interface RestartRequest extends Request {
> >   command: 'restart';
> > 
> >   arguments?: RestartArguments;
> > }
> > ```
> > Arguments for restart request.
> > 
> > ```
> > interface RestartArguments {
> >   /**
> >* The latest version of the `launch` or `attach` configuration.
> >*/
> >   arguments?: LaunchRequestArguments | AttachRequestArguments;
> > }
> > ```
> 
> We can check if the restart request has `arguments` and only used the saved 
> config if that's not the case. What do you think?
> 
> @wallace any opinions here? Is this kind of lldb state manipulation via 
> console commands something that is expected to work correctly in lldb-vscode?
i think it's better to reuse the same arguments that the user passed using the 
vscode interface. Modifying them in the command line might seems 
counterintuitive.


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

https://reviews.llvm.org/D147831

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


[Lldb-commits] [PATCH] D147370: [lldb] fixing #61727 fixing incorrect variable displaying with DW_OP_div

2023-05-01 Thread LU Hongyi via Phabricator via lldb-commits
jwnhy marked an inline comment as done.
jwnhy added a comment.

In D147370#4309481 , @Michael137 
wrote:

> @jwnhy Let me know which name and email I should attribute the patch to

Oh, sorry.
I am LU Hongyi, and the email is jwn...@gmail.com, my github account is also 
jwnhy.

Thank you very much.


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

https://reviews.llvm.org/D147370

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


[Lldb-commits] [lldb] fdbe7c7 - [lldb] Refactor OptionValue to return a std::optional (NFC)

2023-05-01 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-01T21:08:23-07:00
New Revision: fdbe7c7faa547b16bf6da0fedbb7234b6ee3adef

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

LOG: [lldb] Refactor OptionValue to return a std::optional (NFC)

Refactor OptionValue to return a std::optional instead of taking a fail
value. This allows the caller to handle situations where there's no
value, instead of being unable to distinguish between the absence of a
value and the value happening the match the fail value. When a fail
value is required, std::optional::value_or() provides the same
functionality.

Added: 


Modified: 
lldb/include/lldb/Interpreter/OptionValue.h
lldb/source/Commands/CommandObjectBreakpoint.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Commands/CommandObjectRegister.cpp
lldb/source/Core/Disassembler.cpp
lldb/source/Interpreter/OptionValue.cpp
lldb/source/Interpreter/OptionValueArgs.cpp
lldb/source/Interpreter/OptionValueArray.cpp
lldb/source/Interpreter/OptionValueProperties.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index 3c842d1f5ce7..562eab64b518 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -182,10 +182,6 @@ class OptionValue {
   CreateValueFromCStringForTypeMask(const char *value_cstr, uint32_t type_mask,
 Status &error);
 
-  // Get this value as a uint64_t value if it is encoded as a boolean, uint64_t
-  // or int64_t. Other types will cause "fail_value" to be returned
-  uint64_t GetUInt64Value(uint64_t fail_value, bool *success_ptr);
-
   OptionValueArch *GetAsArch();
 
   const OptionValueArch *GetAsArch() const;
@@ -262,15 +258,15 @@ class OptionValue {
 
   const OptionValueFormatEntity *GetAsFormatEntity() const;
 
-  bool GetBooleanValue(bool fail_value = false) const;
+  std::optional GetBooleanValue() const;
 
   bool SetBooleanValue(bool new_value);
 
-  char GetCharValue(char fail_value) const;
+  std::optional GetCharValue() const;
 
   char SetCharValue(char new_value);
 
-  int64_t GetEnumerationValue(int64_t fail_value = -1) const;
+  std::optional GetEnumerationValue() const;
 
   bool SetEnumerationValue(int64_t value);
 
@@ -280,13 +276,11 @@ class OptionValue {
 
   FileSpecList GetFileSpecListValue() const;
 
-  lldb::Format
-  GetFormatValue(lldb::Format fail_value = lldb::eFormatDefault) const;
+  std::optional GetFormatValue() const;
 
   bool SetFormatValue(lldb::Format new_value);
 
-  lldb::LanguageType GetLanguageValue(
-  lldb::LanguageType fail_value = lldb::eLanguageTypeUnknown) const;
+  std::optional GetLanguageValue() const;
 
   bool SetLanguageValue(lldb::LanguageType new_language);
 
@@ -294,16 +288,15 @@ class OptionValue {
 
   const RegularExpression *GetRegexValue() const;
 
-  int64_t GetSInt64Value(int64_t fail_value = 0) const;
+  std::optional GetSInt64Value() const;
 
   bool SetSInt64Value(int64_t new_value);
 
-  llvm::StringRef GetStringValue(llvm::StringRef fail_value) const;
-  llvm::StringRef GetStringValue() const { return 
GetStringValue(llvm::StringRef()); }
+  std::optional GetStringValue() const;
 
   bool SetStringValue(llvm::StringRef new_value);
 
-  uint64_t GetUInt64Value(uint64_t fail_value = 0) const;
+  std::optional GetUInt64Value() const;
 
   bool SetUInt64Value(uint64_t new_value);
 

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 8c31630231b5..3debbb3b576e 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1739,7 +1739,8 @@ class CommandObjectBreakpointNameConfigure : public 
CommandObjectParsed {
 // check the error:
 BreakpointSP bp_sp;
 if (m_bp_id.m_breakpoint.OptionWasSet()) {
-  lldb::break_id_t bp_id = m_bp_id.m_breakpoint.GetUInt64Value();
+  lldb::break_id_t bp_id =
+  m_bp_id.m_breakpoint.GetUInt64Value().value_or(0);
   bp_sp = target.GetBreakpointByID(bp_id);
   if (!bp_sp) {
 result.AppendErrorWithFormatv("Could not find specified breakpoint 
{0}",
@@ -1755,7 +1756,8 @@ class CommandObjectBreakpointNameConfigure : public 
CommandObjectParsed {
   if (!bp_name)
 continue;
   if (m_bp_id.m_help_string.OptionWasSet())
-bp_name->SetHelp(m_bp_id.m_help_string.GetStringValue().str().c_str());
+bp_name->SetHe

[Lldb-commits] [lldb] 9cb3af1 - [lldb] Fix bug introduced by fdbe7c7faa54

2023-05-01 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-01T21:23:14-07:00
New Revision: 9cb3af1e8649444da7ac5080fe2ade70b5dc2992

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

LOG: [lldb] Fix bug introduced by fdbe7c7faa54

I didn't account for the scenario where the string was set but was
empty. This commit restores the old behavior and fixes
TestMemoryFind.py.

Added: 


Modified: 
lldb/source/Commands/CommandObjectMemory.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index 903424336cd5..a8896f8c1fea 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -1047,13 +1047,13 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 DataBufferHeap buffer;
 
 if (m_memory_options.m_string.OptionWasSet()) {
-  std::optional str =
-  m_memory_options.m_string.GetStringValue();
-  if (!str) {
+  llvm::StringRef str =
+  m_memory_options.m_string.GetStringValue().value_or("");
+  if (str.empty()) {
 result.AppendError("search string must have non-zero length.");
 return false;
   }
-  buffer.CopyData(*str);
+  buffer.CopyData(str);
 } else if (m_memory_options.m_expr.OptionWasSet()) {
   StackFrame *frame = m_exe_ctx.GetFramePtr();
   ValueObjectSP result_sp;



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


[Lldb-commits] [lldb] fe3ee68 - [lldb] Fix warning: extra '; ' outside of a function is incompatible with C++98

2023-05-01 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-01T21:23:47-07:00
New Revision: fe3ee680741d603dd1229571e86e62bdb88ea215

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

LOG: [lldb] Fix warning: extra ';' outside of a function is incompatible with 
C++98

Fix warning, remove trailing whitespace and fix formatting.

Added: 


Modified: 
lldb/source/Commands/CommandObjectType.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectType.cpp 
b/lldb/source/Commands/CommandObjectType.cpp
index 2c2973a6272f..b6c379bdb434 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -111,7 +111,7 @@ const char *FormatCategoryToString(FormatCategoryItem item, 
bool long_name) {
 return "format";
   }
   llvm_unreachable("Fully covered switch above!");
-};
+}
 
 #define LLDB_OPTIONS_type_summary_add
 #include "CommandOptions.inc"
@@ -770,11 +770,11 @@ class CommandObjectTypeFormatterDelete : public 
CommandObjectParsed {
   FormatCategoryItem m_formatter_kind;
 
   Options *GetOptions() override { return &m_options; }
-  
-  static constexpr const char *g_short_help_template  = 
+
+  static constexpr const char *g_short_help_template =
   "Delete an existing %s for a type.";
 
-  static constexpr const char *g_long_help_template =  
+  static constexpr const char *g_long_help_template =
   "Delete an existing %s for a type.  Unless you specify a "
   "specific category or all categories, only the "
   "'default' category is searched.  The names must be exactly as "
@@ -783,9 +783,9 @@ class CommandObjectTypeFormatterDelete : public 
CommandObjectParsed {
 public:
   CommandObjectTypeFormatterDelete(CommandInterpreter &interpreter,
FormatCategoryItem formatter_kind)
-  : CommandObjectParsed(interpreter, 
+  : CommandObjectParsed(interpreter,
 FormatCategoryToString(formatter_kind, false)),
-m_formatter_kind(formatter_kind) {
+m_formatter_kind(formatter_kind) {
 CommandArgumentEntry type_arg;
 CommandArgumentData type_style_arg;
 
@@ -795,10 +795,10 @@ class CommandObjectTypeFormatterDelete : public 
CommandObjectParsed {
 type_arg.push_back(type_style_arg);
 
 m_arguments.push_back(type_arg);
-
+
 const char *kind = FormatCategoryToString(formatter_kind, true);
 const char *short_kind = FormatCategoryToString(formatter_kind, false);
-  
+
 StreamString s;
 s.Printf(g_short_help_template, kind);
 SetHelp(s.GetData());



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


[Lldb-commits] [lldb] 76fb334 - [lldb] Remove TestExternalEditor.test

2023-05-01 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-01T21:25:14-07:00
New Revision: 76fb3343029ea618c0cc14d1b20f82b7941cff5e

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

LOG: [lldb] Remove TestExternalEditor.test

Remove TestExternalEditor.test as the code to open the transcript in an
external editor is conditional on lldb running in a graphical session.
As a result this test passes locally but not on the bots.

Added: 


Modified: 


Removed: 
lldb/test/Shell/Settings/TestExternalEditor.test



diff  --git a/lldb/test/Shell/Settings/TestExternalEditor.test 
b/lldb/test/Shell/Settings/TestExternalEditor.test
deleted file mode 100644
index de0195ae8ac5..
--- a/lldb/test/Shell/Settings/TestExternalEditor.test
+++ /dev/null
@@ -1,4 +0,0 @@
-REQUIRES: system-darwin
-RUN: %lldb -o 'settings set use-external-editor true' -o 'setting set 
external-editor foo' -o 'session save' -b 2>&1 | FileCheck %s
-RUN: LLDB_EXTERNAL_EDITOR="foo" %lldb -o 'settings set use-external-editor 
true' -o 'session save' -b 2>&1 | FileCheck %s
-CHECK: error: could not find external editor "foo": LSFindApplicationForInfo 
returned error



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


[Lldb-commits] [lldb] 9c48aa6 - [lldb] Refactor OptionValueProperties to return a std::optional (NFC)

2023-05-01 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-05-01T21:46:32-07:00
New Revision: 9c48aa68f455a63fc5e20e196d3c3e8822bfa6af

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

LOG: [lldb] Refactor OptionValueProperties to return a std::optional (NFC)

Similar to fdbe7c7faa54, refactor OptionValueProperties to return a
std::optional instead of taking a fail value. This allows the caller to
handle situations where there's no value, instead of being unable to
distinguish between the absence of a value and the value happening the
match the fail value. When a fail value is required,
std::optional::value_or() provides the same functionality.

Added: 


Modified: 
lldb/include/lldb/Interpreter/OptionValueProperties.h
lldb/source/Core/Debugger.cpp
lldb/source/Core/ModuleList.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/OptionValueProperties.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h 
b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 814e0a895cc61..691a42a7aeec3 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -125,8 +125,9 @@ class OptionValueProperties
   bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t 
idx,
   const Args &args);
 
-  bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
-   uint32_t idx, bool fail_value) const;
+  std::optional
+  GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
+  uint32_t idx) const;
 
   bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
uint32_t idx, bool new_value);
@@ -135,9 +136,9 @@ class OptionValueProperties
   GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx,
 uint32_t idx) const;
 
-  int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
-  uint32_t idx,
-  int64_t fail_value) const;
+  std::optional
+  GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
+  uint32_t idx) const;
 
   bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
uint32_t idx, int64_t new_value);
@@ -158,21 +159,23 @@ class OptionValueProperties
   GetPropertyAtIndexAsOptionValueUInt64(const ExecutionContext *exe_ctx,
 uint32_t idx) const;
 
-  int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
- uint32_t idx, int64_t fail_value) const;
+  std::optional
+  GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
 
   bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t 
idx,
   int64_t new_value);
 
-  uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
-  uint32_t idx, uint64_t fail_value) const;
+  std::optional
+  GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
 
   bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t 
idx,
   uint64_t new_value);
 
-  llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
- uint32_t idx,
- llvm::StringRef fail_value) const;
+  std::optional
+  GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
+ uint32_t idx) const;
 
   bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t 
idx,
   llvm::StringRef new_value);

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index ee51dd75a9ff7..2