[Lldb-commits] [clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Timm Baeder via lldb-commits


@@ -14690,6 +14690,14 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) {
 }
   }
 
+  // The result of __builtin_counted_by_ref cannot be assigned to a variable.
+  // It allows leaking and modification of bounds safety information.
+  if (const auto *CE = dyn_cast_if_present(VD->getInit());
+  CE && CE->getBuiltinCallee() == Builtin::BI__builtin_counted_by_ref)

tbaederr wrote:

Can you not use `IsBuiltinCountedByRef()` here?

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread via lldb-commits

ChuvakHome wrote:

> BOLT changes look good, thank you for fixing those. If you split them out, I 
> can help land it sooner.

https://github.com/llvm/llvm-project/pull/117156

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


[Lldb-commits] [lldb] Reapply "[lldb] Convert file address to load address when reading memory for DW_OP_piece" (PR #117168)

2024-11-21 Thread Ilia Kuklin via lldb-commits

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


[Lldb-commits] [lldb] Re-apply [lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size as symbols are created (PR #117079)

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

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

This was originally reviewed in #106791. LGTM.

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


[Lldb-commits] [lldb] [lldb] Fix inline function resolution for discontinuous functions (PR #116777)

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

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


[Lldb-commits] [lldb] d71fa33 - [lldb] Fix inline function resolution for discontinuous functions (#116777)

2024-11-21 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-11-22T08:32:47+01:00
New Revision: d71fa331df49450361a9e5cd4e48ae4a79b6126b

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

LOG: [lldb] Fix inline function resolution for discontinuous functions (#116777)

The problem here is the assumption that the entire function will be
placed in a single section. This will ~never be the case for a
discontinuous function, as the point of splitting the function is to let
the linker group parts of the function according to their "hotness".

The fix is to change the offset computation to use file addresses
instead.

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

Modified: 
lldb/source/Symbol/Block.cpp
lldb/source/Symbol/SymbolContext.cpp

Removed: 




diff  --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp
index 5c7772a6db780d..8746a25e3fad5a 100644
--- a/lldb/source/Symbol/Block.cpp
+++ b/lldb/source/Symbol/Block.cpp
@@ -252,19 +252,20 @@ bool Block::GetRangeContainingAddress(const Address &addr,
   Function *function = CalculateSymbolContextFunction();
   if (function) {
 const AddressRange &func_range = function->GetAddressRange();
-if (addr.GetSection() == func_range.GetBaseAddress().GetSection()) {
-  const addr_t addr_offset = addr.GetOffset();
-  const addr_t func_offset = func_range.GetBaseAddress().GetOffset();
-  if (addr_offset >= func_offset &&
-  addr_offset < func_offset + func_range.GetByteSize()) {
-addr_t offset = addr_offset - func_offset;
+if (addr.GetModule() == func_range.GetBaseAddress().GetModule()) {
+  const addr_t file_addr = addr.GetFileAddress();
+  const addr_t func_file_addr =
+  func_range.GetBaseAddress().GetFileAddress();
+  if (file_addr >= func_file_addr &&
+  file_addr < func_file_addr + func_range.GetByteSize()) {
+addr_t offset = file_addr - func_file_addr;
 
 const Range *range_ptr = m_ranges.FindEntryThatContains(offset);
 
 if (range_ptr) {
-  range.GetBaseAddress() = func_range.GetBaseAddress();
-  range.GetBaseAddress().SetOffset(func_offset +
-   range_ptr->GetRangeBase());
+  range.GetBaseAddress() =
+  Address(func_file_addr + range_ptr->GetRangeBase(),
+  addr.GetModule()->GetSectionList());
   range.SetByteSize(range_ptr->GetByteSize());
   return true;
 }

diff  --git a/lldb/source/Symbol/SymbolContext.cpp 
b/lldb/source/Symbol/SymbolContext.cpp
index de083e81206e2a..1a291ca3c0ea7a 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -102,10 +102,11 @@ bool SymbolContext::DumpStopContext(
 s->PutCStringColorHighlighted(name.GetStringRef(), settings);
 }
 
-if (addr.IsValid()) {
+if (addr_t file_addr = addr.GetFileAddress();
+file_addr != LLDB_INVALID_ADDRESS) {
   const addr_t function_offset =
-  addr.GetOffset() -
-  function->GetAddressRange().GetBaseAddress().GetOffset();
+  file_addr -
+  function->GetAddressRange().GetBaseAddress().GetFileAddress();
   if (!show_function_name) {
 // Print +offset even if offset is 0
 dumped_something = true;
@@ -126,7 +127,8 @@ bool SymbolContext::DumpStopContext(
   lldb_private::AddressRange block_range;
   if (inlined_block->GetRangeContainingAddress(addr, block_range)) {
 const addr_t inlined_function_offset =
-addr.GetOffset() - block_range.GetBaseAddress().GetOffset();
+addr.GetFileAddress() -
+block_range.GetBaseAddress().GetFileAddress();
 if (inlined_function_offset) {
   s->Printf(" + %" PRIu64, inlined_function_offset);
 }

diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-inline-function.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-inline-function.s
new file mode 100644
index 00..399f4e4db5b2f1
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-inline-function.s
@@ -0,0 +1,167 @@
+## Test that inline function resolution works when the function has been split
+## into multiple discontinuous parts (and those parts are placed in 
diff erent
+## sections)
+
+# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %s -o %t
+# RUN: %lldb %t -o "image lookup -v -n look_me_up" -o exit | FileCheck %s
+
+# CHECK:  1 match found in {{.*}}
+# CHECK:  Summary: {{.*}}`foo + 6 [inlined] foo_inl + 1
+# CHECK-NEXT:  {{.*}}`foo + 5
+# CHECK:  Blocks: id = {{.*}}, ranges = 
[0x-0x0003)[0x0004-0x0008)
+# CHECK-NEXT: id = {{.*}}, ranges = 
[0x0001-0x0002)[0x0

[Lldb-commits] [lldb] [lldb] Fix inline function resolution for discontinuous functions (PR #116777)

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

labath wrote:

Yeah, in my previous patches, the code was all in one section as it wasn't 
relevant for the test, but the way this really works is that every part of the 
function gets its own subsection (on MachO, I guess you'd use subsections for 
that). That way the linker doesn't need to do anything special -- for all it 
cares, the individual chunks are just separate functions (with strange calling 
conventions).

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


[Lldb-commits] [lldb] Fix loading UUIDs from ELF headers. (PR #117028)

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


@@ -224,7 +224,7 @@ Status ProcessElfCore::DoLoadCore() {
   ArchSpec core_arch(m_core_module_sp->GetArchitecture());
   target_arch.MergeFrom(core_arch);
   GetTarget().SetArchitecture(target_arch);
- 
+

DavidSpickett wrote:

I would push these whitespace changes directly, to keep this change neat.

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


[Lldb-commits] [lldb] Fix loading UUIDs from ELF headers. (PR #117028)

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

https://github.com/DavidSpickett commented:

I'm a bit confused as to how we have a core file but also things are moved in 
memory.

Can you give an explanation of how this occurs? Please add it to the PR 
description.

Also, tests? (which is partly why I ask how this occurs)

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


[Lldb-commits] [lldb] Fix loading UUIDs from ELF headers. (PR #117028)

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

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


[Lldb-commits] [clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread via lldb-commits

https://github.com/Sirraide commented:

I think this might honestly be fine the way it is now, but I’d like for e.g. 
@AaronBallman to take a look at this too before approving it since he’s more 
familiar w/ C than me.

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


[Lldb-commits] [lldb] [lldb] Fix loading UUIDs from ELF headers. (PR #117028)

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

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


[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

2024-11-21 Thread Augusto Noronha via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Fix ELF core debugging (PR #117070)

2024-11-21 Thread Kazuki Sakamoto via lldb-commits


@@ -224,7 +224,7 @@ Status ProcessElfCore::DoLoadCore() {
   ArchSpec core_arch(m_core_module_sp->GetArchitecture());
   target_arch.MergeFrom(core_arch);
   GetTarget().SetArchitecture(target_arch);
- 
+

splhack wrote:

This pull request will be rebased onto #117028 once it landed onto main, which 
will do clang-format.

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


[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

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


@@ -2726,39 +2726,8 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   TypeQuery query_full(query);
   bool have_index_match = false;
   m_index->GetTypesWithQuery(query_full, [&](DWARFDIE die) {
-// Check the language, but only if we have a language filter.
-if (query.HasLanguage()) {
-  if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU(
-return true; // Keep iterating over index types, language mismatch.
-}
-
-// Since mangled names are unique, we only need to check if the names are
-// the same.
-if (query.GetSearchByMangledName()) {
-  if (die.GetMangledName(/*substitute_name_allowed=*/false) !=
-  query.GetTypeBasename().GetStringRef())
-return true; // Keep iterating over index types, mangled name mismatch.
-  if (Type *matching_type = ResolveType(die, true, true)) {
-results.InsertUnique(matching_type->shared_from_this());
-return !results.Done(query); // Keep iterating if we aren't done.
-  }
-  return true; // Keep iterating over index types, weren't able to resolve
-   // this type
-}
-
-// Check the context matches
-std::vector die_context;
-if (query.GetModuleSearch())
-  die_context = die.GetDeclContext();
-else
-  die_context = die.GetTypeLookupContext();
-assert(!die_context.empty());

labath wrote:

I don't feel strongly about this, but I don't think this should be an assert. 
Like, we can probably reach this code if a bad (corrupted) index points us to 
an empty DIE. According to the [assertion 
manifesto](https://lldb.llvm.org/resources/contributing.html#error-handling-and-use-of-assertions-in-lldb)
 this shouldn't crash lldb.

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


[Lldb-commits] [lldb] [lldb] Make sure completions don't end with newlines (PR #117054)

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

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

Okay, so you're saying that we could hit this if we're completing an expression 
(variable name) and a particularly evil compiler puts a newline into the name. 
Makes sense, sort of.

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


[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

2024-11-21 Thread Augusto Noronha via lldb-commits

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


[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

2024-11-21 Thread Augusto Noronha via lldb-commits


@@ -2790,7 +2759,7 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   // With -gsimple-template-names, a templated type's DW_AT_name will not
   // contain the template parameters. Try again stripping '<' and anything
   // after, filtering out entries with template parameters that don't match.
-  if (!have_index_match) {
+  if (!have_index_match && !query.GetSearchByMangledName()) {

augusto2112 wrote:

This `!query.GetSearchByMangledName()` shouldn't be necessary since this 
condition is also in line 2730. so `have_index_match` will always be true

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


[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

2024-11-21 Thread Augusto Noronha via lldb-commits


@@ -2726,39 +2726,8 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   TypeQuery query_full(query);
   bool have_index_match = false;
   m_index->GetTypesWithQuery(query_full, [&](DWARFDIE die) {
-// Check the language, but only if we have a language filter.
-if (query.HasLanguage()) {
-  if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU(
-return true; // Keep iterating over index types, language mismatch.
-}
-
-// Since mangled names are unique, we only need to check if the names are
-// the same.
-if (query.GetSearchByMangledName()) {
-  if (die.GetMangledName(/*substitute_name_allowed=*/false) !=
-  query.GetTypeBasename().GetStringRef())
-return true; // Keep iterating over index types, mangled name mismatch.
-  if (Type *matching_type = ResolveType(die, true, true)) {
-results.InsertUnique(matching_type->shared_from_this());
-return !results.Done(query); // Keep iterating if we aren't done.
-  }
-  return true; // Keep iterating over index types, weren't able to resolve
-   // this type
-}
-
-// Check the context matches
-std::vector die_context;
-if (query.GetModuleSearch())
-  die_context = die.GetDeclContext();
-else
-  die_context = die.GetTypeLookupContext();
-assert(!die_context.empty());

augusto2112 wrote:

This assert is missing in `DWARFIndex::ProcessTypeDIEMatchQuery`, maybe add 
that back?

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread via lldb-commits

https://github.com/ChuvakHome created 
https://github.com/llvm/llvm-project/pull/117151

Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

>From 4bd798da2681d1648c19d10da1160b01e5445804 Mon Sep 17 00:00:00 2001
From: Feng Zou 
Date: Thu, 21 Nov 2024 16:13:11 +0800
Subject: [PATCH 1/2] [X86][MC] Add R_X86_64_CODE_4_GOTTPOFF (#116633)

For

  mov name@GOTTPOFF(%rip), %reg
  add name@GOTTPOFF(%rip), %reg

add

  `R_X86_64_CODE_4_GOTTPOFF` = 44

if the instruction starts at 4 bytes before the relocation offset. It's
similar to R_X86_64_GOTTPOFF.

Linker can treat `R_X86_64_CODE_4_GOTTPOFF` as `R_X86_64_GOTTPOFF` or
convert the instructions above to

  mov $name@tpoff, %reg
  add $name@tpoff, %reg

if the first byte of the instruction at the relocation `offset - 4` is
`0xd5` (namely, encoded w/REX2 prefix) when possible.

Binutils patch:
https://github.com/bminor/binutils-gdb/commit/a533c8df598b5ef99c54a13e2b137c98b34b043c
Binutils mailthread:
https://sourceware.org/pipermail/binutils/2023-December/131463.html
ABI discussion:
https://groups.google.com/g/x86-64-abi/c/ACwD-UQXVDs/m/vrgTenKyFwAJ
Blog: https://kanrobert.github.io/rfc/All-about-APX-relocation

Fix bug with parenthesis
---
 bolt/lib/Passes/ShrinkWrapping.cpp|  4 +-
 .../llvm/BinaryFormat/ELFRelocs/x86_64.def|  1 +
 .../X86/MCTargetDesc/X86ELFObjectWriter.cpp   |  3 +
 llvm/test/MC/ELF/relocation.s | 67 ++-
 4 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/bolt/lib/Passes/ShrinkWrapping.cpp 
b/bolt/lib/Passes/ShrinkWrapping.cpp
index 176321c58dc903..bc4e7e6e386a0e 100644
--- a/bolt/lib/Passes/ShrinkWrapping.cpp
+++ b/bolt/lib/Passes/ShrinkWrapping.cpp
@@ -78,8 +78,8 @@ void CalleeSavedAnalysis::analyzeSaves() {
 // probably dealing with a parameter passed in a stack -- do not mess
 // with it
 if (SRU.isStoreUsed(*FIE,
-Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB)),
-/*IncludeLocalAccesses=*/false) {
+Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB),
+/*IncludeLocalAccesses=*/false)) {
   BlacklistedRegs.set(FIE->RegOrImm);
   CalleeSaved.reset(FIE->RegOrImm);
   Prev = &Inst;
diff --git a/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def 
b/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
index 43473d47e32819..94b1ad9c1f9464 100644
--- a/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
+++ b/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
@@ -44,3 +44,4 @@ ELF_RELOC(R_X86_64_IRELATIVE,   37)
 ELF_RELOC(R_X86_64_GOTPCRELX,   41)
 ELF_RELOC(R_X86_64_REX_GOTPCRELX,42)
 ELF_RELOC(R_X86_64_CODE_4_GOTPCRELX,43)
+ELF_RELOC(R_X86_64_CODE_4_GOTTPOFF,44)
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp 
b/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
index a57b1335d1437a..aa02934cc99963 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
@@ -197,6 +197,9 @@ static unsigned getRelocType64(MCContext &Ctx, SMLoc Loc,
 return ELF::R_X86_64_TLSGD;
   case MCSymbolRefExpr::VK_GOTTPOFF:
 checkIs32(Ctx, Loc, Type);
+if ((unsigned)Kind == X86::reloc_riprel_4byte_movq_load_rex2 ||
+(unsigned)Kind == X86::reloc_riprel_4byte_relax_rex2)
+  return ELF::R_X86_64_CODE_4_GOTTPOFF;
 return ELF::R_X86_64_GOTTPOFF;
   case MCSymbolRefExpr::VK_TLSLD:
 checkIs32(Ctx, Loc, Type);
diff --git a/llvm/test/MC/ELF/relocation.s b/llvm/test/MC/ELF/relocation.s
index 80b671aa2c859e..88301f8447bc2a 100644
--- a/llvm/test/MC/ELF/relocation.s
+++ b/llvm/test/MC/ELF/relocation.s
@@ -19,6 +19,8 @@ bar:
 movq   bar, %rdx # R_X86_64_32S
 .long bar # R_X86_64_32
 leaq   foo@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF
+movqfoo@GOTTPOFF(%rip), %r31 # R_X86_64_CODE_4_GOTTPOFF
+addqfoo@GOTTPOFF(%rip), %r31 # R_X86_64_CODE_4_GOTTPOFF
 leaq   foo@TLSGD(%rip), %rax# R_X86_64_TLSGD
 leaq   foo@TPOFF(%rax), %rax# R_X86_64_TPOFF32
 leaq   foo@TLSLD(%rip), %rdi# R_X86_64_TLSLD
@@ -67,7 +69,6 @@ pr24486:
 weak_sym:
 .long  pr23272-weak_sym
 
-
 // CHECK:Section {
 // CHECK:  Name: .rela.text
 // CHECK:  Relocations [
@@ -78,37 +79,39 @@ weak_sym:
 // CHECK-NEXT:   0x22 R_X86_64_32S  .text
 // CHECK-NEXT:   0x26 R_X86_64_32   .text
 // CHECK-NEXT:   0x2D R_X86_64_GOTTPOFF foo 0xFFFC
-// CHECK-NEXT:   0x34 R_X86_64_TLSGDfoo 0xFFFC
-// CHECK-NEXT:   0x3B R_X86_64_TPOFF32  foo 0x0
-// CHECK-NEXT:   0x42 R_X86_64_TLSLDfoo 0xFFFC
-// CHECK-NEXT:   0x49 R_X86_64_DTPOFF32 foo 0x0
-// CHECK-NEXT:   0x4F R_X86_64_GOT64 foo 0x0
-// CHECK-NEXT:   0x59 R_X86_64_GOTOFF64 fo

[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: Chuvak (ChuvakHome)


Changes

Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

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


11 Files Affected:

- (modified) bolt/lib/Passes/ShrinkWrapping.cpp (+2-2) 
- (modified) bolt/lib/Rewrite/LinuxKernelRewriter.cpp (+1-1) 
- (modified) libc/fuzzing/math/Compare.h (+1-1) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (+1-1) 
- (modified) lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
(+1-1) 
- (modified) llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def (+1) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp (+3) 
- (modified) llvm/test/MC/ELF/relocation.s (+35-32) 
- (modified) mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.cpp 
(+1-1) 
- (modified) polly/lib/External/isl/isl_local_space.c (+1-1) 


``diff
diff --git a/bolt/lib/Passes/ShrinkWrapping.cpp 
b/bolt/lib/Passes/ShrinkWrapping.cpp
index 176321c58dc903..bc4e7e6e386a0e 100644
--- a/bolt/lib/Passes/ShrinkWrapping.cpp
+++ b/bolt/lib/Passes/ShrinkWrapping.cpp
@@ -78,8 +78,8 @@ void CalleeSavedAnalysis::analyzeSaves() {
 // probably dealing with a parameter passed in a stack -- do not mess
 // with it
 if (SRU.isStoreUsed(*FIE,
-Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB)),
-/*IncludeLocalAccesses=*/false) {
+Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB),
+/*IncludeLocalAccesses=*/false)) {
   BlacklistedRegs.set(FIE->RegOrImm);
   CalleeSaved.reset(FIE->RegOrImm);
   Prev = &Inst;
diff --git a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp 
b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
index 03b414b71caca7..39ceeffc79c165 100644
--- a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
+++ b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
@@ -580,7 +580,7 @@ Error LinuxKernelRewriter::readORCTables() {
   // As such, we can ignore alternative ORC entries. They will be preserved
   // in the binary, but will not get printed in the instruction stream.
   Inst = BF->getInstructionContainingOffset(Offset);
-  if (Inst || BC.MIB->hasAnnotation(*Inst, "AltInst"))
+  if (Inst && BC.MIB->hasAnnotation(*Inst, "AltInst"))
 continue;
 
   return createStringError(
diff --git a/libc/fuzzing/math/Compare.h b/libc/fuzzing/math/Compare.h
index 2b84ad3ab46213..8f06ed9c8cc102 100644
--- a/libc/fuzzing/math/Compare.h
+++ b/libc/fuzzing/math/Compare.h
@@ -20,7 +20,7 @@ ValuesEqual(T x1, T x2) {
   LIBC_NAMESPACE::fputil::FPBits bits2(x2);
   // If either is NaN, we want both to be NaN.
   if (bits1.is_nan() || bits2.is_nan())
-return bits2.is_nan() && bits2.is_nan();
+return bits1.is_nan() && bits2.is_nan();
 
   // For all other values, we want the values to be bitwise equal.
   return bits1.uintval() == bits2.uintval();
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 0083b499656979..c43871b08191db 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -3278,7 +3278,7 @@ bool 
AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
   }
 
   // If the index is still out of range then this isn't a pointer.
-  if (index > m_indexed_isa_cache.size())
+  if (index >= m_indexed_isa_cache.size())
 return false;
 
   LLDB_LOGF(log, "AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64 ")",
diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
index 8c69989702c2aa..f7a2d1d07142ec 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
@@ -150,7 +150,7 @@ GeneratePerfEventConfigValue(bool enable_tsc,
   if (enable_tsc) {
 if (Expected offset = ReadIntelPTConfigFile(
 kTSCBitOffsetFile, IntelPTConfigFileType::BitOffset))
-  config |= 1 << *offset;
+  config |= 1ULL << *offset;
 else
   return offset.takeError();
   }
diff --git a/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def 
b/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
index 43473d47e32819..94b1ad9c1f9464 100644
--- a/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
+++ b/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
@@ -44,3 +44,4 @@ ELF_RELOC(R_X86_64_IRELATIVE,   37)
 ELF_RELOC(R_X86_64_GOTPCRELX,   41)
 ELF_RELOC(R_X86_64_REX_GOTPCRELX,42)
 ELF_RELOC(R_X86_64_CODE_4_GOTPCRELX,43)
+ELF_RELOC(R_

[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] [lldb] Make sure completions don't end with newlines (PR #117054)

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

labath wrote:

I get the "description" part, but I'm somewhat confused about the "completion". 
How does a newline (trailing or not) get there? Like, you can't actually type 
something which includes a newline, right? I'm wondering if we should disallow 
these at a higher level...

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


[Lldb-commits] [lldb] [lldb] Fix ELF core debugging (PR #117070)

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


@@ -224,7 +224,7 @@ Status ProcessElfCore::DoLoadCore() {
   ArchSpec core_arch(m_core_module_sp->GetArchitecture());
   target_arch.MergeFrom(core_arch);
   GetTarget().SetArchitecture(target_arch);
- 
+

DavidSpickett wrote:

Keep formatting changes separate, push them directly if you have the rights to 
do so. If you have to choose between a clean commit and the formatter 
complaining, let it complain :)

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 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 46f43b6d92e49b80df13e8a537a95767ffbaac9f 
ee6ab90efad3153cd5f49f1fd3589143291ae68b --extensions c,cpp,h -- 
bolt/lib/Passes/ShrinkWrapping.cpp bolt/lib/Rewrite/LinuxKernelRewriter.cpp 
libc/fuzzing/math/Compare.h 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp 
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp 
mlir/lib/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.cpp 
polly/lib/External/isl/isl_local_space.c
``





View the diff from clang-format here.


``diff
diff --git a/bolt/lib/Passes/ShrinkWrapping.cpp 
b/bolt/lib/Passes/ShrinkWrapping.cpp
index bc4e7e6e38..8fcd8d5c68 100644
--- a/bolt/lib/Passes/ShrinkWrapping.cpp
+++ b/bolt/lib/Passes/ShrinkWrapping.cpp
@@ -79,7 +79,7 @@ void CalleeSavedAnalysis::analyzeSaves() {
 // with it
 if (SRU.isStoreUsed(*FIE,
 Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB),
-/*IncludeLocalAccesses=*/false)) {
+/*IncludeLocalAccesses=*/false)) {
   BlacklistedRegs.set(FIE->RegOrImm);
   CalleeSaved.reset(FIE->RegOrImm);
   Prev = &Inst;
diff --git a/polly/lib/External/isl/isl_local_space.c 
b/polly/lib/External/isl/isl_local_space.c
index 1bffcd544e..9567479a69 100644
--- a/polly/lib/External/isl/isl_local_space.c
+++ b/polly/lib/External/isl/isl_local_space.c
@@ -254,8 +254,8 @@ isl_size isl_local_space_var_offset(__isl_keep 
isl_local_space *ls,
isl_space *space;
 
space = isl_local_space_peek_space(ls);
-   if (space == NULL)
-   return isl_size_error;
+if (space == NULL)
+  return isl_size_error;
switch (type) {
case isl_dim_param:
case isl_dim_in:

``




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


[Lldb-commits] [lldb] Reapply "[lldb] Convert file address to load address when reading memory for DW_OP_piece" (PR #117168)

2024-11-21 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd created 
https://github.com/llvm/llvm-project/pull/117168

This commit fixes the test in so that the breakpoint is triggered correctly 
after `array` usage on Aarch64.

Reapplies #116411 with a fix.


>From b59a2114542999fa233e802cbc36500678132cb2 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Thu, 14 Nov 2024 20:15:19 +0500
Subject: [PATCH 1/3] Convert file address to load address when reading memory
 for DW_OP_piece

---
 lldb/source/Expression/DWARFExpression.cpp | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index f92f25ed342a9c..a7126b25c1cc38 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1853,12 +1853,25 @@ llvm::Expected DWARFExpression::Evaluate(
   const Value::ValueType curr_piece_source_value_type =
   curr_piece_source_value.GetValueType();
   Scalar &scalar = curr_piece_source_value.GetScalar();
-  const lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+  lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
   switch (curr_piece_source_value_type) {
   case Value::ValueType::Invalid:
 return llvm::createStringError("invalid value type");
-  case Value::ValueType::LoadAddress:
-  case Value::ValueType::FileAddress: {
+  case Value::ValueType::FileAddress:
+if (target) {
+  curr_piece_source_value.ConvertToLoadAddress(module_sp.get(),
+   target);
+  addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+} else {
+  return llvm::createStringError(
+  "unable to convert file address 0x%" PRIx64
+  " to load address "
+  "for DW_OP_piece(%" PRIu64 "): "
+  "no target available",
+  addr, piece_byte_size);
+}
+[[fallthrough]];
+  case Value::ValueType::LoadAddress: {
 if (target) {
   if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
 if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),

>From 930bac5a6b36c29fcbf3b602e5fc619b6469dfb5 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Fri, 15 Nov 2024 20:42:58 +0500
Subject: [PATCH 2/3] Add a test

---
 .../Shell/SymbolFile/DWARF/DW_OP_piece-O3.c   | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c

diff --git a/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c 
b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
new file mode 100644
index 00..d31250426dc112
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
@@ -0,0 +1,23 @@
+// Check that optimized with -O3 values that have a file address can be read
+// DWARF info:
+// 0x0023:   DW_TAG_variable
+// DW_AT_name  ("array")
+// DW_AT_type  (0x0032 "char[5]")
+// DW_AT_location  (DW_OP_piece 0x2, DW_OP_addrx 0x0, 
DW_OP_piece 0x1)
+
+// RUN: %clang_host -O3 -gdwarf %s -o %t
+// RUN: %lldb %t \
+// RUN:   -o "b 22" \
+// RUN:   -o "r" \
+// RUN:   -o "p/x array[2]" \
+// RUN:   -b | FileCheck %s
+//
+// CHECK: (lldb) p/x array[2]
+// CHECK: (char) 0x03
+
+static char array[5] = {0, 1, 2, 3, 4};
+
+int main(void) {
+  array[2]++;
+  return 0;
+}
\ No newline at end of file

>From ff7cd83f1d99215803bbc3279f93dd8cb7dd1a77 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Wed, 20 Nov 2024 21:50:35 +0500
Subject: [PATCH 3/3] Move array usage to a separate function to ensure there
 is a breakpoint afterwards

---
 lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c 
b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
index d31250426dc112..77ea81f30395f0 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
@@ -7,7 +7,7 @@
 
 // RUN: %clang_host -O3 -gdwarf %s -o %t
 // RUN: %lldb %t \
-// RUN:   -o "b 22" \
+// RUN:   -o "b 25" \
 // RUN:   -o "r" \
 // RUN:   -o "p/x array[2]" \
 // RUN:   -b | FileCheck %s
@@ -17,7 +17,10 @@
 
 static char array[5] = {0, 1, 2, 3, 4};
 
+void func() __attribute__((noinline));
+void func() { ++array[2]; };
+
 int main(void) {
-  array[2]++;
+  func();
   return 0;
-}
\ No newline at end of file
+}

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


[Lldb-commits] [lldb] Reapply "[lldb] Convert file address to load address when reading memory for DW_OP_piece" (PR #117168)

2024-11-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ilia Kuklin (kuilpd)


Changes

This commit fixes the test in so that the breakpoint is triggered correctly 
after `array` usage on Aarch64.

Reapplies #116411 with a fix.


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


2 Files Affected:

- (modified) lldb/source/Expression/DWARFExpression.cpp (+16-3) 
- (added) lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c (+26) 


``diff
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index f92f25ed342a9c..a7126b25c1cc38 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1853,12 +1853,25 @@ llvm::Expected DWARFExpression::Evaluate(
   const Value::ValueType curr_piece_source_value_type =
   curr_piece_source_value.GetValueType();
   Scalar &scalar = curr_piece_source_value.GetScalar();
-  const lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+  lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
   switch (curr_piece_source_value_type) {
   case Value::ValueType::Invalid:
 return llvm::createStringError("invalid value type");
-  case Value::ValueType::LoadAddress:
-  case Value::ValueType::FileAddress: {
+  case Value::ValueType::FileAddress:
+if (target) {
+  curr_piece_source_value.ConvertToLoadAddress(module_sp.get(),
+   target);
+  addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+} else {
+  return llvm::createStringError(
+  "unable to convert file address 0x%" PRIx64
+  " to load address "
+  "for DW_OP_piece(%" PRIu64 "): "
+  "no target available",
+  addr, piece_byte_size);
+}
+[[fallthrough]];
+  case Value::ValueType::LoadAddress: {
 if (target) {
   if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
 if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),
diff --git a/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c 
b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
new file mode 100644
index 00..77ea81f30395f0
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
@@ -0,0 +1,26 @@
+// Check that optimized with -O3 values that have a file address can be read
+// DWARF info:
+// 0x0023:   DW_TAG_variable
+// DW_AT_name  ("array")
+// DW_AT_type  (0x0032 "char[5]")
+// DW_AT_location  (DW_OP_piece 0x2, DW_OP_addrx 0x0, 
DW_OP_piece 0x1)
+
+// RUN: %clang_host -O3 -gdwarf %s -o %t
+// RUN: %lldb %t \
+// RUN:   -o "b 25" \
+// RUN:   -o "r" \
+// RUN:   -o "p/x array[2]" \
+// RUN:   -b | FileCheck %s
+//
+// CHECK: (lldb) p/x array[2]
+// CHECK: (char) 0x03
+
+static char array[5] = {0, 1, 2, 3, 4};
+
+void func() __attribute__((noinline));
+void func() { ++array[2]; };
+
+int main(void) {
+  func();
+  return 0;
+}

``




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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2024-11-21 Thread via lldb-commits

https://github.com/anjenner updated 
https://github.com/llvm/llvm-project/pull/115331

>From 3fdba46d41ad9668a114766fe892af497f121cd5 Mon Sep 17 00:00:00 2001
From: Andrew Jenner 
Date: Thu, 7 Nov 2024 10:47:42 -0500
Subject: [PATCH 1/2] Modify the localCache API to require an explicit commit
 on CachedFileStream.

CachedFileStream has previously performed the commit step in its destructor,
but this means its only recourse for error handling is report_fatal_error.
Modify this to add an explicit commit() method, and call this in the
appropriate places with appropriate error handling for the location.

Currently the destructor of CacheStream gives an assert failure in Debug builds
if commit() was not called. This will help track down any remaining uses of the
API that assume the old destructior behaviour. In Release builds we fall back
to the previous behaviour and call report_fatal_error if the commit fails.
---
 lldb/source/Core/DataFileCache.cpp  |  5 
 llvm/include/llvm/Support/Caching.h |  1 +
 llvm/lib/Debuginfod/Debuginfod.cpp  |  9 +++
 llvm/lib/LTO/LTOBackend.cpp |  3 +++
 llvm/lib/Support/Caching.cpp| 40 +
 llvm/tools/gold/gold-plugin.cpp |  4 ++-
 llvm/tools/llvm-lto2/llvm-lto2.cpp  |  4 ++-
 7 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/lldb/source/Core/DataFileCache.cpp 
b/lldb/source/Core/DataFileCache.cpp
index ef0e07a8b03420..91092697112317 100644
--- a/lldb/source/Core/DataFileCache.cpp
+++ b/lldb/source/Core/DataFileCache.cpp
@@ -132,6 +132,11 @@ bool DataFileCache::SetCachedData(llvm::StringRef key,
   if (file_or_err) {
 llvm::CachedFileStream *cfs = file_or_err->get();
 cfs->OS->write((const char *)data.data(), data.size());
+if (llvm::Error err = cfs->commit()) {
+  Log *log = GetLog(LLDBLog::Modules);
+  LLDB_LOG_ERROR(log, std::move(err),
+ "failed to commit to the cache for key: {0}");
+}
 return true;
   } else {
 Log *log = GetLog(LLDBLog::Modules);
diff --git a/llvm/include/llvm/Support/Caching.h 
b/llvm/include/llvm/Support/Caching.h
index cf45145619d95b..120bcd9da02ede 100644
--- a/llvm/include/llvm/Support/Caching.h
+++ b/llvm/include/llvm/Support/Caching.h
@@ -30,6 +30,7 @@ class CachedFileStream {
   CachedFileStream(std::unique_ptr OS,
std::string OSPath = "")
   : OS(std::move(OS)), ObjectPathName(OSPath) {}
+  virtual Error commit() { return Error::success(); }
   std::unique_ptr OS;
   std::string ObjectPathName;
   virtual ~CachedFileStream() = default;
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp 
b/llvm/lib/Debuginfod/Debuginfod.cpp
index 4c785117ae8ef7..6ff889d3a8cad2 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -188,6 +188,7 @@ class StreamedHTTPResponseHandler : public 
HTTPResponseHandler {
 public:
   StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client)
   : CreateStream(CreateStream), Client(Client) {}
+  Error commit();
   virtual ~StreamedHTTPResponseHandler() = default;
 
   Error handleBodyChunk(StringRef BodyChunk) override;
@@ -210,6 +211,12 @@ Error 
StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) {
   return Error::success();
 }
 
+Error StreamedHTTPResponseHandler::commit() {
+  if (FileStream)
+return FileStream->commit();
+  return Error::success();
+}
+
 // An over-accepting simplification of the HTTP RFC 7230 spec.
 static bool isHeader(StringRef S) {
   StringRef Name;
@@ -298,6 +305,8 @@ Expected getCachedOrDownloadArtifact(
   Error Err = Client.perform(Request, Handler);
   if (Err)
 return std::move(Err);
+  if (Err = Handler.commit())
+return std::move(Err);
 
   unsigned Code = Client.responseCode();
   if (Code && Code != 200)
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index bdf4ff8960bc82..4bfa8751a43643 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -434,6 +434,9 @@ static void codegen(const Config &Conf, TargetMachine *TM,
 
   if (DwoOut)
 DwoOut->keep();
+
+  if (Error Err = Stream->commit())
+report_fatal_error(std::move(Err));
 }
 
 static void splitCodeGen(const Config &C, TargetMachine *TM,
diff --git a/llvm/lib/Support/Caching.cpp b/llvm/lib/Support/Caching.cpp
index 66e540efaca972..2ecdf53701030d 100644
--- a/llvm/lib/Support/Caching.cpp
+++ b/llvm/lib/Support/Caching.cpp
@@ -80,6 +80,7 @@ Expected llvm::localCache(const Twine 
&CacheNameRef,
   sys::fs::TempFile TempFile;
   std::string ModuleName;
   unsigned Task;
+  bool Committed = false;
 
   CacheStream(std::unique_ptr OS, AddBufferFn AddBuffer,
   sys::fs::TempFile TempFile, std::string EntryPath,
@@ -88,9 +89,10 @@ Expected llvm::localCache(const Twine 
&CacheNameRef,
 AddBuffer(std::move(AddBuffer)), TempFile(std::move(TempFile)),
  

[Lldb-commits] [lldb] 4b5a8d6 - [lldb] Make sure completions don't end with newlines (#117054)

2024-11-21 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-11-21T08:00:32-08:00
New Revision: 4b5a8d6835897477873242ef1ee529d00dedd9a1

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

LOG: [lldb] Make sure completions don't end with newlines (#117054)

The logic that prints completions and their descriptions assumes neither
the completion itself nor the description ends with a newline. I
considered making this an assert, but decided against it as completions
can indirectly come from user input (e.g. oddly crafted names). Instead,
avoid the potential for mistakes by defensively stripping them.

Added: 


Modified: 
lldb/include/lldb/Utility/CompletionRequest.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/CompletionRequest.h 
b/lldb/include/lldb/Utility/CompletionRequest.h
index 650158a197dbd9..865d6db5762984 100644
--- a/lldb/include/lldb/Utility/CompletionRequest.h
+++ b/lldb/include/lldb/Utility/CompletionRequest.h
@@ -52,8 +52,8 @@ class CompletionResult {
   public:
 Completion(llvm::StringRef completion, llvm::StringRef description,
CompletionMode mode)
-: m_completion(completion.str()), m_descripton(description.str()),
-  m_mode(mode) {}
+: m_completion(completion.rtrim().str()),
+  m_descripton(description.rtrim().str()), m_mode(mode) {}
 const std::string &GetCompletion() const { return m_completion; }
 const std::string &GetDescription() const { return m_descripton; }
 CompletionMode GetMode() const { return m_mode; }



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


[Lldb-commits] [lldb] [lldb] Make sure completions don't end with newlines (PR #117054)

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

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread James Henderson via lldb-commits

https://github.com/jh7370 commented:

I think these need to be split into individual PRs, as each will want reviewing 
on its own merits, and potentially they might indicate missing test coverage, 
warranting a test.

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread via lldb-commits

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

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

https://github.com/aaupov commented:

BOLT changes look good, thank you for fixing those. If you split them out, I 
can help land it sooner.

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread via lldb-commits

https://github.com/ChuvakHome updated 
https://github.com/llvm/llvm-project/pull/117151

>From 882bcbafafe9b52014beaf44ffea206d2e03cc97 Mon Sep 17 00:00:00 2001
From: timurdemenev <311...@niuitmo.ru>
Date: Thu, 21 Nov 2024 15:33:04 +0300
Subject: [PATCH] Fix bug with parenthesis, wrong names, invalid pointer
 checking, wrong logical-or operator

---
 bolt/lib/Rewrite/LinuxKernelRewriter.cpp| 2 +-
 libc/fuzzing/math/Compare.h | 2 +-
 .../ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp| 2 +-
 lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp  | 2 +-
 mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp| 2 +-
 mlir/lib/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.cpp | 2 +-
 polly/lib/External/isl/isl_local_space.c| 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp 
b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
index 03b414b71caca7..39ceeffc79c165 100644
--- a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
+++ b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
@@ -580,7 +580,7 @@ Error LinuxKernelRewriter::readORCTables() {
   // As such, we can ignore alternative ORC entries. They will be preserved
   // in the binary, but will not get printed in the instruction stream.
   Inst = BF->getInstructionContainingOffset(Offset);
-  if (Inst || BC.MIB->hasAnnotation(*Inst, "AltInst"))
+  if (Inst && BC.MIB->hasAnnotation(*Inst, "AltInst"))
 continue;
 
   return createStringError(
diff --git a/libc/fuzzing/math/Compare.h b/libc/fuzzing/math/Compare.h
index 2b84ad3ab46213..8f06ed9c8cc102 100644
--- a/libc/fuzzing/math/Compare.h
+++ b/libc/fuzzing/math/Compare.h
@@ -20,7 +20,7 @@ ValuesEqual(T x1, T x2) {
   LIBC_NAMESPACE::fputil::FPBits bits2(x2);
   // If either is NaN, we want both to be NaN.
   if (bits1.is_nan() || bits2.is_nan())
-return bits2.is_nan() && bits2.is_nan();
+return bits1.is_nan() && bits2.is_nan();
 
   // For all other values, we want the values to be bitwise equal.
   return bits1.uintval() == bits2.uintval();
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 0083b499656979..c43871b08191db 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -3278,7 +3278,7 @@ bool 
AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
   }
 
   // If the index is still out of range then this isn't a pointer.
-  if (index > m_indexed_isa_cache.size())
+  if (index >= m_indexed_isa_cache.size())
 return false;
 
   LLDB_LOGF(log, "AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64 ")",
diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
index 8c69989702c2aa..f7a2d1d07142ec 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
@@ -150,7 +150,7 @@ GeneratePerfEventConfigValue(bool enable_tsc,
   if (enable_tsc) {
 if (Expected offset = ReadIntelPTConfigFile(
 kTSCBitOffsetFile, IntelPTConfigFileType::BitOffset))
-  config |= 1 << *offset;
+  config |= 1ULL << *offset;
 else
   return offset.takeError();
   }
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp 
b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 26d9d2b091750c..8973e87c063b33 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -523,7 +523,7 @@ class RegionBuilderHelper {
 isInteger(arg0) && arg0.getType().getIntOrFloatBitWidth() == 1;
 bool tailFloatingPoint =
 isFloatingPoint(arg0) && isFloatingPoint(arg1) && 
isFloatingPoint(arg2);
-bool tailInteger = isInteger(arg0) && isInteger(arg1) && isInteger(arg1);
+bool tailInteger = isInteger(arg0) && isInteger(arg1) && isInteger(arg2);
 OpBuilder::InsertionGuard g(builder);
 builder.setInsertionPointToEnd(&block);
 switch (ternaryFn) {
diff --git a/mlir/lib/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.cpp 
b/mlir/lib/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.cpp
index 4a826f04e1f1d2..88f02369cb7ab1 100644
--- a/mlir/lib/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.cpp
+++ b/mlir/lib/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.cpp
@@ -107,7 +107,7 @@ ScalableValueBoundsConstraintSet::computeScalableBound(
 
   AffineMap bound = [&] {
 if (boundType == BoundType::EQ && !invalidBound(lowerBound) &&
-lowerBound[0] == lowerBound[0]) {
+lowerBound[0] == upperBound[0]) {
   return lowerBound[0];
 } else if (boundType == BoundType::LB && !invalidBound(lowerBo

[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

2024-11-21 Thread Augusto Noronha via lldb-commits


@@ -2790,7 +2759,7 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   // With -gsimple-template-names, a templated type's DW_AT_name will not
   // contain the template parameters. Try again stripping '<' and anything
   // after, filtering out entries with template parameters that don't match.
-  if (!have_index_match) {
+  if (!have_index_match && !query.GetSearchByMangledName()) {

augusto2112 wrote:

Actually, never mind, if no type is found `have_index_match` will be false even 
when searching by mangled name, so this condition is necessary.

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread Simon Pilgrim via lldb-commits

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

Thanks for the cleanups! Please can you close this and submit separate PRs for 
independent review

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-mlir-linalg

@llvm/pr-subscribers-backend-x86

Author: Chuvak (ChuvakHome)


Changes

Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

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


11 Files Affected:

- (modified) bolt/lib/Passes/ShrinkWrapping.cpp (+2-2) 
- (modified) bolt/lib/Rewrite/LinuxKernelRewriter.cpp (+1-1) 
- (modified) libc/fuzzing/math/Compare.h (+1-1) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (+1-1) 
- (modified) lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
(+1-1) 
- (modified) llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def (+1) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp (+3) 
- (modified) llvm/test/MC/ELF/relocation.s (+35-32) 
- (modified) mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Vector/IR/ScalableValueBoundsConstraintSet.cpp 
(+1-1) 
- (modified) polly/lib/External/isl/isl_local_space.c (+1-1) 


``diff
diff --git a/bolt/lib/Passes/ShrinkWrapping.cpp 
b/bolt/lib/Passes/ShrinkWrapping.cpp
index 176321c58dc903..bc4e7e6e386a0e 100644
--- a/bolt/lib/Passes/ShrinkWrapping.cpp
+++ b/bolt/lib/Passes/ShrinkWrapping.cpp
@@ -78,8 +78,8 @@ void CalleeSavedAnalysis::analyzeSaves() {
 // probably dealing with a parameter passed in a stack -- do not mess
 // with it
 if (SRU.isStoreUsed(*FIE,
-Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB)),
-/*IncludeLocalAccesses=*/false) {
+Prev ? SRU.expr_begin(*Prev) : SRU.expr_begin(BB),
+/*IncludeLocalAccesses=*/false)) {
   BlacklistedRegs.set(FIE->RegOrImm);
   CalleeSaved.reset(FIE->RegOrImm);
   Prev = &Inst;
diff --git a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp 
b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
index 03b414b71caca7..39ceeffc79c165 100644
--- a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
+++ b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
@@ -580,7 +580,7 @@ Error LinuxKernelRewriter::readORCTables() {
   // As such, we can ignore alternative ORC entries. They will be preserved
   // in the binary, but will not get printed in the instruction stream.
   Inst = BF->getInstructionContainingOffset(Offset);
-  if (Inst || BC.MIB->hasAnnotation(*Inst, "AltInst"))
+  if (Inst && BC.MIB->hasAnnotation(*Inst, "AltInst"))
 continue;
 
   return createStringError(
diff --git a/libc/fuzzing/math/Compare.h b/libc/fuzzing/math/Compare.h
index 2b84ad3ab46213..8f06ed9c8cc102 100644
--- a/libc/fuzzing/math/Compare.h
+++ b/libc/fuzzing/math/Compare.h
@@ -20,7 +20,7 @@ ValuesEqual(T x1, T x2) {
   LIBC_NAMESPACE::fputil::FPBits bits2(x2);
   // If either is NaN, we want both to be NaN.
   if (bits1.is_nan() || bits2.is_nan())
-return bits2.is_nan() && bits2.is_nan();
+return bits1.is_nan() && bits2.is_nan();
 
   // For all other values, we want the values to be bitwise equal.
   return bits1.uintval() == bits2.uintval();
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 0083b499656979..c43871b08191db 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -3278,7 +3278,7 @@ bool 
AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
   }
 
   // If the index is still out of range then this isn't a pointer.
-  if (index > m_indexed_isa_cache.size())
+  if (index >= m_indexed_isa_cache.size())
 return false;
 
   LLDB_LOGF(log, "AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64 ")",
diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
index 8c69989702c2aa..f7a2d1d07142ec 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
@@ -150,7 +150,7 @@ GeneratePerfEventConfigValue(bool enable_tsc,
   if (enable_tsc) {
 if (Expected offset = ReadIntelPTConfigFile(
 kTSCBitOffsetFile, IntelPTConfigFileType::BitOffset))
-  config |= 1 << *offset;
+  config |= 1ULL << *offset;
 else
   return offset.takeError();
   }
diff --git a/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def 
b/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
index 43473d47e32819..94b1ad9c1f9464 100644
--- a/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
+++ b/llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
@@ -44,3 +44,4 @@ ELF_RELOC(R_X86_64_IRELATIVE,   37)
 ELF_RELOC(R_X86_64_GOTPCRELX,   41)
 ELF_RELOC(R_X86_64_REX_GOTPCRELX,42)
 ELF_RELOC(R_X86_6

[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

2024-11-21 Thread Augusto Noronha via lldb-commits


@@ -2726,39 +2726,8 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   TypeQuery query_full(query);
   bool have_index_match = false;
   m_index->GetTypesWithQuery(query_full, [&](DWARFDIE die) {
-// Check the language, but only if we have a language filter.
-if (query.HasLanguage()) {
-  if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU(
-return true; // Keep iterating over index types, language mismatch.
-}
-
-// Since mangled names are unique, we only need to check if the names are
-// the same.
-if (query.GetSearchByMangledName()) {
-  if (die.GetMangledName(/*substitute_name_allowed=*/false) !=
-  query.GetTypeBasename().GetStringRef())
-return true; // Keep iterating over index types, mangled name mismatch.
-  if (Type *matching_type = ResolveType(die, true, true)) {
-results.InsertUnique(matching_type->shared_from_this());
-return !results.Done(query); // Keep iterating if we aren't done.
-  }
-  return true; // Keep iterating over index types, weren't able to resolve
-   // this type
-}
-
-// Check the context matches
-std::vector die_context;
-if (query.GetModuleSearch())
-  die_context = die.GetDeclContext();
-else
-  die_context = die.GetTypeLookupContext();
-assert(!die_context.empty());

augusto2112 wrote:

Ok, sounds good.

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


[Lldb-commits] [lldb] 915d588 - Reapply "[lldb] Convert file address to load address when reading memory for DW_OP_piece" (#117168)

2024-11-21 Thread via lldb-commits

Author: Ilia Kuklin
Date: 2024-11-21T21:33:01+05:00
New Revision: 915d588b1a4762685b788020beadcd7aad5f50a0

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

LOG: Reapply "[lldb] Convert file address to load address when reading memory 
for DW_OP_piece" (#117168)

This commit fixes the test so that the breakpoint is triggered correctly
after `array` usage on AArch64.

Reapplies #116411 with a fix.

Added: 
lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c

Modified: 
lldb/source/Expression/DWARFExpression.cpp

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index f92f25ed342a9c..a7126b25c1cc38 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1853,12 +1853,25 @@ llvm::Expected DWARFExpression::Evaluate(
   const Value::ValueType curr_piece_source_value_type =
   curr_piece_source_value.GetValueType();
   Scalar &scalar = curr_piece_source_value.GetScalar();
-  const lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+  lldb::addr_t addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
   switch (curr_piece_source_value_type) {
   case Value::ValueType::Invalid:
 return llvm::createStringError("invalid value type");
-  case Value::ValueType::LoadAddress:
-  case Value::ValueType::FileAddress: {
+  case Value::ValueType::FileAddress:
+if (target) {
+  curr_piece_source_value.ConvertToLoadAddress(module_sp.get(),
+   target);
+  addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+} else {
+  return llvm::createStringError(
+  "unable to convert file address 0x%" PRIx64
+  " to load address "
+  "for DW_OP_piece(%" PRIu64 "): "
+  "no target available",
+  addr, piece_byte_size);
+}
+[[fallthrough]];
+  case Value::ValueType::LoadAddress: {
 if (target) {
   if (curr_piece.ResizeData(piece_byte_size) == piece_byte_size) {
 if (target->ReadMemory(addr, curr_piece.GetBuffer().GetBytes(),

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c 
b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
new file mode 100644
index 00..77ea81f30395f0
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
@@ -0,0 +1,26 @@
+// Check that optimized with -O3 values that have a file address can be read
+// DWARF info:
+// 0x0023:   DW_TAG_variable
+// DW_AT_name  ("array")
+// DW_AT_type  (0x0032 "char[5]")
+// DW_AT_location  (DW_OP_piece 0x2, DW_OP_addrx 0x0, 
DW_OP_piece 0x1)
+
+// RUN: %clang_host -O3 -gdwarf %s -o %t
+// RUN: %lldb %t \
+// RUN:   -o "b 25" \
+// RUN:   -o "r" \
+// RUN:   -o "p/x array[2]" \
+// RUN:   -b | FileCheck %s
+//
+// CHECK: (lldb) p/x array[2]
+// CHECK: (char) 0x03
+
+static char array[5] = {0, 1, 2, 3, 4};
+
+void func() __attribute__((noinline));
+void func() { ++array[2]; };
+
+int main(void) {
+  func();
+  return 0;
+}



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


[Lldb-commits] [lldb] Reapply "[lldb] Convert file address to load address when reading memory for DW_OP_piece" (PR #117168)

2024-11-21 Thread Ilia Kuklin via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

Prior to this patch, the function returned an exit status, sometimes a 
ValueObject with an error and a Status object. This patch removes the Status 
object and ensures the error is consistently returned as the error of the 
ValueObject.

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


12 Files Affected:

- (modified) lldb/include/lldb/Expression/UserExpression.h (+4-6) 
- (modified) lldb/source/Expression/REPL.cpp (+2-5) 
- (modified) lldb/source/Expression/UserExpression.cpp (+26-31) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp 
(+3-3) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
 (+3-3) 
- (modified) 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp (+3-3) 
- (modified) lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp 
(+3-3) 
- (modified) lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (+4-5) 
- (modified) lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp (+3-4) 
- (modified) lldb/source/Target/StopInfo.cpp (+5-3) 
- (modified) lldb/source/Target/Target.cpp (+3-8) 
- (modified) lldb/test/API/commands/expression/fixits/TestFixIts.py (+1-1) 


``diff
diff --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 7ce463d2cb4e7e..2fde73dafa035d 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -240,11 +240,9 @@ class UserExpression : public Expression {
   /// definitions to be included when the expression is parsed.
   ///
   /// \param[in,out] result_valobj_sp
-  ///  If execution is successful, the result valobj is placed here.
-  ///
-  /// \param[out] error
-  /// Filled in with an error in case the expression evaluation
-  /// fails to parse, run, or evaluated.
+  ///  If execution is successful, the result valobj is placed
+  ///  here. Otherwise its Error will contain an ExpressionError
+  ///  with details about the failure mode.
   ///
   /// \param[out] fixed_expression
   /// If non-nullptr, the fixed expression is copied into the provided
@@ -266,7 +264,7 @@ class UserExpression : public Expression {
   static lldb::ExpressionResults
   Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
llvm::StringRef expr_cstr, llvm::StringRef expr_prefix,
-   lldb::ValueObjectSP &result_valobj_sp, Status &error,
+   lldb::ValueObjectSP &result_valobj_sp,
std::string *fixed_expression = nullptr,
ValueObject *ctx_obj = nullptr);
 
diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index 56c50e346b39b8..4b53537e50e62a 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -339,12 +339,9 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, 
std::string &code) {
 
   const char *expr_prefix = nullptr;
   lldb::ValueObjectSP result_valobj_sp;
+  lldb::ExpressionResults execution_results = UserExpression::Evaluate(
+  exe_ctx, expr_options, code.c_str(), expr_prefix, result_valobj_sp);
   Status error;
-  lldb::ExpressionResults execution_results =
-  UserExpression::Evaluate(exe_ctx, expr_options, code.c_str(),
-   expr_prefix, result_valobj_sp, error,
-   nullptr); // fixed expression
-
   if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
   execution_results,
   result_valobj_sp, error)) {
diff --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index ed3734cbb943f6..c21bcbd9cfa060 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -144,9 +144,13 @@ lldb::ExpressionResults
 UserExpression::Evaluate(ExecutionContext &exe_ctx,
  const EvaluateExpressionOptions &options,
  llvm::StringRef expr, llvm::StringRef prefix,
- lldb::ValueObjectSP &result_valobj_sp, Status &error,
+ lldb::ValueObjectSP &result_valobj_sp,
  std::string *fixed_expression, ValueObject *ctx_obj) {
   Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
+  auto set_error = [&](Status error) {
+result_valobj_sp = ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), std::move(error));
+  };
 
   if (ctx_obj) {
 static unsigned const ctx_type_mask = lldb::TypeFlags::eTypeIsClass |
@@ -155,8 +159,7 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 if (!(ctx_obj->GetTypeInfo() & ctx_type_mask)) {
   LLDB_LOG(l

[Lldb-commits] [lldb] Reapply "[lldb] Convert file address to load address when reading memory for DW_OP_piece" (PR #117168)

2024-11-21 Thread Ilia Kuklin via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix index boundaries check, Change wrong int literal (PR #117226)

2024-11-21 Thread via lldb-commits


@@ -3278,7 +3278,7 @@ bool 
AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
   }
 
   // If the index is still out of range then this isn't a pointer.
-  if (index > m_indexed_isa_cache.size())
+  if (index >= m_indexed_isa_cache.size())

ChuvakHome wrote:

That sounds correct. Let me think a bit about your words

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread Adrian Prantl via lldb-commits


@@ -339,12 +339,9 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, 
std::string &code) {
 
   const char *expr_prefix = nullptr;
   lldb::ValueObjectSP result_valobj_sp;
+  lldb::ExpressionResults execution_results = UserExpression::Evaluate(
+  exe_ctx, expr_options, code.c_str(), expr_prefix, result_valobj_sp);
   Status error;

adrian-prantl wrote:

It's used on the very next line.

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


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

2024-11-21 Thread via lldb-commits

Author: Jacob Lalonde
Date: 2024-11-21T14:47:08-08:00
New Revision: 0a7242959f5d3f9ccf7b149009b9eebd45b785b0

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

LOG: [LLDB][ProcessELFCore] Add Description to ProcessELFCore/ELFThread stop 
reasons (#110065)

This fixes a functionality gap with GDB, where GDB will properly decode
the stop reason and give the address for SIGSEGV. I also added
descriptions to all stop reasons, following the same code path that the
Native Linux Thread uses.

Added: 


Modified: 
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
lldb/source/Plugins/Process/elf-core/ThreadElfCore.h

lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py

lldb/test/API/linux/aarch64/non_address_bit_memory_access/TestAArch64LinuxNonAddressBitMemoryAccess.py
lldb/test/Shell/Register/Core/x86-32-linux-multithread.test
lldb/test/Shell/Register/Core/x86-64-linux-multithread.test

Removed: 




diff  --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index cd95b000469dc5..a5ee3cfdb2932a 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -232,7 +232,7 @@ Status ProcessElfCore::DoLoadCore() {
   bool prstatus_signal_found = false;
   // Check we found a signal in a SIGINFO note.
   for (const auto &thread_data : m_thread_data) {
-if (thread_data.signo != 0)
+if (thread_data.siginfo.si_signo != 0)
   siginfo_signal_found = true;
 if (thread_data.prstatus_sig != 0)
   prstatus_signal_found = true;
@@ -242,10 +242,10 @@ Status ProcessElfCore::DoLoadCore() {
 // PRSTATUS note.
 if (prstatus_signal_found) {
   for (auto &thread_data : m_thread_data)
-thread_data.signo = thread_data.prstatus_sig;
+thread_data.siginfo.si_signo = thread_data.prstatus_sig;
 } else if (m_thread_data.size() > 0) {
   // If all else fails force the first thread to be SIGSTOP
-  m_thread_data.begin()->signo =
+  m_thread_data.begin()->siginfo.si_signo =
   GetUnixSignals()->GetSignalNumberFromName("SIGSTOP");
 }
   }
@@ -498,7 +498,7 @@ static void ParseFreeBSDPrStatus(ThreadData &thread_data,
   else
 offset += 16;
 
-  thread_data.signo = data.GetU32(&offset); // pr_cursig
+  thread_data.siginfo.si_signo = data.GetU32(&offset); // pr_cursig
   thread_data.tid = data.GetU32(&offset);   // pr_pid
   if (lp64)
 offset += 4;
@@ -581,7 +581,7 @@ static void ParseOpenBSDProcInfo(ThreadData &thread_data,
 return;
 
   offset += 4;
-  thread_data.signo = data.GetU32(&offset);
+  thread_data.siginfo.si_signo = data.GetU32(&offset);
 }
 
 llvm::Expected>
@@ -819,7 +819,7 @@ llvm::Error 
ProcessElfCore::parseNetBSDNotes(llvm::ArrayRef notes) {
   // Signal targeted at the whole process.
   if (siglwp == 0) {
 for (auto &data : m_thread_data)
-  data.signo = signo;
+  data.siginfo.si_signo = signo;
   }
   // Signal destined for a particular LWP.
   else {
@@ -827,7 +827,7 @@ llvm::Error 
ProcessElfCore::parseNetBSDNotes(llvm::ArrayRef notes) {
 
 for (auto &data : m_thread_data) {
   if (data.tid == siglwp) {
-data.signo = signo;
+data.siginfo.si_signo = signo;
 passed = true;
 break;
   }
@@ -930,12 +930,12 @@ llvm::Error 
ProcessElfCore::parseLinuxNotes(llvm::ArrayRef notes) {
   break;
 }
 case ELF::NT_SIGINFO: {
+  const lldb_private::UnixSignals &unix_signals = *GetUnixSignals();
   ELFLinuxSigInfo siginfo;
-  Status status = siginfo.Parse(note.data, arch);
+  Status status = siginfo.Parse(note.data, arch, unix_signals);
   if (status.Fail())
 return status.ToError();
-  thread_data.signo = siginfo.si_signo;
-  thread_data.code = siginfo.si_code;
+  thread_data.siginfo = siginfo;
   break;
 }
 case ELF::NT_FILE: {

diff  --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index f2838087298efb..c810eb9ed61d26 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -9,6 +9,7 @@
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Target/UnixSignals.h"
 #include "lldb/Target/Unwind.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -49,9 +50,9 @@ using namespace lldb_private;
 
 // Construct a Thread object with given data
 ThreadElfCore::ThreadElfCore(Process &process, const ThreadData &td)
-: Thread

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

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

https://github.com/Jlalond closed 
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] [llvm] [DWARF] Fix DWARTTypePrinter unable to print qualified name for DW_TAG_typedef DIE (PR #117239)

2024-11-21 Thread Zequan Wu via lldb-commits

ZequanWu wrote:

Just noticed that this breaks 
`llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/odr-string.test` because for 
`DW_TAG_typedef`, llvm-dwarfdump will print the fully qualified name instead of 
the base name in DW_AT_type that refers to it. Do you think we should keep the 
original bahavior by using the base name of typedef? Or update the test to 
accept fully qualified name?


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


[Lldb-commits] [lldb] Convert the StackFrameList mutex to a shared mutex. (PR #117252)

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

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


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


[Lldb-commits] [lldb] [lldb] Fix ELF core debugging (PR #117070)

2024-11-21 Thread Kazuki Sakamoto via lldb-commits

https://github.com/splhack updated 
https://github.com/llvm/llvm-project/pull/117070

>From b93478345fbaa747b44d678207b768948db0a7d6 Mon Sep 17 00:00:00 2001
From: Kazuki Sakamoto 
Date: Wed, 20 Nov 2024 13:49:26 -0800
Subject: [PATCH] [lldb] Fix ELF core debugging

DynamicLoader does not use ProcessElfCore NT_FILE entries to get
UUID. Use GetModuleSpec to get UUID from Process.
---
 lldb/source/Core/DynamicLoader.cpp   |  6 ++
 .../Plugins/Process/elf-core/ProcessElfCore.cpp  | 16 
 .../Plugins/Process/elf-core/ProcessElfCore.h|  4 
 3 files changed, 26 insertions(+)

diff --git a/lldb/source/Core/DynamicLoader.cpp 
b/lldb/source/Core/DynamicLoader.cpp
index 68d6ab0850853f..3c6c6bd365706e 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -157,6 +157,12 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP 
module) const {
 ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) {
   Target &target = m_process->GetTarget();
   ModuleSpec module_spec(file, target.GetArchitecture());
+  ModuleSpec module_spec_from_process;
+  // Process may be able to augment the module_spec with UUID, e.g. ELF core.
+  if (m_process->GetModuleSpec(file, target.GetArchitecture(),
+   module_spec_from_process)) {
+module_spec = module_spec_from_process;
+  }
 
   if (ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec))
 return module_sp;
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index a5ee3cfdb2932a..e4284905c07240 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -286,6 +286,22 @@ void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
   }
 }
 
+bool ProcessElfCore::GetModuleSpec(const FileSpec &module_file_spec,
+   const ArchSpec &arch,
+   ModuleSpec &module_spec) {
+  module_spec.Clear();
+  for (NT_FILE_Entry &entry : m_nt_file_entries) {
+if (module_file_spec.GetPath() == entry.path) {
+  module_spec.GetFileSpec() = module_file_spec;
+  module_spec.GetArchitecture() = arch;
+  module_spec.GetUUID().SetFromStringRef(entry.uuid.GetAsString());
+  return true;
+}
+  }
+
+  return false;
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index 280c61ed376396..a7b1822ccf01ff 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -163,6 +163,10 @@ class ProcessElfCore : public 
lldb_private::PostMortemProcess {
   // Populate gnu uuid for each NT_FILE entry
   void UpdateBuildIdForNTFileEntries();
 
+  bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
+ const lldb_private::ArchSpec &arch,
+ lldb_private::ModuleSpec &module_spec) override;
+
   // Returns the value of certain type of note of a given start address
   lldb_private::UUID FindBuidIdInCoreMemory(lldb::addr_t address);
 

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

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


@@ -144,9 +144,13 @@ lldb::ExpressionResults
 UserExpression::Evaluate(ExecutionContext &exe_ctx,
  const EvaluateExpressionOptions &options,
  llvm::StringRef expr, llvm::StringRef prefix,
- lldb::ValueObjectSP &result_valobj_sp, Status &error,
+ lldb::ValueObjectSP &result_valobj_sp,
  std::string *fixed_expression, ValueObject *ctx_obj) {
   Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
+  auto set_error = [&](Status error) {

JDevlieghere wrote:

In the interest of getting rid of Status, should this take an `llvm::Error`? 

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

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

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

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

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


[Lldb-commits] [lldb] a3e2f0a - [lldb] Fix a regression in Status::GetErrorType() (#117095)

2024-11-21 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-11-21T11:11:25-08:00
New Revision: a3e2f0acdf5ee452c8eb177b56f476b432539e08

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

LOG: [lldb] Fix a regression in Status::GetErrorType()  (#117095)

The refactored code did not correctly determine the type of expression
errors.

rdar://139699028

Added: 


Modified: 
lldb/source/Utility/Status.cpp
lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py

Removed: 




diff  --git a/lldb/source/Utility/Status.cpp b/lldb/source/Utility/Status.cpp
index 1d171c6b6c3746..5757935fb86228 100644
--- a/lldb/source/Utility/Status.cpp
+++ b/lldb/source/Utility/Status.cpp
@@ -258,7 +258,11 @@ ErrorType Status::GetType() const {
 // Return the first only.
 if (result != eErrorTypeInvalid)
   return;
-result = ErrorCodeToErrorType(error.convertToErrorCode());
+if (error.isA())
+  result = static_cast(error).GetErrorType();
+else
+  result = ErrorCodeToErrorType(error.convertToErrorCode());
+
   });
   return result;
 }

diff  --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index fac562edf9ece0..b9b5bffb87e817 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -184,6 +184,18 @@ def test_source_locations_from_objc_modules(self):
 # the first argument are probably stable enough that this test can 
check for them.
 self.assertIn("void NSLog(NSString *format", 
value.GetError().GetCString())
 
+def test_error_type(self):
+"""Test the error reporting in the API"""
+self.build()
+
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "// Break here", self.main_source_spec
+)
+frame = thread.GetFrameAtIndex(0)
+value = frame.EvaluateExpression('#error("I am error.")')
+error = value.GetError()
+self.assertEqual(error.GetType(), lldb.eErrorTypeExpression)
+
 def test_command_expr_sbdata(self):
 """Test the structured diagnostics data"""
 self.build()



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


[Lldb-commits] [lldb] [lldb] Fix a regression in Status::GetErrorType() (PR #117095)

2024-11-21 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via lldb-commits

bwendling wrote:

> I think this might honestly be fine the way it is now

Yeah. It's going kind of the opposite way from what you suggested with the 
placeholder, just instead of allowing for different uses at various places in 
Sema we disallow without using the placeholder.

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


[Lldb-commits] [clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via lldb-commits


@@ -14690,6 +14690,14 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) {
 }
   }
 
+  // The result of __builtin_counted_by_ref cannot be assigned to a variable.
+  // It allows leaking and modification of bounds safety information.
+  if (const auto *CE = dyn_cast_if_present(VD->getInit());
+  CE && CE->getBuiltinCallee() == Builtin::BI__builtin_counted_by_ref)

bwendling wrote:

Done.

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


[Lldb-commits] [clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via lldb-commits

https://github.com/bwendling updated 
https://github.com/llvm/llvm-project/pull/116719

>From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Fri, 15 Nov 2024 15:41:48 -0800
Subject: [PATCH 1/8] [Clang] Improve Sema diagnostic performance for
 __builtin_counted_by_ref

Implement the sema checks with a placeholder. We then check for that
placeholder in all of the places we care to emit a diagnostic.
---
 clang/include/clang/AST/ASTContext.h  |   1 +
 clang/include/clang/AST/BuiltinTypes.def  |   3 +
 .../clang/Basic/DiagnosticSemaKinds.td|   2 +-
 .../include/clang/Serialization/ASTBitCodes.h |   5 +-
 clang/lib/AST/ASTContext.cpp  |   4 +
 clang/lib/AST/NSAPI.cpp   |   1 +
 clang/lib/AST/Type.cpp|   3 +
 clang/lib/AST/TypeLoc.cpp |   1 +
 clang/lib/Sema/SemaChecking.cpp   |   1 +
 clang/lib/Sema/SemaDecl.cpp   |  11 ++
 clang/lib/Sema/SemaExpr.cpp   | 138 +-
 clang/lib/Sema/SemaStmt.cpp   |  10 ++
 clang/lib/Serialization/ASTCommon.cpp |   3 +
 clang/lib/Serialization/ASTReader.cpp |   3 +
 clang/test/Modules/no-external-type-id.cppm   |   2 +-
 clang/test/Sema/builtin-counted-by-ref.c  |  77 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   2 +
 17 files changed, 154 insertions(+), 113 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 89fcb6789d880a..39cad95d911a33 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1184,6 +1184,7 @@ class ASTContext : public RefCountedBase {
   CanQualType DependentTy, OverloadTy, BoundMemberTy, UnresolvedTemplateTy,
   UnknownAnyTy;
   CanQualType BuiltinFnTy;
+  CanQualType BuiltinCountedByRefTy;
   CanQualType PseudoObjectTy, ARCUnbridgedCastTy;
   CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy;
   CanQualType ObjCBuiltinBoolTy;
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index 444be4311a7431..4eae6962a46de6 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -314,6 +314,9 @@ PLACEHOLDER_TYPE(UnknownAny, UnknownAnyTy)
 
 PLACEHOLDER_TYPE(BuiltinFn, BuiltinFnTy)
 
+// A placeholder type for __builtin_counted_by_ref.
+PLACEHOLDER_TYPE(BuiltinCountedByRef, BuiltinCountedByRefTy)
+
 // The type of a cast which, in ARC, would normally require a
 // __bridge, but which might be okay depending on the immediate
 // context.
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..37fb44d4bf74cd 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6673,7 +6673,7 @@ def err_builtin_counted_by_ref_must_be_flex_array_member 
: Error<
 def err_builtin_counted_by_ref_cannot_leak_reference : Error<
   "value returned by '__builtin_counted_by_ref' cannot be assigned to a "
   "variable, have its address taken, or passed into or returned from a 
function">;
-def err_builtin_counted_by_ref_invalid_lhs_use : Error<
+def err_builtin_counted_by_ref_invalid_use : Error<
   "value returned by '__builtin_counted_by_ref' cannot be used in "
   "%select{an array subscript|a binary}0 expression">;
 def err_builtin_counted_by_ref_has_side_effects : Error<
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index fd834c14ce790f..f4b71861968e77 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -,6 +,9 @@ enum PredefinedTypeIDs {
   /// \brief The '__ibm128' type
   PREDEF_TYPE_IBM128_ID = 74,
 
+  /// \brief The placeholder type for __builtin_counted_by_ref.
+  PREDEF_TYPE_BUILTIN_COUNTED_BY_REF = 75,
+
 /// OpenCL image types with auto numeration
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   
\
   PREDEF_TYPE_##Id##_ID,
@@ -1148,7 +1151,7 @@ enum PredefinedTypeIDs {
 ///
 /// Type IDs for non-predefined types will start at
 /// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 513;
+const unsigned NUM_PREDEF_TYPE_IDS = 514;
 
 // Ensure we do not overrun the predefined types we reserved
 // in the enum PredefinedTypeIDs above.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 14fbadbc35ae5d..06226afaf23aab 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1390,6 +1390,10 @@ void ASTContext::InitBuiltinTypes(const TargetInfo 
&Target,
   if (LangOpts.MatrixTypes)
 InitBuiltinType(IncompleteMatrixIdxTy, BuiltinType::IncompleteMatrixIdx);
 
+  // Placeholder for __builtin_counted_by_ref().
+  if (!LangOpts.CPlusPlus)
+InitBuiltinType(

[Lldb-commits] [lldb] [lldb] Fix a regression in SBValue::GetObjectDescription() (PR #117242)

2024-11-21 Thread Adrian Prantl via lldb-commits

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

>From dc8c3877594a513329a2b920b31f314684e6337c Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 21 Nov 2024 13:14:29 -0800
Subject: [PATCH] [lldb] Fix a regression in SBValue::GetObjectDescription()

The old behavior was to return a null string in the error case,when
refactoring the error handling I thought it would be a good idea to
print the error in the description, but that breaks clients that try
to print a description first and then do something else in the error
case. The API is not great but it's clear that in-band errors are also
not a good idea.

rdar://133956263
---
 lldb/source/API/SBValue.cpp | 6 --
 .../commands/expression/diagnostics/TestExprDiagnostics.py  | 6 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index b35c82250d6ba1..a707b9aa7589c7 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -380,8 +380,10 @@ const char *SBValue::GetObjectDescription() {
 return nullptr;
 
   llvm::Expected str = value_sp->GetObjectDescription();
-  if (!str)
-return ConstString("error: " + toString(str.takeError())).AsCString();
+  if (!str) {
+llvm::consumeError(str.takeError());
+return nullptr;
+  }
   return ConstString(*str).AsCString();
 }
 
diff --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index b9b5bffb87e817..e1f1d8c83b632b 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -194,7 +194,11 @@ def test_error_type(self):
 frame = thread.GetFrameAtIndex(0)
 value = frame.EvaluateExpression('#error("I am error.")')
 error = value.GetError()
-self.assertEqual(error.GetType(), lldb.eErrorTypeExpression)
+self.assertEqual(error.GetType(), lldb.eErrorTypeExpression);
+value = frame.FindVariable("f")
+self.assertTrue(value.IsValid())
+desc = value.GetObjectDescription()
+self.assertEqual(desc, None);
 
 def test_command_expr_sbdata(self):
 """Test the structured diagnostics data"""

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


[Lldb-commits] [lldb] [lldb] Fix a regression in SBValue::GetObjectDescription() (PR #117242)

2024-11-21 Thread Adrian Prantl via lldb-commits

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

>From e4a6563c21c251954b077a27b8375028134aa2f8 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 21 Nov 2024 13:14:29 -0800
Subject: [PATCH] [lldb] Fix a regression in SBValue::GetObjectDescription()

The old behavior was to return a null string in the error case,when
refactoring the error handling I thought it would be a good idea to
print the error in the description, but that breaks clients that try
to print a description first and then do something else in the error
case. The API is not great but it's clear that in-band errors are also
not a good idea.

rdar://133956263
---
 lldb/source/API/SBValue.cpp | 6 --
 .../commands/expression/diagnostics/TestExprDiagnostics.py  | 5 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index b35c82250d6ba1..a707b9aa7589c7 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -380,8 +380,10 @@ const char *SBValue::GetObjectDescription() {
 return nullptr;
 
   llvm::Expected str = value_sp->GetObjectDescription();
-  if (!str)
-return ConstString("error: " + toString(str.takeError())).AsCString();
+  if (!str) {
+llvm::consumeError(str.takeError());
+return nullptr;
+  }
   return ConstString(*str).AsCString();
 }
 
diff --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index b9b5bffb87e817..acba37fcf50fcf 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -195,6 +195,11 @@ def test_error_type(self):
 value = frame.EvaluateExpression('#error("I am error.")')
 error = value.GetError()
 self.assertEqual(error.GetType(), lldb.eErrorTypeExpression)
+value = frame.FindVariable('f')
+self.assertTrue(value.IsValid())
+desc = value.GetObjectDescription()
+self.assertEqual(desc, None)
+
 
 def test_command_expr_sbdata(self):
 """Test the structured diagnostics data"""

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread via lldb-commits

https://github.com/jimingham commented:

It would be marginally nicer if there were some way to have "a shared pointer 
that can't be empty" to express the fact that we are always going to put 
something in the result_valobj_sp, so you didn't have to check it for null.  
That's the intent of Evaluate at this point.  But I'm not sure how you would 
express that.

This is strictly better than what was there before, so LGTM.

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread via lldb-commits

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

Also push the Approve button...

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


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

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

https://github.com/rocallahan updated 
https://github.com/llvm/llvm-project/pull/112079

>From c6d62d1b8612ddf052d5073a2845b1a44ae57a83 Mon Sep 17 00:00:00 2001
From: Robert O'Callahan 
Date: Thu, 21 Nov 2024 22:42:39 +1300
Subject: [PATCH] [lldb] Implement basic support for reverse-continue

This commit only adds support for the
`SBProcess::ContinueInDirection()` API. A user-accessible command
for this will follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`)
providing support for the `bc` and `bs` packets. `lldb-server`
does not support those packets, and there is no plan to change that.
with a Python implementation of *very limited* record-and-replay
functionality.
---
 lldb/include/lldb/API/SBProcess.h |   1 +
 lldb/include/lldb/Target/Process.h|  18 +-
 lldb/include/lldb/Target/StopInfo.h   |   7 +
 lldb/include/lldb/Target/Thread.h |  12 +-
 lldb/include/lldb/Target/ThreadList.h |   6 +-
 lldb/include/lldb/Target/ThreadPlan.h |   2 +
 lldb/include/lldb/Target/ThreadPlanBase.h |   2 +
 lldb/include/lldb/lldb-enumerations.h |   6 +
 .../Python/lldbsuite/test/gdbclientutils.py   |   5 +-
 .../Python/lldbsuite/test/lldbgdbproxy.py | 178 +++
 .../Python/lldbsuite/test/lldbreverse.py  | 445 ++
 .../Python/lldbsuite/test/lldbtest.py |   2 +
 lldb/source/API/SBProcess.cpp |   8 +
 lldb/source/API/SBThread.cpp  |   2 +
 .../source/Interpreter/CommandInterpreter.cpp |   3 +-
 .../Process/Linux/NativeThreadLinux.cpp   |   3 +
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |   9 +-
 .../Process/MacOSX-Kernel/ProcessKDP.h|   2 +-
 .../Process/Windows/Common/ProcessWindows.cpp |   9 +-
 .../Process/Windows/Common/ProcessWindows.h   |   2 +-
 .../GDBRemoteCommunicationClient.cpp  |  22 +
 .../gdb-remote/GDBRemoteCommunicationClient.h |   6 +
 .../GDBRemoteCommunicationServerLLGS.cpp  |   1 +
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  88 +++-
 .../Process/gdb-remote/ProcessGDBRemote.h |   2 +-
 .../Process/scripted/ScriptedProcess.cpp  |  10 +-
 .../Process/scripted/ScriptedProcess.h|   2 +-
 lldb/source/Target/Process.cpp|  33 +-
 lldb/source/Target/StopInfo.cpp   |  29 ++
 lldb/source/Target/Thread.cpp |  13 +-
 lldb/source/Target/ThreadList.cpp |  62 ++-
 lldb/source/Target/ThreadPlanBase.cpp |   4 +
 .../reverse-execution/Makefile|   3 +
 .../TestReverseContinueBreakpoints.py | 151 ++
 .../TestReverseContinueNotSupported.py|  30 ++
 .../functionalities/reverse-execution/main.c  |  14 +
 lldb/tools/lldb-dap/JSONUtils.cpp |   3 +
 lldb/tools/lldb-dap/LLDBUtils.cpp |   1 +
 38 files changed, 1127 insertions(+), 69 deletions(-)
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbreverse.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/Makefile
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/main.c

diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 1624e02070b1b21..882b8bd837131d1 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -159,6 +159,7 @@ class LLDB_API SBProcess {
   lldb::SBError Destroy();
 
   lldb::SBError Continue();
+  lldb::SBError ContinueInDirection(lldb::RunDirection direction);
 
   lldb::SBError Stop();
 
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index b8c53a474ba6b95..7b8ec7ae39f2b76 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -1104,9 +1104,15 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  virtual Status DoResume() {
-return Status::FromErrorStringWithFormatv(
-"error: {0} does not support resuming processes", GetPluginName());
+  virtual Status DoResume(lldb::RunDirection direction) {
+if (direction == lldb::RunDirection::eRunForward) {
+  return Status::FromErrorStringWithFormatv(
+  "error: {0} does not support resuming processes", GetPluginName());
+} else {
+  return Status::FromErrorStringWithFormatv(
+  "error: {0} does not support reverse execution of processes",
+  GetPluginName());
+}
   }
 
   /// Called after resuming a process.
@@ -2674,6 +2680,11 @@ void PruneThreadPlans();
 const AddressRange &range, size_t alignment,
 Status &error);
 
+  lld

[Lldb-commits] [lldb] [lldb] Fix a regression in Status::GetErrorType() (PR #117095)

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

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

🚀

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread Alex Langford via lldb-commits


@@ -339,12 +339,9 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, 
std::string &code) {
 
   const char *expr_prefix = nullptr;
   lldb::ValueObjectSP result_valobj_sp;
+  lldb::ExpressionResults execution_results = UserExpression::Evaluate(
+  exe_ctx, expr_options, code.c_str(), expr_prefix, result_valobj_sp);
   Status error;

bulbazord wrote:

Can you remove this variable? If this variable is checked, that can also be 
removed now since it will always be empty. If it wasn't checked before, well, 
then I guess you can remove only this line. :)

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread Dave Lee via lldb-commits

kastiglione wrote:

for the lldb change: I'm not sure how you'd construct a test, but I think 
that's not a problem – the change looks obviously correct to me.

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


[Lldb-commits] [lldb] [lldb] Fix a regression in SBValue::GetObjectDescription() (PR #117242)

2024-11-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

The old behavior was to return a null string in the error case,when refactoring 
the error handling I thought it would be a good idea to print the error in the 
description, but that breaks clients that try to print a description first and 
then do something else in the error case. The API is not great but it's clear 
that in-band errors are also not a good idea.

rdar://133956263

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


2 Files Affected:

- (modified) lldb/source/API/SBValue.cpp (+4-2) 
- (modified) 
lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py (+6-1) 


``diff
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index b35c82250d6ba1..a707b9aa7589c7 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -380,8 +380,10 @@ const char *SBValue::GetObjectDescription() {
 return nullptr;
 
   llvm::Expected str = value_sp->GetObjectDescription();
-  if (!str)
-return ConstString("error: " + toString(str.takeError())).AsCString();
+  if (!str) {
+llvm::consumeError(str.takeError());
+return nullptr;
+  }
   return ConstString(*str).AsCString();
 }
 
diff --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index b9b5bffb87e817..a68e921ef02dba 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -194,7 +194,12 @@ def test_error_type(self):
 frame = thread.GetFrameAtIndex(0)
 value = frame.EvaluateExpression('#error("I am error.")')
 error = value.GetError()
-self.assertEqual(error.GetType(), lldb.eErrorTypeExpression)
+self.assertEqual(error.GetType(), lldb.eErrorTypeExpression);
+value = frame.FindVariable('f')
+self.assertTrue(value.IsValid());
+desc = value.GetObjectDescription()
+self.assertEqual(desc, None);
+
 
 def test_command_expr_sbdata(self):
 """Test the structured diagnostics data"""

``




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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread via lldb-commits

ChuvakHome wrote:

I've made individual PRs:
- https://github.com/llvm/llvm-project/pull/117156
- https://github.com/llvm/llvm-project/pull/117223
- https://github.com/llvm/llvm-project/pull/117226
- https://github.com/llvm/llvm-project/pull/117227
- https://github.com/llvm/llvm-project/pull/117228

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


[Lldb-commits] [lldb] [lldb] Fix a regression in SBValue::GetObjectDescription() (PR #117242)

2024-11-21 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 
29afbd5893fbf68a2b64321bee0c82233b8b852e...b01b2a158a3449904e210186b0cbfae3f51f6c7e
 lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
``





View the diff from darker here.


``diff
--- TestExprDiagnostics.py  2024-11-21 21:14:29.00 +
+++ TestExprDiagnostics.py  2024-11-21 21:20:36.806667 +
@@ -192,16 +192,15 @@
 self, "// Break here", self.main_source_spec
 )
 frame = thread.GetFrameAtIndex(0)
 value = frame.EvaluateExpression('#error("I am error.")')
 error = value.GetError()
-self.assertEqual(error.GetType(), lldb.eErrorTypeExpression);
-value = frame.FindVariable('f')
-self.assertTrue(value.IsValid());
+self.assertEqual(error.GetType(), lldb.eErrorTypeExpression)
+value = frame.FindVariable("f")
+self.assertTrue(value.IsValid())
 desc = value.GetObjectDescription()
-self.assertEqual(desc, None);
-
+self.assertEqual(desc, None)
 
 def test_command_expr_sbdata(self):
 """Test the structured diagnostics data"""
 self.build()
 

``




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


[Lldb-commits] [lldb] [lldb] Fix a regression in SBValue::GetObjectDescription() (PR #117242)

2024-11-21 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/117242

The old behavior was to return a null string in the error case,when refactoring 
the error handling I thought it would be a good idea to print the error in the 
description, but that breaks clients that try to print a description first and 
then do something else in the error case. The API is not great but it's clear 
that in-band errors are also not a good idea.

rdar://133956263

>From b01b2a158a3449904e210186b0cbfae3f51f6c7e Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 21 Nov 2024 13:14:29 -0800
Subject: [PATCH] [lldb] Fix a regression in SBValue::GetObjectDescription()

The old behavior was to return a null string in the error case,when
refactoring the error handling I thought it would be a good idea to
print the error in the description, but that breaks clients that try
to print a description first and then do something else in the error
case. The API is not great but it's clear that in-band errors are also
not a good idea.

rdar://133956263
---
 lldb/source/API/SBValue.cpp| 6 --
 .../commands/expression/diagnostics/TestExprDiagnostics.py | 7 ++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index b35c82250d6ba1..a707b9aa7589c7 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -380,8 +380,10 @@ const char *SBValue::GetObjectDescription() {
 return nullptr;
 
   llvm::Expected str = value_sp->GetObjectDescription();
-  if (!str)
-return ConstString("error: " + toString(str.takeError())).AsCString();
+  if (!str) {
+llvm::consumeError(str.takeError());
+return nullptr;
+  }
   return ConstString(*str).AsCString();
 }
 
diff --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index b9b5bffb87e817..a68e921ef02dba 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -194,7 +194,12 @@ def test_error_type(self):
 frame = thread.GetFrameAtIndex(0)
 value = frame.EvaluateExpression('#error("I am error.")')
 error = value.GetError()
-self.assertEqual(error.GetType(), lldb.eErrorTypeExpression)
+self.assertEqual(error.GetType(), lldb.eErrorTypeExpression);
+value = frame.FindVariable('f')
+self.assertTrue(value.IsValid());
+desc = value.GetObjectDescription()
+self.assertEqual(desc, None);
+
 
 def test_command_expr_sbdata(self):
 """Test the structured diagnostics data"""

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


[Lldb-commits] [lldb] a62e1c8 - [lldb] Fix incorrect nullptr check in DumpAddressAndContent (#117219)

2024-11-21 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-11-21T13:23:55-08:00
New Revision: a62e1c8eddcda420abec57976dc48f97669277dc

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

LOG: [lldb] Fix incorrect nullptr check in DumpAddressAndContent (#117219)

When checking the section load list, the existing code assumed that a
valid execution context guaranteed a valid target. This is a speculative
fix for a crash report (without a reproducer).

rdar://133969831

Added: 


Modified: 
lldb/source/Core/FormatEntity.cpp

Removed: 




diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 36214c173af6f8..d76fc97caa0133 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -410,31 +410,31 @@ static bool DumpAddressAndContent(Stream &s, const 
SymbolContext *sc,
   const Address &addr,
   bool print_file_addr_or_load_addr) {
   Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
+
   addr_t vaddr = LLDB_INVALID_ADDRESS;
-  if (exe_ctx && !target->GetSectionLoadList().IsEmpty())
+  if (target && !target->GetSectionLoadList().IsEmpty())
 vaddr = addr.GetLoadAddress(target);
   if (vaddr == LLDB_INVALID_ADDRESS)
 vaddr = addr.GetFileAddress();
+  if (vaddr == LLDB_INVALID_ADDRESS)
+return false;
 
-  if (vaddr != LLDB_INVALID_ADDRESS) {
-int addr_width = 0;
-if (exe_ctx && target) {
-  addr_width = target->GetArchitecture().GetAddressByteSize() * 2;
-}
-if (addr_width == 0)
-  addr_width = 16;
-if (print_file_addr_or_load_addr) {
-  ExecutionContextScope *exe_scope = nullptr;
-  if (exe_ctx)
-exe_scope = exe_ctx->GetBestExecutionContextScope();
-  addr.Dump(&s, exe_scope, Address::DumpStyleLoadAddress,
-Address::DumpStyleModuleWithFileAddress, 0);
-} else {
-  s.Printf("0x%*.*" PRIx64, addr_width, addr_width, vaddr);
-}
-return true;
+  int addr_width = 0;
+  if (target)
+addr_width = target->GetArchitecture().GetAddressByteSize() * 2;
+  if (addr_width == 0)
+addr_width = 16;
+
+  if (print_file_addr_or_load_addr) {
+ExecutionContextScope *exe_scope =
+exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
+addr.Dump(&s, exe_scope, Address::DumpStyleLoadAddress,
+  Address::DumpStyleModuleWithFileAddress, 0);
+  } else {
+s.Printf("0x%*.*" PRIx64, addr_width, addr_width, vaddr);
   }
-  return false;
+
+  return true;
 }
 
 static bool DumpAddressOffsetFromFunction(Stream &s, const SymbolContext *sc,



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


[Lldb-commits] [lldb] [lldb] Fix incorrect nullptr check in DumpAddressAndContent (PR #117219)

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

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


[Lldb-commits] [lldb] 9894cd5 - [lldb] Fix a warning

2024-11-21 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2024-11-21T16:00:42-08:00
New Revision: 9894cd5febbb89ad5b97c006179aaee77b824f91

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

LOG: [lldb] Fix a warning

This patch fixes:

  lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp:53:32: error:
  field 'm_thread_reg_ctx_sp' will be initialized after field
  'm_thread_name' [-Werror,-Wreorder-ctor]

Added: 


Modified: 
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index c810eb9ed61d26..91552dd9769252 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -50,7 +50,7 @@ using namespace lldb_private;
 
 // Construct a Thread object with given data
 ThreadElfCore::ThreadElfCore(Process &process, const ThreadData &td)
-: Thread(process, td.tid), m_thread_reg_ctx_sp(), m_thread_name(td.name),
+: Thread(process, td.tid), m_thread_name(td.name), m_thread_reg_ctx_sp(),
   m_gpregset_data(td.gpregset), m_notes(td.notes),
   m_siginfo(std::move(td.siginfo)) {}
 



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


[Lldb-commits] [lldb] [lldb] Add stop_reason_data property to SBThread python extensions (PR #117266)

2024-11-21 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/117266

None

>From 07925dfe397a3cf0aa93f37bfc275cf0125c645d Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Sun, 10 Nov 2024 09:35:06 -0800
Subject: [PATCH] [lldb] Add stop_reason_data property to SBThread python
 extensions

---
 lldb/bindings/interface/SBThreadExtensions.i   |  7 +++
 .../test/API/lang/c/stepping/TestStepAndBreakpoints.py | 10 --
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lldb/bindings/interface/SBThreadExtensions.i 
b/lldb/bindings/interface/SBThreadExtensions.i
index bfcc4d17e8f829..860a2d765a6695 100644
--- a/lldb/bindings/interface/SBThreadExtensions.i
+++ b/lldb/bindings/interface/SBThreadExtensions.i
@@ -45,6 +45,12 @@ STRING_EXTENSION_OUTSIDE(SBThread)
 frames.append(frame)
 return frames
 
+def get_stop_reason_data(self):
+return [
+self.GetStopReasonDataAtIndex(idx)
+for idx in range(self.GetStopReasonDataCount())
+]
+
 id = property(GetThreadID, None, doc='''A read only property that 
returns the thread ID as an integer.''')
 idx = property(GetIndexID, None, doc='''A read only property that 
returns the thread index ID as an integer. Thread index ID values start at 1 
and increment as threads come and go and can be used to uniquely identify 
threads.''')
 return_value = property(GetStopReturnValue, None, doc='''A read only 
property that returns an lldb object that represents the return value from the 
last stop (lldb.SBValue) if we just stopped due to stepping out of a 
function.''')
@@ -56,6 +62,7 @@ STRING_EXTENSION_OUTSIDE(SBThread)
 queue = property(GetQueueName, None, doc='''A read only property that 
returns the dispatch queue name of this thread as a string.''')
 queue_id = property(GetQueueID, None, doc='''A read only property that 
returns the dispatch queue id of this thread as an integer.''')
 stop_reason = property(GetStopReason, None, doc='''A read only 
property that returns an lldb enumeration value (see enumerations that start 
with "lldb.eStopReason") that represents the reason this thread stopped.''')
+stop_reason_data = property(get_stop_reason_data, None, doc='''A read 
only property that returns the stop reason data as a list.''')
 is_suspended = property(IsSuspended, None, doc='''A read only property 
that returns a boolean value that indicates if this thread is suspended.''')
 is_stopped = property(IsStopped, None, doc='''A read only property 
that returns a boolean value that indicates if this thread is stopped but not 
exited.''')
 %}
diff --git a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py 
b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
index 8d0de40cdd7b68..9fe787bcaa9fb7 100644
--- a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
+++ b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
@@ -99,9 +99,7 @@ def test_and_python_api(self):
 frame = thread.GetFrameAtIndex(0)
 current_line = frame.GetLineEntry().GetLine()
 current_file = frame.GetLineEntry().GetFileSpec()
-current_bp = []
-current_bp.append(thread.GetStopReasonDataAtIndex(0))
-current_bp.append(thread.GetStopReasonDataAtIndex(1))
+current_bp = thread.stop_reason_data
 
 stop_id_before_expression = process.GetStopID()
 stop_id_before_including_expressions = process.GetStopID(True)
@@ -124,9 +122,9 @@ def test_and_python_api(self):
 lldb.eStopReasonBreakpoint,
 "We still say we stopped for a breakpoint.",
 )
-self.assertTrue(
-thread.GetStopReasonDataAtIndex(0) == current_bp[0]
-and thread.GetStopReasonDataAtIndex(1) == current_bp[1],
+self.assertEqual(
+thread.stop_reason_data,
+current_bp,
 "And it is the same breakpoint.",
 )
 

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


[Lldb-commits] [lldb] [lldb] Add stop_reason_data property to SBThread python extensions (PR #117266)

2024-11-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes



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


2 Files Affected:

- (modified) lldb/bindings/interface/SBThreadExtensions.i (+7) 
- (modified) lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py (+4-6) 


``diff
diff --git a/lldb/bindings/interface/SBThreadExtensions.i 
b/lldb/bindings/interface/SBThreadExtensions.i
index bfcc4d17e8f829..860a2d765a6695 100644
--- a/lldb/bindings/interface/SBThreadExtensions.i
+++ b/lldb/bindings/interface/SBThreadExtensions.i
@@ -45,6 +45,12 @@ STRING_EXTENSION_OUTSIDE(SBThread)
 frames.append(frame)
 return frames
 
+def get_stop_reason_data(self):
+return [
+self.GetStopReasonDataAtIndex(idx)
+for idx in range(self.GetStopReasonDataCount())
+]
+
 id = property(GetThreadID, None, doc='''A read only property that 
returns the thread ID as an integer.''')
 idx = property(GetIndexID, None, doc='''A read only property that 
returns the thread index ID as an integer. Thread index ID values start at 1 
and increment as threads come and go and can be used to uniquely identify 
threads.''')
 return_value = property(GetStopReturnValue, None, doc='''A read only 
property that returns an lldb object that represents the return value from the 
last stop (lldb.SBValue) if we just stopped due to stepping out of a 
function.''')
@@ -56,6 +62,7 @@ STRING_EXTENSION_OUTSIDE(SBThread)
 queue = property(GetQueueName, None, doc='''A read only property that 
returns the dispatch queue name of this thread as a string.''')
 queue_id = property(GetQueueID, None, doc='''A read only property that 
returns the dispatch queue id of this thread as an integer.''')
 stop_reason = property(GetStopReason, None, doc='''A read only 
property that returns an lldb enumeration value (see enumerations that start 
with "lldb.eStopReason") that represents the reason this thread stopped.''')
+stop_reason_data = property(get_stop_reason_data, None, doc='''A read 
only property that returns the stop reason data as a list.''')
 is_suspended = property(IsSuspended, None, doc='''A read only property 
that returns a boolean value that indicates if this thread is suspended.''')
 is_stopped = property(IsStopped, None, doc='''A read only property 
that returns a boolean value that indicates if this thread is stopped but not 
exited.''')
 %}
diff --git a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py 
b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
index 8d0de40cdd7b68..9fe787bcaa9fb7 100644
--- a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
+++ b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
@@ -99,9 +99,7 @@ def test_and_python_api(self):
 frame = thread.GetFrameAtIndex(0)
 current_line = frame.GetLineEntry().GetLine()
 current_file = frame.GetLineEntry().GetFileSpec()
-current_bp = []
-current_bp.append(thread.GetStopReasonDataAtIndex(0))
-current_bp.append(thread.GetStopReasonDataAtIndex(1))
+current_bp = thread.stop_reason_data
 
 stop_id_before_expression = process.GetStopID()
 stop_id_before_including_expressions = process.GetStopID(True)
@@ -124,9 +122,9 @@ def test_and_python_api(self):
 lldb.eStopReasonBreakpoint,
 "We still say we stopped for a breakpoint.",
 )
-self.assertTrue(
-thread.GetStopReasonDataAtIndex(0) == current_bp[0]
-and thread.GetStopReasonDataAtIndex(1) == current_bp[1],
+self.assertEqual(
+thread.stop_reason_data,
+current_bp,
 "And it is the same breakpoint.",
 )
 

``




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


[Lldb-commits] [lldb] [lldb] Add stop_reason_data property to SBThread python extensions (PR #117266)

2024-11-21 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [DWARF] Fix DWARTTypePrinter unable to print qualified name for DW_TAG_typedef DIE (PR #117239)

2024-11-21 Thread David Blaikie via lldb-commits

dwblaikie wrote:

Rather than a unit test, perhaps this could be tested with llvm-dwarfdump? (I 
think that's how I tested the DWARFTypePrinter during its initial development) 
It's a feature improvement to llvm-dwarfdump - being able to print out names 
better.

I guess most of what I did was more specifically about 
simplified-template-names roundtripping, which this new typedef case isn't 
relevant to (typedefs aren't canonical names, don't themselves get 
simplified/have to be rebuilt).

But the testing was in 
llvm/test/tools/llvm-dwarfdump/X86/simplified-template-names.s (and there's 
similar testing in the cross_project_tests and in clang - so adding the test 
coverage in those places too would be good, if this test file's one that could 
be used for this patch). I guess maybe this testing all only does "verify" 
testing, which means it won't print the typedef qualified name you want to test.

In that case, we have some testing for type printing prior to the 
DWARFTypePrinter work... 

Oh, also - LLVM fixes should be tested in LLVM, not in lldb... 

Probably the most common way to test this would be to add something in 
llvm/test/DebugInfo/X86/dwarfdump-*.ll 

Oh, this test might be where we test most of this in the past: 
llvm/test/tools/llvm-dwarfdump/X86/prettyprint_types.s



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


[Lldb-commits] [lldb] [lldb] Fix ELF core debugging (PR #117070)

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

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


[Lldb-commits] [lldb] Convert the StackFrameList mutex to a shared mutex. (PR #117252)

2024-11-21 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/117252

>From b0d2179cf01cdd0b07bc43cef2a8c14d282e7ee7 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Tue, 19 Nov 2024 17:38:02 -0800
Subject: [PATCH 1/3] Convert the recursive StackFrameList mutex to a
 non-recursive one.

---
 lldb/include/lldb/Target/StackFrameList.h |  19 +++-
 lldb/source/Target/StackFrameList.cpp | 104 +-
 2 files changed, 81 insertions(+), 42 deletions(-)

diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index 7d0e7a5b9a71b2..1c59d2e97937da 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -103,11 +103,15 @@ class StackFrameList {
   /// Realizes frames up to (and including) end_idx (which can be greater than 
 
   /// the actual number of frames.)  
   /// Returns true if the function was interrupted, false otherwise.
+  /// Does not hold the StackFrameList mutex.
   bool GetFramesUpTo(uint32_t end_idx, 
   InterruptionControl allow_interrupt = AllowInterruption);
 
+  /// Does not hold the StackFrameList mutex.
   void GetOnlyConcreteFramesUpTo(uint32_t end_idx, Unwind &unwinder);
 
+  // This gets called without the StackFrameList lock held, callers should 
+  // hold the lock.
   void SynthesizeTailCallFrames(StackFrame &next_frame);
 
   bool GetAllFramesFetched() { return m_concrete_frames_fetched == UINT32_MAX; 
}
@@ -122,6 +126,9 @@ class StackFrameList {
 
   void SetCurrentInlinedDepth(uint32_t new_depth);
 
+  /// Calls into the stack frame recognizers and stop info to set the most
+  /// relevant frame.  This can call out to arbitrary user code so it can't
+  /// hold the StackFrameList mutex.
   void SelectMostRelevantFrame();
 
   typedef std::vector collection;
@@ -142,7 +149,14 @@ class StackFrameList {
   // TODO: This mutex may not always be held when required. In particular, uses
   // of the StackFrameList APIs in lldb_private::Thread look suspect. Consider
   // passing around a lock_guard reference to enforce proper locking.
-  mutable std::recursive_mutex m_mutex;
+  mutable std::mutex m_mutex;
+  
+  // llvm::sys::RWMutex m_stack_list_mutex;
+  
+  // Setting the inlined depth should be protected against other attempts to
+  // change it, but since it doesn't mutate the list itself, we can limit the
+  // critical regions it produces by having a separate mutex.
+  mutable std::mutex m_inlined_depth_mutex;
 
   /// A cache of frames. This may need to be updated when the program counter
   /// changes.
@@ -171,6 +185,9 @@ class StackFrameList {
   const bool m_show_inlined_frames;
 
 private:
+  uint32_t SetSelectedFrameNoLock(lldb_private::StackFrame *frame);
+  lldb::StackFrameSP GetFrameAtIndexNoLock(uint32_t idx);
+
   StackFrameList(const StackFrameList &) = delete;
   const StackFrameList &operator=(const StackFrameList &) = delete;
 };
diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 94a381edd5e202..8dc358e492 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -38,7 +38,7 @@ using namespace lldb_private;
 StackFrameList::StackFrameList(Thread &thread,
const lldb::StackFrameListSP &prev_frames_sp,
bool show_inline_frames)
-: m_thread(thread), m_prev_frames_sp(prev_frames_sp), m_mutex(), 
m_frames(),
+: m_thread(thread), m_prev_frames_sp(prev_frames_sp), m_frames(),
   m_selected_frame_idx(), m_concrete_frames_fetched(0),
   m_current_inlined_depth(UINT32_MAX),
   m_current_inlined_pc(LLDB_INVALID_ADDRESS),
@@ -63,6 +63,7 @@ void StackFrameList::CalculateCurrentInlinedDepth() {
 }
 
 uint32_t StackFrameList::GetCurrentInlinedDepth() {
+  std::lock_guard guard(m_inlined_depth_mutex);
   if (m_show_inlined_frames && m_current_inlined_pc != LLDB_INVALID_ADDRESS) {
 lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
 if (cur_pc != m_current_inlined_pc) {
@@ -84,11 +85,6 @@ void StackFrameList::ResetCurrentInlinedDepth() {
   if (!m_show_inlined_frames)
 return;
 
-  std::lock_guard guard(m_mutex);
-
-  m_current_inlined_pc = LLDB_INVALID_ADDRESS;
-  m_current_inlined_depth = UINT32_MAX;
-
   StopInfoSP stop_info_sp = m_thread.GetStopInfo();
   if (!stop_info_sp)
 return;
@@ -98,6 +94,7 @@ void StackFrameList::ResetCurrentInlinedDepth() {
   // We're only adjusting the inlined stack here.
   Log *log = GetLog(LLDBLog::Step);
   if (inline_depth) {
+std::lock_guard guard(m_inlined_depth_mutex);
 m_current_inlined_depth = *inline_depth;
 m_current_inlined_pc = m_thread.GetRegisterContext()->GetPC();
 
@@ -107,6 +104,9 @@ void StackFrameList::ResetCurrentInlinedDepth() {
 "depth: %d 0x%" PRIx64 ".\n",
 m_current_inlined_depth, m_current_inlined_pc);
   } else {
+std::lock_guard guard(m_inlined_de

[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Fix loading UUIDs from ELF headers. (PR #117028)

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

clayborg wrote:

> I'm a bit confused as to how we have a core file but also things are moved in 
> memory.
> 
> Can you give an explanation of how this occurs? Please add it to the PR 
> description.

Will do.

> Also, tests? (which is partly why I ask how this occurs)

Tests are hard to create as we don't have a custom way to create ELF core files 
and obj2yaml and yaml2obj don't work for ELF files that have program header 
data only. Core files contain program headers with data only in the file, so we 
can't take an existing core file and obj2yaml it and then remove parts of it 
because the resulting file will be missing all of the program header data. If 
anyone has a solution as to how to hand craft a ELF core file using YAML please 
let me know and I will make another PR to test this.


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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/117186

Prior to this patch, the function returned an exit status, sometimes a 
ValueObject with an error and a Status object. This patch removes the Status 
object and ensures the error is consistently returned as the error of the 
ValueObject.

>From 596eb40c641d2c580fd8a2dbfc11e8e3f41dd984 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 21 Nov 2024 08:32:06 -0800
Subject: [PATCH] [lldb] Refactor UserExpression::Evaluate to only have one
 error channel.

Prior to this patch, the function returned an exit status, sometimes a
ValueObject with an error and a Status object. This patch removes the
Status object and ensures the error is consistently returned as the
error of the ValueObject.
---
 lldb/include/lldb/Expression/UserExpression.h | 10 ++--
 lldb/source/Expression/REPL.cpp   |  7 +--
 lldb/source/Expression/UserExpression.cpp | 57 +--
 .../TSan/InstrumentationRuntimeTSan.cpp   |  6 +-
 .../UBSan/InstrumentationRuntimeUBSan.cpp |  6 +-
 .../Utility/ReportRetriever.cpp   |  6 +-
 .../MemoryHistory/asan/MemoryHistoryASan.cpp  |  6 +-
 .../Plugins/Platform/POSIX/PlatformPOSIX.cpp  |  9 ++-
 .../Platform/Windows/PlatformWindows.cpp  |  7 +--
 lldb/source/Target/StopInfo.cpp   |  8 ++-
 lldb/source/Target/Target.cpp | 11 +---
 .../commands/expression/fixits/TestFixIts.py  |  2 +-
 12 files changed, 60 insertions(+), 75 deletions(-)

diff --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 7ce463d2cb4e7e..2fde73dafa035d 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -240,11 +240,9 @@ class UserExpression : public Expression {
   /// definitions to be included when the expression is parsed.
   ///
   /// \param[in,out] result_valobj_sp
-  ///  If execution is successful, the result valobj is placed here.
-  ///
-  /// \param[out] error
-  /// Filled in with an error in case the expression evaluation
-  /// fails to parse, run, or evaluated.
+  ///  If execution is successful, the result valobj is placed
+  ///  here. Otherwise its Error will contain an ExpressionError
+  ///  with details about the failure mode.
   ///
   /// \param[out] fixed_expression
   /// If non-nullptr, the fixed expression is copied into the provided
@@ -266,7 +264,7 @@ class UserExpression : public Expression {
   static lldb::ExpressionResults
   Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
llvm::StringRef expr_cstr, llvm::StringRef expr_prefix,
-   lldb::ValueObjectSP &result_valobj_sp, Status &error,
+   lldb::ValueObjectSP &result_valobj_sp,
std::string *fixed_expression = nullptr,
ValueObject *ctx_obj = nullptr);
 
diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index 56c50e346b39b8..4b53537e50e62a 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -339,12 +339,9 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, 
std::string &code) {
 
   const char *expr_prefix = nullptr;
   lldb::ValueObjectSP result_valobj_sp;
+  lldb::ExpressionResults execution_results = UserExpression::Evaluate(
+  exe_ctx, expr_options, code.c_str(), expr_prefix, result_valobj_sp);
   Status error;
-  lldb::ExpressionResults execution_results =
-  UserExpression::Evaluate(exe_ctx, expr_options, code.c_str(),
-   expr_prefix, result_valobj_sp, error,
-   nullptr); // fixed expression
-
   if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
   execution_results,
   result_valobj_sp, error)) {
diff --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index ed3734cbb943f6..c21bcbd9cfa060 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -144,9 +144,13 @@ lldb::ExpressionResults
 UserExpression::Evaluate(ExecutionContext &exe_ctx,
  const EvaluateExpressionOptions &options,
  llvm::StringRef expr, llvm::StringRef prefix,
- lldb::ValueObjectSP &result_valobj_sp, Status &error,
+ lldb::ValueObjectSP &result_valobj_sp,
  std::string *fixed_expression, ValueObject *ctx_obj) {
   Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
+  auto set_error = [&](Status error) {
+result_valobj_sp = ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), std::move(error));
+  };
 
   if (ctx_obj) {
 static unsigned const 

[Lldb-commits] [lldb] [lldb] Make sure completions don't end with newlines (PR #117054)

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

JDevlieghere wrote:

> I get the "description" part, but I'm somewhat confused about the 
> "completion". How does a newline (trailing or not) get there? Like, you can't 
> actually type something which includes a newline, right? I'm wondering if we 
> should disallow these at a higher level...

I didn't actually find a completion where that was the case, but it seemed 
simple enough to be defensive for both. Like I said in the description, I 
considered an assertion but technically this is user input. I didn't actually 
try this, but what I was thinking of is something like a newline in 
`DW_AT_name` or something. Obviously that's not something reasonable tools 
would generate, but input is input... 

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


[Lldb-commits] [lldb] Fix index boundaries check, Change wrong int literal (PR #117226)

2024-11-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chuvak (ChuvakHome)


Changes

Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

Fixed:
- [Bug 8](https://pvs-studio.com/en/blog/posts/cpp/1188/#ID0EFA5EA398)
- [Bug 10](https://pvs-studio.com/en/blog/posts/cpp/1188/#ID0BFC185CF3)

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


2 Files Affected:

- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (+1-1) 
- (modified) lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
(+1-1) 


``diff
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 0083b499656979..c43871b08191db 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -3278,7 +3278,7 @@ bool 
AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
   }
 
   // If the index is still out of range then this isn't a pointer.
-  if (index > m_indexed_isa_cache.size())
+  if (index >= m_indexed_isa_cache.size())
 return false;
 
   LLDB_LOGF(log, "AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64 ")",
diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
index 8c69989702c2aa..f7a2d1d07142ec 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
@@ -150,7 +150,7 @@ GeneratePerfEventConfigValue(bool enable_tsc,
   if (enable_tsc) {
 if (Expected offset = ReadIntelPTConfigFile(
 kTSCBitOffsetFile, IntelPTConfigFileType::BitOffset))
-  config |= 1 << *offset;
+  config |= 1ULL << *offset;
 else
   return offset.takeError();
   }

``




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


[Lldb-commits] [lldb] Fix index boundaries check, Change wrong int literal (PR #117226)

2024-11-21 Thread via lldb-commits

https://github.com/ChuvakHome created 
https://github.com/llvm/llvm-project/pull/117226

Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

Fixed:
- [Bug 8](https://pvs-studio.com/en/blog/posts/cpp/1188/#ID0EFA5EA398)
- [Bug 10](https://pvs-studio.com/en/blog/posts/cpp/1188/#ID0BFC185CF3)

>From 5aa27e834cc78f329b9d5abd39529f7b5445f74b Mon Sep 17 00:00:00 2001
From: timurdemenev <311...@niuitmo.ru>
Date: Thu, 21 Nov 2024 22:56:13 +0300
Subject: [PATCH] Fix index boundaries check, Change wrong int literal

---
 .../ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp| 2 +-
 lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 0083b499656979..c43871b08191db 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -3278,7 +3278,7 @@ bool 
AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
   }
 
   // If the index is still out of range then this isn't a pointer.
-  if (index > m_indexed_isa_cache.size())
+  if (index >= m_indexed_isa_cache.size())
 return false;
 
   LLDB_LOGF(log, "AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64 ")",
diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp 
b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
index 8c69989702c2aa..f7a2d1d07142ec 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
@@ -150,7 +150,7 @@ GeneratePerfEventConfigValue(bool enable_tsc,
   if (enable_tsc) {
 if (Expected offset = ReadIntelPTConfigFile(
 kTSCBitOffsetFile, IntelPTConfigFileType::BitOffset))
-  config |= 1 << *offset;
+  config |= 1ULL << *offset;
 else
   return offset.takeError();
   }

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


[Lldb-commits] [lldb] Fix index boundaries check, Change wrong int literal (PR #117226)

2024-11-21 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] bcf654c - [lldb] Fix loading UUIDs from ELF headers. (#117028)

2024-11-21 Thread via lldb-commits

Author: Greg Clayton
Date: 2024-11-21T14:15:26-08:00
New Revision: bcf654c7f5fb84dd7cff5fe112d96658853cd8f5

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

LOG: [lldb] Fix loading UUIDs from ELF headers. (#117028)

A previous patch added the ability to load UUID from ELF headers using
the program header and finding PT_NOTE entries. The fix would attempt to
read the data for the PT_NOTE from memory, but it didn't slide the
address so it ended up only working for the main executable if it wasn't
moved in memory. This patch slides the address and adds logging.

All processes map the ELF header + program headers + some program header
contents into memory. The program header for the `PT_NOTE` entries are
mapped, but the p_vaddr doesn't get relocated and is relative to the
load address of the ELF header. So we take a "p_vaddr" (file address)
and convert it into a load address in the process so we can load the
correct bytes that contain the `PT_NOTE` contents.

Added: 


Modified: 
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 7955594bf5d94c..cd95b000469dc5 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -224,7 +224,7 @@ Status ProcessElfCore::DoLoadCore() {
   ArchSpec core_arch(m_core_module_sp->GetArchitecture());
   target_arch.MergeFrom(core_arch);
   GetTarget().SetArchitecture(target_arch);
- 
+
   SetUnixSignals(UnixSignals::Create(GetArchitecture()));
 
   // Ensure we found at least one thread that was stopped on a signal.
@@ -276,8 +276,13 @@ Status ProcessElfCore::DoLoadCore() {
 }
 
 void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  Log *log = GetLog(LLDBLog::Process);
   for (NT_FILE_Entry &entry : m_nt_file_entries) {
 entry.uuid = FindBuidIdInCoreMemory(entry.start);
+if (log && entry.uuid.IsValid())
+  LLDB_LOGF(log, "%s found UUID @ %16.16" PRIx64 ": %s \"%s\"",
+__FUNCTION__, entry.start, entry.uuid.GetAsString().c_str(),
+entry.path.c_str());
   }
 }
 
@@ -875,7 +880,7 @@ llvm::Error 
ProcessElfCore::parseOpenBSDNotes(llvm::ArrayRef notes) {
 /// - NT_SIGINFO - Information about the signal that terminated the process
 /// - NT_AUXV - Process auxiliary vector
 /// - NT_FILE - Files mapped into memory
-/// 
+///
 /// Additionally, for each thread in the process the core file will contain at
 /// least the NT_PRSTATUS note, containing the thread id and general purpose
 /// registers. It may include additional notes for other register sets 
(floating
@@ -1034,15 +1039,20 @@ UUID 
ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) {
 std::vector note_bytes;
 note_bytes.resize(program_header.p_memsz);
 
-byte_read = ReadMemory(program_header.p_vaddr, note_bytes.data(),
-   program_header.p_memsz, error);
+// We need to slide the address of the p_vaddr as these values don't get
+// relocated in memory.
+const lldb::addr_t vaddr = program_header.p_vaddr + address;
+byte_read =
+ReadMemory(vaddr, note_bytes.data(), program_header.p_memsz, error);
 if (byte_read != program_header.p_memsz)
   continue;
 DataExtractor segment_data(note_bytes.data(), note_bytes.size(),
GetByteOrder(), addr_size);
 auto notes_or_error = parseSegment(segment_data);
-if (!notes_or_error)
+if (!notes_or_error) {
+  llvm::consumeError(notes_or_error.takeError());
   return invalid_uuid;
+}
 for (const CoreNote ¬e : *notes_or_error) {
   if (note.info.n_namesz == 4 &&
   note.info.n_type == llvm::ELF::NT_GNU_BUILD_ID &&



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


[Lldb-commits] [lldb] [lldb] Fix loading UUIDs from ELF headers. (PR #117028)

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

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


[Lldb-commits] [lldb] [lldb] Fix loading UUIDs from ELF headers. (PR #117028)

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

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


[Lldb-commits] [libc] [lldb] [llvm] [mlir] [polly] Fix simple bugs (PR #117151)

2024-11-21 Thread Michael Jones via lldb-commits

michaelrj-google wrote:

Same for libc, the change looks good but it's easier to land as an individual 
PR. Feel free to @ me or add me as a reviewer and I'll approve that PR.

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


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

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

rocallahan wrote:

@jimingham I've implemented my proposal above. I added a test that 
`SBProcess::Continue()` preserves the reverse direction after stopping on a 
breakpoint. I also beefed up the conditional-breakpoint test to make a function 
call in the condition, which exercises the step-over-forward thread plan while 
the base direction is in reverse. Tests pass locally and I'll get someone to 
test Mac. Meanwhile I think this is ready for review again. Thanks!

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread Adrian Prantl via lldb-commits


@@ -144,9 +144,13 @@ lldb::ExpressionResults
 UserExpression::Evaluate(ExecutionContext &exe_ctx,
  const EvaluateExpressionOptions &options,
  llvm::StringRef expr, llvm::StringRef prefix,
- lldb::ValueObjectSP &result_valobj_sp, Status &error,
+ lldb::ValueObjectSP &result_valobj_sp,
  std::string *fixed_expression, ValueObject *ctx_obj) {
   Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
+  auto set_error = [&](Status error) {

adrian-prantl wrote:

ValueObject is the prime remaining user of long-lived Status objects, so it 
would be a purely cosmetic change.

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


[Lldb-commits] [lldb] [lldb] Fix index boundaries check, Change wrong int literal (PR #117226)

2024-11-21 Thread via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [DWARF] Fix DWARTTypePrinter unable to print qualified name for DW_TAG_typedef DIE (PR #117239)

2024-11-21 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu created 
https://github.com/llvm/llvm-project/pull/117239

Fix a bug introduced in https://github.com/llvm/llvm-project/pull/117071.

Ideally the DWARTTypePrinter test should go to 
`llvm/unittests/DebugInfo/DWARF/DWARTTypePrinterTest.cpp`.

>From 5ecdcda44c179d32e64fae33a03aa5086255ae22 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Thu, 21 Nov 2024 12:59:54 -0800
Subject: [PATCH] [DWARF] Fix DWARTTypePrinter unable to print qualified name
 for DW_TAG_typedef DIE

---
 .../SymbolFile/DWARF/DWARFDIETest.cpp | 48 ++-
 .../llvm/DebugInfo/DWARF/DWARFTypePrinter.h   |  1 +
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index ae63e286cc1551..3a03ed283a98d4 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -23,6 +23,26 @@ using namespace lldb_private;
 using namespace lldb_private::plugin::dwarf;
 using namespace lldb_private::dwarf;
 
+namespace {
+void Test_appendAndTerminateTemplateParameters(const DWARFDIE &die,
+   const std::string &expected) {
+  std::string template_name;
+  llvm::raw_string_ostream template_name_os(template_name);
+  llvm::DWARFTypePrinter template_name_printer(template_name_os);
+  template_name_printer.appendAndTerminateTemplateParameters(die);
+  EXPECT_THAT(template_name, expected);
+}
+
+void Test_appendQualifiedName(const DWARFDIE &die,
+  const std::string &expected) {
+  std::string qualified_name;
+  llvm::raw_string_ostream template_name_os(qualified_name);
+  llvm::DWARFTypePrinter template_name_printer(template_name_os);
+  template_name_printer.appendQualifiedName(die);
+  EXPECT_THAT(qualified_name, expected);
+}
+} // namespace
+
 TEST(DWARFDIETest, ChildIteration) {
   // Tests DWARFDIE::child_iterator.
 
@@ -466,6 +486,14 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
   Attributes:
 - Attribute:   DW_AT_type
   Form:DW_FORM_ref4
+- Code:0x8
+  Tag: DW_TAG_typedef
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_type
+  Form:DW_FORM_ref4
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
   debug_info:
 - Version: 4
   AddrSize:8
@@ -494,6 +522,10 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
 - AbbrCode:0x7
   Values:
 - Value:0x000c # update
+- AbbrCode:0x8
+  Values:
+- Value:0x000c
+- CStr:my_int
 - AbbrCode:0x0
 - AbbrCode:0x0)";
   YAMLModuleTester t(yamldata);
@@ -505,17 +537,7 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
   unit->Dump(&debug_os);
   ASSERT_TRUE(unit);
 
-  DWARFDIE t1_die = unit->GetDIE(0x11);
-  std::string template_name;
-  llvm::raw_string_ostream template_name_os(template_name);
-  llvm::DWARFTypePrinter template_name_printer(template_name_os);
-  template_name_printer.appendAndTerminateTemplateParameters(t1_die);
-  EXPECT_THAT(template_name, " >");
-
-  DWARFDIE t2_die = unit->GetDIE(0x1a);
-  std::string qualified_name;
-  llvm::raw_string_ostream qualified_name_os(qualified_name);
-  llvm::DWARFTypePrinter qualified_name_printer(qualified_name_os);
-  qualified_name_printer.appendQualifiedName(t2_die);
-  EXPECT_THAT(qualified_name, "t1 >::t2");
+  Test_appendAndTerminateTemplateParameters(unit->GetDIE(0x11), " >");
+  Test_appendQualifiedName(unit->GetDIE(0x1a), "t1 >::t2");
+  Test_appendQualifiedName(unit->GetDIE(0x28), "t3::my_int");
 }
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
index 962462b8278259..3c936b93865045 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
@@ -70,6 +70,7 @@ template  struct DWARFTypePrinter {
 case dwarf::DW_TAG_union_type:
 case dwarf::DW_TAG_namespace:
 case dwarf::DW_TAG_enumeration_type:
+case dwarf::DW_TAG_typedef:
   return true;
 default:
   break;

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


[Lldb-commits] [lldb] [llvm] [DWARF] Fix DWARTTypePrinter unable to print qualified name for DW_TAG_typedef DIE (PR #117239)

2024-11-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-debuginfo

Author: Zequan Wu (ZequanWu)


Changes

Fix a bug introduced in https://github.com/llvm/llvm-project/pull/117071.

Ideally the DWARTTypePrinter test should go to 
`llvm/unittests/DebugInfo/DWARF/DWARTTypePrinterTest.cpp`.

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


2 Files Affected:

- (modified) lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp (+35-13) 
- (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h (+1) 


``diff
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index ae63e286cc1551..3a03ed283a98d4 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -23,6 +23,26 @@ using namespace lldb_private;
 using namespace lldb_private::plugin::dwarf;
 using namespace lldb_private::dwarf;
 
+namespace {
+void Test_appendAndTerminateTemplateParameters(const DWARFDIE &die,
+   const std::string &expected) {
+  std::string template_name;
+  llvm::raw_string_ostream template_name_os(template_name);
+  llvm::DWARFTypePrinter template_name_printer(template_name_os);
+  template_name_printer.appendAndTerminateTemplateParameters(die);
+  EXPECT_THAT(template_name, expected);
+}
+
+void Test_appendQualifiedName(const DWARFDIE &die,
+  const std::string &expected) {
+  std::string qualified_name;
+  llvm::raw_string_ostream template_name_os(qualified_name);
+  llvm::DWARFTypePrinter template_name_printer(template_name_os);
+  template_name_printer.appendQualifiedName(die);
+  EXPECT_THAT(qualified_name, expected);
+}
+} // namespace
+
 TEST(DWARFDIETest, ChildIteration) {
   // Tests DWARFDIE::child_iterator.
 
@@ -466,6 +486,14 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
   Attributes:
 - Attribute:   DW_AT_type
   Form:DW_FORM_ref4
+- Code:0x8
+  Tag: DW_TAG_typedef
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_type
+  Form:DW_FORM_ref4
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
   debug_info:
 - Version: 4
   AddrSize:8
@@ -494,6 +522,10 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
 - AbbrCode:0x7
   Values:
 - Value:0x000c # update
+- AbbrCode:0x8
+  Values:
+- Value:0x000c
+- CStr:my_int
 - AbbrCode:0x0
 - AbbrCode:0x0)";
   YAMLModuleTester t(yamldata);
@@ -505,17 +537,7 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
   unit->Dump(&debug_os);
   ASSERT_TRUE(unit);
 
-  DWARFDIE t1_die = unit->GetDIE(0x11);
-  std::string template_name;
-  llvm::raw_string_ostream template_name_os(template_name);
-  llvm::DWARFTypePrinter template_name_printer(template_name_os);
-  template_name_printer.appendAndTerminateTemplateParameters(t1_die);
-  EXPECT_THAT(template_name, " >");
-
-  DWARFDIE t2_die = unit->GetDIE(0x1a);
-  std::string qualified_name;
-  llvm::raw_string_ostream qualified_name_os(qualified_name);
-  llvm::DWARFTypePrinter qualified_name_printer(qualified_name_os);
-  qualified_name_printer.appendQualifiedName(t2_die);
-  EXPECT_THAT(qualified_name, "t1 >::t2");
+  Test_appendAndTerminateTemplateParameters(unit->GetDIE(0x11), " >");
+  Test_appendQualifiedName(unit->GetDIE(0x1a), "t1 >::t2");
+  Test_appendQualifiedName(unit->GetDIE(0x28), "t3::my_int");
 }
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
index 962462b8278259..3c936b93865045 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
@@ -70,6 +70,7 @@ template  struct DWARFTypePrinter {
 case dwarf::DW_TAG_union_type:
 case dwarf::DW_TAG_namespace:
 case dwarf::DW_TAG_enumeration_type:
+case dwarf::DW_TAG_typedef:
   return true;
 default:
   break;

``




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


[Lldb-commits] [lldb] [lldb] Fix index boundaries check, Change wrong int literal (PR #117226)

2024-11-21 Thread Alex Langford via lldb-commits


@@ -3278,7 +3278,7 @@ bool 
AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
   }
 
   // If the index is still out of range then this isn't a pointer.
-  if (index > m_indexed_isa_cache.size())
+  if (index >= m_indexed_isa_cache.size())

bulbazord wrote:

This fixes this bound check, but there's the exact same bounds check above on 
line 3228. I don't see that mentioned in the blog post's analysis. From the 
comments above line 3228, that should be changed as well, no?

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


[Lldb-commits] [lldb] [llvm] [DWARF] Fix DWARTTypePrinter unable to print qualified name for DW_TAG_typedef DIE (PR #117239)

2024-11-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Zequan Wu (ZequanWu)


Changes

Fix a bug introduced in https://github.com/llvm/llvm-project/pull/117071.

Ideally the DWARTTypePrinter test should go to 
`llvm/unittests/DebugInfo/DWARF/DWARTTypePrinterTest.cpp`.

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


2 Files Affected:

- (modified) lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp (+35-13) 
- (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h (+1) 


``diff
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index ae63e286cc1551..3a03ed283a98d4 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -23,6 +23,26 @@ using namespace lldb_private;
 using namespace lldb_private::plugin::dwarf;
 using namespace lldb_private::dwarf;
 
+namespace {
+void Test_appendAndTerminateTemplateParameters(const DWARFDIE &die,
+   const std::string &expected) {
+  std::string template_name;
+  llvm::raw_string_ostream template_name_os(template_name);
+  llvm::DWARFTypePrinter template_name_printer(template_name_os);
+  template_name_printer.appendAndTerminateTemplateParameters(die);
+  EXPECT_THAT(template_name, expected);
+}
+
+void Test_appendQualifiedName(const DWARFDIE &die,
+  const std::string &expected) {
+  std::string qualified_name;
+  llvm::raw_string_ostream template_name_os(qualified_name);
+  llvm::DWARFTypePrinter template_name_printer(template_name_os);
+  template_name_printer.appendQualifiedName(die);
+  EXPECT_THAT(qualified_name, expected);
+}
+} // namespace
+
 TEST(DWARFDIETest, ChildIteration) {
   // Tests DWARFDIE::child_iterator.
 
@@ -466,6 +486,14 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
   Attributes:
 - Attribute:   DW_AT_type
   Form:DW_FORM_ref4
+- Code:0x8
+  Tag: DW_TAG_typedef
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_type
+  Form:DW_FORM_ref4
+- Attribute:   DW_AT_name
+  Form:DW_FORM_string
   debug_info:
 - Version: 4
   AddrSize:8
@@ -494,6 +522,10 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
 - AbbrCode:0x7
   Values:
 - Value:0x000c # update
+- AbbrCode:0x8
+  Values:
+- Value:0x000c
+- CStr:my_int
 - AbbrCode:0x0
 - AbbrCode:0x0)";
   YAMLModuleTester t(yamldata);
@@ -505,17 +537,7 @@ TEST(DWARFDIETest, TestDWARFTypePrinter) {
   unit->Dump(&debug_os);
   ASSERT_TRUE(unit);
 
-  DWARFDIE t1_die = unit->GetDIE(0x11);
-  std::string template_name;
-  llvm::raw_string_ostream template_name_os(template_name);
-  llvm::DWARFTypePrinter template_name_printer(template_name_os);
-  template_name_printer.appendAndTerminateTemplateParameters(t1_die);
-  EXPECT_THAT(template_name, " >");
-
-  DWARFDIE t2_die = unit->GetDIE(0x1a);
-  std::string qualified_name;
-  llvm::raw_string_ostream qualified_name_os(qualified_name);
-  llvm::DWARFTypePrinter qualified_name_printer(qualified_name_os);
-  qualified_name_printer.appendQualifiedName(t2_die);
-  EXPECT_THAT(qualified_name, "t1 >::t2");
+  Test_appendAndTerminateTemplateParameters(unit->GetDIE(0x11), " >");
+  Test_appendQualifiedName(unit->GetDIE(0x1a), "t1 >::t2");
+  Test_appendQualifiedName(unit->GetDIE(0x28), "t3::my_int");
 }
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
index 962462b8278259..3c936b93865045 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
@@ -70,6 +70,7 @@ template  struct DWARFTypePrinter {
 case dwarf::DW_TAG_union_type:
 case dwarf::DW_TAG_namespace:
 case dwarf::DW_TAG_enumeration_type:
+case dwarf::DW_TAG_typedef:
   return true;
 default:
   break;

``




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


[Lldb-commits] [lldb] [lldb] Fix incorrect nullptr check in DumpAddressAndContent (PR #117219)

2024-11-21 Thread Alex Langford via lldb-commits

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

makes sense

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


[Lldb-commits] [lldb] [lldb] Refactor UserExpression::Evaluate to only have one error channel. (PR #117186)

2024-11-21 Thread Adrian Prantl via lldb-commits

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

>From 208fa0afd563506c91afb320ff6cca4fa579c36a Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 21 Nov 2024 08:32:06 -0800
Subject: [PATCH] [lldb] Refactor UserExpression::Evaluate to only have one
 error channel.

Prior to this patch, the function returned an exit status, sometimes a
ValueObject with an error and a Status object. This patch removes the
Status object and ensures the error is consistently returned as the
error of the ValueObject.
---
 lldb/include/lldb/Expression/UserExpression.h | 10 ++-
 lldb/source/Expression/REPL.cpp   |  7 +-
 lldb/source/Expression/UserExpression.cpp | 64 +--
 .../TSan/InstrumentationRuntimeTSan.cpp   |  6 +-
 .../UBSan/InstrumentationRuntimeUBSan.cpp |  6 +-
 .../Utility/ReportRetriever.cpp   |  6 +-
 .../MemoryHistory/asan/MemoryHistoryASan.cpp  |  6 +-
 .../Plugins/Platform/POSIX/PlatformPOSIX.cpp  |  9 ++-
 .../Platform/Windows/PlatformWindows.cpp  |  7 +-
 lldb/source/Target/StopInfo.cpp   |  8 ++-
 lldb/source/Target/Target.cpp | 11 +---
 .../commands/expression/fixits/TestFixIts.py  |  2 +-
 12 files changed, 63 insertions(+), 79 deletions(-)

diff --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 7ce463d2cb4e7e..2fde73dafa035d 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -240,11 +240,9 @@ class UserExpression : public Expression {
   /// definitions to be included when the expression is parsed.
   ///
   /// \param[in,out] result_valobj_sp
-  ///  If execution is successful, the result valobj is placed here.
-  ///
-  /// \param[out] error
-  /// Filled in with an error in case the expression evaluation
-  /// fails to parse, run, or evaluated.
+  ///  If execution is successful, the result valobj is placed
+  ///  here. Otherwise its Error will contain an ExpressionError
+  ///  with details about the failure mode.
   ///
   /// \param[out] fixed_expression
   /// If non-nullptr, the fixed expression is copied into the provided
@@ -266,7 +264,7 @@ class UserExpression : public Expression {
   static lldb::ExpressionResults
   Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
llvm::StringRef expr_cstr, llvm::StringRef expr_prefix,
-   lldb::ValueObjectSP &result_valobj_sp, Status &error,
+   lldb::ValueObjectSP &result_valobj_sp,
std::string *fixed_expression = nullptr,
ValueObject *ctx_obj = nullptr);
 
diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index 56c50e346b39b8..4b53537e50e62a 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -339,12 +339,9 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, 
std::string &code) {
 
   const char *expr_prefix = nullptr;
   lldb::ValueObjectSP result_valobj_sp;
+  lldb::ExpressionResults execution_results = UserExpression::Evaluate(
+  exe_ctx, expr_options, code.c_str(), expr_prefix, result_valobj_sp);
   Status error;
-  lldb::ExpressionResults execution_results =
-  UserExpression::Evaluate(exe_ctx, expr_options, code.c_str(),
-   expr_prefix, result_valobj_sp, error,
-   nullptr); // fixed expression
-
   if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
   execution_results,
   result_valobj_sp, error)) {
diff --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index ed3734cbb943f6..f1f69ae1c89b85 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -144,9 +144,13 @@ lldb::ExpressionResults
 UserExpression::Evaluate(ExecutionContext &exe_ctx,
  const EvaluateExpressionOptions &options,
  llvm::StringRef expr, llvm::StringRef prefix,
- lldb::ValueObjectSP &result_valobj_sp, Status &error,
+ lldb::ValueObjectSP &result_valobj_sp,
  std::string *fixed_expression, ValueObject *ctx_obj) {
   Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
+  auto set_error = [&](Status error) {
+result_valobj_sp = ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), std::move(error));
+  };
 
   if (ctx_obj) {
 static unsigned const ctx_type_mask = lldb::TypeFlags::eTypeIsClass |
@@ -155,8 +159,7 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 if (!(ctx_obj->GetTypeInfo() & ctx_type_mask)) {
   LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a context

[Lldb-commits] [lldb] ba668eb - Re-apply [lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size as symbols are created (#117079)

2024-11-21 Thread via lldb-commits

Author: Alex Langford
Date: 2024-11-21T13:06:15-08:00
New Revision: ba668eb99c5dc37d3c5cf2775079562460fd7619

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

LOG: Re-apply [lldb] Do not use LC_FUNCTION_STARTS data to determine symbol 
size as symbols are created (#117079)

I backed this out due to a problem on one of the bots that myself and
others have problems reproducing locally. I'd like to try to land it
again, at least to gain more information.

Summary:
This improves the performance of ObjectFileMacho::ParseSymtab by
removing eager and expensive work in favor of doing it later in a
less-expensive fashion.

Experiment:
My goal was to understand LLDB's startup time.
First, I produced a Debug build of LLDB (no dSYM) and a
Release+NoAsserts build of LLDB. The Release build debugged the Debug
build as it debugged a small C++ program. I found that
ObjectFileMachO::ParseSymtab accounted for somewhere between 1.2 and 1.3
seconds consistently. After applying this change, I consistently
measured a reduction of approximately 100ms, putting the time closer to
1.1s and 1.2s on average.

Background:
ObjectFileMachO::ParseSymtab will incrementally create symbols by
parsing nlist entries from the symtab section of a MachO binary. As it
does this, it eagerly tries to determine the size of symbols (e.g. how
long a function is) using LC_FUNCTION_STARTS data (or eh_frame if
LC_FUNCTION_STARTS is unavailable). Concretely, this is done by
performing a binary search on the function starts array and calculating
the distance to the next function or the end of the section (whichever
is smaller).

However, this work is unnecessary for 2 reasons:
1. If you have debug symbol entries (i.e. STABs), the size of a function
is usually stored right after the function's entry. Performing this work
right before parsing the next entry is unnecessary work.
2. Calculating symbol sizes for symbols of size 0 is already performed
in `Symtab::InitAddressIndexes` after all the symbols are added to the
Symtab. It also does this more efficiently by walking over a list of
symbols sorted by address, so the work to calculate the size per symbol
is constant instead of O(log n).

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index b542e237f023d4..85edf4bd5494ae 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -3768,7 +3768,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
 
   SymbolType type = eSymbolTypeInvalid;
   SectionSP symbol_section;
-  lldb::addr_t symbol_byte_size = 0;
   bool add_nlist = true;
   bool is_gsym = false;
   bool demangled_is_synthesized = false;
@@ -4354,47 +4353,6 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
 
   if (symbol_section) {
 const addr_t section_file_addr = symbol_section->GetFileAddress();
-if (symbol_byte_size == 0 && function_starts_count > 0) {
-  addr_t symbol_lookup_file_addr = nlist.n_value;
-  // Do an exact address match for non-ARM addresses, else get the
-  // closest since the symbol might be a thumb symbol which has an
-  // address with bit zero set.
-  FunctionStarts::Entry *func_start_entry =
-  function_starts.FindEntry(symbol_lookup_file_addr, !is_arm);
-  if (is_arm && func_start_entry) {
-// Verify that the function start address is the symbol address
-// (ARM) or the symbol address + 1 (thumb).
-if (func_start_entry->addr != symbol_lookup_file_addr &&
-func_start_entry->addr != (symbol_lookup_file_addr + 1)) {
-  // Not the right entry, NULL it out...
-  func_start_entry = nullptr;
-}
-  }
-  if (func_start_entry) {
-func_start_entry->data = true;
-
-addr_t symbol_file_addr = func_start_entry->addr;
-if (is_arm)
-  symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
-
-const FunctionStarts::Entry *next_func_start_entry =
-function_starts.FindNextEntry(func_start_entry);
-const addr_t section_end_file_addr =
-section_file_addr + symbol_section->GetByteSize();
-if (next_func_start_entry) {
-  addr_t next_symbol_file_addr = next_func_start_entry->addr;
-  // Be sure the clear the Thumb address bit when we calculate the
-  // size from the current and next address
-  if (is_arm)
-next_symbol_file_addr &= THUMB_AD

[Lldb-commits] [lldb] Re-apply [lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size as symbols are created (PR #117079)

2024-11-21 Thread Alex Langford via lldb-commits

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


  1   2   >