[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-02 Thread Michael Buch via lldb-commits

Michael137 wrote:

> > Skipping empty fields does seem like a better heuristic here
> 
> FWIW, I (independently) came to the same conclusion when investigating the 
> fallout of #76756, though it's not fully clear to me whether the PR has been 
> updated to do that.

Not yet, but will have a look at this today

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


[Lldb-commits] [lldb] [LLDB] Enable TLS Variable Debugging Without Location Info on AArch64 (PR #110822)

2024-10-02 Thread Pavel Labath via lldb-commits

labath wrote:

The implementation of Variable::IsThreadLocal is most likely a non-starter, as 
it introduces a relatively expensive operation on the common variable update 
path for all variables. Doing this (once) at variable creation would be better, 
but I still have very big reservations about this approach. AFAICT, there's no 
way to guarantee that the variable you find this way will be the one that is 
actually described by the DWARF. You could even have more than one variable 
with the same name if they're `static thread_local`.

This really sounds like something where the compiler should give us more to go 
on -- instead of us trying to divine this information out of thin air.

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


[Lldb-commits] [lldb] [llvm] [lldb][DWARF] Replace lldb's DWARFDebugArangeSet with llvm's (PR #110058)

2024-10-02 Thread Carlos Alberto Enciso via lldb-commits

CarlosAlbertoEnciso wrote:

On Ubuntu 22.04 with the latest official supported GCC 12.3.0, this commit 
breaks the `check-lldb` due to a failed compilation:
```
llvm-project/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp:95:33: 
error: class template placeholder 'llvm::ArrayRef' not permitted in this context
   95 |   llvm::DWARFDataExtractor data(llvm::ArrayRef(binary_data),
  | ^~~~
```


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


[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)

2024-10-02 Thread Pavel Labath via lldb-commits

labath wrote:

> > I don't like globals
> 
> Is this the only argument? 

No, it's not. You can find my second reason in the full text of my previous 
message. The third reason is that I think this is something that should be 
handled independenly of this (already larger that I'd like) patch.

> I don't like globals too. But no one suggested better solution w/o huge 
> refactoring of MonitorProcessCallback.

You didn't ask for one either. Declaring it's [the only 
way](https://github.com/llvm/llvm-project/pull/104238#discussion_r1745282649) 
isn't the most traditional way of soliciting feedback. 

> 
> Updated. The child process will crash 50/50 at the end, but no one will see 
> it. The problem will remain hidden. Removed `fixes #101475` in the 
> description. I can create a separate patch after merging this PR.

:+1: 

I'm going to look at the patch now.

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


[Lldb-commits] [lldb] [LLDB] Enable TLS Variable Debugging Without Location Info on AArch64 (PR #110822)

2024-10-02 Thread Kamlesh Kumar via lldb-commits

https://github.com/kamleshbhalui created 
https://github.com/llvm/llvm-project/pull/110822

On AArch64, TLS variables do not have DT_Location entries generated in the 
debug information due to the lack of dtpoff relocation support, unlike on 
x86_64. LLDB relies on this location info to calculate the TLS address, leading 
to issues when debugging TLS variables on AArch64.
However, GDB can successfully calculate the TLS address without relying on this 
debug info, by using the symbol’s address and manually calculating the offset. 
We adopt a similar approach for LLDB.

Fixes #71666

>From 899c26d1a70dd332c3a0d5cd1887fac205752888 Mon Sep 17 00:00:00 2001
From: Kamlesh Kumar 
Date: Thu, 19 Sep 2024 18:57:14 +0200
Subject: [PATCH] [LLDB] Enable TLS Variable Debugging Without Location Info on
 AArch64
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On AArch64, TLS variables do not have DT_Location entries generated in the
debug information due to the lack of dtpoff relocation support, unlike on 
x86_64.
LLDB relies on this location info to calculate the TLS address, leading to 
issues
when debugging TLS variables on AArch64.
However, GDB can successfully calculate the TLS address without relying on this 
debug info,
by using the symbol’s address and manually calculating the offset. We adopt a 
similar approach for LLDB.
---
 lldb/include/lldb/Symbol/Variable.h   |  2 ++
 lldb/source/Core/ValueObjectVariable.cpp  | 33 ++-
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 14 +---
 .../Utility/RegisterInfoPOSIX_arm64.cpp   | 13 
 .../Process/Utility/RegisterInfos_arm64.h |  5 +--
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |  5 ++-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  8 +
 lldb/source/Symbol/Variable.cpp   | 11 +++
 8 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Variable.h 
b/lldb/include/lldb/Symbol/Variable.h
index c437624d1ea6d7..4ad06baeb684a4 100644
--- a/lldb/include/lldb/Symbol/Variable.h
+++ b/lldb/include/lldb/Symbol/Variable.h
@@ -79,6 +79,8 @@ class Variable : public UserID, public 
std::enable_shared_from_this {
 return m_location_list;
   }
 
+  bool IsThreadLocal() const;
+
   // When given invalid address, it dumps all locations. Otherwise it only 
dumps
   // the location that contains this address.
   bool DumpLocations(Stream *s, const Address &address);
diff --git a/lldb/source/Core/ValueObjectVariable.cpp 
b/lldb/source/Core/ValueObjectVariable.cpp
index 29aefb270c92c8..393ddc1960ab47 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -254,7 +254,38 @@ bool ValueObjectVariable::UpdateValue() {
   m_resolved_value.SetContext(Value::ContextType::Invalid, nullptr);
 }
   }
-
+  if (m_error.Fail() && variable->IsThreadLocal()) {
+ExecutionContext exe_ctx(GetExecutionContextRef());
+Thread *thread = exe_ctx.GetThreadPtr();
+lldb::ModuleSP module_sp = GetModule();
+if (!thread) {
+  m_error = Status::FromErrorString("no thread to evaluate TLS within");
+  return m_error.Success();
+}
+std::vector symbol_indexes;
+module_sp->GetSymtab()->FindAllSymbolsWithNameAndType(
+ConstString(variable->GetName()), lldb::SymbolType::eSymbolTypeAny,
+symbol_indexes);
+Symbol *symbol = module_sp->GetSymtab()->SymbolAtIndex(symbol_indexes[0]);
+lldb::addr_t tls_file_addr =
+symbol->GetAddress().GetOffset() +
+symbol->GetAddress().GetSection()->GetFileAddress();
+const lldb::addr_t tls_load_addr =
+thread->GetThreadLocalData(module_sp, tls_file_addr);
+if (tls_load_addr == LLDB_INVALID_ADDRESS)
+  m_error = Status::FromErrorString(
+  "no TLS data currently exists for this thread");
+else {
+  Value old_value(m_value);
+  m_value.GetScalar() = tls_load_addr;
+  m_value.SetContext(Value::ContextType::Variable, variable);
+  m_value.SetValueType(Value::ValueType::LoadAddress);
+  m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
+  SetValueDidChange(m_value.GetValueType() != old_value.GetValueType() ||
+m_value.GetScalar() != old_value.GetScalar());
+  SetValueIsValid(m_error.Success());
+}
+  }
   return m_error.Success();
 }
 
diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..5a78ad2286f87a 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -771,9 +771,12 @@ DynamicLoaderPOSIXDYLD::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 "GetThreadLocalData info: link_map=0x%" PRIx64
 ", thread info metadata: "
 "modid_offset=0x%" 

[Lldb-commits] [lldb] [LLDB] Enable TLS Variable Debugging Without Location Info on AArch64 (PR #110822)

2024-10-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kamlesh Kumar (kamleshbhalui)


Changes

On AArch64, TLS variables do not have DT_Location entries generated in the 
debug information due to the lack of dtpoff relocation support, unlike on 
x86_64. LLDB relies on this location info to calculate the TLS address, leading 
to issues when debugging TLS variables on AArch64.
However, GDB can successfully calculate the TLS address without relying on this 
debug info, by using the symbol’s address and manually calculating the offset. 
We adopt a similar approach for LLDB.

Fixes #71666

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


8 Files Affected:

- (modified) lldb/include/lldb/Symbol/Variable.h (+2) 
- (modified) lldb/source/Core/ValueObjectVariable.cpp (+32-1) 
- (modified) 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (+10-4) 
- (modified) lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp 
(+7-6) 
- (modified) lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h (+3-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+2-3) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+8) 
- (modified) lldb/source/Symbol/Variable.cpp (+11) 


``diff
diff --git a/lldb/include/lldb/Symbol/Variable.h 
b/lldb/include/lldb/Symbol/Variable.h
index c437624d1ea6d7..4ad06baeb684a4 100644
--- a/lldb/include/lldb/Symbol/Variable.h
+++ b/lldb/include/lldb/Symbol/Variable.h
@@ -79,6 +79,8 @@ class Variable : public UserID, public 
std::enable_shared_from_this {
 return m_location_list;
   }
 
+  bool IsThreadLocal() const;
+
   // When given invalid address, it dumps all locations. Otherwise it only 
dumps
   // the location that contains this address.
   bool DumpLocations(Stream *s, const Address &address);
diff --git a/lldb/source/Core/ValueObjectVariable.cpp 
b/lldb/source/Core/ValueObjectVariable.cpp
index 29aefb270c92c8..393ddc1960ab47 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -254,7 +254,38 @@ bool ValueObjectVariable::UpdateValue() {
   m_resolved_value.SetContext(Value::ContextType::Invalid, nullptr);
 }
   }
-
+  if (m_error.Fail() && variable->IsThreadLocal()) {
+ExecutionContext exe_ctx(GetExecutionContextRef());
+Thread *thread = exe_ctx.GetThreadPtr();
+lldb::ModuleSP module_sp = GetModule();
+if (!thread) {
+  m_error = Status::FromErrorString("no thread to evaluate TLS within");
+  return m_error.Success();
+}
+std::vector symbol_indexes;
+module_sp->GetSymtab()->FindAllSymbolsWithNameAndType(
+ConstString(variable->GetName()), lldb::SymbolType::eSymbolTypeAny,
+symbol_indexes);
+Symbol *symbol = module_sp->GetSymtab()->SymbolAtIndex(symbol_indexes[0]);
+lldb::addr_t tls_file_addr =
+symbol->GetAddress().GetOffset() +
+symbol->GetAddress().GetSection()->GetFileAddress();
+const lldb::addr_t tls_load_addr =
+thread->GetThreadLocalData(module_sp, tls_file_addr);
+if (tls_load_addr == LLDB_INVALID_ADDRESS)
+  m_error = Status::FromErrorString(
+  "no TLS data currently exists for this thread");
+else {
+  Value old_value(m_value);
+  m_value.GetScalar() = tls_load_addr;
+  m_value.SetContext(Value::ContextType::Variable, variable);
+  m_value.SetValueType(Value::ValueType::LoadAddress);
+  m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
+  SetValueDidChange(m_value.GetValueType() != old_value.GetValueType() ||
+m_value.GetScalar() != old_value.GetScalar());
+  SetValueIsValid(m_error.Success());
+}
+  }
   return m_error.Success();
 }
 
diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..5a78ad2286f87a 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -771,9 +771,12 @@ DynamicLoaderPOSIXDYLD::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 "GetThreadLocalData info: link_map=0x%" PRIx64
 ", thread info metadata: "
 "modid_offset=0x%" PRIx32 ", dtv_offset=0x%" PRIx32
-", tls_offset=0x%" PRIx32 ", dtv_slot_size=%" PRIx32 "\n",
+", tls_offset=0x%" PRIx32 ", dtv_slot_size=%" PRIx32
+", tls_file_addr=0x%" PRIx64 ", module name=%s "
+"\n",
 link_map, metadata.modid_offset, metadata.dtv_offset,
-metadata.tls_offset, metadata.dtv_slot_size);
+metadata.tls_offset, metadata.dtv_slot_size, tls_file_addr,
+module_sp->GetFileSpec().GetFilename().AsCString());
 
   // Get the thread pointer.
   addr_t tp = thread->GetThreadPointer();
@@ -790,9 +793,12 @@ DynamicLoaderPOSIXD

[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-02 Thread Pavel Labath via lldb-commits


@@ -6528,6 +6528,74 @@ static void AddRegion(const MemoryRegionInfo ®ion, 
bool try_dirty_pages,
 CreateCoreFileMemoryRange(region));
 }
 
+static void AddRegisterSections(Process &process, ThreadSP &thread_sp,
+CoreFileMemoryRanges &ranges,
+lldb::addr_t range_end) {
+  lldb::RegisterContextSP reg_ctx = thread_sp->GetRegisterContext();
+  if (!reg_ctx)
+return;
+
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
+  lldb::RegisterKind::eRegisterKindGeneric, LLDB_REGNUM_GENERIC_TP);
+  if (!reg_info)
+return;
+
+  lldb_private::RegisterValue reg_value;
+  bool success = reg_ctx->ReadRegister(reg_info, reg_value);
+  if (!success)
+return;
+
+  const uint64_t fail_value = UINT64_MAX;
+  bool readSuccess = false;
+  const lldb::addr_t reg_value_addr =
+  reg_value.GetAsUInt64(fail_value, &readSuccess);
+  if (!readSuccess || reg_value_addr == fail_value)
+return;
+
+  MemoryRegionInfo register_region;
+  Status err = process.GetMemoryRegionInfo(reg_value_addr, register_region);
+  if (err.Fail())
+return;
+
+  // We already saved off this truncated stack range.
+  if (register_region.GetRange().GetRangeEnd() == range_end)
+return;
+
+  // We don't need to worry about duplication because the CoreFileMemoryRanges
+  // will unique them
+  AddRegion(register_region, true, ranges);
+}
+
+static void AddModuleSections(Process &process, CoreFileMemoryRanges &ranges,
+  std::set &stack_ends) {
+  ModuleList &module_list = process.GetTarget().GetImages();
+  Target *target = &process.GetTarget();
+  for (size_t idx = 0; idx < module_list.GetSize(); idx++) {
+ModuleSP module_sp = module_list.GetModuleAtIndex(idx);
+if (!module_sp)
+  continue;
+
+ObjectFile *obj = module_sp->GetObjectFile();
+if (!obj)
+  continue;
+Address addr = obj->GetImageInfoAddress(target);
+addr_t load_addr = addr.GetLoadAddress(target);
+if (load_addr == LLDB_INVALID_ADDRESS)
+  continue;
+
+MemoryRegionInfo tls_storage_region;
+Status err = process.GetMemoryRegionInfo(load_addr, tls_storage_region);

labath wrote:

I can believe that. My point is that the `tls_storage_region` is not a good 
name for this variable since it does not actually contain the thread-local data.

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-02 Thread Pavel Labath via lldb-commits


@@ -108,21 +108,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
   // if we dont have a load address we cant re-base
   bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
 
-  // if we have a valid executable

labath wrote:

Yeah, let's go with that. Can you create a separate PR for this bit?

https://github.com/llvm/llvm-project/pull/109477
___
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-10-02 Thread Pavel Labath via lldb-commits


@@ -541,9 +542,18 @@ size_t ELFLinuxSigInfo::GetSize(const 
lldb_private::ArchSpec &arch) {
   }
 }
 
+static bool IsSignalWithAddrValue(int signo) {
+  // SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP
+  // We can't use the enum here because it may not be available on windows or
+  // other platforms. We should make an LLDB platform agnostic enum for this

labath wrote:

We already have that. This data is encoded in the `process->GetUnixSignals()` 
object. You just need to plumb it to the right place.

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] [clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)

2024-10-02 Thread Sean Perry via lldb-commits

perry-ca wrote:

> > sorry this is same as #107906 (with a bigger impact radius, as you're also 
> > changing getBufferForFile) and doesn't address any of the issues mention 
> > about explaining the semantics of `IsText` or justification for changing 
> > the core VFS interfaces, for an operation that's can solely be performed on 
> > physical fileystem.
> > @perry-ca raised some concerns in #109664 about this functionality 
> > requiring some context awareness, I don't think any of those is addressed 
> > by this patch either. Pretty much all of the callers apart from ASTReader 
> > is just using `IsText = true`.
> 
> To give some context, the problem we are trying to solve initially is that 
> file opened by `#embed` should not be utf-8 converted.

