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

2024-11-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

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.

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


3 Files Affected:

- (modified) lldb/source/Symbol/Block.cpp (+10-9) 
- (modified) lldb/source/Symbol/SymbolContext.cpp (+6-4) 
- (added) lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-inline-function.s 
(+167) 


``diff
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 different
+## 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)[0x0005-0x0007), name = "foo_inl"
+
+.text
+
+.type   foo,@function
+foo:
+nop
+.Lfoo_inl:
+nop
+.Lfoo_inl_end:
+nop
+.Lfoo_end:
+.size   foo, .Lfoo_end-foo
+
+bar:
+nop
+.Lbar_end:
+.size   bar,

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

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

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/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.

>From 3ef511cd16a85516c12270919c4a19591ab76e13 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 19 Nov 2024 10:50:42 +0100
Subject: [PATCH] [lldb] Fix inline function resolution for discontinuous
 functions

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.
---
 lldb/source/Symbol/Block.cpp  |  19 +-
 lldb/source/Symbol/SymbolContext.cpp  |  10 +-
 .../DWARF/x86/discontinuous-inline-function.s | 167 ++
 3 files changed, 183 insertions(+), 13 deletions(-)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-inline-function.s

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 different
+## 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 

[Lldb-commits] [lldb] dd78d7c - [lldb] Improve editline completion formatting (#116456)

2024-11-19 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-11-19T10:46:57-08:00
New Revision: dd78d7c7be5b8948cf5841e8033e59adebf230ad

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

LOG: [lldb] Improve editline completion formatting (#116456)

This patch improves the formatting of editline completions. The current
implementation is naive and doesn't account for the terminal width.

Concretely, the old implementation suffered from the following issues:

- We would unconditionally pad to the longest completion. If that
completion exceeds the width of the terminal, that would result in a lot
of superfluous white space and line wrapping.
- When printing the description, we wouldn't account for the presence of
newlines, and they would continue without leading padding.

The new code accounts for both. If the completion exceeds the available
terminal width, we show what fits on the current lined followed by
ellipsis. We also no longer pad beyond the length of the current line.
Finally, we print the description line by line, with the proper leading
padding. If a line of the description exceeds the available terminal
width, we print ellipsis and won't print the next line.

Before:

```
Available completions:
_regexp-attach-- Attach to process by ID or name.
_regexp-break -- Set a breakpoint using one of several shorthand
 formats.
_regexp-bt-- Show backtrace of the current thread's call sta
ck. Any numeric argument displays at most that many frames. The argument 'al
l' displays all threads. Use 'settings set frame-format' to customize the pr
inting of individual frames and 'settings set thread-format' to customize th
e thread header. Frame recognizers may filter thelist. Use 'thread backtrace
 -u (--unfiltered)' to see them all.
_regexp-display   -- Evaluate an expression at every stop (see 'help
 target stop-hook'.)

```

After:
```
 Available completions:
_regexp-attach-- Attach to process by ID or name.
_regexp-break -- Set a breakpoint using one of several shorth...
_regexp-bt-- Show backtrace of the current thread's call ...
_regexp-display   -- Evaluate an expression at every stop (see 'h...
```

rdar://135818198

Added: 
lldb/test/API/terminal/TestEditlineCompletions.py

Modified: 
lldb/include/lldb/Host/Editline.h
lldb/source/Host/common/Editline.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index 57e2c831e3499d..e8e8a6c0d4f67e 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -238,6 +238,8 @@ class Editline {
   /// Convert the current input lines into a UTF8 StringList
   StringList GetInputAsStringList(int line_count = UINT32_MAX);
 
+  size_t GetTerminalWidth() { return m_terminal_width; }
+
 private:
   /// Sets the lowest line number for multi-line editing sessions.  A value of
   /// zero suppresses line number printing in the prompt.

diff  --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index f95f854c5f220c..1dc1c3fc180848 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -927,12 +927,86 @@ unsigned char Editline::BufferEndCommand(int ch) {
 static void
 PrintCompletion(FILE *output_file,
 llvm::ArrayRef results,
-size_t max_len) {
+size_t max_completion_length, size_t max_length) {
+  constexpr size_t ellipsis_length = 3;
+  constexpr size_t padding_length = 8;
+  constexpr size_t separator_length = 4;
+
+  const size_t description_col =
+  std::min(max_completion_length + padding_length, max_length);
+
   for (const CompletionResult::Completion &c : results) {
-fprintf(output_file, "\t%-*s", (int)max_len, c.GetCompletion().c_str());
-if (!c.GetDescription().empty())
-  fprintf(output_file, " -- %s", c.GetDescription().c_str());
-fprintf(output_file, "\n");
+if (c.GetCompletion().empty())
+  continue;
+
+// Print the leading padding.
+fprintf(output_file, "");
+
+// Print the completion with trailing padding to the description column if
+// that fits on the screen. Otherwise print whatever fits on the screen
+// followed by ellipsis.
+const size_t completion_length = c.GetCompletion().size();
+if (padding_length + completion_length < max_length) {
+  fprintf(output_file, "%-*s",
+  static_cast(description_col - padding_length),
+  c.GetCompletion().c_str());
+} else {
+  // If the completion doesn't fit on the screen, print ellipsis and don't
+  // bother with the description.
+  fprintf(output_file, "%.*s...\n\n",
+  static_cast(max_length - padd

[Lldb-commits] [lldb] [lldb] Improve editline completion formatting (PR #116456)

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

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


[Lldb-commits] [lldb] [lldb] Refactor helper by using iterators and in-place edits (NFC) (PR #116876)

2024-11-19 Thread Felipe de Azevedo Piovezan via lldb-commits

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

This is even better than the original suggestion!

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


[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

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


@@ -130,6 +131,25 @@ void RenderDiagnosticDetails(Stream &stream,
   }
   stream << '\n';
 
+  // Reverse the order within groups of diagnostics that are on the same 
column.
+  auto group = [](const std::vector &details) {
+uint16_t column = 0;
+std::vector result, group;
+for (auto &d : details) {
+  if (d.source_location->column == column) {
+group.push_back(d);
+continue;
+  }
+  result.insert(result.end(), group.rbegin(), group.rend());
+  group.clear();
+  column = d.source_location->column;
+  group.push_back(d);
+}
+result.insert(result.end(), group.rbegin(), group.rend());
+return result;
+  };
+  remaining_details = group(remaining_details);
+

adrian-prantl wrote:

I can still make the change.

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


[Lldb-commits] [lldb] 5681f75 - Fix broken link

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

Author: Adrian Prantl
Date: 2024-11-19T13:01:08-08:00
New Revision: 5681f756c058204d7e41d065f91c5f3c36a434a7

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

LOG: Fix broken link

Added: 


Modified: 
lldb/docs/use/links.rst

Removed: 




diff  --git a/lldb/docs/use/links.rst b/lldb/docs/use/links.rst
index 88eefb4cadd894..c9e29ed78a2199 100644
--- a/lldb/docs/use/links.rst
+++ b/lldb/docs/use/links.rst
@@ -16,8 +16,8 @@ code.
 Videos
 --
 
-`Run, Break, Inspect: Explore effective debugging in LLDB`_
-~~~
+`Run, Break, Inspect: Explore effective debugging in LLDB (2024)`_
+~~
 
 Learn how to use LLDB to explore and debug codebases. We'll show you
 how to make the most of crashlogs and backtraces, and how to
@@ -65,7 +65,7 @@ iOS apps.
 A collection of LLDB aliases/regexes and Python scripts.
 
 .. _Dancing in the Debugger — A Waltz with LLDB (2014): 
https://www.objc.io/issues/19-debugging/lldb-debugging/
-.. _Run, Break, Inspect: Explore effective debugging in LLDB: 
https://developer.apple.com/videos/play/wwdc2024/10198
+.. _`Run, Break, Inspect: Explore effective debugging in LLDB (2024)`: 
https://developer.apple.com/videos/play/wwdc2024/10198
 .. _`LLDB: Beyond “po” (2019)`: 
https://developer.apple.com/videos/play/wwdc2019/429/
 .. _Advanced Debugging with Xcode and LLDB (2018): 
https://developer.apple.com/videos/play/wwdc2018/412/
 .. _Advanced Apple Debugging & Reverse Engineering (2018): 
https://www.raywenderlich.com/books/advanced-apple-debugging-reverse-engineering/



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


[Lldb-commits] [lldb] 174899f - [lldb] Refactor helper by using iterators and in-place edits (NFC) (#116876)

2024-11-19 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-11-19T13:02:47-08:00
New Revision: 174899f738b31216750ac59562475966b0b0be42

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

LOG: [lldb] Refactor helper by using iterators and in-place edits (NFC) 
(#116876)

Based on post-commit review feedback by Felipe Piovezan!

Added: 


Modified: 
lldb/source/Utility/DiagnosticsRendering.cpp

Removed: 




diff  --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index a20d82ad4eb678..f5aa27baadfef8 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -132,23 +132,16 @@ void RenderDiagnosticDetails(Stream &stream,
   stream << '\n';
 
   // Reverse the order within groups of diagnostics that are on the same 
column.
-  auto group = [](const std::vector &details) {
-uint16_t column = 0;
-std::vector result, group;
-for (auto &d : details) {
-  if (d.source_location->column == column) {
-group.push_back(d);
-continue;
-  }
-  result.insert(result.end(), group.rbegin(), group.rend());
-  group.clear();
-  column = d.source_location->column;
-  group.push_back(d);
+  auto group = [](std::vector &details) {
+for (auto it = details.begin(), end = details.end(); it != end;) {
+  auto eq_end = std::find_if(it, end, [&](const DiagnosticDetail &d) {
+return d.source_location->column != it->source_location->column;
+  });
+  std::reverse(it, eq_end);
+  it = eq_end;
 }
-result.insert(result.end(), group.rbegin(), group.rend());
-return result;
   };
-  remaining_details = group(remaining_details);
+  group(remaining_details);
 
   // Work through each detail in reverse order using the vector/stack.
   bool did_print = false;



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


[Lldb-commits] [lldb] [lldb] Refactor helper by using iterators and in-place edits (NFC) (PR #116876)

2024-11-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

Based on post-commit review feedback by Felipe Piovezan!

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


1 Files Affected:

- (modified) lldb/source/Utility/DiagnosticsRendering.cpp (+8-15) 


``diff
diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index a20d82ad4eb678..f5aa27baadfef8 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -132,23 +132,16 @@ void RenderDiagnosticDetails(Stream &stream,
   stream << '\n';
 
   // Reverse the order within groups of diagnostics that are on the same 
column.
-  auto group = [](const std::vector &details) {
-uint16_t column = 0;
-std::vector result, group;
-for (auto &d : details) {
-  if (d.source_location->column == column) {
-group.push_back(d);
-continue;
-  }
-  result.insert(result.end(), group.rbegin(), group.rend());
-  group.clear();
-  column = d.source_location->column;
-  group.push_back(d);
+  auto group = [](std::vector &details) {
+for (auto it = details.begin(), end = details.end(); it != end;) {
+  auto eq_end = std::find_if(it, end, [&](const DiagnosticDetail &d) {
+return d.source_location->column != it->source_location->column;
+  });
+  std::reverse(it, eq_end);
+  it = eq_end;
 }
-result.insert(result.end(), group.rbegin(), group.rend());
-return result;
   };
-  remaining_details = group(remaining_details);
+  group(remaining_details);
 
   // Work through each detail in reverse order using the vector/stack.
   bool did_print = false;

``




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


[Lldb-commits] [lldb] [lldb] Fix comment in ~Thread (NFC) (PR #116850)

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

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

None

>From f7462578ac8e5977310279ea8f9f01f01bbcedcd Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Mon, 18 Nov 2024 16:21:18 -0800
Subject: [PATCH] [lldb] Fix comment in ~Thread (NFC)

---
 lldb/source/Target/Thread.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 735295e6f25937..fb17276051909c 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -244,7 +244,7 @@ Thread::~Thread() {
   LLDB_LOGF(log, "%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")",
 static_cast(this), GetID());
   /// If you hit this assert, it means your derived class forgot to call
-  /// DoDestroy in its destructor.
+  /// DestroyThread in its destructor.
   assert(m_destroy_called);
 }
 

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


[Lldb-commits] [lldb] [lldb] Refactor helper by using iterators and in-place edits (NFC) (PR #116876)

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

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

Based on post-commit review feedback by Felipe Piovezan!

>From 60d427280f59fdca843332cefa03d960d0fb6587 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 19 Nov 2024 12:51:50 -0800
Subject: [PATCH] [lldb] Refactor helper by using iterators and in-place edits
 (NFC)

Based on post-commit review feedback by Felipe Piovezan!
---
 lldb/source/Utility/DiagnosticsRendering.cpp | 23 +++-
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index a20d82ad4eb678..f5aa27baadfef8 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -132,23 +132,16 @@ void RenderDiagnosticDetails(Stream &stream,
   stream << '\n';
 
   // Reverse the order within groups of diagnostics that are on the same 
column.
-  auto group = [](const std::vector &details) {
-uint16_t column = 0;
-std::vector result, group;
-for (auto &d : details) {
-  if (d.source_location->column == column) {
-group.push_back(d);
-continue;
-  }
-  result.insert(result.end(), group.rbegin(), group.rend());
-  group.clear();
-  column = d.source_location->column;
-  group.push_back(d);
+  auto group = [](std::vector &details) {
+for (auto it = details.begin(), end = details.end(); it != end;) {
+  auto eq_end = std::find_if(it, end, [&](const DiagnosticDetail &d) {
+return d.source_location->column != it->source_location->column;
+  });
+  std::reverse(it, eq_end);
+  it = eq_end;
 }
-result.insert(result.end(), group.rbegin(), group.rend());
-return result;
   };
-  remaining_details = group(remaining_details);
+  group(remaining_details);
 
   // Work through each detail in reverse order using the vector/stack.
   bool did_print = false;

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


[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

2024-11-19 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -130,6 +131,25 @@ void RenderDiagnosticDetails(Stream &stream,
   }
   stream << '\n';
 
+  // Reverse the order within groups of diagnostics that are on the same 
column.
+  auto group = [](const std::vector &details) {
+uint16_t column = 0;
+std::vector result, group;
+for (auto &d : details) {
+  if (d.source_location->column == column) {
+group.push_back(d);
+continue;
+  }
+  result.insert(result.end(), group.rbegin(), group.rend());
+  group.clear();
+  column = d.source_location->column;
+  group.push_back(d);
+}
+result.insert(result.end(), group.rbegin(), group.rend());
+return result;
+  };
+  remaining_details = group(remaining_details);
+

felipepiovezan wrote:

I think this is way more complicated than it should be, and it is one of those 
rare cases where iterators are very helpful:
```
  auto group = [](llvm::ArrayRef details) {
std::vector result;
for (auto it = details.begin(), end = details.end(); it != end;) {
  auto eq_end = std::find_if(it, end, [&](const DiagnosticDetail &d) {
return d.source_location->column != it->source_location->column;
  });
  std::reverse_copy(it, eq_end, std::back_inserter(result));
  it = eq_end;
}
return result;
  };
```

https://github.com/llvm/llvm-project/pull/116727
___
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-19 Thread via lldb-commits

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

>From d16492dc12891cf15e41225abff890462c9f8460 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 ad332d25d9c082..862a6820569f7a 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -432,6 +432,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] [lldb] Reword the "line 0" warning (PR #116827)

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

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

We got a bug report that this message is confusing.  In this particular case, 
the line zero was due to compiler tail merging (in optimized code). The main 
issue was the "no source code" part: in this case it's kind of incorrect 
because -- even though we can't really know that -- the address is arguably 
associated with *multiple* lines of source code.

I've tried to make the new wording more neutral, and added a wink towards 
compiler optimizations. I left out the "compiler generated" part of the message 
because I couldn't find a way to squeeze that in nicely. I'm also not entirely 
sure what it was referring to -- if this was (just) function prologue/epilogue, 
then maybe leaving it out is fine, as we're not likely to stop there anyway (?)

I also left out the function name, because:
- for template functions it gets rather long
- it's already present in the message, potentially twice (once in the "frame 
summary" line and once in the snippet of code we show for the function 
declaration)

>From 59f306aed0736a861f5d084f6e203337234bfb96 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 19 Nov 2024 17:03:48 +0100
Subject: [PATCH] [lldb] Reword the "line 0" warning

We got a bug report that this message is confusing.  In this particular
case, the line zero was due to compiler tail merging (in optimized
code). The main issue was the "no source code" part: in this case it's
kind of incorrect because -- even though we can't really know that --
the address is arguably associated with *multiple* lines of source code.

I've tried to make the new wording more neutral, and added a wink
towards compiler optimizations. I left out the "compiler generated" part
of the message because I couldn't find a way to squeeze that in nicely.
I'm also not entirely sure what it was referring to -- if this was
(just) function prologue/epilogue, then maybe leaving it out is fine, as
we're not likely to stop there anyway (?)

I also left out the function name, because:
- for template functions it gets rather long
- it's already present in the message, potentially twice (once in the
  "frame summary" line and once in the snippet of code we show for the
  function declaration)
---
 lldb/source/Target/StackFrame.cpp| 16 +++-
 .../test/API/source-manager/TestSourceManager.py |  4 ++--
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index 1bca9786fb7c70..ece85a077385ed 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -2007,19 +2007,9 @@ bool StackFrame::GetStatus(Stream &strm, bool 
show_frame_info, bool show_source,
   if (num_lines != 0)
 have_source = true;
   // TODO: Give here a one time warning if source file is missing.
-  if (!m_sc.line_entry.line) {
-ConstString fn_name = m_sc.GetFunctionName();
-
-if (!fn_name.IsEmpty())
-  strm.Printf(
-  "Note: this address is compiler-generated code in function "
-  "%s that has no source code associated with it.",
-  fn_name.AsCString());
-else
-  strm.Printf("Note: this address is compiler-generated code that "
-  "has no source code associated with it.");
-strm.EOL();
-  }
+  if (!m_sc.line_entry.line)
+strm << "Note: This address is not associated with a specific line 
"
+"of code. This may be due to compiler optimizations.\n";
 }
   }
   switch (disasm_display) {
diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index 7071f094e20f7e..ca415626f0d74c 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -336,8 +336,8 @@ def test_artificial_source_location(self):
 "stop reason = breakpoint",
 f"{src_file}:0",
 "static int foo();",
-"Note: this address is compiler-generated code in function",
-"that has no source code associated with it.",
+"Note: This address is not associated with a specific line "
+"of code. This may be due to compiler optimizations."
 ],
 )
 

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


[Lldb-commits] [lldb] [lldb] Reword the "line 0" warning (PR #116827)

2024-11-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

We got a bug report that this message is confusing.  In this particular case, 
the line zero was due to compiler tail merging (in optimized code). The main 
issue was the "no source code" part: in this case it's kind of incorrect 
because -- even though we can't really know that -- the address is arguably 
associated with *multiple* lines of source code.

I've tried to make the new wording more neutral, and added a wink towards 
compiler optimizations. I left out the "compiler generated" part of the message 
because I couldn't find a way to squeeze that in nicely. I'm also not entirely 
sure what it was referring to -- if this was (just) function prologue/epilogue, 
then maybe leaving it out is fine, as we're not likely to stop there anyway (?)

I also left out the function name, because:
- for template functions it gets rather long
- it's already present in the message, potentially twice (once in the "frame 
summary" line and once in the snippet of code we show for the function 
declaration)

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


2 Files Affected:

- (modified) lldb/source/Target/StackFrame.cpp (+3-13) 
- (modified) lldb/test/API/source-manager/TestSourceManager.py (+2-2) 


``diff
diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index 1bca9786fb7c70..ece85a077385ed 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -2007,19 +2007,9 @@ bool StackFrame::GetStatus(Stream &strm, bool 
show_frame_info, bool show_source,
   if (num_lines != 0)
 have_source = true;
   // TODO: Give here a one time warning if source file is missing.
-  if (!m_sc.line_entry.line) {
-ConstString fn_name = m_sc.GetFunctionName();
-
-if (!fn_name.IsEmpty())
-  strm.Printf(
-  "Note: this address is compiler-generated code in function "
-  "%s that has no source code associated with it.",
-  fn_name.AsCString());
-else
-  strm.Printf("Note: this address is compiler-generated code that "
-  "has no source code associated with it.");
-strm.EOL();
-  }
+  if (!m_sc.line_entry.line)
+strm << "Note: This address is not associated with a specific line 
"
+"of code. This may be due to compiler optimizations.\n";
 }
   }
   switch (disasm_display) {
diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index 7071f094e20f7e..ca415626f0d74c 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -336,8 +336,8 @@ def test_artificial_source_location(self):
 "stop reason = breakpoint",
 f"{src_file}:0",
 "static int foo();",
-"Note: this address is compiler-generated code in function",
-"that has no source code associated with it.",
+"Note: This address is not associated with a specific line "
+"of code. This may be due to compiler optimizations."
 ],
 )
 

``




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


[Lldb-commits] [lldb] [llvm] [DebugInfo] Add explicit visibility macros to CodeView template functions (PR #113102)

2024-11-19 Thread Saleem Abdulrasool via lldb-commits


@@ -32,6 +32,19 @@ class SimpleTypeSerializer {
   ArrayRef serialize(const FieldListRecord &Record) = delete;
 };
 
+// Needed by RandomAccessVisitorTest.cpp
+#define TYPE_RECORD(EnumName, EnumVal, Name)   
\
+  class Name##Record;  
\
+  extern template LLVM_TEMPLATE_ABI ArrayRef  
\
+  llvm::codeview::SimpleTypeSerializer::serialize(Name##Record &Record);
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name)
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+#undef TYPE_RECORD
+#undef TYPE_RECORD_ALIAS
+#undef MEMBER_RECORD
+#undef MEMBER_RECORD_ALIAS

compnerd wrote:

Likewise

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


[Lldb-commits] [lldb] [llvm] [DebugInfo] Add explicit visibility macros to CodeView template functions (PR #113102)

2024-11-19 Thread Saleem Abdulrasool via lldb-commits


@@ -495,7 +495,8 @@ class ClassRecord : public TagRecord {
 };
 
 // LF_UNION
-struct UnionRecord : public TagRecord {
+class UnionRecord : public TagRecord {
+public:

compnerd wrote:

Why the change here? The use of `struct` _should_ be fine. Or was it that there 
was a conflict with the declaration from the XMACRO?

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


[Lldb-commits] [lldb] e3ff649 - [lldb] Fix comment in ~Thread (NFC) (#116850)

2024-11-19 Thread via lldb-commits

Author: Dave Lee
Date: 2024-11-19T13:42:51-08:00
New Revision: e3ff649abe975c04aa179622c6f4757e7aa66aaf

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

LOG: [lldb] Fix comment in ~Thread (NFC) (#116850)

Added: 


Modified: 
lldb/source/Target/Thread.cpp

Removed: 




diff  --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 735295e6f25937..fb17276051909c 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -244,7 +244,7 @@ Thread::~Thread() {
   LLDB_LOGF(log, "%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")",
 static_cast(this), GetID());
   /// If you hit this assert, it means your derived class forgot to call
-  /// DoDestroy in its destructor.
+  /// DestroyThread in its destructor.
   assert(m_destroy_called);
 }
 



___
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-19 Thread via lldb-commits

https://github.com/Sirraide commented:

The main thing I’m concerned about here is that I feel like there ought to be a 
better way of doing this than checking for and disallowing it in every place 
where we can have a subexpression in C.

CC @AaronBallman for opinions on this.

Also, if we’re doing it this way, then the check should definitely be factored 
out into a function in `Sema`.

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] Reword the "line 0" warning (PR #116827)

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

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

>From 02637dab316797b0bf6440b549497bf59db2d3c7 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 19 Nov 2024 17:03:48 +0100
Subject: [PATCH 1/3] [lldb] Reword the "line 0" warning

We got a bug report that this message is confusing.  In this particular
case, the line zero was due to compiler tail merging (in optimized
code). The main issue was the "no source code" part: in this case it's
kind of incorrect because -- even though we can't really know that --
the address is arguably associated with *multiple* lines of source code.

I've tried to make the new wording more neutral, and added a wink
towards compiler optimizations. I left out the "compiler generated" part
of the message because I couldn't find a way to squeeze that in nicely.
I'm also not entirely sure what it was referring to -- if this was
(just) function prologue/epilogue, then maybe leaving it out is fine, as
we're not likely to stop there anyway (?)

I also left out the function name, because:
- for template functions it gets rather long
- it's already present in the message, potentially twice (once in the
  "frame summary" line and once in the snippet of code we show for the
  function declaration)
---
 lldb/source/Target/StackFrame.cpp| 16 +++-
 .../test/API/source-manager/TestSourceManager.py |  4 ++--
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index 1bca9786fb7c70..ece85a077385ed 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -2007,19 +2007,9 @@ bool StackFrame::GetStatus(Stream &strm, bool 
show_frame_info, bool show_source,
   if (num_lines != 0)
 have_source = true;
   // TODO: Give here a one time warning if source file is missing.
-  if (!m_sc.line_entry.line) {
-ConstString fn_name = m_sc.GetFunctionName();
-
-if (!fn_name.IsEmpty())
-  strm.Printf(
-  "Note: this address is compiler-generated code in function "
-  "%s that has no source code associated with it.",
-  fn_name.AsCString());
-else
-  strm.Printf("Note: this address is compiler-generated code that "
-  "has no source code associated with it.");
-strm.EOL();
-  }
+  if (!m_sc.line_entry.line)
+strm << "Note: This address is not associated with a specific line 
"
+"of code. This may be due to compiler optimizations.\n";
 }
   }
   switch (disasm_display) {
diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index 7071f094e20f7e..7d239ddb6acbd9 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -336,8 +336,8 @@ def test_artificial_source_location(self):
 "stop reason = breakpoint",
 f"{src_file}:0",
 "static int foo();",
-"Note: this address is compiler-generated code in function",
-"that has no source code associated with it.",
+"Note: This address is not associated with a specific line "
+"of code. This may be due to compiler optimizations.",
 ],
 )
 

>From b57514d3389b6915da8af82c5d1f4e96212cfc0d Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 20 Nov 2024 08:54:36 +0100
Subject: [PATCH 2/3] Update TestSourceManager.py

---
 lldb/test/API/source-manager/TestSourceManager.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index 7d239ddb6acbd9..7d9ce86cdc353a 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -336,7 +336,7 @@ def test_artificial_source_location(self):
 "stop reason = breakpoint",
 f"{src_file}:0",
 "static int foo();",
-"Note: This address is not associated with a specific line "
+"note: This address is not associated with a specific line "
 "of code. This may be due to compiler optimizations.",
 ],
 )

>From 5d78fd9e5450108be2f42803ee3a79cccda191cb Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 20 Nov 2024 08:54:48 +0100
Subject: [PATCH 3/3] Update lldb/source/Target/StackFrame.cpp

Co-authored-by: Jonas Devlieghere 
---
 lldb/source/Target/StackFrame.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index ece85a077385ed..ca02de15295cac 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/

[Lldb-commits] [lldb] [lldb] Reword the "line 0" warning (PR #116827)

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

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

>From 02637dab316797b0bf6440b549497bf59db2d3c7 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 19 Nov 2024 17:03:48 +0100
Subject: [PATCH 1/2] [lldb] Reword the "line 0" warning

We got a bug report that this message is confusing.  In this particular
case, the line zero was due to compiler tail merging (in optimized
code). The main issue was the "no source code" part: in this case it's
kind of incorrect because -- even though we can't really know that --
the address is arguably associated with *multiple* lines of source code.

I've tried to make the new wording more neutral, and added a wink
towards compiler optimizations. I left out the "compiler generated" part
of the message because I couldn't find a way to squeeze that in nicely.
I'm also not entirely sure what it was referring to -- if this was
(just) function prologue/epilogue, then maybe leaving it out is fine, as
we're not likely to stop there anyway (?)

I also left out the function name, because:
- for template functions it gets rather long
- it's already present in the message, potentially twice (once in the
  "frame summary" line and once in the snippet of code we show for the
  function declaration)
---
 lldb/source/Target/StackFrame.cpp| 16 +++-
 .../test/API/source-manager/TestSourceManager.py |  4 ++--
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index 1bca9786fb7c70..ece85a077385ed 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -2007,19 +2007,9 @@ bool StackFrame::GetStatus(Stream &strm, bool 
show_frame_info, bool show_source,
   if (num_lines != 0)
 have_source = true;
   // TODO: Give here a one time warning if source file is missing.
-  if (!m_sc.line_entry.line) {
-ConstString fn_name = m_sc.GetFunctionName();
-
-if (!fn_name.IsEmpty())
-  strm.Printf(
-  "Note: this address is compiler-generated code in function "
-  "%s that has no source code associated with it.",
-  fn_name.AsCString());
-else
-  strm.Printf("Note: this address is compiler-generated code that "
-  "has no source code associated with it.");
-strm.EOL();
-  }
+  if (!m_sc.line_entry.line)
+strm << "Note: This address is not associated with a specific line 
"
+"of code. This may be due to compiler optimizations.\n";
 }
   }
   switch (disasm_display) {
diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index 7071f094e20f7e..7d239ddb6acbd9 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -336,8 +336,8 @@ def test_artificial_source_location(self):
 "stop reason = breakpoint",
 f"{src_file}:0",
 "static int foo();",
-"Note: this address is compiler-generated code in function",
-"that has no source code associated with it.",
+"Note: This address is not associated with a specific line "
+"of code. This may be due to compiler optimizations.",
 ],
 )
 

>From b57514d3389b6915da8af82c5d1f4e96212cfc0d Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 20 Nov 2024 08:54:36 +0100
Subject: [PATCH 2/2] Update TestSourceManager.py

---
 lldb/test/API/source-manager/TestSourceManager.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index 7d239ddb6acbd9..7d9ce86cdc353a 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -336,7 +336,7 @@ def test_artificial_source_location(self):
 "stop reason = breakpoint",
 f"{src_file}:0",
 "static int foo();",
-"Note: This address is not associated with a specific line "
+"note: This address is not associated with a specific line "
 "of code. This may be due to compiler optimizations.",
 ],
 )

___
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-19 Thread Bill Wendling via lldb-commits

bwendling wrote:

I removed the Placeholder code. It's a much smaller patch and has the better 
timing profile. PTAL.

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] Add an API to derive language-specific runtime information (PR #116904)

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

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

This is motivated by exposing some Swift language-specific flags through the 
API, in the example here it is used to communicate the Objective-C runtime 
version. This could also be a meaningful extension point to get information 
about "embedded: languages, such as extracting the C++ version in an 
Objective-C++ frame or something along those lines.

>From 776f10f61603e922bdc38962836583da42e4f650 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 19 Nov 2024 17:30:10 -0800
Subject: [PATCH] [lldb] Add an API to derive language-specific runtime
 information

This is motivated by exposing some Swift language-specific flags
through the API, in the example here it is used to communicate the
Objective-C runtime version. This could also be a meaningful extension
point to get information about "embedded: languages, such as
extracting the C++ version in an Objective-C++ frame or something
along those lines.
---
 lldb/include/lldb/API/SBFrame.h|  5 +
 lldb/include/lldb/API/SBStructuredData.h   |  1 +
 lldb/include/lldb/Target/LanguageRuntime.h |  5 +
 lldb/include/lldb/Target/StackFrame.h  |  6 ++
 lldb/source/API/SBFrame.cpp| 16 
 .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp|  7 +++
 .../ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h |  2 ++
 lldb/source/Target/LanguageRuntime.cpp |  4 
 lldb/source/Target/StackFrame.cpp  | 13 +
 lldb/test/API/lang/objc/languageinfo/Makefile  |  4 
 .../objc/languageinfo/TestObjCLanguageInfo.py  | 18 ++
 lldb/test/API/lang/objc/languageinfo/main.m|  1 +
 12 files changed, 82 insertions(+)
 create mode 100644 lldb/test/API/lang/objc/languageinfo/Makefile
 create mode 100644 lldb/test/API/lang/objc/languageinfo/TestObjCLanguageInfo.py
 create mode 100644 lldb/test/API/lang/objc/languageinfo/main.m

diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index e0d15c3ecc5b1c..e1ff217767cb98 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -122,6 +122,11 @@ class LLDB_API SBFrame {
   lldb::SBValue EvaluateExpression(const char *expr,
const SBExpressionOptions &options);
 
+  /// Language plugins can use this API to report language-specific
+  /// runtime information about this compile unit, such as additional
+  /// language version details or feature flags.
+  SBStructuredData GetLanguageInfo();
+
   /// Gets the lexical block that defines the stack frame. Another way to think
   /// of this is it will return the block that contains all of the variables
   /// for a stack frame. Inlined functions are represented as SBBlock objects
diff --git a/lldb/include/lldb/API/SBStructuredData.h 
b/lldb/include/lldb/API/SBStructuredData.h
index ccdd12cab94b2f..c0d214a7374c65 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -114,6 +114,7 @@ class SBStructuredData {
   friend class SBCommandReturnObject;
   friend class SBLaunchInfo;
   friend class SBDebugger;
+  friend class SBFrame;
   friend class SBTarget;
   friend class SBProcess;
   friend class SBThread;
diff --git a/lldb/include/lldb/Target/LanguageRuntime.h 
b/lldb/include/lldb/Target/LanguageRuntime.h
index 21bdc61b8cbcf0..4f4d426eaa1dab 100644
--- a/lldb/include/lldb/Target/LanguageRuntime.h
+++ b/lldb/include/lldb/Target/LanguageRuntime.h
@@ -241,6 +241,11 @@ class LanguageRuntime : public Runtime, public 
PluginInterface {
lldb_private::RegisterContext *regctx,
bool &behaves_like_zeroth_frame);
 
+  /// Language runtime plugins can use this API to report
+  /// language-specific runtime information about this compile unit,
+  /// such as additional language version details or feature flags.
+  virtual StructuredData::ObjectSP GetLanguageInfo(SymbolContext sc);
+
 protected:
   // The static GetRuntimeUnwindPlan method above is only implemented in the
   // base class; subclasses may override this protected member if they can
diff --git a/lldb/include/lldb/Target/StackFrame.h 
b/lldb/include/lldb/Target/StackFrame.h
index e85430791b7d93..5e82657706339c 100644
--- a/lldb/include/lldb/Target/StackFrame.h
+++ b/lldb/include/lldb/Target/StackFrame.h
@@ -22,6 +22,7 @@
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/ValueObject/ValueObjectList.h"
 
@@ -408,6 +409,11 @@ class StackFrame : public ExecutionContextScope,
   /// system implementation details this way.
   bool IsHidden();
 
+  /// Language plugins can use this API to report language-specific
+  /// runtime information about this compile unit, such as additional
+  /// language version details or 

[Lldb-commits] [lldb] [lldb] Add an API to derive language-specific runtime information (PR #116904)

2024-11-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

This is motivated by exposing some Swift language-specific flags through the 
API, in the example here it is used to communicate the Objective-C runtime 
version. This could also be a meaningful extension point to get information 
about "embedded: languages, such as extracting the C++ version in an 
Objective-C++ frame or something along those lines.

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


12 Files Affected:

- (modified) lldb/include/lldb/API/SBFrame.h (+5) 
- (modified) lldb/include/lldb/API/SBStructuredData.h (+1) 
- (modified) lldb/include/lldb/Target/LanguageRuntime.h (+5) 
- (modified) lldb/include/lldb/Target/StackFrame.h (+6) 
- (modified) lldb/source/API/SBFrame.cpp (+16) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (+7) 
- (modified) 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h 
(+2) 
- (modified) lldb/source/Target/LanguageRuntime.cpp (+4) 
- (modified) lldb/source/Target/StackFrame.cpp (+13) 
- (added) lldb/test/API/lang/objc/languageinfo/Makefile (+4) 
- (added) lldb/test/API/lang/objc/languageinfo/TestObjCLanguageInfo.py (+18) 
- (added) lldb/test/API/lang/objc/languageinfo/main.m (+1) 


``diff
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index e0d15c3ecc5b1c..e1ff217767cb98 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -122,6 +122,11 @@ class LLDB_API SBFrame {
   lldb::SBValue EvaluateExpression(const char *expr,
const SBExpressionOptions &options);
 
+  /// Language plugins can use this API to report language-specific
+  /// runtime information about this compile unit, such as additional
+  /// language version details or feature flags.
+  SBStructuredData GetLanguageInfo();
+
   /// Gets the lexical block that defines the stack frame. Another way to think
   /// of this is it will return the block that contains all of the variables
   /// for a stack frame. Inlined functions are represented as SBBlock objects
diff --git a/lldb/include/lldb/API/SBStructuredData.h 
b/lldb/include/lldb/API/SBStructuredData.h
index ccdd12cab94b2f..c0d214a7374c65 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -114,6 +114,7 @@ class SBStructuredData {
   friend class SBCommandReturnObject;
   friend class SBLaunchInfo;
   friend class SBDebugger;
+  friend class SBFrame;
   friend class SBTarget;
   friend class SBProcess;
   friend class SBThread;
diff --git a/lldb/include/lldb/Target/LanguageRuntime.h 
b/lldb/include/lldb/Target/LanguageRuntime.h
index 21bdc61b8cbcf0..4f4d426eaa1dab 100644
--- a/lldb/include/lldb/Target/LanguageRuntime.h
+++ b/lldb/include/lldb/Target/LanguageRuntime.h
@@ -241,6 +241,11 @@ class LanguageRuntime : public Runtime, public 
PluginInterface {
lldb_private::RegisterContext *regctx,
bool &behaves_like_zeroth_frame);
 
+  /// Language runtime plugins can use this API to report
+  /// language-specific runtime information about this compile unit,
+  /// such as additional language version details or feature flags.
+  virtual StructuredData::ObjectSP GetLanguageInfo(SymbolContext sc);
+
 protected:
   // The static GetRuntimeUnwindPlan method above is only implemented in the
   // base class; subclasses may override this protected member if they can
diff --git a/lldb/include/lldb/Target/StackFrame.h 
b/lldb/include/lldb/Target/StackFrame.h
index e85430791b7d93..5e82657706339c 100644
--- a/lldb/include/lldb/Target/StackFrame.h
+++ b/lldb/include/lldb/Target/StackFrame.h
@@ -22,6 +22,7 @@
 #include "lldb/Utility/Scalar.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/ValueObject/ValueObjectList.h"
 
@@ -408,6 +409,11 @@ class StackFrame : public ExecutionContextScope,
   /// system implementation details this way.
   bool IsHidden();
 
+  /// Language plugins can use this API to report language-specific
+  /// runtime information about this compile unit, such as additional
+  /// language version details or feature flags.
+  StructuredData::ObjectSP GetLanguageInfo();
+
   /// Get the frame's demangled name.
   ///
   ///  /// \return
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index e2c691fa9bfd45..d17bb5cc146086 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -47,6 +47,7 @@
 #include "lldb/API/SBExpressionOptions.h"
 #include "lldb/API/SBFormat.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBStructuredData.h"
 #include "lldb/API/SBSymbolContext.h"
 #include "lldb/API/SBThread.h"
 #include "lldb/API/SBValue.h"
@@ -1154,6 +1155,21 @@ lldb::SBValue SBFrame::EvaluateExpression

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

2024-11-19 Thread via lldb-commits

https://github.com/Sirraide edited 
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-19 Thread via lldb-commits


@@ -6205,10 +6212,24 @@ bool Sema::CheckArgsForPlaceholders(MultiExprArg args) {
   for (size_t i = 0, e = args.size(); i != e; i++) {
 if (isPlaceholderToRemoveAsArg(args[i]->getType())) {
   ExprResult result = CheckPlaceholderExpr(args[i]);
-  if (result.isInvalid()) hasInvalid = true;
-  else args[i] = result.get();
+  if (result.isInvalid())
+hasInvalid = true;
+  else
+args[i] = result.get();
+}
+
+// The result of __builtin_counted_by_ref cannot be used as a function
+// argument. It allows leaking and modification of bounds safety
+// information.
+if (const auto *CE = dyn_cast(args[i]);
+CE && CE->getBuiltinCallee() == Builtin::BI__builtin_counted_by_ref) {
+  hasInvalid = true;
+  Diag(CE->getExprLoc(),
+   diag::err_builtin_counted_by_ref_cannot_leak_reference)
+  << CE->getSourceRange();

Sirraide wrote:

This probably shouldn’t be here anymore if there are no placeholder types 
involved anymore.

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] [llvm] [DebugInfo] Add explicit visibility macros to CodeView template functions (PR #113102)

2024-11-19 Thread Saleem Abdulrasool via lldb-commits


@@ -50,6 +50,20 @@ class ContinuationRecordBuilder {
 
   std::vector end(TypeIndex Index);
 };
+
+// Needed by RandomAccessVisitorTest.cpp
+#define TYPE_RECORD(EnumName, EnumVal, Name)
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name) 
\
+  extern template LLVM_TEMPLATE_ABI void   
\
+  ContinuationRecordBuilder::writeMemberType(Name##Record &Record);
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+#undef TYPE_RECORD
+#undef TYPE_RECORD_ALIAS
+#undef MEMBER_RECORD
+#undef MEMBER_RECORD_ALIAS

compnerd wrote:

I would double check that this works with modular builds, this seems like it 
could cause some issues.

https://github.com/llvm/llvm-project/pull/113102
___
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-19 Thread Bill Wendling via lldb-commits

bwendling wrote:

> Hmm, I don’t think this is the right way of going about it—copy-pasting the 
> check across 6 or so different places seems like it’s missing the point of 
> using a placeholder in the first place.

Could you point to a place in the code where it creates a placeholder? I'm 
unable to find any others that what I modified in SemaExpr.cpp. Many of the 
uses you mentioned would be invalid to perform on other `__builtin` functions 
didn't produce an error when I tried them out (except for using the `AddrOf` 
operator).

> Maybe I didn’t describe this accurately enough, but the idea was that the 
> _call_ to the builtin, not the builtin itself, should get placeholder type. 
> Then, you need to update `CheckPlaceholderExpr` _only_ (and maybe the 
> initialisation code if it’s required there; I don’t remember if that ever 
> checks for placeholders off the top of my head because initialisers are 
> weird, but I hope it does), and then update any places where you want to 
> _allow_ this as a subexpression to check for an expression w/ that 
> placeholder type (and change the placeholder type to be whatever the actual 
> type of the expression is supposed to be) before it calls 
> `CheckPlaceholderExpr`/`CheckArgsForPlaceholders`.

Given that I did this by checking the `CallExpr`, perhaps we should just 
abandon using the placeholder scheme and go with what I have here, but without 
the placeholder stuff.

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-19 Thread Bill Wendling via lldb-commits


@@ -755,6 +755,7 @@ static ExprResult BuiltinDumpStruct(Sema &S, CallExpr 
*TheCall) {
 case BuiltinType::PseudoObject:
 case BuiltinType::UnknownAny:
 case BuiltinType::BuiltinFn:
+case BuiltinType::BuiltinCountedByRef:

bwendling wrote:

Then shouldn't *all* builtin functions be marked as "invalid?"

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/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

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


@@ -259,22 +256,19 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
 }
   }
 
-  if (ranges.IsEmpty()) {
-if (lo_pc != LLDB_INVALID_ADDRESS) {
-  if (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc)
-ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc));
-  else
-ranges.Append(DWARFRangeList::Entry(lo_pc, 0));
-}
+  if (ranges.empty() && lo_pc != LLDB_INVALID_ADDRESS) {
+ranges.emplace_back(
+lo_pc, (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc) ? hi_pc : 0);

bulbazord wrote:

The possibilities for the 2nd argument went from `hi_pc - lo_pc` or `0` to 
`hi_pc` or `0`. Is this intentional? I'm not sure if the format is now `(base 
address, length)` or `(low address, high address)`.

https://github.com/llvm/llvm-project/pull/116620
___
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-19 Thread Bill Wendling via lldb-commits


@@ -14690,6 +14690,17 @@ 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())) {
+const Expr *E = CE->getCallee()->IgnoreParenImpCasts();
+if (const BuiltinType *PTy = E->getType()->getAsPlaceholderType();
+PTy && PTy->getKind() == BuiltinType::BuiltinCountedByRef)
+  Diag(E->getExprLoc(),
+   diag::err_builtin_counted_by_ref_cannot_leak_reference)
+  << E->getSourceRange();
+  }

bwendling wrote:

If I remove the check then it won't trigger an error. Initialization and 
assignment are two completely different paths.

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] Add an API to derive language-specific runtime information (PR #116904)

2024-11-19 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 
565a9ac7df3815ed038938942be4cf1471de4755...776f10f61603e922bdc38962836583da42e4f650
 lldb/test/API/lang/objc/languageinfo/TestObjCLanguageInfo.py
``





View the diff from darker here.


``diff
--- TestObjCLanguageInfo.py 2024-11-20 01:34:06.00 +
+++ TestObjCLanguageInfo.py 2024-11-20 01:37:18.111299 +
@@ -12,7 +12,5 @@
 target, process, thread, bkpt = lldbutil.run_to_name_breakpoint(self, 
"main")
 frame = thread.GetFrameAtIndex(0)
 lang_info = frame.GetLanguageInfo()
 version = lang_info.GetValueForKey("Objective-C runtime version")
 self.assertEqual(version.GetIntegerValue(), 2)
-
-

``




https://github.com/llvm/llvm-project/pull/116904
___
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-19 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/3] [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] Reword the "line 0" warning (PR #116827)

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

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

>From 02637dab316797b0bf6440b549497bf59db2d3c7 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 19 Nov 2024 17:03:48 +0100
Subject: [PATCH] [lldb] Reword the "line 0" warning

We got a bug report that this message is confusing.  In this particular
case, the line zero was due to compiler tail merging (in optimized
code). The main issue was the "no source code" part: in this case it's
kind of incorrect because -- even though we can't really know that --
the address is arguably associated with *multiple* lines of source code.

I've tried to make the new wording more neutral, and added a wink
towards compiler optimizations. I left out the "compiler generated" part
of the message because I couldn't find a way to squeeze that in nicely.
I'm also not entirely sure what it was referring to -- if this was
(just) function prologue/epilogue, then maybe leaving it out is fine, as
we're not likely to stop there anyway (?)

I also left out the function name, because:
- for template functions it gets rather long
- it's already present in the message, potentially twice (once in the
  "frame summary" line and once in the snippet of code we show for the
  function declaration)
---
 lldb/source/Target/StackFrame.cpp| 16 +++-
 .../test/API/source-manager/TestSourceManager.py |  4 ++--
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Target/StackFrame.cpp 
b/lldb/source/Target/StackFrame.cpp
index 1bca9786fb7c70..ece85a077385ed 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -2007,19 +2007,9 @@ bool StackFrame::GetStatus(Stream &strm, bool 
show_frame_info, bool show_source,
   if (num_lines != 0)
 have_source = true;
   // TODO: Give here a one time warning if source file is missing.
-  if (!m_sc.line_entry.line) {
-ConstString fn_name = m_sc.GetFunctionName();
-
-if (!fn_name.IsEmpty())
-  strm.Printf(
-  "Note: this address is compiler-generated code in function "
-  "%s that has no source code associated with it.",
-  fn_name.AsCString());
-else
-  strm.Printf("Note: this address is compiler-generated code that "
-  "has no source code associated with it.");
-strm.EOL();
-  }
+  if (!m_sc.line_entry.line)
+strm << "Note: This address is not associated with a specific line 
"
+"of code. This may be due to compiler optimizations.\n";
 }
   }
   switch (disasm_display) {
diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index 7071f094e20f7e..7d239ddb6acbd9 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -336,8 +336,8 @@ def test_artificial_source_location(self):
 "stop reason = breakpoint",
 f"{src_file}:0",
 "static int foo();",
-"Note: this address is compiler-generated code in function",
-"that has no source code associated with it.",
+"Note: This address is not associated with a specific line "
+"of code. This may be due to compiler optimizations.",
 ],
 )
 

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


[Lldb-commits] [lldb] d29a50f - Revert "[lldb] Allow fetching of RA register when above fault handler (#98566)"

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

Author: Jason Molenda
Date: 2024-11-19T16:01:27-08:00
New Revision: d29a50f358e71a695b23e456d66ed2924617deb9

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

LOG: Revert "[lldb] Allow fetching of RA register when above fault handler 
(#98566)"

This reverts commit fd424179dcb3417fc0675f77d2bf06c750dd1c33.

This patch has two problems.  First, it is unnecessary, Pavel landed
a fix a week or so before mine which solves this problem in
bbd54e08b08f5ccd38c4665178e65c58f7b14459 .  Second, the fix is
incorrect; for a function above a trap handler, where all registers
are available, this patch would have lldb fetch the return address
register from frame 0.  This might be 10 frames up in the stack;
the frame 0 return address register is incorrect.  The change would
have been correct a short bit later than this, but Pavel's fix is
executed earlier in the function and none of this is needed.

Added: 


Modified: 
lldb/source/Target/RegisterContextUnwind.cpp

Removed: 




diff  --git a/lldb/source/Target/RegisterContextUnwind.cpp 
b/lldb/source/Target/RegisterContextUnwind.cpp
index 9a4a8db84a9fa5..dbe885e286ff74 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -1402,7 +1402,7 @@ RegisterContextUnwind::SavedLocationForRegister(
   // it's still live in the actual register. Handle this specially.
 
   if (!have_unwindplan_regloc && return_address_reg.IsValid() &&
-  BehavesLikeZerothFrame()) {
+  IsFrameZero()) {
 if (return_address_reg.GetAsKind(eRegisterKindLLDB) !=
 LLDB_INVALID_REGNUM) {
   lldb_private::UnwindLLDB::ConcreteRegisterLocation new_regloc;



___
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-19 Thread via lldb-commits

Sirraide wrote:

> Could you point to a place in the code where it creates a placeholder?

I mean, e.g. `CheckPointerToMemberOperands()` can return `BoundMemberTy` as the 
type of a `.*` expression, and `CreateBuiltinMatrixSubscriptExpr()` creates a 
`MatrixSubscriptExpr` with type `IncompleteMatrixIdxTy` if that’s what you’re 
asking.

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] Reword the "line 0" warning (PR #116827)

2024-11-19 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 
7e85cb8a8a9de57ed10635b843662148a87b17e5...59f306aed0736a861f5d084f6e203337234bfb96
 lldb/test/API/source-manager/TestSourceManager.py
``





View the diff from darker here.


``diff
--- TestSourceManager.py2024-11-19 16:03:48.00 +
+++ TestSourceManager.py2024-11-19 16:19:57.954090 +
@@ -335,11 +335,11 @@
 substrs=[
 "stop reason = breakpoint",
 f"{src_file}:0",
 "static int foo();",
 "Note: This address is not associated with a specific line "
-"of code. This may be due to compiler optimizations."
+"of code. This may be due to compiler optimizations.",
 ],
 )
 
 def test_source_cache_dump_and_clear(self):
 self.build()

``




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


[Lldb-commits] [lldb] [lldb/www] Garbage collect old videos and add new ones (PR #116838)

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

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

Thanks! LGTM.

Probably for the best since the interface will have changed since the older 
videos, I hope they are preserved somewhere inside Apple though.

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


[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

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


@@ -906,13 +907,18 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit 
&comp_unit,
 
   AddressRanges ranges;
   ModuleSP module_sp(die.GetModule());
-  for (const auto &range : die.GetDIE()->GetAttributeAddressRanges(
-   die.GetCU(), /*check_hi_lo_pc=*/true)) {
-if (range.base < m_first_code_address)
-  continue;
-if (Address base_addr(range.base, module_sp->GetSectionList());
-base_addr.IsValid() && FixupAddress(base_addr))
-  ranges.emplace_back(std::move(base_addr), range.size);
+  if (llvm::Expected die_ranges =
+  die.GetDIE()->GetAttributeAddressRanges(die.GetCU(),
+  /*check_hi_lo_pc=*/true)) {
+for (auto &range : *die_ranges) {

bulbazord wrote:

can `range` be const-qualified? :)

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


[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

2024-11-19 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add an API to derive language-specific runtime information (PR #116904)

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

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

LGTM modulo formatting.

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


[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

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


@@ -259,22 +256,19 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
 }
   }
 
-  if (ranges.IsEmpty()) {
-if (lo_pc != LLDB_INVALID_ADDRESS) {
-  if (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc)
-ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc));
-  else
-ranges.Append(DWARFRangeList::Entry(lo_pc, 0));
-}
+  if (ranges.empty() && lo_pc != LLDB_INVALID_ADDRESS) {
+ranges.emplace_back(
+lo_pc, (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc) ? hi_pc : 0);

labath wrote:

Good catch. The new format is now (low pc, high pc), so the second case should 
be low_pc instead of zero. I don't remember ever seeing a lone low_pc 
attribute, so this might not matter in practice.

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


[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

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


@@ -906,13 +907,18 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit 
&comp_unit,
 
   AddressRanges ranges;
   ModuleSP module_sp(die.GetModule());
-  for (const auto &range : die.GetDIE()->GetAttributeAddressRanges(
-   die.GetCU(), /*check_hi_lo_pc=*/true)) {
-if (range.base < m_first_code_address)
-  continue;
-if (Address base_addr(range.base, module_sp->GetSectionList());
-base_addr.IsValid() && FixupAddress(base_addr))
-  ranges.emplace_back(std::move(base_addr), range.size);
+  if (llvm::Expected die_ranges =
+  die.GetDIE()->GetAttributeAddressRanges(die.GetCU(),
+  /*check_hi_lo_pc=*/true)) {
+for (auto &range : *die_ranges) {

labath wrote:

sure

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


[Lldb-commits] [lldb] [lldb/DWARF] s/DWARFRangeList/llvm::DWARFAddressRangeVector (PR #116620)

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

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

>From 08a947e3a8d6a76d7898a1f3390c4f2ac0446702 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 18 Nov 2024 14:33:40 +0100
Subject: [PATCH 1/2] [lldb/DWARF]
 s/DWARFRangeList/llvm::DWARFAddressRangeVector

The main difference is that the llvm class (just a std::vector in
disguise) is not sorted. It turns out this isn't an issue because the
callers either:
- ignore the range list;
- convert it to a different format (which is then sorted);
- or query the minimum value (which is faster than sorting)

The last case is something I want to get rid of in a followup as a part
of removing the assumption that function's entry point is also its
lowest address.
---
 lldb/include/lldb/Core/dwarf.h|  3 -
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |  3 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  3 +-
 .../SymbolFile/DWARF/DWARFCompileUnit.cpp | 19 ++--
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 43 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   | 11 ++-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  | 95 +--
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h| 20 ++--
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp| 67 ++---
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  7 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 87 +
 11 files changed, 184 insertions(+), 174 deletions(-)

diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h
index e162a090ba7c97..4de5c8f24db02c 100644
--- a/lldb/include/lldb/Core/dwarf.h
+++ b/lldb/include/lldb/Core/dwarf.h
@@ -9,7 +9,6 @@
 #ifndef LLDB_CORE_DWARF_H
 #define LLDB_CORE_DWARF_H
 
-#include "lldb/Utility/RangeMap.h"
 #include 
 
 // Get the DWARF constant definitions from llvm
@@ -40,6 +39,4 @@ typedef uint64_t dw_offset_t; // Dwarf Debug Information 
Entry offset for any
 
 #define DW_EH_PE_MASK_ENCODING 0x0F
 
-typedef lldb_private::RangeVector DWARFRangeList;
-
 #endif // LLDB_CORE_DWARF_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
index ad443aacb46ecc..69be0aa1280c16 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -10,7 +10,8 @@
 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H
 
 #include "lldb/Core/dwarf.h"
-#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-types.h"
 #include 
 #include 
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index d9bdeb560e1220..05d994ae82d8d4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -45,6 +45,7 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 #include "llvm/Demangle/Demangle.h"
 
 #include 
@@ -2353,7 +2354,7 @@ 
DWARFASTParserClang::ConstructDemangledNameFromDWARF(const DWARFDIE &die) {
 
 Function *DWARFASTParserClang::ParseFunctionFromDWARF(
 CompileUnit &comp_unit, const DWARFDIE &die, AddressRanges func_ranges) {
-  DWARFRangeList unused_func_ranges;
+  llvm::DWARFAddressRangesVector unused_func_ranges;
   const char *name = nullptr;
   const char *mangled = nullptr;
   std::optional decl_file;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index ec4c297cf7e164..7f2edbfa95feef 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -8,11 +8,13 @@
 
 #include "DWARFCompileUnit.h"
 #include "DWARFDebugAranges.h"
+#include "LogChannelDWARF.h"
 #include "SymbolFileDWARFDebugMap.h"
 
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Utility/Stream.h"
+#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -41,14 +43,17 @@ void DWARFCompileUnit::BuildAddressRangeTable(
 
   const dw_offset_t cu_offset = GetOffset();
   if (die) {
-DWARFRangeList ranges =
+llvm::Expected ranges =
 die->GetAttributeAddressRanges(this, /*check_hi_lo_pc=*/true);
-for (const DWARFRangeList::Entry &range : ranges)
-  debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
- range.GetRangeEnd());
-
-if (!ranges.IsEmpty())
-  return;
+if (ranges) {
+  for (const llvm::DWARFAddressRange &range : *ranges)
+debug_aranges->AppendRange(cu_offset, range.LowPC, range.HighPC);
+  if (!ranges->empty())
+return;
+} else {
+  LLDB_LOG_ERROR(GetLog(DWARFLog::DebugInfo), ranges.takeError(),
+ "{1:x}: {0}", cu_offset);
+}
   

[Lldb-commits] [lldb] [lldb] Reword the "line 0" warning (PR #116827)

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

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

LGTM

For an expert this wording can imply that the previous wording might be the 
case, and for the non-experts it's less misleading.

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


[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

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

adrian-prantl wrote:

> This reminds me, could you add a release note talking about these diagnostic 
> improvements? They might have started in 19 but we didn't add one then and 
> things have improved more since, and I think it's a cool feature.

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

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


[Lldb-commits] [lldb] [lldb/www] Garbage collect old videos and add new ones (PR #116838)

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

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


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


[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

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

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


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

2024-11-19 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `lldb` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-shell :: Subprocess/fork-follow-parent-wp.test (1561 of 2051)
UNSUPPORTED: lldb-shell :: SymbolFile/DWARF/TestDedupWarnings.test (1562 of 
2051)
PASS: lldb-shell :: SymbolFile/Breakpad/unwind-via-stack-win.test (1563 of 2051)
UNSUPPORTED: lldb-shell :: 
SymbolFile/DWARF/clang-ast-from-dwarf-objc-property.m (1564 of 2051)
PASS: lldb-shell :: SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll 
(1565 of 2051)
PASS: lldb-shell :: 
SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp (1566 of 2051)
PASS: lldb-shell :: SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s (1567 of 
2051)
PASS: lldb-shell :: SymbolFile/DWARF/clang-gmodules-type-lookup.c (1568 of 2051)
PASS: lldb-shell :: SymbolFile/DWARF/debug-types-mangled-name.ll (1569 of 2051)
UNSUPPORTED: lldb-shell :: SymbolFile/DWARF/deterministic-build.cpp (1570 of 
2051)
FAIL: lldb-shell :: SymbolFile/DWARF/DW_OP_piece-O3.c (1571 of 2051)
 TEST 'lldb-shell :: SymbolFile/DWARF/DW_OP_piece-O3.c' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 8: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution 
--target=aarch64-unknown-linux-gnu -pthread 
-fmodules-cache-path=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-shell
 -O3 -gdwarf 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
 -o 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/Output/DW_OP_piece-O3.c.tmp
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution 
--target=aarch64-unknown-linux-gnu -pthread 
-fmodules-cache-path=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-shell
 -O3 -gdwarf 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
 -o 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/Output/DW_OP_piece-O3.c.tmp
clang: warning: argument unused during compilation: 
'-fmodules-cache-path=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-shell'
 [-Wunused-command-line-argument]
RUN: at line 9: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb 
--no-lldbinit -S 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/lit-lldb-init-quiet
 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/Output/DW_OP_piece-O3.c.tmp
-o "b 22"-o "r"-o "p/x array[2]"-b | 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/FileCheck 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb --no-lldbinit 
-S 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/lit-lldb-init-quiet
 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/Output/DW_OP_piece-O3.c.tmp
 -o 'b 22' -o r -o 'p/x array[2]' -b
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/FileCheck 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c:16:11:
 error: CHECK: expected string not found in input
// CHECK: (char) 0x03
  ^
:19:20: note: scanning from here
(lldb) p/x array[2]
   ^
:20:1: note: possible intended match here
(char) 0x02
^

Input file: 
Check file: 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-O3.c

-dump-input=help explains the following input dump.

Input was:
<<
.
.
.
   14:  20 int main(void) { 
   15:  21 array[2]++; 
   16: -> 22 return 0; 
   17:  ^ 
   18:  23 } 
   19: (lldb) p/x array[2] 
check:16'0X error: no match found

```



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


[Lldb-commits] [lldb] [lldb/www] Garbage collect old videos and add new ones (PR #116838)

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

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


[Lldb-commits] [lldb] [lldb] Improve editline completion formatting (PR #116456)

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

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

>From 3434c7de701e4851b4eefe25f23e49d415ba4dd3 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 15 Nov 2024 16:06:47 -0800
Subject: [PATCH 1/6] [lldb] Improve editline completion formatting

This patch improves the formatting of editline completions. The current
implementation is naive and doesn't account for the terminal width.

Concretely, the old implementation suffered from the following issues:

 - We would unconditionally pad to the longest completion. If that
   completion exceeds the width of the terminal, that would result in a
   lot of superfluous white space and line wrapping.
 - When printing the description, we wouldn't account for the presence
   of newlines, and they would continue without leading padding.

The new code accounts for both. If the completion exceeds the available
terminal width, we show what fits on the current lined followed by
ellipsis. We also no longer pad beyond the length of the current line.
Finally, we print the description line by line, with the proper leading
padding. If a line of the description exceeds the available terminal
width, we print ellipsis and won't print the next line.

Before:

```
Available completions:
_regexp-attach-- Attach to process by ID or name.
_regexp-break -- Set a breakpoint using one of several shorthand
 formats.
_regexp-bt-- Show backtrace of the current thread's call sta
ck. Any numeric argument displays at most that many frames. The argument 'al
l' displays all threads. Use 'settings set frame-format' to customize the pr
inting of individual frames and 'settings set thread-format' to customize th
e thread header. Frame recognizers may filter thelist. Use 'thread backtrace
 -u (--unfiltered)' to see them all.
_regexp-display   -- Evaluate an expression at every stop (see 'help
 target stop-hook'.)

```

After:
```
 Available completions:
_regexp-attach-- Attach to process by ID or name.
_regexp-break -- Set a breakpoint using one of several shorth...
_regexp-bt-- Show backtrace of the current thread's call ...
_regexp-display   -- Evaluate an expression at every stop (see 'h...
```

rdar://135818198
---
 lldb/include/lldb/Host/Editline.h|  2 +
 lldb/source/Host/common/Editline.cpp | 95 ++--
 2 files changed, 90 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index 57e2c831e3499d..e8e8a6c0d4f67e 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -238,6 +238,8 @@ class Editline {
   /// Convert the current input lines into a UTF8 StringList
   StringList GetInputAsStringList(int line_count = UINT32_MAX);
 
+  size_t GetTerminalWidth() { return m_terminal_width; }
+
 private:
   /// Sets the lowest line number for multi-line editing sessions.  A value of
   /// zero suppresses line number printing in the prompt.
diff --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index f95f854c5f220c..109cc897b853f3 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -927,12 +927,92 @@ unsigned char Editline::BufferEndCommand(int ch) {
 static void
 PrintCompletion(FILE *output_file,
 llvm::ArrayRef results,
-size_t max_len) {
+size_t max_completion_length, size_t max_lenght) {
+
+  constexpr size_t ellipsis_length = 3;
+  constexpr size_t tab_legnth = 8;
+  constexpr size_t separator_length = 4;
+  const size_t description_col =
+  std::min(max_completion_length + tab_legnth, max_lenght);
+
   for (const CompletionResult::Completion &c : results) {
-fprintf(output_file, "\t%-*s", (int)max_len, c.GetCompletion().c_str());
-if (!c.GetDescription().empty())
-  fprintf(output_file, " -- %s", c.GetDescription().c_str());
-fprintf(output_file, "\n");
+// Print the leading tab-sized padding.
+fprintf(output_file, "");
+size_t cursor = tab_legnth;
+
+if (!c.GetCompletion().empty()) {
+  const size_t completion_length = c.GetCompletion().size();
+  if (cursor + completion_length < max_lenght) {
+fprintf(output_file, "%s", c.GetCompletion().c_str());
+cursor = cursor + completion_length;
+  } else {
+// If the completion doesn't fit on the screen, print ellipsis and 
don't
+// bother with the description.
+fprintf(output_file, "%s...\n",
+c.GetCompletion()
+.substr(0, max_lenght - cursor - ellipsis_length)
+.c_str());
+continue;
+  }
+}
+
+if (!c.GetDescription().empty()) {
+  // If we have a description, we need at least 4 columns for the 
separator.
+  if (cursor + separator_length < max_lenght) {
+// Add padding before the

[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

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

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


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


[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

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


@@ -130,6 +131,25 @@ void RenderDiagnosticDetails(Stream &stream,
   }
   stream << '\n';
 
+  // Reverse the order within groups of diagnostics that are on the same 
column.
+  auto group = [](auto &ds) {

augusto2112 wrote:

I'd prefer to spell out the type of `ds` instead of `auto`

https://github.com/llvm/llvm-project/pull/116727
___
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 positioning bug in diagnostics output (PR #116711)

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

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


[Lldb-commits] [lldb] [lldb] Improve editline completion formatting (PR #116456)

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


@@ -0,0 +1,69 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class EditlineCompletionsTest(PExpectTest):
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@skipIfEditlineWideCharSupportMissing
+def test_completion_truncated(self):
+"""Test that the completion is correctly truncated."""
+self.launch(dimensions=(10, 20))
+self.child.send("_regexp-\t")
+self.child.expect("_regexp-a...")
+self.child.expect("_regexp-b...")
+
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@skipIfEditlineWideCharSupportMissing
+def test_description_truncated(self):
+"""Test that the description is correctly truncated."""
+self.launch(dimensions=(10, 70))
+self.child.send("_regexp-\t")
+self.child.expect(
+"_regexp-attach-- Attach to process by ID or name."
+)
+self.child.expect(
+"_regexp-break -- Set a breakpoint using one of 
several..."
+)
+
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@skipIfEditlineWideCharSupportMissing
+def test_separator_omitted(self):
+"""Test that the separated is correctly omitted."""
+self.launch(dimensions=(10, 32), timeout=1)

JDevlieghere wrote:

I added this for local testing, I meant to remove it.

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


[Lldb-commits] [lldb] [lldb] Reword the "line 0" warning (PR #116827)

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


@@ -2007,19 +2007,9 @@ bool StackFrame::GetStatus(Stream &strm, bool 
show_frame_info, bool show_source,
   if (num_lines != 0)
 have_source = true;
   // TODO: Give here a one time warning if source file is missing.
-  if (!m_sc.line_entry.line) {
-ConstString fn_name = m_sc.GetFunctionName();
-
-if (!fn_name.IsEmpty())
-  strm.Printf(
-  "Note: this address is compiler-generated code in function "
-  "%s that has no source code associated with it.",
-  fn_name.AsCString());
-else
-  strm.Printf("Note: this address is compiler-generated code that "
-  "has no source code associated with it.");
-strm.EOL();
-  }
+  if (!m_sc.line_entry.line)
+strm << "Note: This address is not associated with a specific line 
"

JDevlieghere wrote:

```suggestion
strm << "note: This address is not associated with a specific line "
```

It's a bit awkward with the full sentences, but for consistency we should make 
`note:` lowercase (like `error:` and `warning:`)

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


[Lldb-commits] [lldb] [lldb] Improve editline completion formatting (PR #116456)

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


@@ -0,0 +1,69 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class EditlineCompletionsTest(PExpectTest):
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@skipIfEditlineWideCharSupportMissing

JDevlieghere wrote:

Yeah, copy-paste :-) 

https://github.com/llvm/llvm-project/pull/116456
___
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 positioning bug in diagnostics output (PR #116711)

2024-11-19 Thread Felipe de Azevedo Piovezan via lldb-commits

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

Nice catch

https://github.com/llvm/llvm-project/pull/116711
___
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 positioning bug in diagnostics output (PR #116711)

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

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


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


[Lldb-commits] [lldb] [lldb] Reword the "line 0" warning (PR #116827)

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

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


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


[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

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


@@ -130,6 +131,25 @@ void RenderDiagnosticDetails(Stream &stream,
   }
   stream << '\n';
 
+  // Reverse the order within groups of diagnostics that are on the same 
column.
+  auto group = [](auto &ds) {
+uint16_t column = 0;
+std::vector result, group;
+for (auto d : ds) {

augusto2112 wrote:

`auto &`?

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


[Lldb-commits] [lldb] [lldb] Improve rendering of inline diagnostics on the same column (PR #116727)

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

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

>From 4a9a4b0346e711b596eb14ca9f92f157ae67e469 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Mon, 18 Nov 2024 17:33:10 -0800
Subject: [PATCH] [lldb] Improve rendering of inline diagnostics on the column

by fixing the indentation and printing these annotations in the original order.

Before

a+b+c;
^ ^ ^
| | error: 3
| |note: 2b
| error: 2a
error: 1

After

a+b+c;
^ ^ ^
| | error: 3
| error: 2a
| note: 2b
error: 1
---
 lldb/source/Utility/DiagnosticsRendering.cpp  | 35 +++--
 .../Utility/DiagnosticsRenderingTest.cpp  | 49 +--
 2 files changed, 54 insertions(+), 30 deletions(-)

diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index dfc47ac460ac9f..a20d82ad4eb678 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Utility/DiagnosticsRendering.h"
+#include 
 
 using namespace lldb_private;
 using namespace lldb;
@@ -98,7 +99,7 @@ void RenderDiagnosticDetails(Stream &stream,
   }
 
   // Sort the diagnostics.
-  auto sort = [](auto &ds) {
+  auto sort = [](std::vector &ds) {
 std::stable_sort(ds.begin(), ds.end(), [](auto &d1, auto &d2) {
   auto l1 = 
d1.source_location.value_or(DiagnosticDetail::SourceLocation{});
   auto l2 = 
d2.source_location.value_or(DiagnosticDetail::SourceLocation{});
@@ -130,6 +131,25 @@ void RenderDiagnosticDetails(Stream &stream,
   }
   stream << '\n';
 
+  // Reverse the order within groups of diagnostics that are on the same 
column.
+  auto group = [](const std::vector &details) {
+uint16_t column = 0;
+std::vector result, group;
+for (auto &d : details) {
+  if (d.source_location->column == column) {
+group.push_back(d);
+continue;
+  }
+  result.insert(result.end(), group.rbegin(), group.rend());
+  group.clear();
+  column = d.source_location->column;
+  group.push_back(d);
+}
+result.insert(result.end(), group.rbegin(), group.rend());
+return result;
+  };
+  remaining_details = group(remaining_details);
+
   // Work through each detail in reverse order using the vector/stack.
   bool did_print = false;
   for (auto detail = remaining_details.rbegin();
@@ -142,14 +162,19 @@ void RenderDiagnosticDetails(Stream &stream,
 for (auto &remaining_detail :
  llvm::ArrayRef(remaining_details).drop_back(1)) {
   uint16_t column = remaining_detail.source_location->column;
-  if (x_pos <= column)
+  // Is this a note with the same column as another diagnostic?
+  if (column == detail->source_location->column)
+continue;
+
+  if (column >= x_pos) {
 stream << std::string(column - x_pos, ' ') << vbar;
-  x_pos = column + 1;
+x_pos = column + 1;
+  }
 }
 
-// Print the line connecting the ^ with the error message.
 uint16_t column = detail->source_location->column;
-if (x_pos <= column)
+// Print the line connecting the ^ with the error message.
+if (column >= x_pos)
   stream << std::string(column - x_pos, ' ') << joint << hbar << spacer;
 
 // Print a colorized string based on the message's severity type.
diff --git a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp 
b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
index 1187f3f65f27fd..4e5e0bb7dc3552 100644
--- a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
+++ b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
@@ -29,15 +29,22 @@ TEST_F(ErrorDisplayTest, RenderStatus) {
   {
 // Test that diagnostics on the same column can be handled and all
 // three errors are diagnosed.
-SourceLocation loc1 = {FileSpec{"a.c"}, 13, 11, 0, false, true};
-SourceLocation loc2 = {FileSpec{"a.c"}, 13, 13, 0, false, true};
+SourceLocation loc1 = {FileSpec{"a.c"}, 13, 5, 0, false, true};
+SourceLocation loc2 = {FileSpec{"a.c"}, 13, 7, 0, false, true};
+SourceLocation loc3 = {FileSpec{"a.c"}, 13, 9, 0, false, true};
 std::string result =
 Render({DiagnosticDetail{loc1, eSeverityError, "1", "1"},
-DiagnosticDetail{loc1, eSeverityError, "2", "2"},
-DiagnosticDetail{loc2, eSeverityError, "3", "3"}});
-ASSERT_TRUE(StringRef(result).contains("error: 1"));
-ASSERT_TRUE(StringRef(result).contains("error: 2"));
-ASSERT_TRUE(StringRef(result).contains("error: 3"));
+DiagnosticDetail{loc2, eSeverityError, "2a", "2a"},
+DiagnosticDetail{loc2, eSeverityInfo, "2b", "2b"},
+DiagnosticDetail{loc3, eSeverityError, "3", "3"}});
+llvm::SmallVector lines;
+StringRef(result).split(lines, '\n');
+//1234567890123
+ASSERT_EQ(lines[0]

[Lldb-commits] [lldb] 8b2dff9 - [lldb] Fix a positioning bug in diagnostics output (#116711)

2024-11-19 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-11-19T08:58:49-08:00
New Revision: 8b2dff960d9d987c583c3a6d5729f01d101dc401

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

LOG: [lldb] Fix a positioning bug in diagnostics output (#116711)

The old code did not take the indentation into account.

Added: 


Modified: 
lldb/source/Utility/DiagnosticsRendering.cpp
lldb/unittests/Utility/DiagnosticsRenderingTest.cpp

Removed: 




diff  --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index 208733ffc86853..dfc47ac460ac9f 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -121,10 +121,10 @@ void RenderDiagnosticDetails(Stream &stream,
 continue;
 
   stream << std::string(loc.column - x_pos, ' ') << cursor;
-  ++x_pos;
+  x_pos = loc.column + 1;
   for (unsigned i = 0; i + 1 < loc.length; ++i) {
 stream << underline;
-++x_pos;
+x_pos += 1;
   }
 }
   }

diff  --git a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp 
b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
index ad2ebf7ffe1e2f..1187f3f65f27fd 100644
--- a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
+++ b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
@@ -74,9 +74,27 @@ TEST_F(ErrorDisplayTest, RenderStatus) {
 auto line2 = lines.first;
 lines = lines.second.split('\n');
 auto line3 = lines.first;
-//   1234567
+//1234567
 ASSERT_EQ(line1, "^~~ ^~~");
 ASSERT_EQ(line2, "|   error: Y");
 ASSERT_EQ(line3, "error: X");
   }
+  {
+// Test diagnostics on the same line are emitted correctly.
+SourceLocation loc1 = {FileSpec{"a.c"}, 1, 2, 0, false, true};
+SourceLocation loc2 = {FileSpec{"a.c"}, 1, 6, 0, false, true};
+std::string result =
+Render({DiagnosticDetail{loc1, eSeverityError, "X", "X"},
+DiagnosticDetail{loc2, eSeverityError, "Y", "Y"}});
+auto lines = StringRef(result).split('\n');
+auto line1 = lines.first;
+lines = lines.second.split('\n');
+auto line2 = lines.first;
+lines = lines.second.split('\n');
+auto line3 = lines.first;
+//1234567
+ASSERT_EQ(line1, " ^   ^");
+ASSERT_EQ(line2, " |   error: Y");
+ASSERT_EQ(line3, " error: X");
+  }
 }



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


[Lldb-commits] [lldb] 6b4f675 - [lldb] Improve rendering of inline diagnostics on the same column (#116727)

2024-11-19 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-11-19T09:13:00-08:00
New Revision: 6b4f67545d87d5305cbbc20a678fb97ede995579

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

LOG: [lldb] Improve rendering of inline diagnostics on the same column (#116727)

depends on https://github.com/llvm/llvm-project/pull/116711

[lldb] Improve rendering of inline diagnostics on the same column by
fixing the indentation and printing these annotations in the original
order.

Before

a+b+c;
^ ^ ^
| | error: 3
| |note: 2b
| error: 2a
error: 1

After

a+b+c;
^ ^ ^
| | error: 3
| error: 2a
| note: 2b
error: 1

Added: 


Modified: 
lldb/source/Utility/DiagnosticsRendering.cpp
lldb/unittests/Utility/DiagnosticsRenderingTest.cpp

Removed: 




diff  --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index dfc47ac460ac9f..a20d82ad4eb678 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/Utility/DiagnosticsRendering.h"
+#include 
 
 using namespace lldb_private;
 using namespace lldb;
@@ -98,7 +99,7 @@ void RenderDiagnosticDetails(Stream &stream,
   }
 
   // Sort the diagnostics.
-  auto sort = [](auto &ds) {
+  auto sort = [](std::vector &ds) {
 std::stable_sort(ds.begin(), ds.end(), [](auto &d1, auto &d2) {
   auto l1 = 
d1.source_location.value_or(DiagnosticDetail::SourceLocation{});
   auto l2 = 
d2.source_location.value_or(DiagnosticDetail::SourceLocation{});
@@ -130,6 +131,25 @@ void RenderDiagnosticDetails(Stream &stream,
   }
   stream << '\n';
 
+  // Reverse the order within groups of diagnostics that are on the same 
column.
+  auto group = [](const std::vector &details) {
+uint16_t column = 0;
+std::vector result, group;
+for (auto &d : details) {
+  if (d.source_location->column == column) {
+group.push_back(d);
+continue;
+  }
+  result.insert(result.end(), group.rbegin(), group.rend());
+  group.clear();
+  column = d.source_location->column;
+  group.push_back(d);
+}
+result.insert(result.end(), group.rbegin(), group.rend());
+return result;
+  };
+  remaining_details = group(remaining_details);
+
   // Work through each detail in reverse order using the vector/stack.
   bool did_print = false;
   for (auto detail = remaining_details.rbegin();
@@ -142,14 +162,19 @@ void RenderDiagnosticDetails(Stream &stream,
 for (auto &remaining_detail :
  llvm::ArrayRef(remaining_details).drop_back(1)) {
   uint16_t column = remaining_detail.source_location->column;
-  if (x_pos <= column)
+  // Is this a note with the same column as another diagnostic?
+  if (column == detail->source_location->column)
+continue;
+
+  if (column >= x_pos) {
 stream << std::string(column - x_pos, ' ') << vbar;
-  x_pos = column + 1;
+x_pos = column + 1;
+  }
 }
 
-// Print the line connecting the ^ with the error message.
 uint16_t column = detail->source_location->column;
-if (x_pos <= column)
+// Print the line connecting the ^ with the error message.
+if (column >= x_pos)
   stream << std::string(column - x_pos, ' ') << joint << hbar << spacer;
 
 // Print a colorized string based on the message's severity type.

diff  --git a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp 
b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
index 1187f3f65f27fd..4e5e0bb7dc3552 100644
--- a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
+++ b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
@@ -29,15 +29,22 @@ TEST_F(ErrorDisplayTest, RenderStatus) {
   {
 // Test that diagnostics on the same column can be handled and all
 // three errors are diagnosed.
-SourceLocation loc1 = {FileSpec{"a.c"}, 13, 11, 0, false, true};
-SourceLocation loc2 = {FileSpec{"a.c"}, 13, 13, 0, false, true};
+SourceLocation loc1 = {FileSpec{"a.c"}, 13, 5, 0, false, true};
+SourceLocation loc2 = {FileSpec{"a.c"}, 13, 7, 0, false, true};
+SourceLocation loc3 = {FileSpec{"a.c"}, 13, 9, 0, false, true};
 std::string result =
 Render({DiagnosticDetail{loc1, eSeverityError, "1", "1"},
-DiagnosticDetail{loc1, eSeverityError, "2", "2"},
-DiagnosticDetail{loc2, eSeverityError, "3", "3"}});
-ASSERT_TRUE(StringRef(result).contains("error: 1"));
-ASSERT_TRUE(StringRef(result).contains("error: 2"));
-ASSERT_TRUE(StringRef(result).contains("error: 3"));
+DiagnosticDetail{loc2, eSeverityError, "2a", "2a"},
+Diagnosti

[Lldb-commits] [clang] [lldb] [llvm] Extending LLDB to work on AIX (PR #102601)

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

labath wrote:

BTW, the main loop changes are something that you should be able to upstream 
quite easily. It sounds like the main problem is that you don't have a ppoll 
syscall, but the last round of changes means that ppoll is not actually 
necessary for its operation (the only reason to use it is the increased 
precision)

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


[Lldb-commits] [lldb] [lldb] Fix comment in ~Thread (NFC) (PR #116850)

2024-11-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes



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


1 Files Affected:

- (modified) lldb/source/Target/Thread.cpp (+1-1) 


``diff
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 735295e6f25937..fb17276051909c 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -244,7 +244,7 @@ Thread::~Thread() {
   LLDB_LOGF(log, "%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")",
 static_cast(this), GetID());
   /// If you hit this assert, it means your derived class forgot to call
-  /// DoDestroy in its destructor.
+  /// DestroyThread in its destructor.
   assert(m_destroy_called);
 }
 

``




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