[Lldb-commits] [lldb] [LLDB] Add framework for Data Inspection Language (DIL) work. (PR #115666)

2024-11-12 Thread Pavel Labath via lldb-commits

labath wrote:

+1 to what Jim said. You could keep `GetValueForVariableExpressionPath` as a 
single entry point, but then implement it as something like `if(use_dil) 
LegacyGetValueForVariableExpressionPath() else 
DILGetValueForVariableExpressionPath()`

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


[Lldb-commits] [lldb] [LLDB] Add framework for Data Inspection Language (DIL) work. (PR #115666)

2024-11-12 Thread Pavel Labath via lldb-commits


@@ -56,8 +56,19 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE 
&parent_die,
 if (auto frame = exe_ctx->GetFrameSP()) {
   Status error;
   lldb::VariableSP var_sp;
-  auto valobj_sp = frame->GetValueForVariableExpressionPath(
-  var_die.GetName(), eNoDynamicValues, 0, var_sp, error);
+  lldb::TargetSP target_sp = frame->CalculateTarget();
+  bool use_DIL = target_sp->GetUseDIL(
+  (lldb_private::ExecutionContext *)exe_ctx);

labath wrote:

It looks like this cast wouldn't be required if you changed 
`GetExperimentalPropertyValue` to take a const execution context (all of the 
functions below it already take a const argument)

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


[Lldb-commits] [lldb] 2a3c08f - [lldb] (Begin to) support discontinuous lldb_private::Functions (#115730)

2024-11-12 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-11-12T09:34:53+01:00
New Revision: 2a3c08f620fc89823ebf1d2af4ea0beb97671db2

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

LOG: [lldb] (Begin to) support discontinuous lldb_private::Functions (#115730)

This is the beginning of a different, more fundamental approach to
handling. This PR tries to tries to minimize functional changes. It only
makes sure that we store the true set of ranges inside the function
object, so that subsequent patches can make use of it.

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-function.s

Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/source/Symbol/Function.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 8255c2baea7700..bbfc25fe74ea06 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -428,7 +428,7 @@ class Function : public UserID, public SymbolContextScope {
   /// The section offset based address for this function.
   Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
lldb::user_id_t func_type_uid, const Mangled &mangled,
-   Type *func_type, const AddressRange &range);
+   Type *func_type, AddressRanges ranges);
 
   /// Destructor.
   ~Function() override;
@@ -649,8 +649,12 @@ class Function : public UserID, public SymbolContextScope {
   /// All lexical blocks contained in this function.
   Block m_block;
 
+  /// List of address ranges belonging to the function.
+  AddressRanges m_ranges;
+
   /// The function address range that covers the widest range needed to contain
-  /// all blocks
+  /// all blocks. DEPRECATED: do not use this field in new code as the range 
may
+  /// include addresses belonging to other functions.
   AddressRange m_range;
 
   /// The frame base expression for variables that are relative to the frame

diff  --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index 9e78ba8174e3d5..fadc19676609bf 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -255,7 +255,7 @@ FunctionSP 
SymbolFileBreakpad::GetOrCreateFunction(CompileUnit &comp_unit) {
   section_sp, address - section_sp->GetFileAddress(), record->Size);
   // Use the CU's id because every CU has only one function inside.
   func_sp = std::make_shared(&comp_unit, id, 0, func_name,
-   nullptr, func_range);
+   nullptr, AddressRanges{func_range});
   comp_unit.AddFunction(func_sp);
 }
   }

diff  --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index bb738c3dcc54a0..15e8d38e7f334b 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -829,7 +829,7 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   lldb::user_id_t func_uid = m_functions.size();
   FunctionSP function_sp = std::make_shared(
   &cu, func_uid, function_type_uid, symbol->GetMangled(), 
type_sp.get(),
-  func_range);
+  AddressRanges{func_range});
   m_functions.emplace_back(function_sp);
   cu.AddFunction(function_sp);
 }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 971cbe47fb702d..80f7becc1b24ba 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -42,7 +42,7 @@ class DWARFASTParser {
 
   virtual Function *ParseFunctionFromDWARF(CompileUnit &comp_unit,
const DWARFDIE &die,
-   const AddressRange &range) = 0;
+   AddressRanges ranges) = 0;
 
   virtual bool CompleteTypeFromDWARF(const DWARFDIE &die, Type *type,
  const CompilerType &compiler_type) = 0;

diff 