Correct.  The overall/original problem is that we have many places where text 
files were being read as binary files.  Adding the IsText parameter to the 
openFileForRead() function just like we have in the getFileOrStdin() group of 
functions solves that problem.  It tells the compiler to read files that should 
be text as text and binary as binary.

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


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)

2024-10-02 Thread Abhina Sree via lldb-commits

abhina-sree wrote:

> > sorry this is same as #107906 (with a bigger impact radius, as you're also 
> > changing getBufferForFile) and doesn't address any of the issues mention 
> > about explaining the semantics of `IsText` or justification for changing 
> > the core VFS interfaces, for an operation that's can solely be performed on 
> > physical fileystem.
> > @perry-ca raised some concerns in #109664 about this functionality 
> > requiring some context awareness, I don't think any of those is addressed 
> > by this patch either. Pretty much all of the callers apart from ASTReader 
> > is just using `IsText = true`.
> 
> To give some context, the problem we are trying to solve initially is that 
> file opened by `#embed` should not be utf-8 converted.

Thanks, I've tested the `#embed` lit tests with this fix and did not see any 
regressions

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


[Lldb-commits] [lldb] [lldb][CMake] Add single target that runs libc++ tests (PR #110856)

2024-10-02 Thread Louis Dionne via lldb-commits


@@ -267,6 +267,21 @@ add_lit_testsuite(check-lldb "Running lldb lit test suite"
 lldb-shell-test-deps
 lldb-unit-test-deps)
 
+# This target covers all targets that are tied to implementation details
+# of libc++, intended to be run by the libc++ pre-merge CI.
+add_lit_testsuite(check-lldb-libcxx-integration "Running lldb libc++ support 
test suite"

ldionne wrote:

As part of this patch, you could also change 
https://github.com/llvm/llvm-project/blob/main/libcxx/utils/ci/run-buildbot#L374
 to call this target, that way everything is already plumbed together!

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


[Lldb-commits] [libcxx] [lldb] [lldb][CMake] Add single target that runs libc++ tests (PR #110856)

2024-10-02 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/110856

>From ee28f91822ca449b7b4bb84293cae2aee6803da4 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 2 Oct 2024 15:44:28 +0100
Subject: [PATCH 1/2] [lldb][CMake] Add single target that runs libc++ tests

---
 lldb/test/CMakeLists.txt | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..656f9a1727b316 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -267,6 +267,21 @@ add_lit_testsuite(check-lldb "Running lldb lit test suite"
 lldb-shell-test-deps
 lldb-unit-test-deps)
 
+# This target covers all targets that are tied to implementation details
+# of libc++, intended to be run by the libc++ pre-merge CI.
+add_lit_testsuite(check-lldb-libcxx-integration "Running lldb libc++ support 
test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS
+check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx
+check-lldb-api-functionalities-data-formatter-data-formatter-stl-generic
+
check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx-simulators
+check-lldb-api-commands-expression-import-std-module
+check-lldb-api-lang-cpp-std-function-step-into-callable
+check-lldb-api-lang-cpp-std-function-recognizer
+check-lldb-api-lang-cpp-std-invoke-recognizer
+)
+
 if(LLDB_BUILT_STANDALONE)
   # This has to happen *AFTER* add_lit_testsuite.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)

>From 8aea28660f43b35b9c804c585bc0d83a174e4b23 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 2 Oct 2024 19:41:35 +0100
Subject: [PATCH 2/2] fixup! adjust the libc++ pre-merge CI to run the new
 target

---
 libcxx/utils/ci/run-buildbot | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 229963b38f52b3..5fb1a31995f7ce 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -371,13 +371,7 @@ bootstrapping-build)
   -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml 
--timeout=1500 --time-tests"
 
 echo "+++ Running the LLDB libc++ data formatter tests"
-${NINJA} -vC "${BUILD_DIR}" 
check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx \
-
check-lldb-api-functionalities-data-formatter-data-formatter-stl-generic \
-
check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx-simulators
 \
-
check-lldb-api-commands-expression-import-std-module \
-
check-lldb-api-lang-cpp-std-function-step-into-callable \
-
check-lldb-api-lang-cpp-std-function-recognizer \
-check-lldb-api-lang-cpp-std-invoke-recognizer
+${NINJA} -vC "${BUILD_DIR}" check-lldb-libcxx-integration
 
 
 echo "--- Running the libc++ and libc++abi tests"

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


[Lldb-commits] [libcxx] [lldb] [llvm] [lldb][CMake] Add single target that runs libc++ tests (PR #110856)

2024-10-02 Thread Michael Buch via lldb-commits


@@ -267,6 +267,21 @@ add_lit_testsuite(check-lldb "Running lldb lit test suite"
 lldb-shell-test-deps
 lldb-unit-test-deps)
 
+# This target covers all targets that are tied to implementation details
+# of libc++, intended to be run by the libc++ pre-merge CI.
+add_lit_testsuite(check-lldb-libcxx-integration "Running lldb libc++ support 
test suite"

Michael137 wrote:

good idea, done!

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


[Lldb-commits] [libcxx] [lldb] [llvm] [lldb][CMake] Add single target that runs libc++ tests (PR #110856)

2024-10-02 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/110856

>From ee28f91822ca449b7b4bb84293cae2aee6803da4 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 2 Oct 2024 15:44:28 +0100
Subject: [PATCH 1/3] [lldb][CMake] Add single target that runs libc++ tests

---
 lldb/test/CMakeLists.txt | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..656f9a1727b316 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -267,6 +267,21 @@ add_lit_testsuite(check-lldb "Running lldb lit test suite"
 lldb-shell-test-deps
 lldb-unit-test-deps)
 
+# This target covers all targets that are tied to implementation details
+# of libc++, intended to be run by the libc++ pre-merge CI.
+add_lit_testsuite(check-lldb-libcxx-integration "Running lldb libc++ support 
test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS
+check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx
+check-lldb-api-functionalities-data-formatter-data-formatter-stl-generic
+
check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx-simulators
+check-lldb-api-commands-expression-import-std-module
+check-lldb-api-lang-cpp-std-function-step-into-callable
+check-lldb-api-lang-cpp-std-function-recognizer
+check-lldb-api-lang-cpp-std-invoke-recognizer
+)
+
 if(LLDB_BUILT_STANDALONE)
   # This has to happen *AFTER* add_lit_testsuite.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)

>From 8527773d0db142d0e6eb69de6264938cc9cb3293 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 2 Oct 2024 16:52:37 +0100
Subject: [PATCH 2/3] Revert "Revert "[libc++] LWG3870: Remove `voidify`
 (#110355)" (#110587)"

This reverts commit f3d58f4161b86a479f68acb453e9622911c688a0.
---
 libcxx/docs/Status/Cxx23Issues.csv|  2 +-
 libcxx/include/CMakeLists.txt |  1 -
 libcxx/include/__memory/construct_at.h|  5 ++-
 libcxx/include/__memory/shared_ptr.h  | 14 
 .../__memory/uninitialized_algorithms.h   | 21 ++--
 libcxx/include/__memory/voidify.h | 30 -
 libcxx/include/module.modulemap   |  1 -
 libcxx/include/optional   |  6 ++--
 .../construct_at.pass.cpp | 15 -
 .../ranges_construct_at.pass.cpp  | 10 --
 ...s_uninitialized_default_construct.pass.cpp | 25 --
 ...uninitialized_default_construct_n.pass.cpp | 12 ---
 ...ges_uninitialized_value_construct.pass.cpp | 25 --
 ...s_uninitialized_value_construct_n.pass.cpp | 12 ---
 .../ranges_uninitialized_copy.pass.cpp| 33 ---
 .../ranges_uninitialized_copy_n.pass.cpp  | 16 -
 .../ranges_uninitialized_fill_n.pass.cpp  | 14 
 .../ranges_uninitialized_fill.pass.cpp| 29 
 .../ranges_uninitialized_move.pass.cpp| 33 ---
 .../ranges_uninitialized_move_n.pass.cpp  | 16 -
 .../gn/secondary/libcxx/include/BUILD.gn  |  1 -
 21 files changed, 24 insertions(+), 297 deletions(-)
 delete mode 100644 libcxx/include/__memory/voidify.h

diff --git a/libcxx/docs/Status/Cxx23Issues.csv 
b/libcxx/docs/Status/Cxx23Issues.csv
index 1c8bb057b09660..63e4176ecba1d7 100644
--- a/libcxx/docs/Status/Cxx23Issues.csv
+++ b/libcxx/docs/Status/Cxx23Issues.csv
@@ -296,7 +296,7 @@
 "`LWG3862 `__","``basic_const_iterator``'s 
``common_type`` specialization is underconstrained","2023-02 
(Issaquah)","","",""
 "`LWG3865 `__","Sorting a range of 
``pairs``","2023-02 (Issaquah)","|Complete|","17.0",""
 "`LWG3869 `__","Deprecate ``std::errc`` constants 
related to UNIX STREAMS","2023-02 (Issaquah)","|Complete|","19.0",""
-"`LWG3870 `__","Remove ``voidify``","2023-02 
(Issaquah)","","",""
+"`LWG3870 `__","Remove ``voidify``","2023-02 
(Issaquah)","|Complete|","20.0",""
 "`LWG3871 `__","Adjust note about 
``terminate``","2023-02 (Issaquah)","","",""
 "`LWG3872 `__","``basic_const_iterator`` should 
have custom ``iter_move``","2023-02 (Issaquah)","","",""
 "`LWG3875 `__","``std::ranges::repeat_view::iterator`` may be ill-formed","2023-02 
(Issaquah)","|Complete|","17.0",""
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 8a63280053340f..9bd1b41b8bfac4 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -560,7 +560,6 @@ set(files
   __memory/unique_temporary_buffer.h
   __memory/uses_allocator.h
   __memory/uses_allocator_construction.h
-  __memory/voidify.h
   __memory_resource/memory_resource.h
   __memory_resource/monotonic_buffer_resource.h
   __memory_resource/polymorph

[Lldb-commits] [libcxx] [lldb] [lldb][CMake] Add single target that runs libc++ tests (PR #110856)

2024-10-02 Thread Louis Dionne via lldb-commits

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

Libc++ changes LGTM. Thank you!

https://github.com/llvm/llvm-project/pull/110856
___
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-10-02 Thread Pavel Labath via lldb-commits


@@ -556,6 +566,22 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, 
const ArchSpec &arch) {
   si_signo = data.GetU32(&offset);
   si_errno = data.GetU32(&offset);
   si_code = data.GetU32(&offset);
+  // 64b ELF have a 4 byte pad.
+  if (data.GetAddressByteSize() == 8)
+offset += 4;
+  if (IsSignalWithAddrValue(si_signo)) {
+addr = data.GetAddress(&offset);
+addr_lsb = data.GetU16(&offset);
+  }
 
   return error;
 }
+
+std::string ELFLinuxSigInfo::GetDescription() {
+  if (IsSignalWithAddrValue(si_signo))
+return lldb_private::UnixSignals::CreateForHost()->GetSignalDescription(

labath wrote:

And this shouldn't be using the *Host* UnixSignals object for the same reason. 
Get the one from the `Process` instance.

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] 8712140 - [lldb][RISCV] function calls support in lldb expressions (#99336)

2024-10-02 Thread via lldb-commits

Author: dlav-sc
Date: 2024-10-02T12:08:22+03:00
New Revision: 87121403e251828ed0fee8a9c2a2993ce8f57861

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

LOG: [lldb][RISCV] function calls support in lldb expressions (#99336)

[lldb][RISCV] add jitted function calls to ABI
Function calls support in LLDB expressions for RISCV: 1 of 4

Augments corresponding functionality to RISCV ABI, which allows to jit
lldb expressions and thus make function calls inside them. Only function
calls with integer and void function arguments and return value are
supported.

[lldb][RISCV] add JIT relocations resolver
Function calls support in LLDB expressions for RISCV: 2 of 4

Adds required RISCV relocations resolving functionality in lldb
ExecutionEngine.

[lldb][RISCV] RISC-V large code model in lldb expressions
Function calls support in LLDB expressions for RISCV: 3 of 4

This patch sets large code model in MCJIT settings for RISC-V 64-bit targets
that allows to make assembly jumps at any 64bit address. This is needed,
because resulted jitted code may contain more that +-2GB jumps, that are
not available in RISC-V with medium code model.

[lldb][RISCV] doubles support in lldb expressions
Function calls support in LLDB expressions for RISCV: 4 of 4

This patch adds desired feature flags in MCJIT compiler to enable
hard-float instructions if target supports them and allows to use floats
and doubles in lldb expressions.

Added: 


Modified: 
lldb/source/Expression/IRExecutionUnit.cpp
lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h

Removed: 




diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 15ca2ddbbae046..baf70cbccc8c5c 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -277,6 +277,12 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, 
lldb::addr_t &func_addr,
   .setMCJITMemoryManager(std::make_unique(*this))
   .setOptLevel(llvm::CodeGenOptLevel::Less);
 
+  // Resulted jitted code can be placed too far from the code in the binary
+  // and thus can contain more than +-2GB jumps, that are not available
+  // in RISC-V without large code model.
+  if (triple.isRISCV64())
+builder.setCodeModel(llvm::CodeModel::Large);
+
   llvm::StringRef mArch;
   llvm::StringRef mCPU;
   llvm::SmallVector mAttrs;

diff  --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp 
b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
index de304183f67175..38d452b6ab560c 100644
--- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
+++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
@@ -10,7 +10,9 @@
 
 #include 
 #include 
+#include 
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/IR/DerivedTypes.h"
 
 #include "Utility/RISCV_DWARF_Registers.h"
@@ -20,6 +22,7 @@
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/RegisterValue.h"
 
 #define DEFINE_REG_NAME(reg_num) ConstString(#reg_num).GetCString()
@@ -120,6 +123,10 @@ static const std::array g_register_infos 
= {
 } // namespace dwarf
 } // namespace
 
+// Number of argument registers (the base integer calling convention
+// provides 8 argument registers, a0-a7)
+static constexpr size_t g_regs_for_args_count = 8U;
+
 const RegisterInfo *ABISysV_riscv::GetRegisterInfoArray(uint32_t &count) {
   count = dwarf::g_register_infos.size();
   return dwarf::g_register_infos.data();
@@ -164,11 +171,81 @@ TotalArgsSizeInWords(bool is_rv64,
   return total_size;
 }
 
+static bool UpdateRegister(RegisterContext *reg_ctx,
+   const lldb::RegisterKind reg_kind,
+   const uint32_t reg_num, const addr_t value) {
+  Log *log = GetLog(LLDBLog::Expressions);
+
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(reg_kind, reg_num);
+
+  LLDB_LOG(log, "Writing {0}: 0x{1:x}", reg_info->name,
+   static_cast(value));
+  if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, value)) {
+LLDB_LOG(log, "Writing {0}: failed", reg_info->name);
+return false;
+  }
+  return true;
+}
+
+static void LogInitInfo(Log &log, const Thread &thread, addr_t sp,
+addr_t func_addr, addr_t return_addr,
+const llvm::ArrayRef args) {
+  std::stringstream ss;
+  ss << "ABISysV_riscv::PrepareTrivialCall"
+ << " (tid = 0x" << std::hex << thread.GetID() << ", sp = 0x" << sp
+ << ", func_addr = 0x" << func_addr << ", return_addr = 0x" << return_addr;
+
+

[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)

2024-10-02 Thread via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)

2024-10-02 Thread via lldb-commits

dlav-sc wrote:

Thank you for the review.

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


[Lldb-commits] [lldb] [lldb][dotest] Add an arg to add DLL search paths. (PR #104514)

2024-10-02 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

@labath @kendalharland Here is an attempt to fix this in the bindings 
themselves: https://github.com/swiftlang/llvm-project/pull/9370 What do you 
think?

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


[Lldb-commits] [lldb] 15f9020 - [lldb/DWARF] Respect member layout for types parsed through declarations (#110648)

2024-10-02 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-10-02T11:13:43+02:00
New Revision: 15f90203bcbc685e8d63a7e52e60adff02bf5499

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

LOG: [lldb/DWARF] Respect member layout for types parsed through declarations 
(#110648)

LLDB code for using the type layout data from DWARF was not kicking in
for types which were initially parsed from a declaration. The problem
was in these lines of code:

```
  if (type)
layout_info.bit_size = type->GetByteSize(nullptr).value_or(0) * 8;
```

which determine the types layout size by getting the size from the
lldb_private::Type object. The problem is that if the type object does
not have this information cached, this request can trigger another
(recursive) request to lay out/complete the type. This one, somewhat
surprisingly, succeeds, but does that without the type layout
information (because it hasn't been computed yet). The reasons why this
hasn't been noticed so far are:
- this is a relatively new bug. I haven't checked but I suspect it was
introduced in the "delay type definition search" patchset from this
summer -- if we search for the definition eagerly, we will always have a
cached size value.
- it requires the presence of another bug/issue, as otherwise the
automatically computed layout will match the real thing.
- it reproduces (much) more easily with -flimit-debug-info (though it is
possible to trigger it without that flag).

My fix consists of always fetching type size information from DWARF
(which so far existed as a fallback path). I'm not quite sure why this
code was there in the first place (the code goes back to before the
Great LLDB Reformat), but I don't believe it is necessary, as the type
size (for types parsed from definition DIEs) is set exactly from this
attribute (in ParseStructureLikeDIE).

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-unusual-layout.s

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-with-children.s

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 70540fe7fada68..a30d898a93cc4d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2128,14 +2128,10 @@ bool DWARFASTParserClang::CompleteRecordType(const 
DWARFDIE &die,
   TypeSystemClang::BuildIndirectFields(clang_type);
   TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
 
-  if (type)
-layout_info.bit_size = type->GetByteSize(nullptr).value_or(0) * 8;
-  if (layout_info.bit_size == 0)
-layout_info.bit_size =
-die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
-  if (layout_info.alignment == 0)
-layout_info.alignment =
-die.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_alignment, 0) * 8;
+  layout_info.bit_size =
+  die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
+  layout_info.alignment =
+  die.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_alignment, 0) * 8;
 
   clang::CXXRecordDecl *record_decl =
   m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());

diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-unusual-layout.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-unusual-layout.s
new file mode 100644
index 00..27715c5004720a
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-unusual-layout.s
@@ -0,0 +1,132 @@
+## Test that lldb respects the layout defined in DWARF even when starting out
+## with a declaration of the class.
+
+# RUN: split-file %s %t
+# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj -o %t.o
+# RUN: %lldb -s %t/commands -o exit %t.o 2>&1 | FileCheck %s
+
+#--- commands
+target var a -fx
+# CHECK-LABEL: target var a
+# CHECK: (A) a = (i = 0xbaadf00d)
+
+#--- asm
+.data
+.p2align 4
+.long 0
+a:
+.long  0xdeadbeef
+.long  0xbaadf00d
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   52  # DW_TAG_variable
+.byte   0   # DW_CHI

[Lldb-commits] [lldb] [lldb/DWARF] Respect member layout for types parsed through declarations (PR #110648)

2024-10-02 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-02 Thread Pavel Labath via lldb-commits

labath wrote:

> Skipping empty fields does seem like a better heuristic here

FWIW, I (independently) came to the same conclusion when investigating the 
fallout of  #76756, though it's not fully clear to me whether the PR has been 
updated to do that.

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


[Lldb-commits] [lldb] e379b4b - [lldb] Fix compile failure on SymbolFileDWARFTests.cpp with gcc

2024-10-02 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2024-10-02T14:11:04-07:00
New Revision: e379b4b67f760e743d8bc826cc6de00a27109dbd

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

LOG: [lldb] Fix compile failure on SymbolFileDWARFTests.cpp with gcc

We need to explicitly specify template argument for llvm::ArrayRef when 
building with gcc.

Added: 


Modified: 
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Removed: 




diff  --git a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
index f9e869297bfb06..37ecfea26f36cc 100644
--- a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -92,7 +92,7 @@ TEST_F(SymbolFileDWARFTests, ParseArangesNonzeroSegmentSize) {
   // END TUPLES
   0, 0, 0, 0, 0, 0, 0, 0, 0 // terminator
   };
-  llvm::DWARFDataExtractor data(llvm::ArrayRef(binary_data),
+  llvm::DWARFDataExtractor data(llvm::ArrayRef(binary_data),
 /*isLittleEndian=*/false, /*AddrSize=*/4);
 
   DWARFDebugArangeSet debug_aranges;



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


[Lldb-commits] [lldb] [llvm] [lldb][DWARF] Replace lldb's DWARFDebugArangeSet with llvm's (PR #110058)

2024-10-02 Thread Zequan Wu via lldb-commits

ZequanWu wrote:

> On Ubuntu 22.04 with the latest official supported GCC 12.3.0, this commit 
> breaks the `check-lldb` due to a failed compilation:
> 
> ```
> llvm-project/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp:95:33: 
> error: class template placeholder 'llvm::ArrayRef' not permitted in this 
> context
>95 |   llvm::DWARFDataExtractor data(llvm::ArrayRef(binary_data),
>   | ^~~~
> ```

Hope 
https://github.com/llvm/llvm-project/commit/e379b4b67f760e743d8bc826cc6de00a27109dbd
 will fix it.

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-02 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/110901

>From 262ff5a7a24403eaee1c5b9f95db118925494eb1 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 1 Oct 2024 17:39:10 -0700
Subject: [PATCH] Support inline diagnostics in CommandReturnObject

and implement them for dwim-print (a.k.a. `p`) as an example.

The next step will be to expose them as structured data in
SBCommandReturnObject.
---
 .../lldb/Expression/DiagnosticManager.h   | 33 ++-
 .../lldb/Interpreter/CommandReturnObject.h| 15 ---
 .../lldb/Utility/DiagnosticsRendering.h   | 25 +++
 lldb/include/lldb/Utility/Status.h| 31 ++
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +
 .../Commands/CommandObjectExpression.cpp  |  5 +--
 .../source/Interpreter/CommandInterpreter.cpp | 15 +--
 .../Interpreter/CommandReturnObject.cpp   | 41 ++-
 lldb/source/Utility/CMakeLists.txt|  1 +
 .../DiagnosticsRendering.cpp} | 25 +--
 .../Shell/Commands/command-dwim-print.test| 16 
 lldb/unittests/Interpreter/CMakeLists.txt |  1 -
 lldb/unittests/Utility/CMakeLists.txt |  1 +
 .../DiagnosticsRenderingTest.cpp} |  6 +--
 14 files changed, 155 insertions(+), 62 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/DiagnosticsRendering.h
 rename lldb/source/{Commands/DiagnosticRendering.h => 
Utility/DiagnosticsRendering.cpp} (83%)
 create mode 100644 lldb/test/Shell/Commands/command-dwim-print.test
 rename lldb/unittests/{Interpreter/TestCommandObjectExpression.cpp => 
Utility/DiagnosticsRenderingTest.cpp} (84%)

diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h 
b/lldb/include/lldb/Expression/DiagnosticManager.h
index b9a6421577781e..f90a8764e13962 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -23,35 +23,6 @@
 
 namespace lldb_private {
 
-/// A compiler-independent representation of a Diagnostic. Expression
-/// evaluation failures often have more than one diagnostic that a UI
-/// layer might want to render differently, for example to colorize
-/// it.
-///
-/// Running example:
-///   (lldb) expr 1+foo
-///   error: :1:3: use of undeclared identifier 'foo'
-///   1+foo
-/// ^
-struct DiagnosticDetail {
-  struct SourceLocation {
-FileSpec file;
-unsigned line = 0;
-uint16_t column = 0;
-uint16_t length = 0;
-bool hidden = false;
-bool in_user_input = false;
-  };
-  /// Contains {{}, 1, 3, 3, true} in the example above.
-  std::optional source_location;
-  /// Contains eSeverityError in the example above.
-  lldb::Severity severity = lldb::eSeverityInfo;
-  /// Contains "use of undeclared identifier 'x'" in the example above.
-  std::string message;
-  /// Contains the fully rendered error message.
-  std::string rendered;
-};
-
 /// An llvm::Error used to communicate diagnostics in Status. Multiple
 /// diagnostics may be chained in an llvm::ErrorList.
 class ExpressionError
@@ -65,7 +36,9 @@ class ExpressionError
   ExpressionError(lldb::ExpressionResults result, std::string msg,
   std::vector details = {});
   std::string message() const override;
-  llvm::ArrayRef GetDetails() const { return m_details; }
+  llvm::ArrayRef GetDetails() const override {
+return m_details;
+  }
   std::error_code convertToErrorCode() const override;
   void log(llvm::raw_ostream &OS) const override;
   std::unique_ptr Clone() const override;
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8f6c9f123b7690..97b47148829ec8 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -29,6 +29,9 @@ class CommandReturnObject {
 
   ~CommandReturnObject() = default;
 
+  llvm::StringRef GetInlineDiagnosticsData(unsigned indent,
+   llvm::StringRef command);
+
   llvm::StringRef GetOutputData() {
 lldb::StreamSP 
stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
 if (stream_sp)
@@ -36,12 +39,7 @@ class CommandReturnObject {
 return llvm::StringRef();
   }
 
-  llvm::StringRef GetErrorData() {
-lldb::StreamSP 
stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex));
-if (stream_sp)
-  return std::static_pointer_cast(stream_sp)->GetString();
-return llvm::StringRef();
-  }
+  llvm::StringRef GetErrorData();
 
   Stream &GetOutputStream() {
 // Make sure we at least have our normal string stream output stream
@@ -135,6 +133,8 @@ class CommandReturnObject {
 
   void SetError(llvm::Error error);
 
+  void SetUserInput(llvm::StringRef user_input) { m_user_input = user_input; }
+
   lldb::ReturnStatus GetStatus() const;
 
   void SetStatus(lldb::ReturnStatus status);
@@ -160,6 +160,9 @@ class CommandReturnObject {
 
   Strea

[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-02 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Side note: I also think that it should be possible to change 
CommandObjectExpression to just put the error into CommendReturnObject instead 
of printing it to the error stream directly. But that's for a future patch.

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


[Lldb-commits] [lldb] [lldb-dap] Correct auto-completion based on ReplMode and escape char (PR #110784)

2024-10-02 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/110784

>From 41694e6e64b3f16cc5b8e4b64c89d27f4e076573 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 20 Sep 2024 20:43:11 +
Subject: [PATCH 1/3] [lldb-dap] Correct auto-completion based on ReplMode and
 escape char

This commit improves the auto-completion in the Debug Console provided
by VS-Code.

So far, we were always suggesting completions for both LLDB commands and
for variables / expressions, even if the heuristic already determined
how the given string will be executed, e.g., because the user explicitly
typed the escape prefix. Furthermore, auto-completion after the escape
character was broken, since the offsets were not adjusted correctly.
With this commit we now correctly take this into account.

Even with this commit, auto-completion does not always work reliably:

* VS Code only requests auto-completion after typing the first
  alphabetic character, but not after punctuation characters. This means
  that no completions are provided after typing "`"
* LLDB does not provide autocompletions if a string is an exact match.
  This means if a user types `l` (which is a valid command), LLDB will
  not provide "language" and "log" as potential completions. Even worse,
  VS Code caches the completion and does client-side filtering. Hence,
  even after typing `la`, no auto-completion for "language" is shown in
  the UI.

Those issues might be fixed in follow-up commits. Also with those known
issues, the experience is already much better with this commit.

Furthermore, I updated the README since I noticed that it was slightly
inaccurate.
---
 .../test/tools/lldb-dap/dap_server.py |   2 +-
 .../completions/TestDAP_completions.py| 212 +-
 lldb/tools/lldb-dap/DAP.cpp   |  24 +-
 lldb/tools/lldb-dap/DAP.h |  30 ++-
 lldb/tools/lldb-dap/README.md |  10 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  21 +-
 6 files changed, 217 insertions(+), 82 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 449af1b67d8022..1d5e6e0d75c7cb 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -1006,7 +1006,7 @@ def request_compileUnits(self, moduleId):
 return response
 
 def request_completions(self, text, frameId=None):
-args_dict = {"text": text, "column": len(text)}
+args_dict = {"text": text, "column": len(text) + 1}
 if frameId:
 args_dict["frameId"] = frameId
 command_dict = {
diff --git a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py 
b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
index 2b3ec656c107a5..ae0fe00fec67e8 100644
--- a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
+++ b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
@@ -9,6 +9,25 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+session_completion = {
+"text": "session",
+"label": "session -- Commands controlling LLDB session.",
+}
+settings_completion = {
+"text": "settings",
+"label": "settings -- Commands for managing LLDB settings.",
+}
+memory_completion = {
+"text": "memory",
+"label": "memory -- Commands for operating on memory in the current target 
process."
+}
+command_var_completion = {
+"text": "var",
+"label": "var -- Show variables for the current stack frame. Defaults to 
all arguments and local variables in scope. Names of argument, local, file 
static and file global variables can be specified.",
+}
+variable_var_completion = { "text": "var", "label": "var -- vector &", }
+variable_var1_completion = {"text": "var1", "label": "var1 -- int &"}
+variable_var2_completion = {"text": "var2", "label": "var2 -- int &"}
 
 class TestDAP_completions(lldbdap_testcase.DAPTestCaseBase):
 def verify_completions(self, actual_list, expected_list, 
not_expected_list=[]):
@@ -18,12 +37,8 @@ def verify_completions(self, actual_list, expected_list, 
not_expected_list=[]):
 for not_expected_item in not_expected_list:
 self.assertNotIn(not_expected_item, actual_list)
 
-@skipIfWindows
-@skipIf(compiler="clang", compiler_version=["<", "17.0"])
-def test_completions(self):
-"""
-Tests the completion request at different breakpoints
-"""
+
+def setup_debugee(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)
 
@@ -32,90 +47,146 @@ def test_completions(self):
 breakpoint2_line = line_number(source, "// breakpoint 2")
 
 self.set_source_breakpoints(source, [breakpoint1_line, 
breakpoint2_line])
+
+
+def test_command_completions(self):
+"""
+

[Lldb-commits] [lldb] [lldb-dap] Correct auto-completion based on ReplMode and escape char (PR #110784)

2024-10-02 Thread Adrian Vogelsgesang via lldb-commits


@@ -32,90 +47,146 @@ def test_completions(self):
 breakpoint2_line = line_number(source, "// breakpoint 2")
 
 self.set_source_breakpoints(source, [breakpoint1_line, 
breakpoint2_line])
+
+
+def test_command_completions(self):
+"""
+Tests completion requests for lldb commands, within "repl-mode=command"
+"""
+self.setup_debugee()
 self.continue_to_next_stop()
 
-# shouldn't see variables inside main
+res = self.dap_server.request_evaluate("`lldb-dap repl-mode command", 
context="repl")
+self.assertTrue(res["success"])
+
+# Provides completion for top-level commands
 self.verify_completions(
-self.dap_server.get_completions("var"),
+self.dap_server.get_completions("se"),
+[session_completion, settings_completion]
+)
+
+# Provides completions for sub-commands
+self.verify_completions(
+self.dap_server.get_completions("memory "),
 [
 {
-"text": "var",
-"label": "var -- vector &",
+"text": "read",
+"label": "read -- Read from the memory of the current 
target process."
 },
 {
-"text": "var",
-"label": "var -- Show variables for the current stack 
frame. Defaults to all arguments and local variables in scope. Names of 
argument, local, file static and file global variables can be specified.",
+"text": "region",
+"label": "region -- Get information on the memory region 
containing an address in the current target process.",
 },
-],
-[
-{"text": "var1", "label": "var1 -- int &"},
-],
+]
 )
 
-# should see global keywords but not variables inside main
+# Provides completions for parameter values of commands
 self.verify_completions(
-self.dap_server.get_completions("str"),
-[{"text": "struct", "label": "struct"}],
-[{"text": "str1", "label": "str1 -- std::string &"}],
+self.dap_server.get_completions("`log enable  "),
+[{"text": "gdb-remote", "label": "gdb-remote"}],
 )
 
-self.continue_to_next_stop()
+# Also works if the escape prefix is used
+self.verify_completions(
+self.dap_server.get_completions("`mem"),
+[memory_completion]
+)
 
-# should see variables from main but not from the other function
 self.verify_completions(
-self.dap_server.get_completions("var"),
-[
-{"text": "var1", "label": "var1 -- int &"},
-{"text": "var2", "label": "var2 -- int &"},
-],
+self.dap_server.get_completions("`"),
+[session_completion, settings_completion, memory_completion]
+)
+
+
+# Completes an incomplete quoted token
+self.verify_completions(
+self.dap_server.get_completions('setting "se'),
 [
 {
-"text": "var",
-"label": "var -- vector &",
+"text": "set",
+"label": "set -- Set the value of the specified debugger 
setting.",
 }
 ],
 )
 
+# Completes an incomplete quoted token
 self.verify_completions(
-self.dap_server.get_completions("str"),
-[
-{"text": "struct", "label": "struct"},
-{"text": "str1", "label": "str1 -- string &"},
-],
+self.dap_server.get_completions("'mem"),
+[memory_completion],
 )
 
-# should complete arbitrary commands including word starts
+# Completes expressions with quotes inside
 self.verify_completions(
-self.dap_server.get_completions("`log enable  "),
-[{"text": "gdb-remote", "label": "gdb-remote"}],
+self.dap_server.get_completions('expr " "; typed'),
+[{"text": "typedef", "label": "typedef"}],
 )
 
-# should complete expressions with quotes inside
+# Provides completions for commands, but not variables
 self.verify_completions(
-self.dap_server.get_completions('`expr " "; typed'),
-[{"text": "typedef", "label": "typedef"}],
+self.dap_server.get_completions("var"),
+[command_var_completion],
+[variable_var_completion],
+)
+
+
+def test_variable_completions(self):
+"""
+Tests completion requests in "repl-mode=command"

vogelsgesang wrote:

Thanks for staying vigilant!

https://github.com/llvm/llvm-project/pull/110784
__

[Lldb-commits] [lldb] [lldb-dap] Correct auto-completion based on ReplMode and escape char (PR #110784)

2024-10-02 Thread John Harrison via lldb-commits


@@ -32,90 +47,146 @@ def test_completions(self):
 breakpoint2_line = line_number(source, "// breakpoint 2")
 
 self.set_source_breakpoints(source, [breakpoint1_line, 
breakpoint2_line])
+
+
+def test_command_completions(self):
+"""
+Tests completion requests for lldb commands, within "repl-mode=command"
+"""
+self.setup_debugee()
 self.continue_to_next_stop()
 
-# shouldn't see variables inside main
+res = self.dap_server.request_evaluate("`lldb-dap repl-mode command", 
context="repl")
+self.assertTrue(res["success"])
+
+# Provides completion for top-level commands
 self.verify_completions(
-self.dap_server.get_completions("var"),
+self.dap_server.get_completions("se"),
+[session_completion, settings_completion]
+)
+
+# Provides completions for sub-commands
+self.verify_completions(
+self.dap_server.get_completions("memory "),
 [
 {
-"text": "var",
-"label": "var -- vector &",
+"text": "read",
+"label": "read -- Read from the memory of the current 
target process."
 },
 {
-"text": "var",
-"label": "var -- Show variables for the current stack 
frame. Defaults to all arguments and local variables in scope. Names of 
argument, local, file static and file global variables can be specified.",
+"text": "region",
+"label": "region -- Get information on the memory region 
containing an address in the current target process.",
 },
-],
-[
-{"text": "var1", "label": "var1 -- int &"},
-],
+]
 )
 
-# should see global keywords but not variables inside main
+# Provides completions for parameter values of commands
 self.verify_completions(
-self.dap_server.get_completions("str"),
-[{"text": "struct", "label": "struct"}],
-[{"text": "str1", "label": "str1 -- std::string &"}],
+self.dap_server.get_completions("`log enable  "),
+[{"text": "gdb-remote", "label": "gdb-remote"}],
 )
 
-self.continue_to_next_stop()
+# Also works if the escape prefix is used
+self.verify_completions(
+self.dap_server.get_completions("`mem"),
+[memory_completion]
+)
 
-# should see variables from main but not from the other function
 self.verify_completions(
-self.dap_server.get_completions("var"),
-[
-{"text": "var1", "label": "var1 -- int &"},
-{"text": "var2", "label": "var2 -- int &"},
-],
+self.dap_server.get_completions("`"),
+[session_completion, settings_completion, memory_completion]
+)
+
+
+# Completes an incomplete quoted token
+self.verify_completions(
+self.dap_server.get_completions('setting "se'),
 [
 {
-"text": "var",
-"label": "var -- vector &",
+"text": "set",
+"label": "set -- Set the value of the specified debugger 
setting.",
 }
 ],
 )
 
+# Completes an incomplete quoted token
 self.verify_completions(
-self.dap_server.get_completions("str"),
-[
-{"text": "struct", "label": "struct"},
-{"text": "str1", "label": "str1 -- string &"},
-],
+self.dap_server.get_completions("'mem"),
+[memory_completion],
 )
 
-# should complete arbitrary commands including word starts
+# Completes expressions with quotes inside
 self.verify_completions(
-self.dap_server.get_completions("`log enable  "),
-[{"text": "gdb-remote", "label": "gdb-remote"}],
+self.dap_server.get_completions('expr " "; typed'),
+[{"text": "typedef", "label": "typedef"}],
 )
 
-# should complete expressions with quotes inside
+# Provides completions for commands, but not variables
 self.verify_completions(
-self.dap_server.get_completions('`expr " "; typed'),
-[{"text": "typedef", "label": "typedef"}],
+self.dap_server.get_completions("var"),
+[command_var_completion],
+[variable_var_completion],
+)
+
+
+def test_variable_completions(self):
+"""
+Tests completion requests in "repl-mode=command"

ashgti wrote:

repl-mode=variable?

https://github.com/llvm/llvm-project/pull/110784
___
lldb-commits 

[Lldb-commits] [lldb] [lldb-dap] Correct auto-completion based on ReplMode and escape char (PR #110784)

2024-10-02 Thread John Harrison via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Correct auto-completion based on ReplMode and escape char (PR #110784)

2024-10-02 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/110784

>From 41694e6e64b3f16cc5b8e4b64c89d27f4e076573 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 20 Sep 2024 20:43:11 +
Subject: [PATCH 1/4] [lldb-dap] Correct auto-completion based on ReplMode and
 escape char

This commit improves the auto-completion in the Debug Console provided
by VS-Code.

So far, we were always suggesting completions for both LLDB commands and
for variables / expressions, even if the heuristic already determined
how the given string will be executed, e.g., because the user explicitly
typed the escape prefix. Furthermore, auto-completion after the escape
character was broken, since the offsets were not adjusted correctly.
With this commit we now correctly take this into account.

Even with this commit, auto-completion does not always work reliably:

* VS Code only requests auto-completion after typing the first
  alphabetic character, but not after punctuation characters. This means
  that no completions are provided after typing "`"
* LLDB does not provide autocompletions if a string is an exact match.
  This means if a user types `l` (which is a valid command), LLDB will
  not provide "language" and "log" as potential completions. Even worse,
  VS Code caches the completion and does client-side filtering. Hence,
  even after typing `la`, no auto-completion for "language" is shown in
  the UI.

Those issues might be fixed in follow-up commits. Also with those known
issues, the experience is already much better with this commit.

Furthermore, I updated the README since I noticed that it was slightly
inaccurate.
---
 .../test/tools/lldb-dap/dap_server.py |   2 +-
 .../completions/TestDAP_completions.py| 212 +-
 lldb/tools/lldb-dap/DAP.cpp   |  24 +-
 lldb/tools/lldb-dap/DAP.h |  30 ++-
 lldb/tools/lldb-dap/README.md |  10 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  21 +-
 6 files changed, 217 insertions(+), 82 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 449af1b67d8022..1d5e6e0d75c7cb 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -1006,7 +1006,7 @@ def request_compileUnits(self, moduleId):
 return response
 
 def request_completions(self, text, frameId=None):
-args_dict = {"text": text, "column": len(text)}
+args_dict = {"text": text, "column": len(text) + 1}
 if frameId:
 args_dict["frameId"] = frameId
 command_dict = {
diff --git a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py 
b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
index 2b3ec656c107a5..ae0fe00fec67e8 100644
--- a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
+++ b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
@@ -9,6 +9,25 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+session_completion = {
+"text": "session",
+"label": "session -- Commands controlling LLDB session.",
+}
+settings_completion = {
+"text": "settings",
+"label": "settings -- Commands for managing LLDB settings.",
+}
+memory_completion = {
+"text": "memory",
+"label": "memory -- Commands for operating on memory in the current target 
process."
+}
+command_var_completion = {
+"text": "var",
+"label": "var -- Show variables for the current stack frame. Defaults to 
all arguments and local variables in scope. Names of argument, local, file 
static and file global variables can be specified.",
+}
+variable_var_completion = { "text": "var", "label": "var -- vector &", }
+variable_var1_completion = {"text": "var1", "label": "var1 -- int &"}
+variable_var2_completion = {"text": "var2", "label": "var2 -- int &"}
 
 class TestDAP_completions(lldbdap_testcase.DAPTestCaseBase):
 def verify_completions(self, actual_list, expected_list, 
not_expected_list=[]):
@@ -18,12 +37,8 @@ def verify_completions(self, actual_list, expected_list, 
not_expected_list=[]):
 for not_expected_item in not_expected_list:
 self.assertNotIn(not_expected_item, actual_list)
 
-@skipIfWindows
-@skipIf(compiler="clang", compiler_version=["<", "17.0"])
-def test_completions(self):
-"""
-Tests the completion request at different breakpoints
-"""
+
+def setup_debugee(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)
 
@@ -32,90 +47,146 @@ def test_completions(self):
 breakpoint2_line = line_number(source, "// breakpoint 2")
 
 self.set_source_breakpoints(source, [breakpoint1_line, 
breakpoint2_line])
+
+
+def test_command_completions(self):
+"""
+

[Lldb-commits] [lldb] [lldb-dap] Correct auto-completion based on ReplMode and escape char (PR #110784)

2024-10-02 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/110784

>From 41694e6e64b3f16cc5b8e4b64c89d27f4e076573 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Fri, 20 Sep 2024 20:43:11 +
Subject: [PATCH 1/5] [lldb-dap] Correct auto-completion based on ReplMode and
 escape char

This commit improves the auto-completion in the Debug Console provided
by VS-Code.

So far, we were always suggesting completions for both LLDB commands and
for variables / expressions, even if the heuristic already determined
how the given string will be executed, e.g., because the user explicitly
typed the escape prefix. Furthermore, auto-completion after the escape
character was broken, since the offsets were not adjusted correctly.
With this commit we now correctly take this into account.

Even with this commit, auto-completion does not always work reliably:

* VS Code only requests auto-completion after typing the first
  alphabetic character, but not after punctuation characters. This means
  that no completions are provided after typing "`"
* LLDB does not provide autocompletions if a string is an exact match.
  This means if a user types `l` (which is a valid command), LLDB will
  not provide "language" and "log" as potential completions. Even worse,
  VS Code caches the completion and does client-side filtering. Hence,
  even after typing `la`, no auto-completion for "language" is shown in
  the UI.

Those issues might be fixed in follow-up commits. Also with those known
issues, the experience is already much better with this commit.

Furthermore, I updated the README since I noticed that it was slightly
inaccurate.
---
 .../test/tools/lldb-dap/dap_server.py |   2 +-
 .../completions/TestDAP_completions.py| 212 +-
 lldb/tools/lldb-dap/DAP.cpp   |  24 +-
 lldb/tools/lldb-dap/DAP.h |  30 ++-
 lldb/tools/lldb-dap/README.md |  10 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  21 +-
 6 files changed, 217 insertions(+), 82 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 449af1b67d8022..1d5e6e0d75c7cb 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -1006,7 +1006,7 @@ def request_compileUnits(self, moduleId):
 return response
 
 def request_completions(self, text, frameId=None):
-args_dict = {"text": text, "column": len(text)}
+args_dict = {"text": text, "column": len(text) + 1}
 if frameId:
 args_dict["frameId"] = frameId
 command_dict = {
diff --git a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py 
b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
index 2b3ec656c107a5..ae0fe00fec67e8 100644
--- a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
+++ b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
@@ -9,6 +9,25 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+session_completion = {
+"text": "session",
+"label": "session -- Commands controlling LLDB session.",
+}
+settings_completion = {
+"text": "settings",
+"label": "settings -- Commands for managing LLDB settings.",
+}
+memory_completion = {
+"text": "memory",
+"label": "memory -- Commands for operating on memory in the current target 
process."
+}
+command_var_completion = {
+"text": "var",
+"label": "var -- Show variables for the current stack frame. Defaults to 
all arguments and local variables in scope. Names of argument, local, file 
static and file global variables can be specified.",
+}
+variable_var_completion = { "text": "var", "label": "var -- vector &", }
+variable_var1_completion = {"text": "var1", "label": "var1 -- int &"}
+variable_var2_completion = {"text": "var2", "label": "var2 -- int &"}
 
 class TestDAP_completions(lldbdap_testcase.DAPTestCaseBase):
 def verify_completions(self, actual_list, expected_list, 
not_expected_list=[]):
@@ -18,12 +37,8 @@ def verify_completions(self, actual_list, expected_list, 
not_expected_list=[]):
 for not_expected_item in not_expected_list:
 self.assertNotIn(not_expected_item, actual_list)
 
-@skipIfWindows
-@skipIf(compiler="clang", compiler_version=["<", "17.0"])
-def test_completions(self):
-"""
-Tests the completion request at different breakpoints
-"""
+
+def setup_debugee(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)
 
@@ -32,90 +47,146 @@ def test_completions(self):
 breakpoint2_line = line_number(source, "// breakpoint 2")
 
 self.set_source_breakpoints(source, [breakpoint1_line, 
breakpoint2_line])
+
+
+def test_command_completions(self):
+"""
+

[Lldb-commits] [lldb] [llvm] [lldb][DWARF] Replace lldb's DWARFDebugArangeSet with llvm's (PR #110058)

2024-10-02 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lld-x86_64-win` running on 
`as-worker-93` while building `lldb,llvm` at step 7 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/146/builds/1293


Here is the relevant piece of the build log for the reference

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests.exe/35/87' 
FAILED 
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-24380-35-87.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=35 
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe 
--gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): 
error: Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): 
error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied







```



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


[Lldb-commits] [lldb] [DWARF]Set uuid for symbol file spec (PR #110066)

2024-10-02 Thread via lldb-commits

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


[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-02 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 616d1d2e998aa7a26059dc36fa04875c469f69cd 
43230b5803d28d8f1a4b906e43d14cf4ddc2c363 --extensions h,cpp -- 
lldb/test/Shell/SymbolFile/DWARF/no_unique_address-packed-alignment.cpp 
clang/include/clang/AST/RecordLayout.h clang/lib/AST/RecordLayoutBuilder.cpp 
clang/lib/CodeGen/ABIInfoImpl.cpp clang/lib/CodeGen/ABIInfoImpl.h 
lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp 
lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-packed-alignment.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-packed-alignment.cpp
index 80fb699dda..e47dab45ff 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-packed-alignment.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-packed-alignment.cpp
@@ -6,7 +6,7 @@
 
 struct Empty {};
 struct __attribute((packed)) PackedNUA {
-  [[no_unique_address]] Empty a,b,c,d;
+  [[no_unique_address]] Empty a, b, c, d;
   char x;
   int y;
 };

``




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


[Lldb-commits] [lldb] [lldb][test] Provide proper path to LLVM utils in API tests (PR #110837)

2024-10-02 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev updated 
https://github.com/llvm/llvm-project/pull/110837

>From 8deb61b462964d08b4cc5d7f296b44ea4197f65b Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Tue, 1 Oct 2024 13:14:25 +0200
Subject: [PATCH] [lldb][test] Provide proper path to LLVM utils in API tests

In aea066849, API tests were supposed to be switched to LLVM tools
usage.
However, a path to an utility is made up incorrectly there: util name
should be prefixed with `llvm-`.

Hence it is fixed here.
---
 lldb/packages/Python/lldbsuite/test/builders/builder.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index e3099219e437e3..736f0ddc390736 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -153,7 +153,9 @@ def getToolchainSpec(self, compiler):
 cc_dir = cc_path.parent
 
 def getToolchainUtil(util_name):
-return os.path.join(configuration.llvm_tools_dir, util_name + 
exe_ext)
+return os.path.join(
+configuration.llvm_tools_dir, "llvm-" + util_name + exe_ext
+)
 
 cxx = cc_dir / (cc_prefix + cxx_type + cc_ext)
 

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


[Lldb-commits] [lldb] [lldb] Add isConstant mode for FA locations (PR #110726)

2024-10-02 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -2088,6 +2088,13 @@ bool RegisterContextUnwind::ReadFrameAddress(
 UnwindLogMsg("No suitable CFA found");
 break;
   }
+  case UnwindPlan::Row::FAValue::isConstant: {
+address = fa.GetConstant();
+if (abi_sp)
+  address = abi_sp->FixCodeAddress(address);

felipepiovezan wrote:

Sounds good! I will push an updated version calling the process method!

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


[Lldb-commits] [lldb] [lldb] Add isConstant mode for FA locations (PR #110726)

2024-10-02 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan updated 
https://github.com/llvm/llvm-project/pull/110726

>From a23540f5a793d7c9bb115f06a5af0266f8cfb038 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Tue, 24 Sep 2024 09:26:29 -0700
Subject: [PATCH 1/3] [lldb] Add isConstant mode for FA locations

This is similar to 9fe455fd0c7d, but for FA locations instead of register
locations.
This is useful for unwind plans that cannot create abstract unwind rules, but
instead must inspect the state of the program to determine the current CFA.
---
 lldb/include/lldb/Symbol/UnwindPlan.h| 12 
 lldb/source/Symbol/UnwindPlan.cpp|  4 
 lldb/source/Target/RegisterContextUnwind.cpp |  6 ++
 3 files changed, 22 insertions(+)

diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h 
b/lldb/include/lldb/Symbol/UnwindPlan.h
index e1567c7357d0b5..48c9bef76857c0 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -215,6 +215,7 @@ class UnwindPlan {
 isRegisterDereferenced, // FA = [reg]
 isDWARFExpression,  // FA = eval(dwarf_expr)
 isRaSearch, // FA = SP + offset + ???
+isConstant, // FA = constant
   };
 
   FAValue() : m_value() {}
@@ -259,6 +260,15 @@ class UnwindPlan {
 m_value.expr.length = len;
   }
 
+  bool IsConstant() const { return m_type == isConstant; }
+
+  void SetIsConstant(uint64_t constant) {
+m_type = isConstant;
+m_value.constant = constant;
+  }
+
+  uint64_t GetConstant() const { return m_value.constant; }
+
   uint32_t GetRegisterNumber() const {
 if (m_type == isRegisterDereferenced || m_type == isRegisterPlusOffset)
   return m_value.reg.reg_num;
@@ -329,6 +339,8 @@ class UnwindPlan {
 } expr;
 // For m_type == isRaSearch
 int32_t ra_search_offset;
+// For m_type = isConstant
+uint64_t constant;
   } m_value;
 }; // class FAValue
 
diff --git a/lldb/source/Symbol/UnwindPlan.cpp 
b/lldb/source/Symbol/UnwindPlan.cpp
index a06e7cfd7f5446..25e3676761436e 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -187,6 +187,8 @@ operator==(const UnwindPlan::Row::FAValue &rhs) const {
 return !memcmp(m_value.expr.opcodes, rhs.m_value.expr.opcodes,
m_value.expr.length);
   break;
+case isConstant:
+  return m_value.constant == rhs.m_value.constant;
 }
   }
   return false;
@@ -214,6 +216,8 @@ void UnwindPlan::Row::FAValue::Dump(Stream &s, const 
UnwindPlan *unwind_plan,
   case isRaSearch:
 s.Printf("RaSearch@SP%+d", m_value.ra_search_offset);
 break;
+  case isConstant:
+s.Printf("0x%" PRIx64, m_value.constant);
   }
 }
 
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index b683ea7237de04..8f4def9840712f 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -2088,6 +2088,12 @@ bool RegisterContextUnwind::ReadFrameAddress(
 UnwindLogMsg("No suitable CFA found");
 break;
   }
+  case UnwindPlan::Row::FAValue::isConstant: {
+address = fa.GetConstant();
+address = abi_sp->FixCodeAddress(address);
+UnwindLogMsg("CFA value set by constant is 0x%" PRIx64, address);
+return true;
+  }
   default:
 return false;
   }

>From a4b409d2baa364e7c9b78bc4403410fef211ab69 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Tue, 1 Oct 2024 12:20:17 -0700
Subject: [PATCH 2/3] fixup! [lldb] Add isConstant mode for FA locations

---
 lldb/source/Target/RegisterContextUnwind.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index 8f4def9840712f..6cec24f6affc78 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -2090,7 +2090,8 @@ bool RegisterContextUnwind::ReadFrameAddress(
   }
   case UnwindPlan::Row::FAValue::isConstant: {
 address = fa.GetConstant();
-address = abi_sp->FixCodeAddress(address);
+if (abi_sp)
+  address = abi_sp->FixCodeAddress(address);
 UnwindLogMsg("CFA value set by constant is 0x%" PRIx64, address);
 return true;
   }

>From d1cd2a22b6d12f80cf9b2d08c3145c6ff5cb1ef8 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Wed, 2 Oct 2024 07:11:30 -0700
Subject: [PATCH 3/3] fixup! use process method fix address fixup

---
 lldb/source/Target/RegisterContextUnwind.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index 6cec24f6affc78..9a4a8db84a9fa5 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -2090,8 +2090,7 @@ bool Regi

[Lldb-commits] [lldb] [LLDB] Enable TLS Variable Debugging Without Location Info on AArch64 (PR #110822)

2024-10-02 Thread Kamlesh Kumar via lldb-commits

https://github.com/kamleshbhalui updated 
https://github.com/llvm/llvm-project/pull/110822

>From f36d8a2346be90b6bf5d68a7cec0bcf2d41cbd99 Mon Sep 17 00:00:00 2001
From: Kamlesh Kumar 
Date: Thu, 19 Sep 2024 18:57:14 +0200
Subject: [PATCH] [LLDB] Enable TLS Variable Debugging Without Location Info on
 AArch64
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On AArch64, TLS variables do not have DT_Location entries generated in the
debug information due to the lack of dtpoff relocation support, unlike on 
x86_64.
LLDB relies on this location info to calculate the TLS address, leading to 
issues
when debugging TLS variables on AArch64.
However, GDB can successfully calculate the TLS address without relying on this 
debug info,
by using the symbol’s address and manually calculating the offset. We adopt a 
similar approach for LLDB.
---
 lldb/include/lldb/Symbol/Variable.h   |  2 ++
 lldb/source/Core/ValueObjectVariable.cpp  | 33 ++-
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 14 +---
 .../Utility/RegisterInfoPOSIX_arm64.cpp   | 15 +
 .../Process/Utility/RegisterInfos_arm64.h | 11 +--
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |  7 ++--
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  9 +
 lldb/source/Symbol/Variable.cpp   | 13 
 8 files changed, 85 insertions(+), 19 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Variable.h 
b/lldb/include/lldb/Symbol/Variable.h
index c437624d1ea6d7..4ad06baeb684a4 100644
--- a/lldb/include/lldb/Symbol/Variable.h
+++ b/lldb/include/lldb/Symbol/Variable.h
@@ -79,6 +79,8 @@ class Variable : public UserID, public 
std::enable_shared_from_this {
 return m_location_list;
   }
 
+  bool IsThreadLocal() const;
+
   // When given invalid address, it dumps all locations. Otherwise it only 
dumps
   // the location that contains this address.
   bool DumpLocations(Stream *s, const Address &address);
diff --git a/lldb/source/Core/ValueObjectVariable.cpp 
b/lldb/source/Core/ValueObjectVariable.cpp
index 29aefb270c92c8..393ddc1960ab47 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -254,7 +254,38 @@ bool ValueObjectVariable::UpdateValue() {
   m_resolved_value.SetContext(Value::ContextType::Invalid, nullptr);
 }
   }
-
+  if (m_error.Fail() && variable->IsThreadLocal()) {
+ExecutionContext exe_ctx(GetExecutionContextRef());
+Thread *thread = exe_ctx.GetThreadPtr();
+lldb::ModuleSP module_sp = GetModule();
+if (!thread) {
+  m_error = Status::FromErrorString("no thread to evaluate TLS within");
+  return m_error.Success();
+}
+std::vector symbol_indexes;
+module_sp->GetSymtab()->FindAllSymbolsWithNameAndType(
+ConstString(variable->GetName()), lldb::SymbolType::eSymbolTypeAny,
+symbol_indexes);
+Symbol *symbol = module_sp->GetSymtab()->SymbolAtIndex(symbol_indexes[0]);
+lldb::addr_t tls_file_addr =
+symbol->GetAddress().GetOffset() +
+symbol->GetAddress().GetSection()->GetFileAddress();
+const lldb::addr_t tls_load_addr =
+thread->GetThreadLocalData(module_sp, tls_file_addr);
+if (tls_load_addr == LLDB_INVALID_ADDRESS)
+  m_error = Status::FromErrorString(
+  "no TLS data currently exists for this thread");
+else {
+  Value old_value(m_value);
+  m_value.GetScalar() = tls_load_addr;
+  m_value.SetContext(Value::ContextType::Variable, variable);
+  m_value.SetValueType(Value::ValueType::LoadAddress);
+  m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
+  SetValueDidChange(m_value.GetValueType() != old_value.GetValueType() ||
+m_value.GetScalar() != old_value.GetScalar());
+  SetValueIsValid(m_error.Success());
+}
+  }
   return m_error.Success();
 }
 
diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..5a78ad2286f87a 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -771,9 +771,12 @@ DynamicLoaderPOSIXDYLD::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 "GetThreadLocalData info: link_map=0x%" PRIx64
 ", thread info metadata: "
 "modid_offset=0x%" PRIx32 ", dtv_offset=0x%" PRIx32
-", tls_offset=0x%" PRIx32 ", dtv_slot_size=%" PRIx32 "\n",
+", tls_offset=0x%" PRIx32 ", dtv_slot_size=%" PRIx32
+", tls_file_addr=0x%" PRIx64 ", module name=%s "
+"\n",
 link_map, metadata.modid_offset, metadata.dtv_offset,
-metadata.tls_offset, metadata.dtv_slot_size);
+metadata.tls_offset, metadata.dtv_slot_size, tls_file_addr,
+module_sp->GetFileSpec().G

[Lldb-commits] [lldb] [LLDB][DYLD] Remove logic around not rebasing when main executable has a load address (PR #110885)

2024-10-02 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/110885

>From 5ed6e20b50f70754efbaa157720a7ef120bb6b1e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 2 Oct 2024 09:50:26 -0700
Subject: [PATCH 1/2] Remove additional logic to disable the dynamic loader
 when the main executable already has a load address

---
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 15 ---
 1 file changed, 15 deletions(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..b9c0e174c3be68 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -108,21 +108,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
   // if we dont have a load address we cant re-base
   bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
 
-  // if we have a valid executable
-  if (executable_sp.get()) {
-lldb_private::ObjectFile *obj = executable_sp->GetObjectFile();
-if (obj) {
-  // don't rebase if the module already has a load address
-  Target &target = m_process->GetTarget();
-  Address addr = obj->GetImageInfoAddress(&target);
-  if (addr.GetLoadAddress(&target) != LLDB_INVALID_ADDRESS)
-rebase_exec = false;
-}
-  } else {
-// no executable, nothing to re-base
-rebase_exec = false;
-  }
-
   // if the target executable should be re-based
   if (rebase_exec) {
 ModuleList module_list;

>From 6f409ea70764ccad4a6b0aca070ca44b75ba7ea3 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 2 Oct 2024 11:28:10 -0700
Subject: [PATCH 2/2] Change the test that emits an invalid .so

---
 .../postmortem/minidump-new/TestMiniDumpUUID.py| 3 ---
 1 file changed, 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py 
b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
index 2a3d291086b662..9feac7f446f45e 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -8,7 +8,6 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
 class MiniDumpUUIDTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
@@ -327,8 +326,6 @@ def test_relative_module_name(self):
 old_cwd = os.getcwd()
 self.addTearDownHook(lambda: os.chdir(old_cwd))
 os.chdir(self.getBuildDir())
-name = "file-with-a-name-unlikely-to-exist-in-the-current-directory.so"
-open(name, "a").close()
 modules = self.get_minidump_modules(
 self.getSourcePath("relative_module_name.yaml")
 )

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


[Lldb-commits] [lldb] [LLDB][DYLD] Remove logic around not rebasing when main executable has a load address (PR #110885)

2024-10-02 Thread Jacob Lalonde via lldb-commits


@@ -327,8 +327,6 @@ def test_relative_module_name(self):
 old_cwd = os.getcwd()
 self.addTearDownHook(lambda: os.chdir(old_cwd))
 os.chdir(self.getBuildDir())
-name = "file-with-a-name-unlikely-to-exist-in-the-current-directory.so"

Jlalond wrote:

@labath as an FYI, this test was failing because the .so was invalid. When 
loading manually, I still got an image list but this specific test was getting 
no modules when this .so was just `a`

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


[Lldb-commits] [lldb] [LLDB][DYLD] Remove logic around not rebasing when main executable has a load address (PR #110885)

2024-10-02 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/110885

>From 5ed6e20b50f70754efbaa157720a7ef120bb6b1e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 2 Oct 2024 09:50:26 -0700
Subject: [PATCH 1/2] Remove additional logic to disable the dynamic loader
 when the main executable already has a load address

---
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 15 ---
 1 file changed, 15 deletions(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..b9c0e174c3be68 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -108,21 +108,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
   // if we dont have a load address we cant re-base
   bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
 
-  // if we have a valid executable
-  if (executable_sp.get()) {
-lldb_private::ObjectFile *obj = executable_sp->GetObjectFile();
-if (obj) {
-  // don't rebase if the module already has a load address
-  Target &target = m_process->GetTarget();
-  Address addr = obj->GetImageInfoAddress(&target);
-  if (addr.GetLoadAddress(&target) != LLDB_INVALID_ADDRESS)
-rebase_exec = false;
-}
-  } else {
-// no executable, nothing to re-base
-rebase_exec = false;
-  }
-
   // if the target executable should be re-based
   if (rebase_exec) {
 ModuleList module_list;

>From 071b7fac9f6eadf3c4c466146d429841f3ba1a86 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 2 Oct 2024 11:28:10 -0700
Subject: [PATCH 2/2] Change the test that emits an invalid .so

---
 .../functionalities/postmortem/minidump-new/TestMiniDumpUUID.py | 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py 
b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
index 2a3d291086b662..b212426802cc57 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -327,8 +327,6 @@ def test_relative_module_name(self):
 old_cwd = os.getcwd()
 self.addTearDownHook(lambda: os.chdir(old_cwd))
 os.chdir(self.getBuildDir())
-name = "file-with-a-name-unlikely-to-exist-in-the-current-directory.so"
-open(name, "a").close()
 modules = self.get_minidump_modules(
 self.getSourcePath("relative_module_name.yaml")
 )

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


[Lldb-commits] [lldb] [LLDB][DYLD] Remove logic around not rebasing when main executable has a load address (PR #110885)

2024-10-02 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/110885

>From 5ed6e20b50f70754efbaa157720a7ef120bb6b1e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 2 Oct 2024 09:50:26 -0700
Subject: [PATCH 1/3] Remove additional logic to disable the dynamic loader
 when the main executable already has a load address

---
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 15 ---
 1 file changed, 15 deletions(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..b9c0e174c3be68 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -108,21 +108,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
   // if we dont have a load address we cant re-base
   bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
 
-  // if we have a valid executable
-  if (executable_sp.get()) {
-lldb_private::ObjectFile *obj = executable_sp->GetObjectFile();
-if (obj) {
-  // don't rebase if the module already has a load address
-  Target &target = m_process->GetTarget();
-  Address addr = obj->GetImageInfoAddress(&target);
-  if (addr.GetLoadAddress(&target) != LLDB_INVALID_ADDRESS)
-rebase_exec = false;
-}
-  } else {
-// no executable, nothing to re-base
-rebase_exec = false;
-  }
-
   // if the target executable should be re-based
   if (rebase_exec) {
 ModuleList module_list;

>From 071b7fac9f6eadf3c4c466146d429841f3ba1a86 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 2 Oct 2024 11:28:10 -0700
Subject: [PATCH 2/3] Change the test that emits an invalid .so

---
 .../functionalities/postmortem/minidump-new/TestMiniDumpUUID.py | 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py 
b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
index 2a3d291086b662..b212426802cc57 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -327,8 +327,6 @@ def test_relative_module_name(self):
 old_cwd = os.getcwd()
 self.addTearDownHook(lambda: os.chdir(old_cwd))
 os.chdir(self.getBuildDir())
-name = "file-with-a-name-unlikely-to-exist-in-the-current-directory.so"
-open(name, "a").close()
 modules = self.get_minidump_modules(
 self.getSourcePath("relative_module_name.yaml")
 )

>From e4f0b83d3e599d5190e81e64f5d52d5a3b1a8ce4 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 2 Oct 2024 11:36:14 -0700
Subject: [PATCH 3/3] Have to keep the name variable

---
 .../functionalities/postmortem/minidump-new/TestMiniDumpUUID.py  | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py 
b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
index b212426802cc57..6f8427d67e5092 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -327,6 +327,7 @@ def test_relative_module_name(self):
 old_cwd = os.getcwd()
 self.addTearDownHook(lambda: os.chdir(old_cwd))
 os.chdir(self.getBuildDir())
+name = "file-with-a-name-unlikely-to-exist-in-the-current-directory.so"
 modules = self.get_minidump_modules(
 self.getSourcePath("relative_module_name.yaml")
 )

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


[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)

2024-10-02 Thread Dmitry Vasilyev via lldb-commits


@@ -318,75 +231,67 @@ 
GDBRemoteCommunicationServerPlatform::Handle_qKillSpawnedProcess(
 
   lldb::pid_t pid = packet.GetU64(LLDB_INVALID_PROCESS_ID);
 
-  // verify that we know anything about this pid. Scope for locker
-  {
-std::lock_guard guard(m_spawned_pids_mutex);
-if (m_spawned_pids.find(pid) == m_spawned_pids.end()) {
-  // not a pid we know about
-  return SendErrorResponse(10);
-}
+  // verify that we know anything about this pid.
+  if (SpawnedProcessFinished(pid)) {
+// not a pid we know about
+return SendErrorResponse(10); // ECHILD

slydiman wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)

2024-10-02 Thread Dmitry Vasilyev via lldb-commits


@@ -318,75 +231,67 @@ 
GDBRemoteCommunicationServerPlatform::Handle_qKillSpawnedProcess(
 
   lldb::pid_t pid = packet.GetU64(LLDB_INVALID_PROCESS_ID);
 
-  // verify that we know anything about this pid. Scope for locker
-  {
-std::lock_guard guard(m_spawned_pids_mutex);
-if (m_spawned_pids.find(pid) == m_spawned_pids.end()) {
-  // not a pid we know about
-  return SendErrorResponse(10);
-}
+  // verify that we know anything about this pid.
+  if (SpawnedProcessFinished(pid)) {
+// not a pid we know about
+return SendErrorResponse(10); // ECHILD
   }
 
   // go ahead and attempt to kill the spawned process
   if (KillSpawnedProcess(pid))
 return SendOKResponse();
   else
-return SendErrorResponse(11);
+return SendErrorResponse(11); // EDEADLK
+}
+
+void GDBRemoteCommunicationServerPlatform::AddSpawnedProcess(lldb::pid_t pid) {
+  assert(pid != LLDB_INVALID_PROCESS_ID);
+  std::lock_guard guard(m_spawned_pids_mutex);
+  m_spawned_pids.insert(pid);
+}
+
+bool GDBRemoteCommunicationServerPlatform::SpawnedProcessFinished(

slydiman wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)

2024-10-02 Thread Dmitry Vasilyev via lldb-commits


@@ -119,20 +175,78 @@ static Status save_socket_id_to_file(const std::string 
&socket_id,
   return status;
 }
 
+static Status ListenGdbConnectionsIfNeeded(
+const Socket::SocketProtocol protocol, std::unique_ptr 
&gdb_sock,
+const std::string &gdb_address, uint16_t &gdbserver_port) {
+  if (protocol != Socket::ProtocolTcp)
+return Status();
+
+  gdb_sock = std::make_unique(
+  /*should_close=*/true, /*child_processes_inherit=*/false);
+  Status error = gdb_sock->Listen(gdb_address, backlog);
+  if (error.Fail())
+return error;
+
+  if (gdbserver_port == 0)
+gdbserver_port = gdb_sock->GetLocalPortNumber();
+
+  return Status();
+}
+
+static Status AcceptGdbConnectionsIfNeeded(

slydiman wrote:

Done.

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


[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-02 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/97443

>From 3a718c75d0458b7aece72f2ba8e5aa5a68815237 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 2 Jul 2024 18:43:34 +0200
Subject: [PATCH 1/6] [clang][RecordLayoutBuilder] Be stricter about inferring
 packed-ness in ExternalLayouts

This patch is motivated by the LLDB support required for:
https://github.com/llvm/llvm-project/issues/93069

In the presence of `[[no_unique_address]]`, LLDB may ask Clang
to lay out types with overlapping field offsets. Because we don't
have attributes such as `packed` or `no_unique_address` in the LLDB
AST, the `RecordLayoutBuilder` supports an `InferAlignment` mode, which,
in the past, attempted to detect layouts which came from packed
structures in order to provide a conservative estimate of alignment for
it (since `DW_AT_alignment` isn't emitted unless explicitly changed with
`alignas`, etc.).

However, in the presence of overlapping fields due to `no_unique_address`,
`InferAlignment` would set the alignment of structures to `1` for which
that's incorrect. This poses issues in some LLDB formatters that
synthesize new Clang types and rely on the layout builder to get the
`FieldOffset` of structures right that we did have DWARF offsets for.
The result of this is that if we get the alignment wrong, LLDB reads
out garbage data from the wrong field offsets.

There are a couple of solutions to this that we considered:
1. Make LLDB formatters not do the above, and make them more robust
   to inaccurate alignment.
2. Remove `InferAlignment` entirely and rely on Clang emitting
   `DW_AT_alignment` for packed structures.
3. Remove `InferAlignment` and detect packedness from within LLDB.
4. Make the `InferAlignment` logic account for overlapping fields.

Option (1) turned out quite hairy and it's not clear we can achieve
this with the tools available for certain STL formatters (particularly
`std::map`). But I would still very much like to simplify this if we
can.

Option (2) wouldn't help with GCC-compiled binaries, and if we can
get away with LLDB not needing the alignment, then we wouldn't need
to increase debug-info size.

Option (3), AFAICT, would require us to reimplement some of the layout
logic in the layout builder. Would be great if we can avoid this added
complexity.

Option (4) seemed like the best option in the interim. As part of this
change I also removed one of the `InferAlignment` blocks. The test-cases
associated with this code-path pass regardless, and from the description
of the change that introduced it it's not clear why specifically the
base offsets would influence the `Alignment` field, and how it would
imply packedness. But happy to be proven wrong. Ultimately it would be
great if we can get rid of the `InferAlignment` infrastructure and
support our use-cases in LLDB or DWARF instead.
---
 clang/lib/AST/RecordLayoutBuilder.cpp | 34 +--
 .../DWARF/no_unique_address-alignment.cpp |  2 --
 .../no_unique_address-base-alignment.cpp  |  2 --
 3 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index d9bf62c2bbb04a..8dbf69c310cbb4 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -802,7 +802,8 @@ class ItaniumRecordLayoutBuilder {
   /// \param Field The field whose offset is being queried.
   /// \param ComputedOffset The offset that we've computed for this field.
   uint64_t updateExternalFieldOffset(const FieldDecl *Field,
- uint64_t ComputedOffset);
+ uint64_t ComputedOffset,
+ uint64_t PreviousOffset);
 
   void CheckFieldPadding(uint64_t Offset, uint64_t UnpaddedOffset,
   uint64_t UnpackedOffset, unsigned UnpackedAlign,
@@ -1296,13 +1297,6 @@ ItaniumRecordLayoutBuilder::LayoutBase(const 
BaseSubobjectInfo *Base) {
 bool Allowed = EmptySubobjects->CanPlaceBaseAtOffset(Base, Offset);
 (void)Allowed;
 assert(Allowed && "Base subobject externally placed at overlapping 
offset");
-
-if (InferAlignment && Offset < getDataSize().alignTo(AlignTo)) {
-  // The externally-supplied base offset is before the base offset we
-  // computed. Assume that the structure is packed.
-  Alignment = CharUnits::One();
-  InferAlignment = false;
-}
   }
 
   if (!Base->Class->isEmpty()) {
@@ -1770,7 +1764,8 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   // If we're using external layout, give the external layout a chance
   // to override this information.
   if (UseExternalLayout)
-FieldOffset = updateExternalFieldOffset(D, FieldOffset);
+FieldOffset = updateExternalFieldOffset(
+D, FieldOffset, FieldOffsets.empty() ? 0 : FieldOffsets.back());
 
   // Okay, place the bitfield at the calculated offset.
   Field

[Lldb-commits] [lldb] [lldb][test] Provide proper path to LLVM utils in API tests (PR #110837)

2024-10-02 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 
1bc9b67bd87d7ec51045951c93fd5db953faa745...2036458cada64a285e9b26b9b4c68bf799ff1532
 lldb/packages/Python/lldbsuite/test/builders/builder.py
``





View the diff from darker here.


``diff
--- builder.py  2024-10-02 12:50:26.00 +
+++ builder.py  2024-10-02 13:02:18.467344 +
@@ -151,11 +151,13 @@
 cxx_type = cxx_types.get(cc_type, cc_type)
 
 cc_dir = cc_path.parent
 
 def getToolchainUtil(util_name):
-return os.path.join(configuration.llvm_tools_dir, "llvm-" + 
util_name + exe_ext)
+return os.path.join(
+configuration.llvm_tools_dir, "llvm-" + util_name + exe_ext
+)
 
 cxx = cc_dir / (cc_prefix + cxx_type + cc_ext)
 
 util_names = {
 "OBJCOPY": "objcopy",

``




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


[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-02 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/97443

>From 3a718c75d0458b7aece72f2ba8e5aa5a68815237 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 2 Jul 2024 18:43:34 +0200
Subject: [PATCH 1/2] [clang][RecordLayoutBuilder] Be stricter about inferring
 packed-ness in ExternalLayouts

This patch is motivated by the LLDB support required for:
https://github.com/llvm/llvm-project/issues/93069

In the presence of `[[no_unique_address]]`, LLDB may ask Clang
to lay out types with overlapping field offsets. Because we don't
have attributes such as `packed` or `no_unique_address` in the LLDB
AST, the `RecordLayoutBuilder` supports an `InferAlignment` mode, which,
in the past, attempted to detect layouts which came from packed
structures in order to provide a conservative estimate of alignment for
it (since `DW_AT_alignment` isn't emitted unless explicitly changed with
`alignas`, etc.).

However, in the presence of overlapping fields due to `no_unique_address`,
`InferAlignment` would set the alignment of structures to `1` for which
that's incorrect. This poses issues in some LLDB formatters that
synthesize new Clang types and rely on the layout builder to get the
`FieldOffset` of structures right that we did have DWARF offsets for.
The result of this is that if we get the alignment wrong, LLDB reads
out garbage data from the wrong field offsets.

There are a couple of solutions to this that we considered:
1. Make LLDB formatters not do the above, and make them more robust
   to inaccurate alignment.
2. Remove `InferAlignment` entirely and rely on Clang emitting
   `DW_AT_alignment` for packed structures.
3. Remove `InferAlignment` and detect packedness from within LLDB.
4. Make the `InferAlignment` logic account for overlapping fields.

Option (1) turned out quite hairy and it's not clear we can achieve
this with the tools available for certain STL formatters (particularly
`std::map`). But I would still very much like to simplify this if we
can.

Option (2) wouldn't help with GCC-compiled binaries, and if we can
get away with LLDB not needing the alignment, then we wouldn't need
to increase debug-info size.

Option (3), AFAICT, would require us to reimplement some of the layout
logic in the layout builder. Would be great if we can avoid this added
complexity.

Option (4) seemed like the best option in the interim. As part of this
change I also removed one of the `InferAlignment` blocks. The test-cases
associated with this code-path pass regardless, and from the description
of the change that introduced it it's not clear why specifically the
base offsets would influence the `Alignment` field, and how it would
imply packedness. But happy to be proven wrong. Ultimately it would be
great if we can get rid of the `InferAlignment` infrastructure and
support our use-cases in LLDB or DWARF instead.
---
 clang/lib/AST/RecordLayoutBuilder.cpp | 34 +--
 .../DWARF/no_unique_address-alignment.cpp |  2 --
 .../no_unique_address-base-alignment.cpp  |  2 --
 3 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index d9bf62c2bbb04a..8dbf69c310cbb4 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -802,7 +802,8 @@ class ItaniumRecordLayoutBuilder {
   /// \param Field The field whose offset is being queried.
   /// \param ComputedOffset The offset that we've computed for this field.
   uint64_t updateExternalFieldOffset(const FieldDecl *Field,
- uint64_t ComputedOffset);
+ uint64_t ComputedOffset,
+ uint64_t PreviousOffset);
 
   void CheckFieldPadding(uint64_t Offset, uint64_t UnpaddedOffset,
   uint64_t UnpackedOffset, unsigned UnpackedAlign,
@@ -1296,13 +1297,6 @@ ItaniumRecordLayoutBuilder::LayoutBase(const 
BaseSubobjectInfo *Base) {
 bool Allowed = EmptySubobjects->CanPlaceBaseAtOffset(Base, Offset);
 (void)Allowed;
 assert(Allowed && "Base subobject externally placed at overlapping 
offset");
-
-if (InferAlignment && Offset < getDataSize().alignTo(AlignTo)) {
-  // The externally-supplied base offset is before the base offset we
-  // computed. Assume that the structure is packed.
-  Alignment = CharUnits::One();
-  InferAlignment = false;
-}
   }
 
   if (!Base->Class->isEmpty()) {
@@ -1770,7 +1764,8 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   // If we're using external layout, give the external layout a chance
   // to override this information.
   if (UseExternalLayout)
-FieldOffset = updateExternalFieldOffset(D, FieldOffset);
+FieldOffset = updateExternalFieldOffset(
+D, FieldOffset, FieldOffsets.empty() ? 0 : FieldOffsets.back());
 
   // Okay, place the bitfield at the calculated offset.
   Field

[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-02 Thread Michael Buch via lldb-commits

Michael137 wrote:

> If I'm understanding correctly, the way this currently works is that you do 
> normal field layout, then if you discover that the actual offset of a field 
> is less than the offset normal field layout would produce, you assume the 
> struct is packed. This misses cases where a struct is packed, but the packing 
> doesn't affect the offset of any of the fields. But as you note, this can't 
> be fixed without adjusting the overall architecture.
> 
> There's an issue with the current implementation: it skips fields which 
> actually are packed, I think. Consider the following:
> 
> ```
> struct Empty {};
> struct __attribute((packed)) S {
>   [[no_unique_address]] Empty a,b,c,d;
>   char x;
>   int y;
> };
> S s;
> ```
> 
> In this case, the field "y" is both overlapping, and at a packed offset. 
> Really, you don't want to check for overlap; you want to ignore empty fields. 
> (Non-empty fields can't overlap.)

Updated the patch to ignore empty fields instead of checking overlap with 
previous fields.

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


[Lldb-commits] [lldb] [lldb][test] Provide proper path to LLVM utils in API tests (PR #110837)

2024-10-02 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev updated 
https://github.com/llvm/llvm-project/pull/110837

>From a2c8b8b88fd47cbbdc32ca5f0f051391a9d77823 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Tue, 1 Oct 2024 13:14:25 +0200
Subject: [PATCH] [lldb][test] Provide proper path to LLVM utils in API tests

In aea066849, API tests were supposed to be switched to LLVM tools
usage.
However, a path to an utility is made up incorrectly there: util name
should be prefixed with `llvm-`.

Hence it is fixed here.
---
 lldb/packages/Python/lldbsuite/test/builders/builder.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index e3099219e437e3..f813d68e46e82a 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -176,7 +176,7 @@ def getToolchainUtil(util_name):
 for var, name in util_names.items():
 # Do not override explicity specified tool from the cmd 
line.
 if not os.getenv(var):
-util_paths[var] = getToolchainUtil(name)
+util_paths[var] = getToolchainUtil("llvm-" + name)
 else:
 util_paths[var] = os.getenv(var)
 utils.extend(["AR=%s" % util_paths["ARCHIVER"]])

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


[Lldb-commits] [lldb] 8789c96 - [lldb] Unify implementation of CommandReturnObject::SetError(NFC) (#110707)

2024-10-02 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-10-02T09:11:47-07:00
New Revision: 8789c96698e027b0dd40b6e0475181505d6b8984

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

LOG: [lldb] Unify implementation of CommandReturnObject::SetError(NFC) (#110707)

This is a cleanup that moves the API towards value semantics.

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandReturnObject.h
lldb/source/API/SBCommandReturnObject.cpp
lldb/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/source/Commands/CommandObjectDWIMPrint.cpp
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Commands/CommandObjectMemoryTag.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Interpreter/CommandReturnObject.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8c4dcb54d708f0..8f6c9f123b7690 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -131,7 +131,7 @@ class CommandReturnObject {
 AppendError(llvm::formatv(format, std::forward(args)...).str());
   }
 
-  void SetError(const Status &error, const char *fallback_error_cstr = 
nullptr);
+  void SetError(Status error);
 
   void SetError(llvm::Error error);
 

diff  --git a/lldb/source/API/SBCommandReturnObject.cpp 
b/lldb/source/API/SBCommandReturnObject.cpp
index 7d2c102b3d8c14..d0cdebe8c64911 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/lldb/source/API/SBCommandReturnObject.cpp
@@ -326,10 +326,10 @@ void SBCommandReturnObject::SetError(lldb::SBError &error,
  const char *fallback_error_cstr) {
   LLDB_INSTRUMENT_VA(this, error, fallback_error_cstr);
 
-  if (error.IsValid())
-ref().SetError(error.ref(), fallback_error_cstr);
+  if (error.IsValid() && !error.Fail())
+ref().SetError(error.ref().Clone());
   else if (fallback_error_cstr)
-ref().SetError(Status(), fallback_error_cstr);
+ref().SetError(Status::FromErrorString(fallback_error_cstr));
 }
 
 void SBCommandReturnObject::SetError(const char *error_cstr) {

diff  --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp 
b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index b668cd0f7c22f0..ac2db5973effa9 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -389,7 +389,7 @@ are no syntax errors may indicate that a function was 
declared but never called.
   m_bp_options_vec, result);
 }
 if (!error.Success())
-  result.SetError(error);
+  result.SetError(std::move(error));
   } else {
 // Special handling for one-liner specified inline.
 if (m_options.m_use_one_liner)

diff  --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index b7cd955e00203d..2e1d6e6e5af996 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -202,7 +202,7 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 // If the expression failed, return an error.
 if (expr_result != eExpressionCompleted) {
   if (valobj_sp)
-result.SetError(valobj_sp->GetError());
+result.SetError(valobj_sp->GetError().Clone());
   else
 result.AppendErrorWithFormatv(
 "unknown error evaluating expression `{0}`", expr);

diff  --git a/lldb/source/Commands/CommandObjectExpression.cpp 
b/lldb/source/Commands/CommandObjectExpression.cpp
index 9722c85a79b784..a72b409d21ed83 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -647,8 +647,8 @@ void CommandObjectExpression::DoExecute(llvm::StringRef 
command,
   initialize = true;
   repl_sp = target.GetREPL(repl_error, m_command_options.language,
 nullptr, true);
-  if (!repl_error.Success()) {
-result.SetError(repl_error);
+  if (repl_error.Fail()) {
+result.SetError(std::move(repl_error));
 return;
   }
 }
@@ -668,7 +668,7 @@ void CommandObjectExpression::DoExecute(llvm::StringRef 
command,
   repl_error = Status::FromErrorStringWithFormat(
   "Couldn't create a REPL for %s",
   Language::GetNameForLanguageType(m_command_options.language));
-  result.SetError(repl_error);
+  result.SetError(std::move(repl_error));
   return;
 }
   }

diff  --git a/lldb/source/Commands/CommandObjectMemoryTag.

[Lldb-commits] [lldb] [lldb] Unify implementation of CommandReturnObject::SetError(NFC) (PR #110707)

2024-10-02 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)

2024-10-02 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

> I am still looking for an answer to this one. If it's only the 
> Handle_qLaunchGDBServer that needs to not launch an lldb-server then I don't 
> see why the check couldn't/shouldn't be performed there.

I cannot answer in the thread, no idea why. The answer is here
https://github.com/llvm/llvm-project/pull/104238#issuecomment-2368274458

LaunchGDBServer() may be called from the child process at the beginnig if 
inferior_arguments are present. The behavior depends on the protocol. gdbserver 
will be launched in case of unix sockets. Otherwise we need to check that 
gdbserver is exists and wait for the tcp gdb connection. This part cannot be 
optimized/simplified.

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


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)

2024-10-02 Thread via lldb-commits

cor3ntin wrote:

> sorry this is same as #107906 (with a bigger impact radius, as you're also 
> changing getBufferForFile) and doesn't address any of the issues mention 
> about explaining the semantics of `IsText` or justification for changing the 
> core VFS interfaces, for an operation that's can solely be performed on 
> physical fileystem.
> 
> @perry-ca raised some concerns in #109664 about this functionality requiring 
> some context awareness, I don't think any of those is addressed by this patch 
> either. Pretty much all of the callers apart from ASTReader is just using 
> `IsText = true`.

To give some context, the problem we are trying to solve initially is that file 
opened by `#embed` should not be utf-8 converted. 


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


[Lldb-commits] [lldb] [LLDB][DYLD] Remove logic around not rebasing when main executable has a load address (PR #110885)

2024-10-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

This is a part of #109477 that I'm making into it's own patch. Here we 
remove logic from the DYLD that prevents it's logic from running if the main 
executable already has a load address. Instead we let the DYLD fully determine 
what should be loaded and what shouldn't.

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


1 Files Affected:

- (modified) 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (-15) 


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..b9c0e174c3be68 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -108,21 +108,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
   // if we dont have a load address we cant re-base
   bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
 
-  // if we have a valid executable
-  if (executable_sp.get()) {
-lldb_private::ObjectFile *obj = executable_sp->GetObjectFile();
-if (obj) {
-  // don't rebase if the module already has a load address
-  Target &target = m_process->GetTarget();
-  Address addr = obj->GetImageInfoAddress(&target);
-  if (addr.GetLoadAddress(&target) != LLDB_INVALID_ADDRESS)
-rebase_exec = false;
-}
-  } else {
-// no executable, nothing to re-base
-rebase_exec = false;
-  }
-
   // if the target executable should be re-based
   if (rebase_exec) {
 ModuleList module_list;

``




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


[Lldb-commits] [lldb] [LLDB][DYLD] Remove logic around not rebasing when main executable has a load address (PR #110885)

2024-10-02 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond created 
https://github.com/llvm/llvm-project/pull/110885

This is a part of #109477 that I'm making into it's own patch. Here we remove 
logic from the DYLD that prevents it's logic from running if the main 
executable already has a load address. Instead we let the DYLD fully determine 
what should be loaded and what shouldn't.

>From 5ed6e20b50f70754efbaa157720a7ef120bb6b1e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Wed, 2 Oct 2024 09:50:26 -0700
Subject: [PATCH] Remove additional logic to disable the dynamic loader when
 the main executable already has a load address

---
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 15 ---
 1 file changed, 15 deletions(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..b9c0e174c3be68 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -108,21 +108,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
   // if we dont have a load address we cant re-base
   bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
 
-  // if we have a valid executable
-  if (executable_sp.get()) {
-lldb_private::ObjectFile *obj = executable_sp->GetObjectFile();
-if (obj) {
-  // don't rebase if the module already has a load address
-  Target &target = m_process->GetTarget();
-  Address addr = obj->GetImageInfoAddress(&target);
-  if (addr.GetLoadAddress(&target) != LLDB_INVALID_ADDRESS)
-rebase_exec = false;
-}
-  } else {
-// no executable, nothing to re-base
-rebase_exec = false;
-  }
-
   // if the target executable should be re-based
   if (rebase_exec) {
 ModuleList module_list;

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-02 Thread Jacob Lalonde via lldb-commits


@@ -108,21 +108,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
   // if we dont have a load address we cant re-base
   bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
 
-  // if we have a valid executable

Jlalond wrote:

#110885

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-02 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

On Pavel's suggestion, I broke the DYLD changes into their own patch #110885

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


[Lldb-commits] [lldb] a5876be - [lldb-dap] Correct auto-completion based on ReplMode and escape char (#110784)

2024-10-02 Thread via lldb-commits

Author: Adrian Vogelsgesang
Date: 2024-10-03T02:50:46+02:00
New Revision: a5876bef61e44453b915e1f79366ca1bbfdba371

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

LOG: [lldb-dap] Correct auto-completion based on ReplMode and escape char 
(#110784)

This commit improves the auto-completion in the Debug Console provided
by VS-Code.

So far, we were always suggesting completions for both LLDB commands and
for variables / expressions, even if the heuristic already determined
how the given string will be executed, e.g., because the user explicitly
typed the escape prefix. Furthermore, auto-completion after the escape
character was broken, since the offsets were not adjusted correctly.
With this commit we now correctly take this into account.

Even with this commit, auto-completion does not always work reliably:

* VS Code only requests auto-completion after typing the first
alphabetic character, but not after punctuation characters. This means
that no completions are provided after typing "`"
* LLDB does not provide autocompletions if a string is an exact match.
This means if a user types `l` (which is a valid command), LLDB will not
provide "language" and "log" as potential completions. Even worse, VS
Code caches the completion and does client-side filtering. Hence, even
after typing `la`, no auto-completion for "language" is shown in the UI.

Those issues might be fixed in follow-up commits. Also with those known
issues, the experience is already much better with this commit.

Furthermore, I updated the README since I noticed that it was slightly
inaccurate.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/README.md
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 449af1b67d8022..1d5e6e0d75c7cb 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -1006,7 +1006,7 @@ def request_compileUnits(self, moduleId):
 return response
 
 def request_completions(self, text, frameId=None):
-args_dict = {"text": text, "column": len(text)}
+args_dict = {"text": text, "column": len(text) + 1}
 if frameId:
 args_dict["frameId"] = frameId
 command_dict = {

diff  --git a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py 
b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
index 2b3ec656c107a5..8ad12b3fc2f6b1 100644
--- a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
+++ b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
@@ -9,6 +9,28 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+session_completion = {
+"text": "session",
+"label": "session -- Commands controlling LLDB session.",
+}
+settings_completion = {
+"text": "settings",
+"label": "settings -- Commands for managing LLDB settings.",
+}
+memory_completion = {
+"text": "memory",
+"label": "memory -- Commands for operating on memory in the current target 
process.",
+}
+command_var_completion = {
+"text": "var",
+"label": "var -- Show variables for the current stack frame. Defaults to 
all arguments and local variables in scope. Names of argument, local, file 
static and file global variables can be specified.",
+}
+variable_var_completion = {
+"text": "var",
+"label": "var -- vector &",
+}
+variable_var1_completion = {"text": "var1", "label": "var1 -- int &"}
+variable_var2_completion = {"text": "var2", "label": "var2 -- int &"}
 
 class TestDAP_completions(lldbdap_testcase.DAPTestCaseBase):
 def verify_completions(self, actual_list, expected_list, 
not_expected_list=[]):
@@ -18,12 +40,8 @@ def verify_completions(self, actual_list, expected_list, 
not_expected_list=[]):
 for not_expected_item in not_expected_list:
 self.assertNotIn(not_expected_item, actual_list)
 
-@skipIfWindows
-@skipIf(compiler="clang", compiler_version=["<", "17.0"])
-def test_completions(self):
-"""
-Tests the completion request at 
diff erent breakpoints
-"""
+
+def setup_debugee(self):
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)
 
@@ -32,90 +50,146 @@ def test_completions(self):
 breakpoint2_line = line_number(source, "// breakpoint 2")
 
 self.set_source_breakpoints(source, [breakpoint1_line, 
breakpoint2_line])
+

[Lldb-commits] [lldb] [lldb-dap] Correct auto-completion based on ReplMode and escape char (PR #110784)

2024-10-02 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] [lldb][debugserver] Check if Rosetta debugserver exists (PR #110943)

2024-10-02 Thread via lldb-commits

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

This looks good to me.  In fact, it looks WAY better than the error handling 
just above it where instead of logging something that we could find later in 
the system logs, we fprintf to stderr - which in most cases won't get seen, and 
exit (but w/o an error?).

OTOH, that wasn't part of your patch, so...

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


[Lldb-commits] [lldb] [lldb][debugserver] Check if Rosetta debugserver exists (PR #110943)

2024-10-02 Thread Jason Molenda via lldb-commits

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

If lldb tries to attach to a process that is marked 'Translated' with 
debugserver, it will exec the Rosetta debugserver to handle the debug session 
without checking if it is present.  If there is a configuration that is somehow 
missing this, it will fail poorly.

rdar://135641680

>From e1ea95287aeaa216e332aa221039247feaeb48e1 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Wed, 2 Oct 2024 17:45:36 -0700
Subject: [PATCH] [lldb][debugserver] Check if Rosetta debugserver exists

If lldb tries to attach to a process that is marked 'Translated'
with debugserver, it will exec the Rosetta debugserver to handle
the debug session without checking if it is present.  If there is
a configuration that is somehow missing this, it will fail poorly.

rdar://135641680
---
 lldb/tools/debugserver/source/DNB.cpp | 8 
 1 file changed, 8 insertions(+)

diff --git a/lldb/tools/debugserver/source/DNB.cpp 
b/lldb/tools/debugserver/source/DNB.cpp
index 1ac9a8040c6163..3e213a1f8b9bc0 100644
--- a/lldb/tools/debugserver/source/DNB.cpp
+++ b/lldb/tools/debugserver/source/DNB.cpp
@@ -480,6 +480,14 @@ nub_process_t DNBProcessAttach(nub_process_t attach_pid,
   exit(1);
 }
 
+struct stat st;
+if (::stat(translated_debugserver, &st) != 0) {
+  DNBLogError("Translated inferior process but Rosetta debugserver not 
"
+  "found at %s",
+  translated_debugserver);
+  return INVALID_NUB_PROCESS_ARCH;
+}
+
 snprintf(fdstr, sizeof(fdstr), "--fd=%d", communication_fd);
 snprintf(pidstr, sizeof(pidstr), "--attach=%d", attach_pid);
 execl(translated_debugserver, translated_debugserver, "--native-regs",

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


[Lldb-commits] [lldb] [lldb][debugserver] Check if Rosetta debugserver exists (PR #110943)

2024-10-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)


Changes

If lldb tries to attach to a process that is marked 'Translated' with 
debugserver, it will exec the Rosetta debugserver to handle the debug session 
without checking if it is present.  If there is a configuration that is somehow 
missing this, it will fail poorly.

rdar://135641680

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


1 Files Affected:

- (modified) lldb/tools/debugserver/source/DNB.cpp (+8) 


``diff
diff --git a/lldb/tools/debugserver/source/DNB.cpp 
b/lldb/tools/debugserver/source/DNB.cpp
index 1ac9a8040c6163..3e213a1f8b9bc0 100644
--- a/lldb/tools/debugserver/source/DNB.cpp
+++ b/lldb/tools/debugserver/source/DNB.cpp
@@ -480,6 +480,14 @@ nub_process_t DNBProcessAttach(nub_process_t attach_pid,
   exit(1);
 }
 
+struct stat st;
+if (::stat(translated_debugserver, &st) != 0) {
+  DNBLogError("Translated inferior process but Rosetta debugserver not 
"
+  "found at %s",
+  translated_debugserver);
+  return INVALID_NUB_PROCESS_ARCH;
+}
+
 snprintf(fdstr, sizeof(fdstr), "--fd=%d", communication_fd);
 snprintf(pidstr, sizeof(pidstr), "--attach=%d", attach_pid);
 execl(translated_debugserver, translated_debugserver, "--native-regs",

``




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


[Lldb-commits] [lldb] [lldb][CMake] Add single target that runs libc++ tests (PR #110856)

2024-10-02 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/110856

We've been increasing the coverage of libc++ LLDB tests in the pre-merge CI 
(see https://github.com/llvm/llvm-project/pull/110570). Unfortunately the tests 
are spread across different targets. It would be great if we had a single 
target that libc++ maintainers could run. And we would just add additional 
tests to that list on the LLDB side as needed.

This patch adds such target.

I'm not sure if there's a more idiomatic way of doing this in CMake (or maybe 
`lit`? using the `libc++` API test category?). But here's a first stab that 
does the right thing locally

>From ee28f91822ca449b7b4bb84293cae2aee6803da4 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 2 Oct 2024 15:44:28 +0100
Subject: [PATCH] [lldb][CMake] Add single target that runs libc++ tests

---
 lldb/test/CMakeLists.txt | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..656f9a1727b316 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -267,6 +267,21 @@ add_lit_testsuite(check-lldb "Running lldb lit test suite"
 lldb-shell-test-deps
 lldb-unit-test-deps)
 
+# This target covers all targets that are tied to implementation details
+# of libc++, intended to be run by the libc++ pre-merge CI.
+add_lit_testsuite(check-lldb-libcxx-integration "Running lldb libc++ support 
test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS
+check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx
+check-lldb-api-functionalities-data-formatter-data-formatter-stl-generic
+
check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx-simulators
+check-lldb-api-commands-expression-import-std-module
+check-lldb-api-lang-cpp-std-function-step-into-callable
+check-lldb-api-lang-cpp-std-function-recognizer
+check-lldb-api-lang-cpp-std-invoke-recognizer
+)
+
 if(LLDB_BUILT_STANDALONE)
   # This has to happen *AFTER* add_lit_testsuite.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)

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


[Lldb-commits] [lldb] [lldb][CMake] Add single target that runs libc++ tests (PR #110856)

2024-10-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

We've been increasing the coverage of libc++ LLDB tests in the pre-merge CI 
(see https://github.com/llvm/llvm-project/pull/110570). Unfortunately the tests 
are spread across different targets. It would be great if we had a single 
target that libc++ maintainers could run. And we would just add additional 
tests to that list on the LLDB side as needed.

This patch adds such target.

I'm not sure if there's a more idiomatic way of doing this in CMake (or maybe 
`lit`? using the `libc++` API test category?). But here's a first stab that 
does the right thing locally

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


1 Files Affected:

- (modified) lldb/test/CMakeLists.txt (+15) 


``diff
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..656f9a1727b316 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -267,6 +267,21 @@ add_lit_testsuite(check-lldb "Running lldb lit test suite"
 lldb-shell-test-deps
 lldb-unit-test-deps)
 
+# This target covers all targets that are tied to implementation details
+# of libc++, intended to be run by the libc++ pre-merge CI.
+add_lit_testsuite(check-lldb-libcxx-integration "Running lldb libc++ support 
test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS
+check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx
+check-lldb-api-functionalities-data-formatter-data-formatter-stl-generic
+
check-lldb-api-functionalities-data-formatter-data-formatter-stl-libcxx-simulators
+check-lldb-api-commands-expression-import-std-module
+check-lldb-api-lang-cpp-std-function-step-into-callable
+check-lldb-api-lang-cpp-std-function-recognizer
+check-lldb-api-lang-cpp-std-invoke-recognizer
+)
+
 if(LLDB_BUILT_STANDALONE)
   # This has to happen *AFTER* add_lit_testsuite.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)

``




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


[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-02 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/97443

>From 3a718c75d0458b7aece72f2ba8e5aa5a68815237 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 2 Jul 2024 18:43:34 +0200
Subject: [PATCH 1/3] [clang][RecordLayoutBuilder] Be stricter about inferring
 packed-ness in ExternalLayouts

This patch is motivated by the LLDB support required for:
https://github.com/llvm/llvm-project/issues/93069

In the presence of `[[no_unique_address]]`, LLDB may ask Clang
to lay out types with overlapping field offsets. Because we don't
have attributes such as `packed` or `no_unique_address` in the LLDB
AST, the `RecordLayoutBuilder` supports an `InferAlignment` mode, which,
in the past, attempted to detect layouts which came from packed
structures in order to provide a conservative estimate of alignment for
it (since `DW_AT_alignment` isn't emitted unless explicitly changed with
`alignas`, etc.).

However, in the presence of overlapping fields due to `no_unique_address`,
`InferAlignment` would set the alignment of structures to `1` for which
that's incorrect. This poses issues in some LLDB formatters that
synthesize new Clang types and rely on the layout builder to get the
`FieldOffset` of structures right that we did have DWARF offsets for.
The result of this is that if we get the alignment wrong, LLDB reads
out garbage data from the wrong field offsets.

There are a couple of solutions to this that we considered:
1. Make LLDB formatters not do the above, and make them more robust
   to inaccurate alignment.
2. Remove `InferAlignment` entirely and rely on Clang emitting
   `DW_AT_alignment` for packed structures.
3. Remove `InferAlignment` and detect packedness from within LLDB.
4. Make the `InferAlignment` logic account for overlapping fields.

Option (1) turned out quite hairy and it's not clear we can achieve
this with the tools available for certain STL formatters (particularly
`std::map`). But I would still very much like to simplify this if we
can.

Option (2) wouldn't help with GCC-compiled binaries, and if we can
get away with LLDB not needing the alignment, then we wouldn't need
to increase debug-info size.

Option (3), AFAICT, would require us to reimplement some of the layout
logic in the layout builder. Would be great if we can avoid this added
complexity.

Option (4) seemed like the best option in the interim. As part of this
change I also removed one of the `InferAlignment` blocks. The test-cases
associated with this code-path pass regardless, and from the description
of the change that introduced it it's not clear why specifically the
base offsets would influence the `Alignment` field, and how it would
imply packedness. But happy to be proven wrong. Ultimately it would be
great if we can get rid of the `InferAlignment` infrastructure and
support our use-cases in LLDB or DWARF instead.
---
 clang/lib/AST/RecordLayoutBuilder.cpp | 34 +--
 .../DWARF/no_unique_address-alignment.cpp |  2 --
 .../no_unique_address-base-alignment.cpp  |  2 --
 3 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index d9bf62c2bbb04a..8dbf69c310cbb4 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -802,7 +802,8 @@ class ItaniumRecordLayoutBuilder {
   /// \param Field The field whose offset is being queried.
   /// \param ComputedOffset The offset that we've computed for this field.
   uint64_t updateExternalFieldOffset(const FieldDecl *Field,
- uint64_t ComputedOffset);
+ uint64_t ComputedOffset,
+ uint64_t PreviousOffset);
 
   void CheckFieldPadding(uint64_t Offset, uint64_t UnpaddedOffset,
   uint64_t UnpackedOffset, unsigned UnpackedAlign,
@@ -1296,13 +1297,6 @@ ItaniumRecordLayoutBuilder::LayoutBase(const 
BaseSubobjectInfo *Base) {
 bool Allowed = EmptySubobjects->CanPlaceBaseAtOffset(Base, Offset);
 (void)Allowed;
 assert(Allowed && "Base subobject externally placed at overlapping 
offset");
-
-if (InferAlignment && Offset < getDataSize().alignTo(AlignTo)) {
-  // The externally-supplied base offset is before the base offset we
-  // computed. Assume that the structure is packed.
-  Alignment = CharUnits::One();
-  InferAlignment = false;
-}
   }
 
   if (!Base->Class->isEmpty()) {
@@ -1770,7 +1764,8 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   // If we're using external layout, give the external layout a chance
   // to override this information.
   if (UseExternalLayout)
-FieldOffset = updateExternalFieldOffset(D, FieldOffset);
+FieldOffset = updateExternalFieldOffset(
+D, FieldOffset, FieldOffsets.empty() ? 0 : FieldOffsets.back());
 
   // Okay, place the bitfield at the calculated offset.
   Field

[Lldb-commits] [lldb] [LLDB] Enable TLS Variable Debugging Without Location Info on AArch64 (PR #110822)

2024-10-02 Thread Kamlesh Kumar via lldb-commits

https://github.com/kamleshbhalui updated 
https://github.com/llvm/llvm-project/pull/110822

>From ba3071566ac697e750606c7fc941e5f6fc738367 Mon Sep 17 00:00:00 2001
From: Kamlesh Kumar 
Date: Thu, 19 Sep 2024 18:57:14 +0200
Subject: [PATCH] [LLDB] Enable TLS Variable Debugging Without Location Info on
 AArch64
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On AArch64, TLS variables do not have DT_Location entries generated in the
debug information due to the lack of dtpoff relocation support, unlike on 
x86_64.
LLDB relies on this location info to calculate the TLS address, leading to 
issues
when debugging TLS variables on AArch64.
However, GDB can successfully calculate the TLS address without relying on this 
debug info,
by using the symbol’s address and manually calculating the offset. We adopt a 
similar approach for LLDB.
---
 lldb/include/lldb/Symbol/Variable.h   |  2 ++
 lldb/source/Core/ValueObjectVariable.cpp  | 33 ++-
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 14 +---
 .../Utility/RegisterInfoPOSIX_arm64.cpp   | 15 +
 .../Process/Utility/RegisterInfos_arm64.h | 11 +--
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |  7 ++--
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  9 +
 lldb/source/Symbol/Variable.cpp   | 13 
 8 files changed, 85 insertions(+), 19 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Variable.h 
b/lldb/include/lldb/Symbol/Variable.h
index c437624d1ea6d7..4ad06baeb684a4 100644
--- a/lldb/include/lldb/Symbol/Variable.h
+++ b/lldb/include/lldb/Symbol/Variable.h
@@ -79,6 +79,8 @@ class Variable : public UserID, public 
std::enable_shared_from_this {
 return m_location_list;
   }
 
+  bool IsThreadLocal() const;
+
   // When given invalid address, it dumps all locations. Otherwise it only 
dumps
   // the location that contains this address.
   bool DumpLocations(Stream *s, const Address &address);
diff --git a/lldb/source/Core/ValueObjectVariable.cpp 
b/lldb/source/Core/ValueObjectVariable.cpp
index 29aefb270c92c8..393ddc1960ab47 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -254,7 +254,38 @@ bool ValueObjectVariable::UpdateValue() {
   m_resolved_value.SetContext(Value::ContextType::Invalid, nullptr);
 }
   }
-
+  if (m_error.Fail() && variable->IsThreadLocal()) {
+ExecutionContext exe_ctx(GetExecutionContextRef());
+Thread *thread = exe_ctx.GetThreadPtr();
+lldb::ModuleSP module_sp = GetModule();
+if (!thread) {
+  m_error = Status::FromErrorString("no thread to evaluate TLS within");
+  return m_error.Success();
+}
+std::vector symbol_indexes;
+module_sp->GetSymtab()->FindAllSymbolsWithNameAndType(
+ConstString(variable->GetName()), lldb::SymbolType::eSymbolTypeAny,
+symbol_indexes);
+Symbol *symbol = module_sp->GetSymtab()->SymbolAtIndex(symbol_indexes[0]);
+lldb::addr_t tls_file_addr =
+symbol->GetAddress().GetOffset() +
+symbol->GetAddress().GetSection()->GetFileAddress();
+const lldb::addr_t tls_load_addr =
+thread->GetThreadLocalData(module_sp, tls_file_addr);
+if (tls_load_addr == LLDB_INVALID_ADDRESS)
+  m_error = Status::FromErrorString(
+  "no TLS data currently exists for this thread");
+else {
+  Value old_value(m_value);
+  m_value.GetScalar() = tls_load_addr;
+  m_value.SetContext(Value::ContextType::Variable, variable);
+  m_value.SetValueType(Value::ValueType::LoadAddress);
+  m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
+  SetValueDidChange(m_value.GetValueType() != old_value.GetValueType() ||
+m_value.GetScalar() != old_value.GetScalar());
+  SetValueIsValid(m_error.Success());
+}
+  }
   return m_error.Success();
 }
 
diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 51e4b3e6728f23..5a78ad2286f87a 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -771,9 +771,12 @@ DynamicLoaderPOSIXDYLD::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 "GetThreadLocalData info: link_map=0x%" PRIx64
 ", thread info metadata: "
 "modid_offset=0x%" PRIx32 ", dtv_offset=0x%" PRIx32
-", tls_offset=0x%" PRIx32 ", dtv_slot_size=%" PRIx32 "\n",
+", tls_offset=0x%" PRIx32 ", dtv_slot_size=%" PRIx32
+", tls_file_addr=0x%" PRIx64 ", module name=%s "
+"\n",
 link_map, metadata.modid_offset, metadata.dtv_offset,
-metadata.tls_offset, metadata.dtv_slot_size);
+metadata.tls_offset, metadata.dtv_slot_size, tls_file_addr,
+module_sp->GetFileSpec().G

[Lldb-commits] [lldb] [LLDB] Enable TLS Variable Debugging Without Location Info on AArch64 (PR #110822)

2024-10-02 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 e379094328e49731a606304f7e3559d4f1fa96f9 
ba3071566ac697e750606c7fc941e5f6fc738367 --extensions cpp,h -- 
lldb/include/lldb/Symbol/Variable.h lldb/source/Core/ValueObjectVariable.cpp 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp 
lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h 
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
lldb/source/Symbol/Variable.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
index b1a0a1957e..002690690c 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
@@ -472,10 +472,8 @@ static uint32_t g_d31_invalidates[] = {fpu_v31, fpu_s31, 
LLDB_INVALID_REGNUM};
 
 // Generates register kinds array for registers with only generic kind
 #define GENERIC_KIND(generic_kind) 
\
-  {
\
-LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, generic_kind,
\
-LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM   
\
-  }
+  {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, generic_kind, 
\
+   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}
 
 // Generates register kinds array for registers with only lldb kind
 #define KIND_ALL_INVALID   
\

``




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


[Lldb-commits] [lldb] e7a43ca - [lldb-dap] Fix a warning

2024-10-02 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2024-10-02T19:20:38-07:00
New Revision: e7a43ca84fabeab386ba4d402167244dac27b265

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

LOG: [lldb-dap] Fix a warning

This patch fixes:

  lldb/tools/lldb-dap/lldb-dap.cpp:1405:16: error: comparison of
  integers of different signs: 'int64_t' (aka 'long') and 'size_type'
  (aka 'unsigned long') [-Werror,-Wsign-compare]

Added: 


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

Removed: 




diff  --git a/lldb/tools/lldb-dap/lldb-dap.cpp 
b/lldb/tools/lldb-dap/lldb-dap.cpp
index edbbd9bc5f9539..0b6d6402410654 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -1402,7 +1402,7 @@ void request_completions(const llvm::json::Object 
&request) {
   // Handle the offset change introduced by stripping out the
   // `command_escape_prefix`.
   if (had_escape_prefix) {
-if (offset < g_dap.command_escape_prefix.size()) {
+if (offset < static_cast(g_dap.command_escape_prefix.size())) {
   body.try_emplace("targets", std::move(targets));
   response.try_emplace("body", std::move(body));
   g_dap.SendJSON(llvm::json::Value(std::move(response)));



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


[Lldb-commits] [lldb] [llvm] [lldb][DWARF] Replace lldb's DWARFDebugArangeSet with llvm's (PR #110058)

2024-10-02 Thread Carlos Alberto Enciso via lldb-commits

CarlosAlbertoEnciso wrote:


> Hope 
> [e379b4b](https://github.com/llvm/llvm-project/commit/e379b4b67f760e743d8bc826cc6de00a27109dbd)
>  will fix it.

@ZequanWu The problem is fixed. Thanks.


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