[Lldb-commits] [lldb] [lldb][test] Fix tests Test*FromStdModule where called missing at(0) (PR #112485)

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

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/112485

>From 4736ff60f79352f2f9f703eced07c3555fef8a63 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 16 Oct 2024 10:37:37 +0400
Subject: [PATCH 1/3] [lldb][test] Fix the test TestArrayFromStdModule.py

This patch fixes the error 
https://lab.llvm.org/staging/#/builders/195/builds/4464
```
File 
"llvm-project/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py",
 line 55, in test
self.expect_expr("a.at(0)", result_type=value_type, result_value="3")
Hint: The expression tried to call a function that is not present in the 
target, perhaps because it was optimized out by the compiler.
```
Note adding the usage of `a.at(0)` to main.cpp did not help.
It is the alternative to #98701.
---
 .../import-std-module/array/TestArrayFromStdModule.py  | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
index 13ab6b0c9ac1fb..7dfff91070db08 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
@@ -52,7 +52,8 @@ def test(self):
 self.expect_expr("*a.begin()", result_type=value_type, 
result_value="3")
 self.expect_expr("*a.rbegin()", result_type="int", result_value="2")
 
-self.expect_expr("a.at(0)", result_type=value_type, result_value="3")
+# This check may fail because of compiler optimizations.
+#self.expect_expr("a.at(0)", result_type=value_type, result_value="3")
 
 # Same again with an array that has an element type from debug info.
 array_type = "std::array"
@@ -87,6 +88,7 @@ def test(self):
 "*b.rbegin()", result_type="DbgInfo", 
result_children=dbg_info_elem_children
 )
 
-self.expect_expr(
-"b.at(0)", result_type=value_type, 
result_children=dbg_info_elem_children
-)
+# This check may fail because of compiler optimizations.
+#self.expect_expr(
+#"b.at(0)", result_type=value_type, 
result_children=dbg_info_elem_children
+#)

>From 33226e04aa65bdf86a8923d0617bc716650ab17f Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 16 Oct 2024 10:48:24 +0400
Subject: [PATCH 2/3] Added TestVectorOfVectorsFromStdModule

---
 .../import-std-module/array/TestArrayFromStdModule.py | 8 
 .../vector-of-vectors/TestVectorOfVectorsFromStdModule.py | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
index 7dfff91070db08..515a70c1439dd5 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
@@ -53,7 +53,7 @@ def test(self):
 self.expect_expr("*a.rbegin()", result_type="int", result_value="2")
 
 # This check may fail because of compiler optimizations.
-#self.expect_expr("a.at(0)", result_type=value_type, result_value="3")
+# self.expect_expr("a.at(0)", result_type=value_type, result_value="3")
 
 # Same again with an array that has an element type from debug info.
 array_type = "std::array"
@@ -89,6 +89,6 @@ def test(self):
 )
 
 # This check may fail because of compiler optimizations.
-#self.expect_expr(
-#"b.at(0)", result_type=value_type, 
result_children=dbg_info_elem_children
-#)
+# self.expect_expr(
+# "b.at(0)", result_type=value_type, 
result_children=dbg_info_elem_children
+# )
diff --git 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
index a1f33271f39d2f..f9d44ac4cad205 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
@@ -60,4 +60,5 @@ def test(self):
 "a.front().front()", result_type=value_type, result_value="1"
 )
 self.expect_expr("a[1][1]", result_type=value_type, result_value="2")
-self.expect_expr("a.back().at(0)", result_type=value_type, 
result_value="3")
+# Note calling at(0) may fail because of compiler optimizations.
+self.expect_expr("a.back()[0]", result_type=value_type, 
result_value="3")

>From af2873c4c31f290b41d56f1cd2ca3dc05d500013 Mon Sep 17 00:00:00 2001
Fr