[Lldb-commits] [lldb] ca4cd08 - [lldb][AIX] Added XCOFF Object File Header for AIX (#111814)

2024-11-12 Thread via lldb-commits

Author: Dhruv Srivastava
Date: 2024-11-12T09:34:25+01:00
New Revision: ca4cd08fb9d7a03fbd00bca05d5dbfa87cd6db4e

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

LOG: [lldb][AIX] Added XCOFF Object File Header for AIX (#111814)

Added XCOFF Object File Header for AIX.

Added base functionality for XCOFF support. Will enhance the files in
incremental PRs

Details about XCOFF file format on AIX:
[XCOFF](https://www.ibm.com/docs/en/aix/7.3?topic=formats-xcoff-object-file-format)

Added: 
lldb/source/Plugins/ObjectFile/XCOFF/CMakeLists.txt
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
lldb/test/Shell/ObjectFile/XCOFF/basic-info.yaml

Modified: 
lldb/source/Plugins/ObjectFile/CMakeLists.txt
lldb/tools/lldb-server/CMakeLists.txt
lldb/tools/lldb-server/SystemInitializerLLGS.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/CMakeLists.txt 
b/lldb/source/Plugins/ObjectFile/CMakeLists.txt
index 773241c8944c8a..7abd0c96f4fd74 100644
--- a/lldb/source/Plugins/ObjectFile/CMakeLists.txt
+++ b/lldb/source/Plugins/ObjectFile/CMakeLists.txt
@@ -6,5 +6,6 @@ add_subdirectory(Mach-O)
 add_subdirectory(Minidump)
 add_subdirectory(PDB)
 add_subdirectory(PECOFF)
+add_subdirectory(XCOFF)
 add_subdirectory(Placeholder)
 add_subdirectory(wasm)

diff  --git a/lldb/source/Plugins/ObjectFile/XCOFF/CMakeLists.txt 
b/lldb/source/Plugins/ObjectFile/XCOFF/CMakeLists.txt
new file mode 100644
index 00..8840248574c886
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_lldb_library(lldbPluginObjectFileXCOFF PLUGIN
+  ObjectFileXCOFF.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+BinaryFormat
+Object
+Support
+  )

diff  --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
new file mode 100644
index 00..3be900f9a4bc9f
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -0,0 +1,191 @@
+//===-- ObjectFileXCOFF.cpp
+//-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ObjectFileXCOFF.h"
+
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/FileSpecList.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RangeMap.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/Stream.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/XCOFF.h"
+#include "llvm/Object/XCOFFObjectFile.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+
+LLDB_PLUGIN_DEFINE(ObjectFileXCOFF)
+
+// FIXME: target 64bit at this moment.
+
+// Static methods.
+void ObjectFileXCOFF::Initialize() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(),
+GetPluginDescriptionStatic(), CreateInstance,
+CreateMemoryInstance, GetModuleSpecifications);
+}
+
+void ObjectFileXCOFF::Terminate() {
+  PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+ObjectFile *ObjectFileXCOFF::CreateInstance(const lldb::ModuleSP &module_sp,
+DataBufferSP data_sp,
+lldb::offset_t data_offset,
+const lldb_private::FileSpec *file,
+lldb::offset_t file_offset,
+lldb::offset_t length) {
+  if (!data_sp) {
+data_sp = MapFileData(*file, length, file_offset);
+if (!data_sp)
+  return nullptr;
+data_offset = 0;
+  }
+  if (!ObjectFileXCOFF::MagicBytesMatch(data_sp, data_offset, length))
+return nullptr;
+  // Update the data to contain the entire file if it doesn't already
+  if (data_sp->GetByteSize() < length) {
+data_sp = MapFileData(*file, length, file_offset);
+if (!data_sp)
+  return nullptr;
+data_offset = 

[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF Object File Header for AIX (PR #111814)

2024-11-12 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] (Begin to) support discontinuous lldb_private::Functions (PR #115730)

2024-11-12 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add Function::GetAddress and redirect some uses (PR #115836)

2024-11-12 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/115836

Many calls to Function::GetAddressRange() were not interested in the range 
itself. Instead they wanted to find the address of the function (its entry 
point) or the base address for relocation of function-scoped entities 
(technically, the two don't need to be the same, but there's isn't good reason 
for them not to be). This PR creates a separate function for retrieving this, 
and changes the existing (non-controversial) uses to call that instead.

>From cfca5f7b06c26e35c5884542b52b1fe6d28f59ea Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 12 Nov 2024 10:17:42 +0100
Subject: [PATCH] [lldb] Add Function::GetAddress and redirect some uses

Many calls to Function::GetAddressRange() were not interested in the
range itself. Instead they wanted to find the address of the function
(its entry point) or the base address for relocation of function-scoped
entities. This PR creates a separate function for retrieving this, and
changes the existing (non-controversial) uses to call that instead.
---
 lldb/include/lldb/Symbol/Function.h   |  5 +
 lldb/source/API/SBBlock.cpp   |  3 +--
 lldb/source/API/SBFunction.cpp|  3 +--
 lldb/source/Breakpoint/BreakpointResolver.cpp |  2 +-
 .../Breakpoint/BreakpointResolverName.cpp |  2 +-
 lldb/source/Core/SearchFilter.cpp |  2 +-
 .../source/Expression/DWARFExpressionList.cpp |  3 +--
 lldb/source/Expression/IRExecutionUnit.cpp|  3 +--
 .../Architecture/Mips/ArchitectureMips.cpp|  2 +-
 .../MacOSX-DYLD/DynamicLoaderDarwin.cpp   |  6 ++
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp |  3 +--
 .../Clang/ClangExpressionDeclMap.cpp  |  2 +-
 .../Breakpad/SymbolFileBreakpad.cpp   |  4 ++--
 .../DWARF/SymbolFileDWARFDebugMap.cpp |  3 +--
 .../NativePDB/SymbolFileNativePDB.cpp | 12 
 lldb/source/Symbol/Block.cpp  | 14 ++
 lldb/source/Symbol/Function.cpp   | 19 +--
 lldb/source/Symbol/SymbolContext.cpp  | 10 +++---
 lldb/source/Symbol/Variable.cpp   |  8 +++-
 lldb/source/Target/StackFrame.cpp |  3 +--
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  2 +-
 .../ValueObject/ValueObjectVariable.cpp   |  3 +--
 22 files changed, 52 insertions(+), 62 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index bbfc25fe74ea06..dd4226f300c377 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -446,6 +446,11 @@ class Function : public UserID, public SymbolContextScope {
 
   const AddressRange &GetAddressRange() { return m_range; }
 
+  /// Return the address of the function (its entry point). This address is 
also
+  /// used as a base address for relocation of function-scope entities (blocks
+  /// and variables).
+  Address GetAddress() const;
+
   lldb::LanguageType GetLanguage() const;
   /// Find the file and line number of the source location of the start of the
   /// function.  This will use the declaration if present and fall back on the
diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp
index b921ccd9802454..2ef4cc7227cf95 100644
--- a/lldb/source/API/SBBlock.cpp
+++ b/lldb/source/API/SBBlock.cpp
@@ -176,8 +176,7 @@ bool SBBlock::GetDescription(SBStream &description) {
 m_opaque_ptr->CalculateSymbolContext(&sc);
 if (sc.function) {
   m_opaque_ptr->DumpAddressRanges(
-  &strm,
-  sc.function->GetAddressRange().GetBaseAddress().GetFileAddress());
+  &strm, sc.function->GetAddress().GetFileAddress());
 }
   } else
 strm.PutCString("No value");
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index ac61220ec8736a..91f5e243af4144 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -119,8 +119,7 @@ SBInstructionList SBFunction::GetInstructions(SBTarget 
target,
   if (m_opaque_ptr) {
 TargetSP target_sp(target.GetSP());
 std::unique_lock lock;
-ModuleSP module_sp(
-m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule());
+ModuleSP module_sp(m_opaque_ptr->GetAddress().GetModule());
 if (target_sp && module_sp) {
   lock = std::unique_lock(target_sp->GetAPIMutex());
   const bool force_live_memory = true;
diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp 
b/lldb/source/Breakpoint/BreakpointResolver.cpp
index 9643602d78c751..5fe544908c39e2 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -325,7 +325,7 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
   // If the line number is before the prologue end, move it there...
   bool skipped_prologue = false;
   if (skip_prologue && sc.function) {
-Address prologue_addr(sc.function->GetAddressRange(

[Lldb-commits] [lldb] [lldb] Add Function::GetAddress and redirect some uses (PR #115836)

2024-11-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

Many calls to Function::GetAddressRange() were not interested in the range 
itself. Instead they wanted to find the address of the function (its entry 
point) or the base address for relocation of function-scoped entities 
(technically, the two don't need to be the same, but there's isn't good reason 
for them not to be). This PR creates a separate function for retrieving this, 
and changes the existing (non-controversial) uses to call that instead.

---

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


22 Files Affected:

- (modified) lldb/include/lldb/Symbol/Function.h (+5) 
- (modified) lldb/source/API/SBBlock.cpp (+1-2) 
- (modified) lldb/source/API/SBFunction.cpp (+1-2) 
- (modified) lldb/source/Breakpoint/BreakpointResolver.cpp (+1-1) 
- (modified) lldb/source/Breakpoint/BreakpointResolverName.cpp (+1-1) 
- (modified) lldb/source/Core/SearchFilter.cpp (+1-1) 
- (modified) lldb/source/Expression/DWARFExpressionList.cpp (+1-2) 
- (modified) lldb/source/Expression/IRExecutionUnit.cpp (+1-2) 
- (modified) lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp (+1-1) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+2-4) 
- (modified) 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (+1-2) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
(+2-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
(+1-2) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
(+4-8) 
- (modified) lldb/source/Symbol/Block.cpp (+6-8) 
- (modified) lldb/source/Symbol/Function.cpp (+13-6) 
- (modified) lldb/source/Symbol/SymbolContext.cpp (+3-7) 
- (modified) lldb/source/Symbol/Variable.cpp (+3-5) 
- (modified) lldb/source/Target/StackFrame.cpp (+1-2) 
- (modified) lldb/source/Target/ThreadPlanStepInRange.cpp (+1-1) 
- (modified) lldb/source/ValueObject/ValueObjectVariable.cpp (+1-2) 


``diff
diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index bbfc25fe74ea06..dd4226f300c377 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -446,6 +446,11 @@ class Function : public UserID, public SymbolContextScope {
 
   const AddressRange &GetAddressRange() { return m_range; }
 
+  /// Return the address of the function (its entry point). This address is 
also
+  /// used as a base address for relocation of function-scope entities (blocks
+  /// and variables).
+  Address GetAddress() const;
+
   lldb::LanguageType GetLanguage() const;
   /// Find the file and line number of the source location of the start of the
   /// function.  This will use the declaration if present and fall back on the
diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp
index b921ccd9802454..2ef4cc7227cf95 100644
--- a/lldb/source/API/SBBlock.cpp
+++ b/lldb/source/API/SBBlock.cpp
@@ -176,8 +176,7 @@ bool SBBlock::GetDescription(SBStream &description) {
 m_opaque_ptr->CalculateSymbolContext(&sc);
 if (sc.function) {
   m_opaque_ptr->DumpAddressRanges(
-  &strm,
-  sc.function->GetAddressRange().GetBaseAddress().GetFileAddress());
+  &strm, sc.function->GetAddress().GetFileAddress());
 }
   } else
 strm.PutCString("No value");
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index ac61220ec8736a..91f5e243af4144 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -119,8 +119,7 @@ SBInstructionList SBFunction::GetInstructions(SBTarget 
target,
   if (m_opaque_ptr) {
 TargetSP target_sp(target.GetSP());
 std::unique_lock lock;
-ModuleSP module_sp(
-m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule());
+ModuleSP module_sp(m_opaque_ptr->GetAddress().GetModule());
 if (target_sp && module_sp) {
   lock = std::unique_lock(target_sp->GetAPIMutex());
   const bool force_live_memory = true;
diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp 
b/lldb/source/Breakpoint/BreakpointResolver.cpp
index 9643602d78c751..5fe544908c39e2 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -325,7 +325,7 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
   // If the line number is before the prologue end, move it there...
   bool skipped_prologue = false;
   if (skip_prologue && sc.function) {
-Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
+Address prologue_addr = sc.function->GetAddress();
 if (prologue_addr.IsValid() && (line_start == prologue_addr)) {
   const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize()

[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add Extension to Save a thread and N pointers deep (PR #111601)

2024-11-12 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] e5ba117 - [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (#115933)

2024-11-12 Thread via lldb-commits

Author: John Harrison
Date: 2024-11-12T13:19:17-08:00
New Revision: e5ba11727437456fbab7ce733c07843bf682fa0c

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

LOG: [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (#115933)

This refactor removes g_dap references from lldb-dap/LLDBUtils.{h,cpp}
to allow us to create more than one g_dap instance in the future.

Added: 


Modified: 
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/LLDBUtils.cpp
lldb/tools/lldb-dap/LLDBUtils.h
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index e45f9bf359e5bf..10d2d5d79a74bf 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -548,7 +548,7 @@ bool DAP::RunLLDBCommands(llvm::StringRef prefix,
   llvm::ArrayRef commands) {
   bool required_command_failed = false;
   std::string output =
-  ::RunLLDBCommands(prefix, commands, required_command_failed);
+  ::RunLLDBCommands(debugger, prefix, commands, required_command_failed);
   SendOutput(OutputType::Console, output);
   return !required_command_failed;
 }

diff  --git a/lldb/tools/lldb-dap/LLDBUtils.cpp 
b/lldb/tools/lldb-dap/LLDBUtils.cpp
index 2ffcba7dff4f24..48b63b59e0e3fe 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.cpp
+++ b/lldb/tools/lldb-dap/LLDBUtils.cpp
@@ -15,7 +15,7 @@
 
 namespace lldb_dap {
 
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives) {
   if (commands.empty())
@@ -23,7 +23,7 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 
   bool did_print_prefix = false;
 
-  lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter();
+  lldb::SBCommandInterpreter interp = debugger.GetCommandInterpreter();
   for (llvm::StringRef command : commands) {
 lldb::SBCommandReturnObject result;
 bool quiet_on_success = false;
@@ -78,23 +78,23 @@ bool RunLLDBCommands(llvm::StringRef prefix,
   return true;
 }
 
-std::string RunLLDBCommands(llvm::StringRef prefix,
+std::string RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands,
 bool &required_command_failed,
 bool parse_command_directives) {
   required_command_failed = false;
   std::string s;
   llvm::raw_string_ostream strm(s);
-  required_command_failed =
-  !RunLLDBCommands(prefix, commands, strm, parse_command_directives);
+  required_command_failed = !RunLLDBCommands(debugger, prefix, commands, strm,
+ parse_command_directives);
   return s;
 }
 
 std::string
-RunLLDBCommandsVerbatim(llvm::StringRef prefix,
+RunLLDBCommandsVerbatim(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands) {
   bool required_command_failed = false;
-  return RunLLDBCommands(prefix, commands, required_command_failed,
+  return RunLLDBCommands(debugger, prefix, commands, required_command_failed,
  /*parse_command_directives=*/false);
 }
 

diff  --git a/lldb/tools/lldb-dap/LLDBUtils.h b/lldb/tools/lldb-dap/LLDBUtils.h
index d5072d19029a1e..a9e13bb3678dac 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.h
+++ b/lldb/tools/lldb-dap/LLDBUtils.h
@@ -10,6 +10,7 @@
 #define LLDB_TOOLS_LLDB_DAP_LLDBUTILS_H
 
 #include "DAPForward.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
@@ -30,6 +31,9 @@ namespace lldb_dap {
 /// emitted regardless, and \b false is returned without executing the
 /// remaining commands.
 ///
+/// \param[in] debugger
+/// The debugger that will execute the lldb commands.
+///
 /// \param[in] prefix
 /// A string that will be printed into \a strm prior to emitting
 /// the prompt + command and command output. Can be NULL.
@@ -48,7 +52,7 @@ namespace lldb_dap {
 /// \return
 /// \b true, unless a command prefixed with \b ! fails and parsing of
 /// command directives is enabled.
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives);
 
@@ -57,6 +61,9 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 /// All output from every command, including the prompt + the command
 /// is returned in the std::string return value.
 ///
+/// \param[in] debugger
+/// The debugger that will ex

[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][ProcessELFCore] Add Description to ProcessELFCore/ELFThread stop reasons (PR #110065)

2024-11-12 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #112079)

2024-11-12 Thread Robert O'Callahan via lldb-commits

rocallahan wrote:

> I worry that in a situation like this where there's a pending task people 
> will go the wrong way and lose important state because they forgot that 
> "continue" doesn't mean "continue what I was doing" - which is what it 
> currently means in lldb

I don't know of any other debugger that supports the equivalent of a thread 
plan stack, and even though I've been neck-deep in debuggers for a long time I 
didn't know about this LLDB feature until I started working on this PR, so TBH 
I think most users will assume "continue" works like any other debugger and 
just resumes execution forwards, and are surprised (hopefully in a good way) 
if/when they discover it's more complicated than that. And therefore will be 
surprised in a bad way if/when they discover that "continue" runs backwards in 
some situations.

> I think ultimately I'm arguing against requiring: "we either have all forward 
> or all backwards plans on any given thread plan stack" because I don't think 
> that is flexible enough to support all the use cases we want to support.

I agree and as I said above, I've already removed that requirement in my 
experimental branch. I haven't added a notion of "no-direction-opinion" plans 
yet, but most of what you said above makes sense even if we don't have that.

Let's consider a really simple case where the user does a reverse-continue, 
hits an unconditional breakpoint, and then wants to execute forwards. One 
question is, what command should they use to execute forwards? I've been 
assuming that they would just use `process continue`, but if you really want 
`process continue` to resume the reverse-continue and we should have a separate 
command or flag to switch to forwards, we can do that. We should probably 
settle this now because it's quite fundamental.

The other question is, what should the thread plan stacks look like during this 
scenario?

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


[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread Michael Buch via lldb-commits


@@ -0,0 +1,8 @@
+#include "artificial_location.h"
+
+int A::foo() {
+#line 0

Michael137 wrote:

FYI there's some discussion about this test going on in 
https://github.com/llvm/llvm-project/pull/107849, in case you had some thoughts 
on Jeremy's points

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


[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Jonas Devlieghere via lldb-commits


@@ -288,8 +288,15 @@ Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t 
load_addr,
   MemoryRegionInfo ®ion) {
   Status error;
   if (auto region_or_err =
-  GetInterface().GetMemoryRegionContainingAddress(load_addr, error))
+  GetInterface().GetMemoryRegionContainingAddress(load_addr, error)) {
 region = *region_or_err;
+if (region.GetRange().GetRangeBase() == 0 &&
+(region.GetRange().GetByteSize() == 0 ||
+ region.GetRange().GetByteSize() == LLDB_INVALID_ADDRESS)) {

JDevlieghere wrote:

Why would the size be `LLDB_INVALID_ADDRESS`? Did you mean to check that the 
range base isn't `LLDB_INVALID_ADDRESS`? 

Is this the condition you want?

```
(region.GetRange().GetRangeBase() == 0 || region.GetRange().GetRangeBase() == 
LLDB_INVALID_ADDRESS) && region.GetRange().GetByteSize() == 0) 
```

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


[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap/DAP.{h, cpp} to use its own instance instead of the global instance. (PR #115948)

2024-11-12 Thread Adrian Vogelsgesang via lldb-commits

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


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


[Lldb-commits] [libcxx] [lldb] Unify naming of internal pointer members in std::vector and std::__split_buffer (PR #115517)

2024-11-12 Thread Peng Liu via lldb-commits

https://github.com/winner245 updated 
https://github.com/llvm/llvm-project/pull/115517

>From 29ef4c6b2fae47a68bc9e59343fc18527c09fb1d Mon Sep 17 00:00:00 2001
From: Peng Liu 
Date: Fri, 8 Nov 2024 11:52:29 -0500
Subject: [PATCH 1/3] Unify naming of internal pointer members in std::vector
 and std::__split_buffer

---
 libcxx/include/__split_buffer| 62 
 libcxx/include/__vector/vector.h |  4 +--
 libcxx/include/deque |  8 ++---
 3 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index 2a2f2625c748b2..419eee23882547 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -47,7 +47,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 // __split_buffer allocates a contiguous chunk of memory and stores objects in 
the range [__begin_, __end_).
-// It has uninitialized memory in the ranges  [__first_, __begin_) and 
[__end_, __end_cap_.first()). That allows
+// It has uninitialized memory in the ranges  [__first_, __begin_) and 
[__end_, __cap_). That allows
 // it to grow both in the front and back without having to move the data.
 
 template  >
@@ -78,20 +78,20 @@ public:
   pointer __first_;
   pointer __begin_;
   pointer __end_;
-  _LIBCPP_COMPRESSED_PAIR(pointer, __end_cap_, allocator_type, __alloc_);
+  _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_);
 
   __split_buffer(const __split_buffer&)= delete;
   __split_buffer& operator=(const __split_buffer&) = delete;
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer()
   _NOEXCEPT_(is_nothrow_default_constructible::value)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) 
{}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit 
__split_buffer(__alloc_rr& __a)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr), __alloc_(__a) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__cap_(nullptr), __alloc_(__a) {}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit 
__split_buffer(const __alloc_rr& __a)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr), __alloc_(__a) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__cap_(nullptr), __alloc_(__a) {}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
   __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
@@ -123,7 +123,7 @@ public:
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { 
return __end_ == __begin_; }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() 
const {
-return static_cast(__end_cap_ - __first_);
+return static_cast(__cap_ - __first_);
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type 
__front_spare() const {
@@ -131,7 +131,7 @@ public:
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() 
const {
-return static_cast(__end_cap_ - __end_);
+return static_cast(__cap_ - __end_);
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { 
return *__begin_; }
@@ -219,14 +219,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, 
_Allocator>::__invariants
   return false;
 if (__end_ != nullptr)
   return false;
-if (__end_cap_ != nullptr)
+if (__cap_ != nullptr)
   return false;
   } else {
 if (__begin_ < __first_)
   return false;
 if (__end_ < __begin_)
   return false;
-if (__end_cap_ < __end_)
+if (__cap_ < __end_)
   return false;
   }
   return true;
@@ -273,8 +273,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void
 __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator 
__first, _Sentinel __last) {
   __alloc_rr& __a = __alloc_;
   for (; __first != __last; ++__first) {
-if (__end_ == __end_cap_) {
-  size_type __old_cap = __end_cap_ - __first_;
+if (__end_ == __cap_) {
+  size_type __old_cap = __cap_ - __first_;
   size_type __new_cap = std::max(2 * __old_cap, 8);
   __split_buffer __buf(__new_cap, 0, __a);
   for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_)
@@ -331,7 +331,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer 
__new_last, true_type
 template 
 _LIBCPP_CONSTEXPR_SINCE_CXX20
 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type 
__start, __alloc_rr& __a)
-: __end_cap_(nullptr), __alloc_(__a) {
+: __cap_(nullptr), __alloc_(__a) {
   if (__cap == 0) {
 __first_ = nullptr;
   } else {
@@ -340,7 +340,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type 
__cap, size_type __sta
 __cap = __allocation.count;
   }
   __begin_ = __end_ = __first_ + __start;
-  __end_cap_= __fi

[Lldb-commits] [libcxx] [lldb] Unify naming of internal pointer members in std::vector and std::__split_buffer (PR #115517)

2024-11-12 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
3431d133ccfa75d16964be455238e2a1da0c2004...6e51b126cc760188925f8925325a7a90c193451a
 lldb/examples/synthetic/libcxx.py
``





View the diff from darker here.


``diff
--- libcxx.py   2024-11-12 21:44:45.00 +
+++ libcxx.py   2024-11-12 21:50:10.272888 +
@@ -764,11 +764,11 @@
 map_.GetChildMemberWithName("__end_cap_")
 )
 else:
 map_endcap = map_.GetChildMemberWithName("__cap_")
 if not map_endcap.IsValid():
-  map_endcap = map_.GetChildMemberWithName("__end_cap_")
+map_endcap = map_.GetChildMemberWithName("__end_cap_")
 map_endcap = map_endcap.GetValueAsUnsigned(0)
 
 # check consistency
 if not map_first <= map_begin <= map_end <= map_endcap:
 logger.write("map pointers are not monotonic")

``




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


[Lldb-commits] [libcxx] [lldb] Unify naming of internal pointer members in std::vector and std::__split_buffer (PR #115517)

2024-11-12 Thread Peng Liu via lldb-commits

https://github.com/winner245 updated 
https://github.com/llvm/llvm-project/pull/115517

>From 29ef4c6b2fae47a68bc9e59343fc18527c09fb1d Mon Sep 17 00:00:00 2001
From: Peng Liu 
Date: Fri, 8 Nov 2024 11:52:29 -0500
Subject: [PATCH 1/3] Unify naming of internal pointer members in std::vector
 and std::__split_buffer

---
 libcxx/include/__split_buffer| 62 
 libcxx/include/__vector/vector.h |  4 +--
 libcxx/include/deque |  8 ++---
 3 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index 2a2f2625c748b2..419eee23882547 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -47,7 +47,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 // __split_buffer allocates a contiguous chunk of memory and stores objects in 
the range [__begin_, __end_).
-// It has uninitialized memory in the ranges  [__first_, __begin_) and 
[__end_, __end_cap_.first()). That allows
+// It has uninitialized memory in the ranges  [__first_, __begin_) and 
[__end_, __cap_). That allows
 // it to grow both in the front and back without having to move the data.
 
 template  >
@@ -78,20 +78,20 @@ public:
   pointer __first_;
   pointer __begin_;
   pointer __end_;
-  _LIBCPP_COMPRESSED_PAIR(pointer, __end_cap_, allocator_type, __alloc_);
+  _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_);
 
   __split_buffer(const __split_buffer&)= delete;
   __split_buffer& operator=(const __split_buffer&) = delete;
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer()
   _NOEXCEPT_(is_nothrow_default_constructible::value)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) 
{}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit 
__split_buffer(__alloc_rr& __a)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr), __alloc_(__a) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__cap_(nullptr), __alloc_(__a) {}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit 
__split_buffer(const __alloc_rr& __a)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr), __alloc_(__a) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__cap_(nullptr), __alloc_(__a) {}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
   __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
@@ -123,7 +123,7 @@ public:
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { 
return __end_ == __begin_; }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() 
const {
-return static_cast(__end_cap_ - __first_);
+return static_cast(__cap_ - __first_);
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type 
__front_spare() const {
@@ -131,7 +131,7 @@ public:
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() 
const {
-return static_cast(__end_cap_ - __end_);
+return static_cast(__cap_ - __end_);
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { 
return *__begin_; }
@@ -219,14 +219,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, 
_Allocator>::__invariants
   return false;
 if (__end_ != nullptr)
   return false;
-if (__end_cap_ != nullptr)
+if (__cap_ != nullptr)
   return false;
   } else {
 if (__begin_ < __first_)
   return false;
 if (__end_ < __begin_)
   return false;
-if (__end_cap_ < __end_)
+if (__cap_ < __end_)
   return false;
   }
   return true;
@@ -273,8 +273,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void
 __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator 
__first, _Sentinel __last) {
   __alloc_rr& __a = __alloc_;
   for (; __first != __last; ++__first) {
-if (__end_ == __end_cap_) {
-  size_type __old_cap = __end_cap_ - __first_;
+if (__end_ == __cap_) {
+  size_type __old_cap = __cap_ - __first_;
   size_type __new_cap = std::max(2 * __old_cap, 8);
   __split_buffer __buf(__new_cap, 0, __a);
   for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_)
@@ -331,7 +331,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer 
__new_last, true_type
 template 
 _LIBCPP_CONSTEXPR_SINCE_CXX20
 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type 
__start, __alloc_rr& __a)
-: __end_cap_(nullptr), __alloc_(__a) {
+: __cap_(nullptr), __alloc_(__a) {
   if (__cap == 0) {
 __first_ = nullptr;
   } else {
@@ -340,7 +340,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type 
__cap, size_type __sta
 __cap = __allocation.count;
   }
   __begin_ = __end_ = __first_ + __start;
-  __end_cap_= __fi

[Lldb-commits] [lldb] fix: Target Process may crash on detaching process on windows (PR #115712)

2024-11-12 Thread via lldb-commits

anatawa12 wrote:

I looked the process in suspended state with sysinternal process explorer and I 
found all threads have exactly one suspend count.
Therefore, I added logs to calling [SuspendThread] and [ResumeThread] and I 
found those calls are unbalanced exactly one for each thread so I think #67825 
and #89077 are about calling [ResumeThread] and completely different problem.
I'm interested in #67825 but this is completely different bug so I'm going to 
create another Pull Request when I reached to fix.

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


[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/115963

>From f8f1d70d1d9eac6d36c0fa84e2a94c032385da39 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Tue, 12 Nov 2024 15:55:15 -0800
Subject: [PATCH 1/2] [lldb] Handle an empty SBMemoryRegionInfo from scripted
 process

A scripted process implementation might return an SBMemoryRegionInfo
object in its implementation of `get_memory_region_containing_address`
which will have an address 0 and size 0, without realizing the
problems this can cause.  One problem happens when an expression
is run, and lldb needs to find part of the target's virtual address
space to store the result (actually stored in lldb's host memory),
it uses IRMemoryMap::FindSpace() to do that.  If the process supports
GetMemoryRegionInfo, FindSpace will step through the allocated
memory ranges looking for an unused one.  But if every request is
a memory region with address 0 + size 0, this loop will never
terminate.  Detect this kind of response from a scripted process
plugin and return an error, so callers iterating over the address
space can exit.

Added a test where I copied dummy_scripted_process.py from the
TestScriptedProcess.py existing test, and added a bad
`get_memory_region_containing_address` implementation.

rdar://139678032
---
 .../Process/scripted/ScriptedProcess.cpp  |   9 +-
 .../Makefile  |   3 +
 .../TestScriptedProcessEmptyMemoryRegion.py   |  33 +
 .../dummy_scripted_process.py | 137 ++
 .../main.c|   1 +
 5 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/dummy_scripted_process.py
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/main.c

diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index d2111ce877ce55..c56e24a4ebd188 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -288,8 +288,15 @@ Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t 
load_addr,
   MemoryRegionInfo ®ion) {
   Status error;
   if (auto region_or_err =
-  GetInterface().GetMemoryRegionContainingAddress(load_addr, error))
+  GetInterface().GetMemoryRegionContainingAddress(load_addr, error)) {
 region = *region_or_err;
+if (region.GetRange().GetRangeBase() == 0 &&
+(region.GetRange().GetByteSize() == 0 ||
+ region.GetRange().GetByteSize() == LLDB_INVALID_ADDRESS)) {
+  error = Status::FromErrorString(
+  "Invalid memory region from scripted process");
+}
+  }
 
   return error;
 }
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
new file mode 100644
index 00..10495940055b63
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
new file mode 100644
index 00..1ff084cfb0278e
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
@@ -0,0 +1,33 @@
+"""
+Test python scripted process which returns an empty SBMemoryRegionInfo
+"""
+
+import os, shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbtest
+
+
+class ScriptedProcessEmptyMemoryRegion(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_scripted_process_empty_memory_region(self):
+"""Test that lldb handles an empty SBMemoryRegionInfo object from
+a scripted process plugin."""
+self.build()
+
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.assertTrue(target, VALID_TARGET)
+
+scripted_process_example_relpath = "dummy_scripted_process.py"
+self.runCmd(
+"command script import "
++ os.path.join(self.getSourceDir(), 
scripted_process_example_relpath)
+)
+
+self.expect("memory region 0", error=True, substrs=["Invalid memory 
region"])
+
+self.expect("expr -- 5", substrs=["5"])
diff --git 
a/lldb/test/API/f

[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Jason Molenda via lldb-commits


@@ -288,8 +288,15 @@ Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t 
load_addr,
   MemoryRegionInfo ®ion) {
   Status error;
   if (auto region_or_err =
-  GetInterface().GetMemoryRegionContainingAddress(load_addr, error))
+  GetInterface().GetMemoryRegionContainingAddress(load_addr, error)) {
 region = *region_or_err;
+if (region.GetRange().GetRangeBase() == 0 &&
+(region.GetRange().GetByteSize() == 0 ||
+ region.GetRange().GetByteSize() == LLDB_INVALID_ADDRESS)) {

jasonmolenda wrote:

I'm not wedded to it.  I'm still debating moving both of these checks up in to 
Process::GetMemoryRegionInfo.  I haven't done it yet for fear of unintended 
consequences, but any memory region info response that claims 0 bytes or the 
entire address space is meaningless.

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


[Lldb-commits] [lldb] [lldb][test] Fix remote Shell tests failures on Windows host (PR #115716)

2024-11-12 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap/DAP.{h, cpp} to use its own instance instead of the global instance. (PR #115948)

2024-11-12 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Support true/false in ValueObject::SetValueFromCString (PR #115780)

2024-11-12 Thread Jonas Devlieghere via lldb-commits

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

>From 3450bca62abbc0e9595b61f663114cd67927ffaf Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 11 Nov 2024 14:17:17 -0800
Subject: [PATCH 1/3] [lldb] Support true/false in
 ValueObject::SetValueFromCString

Support "true" and "false" (and "YES" and "NO" in Objective-C) in
ValueObject::SetValueFromCString.

Fixes #112597
---
 lldb/include/lldb/Target/Language.h |  4 +++-
 .../Plugins/Language/ObjC/ObjCLanguage.cpp  |  8 
 .../source/Plugins/Language/ObjC/ObjCLanguage.h |  3 +++
 .../ObjCPlusPlus/ObjCPlusPlusLanguage.cpp   |  8 
 .../ObjCPlusPlus/ObjCPlusPlusLanguage.h |  3 +++
 lldb/source/Target/Language.cpp |  8 
 lldb/source/ValueObject/ValueObject.cpp | 15 +++
 .../data-formatter/setvaluefromcstring/main.m   |  7 ++-
 .../value/change_values/TestChangeValueAPI.py   | 17 +++--
 .../API/python_api/value/change_values/main.c   | 15 +--
 10 files changed, 78 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index c9cddee6baa2da..38ca458159edc7 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -245,7 +245,7 @@ class Language : public PluginInterface {
   // a match.  But we wouldn't want this to match AnotherA::my_function.  The
   // user is specifying a truncated path, not a truncated set of characters.
   // This function does a language-aware comparison for those purposes.
-  virtual bool DemangledNameContainsPath(llvm::StringRef path, 
+  virtual bool DemangledNameContainsPath(llvm::StringRef path,
  ConstString demangled) const;
 
   // if a language has a custom format for printing variable declarations that
@@ -372,6 +372,8 @@ class Language : public PluginInterface {
 return {};
   }
 
+  virtual std::optional GetBooleanFromString(llvm::StringRef str) const;
+
   /// Returns true if this Language supports exception breakpoints on throw via
   /// a corresponding LanguageRuntime plugin.
   virtual bool SupportsExceptionBreakpointsOnThrow() const { return false; }
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index b44971e36c6d0e..2ae203405cbba0 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -1040,3 +1040,11 @@ bool ObjCLanguage::IsSourceFile(llvm::StringRef 
file_path) const {
   }
   return false;
 }
+
+std::optional
+ObjCLanguage::GetBooleanFromString(llvm::StringRef str) const {
+  return llvm::StringSwitch>(str)
+  .Case("YES", {true})
+  .Case("NO", {false})
+  .Default({});
+}
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index d9c0cd3c18cfa1..6d265a9be52771 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -194,6 +194,9 @@ class ObjCLanguage : public Language {
 
   llvm::StringRef GetInstanceVariableName() override { return "self"; }
 
+  virtual std::optional
+  GetBooleanFromString(llvm::StringRef str) const override;
+
   bool SupportsExceptionBreakpointsOnThrow() const override { return true; }
 
   // PluginInterface protocol
diff --git a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
index 79830e529df2d7..0489f4d6ada321 100644
--- a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
@@ -43,3 +43,11 @@ Language 
*ObjCPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
 return nullptr;
   }
 }
+
+std::optional
+ObjCPlusPlusLanguage::GetBooleanFromString(llvm::StringRef str) const {
+  return llvm::StringSwitch>(str)
+  .Cases("true", "YES", {true})
+  .Cases("false", "NO", {false})
+  .Default({});
+}
diff --git a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h 
b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
index 1beab9348eb72e..229dffe8462e41 100644
--- a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
@@ -44,6 +44,9 @@ class ObjCPlusPlusLanguage : public Language {
 
   llvm::StringRef GetInstanceVariableName() override { return "self"; }
 
+  virtual std::optional
+  GetBooleanFromString(llvm::StringRef str) const override;
+
   static llvm::StringRef GetPluginNameStatic() { return "objcplusplus"; }
 
   // PluginInterface protocol
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index d0bffe441f6395..a75894ffa4b3b6 100644
--- a/lldb/source/Target/Language.cpp
+++ 

[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap/DAP.{h, cpp} to use its own instance instead of the global instance. (PR #115948)

2024-11-12 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support true/false in ValueObject::SetValueFromCString (PR #115780)

2024-11-12 Thread via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] fix: Target Process may crash on detaching process on windows (PR #115712)

2024-11-12 Thread via lldb-commits

https://github.com/anatawa12 updated 
https://github.com/llvm/llvm-project/pull/115712

>From cabe26fc14cb4a924b2aebe6f3dd080408fed6ce Mon Sep 17 00:00:00 2001
From: anatawa12 
Date: Mon, 11 Nov 2024 20:22:33 +0900
Subject: [PATCH 1/3] fix: Target Process may crash on detaching process

---
 .../Process/Windows/Common/DebuggerThread.cpp | 45 ---
 .../Process/Windows/Common/DebuggerThread.h   |  2 +-
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp 
b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
index ca8e9c078e1f99..ac63997abe823d 100644
--- a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
@@ -239,12 +239,13 @@ void DebuggerThread::DebugLoop() {
 BOOL wait_result = WaitForDebugEvent(&dbe, INFINITE);
 if (wait_result) {
   DWORD continue_status = DBG_CONTINUE;
+  bool shutting_down = m_is_shutting_down;
   switch (dbe.dwDebugEventCode) {
   default:
 llvm_unreachable("Unhandle debug event code!");
   case EXCEPTION_DEBUG_EVENT: {
-ExceptionResult status =
-HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId);
+ExceptionResult status = HandleExceptionEvent(
+dbe.u.Exception, dbe.dwThreadId, shutting_down);
 
 if (status == ExceptionResult::MaskException)
   continue_status = DBG_CONTINUE;
@@ -292,6 +293,25 @@ void DebuggerThread::DebugLoop() {
 
   ::ContinueDebugEvent(dbe.dwProcessId, dbe.dwThreadId, continue_status);
 
+  // We have to DebugActiveProcessStop after ContinueDebugEvent, otherwise
+  // the target process will crash
+  if (shutting_down) {
+// A breakpoint that occurs while `m_pid_to_detach` is non-zero is a
+// magic exception that we use simply to wake up the DebuggerThread so
+// that we can close out the debug loop.
+if (m_pid_to_detach != 0 &&
+(dbe.u.Exception.ExceptionRecord.ExceptionCode ==
+ EXCEPTION_BREAKPOINT ||
+ dbe.u.Exception.ExceptionRecord.ExceptionCode ==
+ STATUS_WX86_BREAKPOINT)) {
+  LLDB_LOG(log,
+   "Breakpoint exception is cue to detach from process {0:x}",
+   m_pid_to_detach.load());
+  ::DebugActiveProcessStop(m_pid_to_detach);
+  m_detached = true;
+}
+  }
+
   if (m_detached) {
 should_debug = false;
   }
@@ -310,25 +330,18 @@ void DebuggerThread::DebugLoop() {
 
 ExceptionResult
 DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
- DWORD thread_id) {
+ DWORD thread_id, bool shutting_down) {
   Log *log = GetLog(WindowsLog::Event | WindowsLog::Exception);
-  if (m_is_shutting_down) {
-// A breakpoint that occurs while `m_pid_to_detach` is non-zero is a magic
-// exception that
-// we use simply to wake up the DebuggerThread so that we can close out the
-// debug loop.
-if (m_pid_to_detach != 0 &&
+  if (shutting_down) {
+bool is_breakpoint =
 (info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT ||
- info.ExceptionRecord.ExceptionCode == STATUS_WX86_BREAKPOINT)) {
-  LLDB_LOG(log, "Breakpoint exception is cue to detach from process {0:x}",
-   m_pid_to_detach.load());
-  ::DebugActiveProcessStop(m_pid_to_detach);
-  m_detached = true;
-}
+ info.ExceptionRecord.ExceptionCode == STATUS_WX86_BREAKPOINT);
 
 // Don't perform any blocking operations while we're shutting down.  That
 // will cause TerminateProcess -> WaitForSingleObject to time out.
-return ExceptionResult::SendToApplication;
+// We should not send breakpoint exceptions to the application.
+return is_breakpoint ? ExceptionResult::MaskException
+ : ExceptionResult::SendToApplication;
   }
 
   bool first_chance = (info.dwFirstChance != 0);
diff --git a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.h 
b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.h
index e3439ff34584be..5960237b778673 100644
--- a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.h
+++ b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.h
@@ -46,7 +46,7 @@ class DebuggerThread : public 
std::enable_shared_from_this {
   void FreeProcessHandles();
   void DebugLoop();
   ExceptionResult HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
-   DWORD thread_id);
+   DWORD thread_id, bool shutting_down);
   DWORD HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info,
 DWORD thread_id);
   DWORD HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info,

>From 2138286671d92f3959eb0d05697f3b1cb4a6a232 Mon 

[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread Med Ismail Bennani via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/115963

>From f8f1d70d1d9eac6d36c0fa84e2a94c032385da39 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Tue, 12 Nov 2024 15:55:15 -0800
Subject: [PATCH 1/3] [lldb] Handle an empty SBMemoryRegionInfo from scripted
 process

A scripted process implementation might return an SBMemoryRegionInfo
object in its implementation of `get_memory_region_containing_address`
which will have an address 0 and size 0, without realizing the
problems this can cause.  One problem happens when an expression
is run, and lldb needs to find part of the target's virtual address
space to store the result (actually stored in lldb's host memory),
it uses IRMemoryMap::FindSpace() to do that.  If the process supports
GetMemoryRegionInfo, FindSpace will step through the allocated
memory ranges looking for an unused one.  But if every request is
a memory region with address 0 + size 0, this loop will never
terminate.  Detect this kind of response from a scripted process
plugin and return an error, so callers iterating over the address
space can exit.

Added a test where I copied dummy_scripted_process.py from the
TestScriptedProcess.py existing test, and added a bad
`get_memory_region_containing_address` implementation.

rdar://139678032
---
 .../Process/scripted/ScriptedProcess.cpp  |   9 +-
 .../Makefile  |   3 +
 .../TestScriptedProcessEmptyMemoryRegion.py   |  33 +
 .../dummy_scripted_process.py | 137 ++
 .../main.c|   1 +
 5 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/dummy_scripted_process.py
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/main.c

diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index d2111ce877ce55..c56e24a4ebd188 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -288,8 +288,15 @@ Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t 
load_addr,
   MemoryRegionInfo ®ion) {
   Status error;
   if (auto region_or_err =
-  GetInterface().GetMemoryRegionContainingAddress(load_addr, error))
+  GetInterface().GetMemoryRegionContainingAddress(load_addr, error)) {
 region = *region_or_err;
+if (region.GetRange().GetRangeBase() == 0 &&
+(region.GetRange().GetByteSize() == 0 ||
+ region.GetRange().GetByteSize() == LLDB_INVALID_ADDRESS)) {
+  error = Status::FromErrorString(
+  "Invalid memory region from scripted process");
+}
+  }
 
   return error;
 }
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
new file mode 100644
index 00..10495940055b63
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
new file mode 100644
index 00..1ff084cfb0278e
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
@@ -0,0 +1,33 @@
+"""
+Test python scripted process which returns an empty SBMemoryRegionInfo
+"""
+
+import os, shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbtest
+
+
+class ScriptedProcessEmptyMemoryRegion(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_scripted_process_empty_memory_region(self):
+"""Test that lldb handles an empty SBMemoryRegionInfo object from
+a scripted process plugin."""
+self.build()
+
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.assertTrue(target, VALID_TARGET)
+
+scripted_process_example_relpath = "dummy_scripted_process.py"
+self.runCmd(
+"command script import "
++ os.path.join(self.getSourceDir(), 
scripted_process_example_relpath)
+)
+
+self.expect("memory region 0", error=True, substrs=["Invalid memory 
region"])
+
+self.expect("expr -- 5", substrs=["5"])
diff --git 
a/lldb/test/API/f

[Lldb-commits] [lldb] [LLDB] Add framework for Data Inspection Language (DIL) work. (PR #115666)

2024-11-12 Thread via lldb-commits

cmtice wrote:

I've updated the code as Jim and Pavel suggested. :-)

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


[Lldb-commits] [lldb] [lldb] Support true/false in ValueObject::SetValueFromCString (PR #115780)

2024-11-12 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)


Changes

A scripted process implementation might return an SBMemoryRegionInfo object in 
its implementation of `get_memory_region_containing_address` which will have an 
address 0 and size 0, without realizing the problems this can cause.  One 
problem happens when an expression is run, and lldb needs to find part of the 
target's virtual address space to store the result (actually stored in lldb's 
host memory), it uses IRMemoryMap::FindSpace() to do that.  If the process 
supports GetMemoryRegionInfo, FindSpace will step through the allocated memory 
ranges looking for an unused one.  But if every request is a memory region with 
address 0 + size 0, this loop will never terminate.  Detect this kind of 
response from a scripted process plugin and return an error, so callers 
iterating over the address space can exit.

Added a test where I copied dummy_scripted_process.py from the 
TestScriptedProcess.py existing test, and added a bad 
`get_memory_region_containing_address` implementation.

rdar://139678032

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


5 Files Affected:

- (modified) lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp (+8-1) 
- (added) 
lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile 
(+3) 
- (added) 
lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
 (+33) 
- (added) 
lldb/test/API/functionalities/scripted_process_empty_memory_region/dummy_scripted_process.py
 (+137) 
- (added) 
lldb/test/API/functionalities/scripted_process_empty_memory_region/main.c (+1) 


``diff
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index d2111ce877ce55..c56e24a4ebd188 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -288,8 +288,15 @@ Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t 
load_addr,
   MemoryRegionInfo ®ion) {
   Status error;
   if (auto region_or_err =
-  GetInterface().GetMemoryRegionContainingAddress(load_addr, error))
+  GetInterface().GetMemoryRegionContainingAddress(load_addr, error)) {
 region = *region_or_err;
+if (region.GetRange().GetRangeBase() == 0 &&
+(region.GetRange().GetByteSize() == 0 ||
+ region.GetRange().GetByteSize() == LLDB_INVALID_ADDRESS)) {
+  error = Status::FromErrorString(
+  "Invalid memory region from scripted process");
+}
+  }
 
   return error;
 }
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
new file mode 100644
index 00..10495940055b63
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
new file mode 100644
index 00..1ff084cfb0278e
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
@@ -0,0 +1,33 @@
+"""
+Test python scripted process which returns an empty SBMemoryRegionInfo
+"""
+
+import os, shutil
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbtest
+
+
+class ScriptedProcessEmptyMemoryRegion(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_scripted_process_empty_memory_region(self):
+"""Test that lldb handles an empty SBMemoryRegionInfo object from
+a scripted process plugin."""
+self.build()
+
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.assertTrue(target, VALID_TARGET)
+
+scripted_process_example_relpath = "dummy_scripted_process.py"
+self.runCmd(
+"command script import "
++ os.path.join(self.getSourceDir(), 
scripted_process_example_relpath)
+)
+
+self.expect("memory region 0", error=True, substrs=["Invalid memory 
region"])
+
+self.expect("expr -- 5", substrs=["5"])
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/dummy_scripted_process.py
 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/dummy_scripted_process.py
new file mode 100644
index 00..8ca828eef26f01
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/dummy_scripted_process.py
@@ -0,0 +1,137 @@
+import os, str

[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda created 
https://github.com/llvm/llvm-project/pull/115963

A scripted process implementation might return an SBMemoryRegionInfo object in 
its implementation of `get_memory_region_containing_address` which will have an 
address 0 and size 0, without realizing the problems this can cause.  One 
problem happens when an expression is run, and lldb needs to find part of the 
target's virtual address space to store the result (actually stored in lldb's 
host memory), it uses IRMemoryMap::FindSpace() to do that.  If the process 
supports GetMemoryRegionInfo, FindSpace will step through the allocated memory 
ranges looking for an unused one.  But if every request is a memory region with 
address 0 + size 0, this loop will never terminate.  Detect this kind of 
response from a scripted process plugin and return an error, so callers 
iterating over the address space can exit.

Added a test where I copied dummy_scripted_process.py from the 
TestScriptedProcess.py existing test, and added a bad 
`get_memory_region_containing_address` implementation.

rdar://139678032

>From f8f1d70d1d9eac6d36c0fa84e2a94c032385da39 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Tue, 12 Nov 2024 15:55:15 -0800
Subject: [PATCH] [lldb] Handle an empty SBMemoryRegionInfo from scripted
 process

A scripted process implementation might return an SBMemoryRegionInfo
object in its implementation of `get_memory_region_containing_address`
which will have an address 0 and size 0, without realizing the
problems this can cause.  One problem happens when an expression
is run, and lldb needs to find part of the target's virtual address
space to store the result (actually stored in lldb's host memory),
it uses IRMemoryMap::FindSpace() to do that.  If the process supports
GetMemoryRegionInfo, FindSpace will step through the allocated
memory ranges looking for an unused one.  But if every request is
a memory region with address 0 + size 0, this loop will never
terminate.  Detect this kind of response from a scripted process
plugin and return an error, so callers iterating over the address
space can exit.

Added a test where I copied dummy_scripted_process.py from the
TestScriptedProcess.py existing test, and added a bad
`get_memory_region_containing_address` implementation.

rdar://139678032
---
 .../Process/scripted/ScriptedProcess.cpp  |   9 +-
 .../Makefile  |   3 +
 .../TestScriptedProcessEmptyMemoryRegion.py   |  33 +
 .../dummy_scripted_process.py | 137 ++
 .../main.c|   1 +
 5 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/dummy_scripted_process.py
 create mode 100644 
lldb/test/API/functionalities/scripted_process_empty_memory_region/main.c

diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp 
b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index d2111ce877ce55..c56e24a4ebd188 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -288,8 +288,15 @@ Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t 
load_addr,
   MemoryRegionInfo ®ion) {
   Status error;
   if (auto region_or_err =
-  GetInterface().GetMemoryRegionContainingAddress(load_addr, error))
+  GetInterface().GetMemoryRegionContainingAddress(load_addr, error)) {
 region = *region_or_err;
+if (region.GetRange().GetRangeBase() == 0 &&
+(region.GetRange().GetByteSize() == 0 ||
+ region.GetRange().GetByteSize() == LLDB_INVALID_ADDRESS)) {
+  error = Status::FromErrorString(
+  "Invalid memory region from scripted process");
+}
+  }
 
   return error;
 }
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
new file mode 100644
index 00..10495940055b63
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
new file mode 100644
index 00..1ff084cfb0278e
--- /dev/null
+++ 
b/lldb/test/API/functionalities/scripted_process_empty_memory_region/TestScriptedProcessEmptyMemoryRegion.py
@@ -0,0 +1,33 @@
+"""
+Test python scripted process which returns an empty SBMemoryR

[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

I am uncertain where I should detect an improperly formatted memory range.  It 
could be in `Process::GetMemoryRegionInfo`, which would catch a bad gdb remote 
serial protocol response as well.  Or it could be localized to 
IRMemoryMap::FindSpace if we only wanted to avoid an infinite loop in that one 
place -- but there are other parts of the code that try to iterate over the 
address space in the target with these objects.  This patch adjusts it in the 
most specific place that fixed the issue I was looking at, to start with.

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


[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,137 @@
+import os, struct, signal
+
+from typing import Any, Dict
+
+import lldb
+from lldb.plugins.scripted_process import ScriptedProcess
+from lldb.plugins.scripted_process import ScriptedThread
+
+
+class DummyStopHook:
+def __init__(self, target, args):
+self.target = target
+self.args = args
+
+def handle_stop(self, exe_ctx, stream):
+print("My DummyStopHook triggered. Printing args: \n%s" % self.args)
+sp = exe_ctx.process.GetScriptedImplementation()
+sp.handled_stop = True
+
+
+class DummyScriptedProcess(ScriptedProcess):
+memory = None
+
+def __init__(self, exe_ctx: lldb.SBExecutionContext, args: 
lldb.SBStructuredData):
+super().__init__(exe_ctx, args)
+self.threads[0] = DummyScriptedThread(self, None)
+self.memory = {}
+addr = 0x5
+debugger = self.target.GetDebugger()
+index = debugger.GetIndexOfTarget(self.target)
+self.memory[addr] = "Hello, target " + str(index)
+self.handled_stop = False
+
+def read_memory_at_address(
+self, addr: int, size: int, error: lldb.SBError
+) -> lldb.SBData:
+data = lldb.SBData().CreateDataFromCString(
+self.target.GetByteOrder(), self.target.GetCodeByteSize(), 
self.memory[addr]
+)
+
+return data
+
+def get_memory_region_containing_address(
+self, addr: int
+) -> lldb.SBMemoryRegionInfo:
+return lldb.SBMemoryRegionInfo()
+
+def write_memory_at_address(self, addr, data, error):
+self.memory[addr] = data.GetString(error, 0)
+return len(self.memory[addr]) + 1
+
+def get_loaded_images(self):
+return self.loaded_images
+
+def get_process_id(self) -> int:
+return 42
+
+def should_stop(self) -> bool:
+return True
+
+def is_alive(self) -> bool:
+return True
+
+def get_scripted_thread_plugin(self):
+return DummyScriptedThread.__module__ + "." + 
DummyScriptedThread.__name__
+
+def my_super_secret_method(self):
+if hasattr(self, "my_super_secret_member"):
+return self.my_super_secret_member
+else:
+return None
+
+
+class DummyScriptedThread(ScriptedThread):
+def __init__(self, process, args):
+super().__init__(process, args)
+self.frames.append({"pc": 0x011B00})
+
+def get_thread_id(self) -> int:
+return 0x19
+
+def get_name(self) -> str:
+return DummyScriptedThread.__name__ + ".thread-1"
+
+def get_state(self) -> int:
+return lldb.eStateStopped
+
+def get_stop_reason(self) -> Dict[str, Any]:
+return {"type": lldb.eStopReasonTrace, "data": {}}
+
+def get_register_context(self) -> str:
+return struct.pack(
+"21Q",
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+8,
+9,
+10,
+11,
+12,
+13,
+14,
+15,
+16,
+17,
+18,
+19,
+20,
+21,
+)
+
+
+def __lldb_init_module(debugger, dict):
+# This is used when loading the script in an interactive debug session to
+# automatically, register the stop-hook and launch the scripted process.
+if not "SKIP_SCRIPTED_PROCESS_LAUNCH" in os.environ:
+debugger.HandleCommand(
+"target stop-hook add -k first -v 1 -k second -v 2 -P %s.%s"
+% (__name__, DummyStopHook.__name__)
+)
+debugger.HandleCommand(
+"process launch -C %s.%s" % (__name__, 
DummyScriptedProcess.__name__)
+)
+else:
+print(
+"Name of the class that will manage the scripted process: '%s.%s'"
+% (__name__, DummyScriptedProcess.__name__)
+)
+print(
+"Name of the class that will manage the stop-hook: '%s.%s'"
+% (__name__, DummyStopHook.__name__)
+)

medismailben wrote:

Or this

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


[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Med Ismail Bennani via lldb-commits

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

LGTM with comments.

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


[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,137 @@
+import os, struct, signal
+
+from typing import Any, Dict
+
+import lldb
+from lldb.plugins.scripted_process import ScriptedProcess
+from lldb.plugins.scripted_process import ScriptedThread
+
+
+class DummyStopHook:
+def __init__(self, target, args):
+self.target = target
+self.args = args
+
+def handle_stop(self, exe_ctx, stream):
+print("My DummyStopHook triggered. Printing args: \n%s" % self.args)
+sp = exe_ctx.process.GetScriptedImplementation()
+sp.handled_stop = True
+
+

medismailben wrote:

You shouldn't need this

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


[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap/DAP.{h, cpp} to use its own instance instead of the global instance. (PR #115948)

2024-11-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

The refactor will unblock us for creating multiple DAP instances.

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


3 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.cpp (+25-27) 
- (modified) lldb/tools/lldb-dap/DAP.h (+6) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+3-3) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 10d2d5d79a74bf..bdb24fc78cfb64 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -477,12 +477,12 @@ lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object 
&arguments) {
 
 llvm::json::Value DAP::CreateTopLevelScopes() {
   llvm::json::Array scopes;
-  scopes.emplace_back(CreateScope("Locals", VARREF_LOCALS,
-  g_dap.variables.locals.GetSize(), false));
+  scopes.emplace_back(
+  CreateScope("Locals", VARREF_LOCALS, variables.locals.GetSize(), false));
   scopes.emplace_back(CreateScope("Globals", VARREF_GLOBALS,
-  g_dap.variables.globals.GetSize(), false));
+  variables.globals.GetSize(), false));
   scopes.emplace_back(CreateScope("Registers", VARREF_REGS,
-  g_dap.variables.registers.GetSize(), false));
+  variables.registers.GetSize(), false));
   return llvm::json::Value(std::move(scopes));
 }
 
@@ -490,8 +490,8 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, 
std::string &expression,
  bool partial_expression) {
   // Check for the escape hatch prefix.
   if (!expression.empty() &&
-  llvm::StringRef(expression).starts_with(g_dap.command_escape_prefix)) {
-expression = expression.substr(g_dap.command_escape_prefix.size());
+  llvm::StringRef(expression).starts_with(command_escape_prefix)) {
+expression = expression.substr(command_escape_prefix.size());
 return ReplMode::Command;
   }
 
@@ -531,7 +531,7 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, 
std::string &expression,
   << "Warning: Expression '" << term
   << "' is both an LLDB command and variable. It will be evaluated as "
  "a variable. To evaluate the expression as an LLDB command, use '"
-  << g_dap.command_escape_prefix << "' as a prefix.\n";
+  << command_escape_prefix << "' as a prefix.\n";
 }
 
 // Variables take preference to commands in auto, since commands can always
@@ -901,7 +901,7 @@ bool StartDebuggingRequestHandler::DoExecute(
 return false;
   }
 
-  g_dap.SendReverseRequest(
+  dap.SendReverseRequest(
   "startDebugging",
   llvm::json::Object{{"request", request},
  {"configuration", std::move(*configuration)}},
@@ -925,7 +925,7 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   // If a new mode is not specified report the current mode.
   if (!command || llvm::StringRef(command[0]).empty()) {
 std::string mode;
-switch (g_dap.repl_mode) {
+switch (dap.repl_mode) {
 case ReplMode::Variable:
   mode = "variable";
   break;
@@ -946,11 +946,11 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   llvm::StringRef new_mode{command[0]};
 
   if (new_mode == "variable") {
-g_dap.repl_mode = ReplMode::Variable;
+dap.repl_mode = ReplMode::Variable;
   } else if (new_mode == "command") {
-g_dap.repl_mode = ReplMode::Command;
+dap.repl_mode = ReplMode::Command;
   } else if (new_mode == "auto") {
-g_dap.repl_mode = ReplMode::Auto;
+dap.repl_mode = ReplMode::Auto;
   } else {
 lldb::SBStream error_message;
 error_message.Printf("Invalid repl-mode '%s'. Expected one of 'variable', "
@@ -1022,7 +1022,7 @@ bool SendEventRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
 event.try_emplace("body", std::move(*body));
   }
 
-  g_dap.SendJSON(llvm::json::Value(std::move(event)));
+  dap.SendJSON(llvm::json::Value(std::move(event)));
   result.SetStatus(lldb::eReturnStatusSuccessFinishNoResult);
   return true;
 }
@@ -1031,14 +1031,13 @@ void DAP::SetFrameFormat(llvm::StringRef format) {
   if (format.empty())
 return;
   lldb::SBError error;
-  g_dap.frame_format = lldb::SBFormat(format.str().c_str(), error);
+  frame_format = lldb::SBFormat(format.str().c_str(), error);
   if (error.Fail()) {
-g_dap.SendOutput(
-OutputType::Console,
-llvm::formatv(
-"The provided frame format '{0}' couldn't be parsed: {1}\n", 
format,
-error.GetCString())
-.str());
+SendOutput(OutputType::Console,
+   llvm::formatv(
+   "The provided frame format '{0}' couldn't be parsed: {1}\n",
+   format, error.GetCString())
+   .str());
   }
 }
 
@@ -1046,14 +1045,13 @@ void DAP::SetThreadFormat(llvm::StringRef format) {
   if (f

[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #112079)

2024-11-12 Thread via lldb-commits

jimingham wrote:

> > I worry that in a situation like this where there's a pending task people 
> > will go the wrong way and lose important state because they forgot that 
> > "continue" doesn't mean "continue what I was doing" - which is what it 
> > currently means in lldb
> 
> I don't know of any other debugger that supports the equivalent of a thread 
> plan stack, and even though I've been neck-deep in debuggers for a long time 
> I didn't know about this LLDB feature until I started working on this PR, so 
> TBH I think most users will assume "continue" works like any other debugger 
> and just resumes execution forwards, and are surprised (hopefully in a good 
> way) if/when they discover it's more complicated than that. And therefore 
> will be surprised in a bad way if/when they discover that "continue" runs 
> backwards in some situations.

I added a description of how this works a while back to the Tutorial.  Once you 
get used to this behavior, it is SO handy.  All those times you were doing a 
"next" and hit a breakpoint somewhere deep under the next, and had to drive 
your way back out with "finish-es" plus hitting other breakpoints along the way 
gets replaced by `continue` till the next says it's done.  Once you get used to 
it working this way, it's hard to go back - at least in my experience...

But for this to be useful it has to be reliable.  If it doesn't work on you a 
couple of times, you're likely to go back to driving by hand as safer.

> 
> > I think ultimately I'm arguing against requiring: "we either have all 
> > forward or all backwards plans on any given thread plan stack" because I 
> > don't think that is flexible enough to support all the use cases we want to 
> > support.
> 
> I agree and as I said above, I've already removed that requirement in my 
> experimental branch. I haven't added a notion of "no-direction-opinion" plans 
> yet, but most of what you said above makes sense even if we don't have that.
> 

Cool!

> Let's consider a really simple case where the user does a reverse-continue, 
> hits an unconditional breakpoint, and then wants to execute forwards. One 
> question is, what command should they use to execute forwards? I've been 
> assuming that they would just use `process continue`, but if you really want 
> `process continue` to resume the reverse-continue and we should have a 
> separate command or flag to switch to forwards, we can do that. We should 
> probably settle this now because it's quite fundamental.

I expected that we would add a `--direction` to all the execution control 
commands that can go in either direction.  If you don't supply a `--direction`, 
it would be set to whatever the last execution control direction was.  That way 
if you were driving back into the past with a bunch of continues, you would 
have to say:

(lldb) continue --direction reverse
...
(lldb) c
(lldb) c
...

But it would also mean that for folks that want to be explicit about this, they 
could do:

(lldb) command alias rc continue --direction reverse
(lldb) command alias c  continue --direction forward

> 
> The other question is, what should the thread plan stacks look like during 
> this scenario?

continue is a little bit tricky because it doesn't really correspond to a 
thread plan per se.  Thread plans are "execution control with intentions" and 
"continue" doesn't really have an intention.  It just means "restart letting 
the extant plan stack do its thing".  At one point, I thought it might be 
useful to be able to have a mode of lldb where you could say:

thread 1 - do a step over
thread 2 - do a step in
continue

and the first two operations would just push thread plans but not set the 
process going, then "continue" would be set all the threads and their plans 
running.  I only ever really wanted this a couple of times, however, not enough 
to actually implement it, but that's partly why "continue" isn't thread-plan 
based, but rather just runs thread plans on whichever threads want to run that 
time round.

So in this case, the thread plan stack would just have a "base thread plan" - 
which is the plan that handles unexplained stops - throughout the process.

However, up to now, the thread plan stacks for individual threads have been 
independent of each other.  If thread A was doing a "step in" while thread B 
was in the middle of a "step over", the plan for thread A didn't need to affect 
how anything but thread A ran.  The fact that it doesn't make sense to run one 
thread forwards and another thread backwards at the same time adds some thread 
coupling, which complicates this design.  

Suppose, for instance, you were doing a backwards next on thread A and hit a 
breakpoint, then decided to do a forward next on thread B and that also hit a 
breakpoint, then you're going to need to tell thread A - during the forward 
next for thread B - that it will be moving forwards while the thread B next 
plan is in force, then should go back to reverse to finish

[Lldb-commits] [lldb] [lldb] Handle an empty SBMemoryRegionInfo from scripted process (PR #115963)

2024-11-12 Thread Jason Molenda via lldb-commits


@@ -288,8 +288,15 @@ Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t 
load_addr,
   MemoryRegionInfo ®ion) {
   Status error;
   if (auto region_or_err =
-  GetInterface().GetMemoryRegionContainingAddress(load_addr, error))
+  GetInterface().GetMemoryRegionContainingAddress(load_addr, error)) {
 region = *region_or_err;
+if (region.GetRange().GetRangeBase() == 0 &&
+(region.GetRange().GetByteSize() == 0 ||
+ region.GetRange().GetByteSize() == LLDB_INVALID_ADDRESS)) {

jasonmolenda wrote:

Last week I had another similar bug where a gdb remote stub was returning start 
addr 0 size UINT64_MAX as a region response, and I was trying to reject that in 
addition to addr 0 size 0.  I haven't seen someone send that same incorrect 
response from a scripted process, though, I should just check for 0/0 here.

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


[Lldb-commits] [lldb] fix: Target Process may crash or freezes on detaching process on windows (PR #115712)

2024-11-12 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AIX] Added new plugin AIX-DYLD (Dynamic Loader) Base Support (PR #115714)

2024-11-12 Thread Pavel Labath via lldb-commits

labath wrote:

That sounds reasonable. Those three parts should be mostly independent. The 
dynamic loader plugin is tricky as it sort of binds everything together. 
Basically my criterion is: "can this code be useful (e.g. tested) without the 
functionality that is not implemented yet". If the answer is no, then we ought 
deal with the things that make it useful first.

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


[Lldb-commits] [lldb] ae7b5af - [lldb] Remove ConnectionFileDescriptor::child_process_inherit (#115861)

2024-11-12 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-11-13T08:59:42+01:00
New Revision: ae7b5af904850db71308915836f32a8d79553dd8

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

LOG: [lldb] Remove ConnectionFileDescriptor::child_process_inherit (#115861)

It's never set to true. Inheritable FDs are also dangerous as they can
end up processes which know nothing about them. It's better to
explicitly pass a specific FD to a specific subprocess, which we already
mostly can do using the ProcessLaunchInfo FileActions.

Added: 


Modified: 
lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 35773d5907e913..b771f9c3f45a21 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -31,7 +31,7 @@ class ConnectionFileDescriptor : public Connection {
   typedef llvm::function_ref
   socket_id_callback_type;
 
-  ConnectionFileDescriptor(bool child_processes_inherit = false);
+  ConnectionFileDescriptor();
 
   ConnectionFileDescriptor(int fd, bool owns_fd);
 
@@ -65,9 +65,6 @@ class ConnectionFileDescriptor : public Connection {
 
   lldb::IOObjectSP GetReadObject() override { return m_io_sp; }
 
-  bool GetChildProcessesInherit() const;
-  void SetChildProcessesInherit(bool child_processes_inherit);
-
 protected:
   void OpenCommandPipe();
 
@@ -135,7 +132,6 @@ class ConnectionFileDescriptor : public Connection {
   std::atomic m_shutting_down; // This marks that we are shutting down so
  // if we get woken up from
   // BytesAvailable to disconnect, we won't try to read again.
-  bool m_child_processes_inherit;
 
   std::string m_uri;
 

diff  --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp 
b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index d0cc68826d4bb7..8a03e47ef3d900 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -52,18 +52,15 @@
 using namespace lldb;
 using namespace lldb_private;
 
-ConnectionFileDescriptor::ConnectionFileDescriptor(bool 
child_processes_inherit)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-
-  m_child_processes_inherit(child_processes_inherit) {
+ConnectionFileDescriptor::ConnectionFileDescriptor()
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   Log *log(GetLog(LLDBLog::Connection | LLDBLog::Object));
   LLDB_LOGF(log, "%p ConnectionFileDescriptor::ConnectionFileDescriptor ()",
 static_cast(this));
 }
 
 ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-  m_child_processes_inherit(false) {
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   m_io_sp =
   std::make_shared(fd, File::eOpenOptionReadWrite, owns_fd);
 
@@ -76,8 +73,7 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, 
bool owns_fd)
 }
 
 ConnectionFileDescriptor::ConnectionFileDescriptor(Socket *socket)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-  m_child_processes_inherit(false) {
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   InitializeSocket(socket);
 }
 
@@ -94,7 +90,7 @@ void ConnectionFileDescriptor::OpenCommandPipe() {
 
   Log *log = GetLog(LLDBLog::Connection);
   // Make the command file descriptor here:
-  Status result = m_pipe.CreateNew(m_child_processes_inherit);
+  Status result = m_pipe.CreateNew(/*child_processes_inherit=*/false);
   if (!result.Success()) {
 LLDB_LOGF(log,
   "%p ConnectionFileDescriptor::OpenCommandPipe () - could not "
@@ -539,7 +535,7 @@ lldb::ConnectionStatus 
ConnectionFileDescriptor::AcceptSocket(
 Status *error_ptr) {
   Status error;
   std::unique_ptr listening_socket =
-  Socket::Create(socket_protocol, m_child_processes_inherit, error);
+  Socket::Create(socket_protocol, /*child_processes_inherit=*/false, 
error);
   Socket *accepted_socket;
 
   if (!error.Fail())
@@ -567,7 +563,7 @@ 
ConnectionFileDescriptor::ConnectSocket(Socket::SocketProtocol socket_protocol,
 Status *error_ptr) {
   Status error;
   std::unique_ptr socket =
-  Socket::Create(socket_protocol, m_child_processes_inherit, error);
+  Socket::Create(socket_protocol, /*child_processes_inherit=*/false, 
error);
 
   if (!error.Fail())
 error = socket->Connect(socket_name);
@@ -649,7 +645,7 @@ ConnectionFileDescriptor::ConnectUDP(llv

[Lldb-commits] [lldb] [lldb] Remove ConnectionFileDescriptor::child_process_inherit (PR #115861)

2024-11-12 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/115933

>From db7efd17208479fb56eac01eaad1f8bcb993db04 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 12 Nov 2024 14:41:28 -0500
Subject: [PATCH 1/2] [lldb-dap] Remove `g_dap` references from
 lldb-dap/LLDBUtils.

This refactor removes g_dap references from lldb-dap/LLDBUtils.{h,cpp} to allow 
us to create more than one g_dap instance in the future.
---
 lldb/tools/lldb-dap/DAP.cpp   |  2 +-
 lldb/tools/lldb-dap/LLDBUtils.cpp | 14 +++---
 lldb/tools/lldb-dap/LLDBUtils.h   | 10 +++---
 lldb/tools/lldb-dap/lldb-dap.cpp  |  4 ++--
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index e45f9bf359e5bf..10d2d5d79a74bf 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -548,7 +548,7 @@ bool DAP::RunLLDBCommands(llvm::StringRef prefix,
   llvm::ArrayRef commands) {
   bool required_command_failed = false;
   std::string output =
-  ::RunLLDBCommands(prefix, commands, required_command_failed);
+  ::RunLLDBCommands(debugger, prefix, commands, required_command_failed);
   SendOutput(OutputType::Console, output);
   return !required_command_failed;
 }
diff --git a/lldb/tools/lldb-dap/LLDBUtils.cpp 
b/lldb/tools/lldb-dap/LLDBUtils.cpp
index 2ffcba7dff4f24..48b63b59e0e3fe 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.cpp
+++ b/lldb/tools/lldb-dap/LLDBUtils.cpp
@@ -15,7 +15,7 @@
 
 namespace lldb_dap {
 
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives) {
   if (commands.empty())
@@ -23,7 +23,7 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 
   bool did_print_prefix = false;
 
-  lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter();
+  lldb::SBCommandInterpreter interp = debugger.GetCommandInterpreter();
   for (llvm::StringRef command : commands) {
 lldb::SBCommandReturnObject result;
 bool quiet_on_success = false;
@@ -78,23 +78,23 @@ bool RunLLDBCommands(llvm::StringRef prefix,
   return true;
 }
 
-std::string RunLLDBCommands(llvm::StringRef prefix,
+std::string RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands,
 bool &required_command_failed,
 bool parse_command_directives) {
   required_command_failed = false;
   std::string s;
   llvm::raw_string_ostream strm(s);
-  required_command_failed =
-  !RunLLDBCommands(prefix, commands, strm, parse_command_directives);
+  required_command_failed = !RunLLDBCommands(debugger, prefix, commands, strm,
+ parse_command_directives);
   return s;
 }
 
 std::string
-RunLLDBCommandsVerbatim(llvm::StringRef prefix,
+RunLLDBCommandsVerbatim(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands) {
   bool required_command_failed = false;
-  return RunLLDBCommands(prefix, commands, required_command_failed,
+  return RunLLDBCommands(debugger, prefix, commands, required_command_failed,
  /*parse_command_directives=*/false);
 }
 
diff --git a/lldb/tools/lldb-dap/LLDBUtils.h b/lldb/tools/lldb-dap/LLDBUtils.h
index d5072d19029a1e..683d48a4a46321 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.h
+++ b/lldb/tools/lldb-dap/LLDBUtils.h
@@ -10,6 +10,7 @@
 #define LLDB_TOOLS_LLDB_DAP_LLDBUTILS_H
 
 #include "DAPForward.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
@@ -30,6 +31,9 @@ namespace lldb_dap {
 /// emitted regardless, and \b false is returned without executing the
 /// remaining commands.
 ///
+/// \param[in] debugger
+/// The debugger that will execute the lldb commands.
+///
 /// \param[in] prefix
 /// A string that will be printed into \a strm prior to emitting
 /// the prompt + command and command output. Can be NULL.
@@ -48,7 +52,7 @@ namespace lldb_dap {
 /// \return
 /// \b true, unless a command prefixed with \b ! fails and parsing of
 /// command directives is enabled.
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives);
 
@@ -75,14 +79,14 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 /// \return
 /// A std::string that contains the prefix and all commands and
 /// command output.
-std::string RunLLDBCommands(llvm::StringRef prefix,
+std::string RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm

[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

This refactor removes g_dap references from lldb-dap/LLDBUtils.{h,cpp} to allow 
us to create more than one g_dap instance in the future.

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


4 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.cpp (+1-1) 
- (modified) lldb/tools/lldb-dap/LLDBUtils.cpp (+7-7) 
- (modified) lldb/tools/lldb-dap/LLDBUtils.h (+7-3) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+2-2) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index e45f9bf359e5bf..10d2d5d79a74bf 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -548,7 +548,7 @@ bool DAP::RunLLDBCommands(llvm::StringRef prefix,
   llvm::ArrayRef commands) {
   bool required_command_failed = false;
   std::string output =
-  ::RunLLDBCommands(prefix, commands, required_command_failed);
+  ::RunLLDBCommands(debugger, prefix, commands, required_command_failed);
   SendOutput(OutputType::Console, output);
   return !required_command_failed;
 }
diff --git a/lldb/tools/lldb-dap/LLDBUtils.cpp 
b/lldb/tools/lldb-dap/LLDBUtils.cpp
index 2ffcba7dff4f24..48b63b59e0e3fe 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.cpp
+++ b/lldb/tools/lldb-dap/LLDBUtils.cpp
@@ -15,7 +15,7 @@
 
 namespace lldb_dap {
 
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives) {
   if (commands.empty())
@@ -23,7 +23,7 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 
   bool did_print_prefix = false;
 
-  lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter();
+  lldb::SBCommandInterpreter interp = debugger.GetCommandInterpreter();
   for (llvm::StringRef command : commands) {
 lldb::SBCommandReturnObject result;
 bool quiet_on_success = false;
@@ -78,23 +78,23 @@ bool RunLLDBCommands(llvm::StringRef prefix,
   return true;
 }
 
-std::string RunLLDBCommands(llvm::StringRef prefix,
+std::string RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands,
 bool &required_command_failed,
 bool parse_command_directives) {
   required_command_failed = false;
   std::string s;
   llvm::raw_string_ostream strm(s);
-  required_command_failed =
-  !RunLLDBCommands(prefix, commands, strm, parse_command_directives);
+  required_command_failed = !RunLLDBCommands(debugger, prefix, commands, strm,
+ parse_command_directives);
   return s;
 }
 
 std::string
-RunLLDBCommandsVerbatim(llvm::StringRef prefix,
+RunLLDBCommandsVerbatim(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands) {
   bool required_command_failed = false;
-  return RunLLDBCommands(prefix, commands, required_command_failed,
+  return RunLLDBCommands(debugger, prefix, commands, required_command_failed,
  /*parse_command_directives=*/false);
 }
 
diff --git a/lldb/tools/lldb-dap/LLDBUtils.h b/lldb/tools/lldb-dap/LLDBUtils.h
index d5072d19029a1e..683d48a4a46321 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.h
+++ b/lldb/tools/lldb-dap/LLDBUtils.h
@@ -10,6 +10,7 @@
 #define LLDB_TOOLS_LLDB_DAP_LLDBUTILS_H
 
 #include "DAPForward.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
@@ -30,6 +31,9 @@ namespace lldb_dap {
 /// emitted regardless, and \b false is returned without executing the
 /// remaining commands.
 ///
+/// \param[in] debugger
+/// The debugger that will execute the lldb commands.
+///
 /// \param[in] prefix
 /// A string that will be printed into \a strm prior to emitting
 /// the prompt + command and command output. Can be NULL.
@@ -48,7 +52,7 @@ namespace lldb_dap {
 /// \return
 /// \b true, unless a command prefixed with \b ! fails and parsing of
 /// command directives is enabled.
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives);
 
@@ -75,14 +79,14 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 /// \return
 /// A std::string that contains the prefix and all commands and
 /// command output.
-std::string RunLLDBCommands(llvm::StringRef prefix,
+std::string RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands,
 bool &required_command_failed,
 bool parse_command_directives = tr

[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread Adrian Vogelsgesang via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread Jonas Devlieghere via lldb-commits


@@ -205,16 +205,20 @@ Disassembler::GetFunctionDeclLineEntry(const 
SymbolContext &sc) {
 return {};
 
   LineEntry prologue_end_line = sc.line_entry;
-  FileSpec func_decl_file;
+  SupportFileSP func_decl_file_sp;

JDevlieghere wrote:

As you've noticed, `SupportFileSP` is always valid in a few places (like in 
`LineEntry`). I don't think that's something that should generally hold (mostly 
because it's hard to enforce) so I would have done the same thing here. The 
alternative would be to initialize this to an empty `SupportFile` and have 
`GetStartLineSourceInfo` do the same instead of calling `::reset`, though I 
think that's pretty inefficient. Anyway, just an observation, no need to change 
anything. 

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


[Lldb-commits] [lldb] faaf2db - [lldb-dap] Refactoring JSONUtils to not use `g_dap` and instead passing in required arguments. (#115561)

2024-11-12 Thread via lldb-commits

Author: John Harrison
Date: 2024-11-12T12:15:58-05:00
New Revision: faaf2dbf6d2c080d817c4dfe9f888e456418bc2e

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

LOG: [lldb-dap] Refactoring JSONUtils to not use `g_dap` and instead passing in 
required arguments. (#115561)

This is part of a larger refactor to remove the global `g_dap` variable.

Added: 


Modified: 
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/JSONUtils.h
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index a7300abae0eac8..6ca4dfb4711a13 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -154,7 +154,7 @@ DecodeMemoryReference(llvm::StringRef memoryReference) {
 std::vector GetStrings(const llvm::json::Object *obj,
 llvm::StringRef key) {
   std::vector strs;
-  auto json_array = obj->getArray(key);
+  const auto *json_array = obj->getArray(key);
   if (!json_array)
 return strs;
   for (const auto &value : *json_array) {
@@ -210,12 +210,6 @@ static bool IsClassStructOrUnionType(lldb::SBType t) {
 /// glance.
 static std::optional
 TryCreateAutoSummaryForContainer(lldb::SBValue &v) {
-  // We gate this feature because it performs GetNumChildren(), which can
-  // cause performance issues because LLDB needs to complete possibly huge
-  // types.
-  if (!g_dap.enable_auto_variable_summaries)
-return std::nullopt;
-
   if (!v.MightHaveChildren())
 return std::nullopt;
   /// As this operation can be potentially slow, we limit the total time spent
@@ -271,10 +265,7 @@ TryCreateAutoSummaryForContainer(lldb::SBValue &v) {
 
 /// Try to create a summary string for the given value that doesn't have a
 /// summary of its own.
-static std::optional TryCreateAutoSummary(lldb::SBValue value) {
-  if (!g_dap.enable_auto_variable_summaries)
-return std::nullopt;
-
+static std::optional TryCreateAutoSummary(lldb::SBValue &value) {
   // We use the dereferenced value for generating the summary.
   if (value.GetType().IsPointerType() || value.GetType().IsReferenceType())
 value = value.Dereference();
@@ -485,10 +476,12 @@ static std::string ConvertDebugInfoSizeToString(uint64_t 
debug_info) {
   }
   return oss.str();
 }
-llvm::json::Value CreateModule(lldb::SBModule &module) {
+
+llvm::json::Value CreateModule(lldb::SBTarget &target, lldb::SBModule &module) 
{
   llvm::json::Object object;
-  if (!module.IsValid())
+  if (!target.IsValid() || !module.IsValid())
 return llvm::json::Value(std::move(object));
+
   const char *uuid = module.GetUUIDString();
   object.try_emplace("id", uuid ? std::string(uuid) : std::string(""));
   object.try_emplace("name", std::string(module.GetFileSpec().GetFilename()));
@@ -514,7 +507,7 @@ llvm::json::Value CreateModule(lldb::SBModule &module) {
 object.try_emplace("symbolStatus", "Symbols not found.");
   }
   std::string loaded_addr = std::to_string(
-  module.GetObjectFileHeaderAddress().GetLoadAddress(g_dap.target));
+  module.GetObjectFileHeaderAddress().GetLoadAddress(target));
   object.try_emplace("addressRange", loaded_addr);
   std::string version_str;
   uint32_t version_nums[3];
@@ -705,7 +698,7 @@ llvm::json::Value CreateSource(llvm::StringRef source_path) 
{
   return llvm::json::Value(std::move(source));
 }
 
-std::optional CreateSource(lldb::SBFrame &frame) {
+static std::optional CreateSource(lldb::SBFrame &frame) {
   auto line_entry = frame.GetLineEntry();
   // A line entry of 0 indicates the line is compiler generated i.e. no source
   // file is associated with the frame.
@@ -776,15 +769,15 @@ std::optional 
CreateSource(lldb::SBFrame &frame) {
 //   },
 //   "required": [ "id", "name", "line", "column" ]
 // }
-llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) {
+llvm::json::Value CreateStackFrame(lldb::SBFrame &frame,
+   lldb::SBFormat &format) {
   llvm::json::Object object;
   int64_t frame_id = MakeDAPFrameID(frame);
   object.try_emplace("id", frame_id);
 
   std::string frame_name;
   lldb::SBStream stream;
-  if (g_dap.frame_format &&
-  frame.GetDescriptionWithFormat(g_dap.frame_format, stream).Success()) {
+  if (format && frame.GetDescriptionWithFormat(format, stream).Success()) {
 frame_name = stream.GetData();
 
 // `function_name` can be a nullptr, which throws an error when assigned to
@@ -801,7 +794,7 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) {
   }
 
   // We only include `[opt]` if a custom frame format is not specified.
-  if (!g_dap.frame_format && frame.GetFunction().GetIsOptimized())
+  if (!format && frame.GetFunction().GetIsOptimized())
 frame_name += " [opt]";
 
   Emp

[Lldb-commits] [lldb] [lldb-dap] Refactoring JSONUtils to not use `g_dap` and instead passing in required arguments. (PR #115561)

2024-11-12 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] 20c4e95 - [lldb][test] Fix remote Shell tests failures on Windows host (#115716)

2024-11-12 Thread via lldb-commits

Author: Vladislav Dzhidzhoev
Date: 2024-11-12T18:03:24+01:00
New Revision: 20c4e95b9c03a77c2e5ce5f354114752d380c591

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

LOG: [lldb][test] Fix remote Shell tests failures on Windows host (#115716)

Since the remote Shell test execution feature was added, these tests
should now be disabled on Windows target instead of Windows host.

It should fix failures on
https://lab.llvm.org/staging/#/builders/197/builds/76.

Added: 


Modified: 
lldb/test/Shell/Commands/command-disassemble-mixed.c
lldb/test/Shell/Commands/command-expr-diagnostics.test
lldb/test/Shell/Commands/command-target-create-resolve-exe.test
lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
lldb/test/Shell/Expr/TestIRMemoryMapWindows.test
lldb/test/Shell/Process/Windows/exception_access_violation.cpp
lldb/test/Shell/Process/Windows/process_load.cpp
lldb/test/Shell/SymbolFile/DWARF/packed.cpp
lldb/test/Shell/SymbolFile/NativePDB/local-variables.cpp
lldb/test/Shell/SymbolFile/NativePDB/stack_unwinding01.cpp
lldb/test/Shell/SymbolFile/PDB/calling-conventions-arm.test
lldb/test/Shell/SymbolFile/PDB/class-layout.test
lldb/test/Shell/SymbolFile/PDB/compilands.test
lldb/test/Shell/SymbolFile/PDB/expressions.test
lldb/test/Shell/SymbolFile/PDB/func-symbols.test
lldb/test/Shell/SymbolFile/PDB/function-level-linking.test
lldb/test/Shell/SymbolFile/PDB/pointers.test
lldb/test/Shell/SymbolFile/PDB/type-quals.test
lldb/test/Shell/SymbolFile/PDB/udt-layout.test
lldb/test/Shell/SymbolFile/PDB/variables-locations.test
lldb/test/Shell/SymbolFile/PDB/vbases.test
lldb/test/Shell/Target/dependent-modules-nodupe-windows.test
lldb/test/Shell/lit.cfg.py

Removed: 




diff  --git a/lldb/test/Shell/Commands/command-disassemble-mixed.c 
b/lldb/test/Shell/Commands/command-disassemble-mixed.c
index 1e530095c5c56b..4af85c0a4c020b 100644
--- a/lldb/test/Shell/Commands/command-disassemble-mixed.c
+++ b/lldb/test/Shell/Commands/command-disassemble-mixed.c
@@ -1,6 +1,6 @@
 // invalid mixed disassembly line
 
-// XFAIL: system-windows
+// XFAIL: target-windows
 
 // RUN: %clang_host -g %s -o %t
 // RUN: %lldb %t -o "dis -m -n main" -o "exit" | FileCheck %s

diff  --git a/lldb/test/Shell/Commands/command-expr-diagnostics.test 
b/lldb/test/Shell/Commands/command-expr-diagnostics.test
index 72df47bbbdc1ed..3c827fb4516ecd 100644
--- a/lldb/test/Shell/Commands/command-expr-diagnostics.test
+++ b/lldb/test/Shell/Commands/command-expr-diagnostics.test
@@ -1,4 +1,4 @@
-# XFAIL: system-windows
+# XFAIL: target-windows
 # RUN: echo quit | %lldb -o "expression a+b" \
 # RUN:   | FileCheck %s --strict-whitespace --check-prefix=CHECK1
 #(lldb) expression a+b

diff  --git a/lldb/test/Shell/Commands/command-target-create-resolve-exe.test 
b/lldb/test/Shell/Commands/command-target-create-resolve-exe.test
index 0ebbaf25e652de..3a0c7bd91a73e4 100644
--- a/lldb/test/Shell/Commands/command-target-create-resolve-exe.test
+++ b/lldb/test/Shell/Commands/command-target-create-resolve-exe.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-windows
+# REQUIRES: target-windows
 
 ## This checks that when starting lldb (or using `target create`) with a
 ## program name which is on $PATH, or not specify the .exe suffix of a program

diff  --git a/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp 
b/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
index 3d7b193dc6aaca..725b2d637637f2 100644
--- a/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
+++ b/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
@@ -3,7 +3,7 @@
 // linkage. In this case, a function whose argument
 // is not legally usable outside this TU.
 
-// XFAIL: system-windows
+// XFAIL: target-windows
 
 // RUN: %build %s -o %t
 // RUN: %lldb %t -o run -o "expression func(a)" -o exit | FileCheck %s

diff  --git a/lldb/test/Shell/Expr/TestIRMemoryMapWindows.test 
b/lldb/test/Shell/Expr/TestIRMemoryMapWindows.test
index ae29492c9ccc9f..66f0bce3047303 100644
--- a/lldb/test/Shell/Expr/TestIRMemoryMapWindows.test
+++ b/lldb/test/Shell/Expr/TestIRMemoryMapWindows.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-windows
+# REQUIRES: target-windows
 
 # RUN: %clang_cl_host /Zi /GS- %p/Inputs/call-function.cpp /c /o %t.obj
 # RUN: %msvc_link /debug:full %t.obj /out:%t

diff  --git a/lldb/test/Shell/Process/Windows/exception_access_violation.cpp 
b/lldb/test/Shell/Process/Windows/exception_access_violation.cpp
index 4835b498ee4dfd..93898a1991bc6d 100644
--- a/lldb/test/Shell/Process/Windows/exception_access_violation.cpp
+++ b/lldb/test/Shell/Process/Windows/exception_access_violation.cpp
@@ -1,6 +1,6 @@
 // clang-format off
 
-// REQUIRES: system-windows
+// REQUIRES: target-windows
 // RUN:

[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread John Harrison via lldb-commits

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/115933

This refactor removes g_dap references from lldb-dap/LLDBUtils.{h,cpp} to allow 
us to create more than one g_dap instance in the future.

>From db7efd17208479fb56eac01eaad1f8bcb993db04 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 12 Nov 2024 14:41:28 -0500
Subject: [PATCH] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils.

This refactor removes g_dap references from lldb-dap/LLDBUtils.{h,cpp} to allow 
us to create more than one g_dap instance in the future.
---
 lldb/tools/lldb-dap/DAP.cpp   |  2 +-
 lldb/tools/lldb-dap/LLDBUtils.cpp | 14 +++---
 lldb/tools/lldb-dap/LLDBUtils.h   | 10 +++---
 lldb/tools/lldb-dap/lldb-dap.cpp  |  4 ++--
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index e45f9bf359e5bf..10d2d5d79a74bf 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -548,7 +548,7 @@ bool DAP::RunLLDBCommands(llvm::StringRef prefix,
   llvm::ArrayRef commands) {
   bool required_command_failed = false;
   std::string output =
-  ::RunLLDBCommands(prefix, commands, required_command_failed);
+  ::RunLLDBCommands(debugger, prefix, commands, required_command_failed);
   SendOutput(OutputType::Console, output);
   return !required_command_failed;
 }
diff --git a/lldb/tools/lldb-dap/LLDBUtils.cpp 
b/lldb/tools/lldb-dap/LLDBUtils.cpp
index 2ffcba7dff4f24..48b63b59e0e3fe 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.cpp
+++ b/lldb/tools/lldb-dap/LLDBUtils.cpp
@@ -15,7 +15,7 @@
 
 namespace lldb_dap {
 
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives) {
   if (commands.empty())
@@ -23,7 +23,7 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 
   bool did_print_prefix = false;
 
-  lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter();
+  lldb::SBCommandInterpreter interp = debugger.GetCommandInterpreter();
   for (llvm::StringRef command : commands) {
 lldb::SBCommandReturnObject result;
 bool quiet_on_success = false;
@@ -78,23 +78,23 @@ bool RunLLDBCommands(llvm::StringRef prefix,
   return true;
 }
 
-std::string RunLLDBCommands(llvm::StringRef prefix,
+std::string RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands,
 bool &required_command_failed,
 bool parse_command_directives) {
   required_command_failed = false;
   std::string s;
   llvm::raw_string_ostream strm(s);
-  required_command_failed =
-  !RunLLDBCommands(prefix, commands, strm, parse_command_directives);
+  required_command_failed = !RunLLDBCommands(debugger, prefix, commands, strm,
+ parse_command_directives);
   return s;
 }
 
 std::string
-RunLLDBCommandsVerbatim(llvm::StringRef prefix,
+RunLLDBCommandsVerbatim(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands) {
   bool required_command_failed = false;
-  return RunLLDBCommands(prefix, commands, required_command_failed,
+  return RunLLDBCommands(debugger, prefix, commands, required_command_failed,
  /*parse_command_directives=*/false);
 }
 
diff --git a/lldb/tools/lldb-dap/LLDBUtils.h b/lldb/tools/lldb-dap/LLDBUtils.h
index d5072d19029a1e..683d48a4a46321 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.h
+++ b/lldb/tools/lldb-dap/LLDBUtils.h
@@ -10,6 +10,7 @@
 #define LLDB_TOOLS_LLDB_DAP_LLDBUTILS_H
 
 #include "DAPForward.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
@@ -30,6 +31,9 @@ namespace lldb_dap {
 /// emitted regardless, and \b false is returned without executing the
 /// remaining commands.
 ///
+/// \param[in] debugger
+/// The debugger that will execute the lldb commands.
+///
 /// \param[in] prefix
 /// A string that will be printed into \a strm prior to emitting
 /// the prompt + command and command output. Can be NULL.
@@ -48,7 +52,7 @@ namespace lldb_dap {
 /// \return
 /// \b true, unless a command prefixed with \b ! fails and parsing of
 /// command directives is enabled.
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives);
 
@@ -75,14 +79,14 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 /// \return
 /// A std::string that contains the prefix and all commands and
 /// command output.
-std::string RunLLDBCommands(llvm::Stri

[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/115933

>From db7efd17208479fb56eac01eaad1f8bcb993db04 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 12 Nov 2024 14:41:28 -0500
Subject: [PATCH] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils.

This refactor removes g_dap references from lldb-dap/LLDBUtils.{h,cpp} to allow 
us to create more than one g_dap instance in the future.
---
 lldb/tools/lldb-dap/DAP.cpp   |  2 +-
 lldb/tools/lldb-dap/LLDBUtils.cpp | 14 +++---
 lldb/tools/lldb-dap/LLDBUtils.h   | 10 +++---
 lldb/tools/lldb-dap/lldb-dap.cpp  |  4 ++--
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index e45f9bf359e5bf..10d2d5d79a74bf 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -548,7 +548,7 @@ bool DAP::RunLLDBCommands(llvm::StringRef prefix,
   llvm::ArrayRef commands) {
   bool required_command_failed = false;
   std::string output =
-  ::RunLLDBCommands(prefix, commands, required_command_failed);
+  ::RunLLDBCommands(debugger, prefix, commands, required_command_failed);
   SendOutput(OutputType::Console, output);
   return !required_command_failed;
 }
diff --git a/lldb/tools/lldb-dap/LLDBUtils.cpp 
b/lldb/tools/lldb-dap/LLDBUtils.cpp
index 2ffcba7dff4f24..48b63b59e0e3fe 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.cpp
+++ b/lldb/tools/lldb-dap/LLDBUtils.cpp
@@ -15,7 +15,7 @@
 
 namespace lldb_dap {
 
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives) {
   if (commands.empty())
@@ -23,7 +23,7 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 
   bool did_print_prefix = false;
 
-  lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter();
+  lldb::SBCommandInterpreter interp = debugger.GetCommandInterpreter();
   for (llvm::StringRef command : commands) {
 lldb::SBCommandReturnObject result;
 bool quiet_on_success = false;
@@ -78,23 +78,23 @@ bool RunLLDBCommands(llvm::StringRef prefix,
   return true;
 }
 
-std::string RunLLDBCommands(llvm::StringRef prefix,
+std::string RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands,
 bool &required_command_failed,
 bool parse_command_directives) {
   required_command_failed = false;
   std::string s;
   llvm::raw_string_ostream strm(s);
-  required_command_failed =
-  !RunLLDBCommands(prefix, commands, strm, parse_command_directives);
+  required_command_failed = !RunLLDBCommands(debugger, prefix, commands, strm,
+ parse_command_directives);
   return s;
 }
 
 std::string
-RunLLDBCommandsVerbatim(llvm::StringRef prefix,
+RunLLDBCommandsVerbatim(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::ArrayRef &commands) {
   bool required_command_failed = false;
-  return RunLLDBCommands(prefix, commands, required_command_failed,
+  return RunLLDBCommands(debugger, prefix, commands, required_command_failed,
  /*parse_command_directives=*/false);
 }
 
diff --git a/lldb/tools/lldb-dap/LLDBUtils.h b/lldb/tools/lldb-dap/LLDBUtils.h
index d5072d19029a1e..683d48a4a46321 100644
--- a/lldb/tools/lldb-dap/LLDBUtils.h
+++ b/lldb/tools/lldb-dap/LLDBUtils.h
@@ -10,6 +10,7 @@
 #define LLDB_TOOLS_LLDB_DAP_LLDBUTILS_H
 
 #include "DAPForward.h"
+#include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEnvironment.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
@@ -30,6 +31,9 @@ namespace lldb_dap {
 /// emitted regardless, and \b false is returned without executing the
 /// remaining commands.
 ///
+/// \param[in] debugger
+/// The debugger that will execute the lldb commands.
+///
 /// \param[in] prefix
 /// A string that will be printed into \a strm prior to emitting
 /// the prompt + command and command output. Can be NULL.
@@ -48,7 +52,7 @@ namespace lldb_dap {
 /// \return
 /// \b true, unless a command prefixed with \b ! fails and parsing of
 /// command directives is enabled.
-bool RunLLDBCommands(llvm::StringRef prefix,
+bool RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
  const llvm::ArrayRef &commands,
  llvm::raw_ostream &strm, bool parse_command_directives);
 
@@ -75,14 +79,14 @@ bool RunLLDBCommands(llvm::StringRef prefix,
 /// \return
 /// A std::string that contains the prefix and all commands and
 /// command output.
-std::string RunLLDBCommands(llvm::StringRef prefix,
+std::string RunLLDBCommands(lldb::SBDebugger &debugger, llvm::StringRef prefix,
 const llvm::Arr

[Lldb-commits] [lldb] [lldb-dap] Remove `g_dap` references from lldb-dap/LLDBUtils. (PR #115933)

2024-11-12 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [libcxx] [lldb] Unify naming of internal pointer members in std::vector and std::__split_buffer (PR #115517)

2024-11-12 Thread Peng Liu via lldb-commits

https://github.com/winner245 updated 
https://github.com/llvm/llvm-project/pull/115517

>From 2f108fec2dc46a4242142e69cf2e189f117d6cfc Mon Sep 17 00:00:00 2001
From: Peng Liu 
Date: Fri, 8 Nov 2024 11:52:29 -0500
Subject: [PATCH 1/3] Unify naming of internal pointer members in std::vector
 and std::__split_buffer

---
 libcxx/include/__split_buffer| 60 
 libcxx/include/__vector/vector.h |  4 +--
 libcxx/include/deque |  8 ++---
 3 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index 63ead9b1efd36d..b1c909f04b4861 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -47,7 +47,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 // __split_buffer allocates a contiguous chunk of memory and stores objects in 
the range [__begin_, __end_).
-// It has uninitialized memory in the ranges  [__first_, __begin_) and 
[__end_, __end_cap_.first()). That allows
+// It has uninitialized memory in the ranges  [__first_, __begin_) and 
[__end_, __cap_). That allows
 // it to grow both in the front and back without having to move the data.
 
 template  >
@@ -78,20 +78,20 @@ public:
   pointer __first_;
   pointer __begin_;
   pointer __end_;
-  _LIBCPP_COMPRESSED_PAIR(pointer, __end_cap_, allocator_type, __alloc_);
+  _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_);
 
   __split_buffer(const __split_buffer&)= delete;
   __split_buffer& operator=(const __split_buffer&) = delete;
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer()
   _NOEXCEPT_(is_nothrow_default_constructible::value)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) 
{}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit 
__split_buffer(__alloc_rr& __a)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr), __alloc_(__a) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__cap_(nullptr), __alloc_(__a) {}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit 
__split_buffer(const __alloc_rr& __a)
-  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__end_cap_(nullptr), __alloc_(__a) {}
+  : __first_(nullptr), __begin_(nullptr), __end_(nullptr), 
__cap_(nullptr), __alloc_(__a) {}
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
   __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
@@ -123,7 +123,7 @@ public:
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { 
return __end_ == __begin_; }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() 
const {
-return static_cast(__end_cap_ - __first_);
+return static_cast(__cap_ - __first_);
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type 
__front_spare() const {
@@ -131,7 +131,7 @@ public:
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() 
const {
-return static_cast(__end_cap_ - __end_);
+return static_cast(__cap_ - __end_);
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { 
return *__begin_; }
@@ -215,14 +215,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, 
_Allocator>::__invariants
   return false;
 if (__end_ != nullptr)
   return false;
-if (__end_cap_ != nullptr)
+if (__cap_ != nullptr)
   return false;
   } else {
 if (__begin_ < __first_)
   return false;
 if (__end_ < __begin_)
   return false;
-if (__end_cap_ < __end_)
+if (__cap_ < __end_)
   return false;
   }
   return true;
@@ -262,8 +262,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void
 __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator 
__first, _Sentinel __last) {
   __alloc_rr& __a = __alloc_;
   for (; __first != __last; ++__first) {
-if (__end_ == __end_cap_) {
-  size_type __old_cap = __end_cap_ - __first_;
+if (__end_ == __cap_) {
+  size_type __old_cap = __cap_ - __first_;
   size_type __new_cap = std::max(2 * __old_cap, 8);
   __split_buffer __buf(__new_cap, 0, __a);
   for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_)
@@ -320,7 +320,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer 
__new_last, true_type
 template 
 _LIBCPP_CONSTEXPR_SINCE_CXX20
 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type 
__start, __alloc_rr& __a)
-: __end_cap_(nullptr), __alloc_(__a) {
+: __cap_(nullptr), __alloc_(__a) {
   if (__cap == 0) {
 __first_ = nullptr;
   } else {
@@ -329,7 +329,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type 
__cap, size_type __sta
 __cap = __allocation.count;
   }
   __begin_ = __end_ = __first_ + __start;
-  __end_cap_= __fi

[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap/DAP.{h, cpp} to use its own instance instead of the global instance. (PR #115948)

2024-11-12 Thread John Harrison via lldb-commits

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/115948

The refactor will unblock us for creating multiple DAP instances.

>From 83a1ad1cd80c71531db6d3014fa16a8fbc38eeeb Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 12 Nov 2024 17:13:32 -0500
Subject: [PATCH] [lldb-dap] Refactor lldb-dap/DAP.{h,cpp} to not use its own
 instance instead of the global instance.

The refactor will unblock us for creating multiple DAP instances.
---
 lldb/tools/lldb-dap/DAP.cpp  | 52 +++-
 lldb/tools/lldb-dap/DAP.h|  6 
 lldb/tools/lldb-dap/lldb-dap.cpp |  6 ++--
 3 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 10d2d5d79a74bf..bdb24fc78cfb64 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -477,12 +477,12 @@ lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object 
&arguments) {
 
 llvm::json::Value DAP::CreateTopLevelScopes() {
   llvm::json::Array scopes;
-  scopes.emplace_back(CreateScope("Locals", VARREF_LOCALS,
-  g_dap.variables.locals.GetSize(), false));
+  scopes.emplace_back(
+  CreateScope("Locals", VARREF_LOCALS, variables.locals.GetSize(), false));
   scopes.emplace_back(CreateScope("Globals", VARREF_GLOBALS,
-  g_dap.variables.globals.GetSize(), false));
+  variables.globals.GetSize(), false));
   scopes.emplace_back(CreateScope("Registers", VARREF_REGS,
-  g_dap.variables.registers.GetSize(), false));
+  variables.registers.GetSize(), false));
   return llvm::json::Value(std::move(scopes));
 }
 
@@ -490,8 +490,8 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, 
std::string &expression,
  bool partial_expression) {
   // Check for the escape hatch prefix.
   if (!expression.empty() &&
-  llvm::StringRef(expression).starts_with(g_dap.command_escape_prefix)) {
-expression = expression.substr(g_dap.command_escape_prefix.size());
+  llvm::StringRef(expression).starts_with(command_escape_prefix)) {
+expression = expression.substr(command_escape_prefix.size());
 return ReplMode::Command;
   }
 
@@ -531,7 +531,7 @@ ReplMode DAP::DetectReplMode(lldb::SBFrame frame, 
std::string &expression,
   << "Warning: Expression '" << term
   << "' is both an LLDB command and variable. It will be evaluated as "
  "a variable. To evaluate the expression as an LLDB command, use '"
-  << g_dap.command_escape_prefix << "' as a prefix.\n";
+  << command_escape_prefix << "' as a prefix.\n";
 }
 
 // Variables take preference to commands in auto, since commands can always
@@ -901,7 +901,7 @@ bool StartDebuggingRequestHandler::DoExecute(
 return false;
   }
 
-  g_dap.SendReverseRequest(
+  dap.SendReverseRequest(
   "startDebugging",
   llvm::json::Object{{"request", request},
  {"configuration", std::move(*configuration)}},
@@ -925,7 +925,7 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   // If a new mode is not specified report the current mode.
   if (!command || llvm::StringRef(command[0]).empty()) {
 std::string mode;
-switch (g_dap.repl_mode) {
+switch (dap.repl_mode) {
 case ReplMode::Variable:
   mode = "variable";
   break;
@@ -946,11 +946,11 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   llvm::StringRef new_mode{command[0]};
 
   if (new_mode == "variable") {
-g_dap.repl_mode = ReplMode::Variable;
+dap.repl_mode = ReplMode::Variable;
   } else if (new_mode == "command") {
-g_dap.repl_mode = ReplMode::Command;
+dap.repl_mode = ReplMode::Command;
   } else if (new_mode == "auto") {
-g_dap.repl_mode = ReplMode::Auto;
+dap.repl_mode = ReplMode::Auto;
   } else {
 lldb::SBStream error_message;
 error_message.Printf("Invalid repl-mode '%s'. Expected one of 'variable', "
@@ -1022,7 +1022,7 @@ bool SendEventRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
 event.try_emplace("body", std::move(*body));
   }
 
-  g_dap.SendJSON(llvm::json::Value(std::move(event)));
+  dap.SendJSON(llvm::json::Value(std::move(event)));
   result.SetStatus(lldb::eReturnStatusSuccessFinishNoResult);
   return true;
 }
@@ -1031,14 +1031,13 @@ void DAP::SetFrameFormat(llvm::StringRef format) {
   if (format.empty())
 return;
   lldb::SBError error;
-  g_dap.frame_format = lldb::SBFormat(format.str().c_str(), error);
+  frame_format = lldb::SBFormat(format.str().c_str(), error);
   if (error.Fail()) {
-g_dap.SendOutput(
-OutputType::Console,
-llvm::formatv(
-"The provided frame format '{0}' couldn't be parsed: {1}\n", 
format,
-error.GetCString())
-.str());
+SendOutput(OutputType::Console,
+

[Lldb-commits] [lldb] 4714215 - [lldb] Support true/false in ValueObject::SetValueFromCString (#115780)

2024-11-12 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-11-12T21:18:22-08:00
New Revision: 4714215efb0486682feaa3a99162e80a934be8f9

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

LOG: [lldb] Support true/false in ValueObject::SetValueFromCString (#115780)

Support "true" and "false" (and "YES" and "NO" in Objective-C) in
ValueObject::SetValueFromCString.

Fixes #112597

Added: 


Modified: 
lldb/include/lldb/Target/Language.h
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
lldb/source/Target/Language.cpp
lldb/source/ValueObject/ValueObject.cpp
lldb/test/API/functionalities/data-formatter/setvaluefromcstring/main.m
lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
lldb/test/API/python_api/value/change_values/main.c

Removed: 




diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index c9cddee6baa2da..38ca458159edc7 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -245,7 +245,7 @@ class Language : public PluginInterface {
   // a match.  But we wouldn't want this to match AnotherA::my_function.  The
   // user is specifying a truncated path, not a truncated set of characters.
   // This function does a language-aware comparison for those purposes.
-  virtual bool DemangledNameContainsPath(llvm::StringRef path, 
+  virtual bool DemangledNameContainsPath(llvm::StringRef path,
  ConstString demangled) const;
 
   // if a language has a custom format for printing variable declarations that
@@ -372,6 +372,8 @@ class Language : public PluginInterface {
 return {};
   }
 
+  virtual std::optional GetBooleanFromString(llvm::StringRef str) const;
+
   /// Returns true if this Language supports exception breakpoints on throw via
   /// a corresponding LanguageRuntime plugin.
   virtual bool SupportsExceptionBreakpointsOnThrow() const { return false; }

diff  --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index b44971e36c6d0e..2ae203405cbba0 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -1040,3 +1040,11 @@ bool ObjCLanguage::IsSourceFile(llvm::StringRef 
file_path) const {
   }
   return false;
 }
+
+std::optional
+ObjCLanguage::GetBooleanFromString(llvm::StringRef str) const {
+  return llvm::StringSwitch>(str)
+  .Case("YES", {true})
+  .Case("NO", {false})
+  .Default({});
+}

diff  --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index d9c0cd3c18cfa1..6d265a9be52771 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -194,6 +194,9 @@ class ObjCLanguage : public Language {
 
   llvm::StringRef GetInstanceVariableName() override { return "self"; }
 
+  virtual std::optional
+  GetBooleanFromString(llvm::StringRef str) const override;
+
   bool SupportsExceptionBreakpointsOnThrow() const override { return true; }
 
   // PluginInterface protocol

diff  --git 
a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
index 79830e529df2d7..0489f4d6ada321 100644
--- a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
@@ -43,3 +43,11 @@ Language 
*ObjCPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
 return nullptr;
   }
 }
+
+std::optional
+ObjCPlusPlusLanguage::GetBooleanFromString(llvm::StringRef str) const {
+  return llvm::StringSwitch>(str)
+  .Cases("true", "YES", {true})
+  .Cases("false", "NO", {false})
+  .Default({});
+}

diff  --git a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h 
b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
index 1beab9348eb72e..229dffe8462e41 100644
--- a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
@@ -44,6 +44,9 @@ class ObjCPlusPlusLanguage : public Language {
 
   llvm::StringRef GetInstanceVariableName() override { return "self"; }
 
+  virtual std::optional
+  GetBooleanFromString(llvm::StringRef str) const override;
+
   static llvm::StringRef GetPluginNameStatic() { return "objcplusplus"; }
 
   // PluginInterface protocol

diff  --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
inde

[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-12 Thread David Spickett via lldb-commits

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


[Lldb-commits] [clang] [compiler-rt] [libc] [lld] [lldb] [llvm] [mlir] [BOLT] Match blocks with pseudo probes (PR #99891)

2024-11-12 Thread Amir Ayupov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/115876

When retrieving the location of the function declaration, we were dropping the 
file component on the floor, which resulted in an amusingly confusing situation 
were we displayed the file containing the implementation of the function, but 
used the line number of the declaration. This patch fixes that.

It required a small refactor Function::GetStartLineSourceLineInfo to return a 
SupportFile (instead of just the file spec), which in turn necessitated changes 
in a couple of other places as well.

>From 7f9c959bf0ee984b3c2e93f11a96b57162b3 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 12 Nov 2024 15:43:02 +0100
Subject: [PATCH] [lldb] Fix source display for artificial locations

When retrieving the location of the function declaration, we were
dropping the file component on the floor, which resulted in an amusingly
confusing situation were we displayed the file containing the
implementation of the function, but used the line number of the
declaration. This patch fixes that.

It required a small refactor Function::GetStartLineSourceLineInfo to
return a SupportFile (instead of just the file spec), which in turn
necessitated changes in a couple of other places as well.
---
 lldb/include/lldb/Symbol/Function.h   |  3 +-
 .../Breakpoint/BreakpointResolverFileLine.cpp | 13 
 lldb/source/Commands/CommandObjectSource.cpp  |  4 +--
 lldb/source/Core/Disassembler.cpp | 30 ---
 lldb/source/Symbol/Function.cpp   |  9 +++---
 lldb/source/Target/StackFrame.cpp |  6 ++--
 .../API/source-manager/TestSourceManager.py   | 19 
 .../API/source-manager/artificial_location.c  |  6 
 .../source-manager/artificial_location.cpp| 10 +++
 .../API/source-manager/artificial_location.h  |  3 ++
 10 files changed, 65 insertions(+), 38 deletions(-)
 delete mode 100644 lldb/test/API/source-manager/artificial_location.c
 create mode 100644 lldb/test/API/source-manager/artificial_location.cpp
 create mode 100644 lldb/test/API/source-manager/artificial_location.h

diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index bbfc25fe74ea06..70f51a846f8d96 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -457,7 +457,8 @@ class Function : public UserID, public SymbolContextScope {
   ///
   /// \param[out] line_no
   /// The line number.
-  void GetStartLineSourceInfo(FileSpec &source_file, uint32_t &line_no);
+  void GetStartLineSourceInfo(lldb::SupportFileSP &source_file_sp,
+  uint32_t &line_no);
 
   /// Find the file and line number of the source location of the end of the
   /// function.
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index 8e7386df03e9bf..a94e9e23163d3e 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -139,21 +139,23 @@ void 
BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
 if (!sc.block)
   continue;
 
-FileSpec file;
+SupportFileSP file_sp;
 uint32_t line;
 const Block *inline_block = sc.block->GetContainingInlinedBlock();
 if (inline_block) {
   const Declaration &inline_declaration = 
inline_block->GetInlinedFunctionInfo()->GetDeclaration();
   if (!inline_declaration.IsValid())
 continue;
-  file = inline_declaration.GetFile();
+  file_sp = std::make_shared(inline_declaration.GetFile());
   line = inline_declaration.GetLine();
 } else if (sc.function)
-  sc.function->GetStartLineSourceInfo(file, line);
+  sc.function->GetStartLineSourceInfo(file_sp, line);
 else
   continue;
 
-if (file != sc.line_entry.GetFile()) {
+if (!file_sp ||
+!file_sp->Equal(*sc.line_entry.file_sp,
+SupportFile::eEqualFileSpecAndChecksumIfSet)) {
   LLDB_LOG(log, "unexpected symbol context file {0}",
sc.line_entry.GetFile());
   continue;
@@ -190,7 +192,8 @@ void 
BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
 const int decl_line_is_too_late_fudge = 1;
 if (line &&
 m_location_spec.GetLine() < line - decl_line_is_too_late_fudge) {
-  LLDB_LOG(log, "removing symbol context at {0}:{1}", file, line);
+  LLDB_LOG(log, "removing symbol context at {0}:{1}",
+   file_sp->GetSpecOnly(), line);
   sc_list.RemoveContextAtIndex(i);
   --i;
 }
diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 86c090f9f36c16..c8295fd10cf221 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -784,9 +784,7 @@ class CommandObjectSourceList : public CommandObjectParse

[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

When retrieving the location of the function declaration, we were dropping the 
file component on the floor, which resulted in an amusingly confusing situation 
were we displayed the file containing the implementation of the function, but 
used the line number of the declaration. This patch fixes that.

It required a small refactor Function::GetStartLineSourceLineInfo to return a 
SupportFile (instead of just the file spec), which in turn necessitated changes 
in a couple of other places as well.

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


10 Files Affected:

- (modified) lldb/include/lldb/Symbol/Function.h (+2-1) 
- (modified) lldb/source/Breakpoint/BreakpointResolverFileLine.cpp (+8-5) 
- (modified) lldb/source/Commands/CommandObjectSource.cpp (+1-3) 
- (modified) lldb/source/Core/Disassembler.cpp (+19-11) 
- (modified) lldb/source/Symbol/Function.cpp (+5-4) 
- (modified) lldb/source/Target/StackFrame.cpp (+3-3) 
- (modified) lldb/test/API/source-manager/TestSourceManager.py (+14-5) 
- (removed) lldb/test/API/source-manager/artificial_location.c (-6) 
- (added) lldb/test/API/source-manager/artificial_location.cpp (+10) 
- (added) lldb/test/API/source-manager/artificial_location.h (+3) 


``diff
diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index bbfc25fe74ea06..70f51a846f8d96 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -457,7 +457,8 @@ class Function : public UserID, public SymbolContextScope {
   ///
   /// \param[out] line_no
   /// The line number.
-  void GetStartLineSourceInfo(FileSpec &source_file, uint32_t &line_no);
+  void GetStartLineSourceInfo(lldb::SupportFileSP &source_file_sp,
+  uint32_t &line_no);
 
   /// Find the file and line number of the source location of the end of the
   /// function.
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index 8e7386df03e9bf..a94e9e23163d3e 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -139,21 +139,23 @@ void 
BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
 if (!sc.block)
   continue;
 
-FileSpec file;
+SupportFileSP file_sp;
 uint32_t line;
 const Block *inline_block = sc.block->GetContainingInlinedBlock();
 if (inline_block) {
   const Declaration &inline_declaration = 
inline_block->GetInlinedFunctionInfo()->GetDeclaration();
   if (!inline_declaration.IsValid())
 continue;
-  file = inline_declaration.GetFile();
+  file_sp = std::make_shared(inline_declaration.GetFile());
   line = inline_declaration.GetLine();
 } else if (sc.function)
-  sc.function->GetStartLineSourceInfo(file, line);
+  sc.function->GetStartLineSourceInfo(file_sp, line);
 else
   continue;
 
-if (file != sc.line_entry.GetFile()) {
+if (!file_sp ||
+!file_sp->Equal(*sc.line_entry.file_sp,
+SupportFile::eEqualFileSpecAndChecksumIfSet)) {
   LLDB_LOG(log, "unexpected symbol context file {0}",
sc.line_entry.GetFile());
   continue;
@@ -190,7 +192,8 @@ void 
BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
 const int decl_line_is_too_late_fudge = 1;
 if (line &&
 m_location_spec.GetLine() < line - decl_line_is_too_late_fudge) {
-  LLDB_LOG(log, "removing symbol context at {0}:{1}", file, line);
+  LLDB_LOG(log, "removing symbol context at {0}:{1}",
+   file_sp->GetSpecOnly(), line);
   sc_list.RemoveContextAtIndex(i);
   --i;
 }
diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 86c090f9f36c16..c8295fd10cf221 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -784,9 +784,7 @@ class CommandObjectSourceList : public CommandObjectParsed {
 
   if (sc.block == nullptr) {
 // Not an inlined function
-FileSpec function_file_spec;
-sc.function->GetStartLineSourceInfo(function_file_spec, start_line);
-start_file = std::make_shared(function_file_spec);
+sc.function->GetStartLineSourceInfo(start_file, start_line);
 if (start_line == 0) {
   result.AppendErrorWithFormat("Could not find line information for "
"start of function: \"%s\".\n",
diff --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 522a3ef2efc334..68e52144eb6ef8 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -205,16 +205,20 @@ Disassembler::GetFunctionDeclLineEntry(const 
SymbolContext &sc) {
 return {

[Lldb-commits] [lldb] [lldb] Remove ConnectionFileDescriptor::child_process_inherit (PR #115861)

2024-11-12 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
2a3c08f620fc89823ebf1d2af4ea0beb97671db2...7f9c959bf0ee984b3c2e93f11a96b57162b3
 lldb/test/API/source-manager/TestSourceManager.py
``





View the diff from darker here.


``diff
--- TestSourceManager.py2024-11-12 14:51:28.00 +
+++ TestSourceManager.py2024-11-12 14:56:35.660866 +
@@ -313,11 +313,11 @@
 ],
 )
 
 def test_artificial_source_location(self):
 src_file = "artificial_location.cpp"
-d = {"C_SOURCES":"", "CXX_SOURCES": src_file}
+d = {"C_SOURCES": "", "CXX_SOURCES": src_file}
 self.build(dictionary=d)
 
 target = lldbutil.run_to_breakpoint_make_target(self)
 
 # Find the instruction with line=0 and put a breakpoint there.

``




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


[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 2a3c08f620fc89823ebf1d2af4ea0beb97671db2 
7f9c959bf0ee984b3c2e93f11a96b57162b3 --extensions h,cpp -- 
lldb/test/API/source-manager/artificial_location.cpp 
lldb/test/API/source-manager/artificial_location.h 
lldb/include/lldb/Symbol/Function.h 
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
lldb/source/Commands/CommandObjectSource.cpp lldb/source/Core/Disassembler.cpp 
lldb/source/Symbol/Function.cpp lldb/source/Target/StackFrame.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/source-manager/artificial_location.cpp 
b/lldb/test/API/source-manager/artificial_location.cpp
index e5f03b3139..776f68a00b 100644
--- a/lldb/test/API/source-manager/artificial_location.cpp
+++ b/lldb/test/API/source-manager/artificial_location.cpp
@@ -5,6 +5,4 @@ int A::foo() {
   return 42;
 }
 
-int main() {
-  return A::foo();
-}
+int main() { return A::foo(); }

``




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


[Lldb-commits] [lldb] [lldb] Fix source display for artificial locations (PR #115876)

2024-11-12 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/115876

>From 0e9fa482457c08c17c3d6b2219bb9ffd7a54d62f Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 12 Nov 2024 15:43:02 +0100
Subject: [PATCH] [lldb] Fix source display for artificial locations

When retrieving the location of the function declaration, we were
dropping the file component on the floor, which resulted in an amusingly
confusing situation were we displayed the file containing the
implementation of the function, but used the line number of the
declaration. This patch fixes that.

It required a small refactor Function::GetStartLineSourceLineInfo to
return a SupportFile (instead of just the file spec), which in turn
necessitated changes in a couple of other places as well.
---
 lldb/include/lldb/Symbol/Function.h   |  3 +-
 .../Breakpoint/BreakpointResolverFileLine.cpp | 13 
 lldb/source/Commands/CommandObjectSource.cpp  |  4 +--
 lldb/source/Core/Disassembler.cpp | 30 ---
 lldb/source/Symbol/Function.cpp   |  9 +++---
 lldb/source/Target/StackFrame.cpp |  6 ++--
 .../API/source-manager/TestSourceManager.py   | 19 
 .../API/source-manager/artificial_location.c  |  6 
 .../source-manager/artificial_location.cpp|  8 +
 .../API/source-manager/artificial_location.h  |  3 ++
 10 files changed, 63 insertions(+), 38 deletions(-)
 delete mode 100644 lldb/test/API/source-manager/artificial_location.c
 create mode 100644 lldb/test/API/source-manager/artificial_location.cpp
 create mode 100644 lldb/test/API/source-manager/artificial_location.h

diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index bbfc25fe74ea06..70f51a846f8d96 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -457,7 +457,8 @@ class Function : public UserID, public SymbolContextScope {
   ///
   /// \param[out] line_no
   /// The line number.
-  void GetStartLineSourceInfo(FileSpec &source_file, uint32_t &line_no);
+  void GetStartLineSourceInfo(lldb::SupportFileSP &source_file_sp,
+  uint32_t &line_no);
 
   /// Find the file and line number of the source location of the end of the
   /// function.
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index 8e7386df03e9bf..a94e9e23163d3e 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -139,21 +139,23 @@ void 
BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
 if (!sc.block)
   continue;
 
-FileSpec file;
+SupportFileSP file_sp;
 uint32_t line;
 const Block *inline_block = sc.block->GetContainingInlinedBlock();
 if (inline_block) {
   const Declaration &inline_declaration = 
inline_block->GetInlinedFunctionInfo()->GetDeclaration();
   if (!inline_declaration.IsValid())
 continue;
-  file = inline_declaration.GetFile();
+  file_sp = std::make_shared(inline_declaration.GetFile());
   line = inline_declaration.GetLine();
 } else if (sc.function)
-  sc.function->GetStartLineSourceInfo(file, line);
+  sc.function->GetStartLineSourceInfo(file_sp, line);
 else
   continue;
 
-if (file != sc.line_entry.GetFile()) {
+if (!file_sp ||
+!file_sp->Equal(*sc.line_entry.file_sp,
+SupportFile::eEqualFileSpecAndChecksumIfSet)) {
   LLDB_LOG(log, "unexpected symbol context file {0}",
sc.line_entry.GetFile());
   continue;
@@ -190,7 +192,8 @@ void 
BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
 const int decl_line_is_too_late_fudge = 1;
 if (line &&
 m_location_spec.GetLine() < line - decl_line_is_too_late_fudge) {
-  LLDB_LOG(log, "removing symbol context at {0}:{1}", file, line);
+  LLDB_LOG(log, "removing symbol context at {0}:{1}",
+   file_sp->GetSpecOnly(), line);
   sc_list.RemoveContextAtIndex(i);
   --i;
 }
diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 86c090f9f36c16..c8295fd10cf221 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -784,9 +784,7 @@ class CommandObjectSourceList : public CommandObjectParsed {
 
   if (sc.block == nullptr) {
 // Not an inlined function
-FileSpec function_file_spec;
-sc.function->GetStartLineSourceInfo(function_file_spec, start_line);
-start_file = std::make_shared(function_file_spec);
+sc.function->GetStartLineSourceInfo(start_file, start_line);
 if (start_line == 0) {
   result.AppendErrorWithFormat("Could not find line information for "
"start of function: \"%s\".\n",

[Lldb-commits] [lldb] [lldb] Support overriding the disassembly CPU & features (PR #115382)

2024-11-12 Thread David Spickett via lldb-commits


@@ -157,6 +157,12 @@ let Definition = "target" in {
 DefaultEnumValue<"eX86DisFlavorDefault">,
 EnumValues<"OptionEnumValues(g_x86_dis_flavor_value_types)">,
 Desc<"The default disassembly flavor to use for x86 or x86-64 targets.">;
+  def DisassemblyCPU: Property<"disassembly-cpu", "String">,
+DefaultStringValue<"">,
+Desc<"Override the CPU for disassembling. Takes the same values as the 
-mcpu compiler flag.">;
+  def DisassemblyFeatures: Property<"disassembly-features", "String">,
+DefaultStringValue<"">,
+Desc<"Specify additional CPU features for disassembling.">;

DavidSpickett wrote:

If I were a risc-v clang user I'd probably reference this:
```
$ ./bin/clang -target riscv64-linux-gnu --print-supported-extensions
clang version 20.0.0git (https://github.com/llvm/llvm-project.git 
5f342816efe1854333f2be41a03fdd25fa0db433)
Target: riscv64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/david.spickett/build-llvm-aarch64/bin
Build config: +assertions
All available -march extensions for RISC-V

Name Version   Description
i2.1   'I' (Base Integer Instruction Set)
e2.0   Implements RV{32,64}E (provides 16 rather 
than 32 GPRs)
```
Assuming I knew to add the `+` on. This works for AArch64 as well.

For AArch64 I know some of the MC names are slightly different (because we made 
mistakes, e.g. `memtag` and `mte`) so that could be interesting for a user here.

If the CPU option takes `-mcpu` I'd expect this to take `-march` names. I see 
`+all` though so I assume this actually takes `llvm-mc -mattr=` names.

It would be nice to use the frontend names but doing so is probably more hassle 
than it's worth given that the users of this setting probably know how to 
figure it out anyway for the few cases where the name is different.

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


[Lldb-commits] [lldb] [lldb][test] Fix inline_sites_live.cpp Shell test on Linux remote (PR #115722)

2024-11-12 Thread David Spickett via lldb-commits

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

I thought maybe the test passed accidentally with this change but the backtrace 
must still match so LGTM.

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


[Lldb-commits] [lldb] [lldb][test] Fix inline_sites_live.cpp Shell test on Linux remote (PR #115722)

2024-11-12 Thread David Spickett via lldb-commits

DavidSpickett wrote:

If I understand correctly this is building the test on Linux and running it on 
Windows.

And it seems that the output is in fact better this way? Can't complain about 
that.

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


[Lldb-commits] [lldb] [lldb][test] Fix inline_sites_live.cpp Shell when run on Windows remotely from Linux (PR #115722)

2024-11-12 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Fix remote Shell tests failures on Windows host (PR #115716)

2024-11-12 Thread David Spickett via lldb-commits

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

Thought that maybe you could just re-use the check for `system-windows`, but 
that's something lit adds for us by asking Python what it's running on.

LGTM.

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


[Lldb-commits] [lldb] [lldb][docs] Document Lua 5.3 as the only supported version (PR #115288)

2024-11-12 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Abandoning in favour of your patch, thanks!

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


[Lldb-commits] [lldb] [lldb] (Begin to) support discontinuous lldb_private::Functions (PR #115730)

2024-11-12 Thread Pavel Labath via lldb-commits


@@ -254,12 +254,32 @@ Function *IndirectCallEdge::GetCallee(ModuleList &images,
 
 /// @}
 
+AddressRange CollapseRanges(llvm::ArrayRef ranges) {
+  if (ranges.empty())
+return AddressRange();
+  if (ranges.size() == 1)
+return ranges[0];
+
+  Address lowest_addr = ranges[0].GetBaseAddress();
+  addr_t highest_addr = lowest_addr.GetFileAddress() + ranges[0].GetByteSize();
+  for (const AddressRange &range : ranges.drop_front()) {
+Address range_begin = range.GetBaseAddress();
+addr_t range_end = range_begin.GetFileAddress() + range.GetByteSize();
+if (range_begin.GetFileAddress() < lowest_addr.GetFileAddress())
+  lowest_addr = range_begin;
+if (range_end > highest_addr)
+  highest_addr = range_end;
+  }
+  return AddressRange(lowest_addr, highest_addr - 
lowest_addr.GetFileAddress());

labath wrote:

The problem is that the range may need extending at both ends (there's no 
guarantee the lowest address will be the first one). Extending it an the lower 
end is tricky as you need to both change the base address and increase the 
range size. Storing it decomposed and only constructing the range object at the 
end is simpler.

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


[Lldb-commits] [lldb] fix: Target Process may crash on detaching process on windows (PR #115712)

2024-11-12 Thread via lldb-commits

anatawa12 wrote:

I tried to run `TestDetachResumes` but it fails (still in suspended state) so I 
may need some other work to them work correctly. I'll investigate more tomorrow.

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


[Lldb-commits] [lldb] 3ce0dbb - [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (#114807)

2024-11-12 Thread via lldb-commits

Author: David Spickett
Date: 2024-11-12T10:49:16Z
New Revision: 3ce0dbb718c9df123fd1cb87623aa31b3376fb61

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

LOG: [lldb] Recommend Python 3.8 as the minimum Python version for LLDB 
(#114807)

See
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will be
a CMake warning telling builders that from LLDB 21 this will be a hard
requirement. From LLDB 21, it will be an error to try to build with
anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch is
created we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new
warnings or errors from this change.

Added: 


Modified: 
lldb/cmake/modules/FindPythonAndSwig.cmake
lldb/docs/resources/build.rst

Removed: 




diff  --git a/lldb/cmake/modules/FindPythonAndSwig.cmake 
b/lldb/cmake/modules/FindPythonAndSwig.cmake
index d62cced0d095e9..1f6f553e86048e 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -64,3 +64,9 @@ else()
   Python3_EXECUTABLE
   LLDB_ENABLE_SWIG)
 endif()
+
+set(LLDB_RECOMMENDED_PYTHON "3.8")
+if(PYTHONANDSWIG_FOUND AND "${Python3_VERSION}" VERSION_LESS 
"${LLDB_RECOMMENDED_PYTHON}")
+  message(WARNING "Using Python ${Python3_VERSION}. ${LLDB_RECOMMENDED_PYTHON} 
"
+  "is recommended and will be required from LLDB 21.")
+endif()
\ No newline at end of file

diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 66db84522bff1f..c0d3c580d631c1 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -51,21 +51,21 @@ CMake flag to ``On`` or ``Off`` to force the dependency to 
be enabled or
 disabled. When a dependency is set to ``On`` and can't be found it will cause a
 CMake configuration error.
 
-+---+--+--+
-| Feature   | Description  | 
CMake Flag   |
-+===+==+==+
-| Editline  | Generic line editing, history, Emacs and Vi bindings | 
``LLDB_ENABLE_LIBEDIT``  |
-+---+--+--+
-| Curses| Text user interface  | 
``LLDB_ENABLE_CURSES``   |
-+---+--+--+
-| LZMA  | Lossless data compression| 
``LLDB_ENABLE_LZMA`` |
-+---+--+--+
-| Libxml2   | XML  | 
``LLDB_ENABLE_LIBXML2``  |
-+---+--+--+
-| Python| Python scripting | 
``LLDB_ENABLE_PYTHON``   |
-+---+--+--+
-| Lua   | Lua scripting. Lua 5.3 and 5.4 are supported.| 
``LLDB_ENABLE_LUA``  |
-+---+--+--+
++---+--+--+
+| Feature   | Description  
| CMake Flag   |
++===+==+==+
+| Editline  | Generic line editing, history, Emacs and Vi bindings 
| ``LLDB_ENABLE_LIBEDIT``  |
++---+--+--+
+| Curses| Text user interface  
| ``LLDB_ENABLE_CURSES``   |
++---+--+--+
+| LZMA  | Lossless data compression
| ``LLDB_ENABLE_LZMA`` |
++---+--+--+
+| Libxml2   | XML  
| ``LLDB_ENABLE_LIBXML2``  |
++--

[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-12 Thread David Spickett via lldb-commits

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

>From fb436219e527f4de3cc4ce35eb3b884b824924a3 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 4 Nov 2024 14:41:19 +
Subject: [PATCH 1/2] [lldb] Recommend Python 3.8 as the minimum Python version
 for LLDB

See 
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will
be a CMake warning telling builders that from LLDB 21 this will be
a hard requirement. From LLDB 21, it will be an error to try to build
with anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch
is created we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new
warnings or errors from this change.
---
 lldb/cmake/modules/FindPythonAndSwig.cmake |  7 +
 lldb/docs/resources/build.rst  | 32 +++---
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/lldb/cmake/modules/FindPythonAndSwig.cmake 
b/lldb/cmake/modules/FindPythonAndSwig.cmake
index d62cced0d095e9..2cdd2204ae43cc 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -64,3 +64,10 @@ else()
   Python3_EXECUTABLE
   LLDB_ENABLE_SWIG)
 endif()
+
+set(LLDB_RECOMMENDED_PYTHON "3.8")
+if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND 
LLDB_ENABLE_SWIG
+   AND "${Python3_VERSION}" VERSION_LESS "${LLDB_RECOMMENDED_PYTHON}")
+  message(WARNING "Using Python ${Python3_VERSION}. ${LLDB_RECOMMENDED_PYTHON} 
"
+  "is recommended and will be required from LLDB 21.")
+endif()
\ No newline at end of file
diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 66db84522bff1f..c0d3c580d631c1 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -51,21 +51,21 @@ CMake flag to ``On`` or ``Off`` to force the dependency to 
be enabled or
 disabled. When a dependency is set to ``On`` and can't be found it will cause a
 CMake configuration error.
 
-+---+--+--+
-| Feature   | Description  | 
CMake Flag   |
-+===+==+==+
-| Editline  | Generic line editing, history, Emacs and Vi bindings | 
``LLDB_ENABLE_LIBEDIT``  |
-+---+--+--+
-| Curses| Text user interface  | 
``LLDB_ENABLE_CURSES``   |
-+---+--+--+
-| LZMA  | Lossless data compression| 
``LLDB_ENABLE_LZMA`` |
-+---+--+--+
-| Libxml2   | XML  | 
``LLDB_ENABLE_LIBXML2``  |
-+---+--+--+
-| Python| Python scripting | 
``LLDB_ENABLE_PYTHON``   |
-+---+--+--+
-| Lua   | Lua scripting. Lua 5.3 and 5.4 are supported.| 
``LLDB_ENABLE_LUA``  |
-+---+--+--+
++---+--+--+
+| Feature   | Description  
| CMake Flag   |
++===+==+==+
+| Editline  | Generic line editing, history, Emacs and Vi bindings 
| ``LLDB_ENABLE_LIBEDIT``  |
++---+--+--+
+| Curses| Text user interface  
| ``LLDB_ENABLE_CURSES``   |
++---+--+--+
+| LZMA  | Lossless data compression
| ``LLDB_ENABLE_LZMA`` |
++---+--+--+
+| Libxml2   | XML  
| ``LLDB_ENABLE_LIBXML2``  |
++---+

[Lldb-commits] [lldb] [lldb][docs] Document Lua 5.3 as the only supported version (PR #115288)

2024-11-12 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring JSONUtils to not use `g_dap` and instead passing in required arguments. (PR #115561)

2024-11-12 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb] Remove ConnectionFileDescriptor::child_process_inherit (PR #115861)

2024-11-12 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/115861

It's never set to true. Inheritable FDs are also dangerous as they can end up 
processes which know nothing about them. It's better to explicitly pass a 
specific FD to a specific subprocess, which we already mostly can do using the 
ProcessLaunchInfo FileActions.

>From 4fc069b3517f4ff332020627285359b1b5989878 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Sat, 19 Oct 2024 16:44:49 +0200
Subject: [PATCH] [lldb] Remove ConnectionFileDescriptor::child_process_inherit

It's never set to true. Inheritable FDs are also dangerous as they can
end up processes which know nothing about them. It's better to
explicitly pass a specific FD to a specific subprocess, which we already
mostly can do using the ProcessLaunchInfo FileActions.
---
 .../posix/ConnectionFileDescriptorPosix.h |  6 +---
 .../posix/ConnectionFileDescriptorPosix.cpp   | 29 +--
 2 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 35773d5907e913..b771f9c3f45a21 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -31,7 +31,7 @@ class ConnectionFileDescriptor : public Connection {
   typedef llvm::function_ref
   socket_id_callback_type;
 
-  ConnectionFileDescriptor(bool child_processes_inherit = false);
+  ConnectionFileDescriptor();
 
   ConnectionFileDescriptor(int fd, bool owns_fd);
 
@@ -65,9 +65,6 @@ class ConnectionFileDescriptor : public Connection {
 
   lldb::IOObjectSP GetReadObject() override { return m_io_sp; }
 
-  bool GetChildProcessesInherit() const;
-  void SetChildProcessesInherit(bool child_processes_inherit);
-
 protected:
   void OpenCommandPipe();
 
@@ -135,7 +132,6 @@ class ConnectionFileDescriptor : public Connection {
   std::atomic m_shutting_down; // This marks that we are shutting down so
  // if we get woken up from
   // BytesAvailable to disconnect, we won't try to read again.
-  bool m_child_processes_inherit;
 
   std::string m_uri;
 
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp 
b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index d0cc68826d4bb7..8a03e47ef3d900 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -52,18 +52,15 @@
 using namespace lldb;
 using namespace lldb_private;
 
-ConnectionFileDescriptor::ConnectionFileDescriptor(bool 
child_processes_inherit)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-
-  m_child_processes_inherit(child_processes_inherit) {
+ConnectionFileDescriptor::ConnectionFileDescriptor()
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   Log *log(GetLog(LLDBLog::Connection | LLDBLog::Object));
   LLDB_LOGF(log, "%p ConnectionFileDescriptor::ConnectionFileDescriptor ()",
 static_cast(this));
 }
 
 ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-  m_child_processes_inherit(false) {
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   m_io_sp =
   std::make_shared(fd, File::eOpenOptionReadWrite, owns_fd);
 
@@ -76,8 +73,7 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, 
bool owns_fd)
 }
 
 ConnectionFileDescriptor::ConnectionFileDescriptor(Socket *socket)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-  m_child_processes_inherit(false) {
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   InitializeSocket(socket);
 }
 
@@ -94,7 +90,7 @@ void ConnectionFileDescriptor::OpenCommandPipe() {
 
   Log *log = GetLog(LLDBLog::Connection);
   // Make the command file descriptor here:
-  Status result = m_pipe.CreateNew(m_child_processes_inherit);
+  Status result = m_pipe.CreateNew(/*child_processes_inherit=*/false);
   if (!result.Success()) {
 LLDB_LOGF(log,
   "%p ConnectionFileDescriptor::OpenCommandPipe () - could not "
@@ -539,7 +535,7 @@ lldb::ConnectionStatus 
ConnectionFileDescriptor::AcceptSocket(
 Status *error_ptr) {
   Status error;
   std::unique_ptr listening_socket =
-  Socket::Create(socket_protocol, m_child_processes_inherit, error);
+  Socket::Create(socket_protocol, /*child_processes_inherit=*/false, 
error);
   Socket *accepted_socket;
 
   if (!error.Fail())
@@ -567,7 +563,7 @@ 
ConnectionFileDescriptor::ConnectSocket(Socket::SocketProtocol socket_protocol,
 Status *error_ptr) {
   Status error;
   std::unique_ptr socket =
-  Socket::Create(socket_protocol, m_child_processes_inherit, error);
+  Socket::Create(socket_protocol, /*child_processes_inherit=*/false, 
error);
 
   if (!e

[Lldb-commits] [lldb] [lldb] Remove ConnectionFileDescriptor::child_process_inherit (PR #115861)

2024-11-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

It's never set to true. Inheritable FDs are also dangerous as they can end up 
processes which know nothing about them. It's better to explicitly pass a 
specific FD to a specific subprocess, which we already mostly can do using the 
ProcessLaunchInfo FileActions.

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


2 Files Affected:

- (modified) lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
(+1-5) 
- (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+8-21) 


``diff
diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 35773d5907e913..b771f9c3f45a21 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -31,7 +31,7 @@ class ConnectionFileDescriptor : public Connection {
   typedef llvm::function_ref
   socket_id_callback_type;
 
-  ConnectionFileDescriptor(bool child_processes_inherit = false);
+  ConnectionFileDescriptor();
 
   ConnectionFileDescriptor(int fd, bool owns_fd);
 
@@ -65,9 +65,6 @@ class ConnectionFileDescriptor : public Connection {
 
   lldb::IOObjectSP GetReadObject() override { return m_io_sp; }
 
-  bool GetChildProcessesInherit() const;
-  void SetChildProcessesInherit(bool child_processes_inherit);
-
 protected:
   void OpenCommandPipe();
 
@@ -135,7 +132,6 @@ class ConnectionFileDescriptor : public Connection {
   std::atomic m_shutting_down; // This marks that we are shutting down so
  // if we get woken up from
   // BytesAvailable to disconnect, we won't try to read again.
-  bool m_child_processes_inherit;
 
   std::string m_uri;
 
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp 
b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index d0cc68826d4bb7..8a03e47ef3d900 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -52,18 +52,15 @@
 using namespace lldb;
 using namespace lldb_private;
 
-ConnectionFileDescriptor::ConnectionFileDescriptor(bool 
child_processes_inherit)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-
-  m_child_processes_inherit(child_processes_inherit) {
+ConnectionFileDescriptor::ConnectionFileDescriptor()
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   Log *log(GetLog(LLDBLog::Connection | LLDBLog::Object));
   LLDB_LOGF(log, "%p ConnectionFileDescriptor::ConnectionFileDescriptor ()",
 static_cast(this));
 }
 
 ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-  m_child_processes_inherit(false) {
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   m_io_sp =
   std::make_shared(fd, File::eOpenOptionReadWrite, owns_fd);
 
@@ -76,8 +73,7 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, 
bool owns_fd)
 }
 
 ConnectionFileDescriptor::ConnectionFileDescriptor(Socket *socket)
-: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
-  m_child_processes_inherit(false) {
+: Connection(), m_pipe(), m_mutex(), m_shutting_down(false) {
   InitializeSocket(socket);
 }
 
@@ -94,7 +90,7 @@ void ConnectionFileDescriptor::OpenCommandPipe() {
 
   Log *log = GetLog(LLDBLog::Connection);
   // Make the command file descriptor here:
-  Status result = m_pipe.CreateNew(m_child_processes_inherit);
+  Status result = m_pipe.CreateNew(/*child_processes_inherit=*/false);
   if (!result.Success()) {
 LLDB_LOGF(log,
   "%p ConnectionFileDescriptor::OpenCommandPipe () - could not "
@@ -539,7 +535,7 @@ lldb::ConnectionStatus 
ConnectionFileDescriptor::AcceptSocket(
 Status *error_ptr) {
   Status error;
   std::unique_ptr listening_socket =
-  Socket::Create(socket_protocol, m_child_processes_inherit, error);
+  Socket::Create(socket_protocol, /*child_processes_inherit=*/false, 
error);
   Socket *accepted_socket;
 
   if (!error.Fail())
@@ -567,7 +563,7 @@ 
ConnectionFileDescriptor::ConnectSocket(Socket::SocketProtocol socket_protocol,
 Status *error_ptr) {
   Status error;
   std::unique_ptr socket =
-  Socket::Create(socket_protocol, m_child_processes_inherit, error);
+  Socket::Create(socket_protocol, /*child_processes_inherit=*/false, 
error);
 
   if (!error.Fail())
 error = socket->Connect(socket_name);
@@ -649,7 +645,7 @@ ConnectionFileDescriptor::ConnectUDP(llvm::StringRef s,
   if (error_ptr)
 *error_ptr = Status();
   llvm::Expected> socket =
-  Socket::UdpConnect(s, m_child_processes_inherit);
+  Socket::UdpConnect(s, /*child_processes_inherit=*/false);
   if (!socket) {
 if (error_ptr)
   *error_ptr = 

[Lldb-commits] [lldb] fix: Target Process may crash on detaching process on windows (PR #115712)

2024-11-12 Thread via lldb-commits

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


[Lldb-commits] [lldb] fix: Target Process may crash on detaching process on windows (PR #115712)

2024-11-12 Thread via lldb-commits

anatawa12 wrote:

After I changed debug-api-test, I found that calling DebugActiveProcessStop 
before ContinueDebugEvent will follow behavior specified by 
DebugSetProcessKillOnExit for some cases.

This PR only fixes this behavior, which is reported on Rider issue tracker as 
[RIDER-99436](https://youtrack.jetbrains.com/issue/RIDER-99436/Unity-Editor-will-be-crashed-when-detaching-LLDB-debugger-in-Rider).

It looks freezing in Suspended state, which are reported as #67825 and #89077, 
are completely different issue and not fixed with this PR.

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


[Lldb-commits] [lldb] fix: Target Process may crash on detaching process on windows (PR #115712)

2024-11-12 Thread via lldb-commits

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