[Lldb-commits] [lldb] [lldb] Narrow scope of -Wno-deprecated-declarations (NFC) (PR #112276)

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

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

Thanks for cleaning this up.

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


[Lldb-commits] [lldb] 3ef630a - [lldb] Support tests with nested make invocations on Windows 2/2 (#112360)

2024-10-16 Thread via lldb-commits

Author: Stefan Gränitz
Date: 2024-10-16T13:07:02+02:00
New Revision: 3ef630ac339f31686290f9460a40eb2a9c9f5bd0

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

LOG: [lldb] Support tests with nested make invocations on Windows 2/2 (#112360)

Following up from https://github.com/llvm/llvm-project/pull/112342, we
roll out the fix and quote nested `make` invocations in all API tests.

Added: 


Modified: 
lldb/test/API/commands/expression/top-level/Makefile
lldb/test/API/commands/expression/weak_symbols/Makefile
lldb/test/API/commands/target/create-deps/Makefile
lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/Makefile
lldb/test/API/functionalities/dlopen_other_executable/Makefile
lldb/test/API/functionalities/exec/Makefile
lldb/test/API/functionalities/jitloader_gdb/Makefile
lldb/test/API/functionalities/limit-debug-info/Makefile
lldb/test/API/functionalities/load_after_attach/Makefile
lldb/test/API/functionalities/load_lazy/Makefile
lldb/test/API/functionalities/load_unload/Makefile
lldb/test/API/functionalities/load_using_paths/Makefile
lldb/test/API/functionalities/scripted_process/Makefile
lldb/test/API/functionalities/stop-on-sharedlibrary-load/Makefile
lldb/test/API/functionalities/tail_call_frames/cross_dso/Makefile
lldb/test/API/functionalities/target-new-solib-notifications/Makefile
lldb/test/API/lang/c/conflicting-symbol/Makefile
lldb/test/API/lang/cpp/incomplete-types/Makefile
lldb/test/API/lang/cpp/namespace_definitions/Makefile
lldb/test/API/lang/objc/conflicting-definition/Makefile
lldb/test/API/lang/objc/modules-hash-mismatch/Makefile
lldb/test/API/macosx/delay-init-dependency/Makefile
lldb/test/API/macosx/expedited-thread-pcs/Makefile
lldb/test/API/macosx/indirect_symbol/Makefile
lldb/test/API/macosx/lc-note/kern-ver-str/Makefile
lldb/test/API/macosx/lc-note/multiple-binary-corefile/Makefile
lldb/test/API/macosx/macCatalystAppMacOSFramework/Makefile
lldb/test/API/macosx/skinny-corefile/Makefile
lldb/test/API/tools/lldb-dap/breakpoint/Makefile
lldb/test/API/tools/lldb-server/libraries-svr4/Makefile

Removed: 




diff  --git a/lldb/test/API/commands/expression/top-level/Makefile 
b/lldb/test/API/commands/expression/top-level/Makefile
index e5e9e78d4ead2a..51b27ddbb3c2f9 100644
--- a/lldb/test/API/commands/expression/top-level/Makefile
+++ b/lldb/test/API/commands/expression/top-level/Makefile
@@ -5,6 +5,6 @@ all: dummy
 include Makefile.rules
 
 dummy: dummy.cpp
-   $(MAKE) -f $(MAKEFILE_RULES) \
+   "$(MAKE)" -f $(MAKEFILE_RULES) \
CXX_SOURCES=dummy.cpp EXE=dummy
 

diff  --git a/lldb/test/API/commands/expression/weak_symbols/Makefile 
b/lldb/test/API/commands/expression/weak_symbols/Makefile
index 6fd8133312ade6..1636e9b3032632 100644
--- a/lldb/test/API/commands/expression/weak_symbols/Makefile
+++ b/lldb/test/API/commands/expression/weak_symbols/Makefile
@@ -9,12 +9,12 @@ a.out: libdylib.dylib
 include Makefile.rules
 
 libdylib.dylib: dylib.c
-   $(MAKE) -C $(BUILDDIR) -f $(MAKEFILE_RULES) \
+   "$(MAKE)" -C $(BUILDDIR) -f $(MAKEFILE_RULES) \
C_SOURCES= DYLIB_C_SOURCES=dylib.c DYLIB_NAME=dylib \
CFLAGS_EXTRAS=-DHAS_THEM LD_EXTRAS=-dynamiclib
 
 hidden/libdylib.dylib:
mkdir hidden
-   $(MAKE) -C $(BUILDDIR)/hidden -f $(MAKEFILE_RULES) \
+   "$(MAKE)" -C $(BUILDDIR)/hidden -f $(MAKEFILE_RULES) \
C_SOURCES= DYLIB_C_SOURCES=dylib.c DYLIB_NAME=dylib \
LD_EXTRAS=-dynamiclib

diff  --git a/lldb/test/API/commands/target/create-deps/Makefile 
b/lldb/test/API/commands/target/create-deps/Makefile
index 3e5b1049b5a19f..866d550ee7d0ae 100644
--- a/lldb/test/API/commands/target/create-deps/Makefile
+++ b/lldb/test/API/commands/target/create-deps/Makefile
@@ -6,5 +6,5 @@ a.out: libload_a
 include Makefile.rules
 
 libload_a:
-   $(MAKE) -f $(MAKEFILE_RULES) \
+   "$(MAKE)" -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_NAME=load_a DYLIB_CXX_SOURCES=a.cpp

diff  --git 
a/lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/Makefile 
b/lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/Makefile
index 0f3fb37bdadf3c..112210e7e2c603 100644
--- a/lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/Makefile
+++ b/lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/Makefile
@@ -2,7 +2,7 @@ CXX_SOURCES := main.cpp
 USE_LIBDL := 1
 
 lib_b:
-   $(MAKE) -f $(MAKEFILE_RULES) \
+   "$(MAKE)" -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_CXX_SOURCES=b.cpp DYLIB_NAME=lib_b
 all: lib_b
 

diff  --git a/lldb/test/API/functionalities/dlopen_other_executable/Makefile 
b/

[Lldb-commits] [lldb] [lldb] Support tests with nested make invocations on Windows 2/2 (PR #112360)

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

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


[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)

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

labath wrote:

> There was an attempt to remove this (https://reviews.llvm.org/D106035) but 
> this hit some issues on Arch and with column counting which is out of scope 
> for what I'm trying to achieve.

I'm not actually sure the approach in that patch is feasible. Last time I 
looked at this (which was a long time ago, to be fair), to problem was 
basically that editline could be built in two modes (wide or not), and we had 
to do something to match what was being used there.

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


[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)

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

https://github.com/labath commented:

[this](https://godbolt.org/z/4WsnMvz5G) _might_ be a non-deprecated way of 
achieving this, though I'm not entirely sure about its portability (windows is 
the main question, but I guess we don't use editline there anyway). I don't 
think you have to do that, but it is an option.

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


[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)

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


@@ -57,6 +57,26 @@
 
 #include "llvm/ADT/FunctionExtras.h"
 
+#if defined(__clang__) && defined(__has_warning)
+#if __has_warning("-Wimplicit-fallthrough")

labath wrote:

implicit fallthrough?

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


[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)

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


@@ -57,6 +57,26 @@
 
 #include "llvm/ADT/FunctionExtras.h"
 
+#if defined(__clang__) && defined(__has_warning)
+#if __has_warning("-Wimplicit-fallthrough")
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\

labath wrote:

Since these are still our (lldb) macro, they should use the LLDB prefix
E.g. LLDB_EDITLINE_DISABLE_DEPRECATED_DECLARATION_WARNINGS (or something 
shorter)

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


[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)

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


@@ -57,6 +57,26 @@
 
 #include "llvm/ADT/FunctionExtras.h"
 
+#if defined(__clang__) && defined(__has_warning)
+#if __has_warning("-Wimplicit-fallthrough")
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+  _Pragma("clang diagnostic push") 
\
+  _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("clang diagnostic pop")

labath wrote:

This doesn't actually define the name that's defined in the fallback (and later 
used). I'd suggest changing the fallback to `#else #define MACRO` so that it 
catches this.

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


[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)

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

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


[Lldb-commits] [lldb] [lldb][test] Move no_unique_address to DWARF/x86 (PR #112523)

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

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

Follow up to https://github.com/llvm/llvm-project/pull/111902.

Makes sure all the `no_unique_address` tests are in the same place and we don't 
rely on the host compiler.

Now that we don't compile with the host compiler, this patch also adds `-c` to 
the compilation command since we don't actually need the linked binary in the 
test anyway (and on Darwin linking through Clang requires the `xcrun` prefix to 
set up the SDK paths, etc.). We already do this in 
`no_unique_address-with-bitfields.cpp` anyway.

>From c22137a5d86786cd414e192ff8ecd769e231670d Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 16 Oct 2024 12:28:44 +0100
Subject: [PATCH] [lldb][test] Move no_unique_address to DWARF/x86

Follow up to https://github.com/llvm/llvm-project/pull/111902.

Makes sure all the `no_unique_address` tests are in the same
place and we don't rely on the host compiler.

Now that we don't compile with the host compiler, this patch
also adds `-c` to the compilation command since we don't actually
need the linked binary in the test anyway (and on Darwin linking
through Clang requires the `xcrun` prefix to set up the SDK paths,
etc.). We already do this in `no_unique_address-with-bitfields.cpp`
anyway.
---
 .../SymbolFile/DWARF/{ => x86}/no_unique_address-alignment.cpp  | 2 +-
 .../DWARF/{ => x86}/no_unique_address-base-alignment.cpp| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename lldb/test/Shell/SymbolFile/DWARF/{ => 
x86}/no_unique_address-alignment.cpp (89%)
 rename lldb/test/Shell/SymbolFile/DWARF/{ => 
x86}/no_unique_address-base-alignment.cpp (91%)

diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-alignment.cpp
similarity index 89%
rename from lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
rename to lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-alignment.cpp
index 1488199a3ad2d3..e198bf0cafeaac 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-alignment.cpp
@@ -1,6 +1,6 @@
 // XFAIL: *
 
-// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %clang --target=x86_64-apple-macosx -c -gdwarf -o %t %s
 // RUN: %lldb %t \
 // RUN:   -o "expr alignof(OverlappingFields)" \
 // RUN:   -o "expr sizeof(OverlappingFields)" \
diff --git 
a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-base-alignment.cpp
similarity index 91%
rename from 
lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp
rename to 
lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-base-alignment.cpp
index 15d8de0e3ee988..c4bcfc473277f6 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-base-alignment.cpp
@@ -1,6 +1,6 @@
 // XFAIL: *
 
-// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %clang --target=x86_64-apple-macosx -c -gdwarf -o %t %s
 // RUN: %lldb %t \
 // RUN:   -o "expr alignof(OverlappingDerived)" \
 // RUN:   -o "expr sizeof(OverlappingDerived)" \

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


[Lldb-commits] [lldb] [lldb][test] Fixed the test `no_unique_address-with-bitfields` (PR #111902)

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

Michael137 wrote:

> I would recommend that -- then you wouldn't need to worry about how to spell 
> [[no_unique_address]] on windows.

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

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


[Lldb-commits] [lldb] [lldb][test] Move no_unique_address tests to DWARF/x86 (PR #112523)

2024-10-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

Follow up to https://github.com/llvm/llvm-project/pull/111902.

Makes sure all the `no_unique_address` tests are in the same place and we don't 
rely on the host compiler.

Now that we don't compile with the host compiler, this patch also adds `-c` to 
the compilation command since we don't actually need the linked binary in the 
test anyway (and on Darwin linking through Clang requires the `xcrun` prefix to 
set up the SDK paths, etc.). We already do this in 
`no_unique_address-with-bitfields.cpp` anyway.

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


2 Files Affected:

- (renamed) 
lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-alignment.cpp (+1-1) 
- (renamed) 
lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-base-alignment.cpp 
(+1-1) 


``diff
diff --git a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-alignment.cpp
similarity index 89%
rename from lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
rename to lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-alignment.cpp
index 1488199a3ad2d3..e198bf0cafeaac 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-alignment.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-alignment.cpp
@@ -1,6 +1,6 @@
 // XFAIL: *
 
-// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %clang --target=x86_64-apple-macosx -c -gdwarf -o %t %s
 // RUN: %lldb %t \
 // RUN:   -o "expr alignof(OverlappingFields)" \
 // RUN:   -o "expr sizeof(OverlappingFields)" \
diff --git 
a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-base-alignment.cpp
similarity index 91%
rename from 
lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp
rename to 
lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-base-alignment.cpp
index 15d8de0e3ee988..c4bcfc473277f6 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/no_unique_address-base-alignment.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/no_unique_address-base-alignment.cpp
@@ -1,6 +1,6 @@
 // XFAIL: *
 
-// RUN: %clangxx_host -gdwarf -o %t %s
+// RUN: %clang --target=x86_64-apple-macosx -c -gdwarf -o %t %s
 // RUN: %lldb %t \
 // RUN:   -o "expr alignof(OverlappingDerived)" \
 // RUN:   -o "expr sizeof(OverlappingDerived)" \

``




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


[Lldb-commits] [lldb] [lldb][test] Move no_unique_address tests to DWARF/x86 (PR #112523)

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

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


[Lldb-commits] [lldb] [lldb][test] Explicitly add target triple to no_unique_address Shell tests (PR #112523)

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

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


[Lldb-commits] [lldb] [lldb] Support tests with nested make invocations on Windows 2/2 (PR #112360)

2024-10-16 Thread David Spickett via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][test] Enable static linking with libcxx for import-std-module tests (PR #98701)

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

slydiman wrote:

Those linker flags work on Windows. 
Note I tried to add the usage of a.at(0) to main.cpp and it did not help.
Please see the alternative patch #112485.

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


[Lldb-commits] [lldb] [lldb][test] Fix TestStdCXXDisassembly test (PR #112357)

2024-10-16 Thread via lldb-commits

zeroomega wrote:

We are seeing test failures on `lldb-api :: lang/cpp/stl/TestSTL.py` after this 
patch is landed.
```
Error when building test subject.

Build Command:
/b/s/w/ir/x/w/cipd/bin/make 
VPATH=/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl -C 
/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/lang/cpp/stl/TestSTL.test_SBType_template_aspects_dwarf
 -I /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl -I 
/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/make -f 
/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl/Makefile 
MAKE_DSYM=NO all ARCH=x86_64 CC=/b/s/w/ir/x/w/cipd/clang/bin/clang 
CC_TYPE=clang CXX=/b/s/w/ir/x/w/cipd/clang/bin/clang++ 
LLVM_AR=/b/s/w/ir/x/w/llvm_build/./bin/llvm-ar 
AR=/b/s/w/ir/x/w/llvm_build/./bin/llvm-ar 
OBJCOPY=/b/s/w/ir/x/w/llvm_build/./bin/llvm-objcopy 
STRIP=/b/s/w/ir/x/w/llvm_build/./bin/llvm-strip 
ARCHIVER=/b/s/w/ir/x/w/llvm_build/./bin/llvm-ar 
DWP=/b/s/w/ir/x/w/llvm_build/./bin/llvm-dwp 
CLANG_MODULE_CACHE_DIR=/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-clang/lldb-api
 LLDB_OBJ_ROOT=/b/s/w/ir/x/w/llvm_build/tools/lldb OS=Linux HOST_OS=Linux

Build Command Output:
make: Entering directory 
'/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/lang/cpp/stl/TestSTL.test_SBType_template_aspects_dwarf'
/b/s/w/ir/x/w/cipd/clang/bin/clang++  -std=c++11 -g -O0  -m64 
-I/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include
 -I/b/s/w/ir/x/w/llvm_build/tools/lldb/include 
-I/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl 
-I/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/make 
-include 
/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h
 -fno-limit-debug-info-stdlib=libstdc++   --driver-mode=g++ -MT main.o -MD 
-MP -MF main.d -c -o main.o 
/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl/main.cpp
/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl/main.cpp:1:10: fatal 
error: 'cstdio' file not found
1 | #include 
  |  ^~~~
1 error generated.
make: *** [Makefile.rules:608: main.o] Error 1
make: Leaving directory 
'/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/lang/cpp/stl/TestSTL.test_SBType_template_aspects_dwarf'

```

Looking at the clang invocation, I believe the issue is that it forced the test 
to be build with GNU libstdc++ , and our bots don't have any GNU toolchain 
installed.

Is there a reason why LLDB doesn't use LLVM's own libc++?
And if libstdc++ is not present, shouldn't the build system just disable the 
test that depends on it instead of blindly assume it exists?

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


[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-16 Thread Nikita Popov via lldb-commits


@@ -437,7 +437,9 @@ ExprResult Parser::createEmbedExpr() {
   SourceLocation StartLoc = ConsumeAnnotationToken();
   if (Data->BinaryData.size() == 1) {
 Res = IntegerLiteral::Create(Context,
- llvm::APInt(CHAR_BIT, 
Data->BinaryData.back()),
+ llvm::APInt(CHAR_BIT, Data->BinaryData.back(),

nikic wrote:

Done, though I used `(unsigned char)` to match `CHAR_BIT` more closely.

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


[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-16 Thread Nikita Popov via lldb-commits


@@ -3600,8 +3600,11 @@ ExprResult Sema::ActOnCharacterConstant(const Token 
&Tok, Scope *UDLScope) {
 
 ExprResult Sema::ActOnIntegerConstant(SourceLocation Loc, uint64_t Val) {
   unsigned IntSize = Context.getTargetInfo().getIntWidth();
-  return IntegerLiteral::Create(Context, llvm::APInt(IntSize, Val),
-Context.IntTy, Loc);
+  // TODO: Avoid implicit trunc?
+  return IntegerLiteral::Create(
+  Context,
+  llvm::APInt(IntSize, Val, /*isSigned=*/false, /*implicitTrunc=*/true),

nikic wrote:

I've changed this to set isSigned=true and updated the signature to use int64_t 
instead of uint64_t to clarify that a signed value is expected.

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


[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-16 Thread Nikita Popov via lldb-commits

https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/80309

>From 96795194fc79359363bac0423516da2a06733047 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Thu, 19 Sep 2024 17:27:13 +0200
Subject: [PATCH 1/5] apint only

---
 clang/lib/AST/ByteCode/IntegralAP.h   |  6 ++--
 clang/lib/CodeGen/CGVTT.cpp   |  5 +--
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  5 +--
 clang/lib/Parse/ParseInit.cpp |  4 ++-
 clang/lib/Sema/SemaExpr.cpp   |  7 ++--
 clang/lib/Sema/SemaOpenMP.cpp |  4 ++-
 lldb/source/Expression/DWARFExpression.cpp|  7 ++--
 llvm/include/llvm/ADT/APFixedPoint.h  |  4 ++-
 llvm/lib/Analysis/ConstantFolding.cpp |  3 +-
 llvm/lib/Analysis/Loads.cpp   |  6 ++--
 llvm/lib/Analysis/MemoryBuiltins.cpp  |  2 ++
 llvm/lib/Analysis/ScalarEvolution.cpp |  2 +-
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  3 +-
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp |  5 ++-
 .../SelectionDAG/SelectionDAGBuilder.cpp  |  3 +-
 .../CodeGen/SelectionDAG/SelectionDAGISel.cpp |  8 +++--
 .../CodeGen/SelectionDAG/TargetLowering.cpp   |  8 +++--
 llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp  |  2 +-
 llvm/lib/IR/Constants.cpp |  4 ++-
 .../Target/AArch64/AArch64ISelLowering.cpp| 32 +--
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp|  3 +-
 .../Target/AMDGPU/SIShrinkInstructions.cpp|  4 +--
 .../lib/Target/ARM/AsmParser/ARMAsmParser.cpp |  4 ++-
 .../Hexagon/HexagonConstPropagation.cpp   |  3 +-
 llvm/lib/Target/Hexagon/HexagonGenExtract.cpp |  2 +-
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp   |  4 ++-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  6 ++--
 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp |  3 +-
 llvm/lib/Transforms/Utils/SimplifyCFG.cpp |  2 +-
 llvm/unittests/ADT/APFixedPointTest.cpp   |  9 +++---
 30 files changed, 99 insertions(+), 61 deletions(-)

diff --git a/clang/lib/AST/ByteCode/IntegralAP.h 
b/clang/lib/AST/ByteCode/IntegralAP.h
index a4d656433344b7..6ab3d09ec85d5b 100644
--- a/clang/lib/AST/ByteCode/IntegralAP.h
+++ b/clang/lib/AST/ByteCode/IntegralAP.h
@@ -61,7 +61,7 @@ template  class IntegralAP final {
 
   IntegralAP(APInt V) : V(V) {}
   /// Arbitrary value for uninitialized variables.
-  IntegralAP() : IntegralAP(-1, 3) {}
+  IntegralAP() : IntegralAP(Signed ? -1 : 7, 3) {}
 
   IntegralAP operator-() const { return IntegralAP(-V); }
   IntegralAP operator-(const IntegralAP &Other) const {
@@ -112,7 +112,9 @@ template  class IntegralAP final {
 
   template 
   static IntegralAP from(Integral I, unsigned BitWidth) {
-APInt Copy = APInt(BitWidth, static_cast(I), InputSigned);
+// TODO: Avoid implicit trunc?
+APInt Copy = APInt(BitWidth, static_cast(I), InputSigned,
+   /*implicitTrunc=*/true);
 
 return IntegralAP(Copy);
   }
diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp
index 20bd2c2fc2c642..989a07d09d50ee 100644
--- a/clang/lib/CodeGen/CGVTT.cpp
+++ b/clang/lib/CodeGen/CGVTT.cpp
@@ -85,8 +85,9 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,
  cast(VTable->getValueType())
  ->getElementType(AddressPoint.VTableIndex));
  unsigned Offset = ComponentSize * AddressPoint.AddressPointIndex;
- llvm::ConstantRange InRange(llvm::APInt(32, -Offset, true),
- llvm::APInt(32, VTableSize - Offset, true));
+ llvm::ConstantRange InRange(
+ llvm::APInt(32, (int)-Offset, true),
+ llvm::APInt(32, (int)(VTableSize - Offset), true));
  llvm::Constant *Init = llvm::ConstantExpr::getGetElementPtr(
  VTable->getValueType(), VTable, Idxs, /*InBounds=*/true, InRange);
 
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 75dab596e1b2c4..5bb0765cb0249c 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2099,8 +2099,9 @@ ItaniumCXXABI::getVTableAddressPoint(BaseSubobject Base,
   unsigned VTableSize =
   ComponentSize * Layout.getVTableSize(AddressPoint.VTableIndex);
   unsigned Offset = ComponentSize * AddressPoint.AddressPointIndex;
-  llvm::ConstantRange InRange(llvm::APInt(32, -Offset, true),
-  llvm::APInt(32, VTableSize - Offset, true));
+  llvm::ConstantRange InRange(
+  llvm::APInt(32, (int)-Offset, true),
+  llvm::APInt(32, (int)(VTableSize - Offset), true));
   return llvm::ConstantExpr::getGetElementPtr(
   VTable->getValueType(), VTable, Indices, /*InBounds=*/true, InRange);
 }
diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 0a9a359cdaf979..e7c8d79ac3 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -437,7 +437,9 @@ ExprResult Parser::createEmbedExpr() {
   SourceLocation StartLoc = ConsumeAnnotationToken();
   if (Data->BinaryDa

[Lldb-commits] [lldb] [lldb] Improve unwinding for discontinuous functions (PR #111409)

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

labath wrote:

Thanks Jason. I have no doubt that the failure was triggered by this patch (the 
test tests unwinding, the patch touches unwinding), but the mechanism itself is 
very unclear to me. The functions in that patch have a valid eh_frame (and they 
don't have debug info), so I would expect that a change like this would be a 
noop in this case. I suspect there's something subtle going on, and that this 
could very well be a bug in some other lldb component, but it's hard tell what 
that is without more info. It could also easily depend on some system code that 
makes its way into the debugged process (process startup code and stuff). If 
you're unable to reproduce this on your machine, maybe we'll have to modify the 
test to dump loads of extra output to make sense of it.

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


[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-16 Thread Nikita Popov via lldb-commits

https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/80309

>From 96795194fc79359363bac0423516da2a06733047 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Thu, 19 Sep 2024 17:27:13 +0200
Subject: [PATCH 1/6] apint only

---
 clang/lib/AST/ByteCode/IntegralAP.h   |  6 ++--
 clang/lib/CodeGen/CGVTT.cpp   |  5 +--
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  5 +--
 clang/lib/Parse/ParseInit.cpp |  4 ++-
 clang/lib/Sema/SemaExpr.cpp   |  7 ++--
 clang/lib/Sema/SemaOpenMP.cpp |  4 ++-
 lldb/source/Expression/DWARFExpression.cpp|  7 ++--
 llvm/include/llvm/ADT/APFixedPoint.h  |  4 ++-
 llvm/lib/Analysis/ConstantFolding.cpp |  3 +-
 llvm/lib/Analysis/Loads.cpp   |  6 ++--
 llvm/lib/Analysis/MemoryBuiltins.cpp  |  2 ++
 llvm/lib/Analysis/ScalarEvolution.cpp |  2 +-
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |  3 +-
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp |  5 ++-
 .../SelectionDAG/SelectionDAGBuilder.cpp  |  3 +-
 .../CodeGen/SelectionDAG/SelectionDAGISel.cpp |  8 +++--
 .../CodeGen/SelectionDAG/TargetLowering.cpp   |  8 +++--
 llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp  |  2 +-
 llvm/lib/IR/Constants.cpp |  4 ++-
 .../Target/AArch64/AArch64ISelLowering.cpp| 32 +--
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp|  3 +-
 .../Target/AMDGPU/SIShrinkInstructions.cpp|  4 +--
 .../lib/Target/ARM/AsmParser/ARMAsmParser.cpp |  4 ++-
 .../Hexagon/HexagonConstPropagation.cpp   |  3 +-
 llvm/lib/Target/Hexagon/HexagonGenExtract.cpp |  2 +-
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp   |  4 ++-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  6 ++--
 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp |  3 +-
 llvm/lib/Transforms/Utils/SimplifyCFG.cpp |  2 +-
 llvm/unittests/ADT/APFixedPointTest.cpp   |  9 +++---
 30 files changed, 99 insertions(+), 61 deletions(-)

diff --git a/clang/lib/AST/ByteCode/IntegralAP.h 
b/clang/lib/AST/ByteCode/IntegralAP.h
index a4d656433344b7..6ab3d09ec85d5b 100644
--- a/clang/lib/AST/ByteCode/IntegralAP.h
+++ b/clang/lib/AST/ByteCode/IntegralAP.h
@@ -61,7 +61,7 @@ template  class IntegralAP final {
 
   IntegralAP(APInt V) : V(V) {}
   /// Arbitrary value for uninitialized variables.
-  IntegralAP() : IntegralAP(-1, 3) {}
+  IntegralAP() : IntegralAP(Signed ? -1 : 7, 3) {}
 
   IntegralAP operator-() const { return IntegralAP(-V); }
   IntegralAP operator-(const IntegralAP &Other) const {
@@ -112,7 +112,9 @@ template  class IntegralAP final {
 
   template 
   static IntegralAP from(Integral I, unsigned BitWidth) {
-APInt Copy = APInt(BitWidth, static_cast(I), InputSigned);
+// TODO: Avoid implicit trunc?
+APInt Copy = APInt(BitWidth, static_cast(I), InputSigned,
+   /*implicitTrunc=*/true);
 
 return IntegralAP(Copy);
   }
diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp
index 20bd2c2fc2c642..989a07d09d50ee 100644
--- a/clang/lib/CodeGen/CGVTT.cpp
+++ b/clang/lib/CodeGen/CGVTT.cpp
@@ -85,8 +85,9 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,
  cast(VTable->getValueType())
  ->getElementType(AddressPoint.VTableIndex));
  unsigned Offset = ComponentSize * AddressPoint.AddressPointIndex;
- llvm::ConstantRange InRange(llvm::APInt(32, -Offset, true),
- llvm::APInt(32, VTableSize - Offset, true));
+ llvm::ConstantRange InRange(
+ llvm::APInt(32, (int)-Offset, true),
+ llvm::APInt(32, (int)(VTableSize - Offset), true));
  llvm::Constant *Init = llvm::ConstantExpr::getGetElementPtr(
  VTable->getValueType(), VTable, Idxs, /*InBounds=*/true, InRange);
 
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 75dab596e1b2c4..5bb0765cb0249c 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2099,8 +2099,9 @@ ItaniumCXXABI::getVTableAddressPoint(BaseSubobject Base,
   unsigned VTableSize =
   ComponentSize * Layout.getVTableSize(AddressPoint.VTableIndex);
   unsigned Offset = ComponentSize * AddressPoint.AddressPointIndex;
-  llvm::ConstantRange InRange(llvm::APInt(32, -Offset, true),
-  llvm::APInt(32, VTableSize - Offset, true));
+  llvm::ConstantRange InRange(
+  llvm::APInt(32, (int)-Offset, true),
+  llvm::APInt(32, (int)(VTableSize - Offset), true));
   return llvm::ConstantExpr::getGetElementPtr(
   VTable->getValueType(), VTable, Indices, /*InBounds=*/true, InRange);
 }
diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 0a9a359cdaf979..e7c8d79ac3 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -437,7 +437,9 @@ ExprResult Parser::createEmbedExpr() {
   SourceLocation StartLoc = ConsumeAnnotationToken();
   if (Data->BinaryDa

[Lldb-commits] [lldb] [lldb][test] Enable static linking with libcxx for import-std-module tests (PR #98701)

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

Michael137 wrote:

> I guess it will with clang+lld (which is the only way we can run the test 
> suite now), though I still find this suboptimal -- in particular, I think the 
> multiple definition thingy plants us firmly into undefined behavior territory.
> 
> Did you check that `at(0)` actually causes the necessary symbols to be pulled 
> into the binary? If yes, why can't we find them? If not, why not?

Agree with Pavel here, it would be good to figure out what exactly is going 
wrong in this test.

FWIW, we don't actually want to emit `at` into the debug-info. This test 
specifically tests the case where we don't have the debug-info for a function, 
but are able to find and call it using the `std` Clang module. IIRC from the 
last time we saw this, the problem only occurs when debug symbols for libc++ 
are available (https://reviews.llvm.org/D139361).

Since this is quite tricky to debug, and has been a known issue for a while and 
(i think) only happens when we built libc++ with debug symbols, I'd be fine 
with skipping the test on Linux until we figure out what the root cause is.

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


[Lldb-commits] [lldb] [lldb][test] Fix tests Test*FromStdModule where called missing at(0) (PR #112485)

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

Michael137 wrote:

As mentioned in 
https://github.com/llvm/llvm-project/pull/98701#issuecomment-2416223393, the 
test deliberately omits `at` from debug-info.

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


[Lldb-commits] [lldb] [lldb][test] Fix TestStdCXXDisassembly test (PR #112357)

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

Michael137 wrote:

> We are seeing test failures on `lldb-api :: lang/cpp/stl/TestSTL.py` after 
> this patch is landed.
> 
> ```
> Error when building test subject.
> 
> Build Command:
> /b/s/w/ir/x/w/cipd/bin/make 
> VPATH=/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl -C 
> /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/lang/cpp/stl/TestSTL.test_SBType_template_aspects_dwarf
>  -I /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl -I 
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/make -f 
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl/Makefile 
> MAKE_DSYM=NO all ARCH=x86_64 CC=/b/s/w/ir/x/w/cipd/clang/bin/clang 
> CC_TYPE=clang CXX=/b/s/w/ir/x/w/cipd/clang/bin/clang++ 
> LLVM_AR=/b/s/w/ir/x/w/llvm_build/./bin/llvm-ar 
> AR=/b/s/w/ir/x/w/llvm_build/./bin/llvm-ar 
> OBJCOPY=/b/s/w/ir/x/w/llvm_build/./bin/llvm-objcopy 
> STRIP=/b/s/w/ir/x/w/llvm_build/./bin/llvm-strip 
> ARCHIVER=/b/s/w/ir/x/w/llvm_build/./bin/llvm-ar 
> DWP=/b/s/w/ir/x/w/llvm_build/./bin/llvm-dwp 
> CLANG_MODULE_CACHE_DIR=/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-clang/lldb-api
>  LLDB_OBJ_ROOT=/b/s/w/ir/x/w/llvm_build/tools/lldb OS=Linux HOST_OS=Linux
> 
> Build Command Output:
> make: Entering directory 
> '/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/lang/cpp/stl/TestSTL.test_SBType_template_aspects_dwarf'
> /b/s/w/ir/x/w/cipd/clang/bin/clang++  -std=c++11 -g -O0  -m64 
> -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include
>  -I/b/s/w/ir/x/w/llvm_build/tools/lldb/include 
> -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl 
> -I/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/make 
> -include 
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h
>  -fno-limit-debug-info-stdlib=libstdc++   --driver-mode=g++ -MT main.o 
> -MD -MP -MF main.d -c -o main.o 
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl/main.cpp
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/stl/main.cpp:1:10: 
> fatal error: 'cstdio' file not found
> 1 | #include 
>   |  ^~~~
> 1 error generated.
> make: *** [Makefile.rules:608: main.o] Error 1
> make: Leaving directory 
> '/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/lang/cpp/stl/TestSTL.test_SBType_template_aspects_dwarf'
> ```
> 
> Failed bot task: 
> https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/lldb-linux-x64/b8733980216892309505/overview

Lets just revert the Makefile changes in this PR and let the test pick 
whatever's on the system. The test changes ensure we skip it in the statically 
linked builds.

> Is there a reason why LLDB doesn't use LLVM's own libc++? And if libstdc++ is 
> not present, shouldn't the build system just disable the test that depends on 
> it instead of blindly assume it exists?

We do use a local libc++ build for libc++-specific tests. Otherwise we just use 
whatever is on the system. I do think the silent fallbacks in some cases could 
be cleaned up: 
https://github.com/llvm/llvm-project/pull/106885#pullrequestreview-2275238360. 
Though I'm a bit surprised clang lets you specify `-stdlib=libstdc++` but not 
warn/error out when it's ignored.

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


[Lldb-commits] [lldb] [lldb][LoongArch64] Add support for LoongArch64 in elf-core for lldb (PR #112296)

2024-10-16 Thread Lu Weining via lldb-commits

SixWeining wrote:

Seems we the same `GetRegisterSetCount` misprint issue as #93297.

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


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

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


@@ -290,6 +290,30 @@ The initial repl-mode can be configured with the cli flag 
`--repl-mode=`
 and may also be adjusted at runtime using the lldb command
 `lldb-dap repl-mode `.
 
+ `lldb-dap custom-event`

vogelsgesang wrote:

Thanks, the updated documentation & blocking of internally handled events looks 
good to me

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


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

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


@@ -962,6 +962,44 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   return true;
 }
 
+// Sends a custom DAP event with an optional body.
+//
+// See
+// 
https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent
+bool CustomDAPEventRequestHandler::DoExecute(
+lldb::SBDebugger debugger, char **command,
+lldb::SBCommandReturnObject &result) {
+  // Command format like: `custom-event  ?`

vogelsgesang wrote:

I couldn't find where we are handling this in the code. Did you already update 
the PR with those changes?

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


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

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


@@ -962,6 +962,68 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   return true;
 }
 
+// Sends a DAP event with an optional body.
+//
+// See
+// 
https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent
+bool SendEventRequestHandler::DoExecute(lldb::SBDebugger debugger,
+char **command,
+lldb::SBCommandReturnObject &result) {
+  // Command format like: `send-event  ?`
+  if (!command || !command[0] || llvm::StringRef(command[0]).empty()) {
+result.SetError("Not enough arguments found, expected format "
+"`lldb-dap send-event  ?`.");
+return false;
+  }
+
+  llvm::StringRef name{command[0]};
+  // Events that are stateful and should be handled by lldb-dap internally.
+  const std::array internal_events{"breakpoint", "capabilities", "continued",
+   "exited", "initialize",   
"loadedSource",
+   "module", "process",  "stopped",
+   "terminated", "thread"};
+  if (std::find(internal_events.begin(), internal_events.end(), name) !=
+  std::end(internal_events)) {
+std::string msg =
+llvm::formatv("Invalid use of lldb-dap send-event, event \"{0}\" "
+  "should be handled by lldb-dap internally.",
+  name)
+.str();
+result.SetError(msg.c_str());
+return false;
+  }
+
+  llvm::json::Object event(CreateEventObject(name));
+
+  if (command[1] && !llvm::StringRef(command[1]).empty()) {
+// See if we have to unused arguments.
+if (command[2] && !llvm::StringRef(command[2]).empty()) {

vogelsgesang wrote:

this would still allow things like `lldb-dap send-event foo bar "" "" baz`. I 
would have expected a condition similar to `command.size() >= 2`

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


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

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


@@ -962,6 +962,44 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   return true;
 }
 
+// Sends a custom DAP event with an optional body.
+//
+// See
+// 
https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent
+bool CustomDAPEventRequestHandler::DoExecute(
+lldb::SBDebugger debugger, char **command,
+lldb::SBCommandReturnObject &result) {
+  // Command format like: `custom-event  ?`

vogelsgesang wrote:

Ah, I found it now. Looked a bit different than what I had in mind, and hence 
my simple scanning for `size()` didn't find it. See other comment

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


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

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

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


[Lldb-commits] [lldb] [lldb][test] Fix TestStdCXXDisassembly test (PR #112357)

2024-10-16 Thread via lldb-commits


@@ -1,5 +1,9 @@
 CXX_SOURCES := main.cpp
 
-USE_SYSTEM_STDLIB := 1
+ifneq ($(OS),Darwin)
+USE_LIBSTDCPP := 1

zeroomega wrote:

This will break every test under `lldb/test/API/lang/cpp/stl` on non darwin 
machines if GNU libstdc++ is not installed.

I don't think it is a correct to assume the host machine has libstdc++. Plenty 
of bots are set up in a way to avoid introducing GNU toolchains in a LLVM build 
implicitly by removing the entire GNU toolchain from the host machine. It 
appears the upstream LLDB bots are not set up in this way.

If libstdc++ is required to run this test (and it is the indended behavior), 
the correct way is to introduce LLVM cmake flag, e.g. `LLDB_STDCPP_PATH` to 
explicitly specify the path to the libstdc++, and disable the tests that 
depends on it in the build system. 

But from what I see in the patch history. I believe both tests are not bound to 
a specific c++ lib. It just need either libc++ or libstdc++. If that is the 
case, the way this patch address the test failure on upstream llvm bot is 
wrong. It is likely the bot doesn't have libc++ but have libstdc++ but its path 
failed to be determined by the test runner. If that is the case, the correct 
way it to fix the test runner instead of forcing using libstdc++ regardless of 
host environment.

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


[Lldb-commits] [lldb] [lldb][test] Fix tests Test*FromStdModule where called missing at(0) (PR #112485)

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

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


[Lldb-commits] [lldb] [lldb][test] Explicitly add target triple to no_unique_address Shell tests (PR #112523)

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

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


[Lldb-commits] [lldb] [lldb] Don't exit the main loop when in runs out of things to listen on (PR #112565)

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

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

This behavior made sense in the beginning as the class was completely single 
threaded, so if the source count ever reached zero, there was no way to add new 
ones. In https://reviews.llvm.org/D131160, the class gained the ability to add 
events (callbacks) from other threads, which means that is no longer the case 
(and indeed, one possible use case for this class -- acting as a sort of 
arbiter for multiple threads wanting to run code while making sure it runs 
serially -- has this class sit in an empty Run call most of the time). I'm not 
aware of us having a use for such a thing right now, but one of my tests in 
another patch turned into something similar by accident.

Another problem with the current approach is that, in a distributed/dynamic 
setup (multiple things using the main loop without a clear coordinator), one 
can never be sure whether unregistering a specific event will terminate the 
loop (it depends on whether there are other listeners). We had this problem in 
lldb-platform.cpp, where we had to add an additional layer of synchronization 
to avoid premature termination. We can remove this if we can rely on the loop 
terminating only when we tell it to.

>From 8a531630f6b233d83f33740ce9dbbd9b3a778641 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 16 Oct 2024 16:54:06 +0200
Subject: [PATCH] [lldb] Don't exit the main loop when in runs out of things to
 listen on

This behavior made sense in the beginning as the class was completely
single threaded, so if the source count ever reached zero, there was no
way to add new ones. In https://reviews.llvm.org/D131160, the class
gained the ability to add events (callbacks) from other threads, which
means that is no longer the case (and indeed, one possible use case for
this class -- acting as a sort of arbiter for multiple threads
wanting to run code while making sure it runs serially -- has this class
sit in an empty Run call most of the time). I'm not aware of us having a
use for such a thing right now, but one of my tests in another patch
turned into something similar by accident.

Another problem with the current approach is that, in a
distributed/dynamic setup (multiple things using the main loop without a
clear coordinator), one can never be sure whether unregistering a
specific event will terminate the loop (it depends on whether there are
other listeners). We had this problem in lldb-platform.cpp, where we had
to add an additional layer of synchronization to avoid premature
termination. We can remove this if we can rely on the loop terminating
only when we tell it to.
---
 lldb/source/Host/posix/MainLoopPosix.cpp |  5 +
 lldb/source/Host/windows/MainLoopWindows.cpp |  4 +---
 lldb/tools/lldb-server/lldb-platform.cpp | 23 +++-
 lldb/unittests/Host/MainLoopTest.cpp | 11 +-
 4 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp 
b/lldb/source/Host/posix/MainLoopPosix.cpp
index 816581e70294a7..6f8eaa55cfdf09 100644
--- a/lldb/source/Host/posix/MainLoopPosix.cpp
+++ b/lldb/source/Host/posix/MainLoopPosix.cpp
@@ -365,10 +365,7 @@ Status MainLoopPosix::Run() {
   Status error;
   RunImpl impl(*this);
 
-  // run until termination or until we run out of things to listen to
-  // (m_read_fds will always contain m_trigger_pipe fd, so check for > 1)
-  while (!m_terminate_request &&
- (m_read_fds.size() > 1 || !m_signals.empty())) {
+  while (!m_terminate_request) {
 error = impl.Poll();
 if (error.Fail())
   return error;
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp 
b/lldb/source/Host/windows/MainLoopWindows.cpp
index 88d929535ab6c5..c9aa6d339d8f48 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -116,9 +116,7 @@ Status MainLoopWindows::Run() {
 
   Status error;
 
-  // run until termination or until we run out of things to listen to
-  while (!m_terminate_request && !m_read_fds.empty()) {
-
+  while (!m_terminate_request) {
 llvm::Expected signaled_event = Poll();
 if (!signaled_event)
   return Status::FromError(signaled_event.takeError());
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 2ef780578d0a28..d702f07deabd31 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -260,8 +260,7 @@ static void 
client_handle(GDBRemoteCommunicationServerPlatform &platform,
 static Status spawn_process(const char *progname, const Socket *conn_socket,
 uint16_t gdb_port, const lldb_private::Args &args,
 const std::string &log_file,
-const StringRef log_channels, MainLoop &main_loop,
-std::promise &child_exited) {
+const String

[Lldb-commits] [lldb] [lldb] Don't exit the main loop when in runs out of things to listen on (PR #112565)

2024-10-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

This behavior made sense in the beginning as the class was completely single 
threaded, so if the source count ever reached zero, there was no way to add new 
ones. In https://reviews.llvm.org/D131160, the class gained the ability to add 
events (callbacks) from other threads, which means that is no longer the case 
(and indeed, one possible use case for this class -- acting as a sort of 
arbiter for multiple threads wanting to run code while making sure it runs 
serially -- has this class sit in an empty Run call most of the time). I'm not 
aware of us having a use for such a thing right now, but one of my tests in 
another patch turned into something similar by accident.

Another problem with the current approach is that, in a distributed/dynamic 
setup (multiple things using the main loop without a clear coordinator), one 
can never be sure whether unregistering a specific event will terminate the 
loop (it depends on whether there are other listeners). We had this problem in 
lldb-platform.cpp, where we had to add an additional layer of synchronization 
to avoid premature termination. We can remove this if we can rely on the loop 
terminating only when we tell it to.

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


4 Files Affected:

- (modified) lldb/source/Host/posix/MainLoopPosix.cpp (+1-4) 
- (modified) lldb/source/Host/windows/MainLoopWindows.cpp (+1-3) 
- (modified) lldb/tools/lldb-server/lldb-platform.cpp (+8-15) 
- (modified) lldb/unittests/Host/MainLoopTest.cpp (+5-6) 


``diff
diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp 
b/lldb/source/Host/posix/MainLoopPosix.cpp
index 816581e70294a7..6f8eaa55cfdf09 100644
--- a/lldb/source/Host/posix/MainLoopPosix.cpp
+++ b/lldb/source/Host/posix/MainLoopPosix.cpp
@@ -365,10 +365,7 @@ Status MainLoopPosix::Run() {
   Status error;
   RunImpl impl(*this);
 
-  // run until termination or until we run out of things to listen to
-  // (m_read_fds will always contain m_trigger_pipe fd, so check for > 1)
-  while (!m_terminate_request &&
- (m_read_fds.size() > 1 || !m_signals.empty())) {
+  while (!m_terminate_request) {
 error = impl.Poll();
 if (error.Fail())
   return error;
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp 
b/lldb/source/Host/windows/MainLoopWindows.cpp
index 88d929535ab6c5..c9aa6d339d8f48 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -116,9 +116,7 @@ Status MainLoopWindows::Run() {
 
   Status error;
 
-  // run until termination or until we run out of things to listen to
-  while (!m_terminate_request && !m_read_fds.empty()) {
-
+  while (!m_terminate_request) {
 llvm::Expected signaled_event = Poll();
 if (!signaled_event)
   return Status::FromError(signaled_event.takeError());
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 2ef780578d0a28..d702f07deabd31 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -260,8 +260,7 @@ static void 
client_handle(GDBRemoteCommunicationServerPlatform &platform,
 static Status spawn_process(const char *progname, const Socket *conn_socket,
 uint16_t gdb_port, const lldb_private::Args &args,
 const std::string &log_file,
-const StringRef log_channels, MainLoop &main_loop,
-std::promise &child_exited) {
+const StringRef log_channels, MainLoop &main_loop) 
{
   Status error;
   SharedSocket shared_socket(conn_socket, error);
   if (error.Fail())
@@ -301,12 +300,10 @@ static Status spawn_process(const char *progname, const 
Socket *conn_socket,
   if (g_server)
 launch_info.SetMonitorProcessCallback([](lldb::pid_t, int, int) {});
   else
-launch_info.SetMonitorProcessCallback(
-[&child_exited, &main_loop](lldb::pid_t, int, int) {
-  main_loop.AddPendingCallback(
-  [](MainLoopBase &loop) { loop.RequestTermination(); });
-  child_exited.set_value();
-});
+launch_info.SetMonitorProcessCallback([&main_loop](lldb::pid_t, int, int) {
+  main_loop.AddPendingCallback(
+  [](MainLoopBase &loop) { loop.RequestTermination(); });
+});
 
   // Copy the current environment.
   launch_info.GetEnvironment() = Host::GetEnvironment();
@@ -550,27 +547,24 @@ int main_platform(int argc, char *argv[]) {
 return socket_error;
   }
 
-  std::promise child_exited;
   MainLoop main_loop;
   {
 llvm::Expected> platform_handles =
 platform_sock->Accept(
 main_loop, [progname, gdbserver_port, &inferior_arguments, 
log_file,
-log_channels, &main_loop, &child_exited,
+log_channels, &main_loop,
 &

[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

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

Michael137 wrote:

Not sure how to best XFAIL this atm (really want to avoid just skipping it). 
This currently crashes LLDB. Maybe we could make use of the AST dump, or the 
expression log..

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


[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

2024-10-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This is a reduced test case from a crash we've observed in the past. The 
assertion that this test triggers is:
```
Assertion failed: ((Pos == ImportedDecls.end() || Pos->second == To) 
&& "Try to import an already imported Decl"), function MapImported, 
file ASTImporter.cpp, line 10494.
```

In a non-asserts build we crash later on in the ASTImporter. The root cause is, 
as the assertion above points out, that we erroneously replace an existing 
`From->To` decl mapping with a `To` decl that isn't complete. Then we try to 
complete it but it has no definition and we dereference a nullptr.

The reason this happens is basically what's been described in 
https://reviews.llvm.org/D67803?id=220956#1676588

The dylib contains a definition of `Service` which is different to the one in 
the main executable. When we start dumping the children of the variable we're 
printing, we start completing it's members, `ASTImport`ing fields in the 
process. When the ASTImporter realizes there's been a name conflict (i.e., a 
structural mismatch on the `Service` type) it would usually report back an 
error. However, LLDB uses `ODRHandlingType::Liberal`, which means we create a 
new decl for the ODR'd type instead of re-using the previously mapped decl. 
Eventually this leads us to crash.

Ideally we'd be using `ODRHandlingType::Conservative` and warn/error, though 
LLDB relies on this in some cases (particularly for distinguishing template 
specializations, though maybe there's better a way to deal with those).

We should really warn the user when this happens and not crash. To avoid the 
crash we'd need to know to not create a decl for the ODR violation, and instead 
re-use the definition we've previously seen. Though I'm not yet sure that's 
viable for all of LLDB's use-cases (where ODR violations might legimiately 
occur in a program, e.g., with opaque definitions, etc.).

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


6 Files Affected:

- (added) lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp (+21) 
- (added) lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp (+15) 
- (added) lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h (+10) 
- (added) lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp (+15) 
- (added) lldb/test/Shell/Expr/Inputs/name-conflict-test/service.h (+20) 
- (added) lldb/test/Shell/Expr/TestODRHandlingWithDylib.test (+17) 


``diff
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp
new file mode 100644
index 00..74d40d04ed4e20
--- /dev/null
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp
@@ -0,0 +1,21 @@
+#include "service.h"
+#include 
+#include 
+
+#ifndef PLUGIN_PATH
+#error "Expected PLUGIN_PATH to be defined"
+#endif // !PLUGIN_PATH
+
+int main() {
+  void *handle = dlopen(PLUGIN_PATH, RTLD_NOW);
+  assert(handle != nullptr);
+  void (*plugin_init)(void) = (void (*)(void))dlsym(handle, "plugin_init");
+  assert(plugin_init != nullptr);
+  void (*plugin_entry)(void) = (void (*)(void))dlsym(handle, "plugin_entry");
+  assert(plugin_entry != nullptr);
+
+  exported();
+  plugin_init();
+  plugin_entry();
+  return 0;
+}
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
new file mode 100644
index 00..8f8e98ed5c4b01
--- /dev/null
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
@@ -0,0 +1,15 @@
+#include "service.h"
+#include "plugin.h"
+
+struct Proxy : public Service {
+  State *proxyState;
+};
+
+Proxy *gProxyThis = 0;
+
+extern "C" {
+void plugin_init() { gProxyThis = new Proxy; }
+
+void plugin_entry() {}
+}
+
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
new file mode 100644
index 00..a04b0974165e71
--- /dev/null
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
@@ -0,0 +1,10 @@
+#ifndef PLUGIN_H_IN
+#define PLUGIN_H_IN
+
+extern "C" {
+void plugin_entry(void);
+void plugin_init(void);
+}
+
+#endif // _H_IN
+
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
new file mode 100644
index 00..5fd008c2aa8b80
--- /dev/null
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
@@ -0,0 +1,15 @@
+#include "service.h"
+
+struct ServiceAux {
+  Service *Owner;
+};
+
+struct Service::State {};
+
+void exported() {
+  // Make sure debug-info for definition of Service is
+  // emitted in this CU.
+  Service service;
+  service.start(0);
+}
+
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.h 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.h
new file mode 100644
index 00..53762a6e00357a
--- /dev/null
+++ b/ll

[Lldb-commits] [lldb] [lldb] Don't exit the main loop when in runs out of things to listen on (PR #112565)

2024-10-16 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff c01ddbe9166614db8121f5ddd5d7291be454c046 
8a531630f6b233d83f33740ce9dbbd9b3a778641 --extensions cpp -- 
lldb/source/Host/posix/MainLoopPosix.cpp 
lldb/source/Host/windows/MainLoopWindows.cpp 
lldb/tools/lldb-server/lldb-platform.cpp lldb/unittests/Host/MainLoopTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index d702f07dea..735a558810 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -555,9 +555,9 @@ int main_platform(int argc, char *argv[]) {
 log_channels, &main_loop,
 &platform_handles](std::unique_ptr sock_up) {
   printf("Connection established.\n");
-  Status error = spawn_process(
-  progname, sock_up.get(), gdbserver_port, inferior_arguments,
-  log_file, log_channels, main_loop);
+  Status error = spawn_process(progname, sock_up.get(),
+   gdbserver_port, inferior_arguments,
+   log_file, log_channels, main_loop);
   if (error.Fail()) {
 Log *log = GetLog(LLDBLog::Platform);
 LLDB_LOGF(log, "spawn_process failed: %s", error.AsCString());

``




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


[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

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

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

This is a reduced test case from a crash we've observed in the past. The 
assertion that this test triggers is:
```
Assertion failed: ((Pos == ImportedDecls.end() || Pos->second == To) && "Try to 
import an already imported Decl"), function MapImported, file ASTImporter.cpp, 
line 10494.
```

In a non-asserts build we crash later on in the ASTImporter. The root cause is, 
as the assertion above points out, that we erroneously replace an existing 
`From->To` decl mapping with a `To` decl that isn't complete. Then we try to 
complete it but it has no definition and we dereference a nullptr.

The reason this happens is basically what's been described in 
https://reviews.llvm.org/D67803?id=220956#1676588

The dylib contains a definition of `Service` which is different to the one in 
the main executable. When we start dumping the children of the variable we're 
printing, we start completing it's members, `ASTImport`ing fields in the 
process. When the ASTImporter realizes there's been a name conflict (i.e., a 
structural mismatch on the `Service` type) it would usually report back an 
error. However, LLDB uses `ODRHandlingType::Liberal`, which means we create a 
new decl for the ODR'd type instead of re-using the previously mapped decl. 
Eventually this leads us to crash.

Ideally we'd be using `ODRHandlingType::Conservative` and warn/error, though 
LLDB relies on this in some cases (particularly for distinguishing template 
specializations, though maybe there's better a way to deal with those).

We should really warn the user when this happens and not crash. To avoid the 
crash we'd need to know to not create a decl for the ODR violation, and instead 
re-use the definition we've previously seen. Though I'm not yet sure that's 
viable for all of LLDB's use-cases (where ODR violations might legimiately 
occur in a program, e.g., with opaque definitions, etc.).

>From d8369837a10f0e4750dd6c0f6c6b4467931b5012 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 16 Oct 2024 15:48:47 +0100
Subject: [PATCH] [lldb][test] Add test for ASTImporter's name conflict
 resolution

This is a reduced test case from a crash we've observed in the past.
The assertion that this test triggers is:
```
Assertion failed: ((Pos == ImportedDecls.end() || Pos->second == To) && "Try to 
import an already imported Decl"), function MapImported, file ASTImporter.cpp, 
line 10494.
```

In a non-asserts build we crash later on in the ASTImporter. The
root cause is, as the assertion above points out, that we erroneously
replace an existing `From->To` decl mapping with a `To` decl that
isn't complete. Then we try to complete it but it has no definition
and we dereference a nullptr.

The reason this happens is basically what's been described in 
https://reviews.llvm.org/D67803?id=220956#1676588

The dylib contains a definition of `Service` which is different to the
one in the main executable. When we start dumping the children of the
variable we're printing, we start completing it's members, `ASTImport`ing
fields in the process. When the ASTImporter realizes there's been a name
conflict (i.e., a structural mismatch on the `Service` type) it would
usually report back an error. However, LLDB uses `ODRHandlingType::Liberal`,
which means we create a new decl for the ODR'd type instead of re-using
the previously mapped decl. Eventually this leads us to crash.

Ideally we'd be using `ODRHandlingType::Conservative` and warn/error, though
LLDB relies on this in some cases (particularly for distinguishing template
specializations, though maybe there's better a way to deal with those).

We should really warn the user when this happens and not crash. To avoid
the crash we'd need to know to not create a decl for the ODR violation,
and instead re-use the definition we've previously seen. Though I'm not
yet sure that's viable for all of LLDB's use-cases (where ODR violations
might legimiately occur in a program, e.g., with opaque definitions,
etc.).
---
 .../Expr/Inputs/name-conflict-test/main.cpp   | 21 +++
 .../Expr/Inputs/name-conflict-test/plugin.cpp | 15 +
 .../Expr/Inputs/name-conflict-test/plugin.h   | 10 +
 .../Inputs/name-conflict-test/service.cpp | 15 +
 .../Expr/Inputs/name-conflict-test/service.h  | 20 ++
 .../Shell/Expr/TestODRHandlingWithDylib.test  | 17 +++
 6 files changed, 98 insertions(+)
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/service.h
 create mode 100644 lldb/test/Shell/Expr/TestODRHandlingWithDylib.test

diff --git a/lldb/test/Shell/Expr/I

[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

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

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

>From d8369837a10f0e4750dd6c0f6c6b4467931b5012 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 16 Oct 2024 15:48:47 +0100
Subject: [PATCH 1/2] [lldb][test] Add test for ASTImporter's name conflict
 resolution

This is a reduced test case from a crash we've observed in the past.
The assertion that this test triggers is:
```
Assertion failed: ((Pos == ImportedDecls.end() || Pos->second == To) && "Try to 
import an already imported Decl"), function MapImported, file ASTImporter.cpp, 
line 10494.
```

In a non-asserts build we crash later on in the ASTImporter. The
root cause is, as the assertion above points out, that we erroneously
replace an existing `From->To` decl mapping with a `To` decl that
isn't complete. Then we try to complete it but it has no definition
and we dereference a nullptr.

The reason this happens is basically what's been described in 
https://reviews.llvm.org/D67803?id=220956#1676588

The dylib contains a definition of `Service` which is different to the
one in the main executable. When we start dumping the children of the
variable we're printing, we start completing it's members, `ASTImport`ing
fields in the process. When the ASTImporter realizes there's been a name
conflict (i.e., a structural mismatch on the `Service` type) it would
usually report back an error. However, LLDB uses `ODRHandlingType::Liberal`,
which means we create a new decl for the ODR'd type instead of re-using
the previously mapped decl. Eventually this leads us to crash.

Ideally we'd be using `ODRHandlingType::Conservative` and warn/error, though
LLDB relies on this in some cases (particularly for distinguishing template
specializations, though maybe there's better a way to deal with those).

We should really warn the user when this happens and not crash. To avoid
the crash we'd need to know to not create a decl for the ODR violation,
and instead re-use the definition we've previously seen. Though I'm not
yet sure that's viable for all of LLDB's use-cases (where ODR violations
might legimiately occur in a program, e.g., with opaque definitions,
etc.).
---
 .../Expr/Inputs/name-conflict-test/main.cpp   | 21 +++
 .../Expr/Inputs/name-conflict-test/plugin.cpp | 15 +
 .../Expr/Inputs/name-conflict-test/plugin.h   | 10 +
 .../Inputs/name-conflict-test/service.cpp | 15 +
 .../Expr/Inputs/name-conflict-test/service.h  | 20 ++
 .../Shell/Expr/TestODRHandlingWithDylib.test  | 17 +++
 6 files changed, 98 insertions(+)
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
 create mode 100644 lldb/test/Shell/Expr/Inputs/name-conflict-test/service.h
 create mode 100644 lldb/test/Shell/Expr/TestODRHandlingWithDylib.test

diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp
new file mode 100644
index 00..74d40d04ed4e20
--- /dev/null
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp
@@ -0,0 +1,21 @@
+#include "service.h"
+#include 
+#include 
+
+#ifndef PLUGIN_PATH
+#error "Expected PLUGIN_PATH to be defined"
+#endif // !PLUGIN_PATH
+
+int main() {
+  void *handle = dlopen(PLUGIN_PATH, RTLD_NOW);
+  assert(handle != nullptr);
+  void (*plugin_init)(void) = (void (*)(void))dlsym(handle, "plugin_init");
+  assert(plugin_init != nullptr);
+  void (*plugin_entry)(void) = (void (*)(void))dlsym(handle, "plugin_entry");
+  assert(plugin_entry != nullptr);
+
+  exported();
+  plugin_init();
+  plugin_entry();
+  return 0;
+}
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
new file mode 100644
index 00..8f8e98ed5c4b01
--- /dev/null
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
@@ -0,0 +1,15 @@
+#include "service.h"
+#include "plugin.h"
+
+struct Proxy : public Service {
+  State *proxyState;
+};
+
+Proxy *gProxyThis = 0;
+
+extern "C" {
+void plugin_init() { gProxyThis = new Proxy; }
+
+void plugin_entry() {}
+}
+
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
new file mode 100644
index 00..a04b0974165e71
--- /dev/null
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
@@ -0,0 +1,10 @@
+#ifndef PLUGIN_H_IN
+#define PLUGIN_H_IN
+
+extern "C" {
+void plugin_entry(void);
+void plugin_init(void);
+}
+
+#endif // _H_IN
+
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
new file mode 100644
index 00..5fd008c2aa8b8

[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

2024-10-16 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff f113a66c29b17e4937ff5d0ab67dc087fa6ee27e 
d8369837a10f0e4750dd6c0f6c6b4467931b5012 --extensions cpp,h -- 
lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp 
lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp 
lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h 
lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp 
lldb/test/Shell/Expr/Inputs/name-conflict-test/service.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
index 8f8e98ed5c..190388000a 100644
--- a/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
@@ -1,5 +1,5 @@
-#include "service.h"
 #include "plugin.h"
+#include "service.h"
 
 struct Proxy : public Service {
   State *proxyState;
@@ -12,4 +12,3 @@ void plugin_init() { gProxyThis = new Proxy; }
 
 void plugin_entry() {}
 }
-
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
index a04b097416..66053f4e75 100644
--- a/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
@@ -7,4 +7,3 @@ void plugin_init(void);
 }
 
 #endif // _H_IN
-
diff --git a/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp 
b/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
index 5fd008c2aa..9a65e33d8a 100644
--- a/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
+++ b/lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
@@ -12,4 +12,3 @@ void exported() {
   Service service;
   service.start(0);
 }
-

``




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


[Lldb-commits] [lldb] [lldb] Don't exit the main loop when in runs out of things to listen on (PR #112565)

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

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

>From 8a531630f6b233d83f33740ce9dbbd9b3a778641 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 16 Oct 2024 16:54:06 +0200
Subject: [PATCH 1/3] [lldb] Don't exit the main loop when in runs out of
 things to listen on

This behavior made sense in the beginning as the class was completely
single threaded, so if the source count ever reached zero, there was no
way to add new ones. In https://reviews.llvm.org/D131160, the class
gained the ability to add events (callbacks) from other threads, which
means that is no longer the case (and indeed, one possible use case for
this class -- acting as a sort of arbiter for multiple threads
wanting to run code while making sure it runs serially -- has this class
sit in an empty Run call most of the time). I'm not aware of us having a
use for such a thing right now, but one of my tests in another patch
turned into something similar by accident.

Another problem with the current approach is that, in a
distributed/dynamic setup (multiple things using the main loop without a
clear coordinator), one can never be sure whether unregistering a
specific event will terminate the loop (it depends on whether there are
other listeners). We had this problem in lldb-platform.cpp, where we had
to add an additional layer of synchronization to avoid premature
termination. We can remove this if we can rely on the loop terminating
only when we tell it to.
---
 lldb/source/Host/posix/MainLoopPosix.cpp |  5 +
 lldb/source/Host/windows/MainLoopWindows.cpp |  4 +---
 lldb/tools/lldb-server/lldb-platform.cpp | 23 +++-
 lldb/unittests/Host/MainLoopTest.cpp | 11 +-
 4 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp 
b/lldb/source/Host/posix/MainLoopPosix.cpp
index 816581e70294a7..6f8eaa55cfdf09 100644
--- a/lldb/source/Host/posix/MainLoopPosix.cpp
+++ b/lldb/source/Host/posix/MainLoopPosix.cpp
@@ -365,10 +365,7 @@ Status MainLoopPosix::Run() {
   Status error;
   RunImpl impl(*this);
 
-  // run until termination or until we run out of things to listen to
-  // (m_read_fds will always contain m_trigger_pipe fd, so check for > 1)
-  while (!m_terminate_request &&
- (m_read_fds.size() > 1 || !m_signals.empty())) {
+  while (!m_terminate_request) {
 error = impl.Poll();
 if (error.Fail())
   return error;
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp 
b/lldb/source/Host/windows/MainLoopWindows.cpp
index 88d929535ab6c5..c9aa6d339d8f48 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -116,9 +116,7 @@ Status MainLoopWindows::Run() {
 
   Status error;
 
-  // run until termination or until we run out of things to listen to
-  while (!m_terminate_request && !m_read_fds.empty()) {
-
+  while (!m_terminate_request) {
 llvm::Expected signaled_event = Poll();
 if (!signaled_event)
   return Status::FromError(signaled_event.takeError());
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 2ef780578d0a28..d702f07deabd31 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -260,8 +260,7 @@ static void 
client_handle(GDBRemoteCommunicationServerPlatform &platform,
 static Status spawn_process(const char *progname, const Socket *conn_socket,
 uint16_t gdb_port, const lldb_private::Args &args,
 const std::string &log_file,
-const StringRef log_channels, MainLoop &main_loop,
-std::promise &child_exited) {
+const StringRef log_channels, MainLoop &main_loop) 
{
   Status error;
   SharedSocket shared_socket(conn_socket, error);
   if (error.Fail())
@@ -301,12 +300,10 @@ static Status spawn_process(const char *progname, const 
Socket *conn_socket,
   if (g_server)
 launch_info.SetMonitorProcessCallback([](lldb::pid_t, int, int) {});
   else
-launch_info.SetMonitorProcessCallback(
-[&child_exited, &main_loop](lldb::pid_t, int, int) {
-  main_loop.AddPendingCallback(
-  [](MainLoopBase &loop) { loop.RequestTermination(); });
-  child_exited.set_value();
-});
+launch_info.SetMonitorProcessCallback([&main_loop](lldb::pid_t, int, int) {
+  main_loop.AddPendingCallback(
+  [](MainLoopBase &loop) { loop.RequestTermination(); });
+});
 
   // Copy the current environment.
   launch_info.GetEnvironment() = Host::GetEnvironment();
@@ -550,27 +547,24 @@ int main_platform(int argc, char *argv[]) {
 return socket_error;
   }
 
-  std::promise child_exited;
   MainLoop main_loop;
   {
 llvm::Expected> platform_handles =
 platform_sock->Accept(
 main_loop, [progname, gdbserver_port, &inferior_arguments

[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

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

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

>From 7c35b47aa81ee0d2151944eff59c159ea3fd4c5c Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 15 Oct 2024 16:20:33 -0700
Subject: [PATCH] [lldb] Fix a crash when two diagnostics are on the same
 column or in reverse order

The second inner loop (only) was missing the check for
offset > column. Also this patch sorts the diagnostics before printing them.
---
 lldb/source/Utility/DiagnosticsRendering.cpp  | 32 
 .../Utility/DiagnosticsRenderingTest.cpp  | 37 ++-
 2 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index 96caf934cc2315..dd059d6e98a63d 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -77,11 +77,7 @@ void RenderDiagnosticDetails(Stream &stream,
 spacer = "";
   }
 
-  // Print a line with caret indicator(s) below the lldb prompt + command.
-  const size_t padding = *offset_in_command;
-  stream << std::string(padding, ' ');
-
-  size_t offset = 1;
+  // Partition the diagnostics.
   std::vector remaining_details, other_details,
   hidden_details;
   for (const DiagnosticDetail &detail : details) {
@@ -98,10 +94,31 @@ void RenderDiagnosticDetails(Stream &stream,
   continue;
 }
 
-auto &loc = *detail.source_location;
 remaining_details.push_back(detail);
+  }
+
+  // Sort the diagnostics.
+  auto sort = [](auto &ds) {
+llvm::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{});
+  return std::pair(l1.line, l2.column) < std::pair(l1.line, l2.column);
+});
+  };
+  sort(remaining_details);
+  sort(other_details);
+  sort(hidden_details);
+
+  // Print a line with caret indicator(s) below the lldb prompt + command.
+  const size_t padding = *offset_in_command;
+  stream << std::string(padding, ' ');
+  size_t offset = 1;
+  for (const DiagnosticDetail &detail : remaining_details) {
+auto &loc = *detail.source_location;
+
 if (offset > loc.column)
   continue;
+
 stream << std::string(loc.column - offset, ' ') << cursor;
 for (unsigned i = 0; i + 1 < loc.length; ++i)
   stream << underline;
@@ -121,7 +138,8 @@ void RenderDiagnosticDetails(Stream &stream,
 for (auto &remaining_detail :
  llvm::ArrayRef(remaining_details).drop_back(1)) {
   uint16_t column = remaining_detail.source_location->column;
-  stream << std::string(column - offset, ' ') << vbar;
+  if (offset <= column)
+stream << std::string(column - offset, ' ') << vbar;
   offset = column + 1;
 }
 
diff --git a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp 
b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
index 2bd80796b8074c..3d37403331b4c8 100644
--- a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
+++ b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
@@ -16,12 +16,45 @@ std::string Render(std::vector details) {
 } // namespace
 
 TEST_F(ErrorDisplayTest, RenderStatus) {
-  DiagnosticDetail::SourceLocation inline_loc;
-  inline_loc.in_user_input = true;
+  using SourceLocation = DiagnosticDetail::SourceLocation;
   {
+SourceLocation inline_loc;
+inline_loc.in_user_input = true;
 std::string result =
 Render({DiagnosticDetail{inline_loc, eSeverityError, "foo", ""}});
 ASSERT_TRUE(StringRef(result).contains("error:"));
 ASSERT_TRUE(StringRef(result).contains("foo"));
   }
+
+  {
+// 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};
+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"));
+  }
+  {
+// Test that diagnostics in reverse order are emitted correctly.
+SourceLocation loc1 = {FileSpec{"a.c"}, 1, 20, 0, false, true};
+SourceLocation loc2 = {FileSpec{"a.c"}, 2, 10, 0, false, true};
+std::string result =
+Render({DiagnosticDetail{loc2, eSeverityError, "X", "X"},
+DiagnosticDetail{loc1, eSeverityError, "Y", "Y"}});
+ASSERT_LT(StringRef(result).find("Y"), StringRef(result).find("X"));
+  }
+  {
+// Test that diagnostics in reverse order are emitted correctly.
+SourceLocation loc1 = {FileSpec{"a.c"}, 2, 10, 0, false, true};
+SourceLocation loc2 

[Lldb-commits] [lldb] [lldb] Fix offset calculation when printing diagnostics in multiple ranges (PR #112466)

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

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

>From 7c35b47aa81ee0d2151944eff59c159ea3fd4c5c Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 15 Oct 2024 16:20:33 -0700
Subject: [PATCH 1/2] [lldb] Fix a crash when two diagnostics are on the same
 column or in reverse order

The second inner loop (only) was missing the check for
offset > column. Also this patch sorts the diagnostics before printing them.
---
 lldb/source/Utility/DiagnosticsRendering.cpp  | 32 
 .../Utility/DiagnosticsRenderingTest.cpp  | 37 ++-
 2 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index 96caf934cc2315..dd059d6e98a63d 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -77,11 +77,7 @@ void RenderDiagnosticDetails(Stream &stream,
 spacer = "";
   }
 
-  // Print a line with caret indicator(s) below the lldb prompt + command.
-  const size_t padding = *offset_in_command;
-  stream << std::string(padding, ' ');
-
-  size_t offset = 1;
+  // Partition the diagnostics.
   std::vector remaining_details, other_details,
   hidden_details;
   for (const DiagnosticDetail &detail : details) {
@@ -98,10 +94,31 @@ void RenderDiagnosticDetails(Stream &stream,
   continue;
 }
 
-auto &loc = *detail.source_location;
 remaining_details.push_back(detail);
+  }
+
+  // Sort the diagnostics.
+  auto sort = [](auto &ds) {
+llvm::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{});
+  return std::pair(l1.line, l2.column) < std::pair(l1.line, l2.column);
+});
+  };
+  sort(remaining_details);
+  sort(other_details);
+  sort(hidden_details);
+
+  // Print a line with caret indicator(s) below the lldb prompt + command.
+  const size_t padding = *offset_in_command;
+  stream << std::string(padding, ' ');
+  size_t offset = 1;
+  for (const DiagnosticDetail &detail : remaining_details) {
+auto &loc = *detail.source_location;
+
 if (offset > loc.column)
   continue;
+
 stream << std::string(loc.column - offset, ' ') << cursor;
 for (unsigned i = 0; i + 1 < loc.length; ++i)
   stream << underline;
@@ -121,7 +138,8 @@ void RenderDiagnosticDetails(Stream &stream,
 for (auto &remaining_detail :
  llvm::ArrayRef(remaining_details).drop_back(1)) {
   uint16_t column = remaining_detail.source_location->column;
-  stream << std::string(column - offset, ' ') << vbar;
+  if (offset <= column)
+stream << std::string(column - offset, ' ') << vbar;
   offset = column + 1;
 }
 
diff --git a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp 
b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
index 2bd80796b8074c..3d37403331b4c8 100644
--- a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
+++ b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
@@ -16,12 +16,45 @@ std::string Render(std::vector details) {
 } // namespace
 
 TEST_F(ErrorDisplayTest, RenderStatus) {
-  DiagnosticDetail::SourceLocation inline_loc;
-  inline_loc.in_user_input = true;
+  using SourceLocation = DiagnosticDetail::SourceLocation;
   {
+SourceLocation inline_loc;
+inline_loc.in_user_input = true;
 std::string result =
 Render({DiagnosticDetail{inline_loc, eSeverityError, "foo", ""}});
 ASSERT_TRUE(StringRef(result).contains("error:"));
 ASSERT_TRUE(StringRef(result).contains("foo"));
   }
+
+  {
+// 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};
+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"));
+  }
+  {
+// Test that diagnostics in reverse order are emitted correctly.
+SourceLocation loc1 = {FileSpec{"a.c"}, 1, 20, 0, false, true};
+SourceLocation loc2 = {FileSpec{"a.c"}, 2, 10, 0, false, true};
+std::string result =
+Render({DiagnosticDetail{loc2, eSeverityError, "X", "X"},
+DiagnosticDetail{loc1, eSeverityError, "Y", "Y"}});
+ASSERT_LT(StringRef(result).find("Y"), StringRef(result).find("X"));
+  }
+  {
+// Test that diagnostics in reverse order are emitted correctly.
+SourceLocation loc1 = {FileSpec{"a.c"}, 2, 10, 0, false, true};
+SourceLocation l

[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

2024-10-16 Thread Jonas Devlieghere via lldb-commits

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

Thanks!

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


[Lldb-commits] [lldb] [lldb] Fix offset calculation when printing diagnostics in multiple ranges (PR #112466)

2024-10-16 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][test] Explicitly add target triple to no_unique_address Shell tests (PR #112523)

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

Michael137 wrote:

> I'll just note that `%clang_host` is not the host compiler (in the way that I 
> understand the term). It's the clang we've just built, _configured_ to build 
> for the (current) host.

Ooh I see, I didn't realize that. When would we not want to use `clangxx_host` 
then? I guess when we want to create object files configured for a different 
target?

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


[Lldb-commits] [lldb] 889e6ad - [lldb] Fix a crash when two diagnostics are on the same column or in … (#112451)

2024-10-16 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-10-16T09:45:39-07:00
New Revision: 889e6ad24b6df4f8d5232d4ecbd8eb492717f1b7

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

LOG: [lldb] Fix a crash when two diagnostics are on the same column or in … 
(#112451)

…reverse order

The second inner loop (only) was missing the check for offset > column.
Also this patch sorts the diagnostics before printing them.

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 96caf934cc2315..dd059d6e98a63d 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -77,11 +77,7 @@ void RenderDiagnosticDetails(Stream &stream,
 spacer = "";
   }
 
-  // Print a line with caret indicator(s) below the lldb prompt + command.
-  const size_t padding = *offset_in_command;
-  stream << std::string(padding, ' ');
-
-  size_t offset = 1;
+  // Partition the diagnostics.
   std::vector remaining_details, other_details,
   hidden_details;
   for (const DiagnosticDetail &detail : details) {
@@ -98,10 +94,31 @@ void RenderDiagnosticDetails(Stream &stream,
   continue;
 }
 
-auto &loc = *detail.source_location;
 remaining_details.push_back(detail);
+  }
+
+  // Sort the diagnostics.
+  auto sort = [](auto &ds) {
+llvm::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{});
+  return std::pair(l1.line, l2.column) < std::pair(l1.line, l2.column);
+});
+  };
+  sort(remaining_details);
+  sort(other_details);
+  sort(hidden_details);
+
+  // Print a line with caret indicator(s) below the lldb prompt + command.
+  const size_t padding = *offset_in_command;
+  stream << std::string(padding, ' ');
+  size_t offset = 1;
+  for (const DiagnosticDetail &detail : remaining_details) {
+auto &loc = *detail.source_location;
+
 if (offset > loc.column)
   continue;
+
 stream << std::string(loc.column - offset, ' ') << cursor;
 for (unsigned i = 0; i + 1 < loc.length; ++i)
   stream << underline;
@@ -121,7 +138,8 @@ void RenderDiagnosticDetails(Stream &stream,
 for (auto &remaining_detail :
  llvm::ArrayRef(remaining_details).drop_back(1)) {
   uint16_t column = remaining_detail.source_location->column;
-  stream << std::string(column - offset, ' ') << vbar;
+  if (offset <= column)
+stream << std::string(column - offset, ' ') << vbar;
   offset = column + 1;
 }
 

diff  --git a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp 
b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
index 2bd80796b8074c..3d37403331b4c8 100644
--- a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
+++ b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
@@ -16,12 +16,45 @@ std::string Render(std::vector details) {
 } // namespace
 
 TEST_F(ErrorDisplayTest, RenderStatus) {
-  DiagnosticDetail::SourceLocation inline_loc;
-  inline_loc.in_user_input = true;
+  using SourceLocation = DiagnosticDetail::SourceLocation;
   {
+SourceLocation inline_loc;
+inline_loc.in_user_input = true;
 std::string result =
 Render({DiagnosticDetail{inline_loc, eSeverityError, "foo", ""}});
 ASSERT_TRUE(StringRef(result).contains("error:"));
 ASSERT_TRUE(StringRef(result).contains("foo"));
   }
+
+  {
+// 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};
+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"));
+  }
+  {
+// Test that diagnostics in reverse order are emitted correctly.
+SourceLocation loc1 = {FileSpec{"a.c"}, 1, 20, 0, false, true};
+SourceLocation loc2 = {FileSpec{"a.c"}, 2, 10, 0, false, true};
+std::string result =
+Render({DiagnosticDetail{loc2, eSeverityError, "X", "X"},
+DiagnosticDetail{loc1, eSeverityError, "Y", "Y"}});
+ASSERT_LT(StringRef(result).find("Y"), StringRef(result).find("X"));
+  }
+  {
+// Test that diagnostics in reverse order are

[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

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

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


[Lldb-commits] [lldb] [lldb] Fix offset calculation when printing diagnostics in multiple ranges (PR #112466)

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

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

>From 433765aeb92179d3dcd422949275bf043661682b Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 15 Oct 2024 20:15:12 -0700
Subject: [PATCH] [lldb] Fix offset calculation when printing diagnostics in
 multiple ranges

---
 lldb/source/Utility/DiagnosticsRendering.cpp  | 38 ++-
 .../Utility/DiagnosticsRenderingTest.cpp  | 18 +
 2 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp 
b/lldb/source/Utility/DiagnosticsRendering.cpp
index dd059d6e98a63d..d28a9ab8958ba6 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -112,17 +112,21 @@ void RenderDiagnosticDetails(Stream &stream,
   // Print a line with caret indicator(s) below the lldb prompt + command.
   const size_t padding = *offset_in_command;
   stream << std::string(padding, ' ');
-  size_t offset = 1;
-  for (const DiagnosticDetail &detail : remaining_details) {
-auto &loc = *detail.source_location;
-
-if (offset > loc.column)
-  continue;
-
-stream << std::string(loc.column - offset, ' ') << cursor;
-for (unsigned i = 0; i + 1 < loc.length; ++i)
-  stream << underline;
-offset = loc.column + 1;
+  {
+size_t x_pos = 1;
+for (const DiagnosticDetail &detail : remaining_details) {
+  auto &loc = *detail.source_location;
+
+  if (x_pos > loc.column)
+continue;
+
+  stream << std::string(loc.column - x_pos, ' ') << cursor;
+  ++x_pos;
+  for (unsigned i = 0; i + 1 < loc.length; ++i) {
+stream << underline;
+++x_pos;
+  }
+}
   }
   stream << '\n';
 
@@ -134,19 +138,19 @@ void RenderDiagnosticDetails(Stream &stream,
 // Get the information to print this detail and remove it from the stack.
 // Print all the lines for all the other messages first.
 stream << std::string(padding, ' ');
-size_t offset = 1;
+size_t x_pos = 1;
 for (auto &remaining_detail :
  llvm::ArrayRef(remaining_details).drop_back(1)) {
   uint16_t column = remaining_detail.source_location->column;
-  if (offset <= column)
-stream << std::string(column - offset, ' ') << vbar;
-  offset = column + 1;
+  if (x_pos <= column)
+stream << std::string(column - x_pos, ' ') << vbar;
+  x_pos = column + 1;
 }
 
 // Print the line connecting the ^ with the error message.
 uint16_t column = detail->source_location->column;
-if (offset <= column)
-  stream << std::string(column - offset, ' ') << joint << hbar << spacer;
+if (x_pos <= column)
+  stream << std::string(column - x_pos, ' ') << joint << hbar << spacer;
 
 // Print a colorized string based on the message's severity type.
 PrintSeverity(stream, detail->severity);
diff --git a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp 
b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
index 3d37403331b4c8..39d8b1d558420d 100644
--- a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
+++ b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
@@ -57,4 +57,22 @@ TEST_F(ErrorDisplayTest, RenderStatus) {
 DiagnosticDetail{loc1, eSeverityError, "Y", "Y"}});
 ASSERT_LT(StringRef(result).find("Y"), StringRef(result).find("X"));
   }
+  {
+// Test that range diagnostics are emitted correctly.
+SourceLocation loc1 = {FileSpec{"a.c"}, 1, 1, 3, false, true};
+SourceLocation loc2 = {FileSpec{"a.c"}, 1, 5, 3, 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] 8046f15 - [lldb] Fix offset calculation when printing diagnostics in multiple ranges (#112466)

2024-10-16 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-10-16T09:46:35-07:00
New Revision: 8046f15dfaaa8726b058a3483175890ca95832af

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

LOG: [lldb] Fix offset calculation when printing diagnostics in multiple ranges 
(#112466)

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

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 dd059d6e98a63d..d28a9ab8958ba6 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -112,17 +112,21 @@ void RenderDiagnosticDetails(Stream &stream,
   // Print a line with caret indicator(s) below the lldb prompt + command.
   const size_t padding = *offset_in_command;
   stream << std::string(padding, ' ');
-  size_t offset = 1;
-  for (const DiagnosticDetail &detail : remaining_details) {
-auto &loc = *detail.source_location;
-
-if (offset > loc.column)
-  continue;
-
-stream << std::string(loc.column - offset, ' ') << cursor;
-for (unsigned i = 0; i + 1 < loc.length; ++i)
-  stream << underline;
-offset = loc.column + 1;
+  {
+size_t x_pos = 1;
+for (const DiagnosticDetail &detail : remaining_details) {
+  auto &loc = *detail.source_location;
+
+  if (x_pos > loc.column)
+continue;
+
+  stream << std::string(loc.column - x_pos, ' ') << cursor;
+  ++x_pos;
+  for (unsigned i = 0; i + 1 < loc.length; ++i) {
+stream << underline;
+++x_pos;
+  }
+}
   }
   stream << '\n';
 
@@ -134,19 +138,19 @@ void RenderDiagnosticDetails(Stream &stream,
 // Get the information to print this detail and remove it from the stack.
 // Print all the lines for all the other messages first.
 stream << std::string(padding, ' ');
-size_t offset = 1;
+size_t x_pos = 1;
 for (auto &remaining_detail :
  llvm::ArrayRef(remaining_details).drop_back(1)) {
   uint16_t column = remaining_detail.source_location->column;
-  if (offset <= column)
-stream << std::string(column - offset, ' ') << vbar;
-  offset = column + 1;
+  if (x_pos <= column)
+stream << std::string(column - x_pos, ' ') << vbar;
+  x_pos = column + 1;
 }
 
 // Print the line connecting the ^ with the error message.
 uint16_t column = detail->source_location->column;
-if (offset <= column)
-  stream << std::string(column - offset, ' ') << joint << hbar << spacer;
+if (x_pos <= column)
+  stream << std::string(column - x_pos, ' ') << joint << hbar << spacer;
 
 // Print a colorized string based on the message's severity type.
 PrintSeverity(stream, detail->severity);

diff  --git a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp 
b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
index 3d37403331b4c8..39d8b1d558420d 100644
--- a/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
+++ b/lldb/unittests/Utility/DiagnosticsRenderingTest.cpp
@@ -57,4 +57,22 @@ TEST_F(ErrorDisplayTest, RenderStatus) {
 DiagnosticDetail{loc1, eSeverityError, "Y", "Y"}});
 ASSERT_LT(StringRef(result).find("Y"), StringRef(result).find("X"));
   }
+  {
+// Test that range diagnostics are emitted correctly.
+SourceLocation loc1 = {FileSpec{"a.c"}, 1, 1, 3, false, true};
+SourceLocation loc2 = {FileSpec{"a.c"}, 1, 5, 3, 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] [lldb] Fix offset calculation when printing diagnostics in multiple ranges (PR #112466)

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

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


[Lldb-commits] [lldb] [lldb][test] Explicitly add target triple to no_unique_address Shell tests (PR #112523)

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

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


[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)

2024-10-16 Thread Jonas Devlieghere via lldb-commits

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

>From 4c53565414c95ddd49050363d3302452cbb99b27 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 15 Oct 2024 15:19:16 -0700
Subject: [PATCH 1/2] [lldb] Disable warning about codecvt_utf8 deprecation
 (NFC)

Disable -Wdeprecated-declarations for codecvt_utf8 in Editline. This is
in preparation for #112276 which narrows the scope of
-Wno-deprecated-declarations for building LLDB.
---
 lldb/include/lldb/Host/Editline.h| 22 ++
 lldb/source/Host/common/Editline.cpp |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index 9049b106f02a34..f5d461d32b72fa 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -57,6 +57,26 @@
 
 #include "llvm/ADT/FunctionExtras.h"
 
+#if defined(__clang__) && defined(__has_warning)
+#if __has_warning("-Wimplicit-fallthrough")
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+  _Pragma("clang diagnostic push") 
\
+  _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("clang diagnostic pop")
+#endif
+#elif defined(__GNUC__) && __GNUC__ > 6
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+  _Pragma("GCC diagnostic push")   
\
+  _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("GCC diagnostic pop")
+#endif
+#ifndef EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
+#endif
+#ifndef EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#define EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#endif
+
 namespace lldb_private {
 namespace line_editor {
 
@@ -367,7 +387,9 @@ class Editline {
   void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn);
 
 #if LLDB_EDITLINE_USE_WCHAR
+  EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
   std::wstring_convert> m_utf8conv;
+  EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
 #endif
   ::EditLine *m_editline = nullptr;
   EditlineHistorySP m_history_sp;
diff --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index 561ec228cdb23f..b5b8d46c0721cf 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1574,7 +1574,9 @@ bool Editline::CompleteCharacter(char ch, 
EditLineGetCharType &out) {
   out = (unsigned char)ch;
   return true;
 #else
+  EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
   std::codecvt_utf8 cvt;
+  EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
   llvm::SmallString<4> input;
   for (;;) {
 const char *from_next;

>From 206f4725a7b58f6ffa8f2420b800c17d5b9a52e4 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 16 Oct 2024 07:13:07 -0700
Subject: [PATCH 2/2] Address Pavel's feedback

 - Rename macro and include LLDB prefix.
 - Fix copy/paste error.
 - Define empty macro in else block.
---
 lldb/include/lldb/Host/Editline.h| 23 ++-
 lldb/source/Host/common/Editline.cpp |  2 +-
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index f5d461d32b72fa..a02f90891599ad 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -58,23 +58,20 @@
 #include "llvm/ADT/FunctionExtras.h"
 
 #if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wimplicit-fallthrough")
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+#if __has_warning("-Wdeprecated-declarations")
+#define LLDB_DEPRECATED_WARNING_DISABLE
\
   _Pragma("clang diagnostic push") 
\
   _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
-#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("clang diagnostic pop")
+#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("clang diagnostic pop")
 #endif
 #elif defined(__GNUC__) && __GNUC__ > 6
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+#define LLDB_DEPRECATED_WARNING_DISABLE
\
   _Pragma("GCC diagnostic push")   
\
   _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
-#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("GCC diagnostic pop")
-#endif
-#ifndef EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
-#endif
-#ifndef EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
-#define EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("GCC diagnostic pop")
+#else
+#define LLDB_DEPRECATED_WARN

[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

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


@@ -16,12 +16,36 @@ std::string Render(std::vector details) {
 } // namespace
 
 TEST_F(ErrorDisplayTest, RenderStatus) {
-  DiagnosticDetail::SourceLocation inline_loc;
-  inline_loc.in_user_input = true;
   {
+DiagnosticDetail::SourceLocation inline_loc;
+inline_loc.in_user_input = true;
 std::string result =
 Render({DiagnosticDetail{inline_loc, eSeverityError, "foo", ""}});
 ASSERT_TRUE(StringRef(result).contains("error:"));
 ASSERT_TRUE(StringRef(result).contains("foo"));
   }
+
+  {
+DiagnosticDetail::SourceLocation loc1 = {FileSpec{"a.c"}, 13,  11, 0,
+ false,   true};
+DiagnosticDetail::SourceLocation loc2 = {FileSpec{"a.c"}, 13,  13, 0,
+ false,   true};
+std::string result =
+Render({DiagnosticDetail{loc1, eSeverityError, "1", "1"},
+DiagnosticDetail{loc1, eSeverityError, "2", "3"},
+DiagnosticDetail{loc2, eSeverityError, "3", "3"}});
+ASSERT_TRUE(StringRef(result).contains("error: 1"));
+ASSERT_TRUE(StringRef(result).contains("error: 3"));
+ASSERT_TRUE(StringRef(result).contains("error: 2"));

adrian-prantl wrote:

This first test is the "don't crash" test. I'll add comments.

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


[Lldb-commits] [lldb] [lldb][test] Skip Test*FromStdModule tests on Linux for now (PR #112530)

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

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/112530

This is the alternative to #98701.
See for more details:
https://reviews.llvm.org/D139361
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095

>From 4bf78a4bc9b37322502dfc9810ddae7c231aa7d1 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 16 Oct 2024 16:22:18 +0400
Subject: [PATCH] [lldb][test] Skip Test*FromStdModule tests on Linux for now

This is the alternative to #98701.
See for more details:
https://reviews.llvm.org/D139361
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
---
 .../expression/import-std-module/array/TestArrayFromStdModule.py | 1 +
 .../TestDbgInfoContentVectorFromStdModule.py | 1 +
 .../vector-of-vectors/TestVectorOfVectorsFromStdModule.py| 1 +
 3 files changed, 3 insertions(+)

diff --git 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
index 13ab6b0c9ac1fb..bafc7628296217 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
@@ -10,6 +10,7 @@
 class TestCase(TestBase):
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 
diff --git 
a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
index 1c3e64f14c..71eaeef20e792d 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
@@ -14,6 +14,7 @@ class TestDbgInfoContentVector(TestBase):
 @skipIf(compiler="clang", compiler_version=["<", "12.0"])
 @skipIf(macos_version=["<", "14.0"])
 @skipIfDarwin  # https://github.com/llvm/llvm-project/issues/106475
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 
diff --git 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
index a1f33271f39d2f..e9415fd53651f7 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
@@ -10,6 +10,7 @@
 class TestVectorOfVectors(TestBase):
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 

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


[Lldb-commits] [lldb] [lldb][test] Skip Test*FromStdModule tests on Linux for now (PR #112530)

2024-10-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

This is the alternative to #98701.
See for more details:
https://reviews.llvm.org/D139361
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095

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


3 Files Affected:

- (modified) 
lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
 (+1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
 (+1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
 (+1) 


``diff
diff --git 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
index 13ab6b0c9ac1fb..bafc7628296217 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
@@ -10,6 +10,7 @@
 class TestCase(TestBase):
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 
diff --git 
a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
index 1c3e64f14c..71eaeef20e792d 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
@@ -14,6 +14,7 @@ class TestDbgInfoContentVector(TestBase):
 @skipIf(compiler="clang", compiler_version=["<", "12.0"])
 @skipIf(macos_version=["<", "14.0"])
 @skipIfDarwin  # https://github.com/llvm/llvm-project/issues/106475
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 
diff --git 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
index a1f33271f39d2f..e9415fd53651f7 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
@@ -10,6 +10,7 @@
 class TestVectorOfVectors(TestBase):
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 

``




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


[Lldb-commits] [lldb] [lldb][test] Enable static linking with libcxx for import-std-module tests (PR #98701)

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

slydiman wrote:

> Since this is quite tricky to debug, and has been a known issue for a while 
> and (i think) only happens when we built libc++ with debug symbols, I'd be 
> fine with skipping the test on Linux until we figure out what the root cause 
> is.

Agree. Please see #112530.

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


[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-16 Thread Simon Pilgrim via lldb-commits

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

LGTM with one minor

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


[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-16 Thread Simon Pilgrim via lldb-commits


@@ -28729,7 +28731,7 @@ static SDValue GenerateFixedLengthSVETBL(SDValue Op, 
SDValue Op1, SDValue Op2,
   unsigned BitsPerElt = VTOp1.getVectorElementType().getSizeInBits();
   unsigned IndexLen = MinSVESize / BitsPerElt;
   unsigned ElementsPerVectorReg = VTOp1.getVectorNumElements();
-  uint64_t MaxOffset = APInt(BitsPerElt, -1, false).getZExtValue();
+  uint64_t MaxOffset = APInt(BitsPerElt, -1, true).getZExtValue();

RKSimon wrote:

Seems convoluted - `APInt::getAllOnes(BitsPerElt).getZExtValue()` or just do a 
`~0ULL >> (64 - BitsPerElt)`?

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


[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-16 Thread Simon Pilgrim via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add --platform-available-ports option to the dotest.py (PR #112555)

2024-10-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (dlav-sc)


Changes

This patch adds --platform-available-ports option to the dotest.py script to 
avoid hardcoded gdb ports in lldb testsuite.

Currently, this option could be helpful in GdbRemoteTestCases (e.g. 
TestLldbGdbServer, TestNonStop, TestGdbRemoteThreadsInStopReply, 
TestGdbRemotePlatformFile, TestGdbRemote_vCont)

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


5 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/configuration.py (+1) 
- (modified) lldb/packages/Python/lldbsuite/test/dotest.py (+2) 
- (modified) lldb/packages/Python/lldbsuite/test/dotest_args.py (+7) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+4) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
(+3) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py 
b/lldb/packages/Python/lldbsuite/test/configuration.py
index 1bacd74a968c31..c54f8d6a3962f8 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -99,6 +99,7 @@
 lldb_platform_name = None
 lldb_platform_url = None
 lldb_platform_working_dir = None
+lldb_platform_available_ports = None
 
 # Apple SDK
 apple_sdk = None
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 681ea1638f2d6f..7cc8f2985043e6 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -419,6 +419,8 @@ def parseOptionsAndInitTestdirs():
 configuration.lldb_platform_url = args.lldb_platform_url
 if args.lldb_platform_working_dir:
 configuration.lldb_platform_working_dir = 
args.lldb_platform_working_dir
+if args.lldb_platform_available_ports:
+configuration.lldb_platform_available_ports = 
args.lldb_platform_available_ports
 if platform_system == "Darwin" and args.apple_sdk:
 configuration.apple_sdk = args.apple_sdk
 if args.test_build_dir:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index a80428ebec5891..18047fdca2a921 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -292,6 +292,13 @@ def create_parser():
 metavar="platform-working-dir",
 help="The directory to use on the remote platform.",
 )
+group.add_argument(
+"--platform-available-ports",
+dest="lldb_platform_available_ports",
+type=lambda ports: [int(port.strip()) for port in ports.split(":")],
+metavar="platform-available-ports",
+help="Ports available for connection to a lldb server on the remote 
platform",
+)
 
 # Test-suite behaviour
 group = parser.add_argument_group("Runtime behaviour options")
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 8884ef5933ada8..112f139518f393 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -747,6 +747,10 @@ def getSourcePath(self, name):
 """Return absolute path to a file in the test's source directory."""
 return os.path.join(self.getSourceDir(), name)
 
+def getPlatformAvailablePorts(self):
+"""Return ports available for connection to a lldb server on the 
remote platform."""
+return configuration.lldb_platform_available_ports
+
 @classmethod
 def setUpCommands(cls):
 commands = [
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 8c8e4abed0b454..f7516d26d01d79 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -185,6 +185,9 @@ def setUpServerLogging(self, is_llgs):
 ]
 
 def get_next_port(self):
+available_ports = self.getPlatformAvailablePorts()
+if available_ports:
+return random.choice(available_ports)
 return 12000 + random.randint(0, 3999)
 
 def reset_test_sequence(self):

``




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


[Lldb-commits] [lldb] [lldb][test] Explicitly add target triple to no_unique_address Shell tests (PR #112523)

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

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


[Lldb-commits] [lldb] [lldb][test] Skip Test*FromStdModule tests on Linux for now (PR #112530)

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

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


[Lldb-commits] [lldb] 87f1262 - [lldb][test] Skip Test*FromStdModule tests on Linux for now (#112530)

2024-10-16 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-10-16T17:52:16+04:00
New Revision: 87f126243beb69b8b02e5cd4df762bc8a6f1f8cc

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

LOG: [lldb][test] Skip Test*FromStdModule tests on Linux for now (#112530)

This is the alternative to #98701.
See for more details:
https://reviews.llvm.org/D139361
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095

Added: 


Modified: 

lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py

lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py

lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
index 13ab6b0c9ac1fb..bafc7628296217 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
@@ -10,6 +10,7 @@
 class TestCase(TestBase):
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 

diff  --git 
a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
index 1c3e64f14c..71eaeef20e792d 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
@@ -14,6 +14,7 @@ class TestDbgInfoContentVector(TestBase):
 @skipIf(compiler="clang", compiler_version=["<", "12.0"])
 @skipIf(macos_version=["<", "14.0"])
 @skipIfDarwin  # https://github.com/llvm/llvm-project/issues/106475
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 

diff  --git 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
index a1f33271f39d2f..e9415fd53651f7 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
@@ -10,6 +10,7 @@
 class TestVectorOfVectors(TestBase):
 @add_test_categories(["libc++"])
 @skipIf(compiler=no_match("clang"))
+@skipIfLinux  # 
https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
 def test(self):
 self.build()
 



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


[Lldb-commits] [lldb] 255a99c - [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (#80309)

2024-10-16 Thread via lldb-commits

Author: Nikita Popov
Date: 2024-10-17T08:48:08+02:00
New Revision: 255a99c29f9fa1a89b03a85a3a73d6f44d03c6c1

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

LOG: [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) 
(#80309)

This fixes all the places that hit the new assertion added in
https://github.com/llvm/llvm-project/pull/106524 in tests. That is,
cases where the value passed to the APInt constructor is not an N-bit
signed/unsigned integer, where N is the bit width and signedness is
determined by the isSigned flag.

The fixes either set the correct value for isSigned, set the
implicitTrunc flag, or perform more calculations inside APInt.

Note that the assertion is currently still disabled by default, so this
patch is mostly NFC.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/AST/ByteCode/IntegralAP.h
clang/lib/CodeGen/CGVTT.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOpenMP.cpp
lldb/source/Expression/DWARFExpression.cpp
llvm/include/llvm/ADT/APFixedPoint.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Analysis/Loads.cpp
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp
llvm/lib/Target/Hexagon/HexagonGenExtract.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/unittests/ADT/APFixedPointTest.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 0faa5aed4eec3b..2c5769f8469e5b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6755,7 +6755,7 @@ class Sema final : public SemaBase {
 
   ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK);
   ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
-  ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val);
+  ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
 
   bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
 

diff  --git a/clang/lib/AST/ByteCode/IntegralAP.h 
b/clang/lib/AST/ByteCode/IntegralAP.h
index a4d656433344b7..252d7243bee73e 100644
--- a/clang/lib/AST/ByteCode/IntegralAP.h
+++ b/clang/lib/AST/ByteCode/IntegralAP.h
@@ -61,7 +61,7 @@ template  class IntegralAP final {
 
   IntegralAP(APInt V) : V(V) {}
   /// Arbitrary value for uninitialized variables.
-  IntegralAP() : IntegralAP(-1, 3) {}
+  IntegralAP() : IntegralAP(Signed ? -1 : 7, 3) {}
 
   IntegralAP operator-() const { return IntegralAP(-V); }
   IntegralAP operator-(const IntegralAP &Other) const {
@@ -112,7 +112,10 @@ template  class IntegralAP final {
 
   template 
   static IntegralAP from(Integral I, unsigned BitWidth) {
-APInt Copy = APInt(BitWidth, static_cast(I), InputSigned);
+// TODO: Avoid implicit trunc?
+// See https://github.com/llvm/llvm-project/issues/112510.
+APInt Copy = APInt(BitWidth, static_cast(I), InputSigned,
+   /*implicitTrunc=*/true);
 
 return IntegralAP(Copy);
   }

diff  --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp
index 20bd2c2fc2c642..989a07d09d50ee 100644
--- a/clang/lib/CodeGen/CGVTT.cpp
+++ b/clang/lib/CodeGen/CGVTT.cpp
@@ -85,8 +85,9 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,
  cast(VTable->getValueType())
  ->getElementType(AddressPoint.VTableIndex));
  unsigned Offset = ComponentSize * AddressPoint.AddressPointIndex;
- llvm::ConstantRange InRange(llvm::APInt(32, -Offset, true),
- llvm::APInt(32, VTableSize - Offset, true));
+ llvm::ConstantRange InRange(
+ llvm::APInt(32, (int)-Offset, true),
+ llvm::APInt(32, (int)(VTableSize - Offset), true));
  llvm::Constant *Init = llvm::ConstantExpr::getGetElementPtr(
  VTable->getValueType(), VTable, Idxs, /*InBounds=*/true, InRange);
 

diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp

[Lldb-commits] [clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)

2024-10-16 Thread Nikita Popov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Avoid repeated map lookups (NFC) (PR #112655)

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

https://github.com/kazutakahirata updated 
https://github.com/llvm/llvm-project/pull/112655

>From 826b8ad10ef9d24e744aa00298ca380bfcd4c79a Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Wed, 16 Oct 2024 06:49:47 -0700
Subject: [PATCH 1/2] [lldb] Avoid repeated map lookups (NFC)

---
 lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3e09c316d74f44..70cbd1c57b895a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -5324,7 +5324,7 @@ std::string 
ProcessGDBRemote::HarmonizeThreadIdsForProfileData(
 std::map::iterator iterator =
 m_thread_id_to_used_usec_map.find(thread_id);
 if (iterator != m_thread_id_to_used_usec_map.end()) {
-  prev_used_usec = m_thread_id_to_used_usec_map[thread_id];
+  prev_used_usec = iterator->second;
 }
 
 uint32_t real_used_usec = curr_used_usec - prev_used_usec;

>From a9fb4382e8f8936dfa861dc2dbd773c70a3981f5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Wed, 16 Oct 2024 23:42:50 -0700
Subject: [PATCH 2/2] Remove curly braces.

---
 lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 70cbd1c57b895a..538c8680140091 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -5323,9 +5323,8 @@ std::string 
ProcessGDBRemote::HarmonizeThreadIdsForProfileData(
 uint32_t prev_used_usec = 0;
 std::map::iterator iterator =
 m_thread_id_to_used_usec_map.find(thread_id);
-if (iterator != m_thread_id_to_used_usec_map.end()) {
+if (iterator != m_thread_id_to_used_usec_map.end())
   prev_used_usec = iterator->second;
-}
 
 uint32_t real_used_usec = curr_used_usec - prev_used_usec;
 // A good first time record is one that runs for at least 0.25 sec

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


[Lldb-commits] [lldb] [lldb] Avoid repeated map lookups (NFC) (PR #112655)

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


@@ -5324,7 +5324,7 @@ std::string 
ProcessGDBRemote::HarmonizeThreadIdsForProfileData(
 std::map::iterator iterator =
 m_thread_id_to_used_usec_map.find(thread_id);
 if (iterator != m_thread_id_to_used_usec_map.end()) {
-  prev_used_usec = m_thread_id_to_used_usec_map[thread_id];
+  prev_used_usec = iterator->second;
 }

kazutakahirata wrote:

Sure.  Addressed in the latest iteration.

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


[Lldb-commits] [lldb] [lldb] Disable warning about codecvt_utf8 deprecation (NFC) (PR #112446)

2024-10-16 Thread Jonas Devlieghere via lldb-commits

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

>From 4c53565414c95ddd49050363d3302452cbb99b27 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 15 Oct 2024 15:19:16 -0700
Subject: [PATCH 1/3] [lldb] Disable warning about codecvt_utf8 deprecation
 (NFC)

Disable -Wdeprecated-declarations for codecvt_utf8 in Editline. This is
in preparation for #112276 which narrows the scope of
-Wno-deprecated-declarations for building LLDB.
---
 lldb/include/lldb/Host/Editline.h| 22 ++
 lldb/source/Host/common/Editline.cpp |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index 9049b106f02a34..f5d461d32b72fa 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -57,6 +57,26 @@
 
 #include "llvm/ADT/FunctionExtras.h"
 
+#if defined(__clang__) && defined(__has_warning)
+#if __has_warning("-Wimplicit-fallthrough")
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+  _Pragma("clang diagnostic push") 
\
+  _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("clang diagnostic pop")
+#endif
+#elif defined(__GNUC__) && __GNUC__ > 6
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+  _Pragma("GCC diagnostic push")   
\
+  _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("GCC diagnostic pop")
+#endif
+#ifndef EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
+#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
+#endif
+#ifndef EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#define EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#endif
+
 namespace lldb_private {
 namespace line_editor {
 
@@ -367,7 +387,9 @@ class Editline {
   void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn);
 
 #if LLDB_EDITLINE_USE_WCHAR
+  EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
   std::wstring_convert> m_utf8conv;
+  EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
 #endif
   ::EditLine *m_editline = nullptr;
   EditlineHistorySP m_history_sp;
diff --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index 561ec228cdb23f..b5b8d46c0721cf 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1574,7 +1574,9 @@ bool Editline::CompleteCharacter(char ch, 
EditLineGetCharType &out) {
   out = (unsigned char)ch;
   return true;
 #else
+  EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
   std::codecvt_utf8 cvt;
+  EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
   llvm::SmallString<4> input;
   for (;;) {
 const char *from_next;

>From 206f4725a7b58f6ffa8f2420b800c17d5b9a52e4 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 16 Oct 2024 07:13:07 -0700
Subject: [PATCH 2/3] Address Pavel's feedback

 - Rename macro and include LLDB prefix.
 - Fix copy/paste error.
 - Define empty macro in else block.
---
 lldb/include/lldb/Host/Editline.h| 23 ++-
 lldb/source/Host/common/Editline.cpp |  2 +-
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index f5d461d32b72fa..a02f90891599ad 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -58,23 +58,20 @@
 #include "llvm/ADT/FunctionExtras.h"
 
 #if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wimplicit-fallthrough")
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+#if __has_warning("-Wdeprecated-declarations")
+#define LLDB_DEPRECATED_WARNING_DISABLE
\
   _Pragma("clang diagnostic push") 
\
   _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
-#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("clang diagnostic pop")
+#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("clang diagnostic pop")
 #endif
 #elif defined(__GNUC__) && __GNUC__ > 6
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS 
\
+#define LLDB_DEPRECATED_WARNING_DISABLE
\
   _Pragma("GCC diagnostic push")   
\
   _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
-#define RESTORE_DEPRECATED_DECLARATION_WARNINGS _Pragma("GCC diagnostic pop")
-#endif
-#ifndef EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
-#define EL_DISABLE_DEPRECATED_DECLARATION_WARNINGS
-#endif
-#ifndef EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
-#define EL_RESTORE_DEPRECATED_DECLARATION_WARNINGS
+#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("GCC diagnostic pop")
+#else
+#define LLDB_DEPRECATED_WARN

[Lldb-commits] [lldb] [lldb] Use Locale to convert between std::wstring and std::string (NFC) (PR #112582)

2024-10-16 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

Looks like this is failing in CI. I'll take a look at this tomorrow. In the 
meantime I'd still like to merge #112446 and #112276. 

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


[Lldb-commits] [lldb] [lldb] Improve unwinding for discontinuous functions (PR #111409)

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

jasonmolenda wrote:

I was able to build github main on an Intel mac running the current OS, and the 
shell tests all pass with it.  I had the same difficulty trying to repo a 
failure with this test with Alex's change, I could never get the failure the CI 
bots were hitting, but I didn't have the exact same macOS version as the CI 
bots installed, shrug maybe that's important.  I'll try to figure that out and 
install it on an intel mac and try to repo that way, I really wanted to get 
back to Alex's change too.

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


[Lldb-commits] [lldb] [lldb] Use Locale to convert between std::wstring and std::string (NFC) (PR #112582)

2024-10-16 Thread Jonas Devlieghere via lldb-commits

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

>From de1a1c4cfb5a8c3fc47194275fcc8fc48b7cbbf9 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 16 Oct 2024 10:06:31 -0700
Subject: [PATCH 1/2] [lldb] Use Locale to convert between std::wstring and
 std::string (NFC)

The codecvt header has been deprecated in C++17. Use locale to convert
between std::string and std::wstring in Editline.
---
 lldb/include/lldb/Host/Editline.h|  6 
 lldb/source/Host/common/Editline.cpp | 53 
 2 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index 9049b106f02a34..57e2c831e3499d 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -30,9 +30,6 @@
 
 #include "lldb/Host/Config.h"
 
-#if LLDB_EDITLINE_USE_WCHAR
-#include 
-#endif
 #include 
 #include 
 #include 
@@ -366,9 +363,6 @@ class Editline {
   void SetEditLinePromptCallback(EditlinePromptCallbackType callbackFn);
   void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn);
 
-#if LLDB_EDITLINE_USE_WCHAR
-  std::wstring_convert> m_utf8conv;
-#endif
   ::EditLine *m_editline = nullptr;
   EditlineHistorySP m_history_sp;
   bool m_in_history = false;
diff --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index 561ec228cdb23f..99a5003e7a83db 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -76,6 +76,46 @@ using namespace lldb_private::line_editor;
 
 #endif // #if LLDB_EDITLINE_USE_WCHAR
 
+#if LLDB_EDITLINE_USE_WCHAR
+std::string ToBytes(const std::wstring &in) {
+  static std::locale locale("C.UTF-8");
+  static const auto &cvt =
+  std::use_facet>(locale);
+
+  const size_t length = in.length();
+  std::string output(length + 1, 0x0);
+
+  std::mbstate_t mbs{};
+  const wchar_t *in_next;
+  char *out_next;
+
+  if (cvt.out(mbs, in.data(), in.data() + length + 1, in_next, output.data(),
+  output.data() + output.length() + 1,
+  out_next) == std::codecvt_base::ok)
+return output;
+  return {};
+}
+
+std::wstring FromBytes(const std::string &in) {
+  static std::locale locale("C.UTF-8");
+  static const auto &cvt =
+  std::use_facet>(locale);
+
+  const size_t length = in.length();
+  std::wstring output(length + 1, 0x0);
+
+  std::mbstate_t mbs{};
+  const char *in_next;
+  wchar_t *out_next;
+
+  if (cvt.in(mbs, in.data(), in.data() + length + 1, in_next, output.data(),
+ output.data() + output.length() + 1,
+ out_next) == std::codecvt_base::ok)
+return output;
+  return {};
+}
+#endif
+
 bool IsOnlySpaces(const EditLineStringType &content) {
   for (wchar_t ch : content) {
 if (ch != EditLineCharType(' '))
@@ -444,7 +484,7 @@ StringList Editline::GetInputAsStringList(int line_count) {
 if (line_count == 0)
   break;
 #if LLDB_EDITLINE_USE_WCHAR
-lines.AppendString(m_utf8conv.to_bytes(line));
+lines.AppendString(ToBytes(line));
 #else
 lines.AppendString(line);
 #endif
@@ -636,7 +676,7 @@ unsigned char Editline::BreakLineCommand(int ch) {
 if (m_fix_indentation_callback) {
   StringList lines = GetInputAsStringList(m_current_line_index + 1);
 #if LLDB_EDITLINE_USE_WCHAR
-  lines.AppendString(m_utf8conv.to_bytes(new_line_fragment));
+  lines.AppendString(ToBytes(new_line_fragment));
 #else
   lines.AppendString(new_line_fragment);
 #endif
@@ -685,7 +725,7 @@ unsigned char Editline::EndOrAddLineCommand(int ch) {
   for (unsigned index = 0; index < lines.GetSize(); index++) {
 #if LLDB_EDITLINE_USE_WCHAR
 m_input_lines.insert(m_input_lines.end(),
- m_utf8conv.from_bytes(lines[index]));
+ FromBytes(lines[index]));
 #else
 m_input_lines.insert(m_input_lines.end(), lines[index]);
 #endif
@@ -869,7 +909,7 @@ unsigned char Editline::FixIndentationCommand(int ch) {
 currentLine = currentLine.erase(0, -indent_correction);
   }
 #if LLDB_EDITLINE_USE_WCHAR
-  m_input_lines[m_current_line_index] = m_utf8conv.from_bytes(currentLine);
+  m_input_lines[m_current_line_index] = FromBytes(currentLine);
 #else
   m_input_lines[m_current_line_index] = currentLine;
 #endif
@@ -1502,7 +1542,7 @@ bool Editline::GetLine(std::string &line, bool 
&interrupted) {
 } else {
   m_history_sp->Enter(input);
 #if LLDB_EDITLINE_USE_WCHAR
-  line = m_utf8conv.to_bytes(SplitLines(input)[0]);
+  line = ToBytes(SplitLines(input)[0]);
 #else
   line = SplitLines(input)[0];
 #endif
@@ -1574,7 +1614,8 @@ bool Editline::CompleteCharacter(char ch, 
EditLineGetCharType &out) {
   out = (unsigned char)ch;
   return true;
 #else
-  std::codecvt_utf8 cvt;
+  std::locale locale("C.UTF-8");
+  const auto &cvt = std::use_facet>(locale);
   llvm::SmallString<4> input;
   for (;;) {
 const char *from_next;

>From 

[Lldb-commits] [lldb] [lldb] Use system c++ lib for LLDB STL tests (PR #112598)

2024-10-16 Thread via lldb-commits

https://github.com/zeroomega updated 
https://github.com/llvm/llvm-project/pull/112598

>From 2f2ab10e3712992bab7d4b08fad641d73c2800cb Mon Sep 17 00:00:00 2001
From: Haowei Wu 
Date: Wed, 16 Oct 2024 11:24:34 -0700
Subject: [PATCH] [lldb] Use system c++ lib for LLDB STL tests

This change partially reverts #112357 to avoid LLDB STL test
failures on machines which do not have gcc installed.
---
 lldb/test/API/lang/cpp/stl/Makefile | 6 --
 1 file changed, 6 deletions(-)

diff --git a/lldb/test/API/lang/cpp/stl/Makefile 
b/lldb/test/API/lang/cpp/stl/Makefile
index 4408691f01b701..8b20bcb050 100644
--- a/lldb/test/API/lang/cpp/stl/Makefile
+++ b/lldb/test/API/lang/cpp/stl/Makefile
@@ -1,9 +1,3 @@
 CXX_SOURCES := main.cpp
 
-ifneq ($(OS),Darwin)
-USE_LIBSTDCPP := 1
-else
-USE_SYSTEM_STDLIB := 1
-endif
-
 include Makefile.rules

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


[Lldb-commits] [lldb] [lldb] Use system c++ lib for LLDB STL tests (PR #112598)

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

https://github.com/Michael137 commented:

I believe we need to just remove all the USE_ variables. The PR that broke your 
bots was itself motivated by a breakage due to USE_SYSTEM_STDLIB

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


[Lldb-commits] [lldb] [lldb] Use system c++ lib for LLDB STL tests (PR #112598)

2024-10-16 Thread via lldb-commits

zeroomega wrote:

> I believe we need to just remove all the USE_ variables. The PR that broke 
> your bots was itself motivated by a breakage due to USE_SYSTEM_STDLIB

Done.
Test run in progress: https://ci.chromium.org/b/8733895290278713505

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


[Lldb-commits] [lldb] [lldb] Use system c++ lib for LLDB STL tests (PR #112598)

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

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

LGTM thx!

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


[Lldb-commits] [lldb] [lldb] Use system c++ lib for LLDB STL tests (PR #112598)

2024-10-16 Thread via lldb-commits

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


[Lldb-commits] [lldb] 8f683b5 - [lldb] Use system c++ lib for LLDB STL tests (#112598)

2024-10-16 Thread via lldb-commits

Author: Haowei
Date: 2024-10-16T16:34:02-07:00
New Revision: 8f683b552d7a0cf1bdd93f220e2552f9ea0a6b8d

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

LOG: [lldb] Use system c++ lib for LLDB STL tests (#112598)

This change partially reverts #112357 to avoid test failures on machines
which do not have gcc installed.

Added: 


Modified: 
lldb/test/API/lang/cpp/stl/Makefile

Removed: 




diff  --git a/lldb/test/API/lang/cpp/stl/Makefile 
b/lldb/test/API/lang/cpp/stl/Makefile
index 4408691f01b701..8b20bcb050 100644
--- a/lldb/test/API/lang/cpp/stl/Makefile
+++ b/lldb/test/API/lang/cpp/stl/Makefile
@@ -1,9 +1,3 @@
 CXX_SOURCES := main.cpp
 
-ifneq ($(OS),Darwin)
-USE_LIBSTDCPP := 1
-else
-USE_SYSTEM_STDLIB := 1
-endif
-
 include Makefile.rules



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


[Lldb-commits] [lldb] [lldb] Don't exit the main loop when in runs out of things to listen on (PR #112565)

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


@@ -365,10 +365,7 @@ Status MainLoopPosix::Run() {
   Status error;
   RunImpl impl(*this);
 
-  // run until termination or until we run out of things to listen to
-  // (m_read_fds will always contain m_trigger_pipe fd, so check for > 1)
-  while (!m_terminate_request &&

Jlalond wrote:

What changed to make this comment above (about the pipe never being empty) 
incorrect? 

Then again it basically sounds like a no-op

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


[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-16 Thread via lldb-commits

jimingham wrote:

That seems a common enough problem that there should be a more straightforward 
way to do it than having to barge into the middle of target setup...  

The SBPlatform already has a "module location callback" that you can hook in to 
find debug modules in a programmatic way.  It also knows things like the SDK 
Path on the host.  So it seems consistent with this design that you could put 
the "debug file location for this platform" into the platform, and then pass 
the platform to the target as you create it (you can already do that), and have 
the Target consult that first for where to find debug files.

Jim



> On Oct 16, 2024, at 1:19 PM, cmtice ***@***.***> wrote:
> 
> 
> I have wanted to be able to hook into target creation to be able to setup 
> targets when they get created. It would be also nice to get an event when a 
> process is not longer being debugged due to process exit or detach.
> 
> Something I have wanted for a long time is a stop hook just BEFORE the target 
> is created, to that I can change the setting for 
> target.debug-file-search-paths before LLDB tries to read all the debug info 
> (that it can't find because the search path setting hasn't been properly set 
> up for us).
> 
> —
> Reply to this email directly, view it on GitHub 
> , 
> or unsubscribe 
> .
> You are receiving this because you were mentioned.
> 



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


[Lldb-commits] [lldb] c5c11f3 - [lldb-dap] Creating an API for sending dap events from a script in lldb-dap. (#112384)

2024-10-16 Thread via lldb-commits

Author: John Harrison
Date: 2024-10-16T17:19:51-07:00
New Revision: c5c11f340436a88cfc2165f2dcd64e4d63285068

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

LOG: [lldb-dap] Creating an API for sending dap events from a script in 
lldb-dap. (#112384)

Custom DAP events can be detected using
https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent.

This API allows an lldb python script to send events to the DAP
client to allow extensions to handle these custom events.

Added: 
lldb/test/API/tools/lldb-dap/send-event/Makefile
lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
lldb/test/API/tools/lldb-dap/send-event/main.c

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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 1d5e6e0d75c7cb..63748a71f1122d 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -1267,7 +1267,7 @@ def run_vscode(dbg, args, options):
 def main():
 parser = optparse.OptionParser(
 description=(
-"A testing framework for the Visual Studio Code Debug " "Adaptor 
protocol"
+"A testing framework for the Visual Studio Code Debug Adaptor 
protocol"
 )
 )
 

diff  --git a/lldb/test/API/tools/lldb-dap/send-event/Makefile 
b/lldb/test/API/tools/lldb-dap/send-event/Makefile
new file mode 100644
index 00..10495940055b63
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/send-event/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules

diff  --git a/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py 
b/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
new file mode 100644
index 00..de47651bb2fa1b
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
@@ -0,0 +1,67 @@
+"""
+Test lldb-dap send-event integration.
+"""
+
+import json
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbdap_testcase
+
+
+class TestDAP_sendEvent(lldbdap_testcase.DAPTestCaseBase):
+def test_send_event(self):
+"""
+Test sending a custom event.
+"""
+program = self.getBuildArtifact("a.out")
+source = "main.c"
+custom_event_body = {
+"key": 321,
+"arr": [True],
+}
+self.build_and_launch(
+program,
+stopCommands=[
+"lldb-dap send-event my-custom-event-no-body",
+"lldb-dap send-event my-custom-event '{}'".format(
+json.dumps(custom_event_body)
+),
+],
+)
+
+breakpoint_line = line_number(source, "// breakpoint")
+
+self.set_source_breakpoints(source, [breakpoint_line])
+self.continue_to_next_stop()
+
+custom_event = self.dap_server.wait_for_event(
+filter=["my-custom-event-no-body"]
+)
+self.assertEquals(custom_event["event"], "my-custom-event-no-body")
+self.assertIsNone(custom_event.get("body", None))
+
+custom_event = 
self.dap_server.wait_for_event(filter=["my-custom-event"])
+self.assertEquals(custom_event["event"], "my-custom-event")
+self.assertEquals(custom_event["body"], custom_event_body)
+
+def test_send_internal_event(self):
+"""
+Test sending an internal event produces an error.
+"""
+program = self.getBuildArtifact("a.out")
+source = "main.c"
+self.build_and_launch(program)
+
+breakpoint_line = line_number(source, "// breakpoint")
+
+self.set_source_breakpoints(source, [breakpoint_line])
+self.continue_to_next_stop()
+
+resp = self.dap_server.request_evaluate(
+"`lldb-dap send-event stopped", context="repl"
+)
+self.assertRegex(
+resp["body"]["result"],
+r"Invalid use of lldb-dap send-event, event \"stopped\" should be 
handled by lldb-dap internally.",
+)

diff  --git a/lldb/test/API/tools/lldb-dap/send-event/main.c 
b/lldb/test/API/tools/lldb-dap/send-event/main.c
new file mode 100644
index 00..27bc22b94794b6
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/send-event/main.c
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char const *argv[]) {
+  printf("example\n"); // breakpoint 1
+  return 0;
+}

diff  --git a/lldb/tools/lldb-dap/DAP.

[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

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

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


[Lldb-commits] [lldb] [lldb] Remove more mentions of ASLLogCallback (PR #112639)

2024-10-16 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/112639

None

>From 44c697b7621b25505bd9097f5820b813868d4f0f Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 16 Oct 2024 17:29:44 -0700
Subject: [PATCH] [lldb] Remove more mentions of ASLLogCallback

---
 lldb/tools/debugserver/source/RNBRemote.cpp  | 16 +++-
 lldb/tools/debugserver/source/libdebugserver.cpp |  8 
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index f22d626c4af2c6..07211c6e9db492 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -176,9 +176,6 @@ void append_hexified_string(std::ostream &ostrm, const 
std::string &string) {
   }
 }
 
-extern void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-   va_list args);
-
 // from System.framework/Versions/B/PrivateHeaders/sys/codesign.h
 extern "C" {
 #define CS_OPS_STATUS 0   /* return status */
@@ -1773,8 +1770,6 @@ static std::string get_value(std::string &line) {
 
 extern void FileLogCallback(void *baton, uint32_t flags, const char *format,
 va_list args);
-extern void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-   va_list args);
 
 rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
   const char *c = p + strlen("qRcmd,");
@@ -1809,8 +1804,8 @@ rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
 static_cast(strtoul(value.c_str(), &end, 0));
 if (errno == 0 && end && *end == '\0') {
   DNBLogSetLogMask(logmask);
-  if (!DNBLogGetLogCallback())
-DNBLogSetLogCallback(ASLLogCallback, NULL);
+  if (auto log_callback = OsLogger::GetLogFunction())
+DNBLogSetLogCallback(log_callback, nullptr);
   return SendPacket("OK");
 }
 errno = 0;
@@ -2177,13 +2172,8 @@ rnb_err_t set_logging(const char *p) {
 // Enable DNB logging.
 // Use the existing log callback if one was already configured.
 if (!DNBLogGetLogCallback()) {
-  // Use the os_log()-based logger if available; otherwise,
-  // fallback to ASL.
-  auto log_callback = OsLogger::GetLogFunction();
-  if (log_callback)
+  if (auto log_callback = OsLogger::GetLogFunction())
 DNBLogSetLogCallback(log_callback, nullptr);
-  else
-DNBLogSetLogCallback(ASLLogCallback, nullptr);
 }
 
 // Update logging to use the configured log channel bitmask.
diff --git a/lldb/tools/debugserver/source/libdebugserver.cpp 
b/lldb/tools/debugserver/source/libdebugserver.cpp
index 6da3708b4240b7..17a5c137c1afb1 100644
--- a/lldb/tools/debugserver/source/libdebugserver.cpp
+++ b/lldb/tools/debugserver/source/libdebugserver.cpp
@@ -311,13 +311,6 @@ RNBRunLoopMode RNBRunLoopInferiorExecuting(RNBRemoteSP 
&remote) {
   return mode;
 }
 
-void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-va_list args) {
-#if 0
-   vprintf(format, args);
-#endif
-}
-
 extern "C" int debug_server_main(int fd) {
 #if 1
   g_isatty = 0;
@@ -327,7 +320,6 @@ extern "C" int debug_server_main(int fd) {
   DNBLogSetDebug(1);
   DNBLogSetVerbose(1);
   DNBLogSetLogMask(-1);
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
 #endif
 
   signal(SIGPIPE, signal_handler);

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


[Lldb-commits] [lldb] [lldb] Remove more mentions of ASLLogCallback (PR #112639)

2024-10-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes



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


2 Files Affected:

- (modified) lldb/tools/debugserver/source/RNBRemote.cpp (+3-13) 
- (modified) lldb/tools/debugserver/source/libdebugserver.cpp (-8) 


``diff
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index f22d626c4af2c6..07211c6e9db492 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -176,9 +176,6 @@ void append_hexified_string(std::ostream &ostrm, const 
std::string &string) {
   }
 }
 
-extern void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-   va_list args);
-
 // from System.framework/Versions/B/PrivateHeaders/sys/codesign.h
 extern "C" {
 #define CS_OPS_STATUS 0   /* return status */
@@ -1773,8 +1770,6 @@ static std::string get_value(std::string &line) {
 
 extern void FileLogCallback(void *baton, uint32_t flags, const char *format,
 va_list args);
-extern void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-   va_list args);
 
 rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
   const char *c = p + strlen("qRcmd,");
@@ -1809,8 +1804,8 @@ rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
 static_cast(strtoul(value.c_str(), &end, 0));
 if (errno == 0 && end && *end == '\0') {
   DNBLogSetLogMask(logmask);
-  if (!DNBLogGetLogCallback())
-DNBLogSetLogCallback(ASLLogCallback, NULL);
+  if (auto log_callback = OsLogger::GetLogFunction())
+DNBLogSetLogCallback(log_callback, nullptr);
   return SendPacket("OK");
 }
 errno = 0;
@@ -2177,13 +2172,8 @@ rnb_err_t set_logging(const char *p) {
 // Enable DNB logging.
 // Use the existing log callback if one was already configured.
 if (!DNBLogGetLogCallback()) {
-  // Use the os_log()-based logger if available; otherwise,
-  // fallback to ASL.
-  auto log_callback = OsLogger::GetLogFunction();
-  if (log_callback)
+  if (auto log_callback = OsLogger::GetLogFunction())
 DNBLogSetLogCallback(log_callback, nullptr);
-  else
-DNBLogSetLogCallback(ASLLogCallback, nullptr);
 }
 
 // Update logging to use the configured log channel bitmask.
diff --git a/lldb/tools/debugserver/source/libdebugserver.cpp 
b/lldb/tools/debugserver/source/libdebugserver.cpp
index 6da3708b4240b7..17a5c137c1afb1 100644
--- a/lldb/tools/debugserver/source/libdebugserver.cpp
+++ b/lldb/tools/debugserver/source/libdebugserver.cpp
@@ -311,13 +311,6 @@ RNBRunLoopMode RNBRunLoopInferiorExecuting(RNBRemoteSP 
&remote) {
   return mode;
 }
 
-void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-va_list args) {
-#if 0
-   vprintf(format, args);
-#endif
-}
-
 extern "C" int debug_server_main(int fd) {
 #if 1
   g_isatty = 0;
@@ -327,7 +320,6 @@ extern "C" int debug_server_main(int fd) {
   DNBLogSetDebug(1);
   DNBLogSetVerbose(1);
   DNBLogSetLogMask(-1);
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
 #endif
 
   signal(SIGPIPE, signal_handler);

``




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


[Lldb-commits] [lldb] 90767bc - [lldb] Remove more mentions of ASLLogCallback (#112639)

2024-10-16 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-10-16T17:33:12-07:00
New Revision: 90767bc41bd69fb4b9ac01a8420ef58bbbaeab7c

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

LOG: [lldb] Remove more mentions of ASLLogCallback (#112639)

Added: 


Modified: 
lldb/tools/debugserver/source/RNBRemote.cpp
lldb/tools/debugserver/source/libdebugserver.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index f22d626c4af2c6..07211c6e9db492 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -176,9 +176,6 @@ void append_hexified_string(std::ostream &ostrm, const 
std::string &string) {
   }
 }
 
-extern void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-   va_list args);
-
 // from System.framework/Versions/B/PrivateHeaders/sys/codesign.h
 extern "C" {
 #define CS_OPS_STATUS 0   /* return status */
@@ -1773,8 +1770,6 @@ static std::string get_value(std::string &line) {
 
 extern void FileLogCallback(void *baton, uint32_t flags, const char *format,
 va_list args);
-extern void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-   va_list args);
 
 rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
   const char *c = p + strlen("qRcmd,");
@@ -1809,8 +1804,8 @@ rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
 static_cast(strtoul(value.c_str(), &end, 0));
 if (errno == 0 && end && *end == '\0') {
   DNBLogSetLogMask(logmask);
-  if (!DNBLogGetLogCallback())
-DNBLogSetLogCallback(ASLLogCallback, NULL);
+  if (auto log_callback = OsLogger::GetLogFunction())
+DNBLogSetLogCallback(log_callback, nullptr);
   return SendPacket("OK");
 }
 errno = 0;
@@ -2177,13 +2172,8 @@ rnb_err_t set_logging(const char *p) {
 // Enable DNB logging.
 // Use the existing log callback if one was already configured.
 if (!DNBLogGetLogCallback()) {
-  // Use the os_log()-based logger if available; otherwise,
-  // fallback to ASL.
-  auto log_callback = OsLogger::GetLogFunction();
-  if (log_callback)
+  if (auto log_callback = OsLogger::GetLogFunction())
 DNBLogSetLogCallback(log_callback, nullptr);
-  else
-DNBLogSetLogCallback(ASLLogCallback, nullptr);
 }
 
 // Update logging to use the configured log channel bitmask.

diff  --git a/lldb/tools/debugserver/source/libdebugserver.cpp 
b/lldb/tools/debugserver/source/libdebugserver.cpp
index 6da3708b4240b7..17a5c137c1afb1 100644
--- a/lldb/tools/debugserver/source/libdebugserver.cpp
+++ b/lldb/tools/debugserver/source/libdebugserver.cpp
@@ -311,13 +311,6 @@ RNBRunLoopMode RNBRunLoopInferiorExecuting(RNBRemoteSP 
&remote) {
   return mode;
 }
 
-void ASLLogCallback(void *baton, uint32_t flags, const char *format,
-va_list args) {
-#if 0
-   vprintf(format, args);
-#endif
-}
-
 extern "C" int debug_server_main(int fd) {
 #if 1
   g_isatty = 0;
@@ -327,7 +320,6 @@ extern "C" int debug_server_main(int fd) {
   DNBLogSetDebug(1);
   DNBLogSetVerbose(1);
   DNBLogSetLogMask(-1);
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
 #endif
 
   signal(SIGPIPE, signal_handler);



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


[Lldb-commits] [lldb] [lldb] Remove more mentions of ASLLogCallback (PR #112639)

2024-10-16 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove more mentions of ASLLogCallback (PR #112639)

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

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


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


[Lldb-commits] [lldb] Add support for reading the dynamic symbol table from PT_DYNAMIC (PR #112596)

2024-10-16 Thread Greg Clayton via lldb-commits

https://github.com/clayborg created 
https://github.com/llvm/llvm-project/pull/112596

Allow LLDB to parse the dynamic symbol table from an ELF file or memory image 
in an ELF file that has no section headers. This patch uses the ability to 
parse the PT_DYNAMIC segment and find the DT_SYMTAB, DT_SYMENT, DT_HASH or 
DT_GNU_HASH to find and parse the dynamic symbol table if the section headers 
are not present. It also adds a helper function to read data from a .dynamic 
key/value pair entry correctly from the file or from memory.

>From 890d2bcf655a2e1e58b025cc0df7b4e42956e4c6 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Sat, 28 Sep 2024 15:05:37 -0700
Subject: [PATCH] Add support for reading the dynamic symbol table from program
 headers and PT_DYNAMIC.

Allow LLDB to parse the dynamic symbol table from an ELF file or memory image 
in an ELF file that has no section headers. This patch uses the ability to 
parse the PT_DYNAMIC segment and find the DT_SYMTAB, DT_SYMENT, DT_HASH or 
DT_GNU_HASH to find and parse the dynamic symbol table if the section headers 
are not present. It also adds a helper function to read data from a .dynamic 
key/value pair entry correctly from the file or from memory.
---
 .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp  | 163 -
 .../Plugins/ObjectFile/ELF/ObjectFileELF.h|  34 +
 .../test/Shell/ObjectFile/ELF/elf-dynsym.yaml | 631 ++
 3 files changed, 811 insertions(+), 17 deletions(-)
 create mode 100644 lldb/test/Shell/ObjectFile/ELF/elf-dynsym.yaml

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 10d09662c0a47a..7374ac10a1e27a 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -44,6 +44,8 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MipsABIFlags.h"
+#include "lldb/Target/Process.h"
+
 
 #define CASE_AND_STREAM(s, def, width) 
\
   case def:
\
@@ -2990,18 +2992,34 @@ void ObjectFileELF::ParseSymtab(Symtab &lldb_symtab) {
   // section, nomatter if .symtab was already parsed or not. This is because
   // minidebuginfo normally removes the .symtab symbols which have their
   // matching .dynsym counterparts.
+  bool found_dynsym = false;
   if (!symtab ||
   GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"))) {
 Section *dynsym =
 section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
 .get();
 if (dynsym) {
+  found_dynsym = true;
   auto [num_symbols, address_class_map] =
   ParseSymbolTable(&lldb_symtab, symbol_id, dynsym);
   symbol_id += num_symbols;
   m_address_class_map.merge(address_class_map);
 }
   }
+  if (!found_dynsym) {
+// Try and read the dynamic symbol table from the .dynamic section.
+uint32_t num_symbols = 0;
+std::optional symtab_data =
+GetDynsymDataFromDynamic(num_symbols);
+std::optional strtab_data = GetDynstrData();
+if (symtab_data && strtab_data) {
+  auto [num_symbols_parsed, address_class_map] =
+  ParseSymbols(&lldb_symtab, symbol_id, section_list, num_symbols,
+symtab_data.value(), strtab_data.value());
+  symbol_id += num_symbols_parsed;
+  m_address_class_map.merge(address_class_map);
+}
+  }
 
   // DT_JMPREL
   //  If present, this entry's d_ptr member holds the address of
@@ -3811,6 +3829,33 @@ ObjectFileELF::MapFileDataWritable(const FileSpec &file, 
uint64_t Size,
  Offset);
 }
 
+std::optional
+ObjectFileELF::ReadDataFromDynamic(const ELFDynamic *dyn, uint64_t length,
+   uint64_t offset) {
+  // ELFDynamic values contain a "d_ptr" member that will be a load address if
+  // we have an ELF file read from memory, or it will be a file address if it
+  // was read from a ELF file. This function will correctly fetch data pointed
+  // to by the ELFDynamic::d_ptr, or return std::nullopt if the data isn't
+  // available.
+  const lldb::addr_t d_ptr_addr = dyn->d_ptr + offset;
+  if (ProcessSP process_sp = m_process_wp.lock()) {
+if (DataBufferSP data_sp = ReadMemory(process_sp, d_ptr_addr, length))
+  return DataExtractor(data_sp, GetByteOrder(), GetAddressByteSize());
+  } else {
+// We have an ELF file with no section headers or we didn't find the
+// .dynamic section. Try and find the .dynstr section.
+Address addr;
+if (!addr.ResolveAddressUsingFileSections(d_ptr_addr, GetSectionList()))
+  return std::nullopt;
+DataExtractor data;
+addr.GetSection()->GetSectionData(data);
+return DataExtractor(data,
+ d_ptr_addr - addr.GetSection()->GetFileAddress(),
+ l

[Lldb-commits] [lldb] Add support for reading the dynamic symbol table from PT_DYNAMIC (PR #112596)

2024-10-16 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Greg Clayton (clayborg)


Changes

Allow LLDB to parse the dynamic symbol table from an ELF file or memory image 
in an ELF file that has no section headers. This patch uses the ability to 
parse the PT_DYNAMIC segment and find the DT_SYMTAB, DT_SYMENT, DT_HASH or 
DT_GNU_HASH to find and parse the dynamic symbol table if the section headers 
are not present. It also adds a helper function to read data from a .dynamic 
key/value pair entry correctly from the file or from memory.

---

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


3 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+146-17) 
- (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (+34) 
- (added) lldb/test/Shell/ObjectFile/ELF/elf-dynsym.yaml (+631) 


``diff
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 10d09662c0a47a..7374ac10a1e27a 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -44,6 +44,8 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MipsABIFlags.h"
+#include "lldb/Target/Process.h"
+
 
 #define CASE_AND_STREAM(s, def, width) 
\
   case def:
\
@@ -2990,18 +2992,34 @@ void ObjectFileELF::ParseSymtab(Symtab &lldb_symtab) {
   // section, nomatter if .symtab was already parsed or not. This is because
   // minidebuginfo normally removes the .symtab symbols which have their
   // matching .dynsym counterparts.
+  bool found_dynsym = false;
   if (!symtab ||
   GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"))) {
 Section *dynsym =
 section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
 .get();
 if (dynsym) {
+  found_dynsym = true;
   auto [num_symbols, address_class_map] =
   ParseSymbolTable(&lldb_symtab, symbol_id, dynsym);
   symbol_id += num_symbols;
   m_address_class_map.merge(address_class_map);
 }
   }
+  if (!found_dynsym) {
+// Try and read the dynamic symbol table from the .dynamic section.
+uint32_t num_symbols = 0;
+std::optional symtab_data =
+GetDynsymDataFromDynamic(num_symbols);
+std::optional strtab_data = GetDynstrData();
+if (symtab_data && strtab_data) {
+  auto [num_symbols_parsed, address_class_map] =
+  ParseSymbols(&lldb_symtab, symbol_id, section_list, num_symbols,
+symtab_data.value(), strtab_data.value());
+  symbol_id += num_symbols_parsed;
+  m_address_class_map.merge(address_class_map);
+}
+  }
 
   // DT_JMPREL
   //  If present, this entry's d_ptr member holds the address of
@@ -3811,6 +3829,33 @@ ObjectFileELF::MapFileDataWritable(const FileSpec &file, 
uint64_t Size,
  Offset);
 }
 
+std::optional
+ObjectFileELF::ReadDataFromDynamic(const ELFDynamic *dyn, uint64_t length,
+   uint64_t offset) {
+  // ELFDynamic values contain a "d_ptr" member that will be a load address if
+  // we have an ELF file read from memory, or it will be a file address if it
+  // was read from a ELF file. This function will correctly fetch data pointed
+  // to by the ELFDynamic::d_ptr, or return std::nullopt if the data isn't
+  // available.
+  const lldb::addr_t d_ptr_addr = dyn->d_ptr + offset;
+  if (ProcessSP process_sp = m_process_wp.lock()) {
+if (DataBufferSP data_sp = ReadMemory(process_sp, d_ptr_addr, length))
+  return DataExtractor(data_sp, GetByteOrder(), GetAddressByteSize());
+  } else {
+// We have an ELF file with no section headers or we didn't find the
+// .dynamic section. Try and find the .dynstr section.
+Address addr;
+if (!addr.ResolveAddressUsingFileSections(d_ptr_addr, GetSectionList()))
+  return std::nullopt;
+DataExtractor data;
+addr.GetSection()->GetSectionData(data);
+return DataExtractor(data,
+ d_ptr_addr - addr.GetSection()->GetFileAddress(),
+ length);
+  }
+  return std::nullopt;
+}
+
 std::optional ObjectFileELF::GetDynstrData() {
   if (SectionList *section_list = GetSectionList()) {
 // Find the SHT_DYNAMIC section.
@@ -3846,23 +3891,7 @@ std::optional 
ObjectFileELF::GetDynstrData() {
   if (strtab == nullptr || strsz == nullptr)
 return std::nullopt;
 
-  if (ProcessSP process_sp = m_process_wp.lock()) {
-if (DataBufferSP data_sp =
-ReadMemory(process_sp, strtab->d_ptr, strsz->d_val))
-  return DataExtractor(data_sp, GetByteOrder(), GetAddressByteSize());
-  } else {
-// We have an ELF file with no section headers

[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-16 Thread via lldb-commits

cmtice wrote:

> I have wanted to be able to hook into target creation to be able to setup 
> targets when they get created. It would be also nice to get an event when a 
> process is not longer being debugged due to process exit or detach.

Something I have wanted for a long time is a stop hook just BEFORE the target 
is created, to that I can change the setting for target.debug-file-search-paths 
before LLDB tries to read all the debug info (that it can't find because the 
search path setting hasn't been properly set up for us).

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


[Lldb-commits] [lldb] [lldb] Don't exit the main loop when in runs out of things to listen on (PR #112565)

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

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


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


[Lldb-commits] [lldb] [lldb] Don't exit the main loop when in runs out of things to listen on (PR #112565)

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


@@ -212,15 +209,14 @@ TEST_F(MainLoopTest, PendingCallbackTrigger) {
   ASSERT_TRUE(callback2_called);
 }
 
-// Regression test for assertion failure if a lot of callbacks end up
-// being queued after loop exits.
-TEST_F(MainLoopTest, PendingCallbackAfterLoopExited) {
+TEST_F(MainLoopTest, ManyPendingCallbacks) {
   MainLoop loop;
   Status error;
-  ASSERT_TRUE(loop.Run().Success());
-  // Try to fill the pipe buffer in.
+  // Try to fill up the pipe buffer and make sure bad things don't happen.

Jlalond wrote:

The prior comment I think better explained the purpose of the test (ensuring we 
terminate even if the pipe buffer is full). 

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


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

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


@@ -962,6 +962,68 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   return true;
 }
 
+// Sends a DAP event with an optional body.
+//
+// See
+// 
https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent
+bool SendEventRequestHandler::DoExecute(lldb::SBDebugger debugger,
+char **command,
+lldb::SBCommandReturnObject &result) {
+  // Command format like: `send-event  ?`
+  if (!command || !command[0] || llvm::StringRef(command[0]).empty()) {
+result.SetError("Not enough arguments found, expected format "
+"`lldb-dap send-event  ?`.");
+return false;
+  }
+
+  llvm::StringRef name{command[0]};
+  // Events that are stateful and should be handled by lldb-dap internally.
+  const std::array internal_events{"breakpoint", "capabilities", "continued",
+   "exited", "initialize",   
"loadedSource",
+   "module", "process",  "stopped",
+   "terminated", "thread"};
+  if (std::find(internal_events.begin(), internal_events.end(), name) !=
+  std::end(internal_events)) {
+std::string msg =
+llvm::formatv("Invalid use of lldb-dap send-event, event \"{0}\" "
+  "should be handled by lldb-dap internally.",
+  name)
+.str();
+result.SetError(msg.c_str());
+return false;
+  }
+
+  llvm::json::Object event(CreateEventObject(name));
+
+  if (command[1] && !llvm::StringRef(command[1]).empty()) {
+// See if we have to unused arguments.

ashgti wrote:

Applied

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


[Lldb-commits] [lldb] [lldb-dap] Creating an API for sending custom dap events from lldb-dap. (PR #112384)

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


@@ -962,6 +962,68 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   return true;
 }
 
+// Sends a DAP event with an optional body.
+//
+// See
+// 
https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent
+bool SendEventRequestHandler::DoExecute(lldb::SBDebugger debugger,
+char **command,
+lldb::SBCommandReturnObject &result) {
+  // Command format like: `send-event  ?`
+  if (!command || !command[0] || llvm::StringRef(command[0]).empty()) {
+result.SetError("Not enough arguments found, expected format "
+"`lldb-dap send-event  ?`.");
+return false;
+  }
+
+  llvm::StringRef name{command[0]};
+  // Events that are stateful and should be handled by lldb-dap internally.
+  const std::array internal_events{"breakpoint", "capabilities", "continued",
+   "exited", "initialize",   
"loadedSource",
+   "module", "process",  "stopped",
+   "terminated", "thread"};
+  if (std::find(internal_events.begin(), internal_events.end(), name) !=
+  std::end(internal_events)) {
+std::string msg =
+llvm::formatv("Invalid use of lldb-dap send-event, event \"{0}\" "
+  "should be handled by lldb-dap internally.",
+  name)
+.str();
+result.SetError(msg.c_str());
+return false;
+  }
+
+  llvm::json::Object event(CreateEventObject(name));
+
+  if (command[1] && !llvm::StringRef(command[1]).empty()) {
+// See if we have to unused arguments.
+if (command[2] && !llvm::StringRef(command[2]).empty()) {

ashgti wrote:

The `command` param is a `char **command` so I can't check a `.size()`. Its an 
array of null terminated strings with nullptr at the tail end.

Updated the check to not use `.empty()` and instead just check if the pointer 
is not null.

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


[Lldb-commits] [lldb] [lldb] Use system c++ lib for LLDB STL tests (PR #112598)

2024-10-16 Thread via lldb-commits

zeroomega wrote:

The patch passed all presubmit tests.
Can I get a approval to land it?

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


[Lldb-commits] [lldb] Add support for reading the dynamic symbol table from PT_DYNAMIC (PR #112596)

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


@@ -44,6 +44,8 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MipsABIFlags.h"
+#include "lldb/Target/Process.h"
+

Jlalond wrote:

Nit: empty line

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


[Lldb-commits] [lldb] Add support for reading the dynamic symbol table from PT_DYNAMIC (PR #112596)

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


@@ -3895,3 +3924,103 @@ std::optional 
ObjectFileELF::GetDynamicData() {
   }
   return std::nullopt;
 }
+
+
+std::optional
+ObjectFileELF::GetDynsymDataFromDynamic(uint32_t &num_symbols) {
+  // Every ELF file which represents an executable or shared library has
+  // mandatory .dynamic entries. The DT_SYMTAB value contains a pointer to the
+  // symbol table, and DT_SYMENT contains the size of a symbol table entry.
+  // We then can use either the DT_HASH or DT_GNU_HASH to find the number of
+  // symbols in the symbol table as the symbol count is not stored in the
+  // .dynamic section as a key/value pair.
+  //
+  // When loading and ELF file from memory, only the program headers end up
+  // being mapped into memory, and we can find these values in the PT_DYNAMIC
+  // segment.
+  num_symbols = 0;
+  // Get the process in case this is an in memory ELF file.
+  ProcessSP process_sp(m_process_wp.lock());
+  const ELFDynamic *symtab = FindDynamicSymbol(DT_SYMTAB);
+  const ELFDynamic *syment = FindDynamicSymbol(DT_SYMENT);
+  const ELFDynamic *hash = FindDynamicSymbol(DT_HASH);
+  const ELFDynamic *gnu_hash = FindDynamicSymbol(DT_GNU_HASH);
+  // DT_SYMTAB and DT_SYMENT are mandatory.
+  if (symtab == nullptr || syment == nullptr)
+return std::nullopt;
+  // We must have either a DT_HASH or a DT_GNU_HASH.
+  if (hash == nullptr && gnu_hash == nullptr)
+return std::nullopt;
+  // The number of symbols in the symbol table is the number of entries in the
+  // symbol table divided by the size of each symbol table entry.
+  // We must figure out the number of symbols in the symbol table using the
+  // DT_HASH or the DT_GNU_HASH as the number of symbols isn't stored anywhere
+  // in the .dynamic section.
+
+  lldb::offset_t offset;
+  if (hash) {
+// The DT_HASH header contains the number of symbols in the "nchain"
+// member. The header looks like this:
+// struct DT_HASH_HEADER {
+//   uint32_t nbucket;
+//   uint32_t nchain;
+// };
+if (auto data = ReadDataFromDynamic(hash, 8)) {
+  offset = 4;

Jlalond wrote:

Should we make a comment why we're ignoring the first field

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


  1   2   >