[Lldb-commits] [lldb] [lldb-dap] Correctly detect alias commands with arguments in repl (PR #92137)

2024-05-15 Thread Pavel Labath via lldb-commits

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

>From 6d4df820e84e84a871a6d24a196608047470d7d7 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 14 May 2024 15:32:15 +
Subject: [PATCH 1/2] [lldb-dap] Correctly detect alias commands with arguments
 in repl

ResolveCommand will not succeed for an alias command with arguments, and
the code wasn't providing any. Replace that with explicit query(ies) for
the existence of a command with the given name.
---
 .../API/tools/lldb-dap/repl-mode/Makefile |  3 +
 .../repl-mode/TestDAP_repl_mode_detection.py  | 56 +++
 .../API/tools/lldb-dap/repl-mode/main.cpp | 15 +
 lldb/tools/lldb-dap/DAP.cpp   |  8 ++-
 4 files changed, 79 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/repl-mode/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
 create mode 100644 lldb/test/API/tools/lldb-dap/repl-mode/main.cpp

diff --git a/lldb/test/API/tools/lldb-dap/repl-mode/Makefile 
b/lldb/test/API/tools/lldb-dap/repl-mode/Makefile
new file mode 100644
index 0..8b20bcb05
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/repl-mode/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py 
b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
new file mode 100644
index 0..8beecac26160e
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py
@@ -0,0 +1,56 @@
+"""
+Test lldb-dap repl mode detection
+"""
+
+import lldbdap_testcase
+import dap_server
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestDAP_repl_mode_detection(lldbdap_testcase.DAPTestCaseBase):
+
+def assertEvaluate(self, expression, regex):
+self.assertRegex(
+self.dap_server.request_evaluate(expression, 
context="repl")["body"][
+"result"
+],
+regex,
+)
+
+def test_completions(self):
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+source = "main.cpp"
+breakpoint1_line = line_number(source, "// breakpoint 1")
+breakpoint2_line = line_number(source, "// breakpoint 2")
+
+self.set_source_breakpoints(source, [breakpoint1_line, 
breakpoint2_line])
+
+self.assertEvaluate(
+"`command regex user_command s/^$/platform/", r"\(lldb\) command 
regex"
+)
+self.assertEvaluate(
+"`command alias alias_command platform", r"\(lldb\) command alias"
+)
+self.assertEvaluate(
+"`command alias alias_command_with_arg platform select --sysroot 
%1 remote-linux",
+r"\(lldb\) command alias",
+)
+
+self.continue_to_next_stop()
+self.assertEvaluate("user_command", "474747")
+self.assertEvaluate("alias_command", "474747")
+self.assertEvaluate("alias_command_with_arg", "474747")
+self.assertEvaluate("platform", "474747")
+
+self.continue_to_next_stop()
+platform_help_needle = "Commands to manage and create platforms"
+self.assertEvaluate("user_command", platform_help_needle)
+self.assertEvaluate("alias_command", platform_help_needle)
+self.assertEvaluate(
+"alias_command_with_arg " + self.getBuildDir(), "Platform: 
remote-linux"
+)
+self.assertEvaluate("platform", platform_help_needle)
diff --git a/lldb/test/API/tools/lldb-dap/repl-mode/main.cpp 
b/lldb/test/API/tools/lldb-dap/repl-mode/main.cpp
new file mode 100644
index 0..52561d3471abf
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/repl-mode/main.cpp
@@ -0,0 +1,15 @@
+void noop() {}
+
+void fun() {
+  int user_command = 474747;
+  int alias_command = 474747;
+  int alias_command_with_arg = 474747;
+  int platform = 474747; // built-in command
+  noop();// breakpoint 1
+}
+
+int main() {
+  fun();
+  noop(); // breakpoint 2
+  return 0;
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 55ff1493c1011..c7eb3db4304a9 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -14,6 +14,7 @@
 
 #include "DAP.h"
 #include "LLDBUtils.h"
+#include "lldb/API/SBCommandInterpreter.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/FormatVariadic.h"
 
@@ -405,9 +406,10 @@ ExpressionContext 
DAP::DetectExpressionContext(lldb::SBFrame frame,
 std::pair token =
 llvm::getToken(expression);
 std::string term = token.first.str();
-lldb::SBCommandReturnObject result;
-debugger.GetCommandInterpreter().ResolveCommand(term.c_str(), result);
-bool term_is_command = result.Succeeded();
+lldb::SBCommandInterpreter interpreter = debugger.

[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92078)

2024-05-15 Thread Pavel Labath via lldb-commits

labath wrote:

> > Can we make this less brute force? I believe searching for the Build ID 
> > Note should be a completely deterministic process, without the need for 
> > heuristics. You start with the elf header, find the program headers, 
> > iterate to find the PT_NOTE segment (there could be more of them), and 
> > iterate over the notes until you find NT_GNU_BUILD_ID. All of these things 
> > should be in the memory (=> also in the core file) and within the first 4k 
> > of the mapping. There should be no need to search through a potentially 
> > huge file mapping just to see if it contains the build id.
> 
> Yes, we can parse the program headers. That is a good idea as long as all the 
> info we need is mapped

It should all be there. In the files I looked at, both the program headers and 
all the note segments are in the first page of the mapping (which is the page 
containing the elf header). I can't find a reference for that now but I 
remember reading somewhere that this was intentional (to ensure the build id 
survives).

BTW, we have some elf parsing code in 
`NativeProcessELF::GetELFImageInfoAddress()`, that you could draw inspiration 
from.


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


[Lldb-commits] [lldb] [lldb/aarch64] Allow unaligned PC addresses below a trap handler (PR #92093)

2024-05-15 Thread Pavel Labath via lldb-commits

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

>From 391a4129d3da4c4730e50d6ebca23a3c36c3b462 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 14 May 2024 01:27:45 -0700
Subject: [PATCH 1/2] [lldb/aarch64] Allow unaligned PC addresses below a trap
 handler

The stack validation heuristic is counter-productive in this case, as
the unaligned address is most likely the thing that caused the signal in
the first place.
---
 lldb/source/Target/UnwindLLDB.cpp |  7 -
 .../Shell/Unwind/Inputs/unaligned-pc-sigbus.c | 21 +++
 .../Shell/Unwind/unaligned-pc-sigbus.test | 26 +++
 3 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c
 create mode 100644 lldb/test/Shell/Unwind/unaligned-pc-sigbus.test

diff --git a/lldb/source/Target/UnwindLLDB.cpp 
b/lldb/source/Target/UnwindLLDB.cpp
index 1d8bf2f88ae67..f43e940492b09 100644
--- a/lldb/source/Target/UnwindLLDB.cpp
+++ b/lldb/source/Target/UnwindLLDB.cpp
@@ -261,7 +261,12 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) 
{
   cur_idx < 100 ? cur_idx : 100, "", cur_idx);
 return nullptr;
   }
-  if (abi && !abi->CodeAddressIsValid(cursor_sp->start_pc)) {
+
+  // Invalid code addresses should not appear on the stack *unless* we're
+  // directly below a trap handler frame (in this case, the invalid address is
+  // likely the cause of the trap).
+  if (abi && !abi->CodeAddressIsValid(cursor_sp->start_pc) &&
+  !prev_frame->reg_ctx_lldb_sp->IsTrapHandlerFrame()) {
 // If the RegisterContextUnwind has a fallback UnwindPlan, it will switch 
to
 // that and return true.  Subsequent calls to TryFallbackUnwindPlan() will
 // return false.
diff --git a/lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c 
b/lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c
new file mode 100644
index 0..b4818de3b7fb3
--- /dev/null
+++ b/lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c
@@ -0,0 +1,21 @@
+#include 
+#include 
+#include 
+
+void sigbus_handler(int signo) { _exit(47); }
+
+int target_function() { return 47; }
+
+int main() {
+  signal(SIGBUS, sigbus_handler);
+
+  // Generate a SIGBUS by deliverately calling through an unaligned function
+  // pointer.
+  union {
+int (*t)();
+uintptr_t p;
+  } u;
+  u.t = target_function;
+  u.p |= 1;
+  return u.t();
+}
diff --git a/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test 
b/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
new file mode 100644
index 0..f74ec1e858551
--- /dev/null
+++ b/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
@@ -0,0 +1,26 @@
+# REQUIRES: (target-aarch64 || target-arm) && native
+# UNSUPPORTED: system-windows
+
+# RUN: %clang_host %S/Inputs/unaligned-pc-sigbus.c -o %t
+# RUN: %lldb -s %s -o exit %t | FileCheck %s
+
+breakpoint set -n sigbus_handler
+# CHECK: Breakpoint 1: where = {{.*}}`sigbus_handler
+
+run
+# CHECK: thread #1, {{.*}} stop reason = signal SIGBUS
+
+thread backtrace
+# CHECK: (lldb) thread backtrace
+# CHECK: frame #0: [[TARGET:0x[0-9a-fA-F]*]] {{.*}}`target_function
+
+continue
+# CHECK: thread #1, {{.*}} stop reason = breakpoint 1
+
+
+thread backtrace
+# CHECK: (lldb) thread backtrace
+# CHECK: frame #0: {{.*}}`sigbus_handler
+# Unknown number of signal trampoline frames
+# CHECK: frame #{{[0-9]+}}: [[TARGET]] {{.*}}`target_function
+

>From b97a7c9752a8ee7e2b5fdcc83790e1bb301f1b42 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 15 May 2024 07:58:00 +
Subject: [PATCH 2/2] fix/xfail darwin

---
 lldb/test/Shell/Unwind/unaligned-pc-sigbus.test | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test 
b/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
index f74ec1e858551..5ebfba54301ef 100644
--- a/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
+++ b/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
@@ -1,9 +1,14 @@
 # REQUIRES: (target-aarch64 || target-arm) && native
 # UNSUPPORTED: system-windows
+# llvm.org/pr91610, rdar://128031075
+# XFAIL: system-darwin
 
 # RUN: %clang_host %S/Inputs/unaligned-pc-sigbus.c -o %t
 # RUN: %lldb -s %s -o exit %t | FileCheck %s
 
+# Convert EXC_BAD_ACCESS into SIGBUS on darwin.
+settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS
+
 breakpoint set -n sigbus_handler
 # CHECK: Breakpoint 1: where = {{.*}}`sigbus_handler
 

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


[Lldb-commits] [lldb] [lldb/aarch64] Allow unaligned PC addresses below a trap handler (PR #92093)

2024-05-15 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,26 @@
+# REQUIRES: (target-aarch64 || target-arm) && native
+# UNSUPPORTED: system-windows
+
+# RUN: %clang_host %S/Inputs/unaligned-pc-sigbus.c -o %t
+# RUN: %lldb -s %s -o exit %t | FileCheck %s
+
+breakpoint set -n sigbus_handler
+# CHECK: Breakpoint 1: where = {{.*}}`sigbus_handler
+
+run
+# CHECK: thread #1, {{.*}} stop reason = signal SIGBUS

labath wrote:

Thanks for checking this out. I'll xfail the test and reference the rdar, and 
also the llvm bug I created earlier.

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


[Lldb-commits] [lldb] d12c48c - [lldb/aarch64] Allow unaligned PC addresses below a trap handler (#92093)

2024-05-15 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-05-15T10:02:24+02:00
New Revision: d12c48cad52798f4846dd8ef882af0f854118d16

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

LOG: [lldb/aarch64] Allow unaligned PC addresses below a trap handler (#92093)

The stack validation heuristic is counter-productive in this case, as
the unaligned address is most likely the thing that caused the signal in
the first place.

Added: 
lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c
lldb/test/Shell/Unwind/unaligned-pc-sigbus.test

Modified: 
lldb/source/Target/UnwindLLDB.cpp

Removed: 




diff  --git a/lldb/source/Target/UnwindLLDB.cpp 
b/lldb/source/Target/UnwindLLDB.cpp
index 1d8bf2f88ae67..f43e940492b09 100644
--- a/lldb/source/Target/UnwindLLDB.cpp
+++ b/lldb/source/Target/UnwindLLDB.cpp
@@ -261,7 +261,12 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) 
{
   cur_idx < 100 ? cur_idx : 100, "", cur_idx);
 return nullptr;
   }
-  if (abi && !abi->CodeAddressIsValid(cursor_sp->start_pc)) {
+
+  // Invalid code addresses should not appear on the stack *unless* we're
+  // directly below a trap handler frame (in this case, the invalid address is
+  // likely the cause of the trap).
+  if (abi && !abi->CodeAddressIsValid(cursor_sp->start_pc) &&
+  !prev_frame->reg_ctx_lldb_sp->IsTrapHandlerFrame()) {
 // If the RegisterContextUnwind has a fallback UnwindPlan, it will switch 
to
 // that and return true.  Subsequent calls to TryFallbackUnwindPlan() will
 // return false.

diff  --git a/lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c 
b/lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c
new file mode 100644
index 0..b4818de3b7fb3
--- /dev/null
+++ b/lldb/test/Shell/Unwind/Inputs/unaligned-pc-sigbus.c
@@ -0,0 +1,21 @@
+#include 
+#include 
+#include 
+
+void sigbus_handler(int signo) { _exit(47); }
+
+int target_function() { return 47; }
+
+int main() {
+  signal(SIGBUS, sigbus_handler);
+
+  // Generate a SIGBUS by deliverately calling through an unaligned function
+  // pointer.
+  union {
+int (*t)();
+uintptr_t p;
+  } u;
+  u.t = target_function;
+  u.p |= 1;
+  return u.t();
+}

diff  --git a/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test 
b/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
new file mode 100644
index 0..5ebfba54301ef
--- /dev/null
+++ b/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
@@ -0,0 +1,31 @@
+# REQUIRES: (target-aarch64 || target-arm) && native
+# UNSUPPORTED: system-windows
+# llvm.org/pr91610, rdar://128031075
+# XFAIL: system-darwin
+
+# RUN: %clang_host %S/Inputs/unaligned-pc-sigbus.c -o %t
+# RUN: %lldb -s %s -o exit %t | FileCheck %s
+
+# Convert EXC_BAD_ACCESS into SIGBUS on darwin.
+settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS
+
+breakpoint set -n sigbus_handler
+# CHECK: Breakpoint 1: where = {{.*}}`sigbus_handler
+
+run
+# CHECK: thread #1, {{.*}} stop reason = signal SIGBUS
+
+thread backtrace
+# CHECK: (lldb) thread backtrace
+# CHECK: frame #0: [[TARGET:0x[0-9a-fA-F]*]] {{.*}}`target_function
+
+continue
+# CHECK: thread #1, {{.*}} stop reason = breakpoint 1
+
+
+thread backtrace
+# CHECK: (lldb) thread backtrace
+# CHECK: frame #0: {{.*}}`sigbus_handler
+# Unknown number of signal trampoline frames
+# CHECK: frame #{{[0-9]+}}: [[TARGET]] {{.*}}`target_function
+



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


[Lldb-commits] [lldb] [lldb/aarch64] Allow unaligned PC addresses below a trap handler (PR #92093)

2024-05-15 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] f090801 - [lldb] Disable unaligned-pc-sigbus.test on arm(32)

2024-05-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2024-05-15T09:18:42Z
New Revision: f090801a9651cf4f0d05cc361a2a1b14805b62bf

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

LOG: [lldb] Disable unaligned-pc-sigbus.test on arm(32)

I though the test could work there as well, but (of course) it does not,
because the lowest bit just means "run the code as thumb".

Added: 


Modified: 
lldb/test/Shell/Unwind/unaligned-pc-sigbus.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test 
b/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
index 5ebfba54301ef..49f771cae95bf 100644
--- a/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
+++ b/lldb/test/Shell/Unwind/unaligned-pc-sigbus.test
@@ -1,4 +1,4 @@
-# REQUIRES: (target-aarch64 || target-arm) && native
+# REQUIRES: target-aarch64 && native
 # UNSUPPORTED: system-windows
 # llvm.org/pr91610, rdar://128031075
 # XFAIL: system-darwin



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


[Lldb-commits] [lldb] [lldb][Windows] Fixed tests TestPty and TestPtyServer (PR #92090)

2024-05-15 Thread Pavel Labath via lldb-commits

labath wrote:

>  @skipIfRemote is too much. These tests are still usable for Linux->Linux and 
> such.

I don't really care about this, but I'll note that while these tests will run 
in a remote configuration, they will not actually test any meaningful property 
of the remote setup. They create a local pty endpoint, connect and talk over 
it, completely ignoring the the remote connection that the general test infra 
has set up for them. In fact, I might go so far as to say that if this test 
does ever fail in a remote configuration, then that's a bug in the test, 
because it's not insulated enough from the environment.

I realize this if confusing, and that's because the API test suite is really 
two test suites jumbled into one:
- on one side we have really generic tests, which test that debugging writ 
large works, and are usable in a wide variety of configurations. To achieve 
this, the tests try to make as few assumptions about the environment as 
possible.
- on the other one, we have tests for some very specific scenarios/corner 
cases/bugs/features. Because the thing they are testing occurs only in very 
specific circumstances, these tests usually try to insulate themselves from the 
environment as much as possible. And since these things often require very 
elaborate setups, it's usually not possible or very difficult to test them 
using one of other other test suites.


We're not currently doing a good job at differentiating the two. It might be 
the best two split the test suite into two, but that would be a fairly big 
undertaking, and would involve a lot of hairsplitting, as the line is not 
always very clear.

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed tests TestPty and TestPtyServer (PR #92090)

2024-05-15 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Document some more packets (PR #92124)

2024-05-15 Thread David Spickett via lldb-commits

DavidSpickett wrote:

It's used for the `process plugin packet speed-test` command, by whom, I have 
no idea :)

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


[Lldb-commits] [lldb] b6f050f - [lldb] Document some more packets (#92124)

2024-05-15 Thread via lldb-commits

Author: David Spickett
Date: 2024-05-15T11:20:58+01:00
New Revision: b6f050fa129b08b6bc35168f0b8010742cd1ed9d

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

LOG: [lldb] Document some more packets (#92124)

Comparing a bit of the mock GDB server code to what was in the document
I found these:
* QLaunchArch
* qSpeedTest
* qSymbol

qSymbol is the most mysterious but it did have some examples in a
comment so I've adapted that.

Added: 


Modified: 
lldb/docs/resources/lldbgdbremote.md

Removed: 




diff  --git a/lldb/docs/resources/lldbgdbremote.md 
b/lldb/docs/resources/lldbgdbremote.md
index 1467723fb79dc..7076a75032dae 100644
--- a/lldb/docs/resources/lldbgdbremote.md
+++ b/lldb/docs/resources/lldbgdbremote.md
@@ -867,6 +867,22 @@ error replies.
 **Priority To Implement:** Low. Only needed if the remote target wants to
 provide strings that are human readable along with an error code.
 
+## QLaunchArch
+
+Set the architecture to use when launching a process for hosts that can run
+multiple architecture slices that are contained in a single universal program
+file.
+
+```
+send packet: $QLaunchArch:
+```
+
+The response is `OK` if the value in `` was recognised as valid
+and will be used for the next launch request. `E63` if not.
+
+**Priority To Implement:** Only required for hosts that support program files
+that contain code for multiple architectures.
+
 ## QListThreadsInStopReply
 
 Enable the `threads:` and `thread-pcs:` data in the question-mark packet
@@ -1883,6 +1899,77 @@ some platforms know, or can find out where this 
information is.
 Low if you have a debug target where all object and symbol files
 contain static load addresses.
 
+## qSpeedTest
+
+Test the maximum speed at which packets can be sent and received.
+
+```
+send packet: qSpeedTest:response_size:;
+read packet: data:
+```
+
+`` is a hex encoded unsigned number up to 64 bits in size.
+The remote will respond with `data:` followed by a block of `a` characters
+whose size should match ``, if the connection is stable.
+
+If there is an error parsing the packet, the response is `E79`.
+
+This packet is used by LLDB to discover how reliable the connection is by
+varying the amount of data requested by `` and checking whether
+the expected amount and values were received.
+
+**Priority to Implemment:** Not required for debugging on the same host, 
otherwise
+low unless you know your connection quality is variable.
+
+## qSymbol
+
+Notify the remote that LLDB is ready to do symbol lookups on behalf of the
+debug server. The response is the symbol name the debug server wants to know 
the
+value of, or `OK` if the debug server does not need to know any more symbol 
values.
+
+The exchange always begins with:
+```
+send packet: qSymbol::
+```
+
+The `::` are delimiters for fields that may be filled in future responses. 
These
+delimiters must be included even in the first packet sent.
+
+The debug server can reply one of two ways. If it doesn't need any symbol 
values:
+```
+read packet: OK
+```
+
+If it does need a symbol value, it includes the ASCII hex encoded name of the
+symbol:
+```
+read packet: qSymbol:6578616D706C65
+```
+
+This should be looked up by LLDB then sent back to the server. Include the name
+again, with the vaue as a hex number:
+```
+read packet: qSymbol:6578616D706C65:CAFEF00D
+```
+
+If LLDB cannot find the value, it should respond with only the name. Note that
+the second `:` is not included here, whereas it is in the initial packet.
+```
+read packet: qSymbol:6578616D706C65
+```
+
+If LLDB is asked for any symbols that it cannot find, it should send the
+initial `qSymbol::` again at any point where new libraries are loaded. In case
+the symbol can now be resolved.
+
+If the debug server has requested all the symbols it wants, the final response
+will be `OK` (whether they were all found or not).
+
+If LLDB did find all the symbols and recieves an `OK` it does not need to send
+`qSymbol::` again during the debug session.
+
+**Priority To Implement:** Low, this is rarely used.
+
 ## qThreadStopInfo\
 
 Get information about why a thread, whose ID is ``, is stopped.



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


[Lldb-commits] [lldb] [lldb] Document some more packets (PR #92124)

2024-05-15 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test][FreeBSD] Fix some concurrent event tests (PR #84155)

2024-05-15 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I'm going to go ahead and land this, don't hesitate to revert if there are 
still problems.

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


[Lldb-commits] [lldb] 03bdfb6 - [lldb][test][FreeBSD] Fix some concurrent event tests (#84155)

2024-05-15 Thread via lldb-commits

Author: David Spickett
Date: 2024-05-15T11:25:15+01:00
New Revision: 03bdfb65617e3cf714a106fdf7a6ae7551d17bce

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

LOG: [lldb][test][FreeBSD] Fix some concurrent event tests (#84155)

A lot of `TestConcurrent*.py` expect one of the threads to crash, but we
weren't checking for it properly.

Possibly because signal reporting got better on FreeBSD at some point,
and it now shows the same info as Linux does.

```
  lldb-api :: functionalities/inferior-changed/TestInferiorChanged.py
  lldb-api :: functionalities/inferior-crashing/TestInferiorCrashing.py
  lldb-api :: functionalities/inferior-crashing/TestInferiorCrashingStep.py
  lldb-api :: 
functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
  lldb-api :: 
functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferiorStep.py
  lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentCrashWithBreak.py
  lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentCrashWithSignal.py
  lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpoint.py
  lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpointBreakpointSignal.py
```

Fixes #48777

`TestConcurrentTwoBreakpointsOneSignal.py` no longer fails, at least on
an AWS instance, so I've removed the xfail there.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbutil.py

lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 1ec036f885e7e..02ec65170f20c 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -809,7 +809,7 @@ def is_thread_crashed(test, thread):
 thread.GetStopReason() == lldb.eStopReasonException
 and "EXC_BAD_ACCESS" in thread.GetStopDescription(100)
 )
-elif test.getPlatform() == "linux":
+elif test.getPlatform() in ["linux", "freebsd"]:
 return (
 thread.GetStopReason() == lldb.eStopReasonSignal
 and thread.GetStopReasonDataAtIndex(0)

diff  --git 
a/lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py
 
b/lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py
index c66905af9e92d..4960c4b241fb8 100644
--- 
a/lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py
+++ 
b/lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py
@@ -8,9 +8,6 @@ class ConcurrentTwoBreakpointsOneSignal(ConcurrentEventsBase):
 # Atomic sequences are not supported yet for MIPS in LLDB.
 @skipIf(triple="^mips")
 @expectedFlakeyNetBSD
-@expectedFailureAll(
-archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49433"
-)
 def test(self):
 """Test two threads that trigger a breakpoint and one signal thread."""
 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][FreeBSD] Fix some concurrent event tests (PR #84155)

2024-05-15 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the test gdb_remote_client/TestGDBRemotePlatformFile (PR #92088)

2024-05-15 Thread Pavel Labath via lldb-commits

labath wrote:

> The problem is here 
> lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp, line 
> 3235 inside GDBRemoteCommunicationClient::GetFilePermissions()
> 
> ```
> file_permissions = mode & (S_IRWXU | S_IRWXG | S_IRWXO);
> ```


Okay, so I think this is the bug. The protocol code should not be depending on 
the host definitions of the permission constants.

Would you be interested in creating a patch to change this so that it uses 
lldb's `eFilePermissions***` enums (which are the same everywhere(*)). I don't 
think it is necessarily up to you to fix this issue, but you do seem to care 
about the windows->linux configs, and this is approximately the only 
configuration in which this bug manifests itself. And it's definitely not a big 
bug, but it could cause some surprises when debugging in these setups. In case 
you do not want to make that change, I'd say that the appropriate decorator is 
`@expectedFailureAll(hostoslist=["windows"])` with a reference to this issue, 
as this is something that is supposed to work, but fails due to an lldb bug.

(*) Technically, there is no requirement that the [gdb-protocol 
values](https://github.com/llvm/llvm-project/blob/b6f050fa129b08b6bc35168f0b8010742cd1ed9d/lldb/docs/resources/lldbgdbremote.md?plain=1#L2302)
 match `lldb` public enums. Puristically, one ought to define separate 
constants for the protocol and then convert them between the two. However, the 
two definitions happen to match in this case, and both of them are part of 
stable APIs so they can't go out of sync and I think we can skip the conversion 
step.

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


[Lldb-commits] [clang] [lldb] [llvm] [openmp] [polly] fix(python): fix comparison to True/False (PR #91858)

2024-05-15 Thread Donát Nagy via lldb-commits

NagyDonat wrote:

The main problem with comparison to `True`/`False` is that it's completely 
redundant when the variable is _guaranteed to be boolean_. However, if a 
variable may contain either a boolean or something else, it's reasonable to 
compare it with `True` or `False`.

For the operator `==` there is another pitfall that according to Python `True 
== 1` and `False == 0` holds. (In ancient versions `True` and `False` were 
simply integer constants with these values; now `bool` is a subclass of `int` 
and preserves this old behavior.)

This implies that:
- When `x` is guaranteed to be a boolean, it should be used as `if x:` or `if 
not x:` (instead of `if x == True:` or `if x == False:`.
- Otherwise it may be reasonable to use the `is` operator: e.g. when `x` may be 
`True`, `False` or `None`, it is reasonable to check `if x is False:` or `if x 
is None:`.
- Using `==` has no advantage over `is` and could cause very surprising bugs 
when the variable can hold either a boolean or a number, so I'd say that it 
should be avoided. (However I admit that when `x` is known to be either `True`, 
`False` or `None`, there's a high chance that I'd instinctively write `if x == 
False:`.)

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


[Lldb-commits] [lldb] eacefba - [lldb][Windows] Fixed tests TestPty and TestPtyServer (#92090)

2024-05-15 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-15T14:44:24+04:00
New Revision: eacefba9aa3d1a5181d3d49823df24aca0d2b344

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

LOG: [lldb][Windows] Fixed tests TestPty and TestPtyServer (#92090)

The tests TestPty and TestPtyServer use the Unix specific python builtin
module termios. They are failed in case of Windows host and Linux
target. Disable them for Windows host too.

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestPty.py
lldb/test/API/tools/lldb-server/TestPtyServer.py

Removed: 




diff  --git a/lldb/test/API/functionalities/gdb_remote_client/TestPty.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestPty.py
index 4d4dd489b294a..94eeb6e3ba11a 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestPty.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestPty.py
@@ -5,7 +5,7 @@
 from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
 
 
-@skipIfWindows
+@skipIf(hostoslist=["windows"])
 class TestPty(GDBRemoteTestBase):
 server_socket_class = PtyServerSocket
 

diff  --git a/lldb/test/API/tools/lldb-server/TestPtyServer.py 
b/lldb/test/API/tools/lldb-server/TestPtyServer.py
index aa5bd635650ac..4bfcf70bfa01b 100644
--- a/lldb/test/API/tools/lldb-server/TestPtyServer.py
+++ b/lldb/test/API/tools/lldb-server/TestPtyServer.py
@@ -7,7 +7,7 @@
 import xml.etree.ElementTree as ET
 
 
-@skipIfWindows
+@skipIf(hostoslist=["windows"])
 class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 def setUp(self):
 super().setUp()



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


[Lldb-commits] [lldb] [lldb][Windows] Fixed tests TestPty and TestPtyServer (PR #92090)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Move TestBase.runCmd() to the Base class (PR #92252)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

runCmd() is called from Base.getCPUInfo() but implemented only in 
TestBase(Base). Usually it works if TestBase is used. But call getCPUInfo() 
from a class based on Base will cause something like
```
File 
"E:\projects\llvm-nino\lldb\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 1256, in getCPUInfo
  self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path)
AttributeError: 'TestGdbRemoteExpeditedRegisters' object has no attribute 
'runCmd'
```
BTW, TestBase.setUp() called runCmd() before applying LLDB_MAX_LAUNCH_COUNT and 
LLDB_TIME_WAIT_NEXT_LAUNCH.

This patch fixes the test TestGdbRemoteExpeditedRegisters in case of Windows 
host and Linux target.

>From 3df0ffbf3ff66b6ee9419adf288efc2bbdd2c949 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 15:54:25 +0400
Subject: [PATCH] [lldb] Move TestBase.runCmd() to the base class Base

runCmd() is called from Base.getCPUInfo() but implemented only in 
TestBase(Base).
Usually it works if TestBase is used. But call getCPUInfo() from a class based 
on Base will cause something like
```
File 
"E:\projects\llvm-nino\lldb\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 1256, in getCPUInfo
  self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path)
AttributeError: 'TestGdbRemoteExpeditedRegisters' object has no attribute 
'runCmd'
```
BTW, TestBase.setUp() called runCmd() before applying LLDB_MAX_LAUNCH_COUNT and 
LLDB_TIME_WAIT_NEXT_LAUNCH.

This patch fixes the test TestGdbRemoteExpeditedRegisters in case of Windows 
host and Linux target.
---
 .../Python/lldbsuite/test/lldbtest.py | 130 +-
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 5fd686c143e9f..1ad8ab6e6e462 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -531,6 +531,14 @@ class Base(unittest.TestCase):
 # Keep track of the old current working directory.
 oldcwd = None
 
+# Maximum allowed attempts when launching the inferior process.
+# Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable.
+maxLaunchCount = 1
+
+# Time to wait before the next launching attempt in second(s).
+# Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable.
+timeWaitNextLaunch = 1.0
+
 @staticmethod
 def compute_mydir(test_file):
 """Subclasses should call this function to correctly calculate the
@@ -796,6 +804,12 @@ def setUp(self):
 # import traceback
 # traceback.print_stack()
 
+if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
+self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"])
+
+if "LLDB_TIME_WAIT_NEXT_LAUNCH" in os.environ:
+self.timeWaitNextLaunch = 
float(os.environ["LLDB_TIME_WAIT_NEXT_LAUNCH"])
+
 if "LIBCXX_PATH" in os.environ:
 self.libcxxPath = os.environ["LIBCXX_PATH"]
 else:
@@ -937,6 +951,57 @@ def spawnSubprocess(self, executable, args=[], 
extra_env=None, install_remote=Tr
 self.subprocesses.append(proc)
 return proc
 
+def runCmd(self, cmd, msg=None, check=True, trace=False, inHistory=False):
+"""
+Ask the command interpreter to handle the command and then check its
+return status.
+"""
+# Fail fast if 'cmd' is not meaningful.
+if cmd is None:
+raise Exception("Bad 'cmd' parameter encountered")
+
+trace = True if traceAlways else trace
+
+if cmd.startswith("target create "):
+cmd = cmd.replace("target create ", "file ")
+
+running = cmd.startswith("run") or cmd.startswith("process launch")
+
+for i in range(self.maxLaunchCount if running else 1):
+with recording(self, trace) as sbuf:
+print("runCmd:", cmd, file=sbuf)
+if not check:
+print("check of return status not required", file=sbuf)
+
+self.ci.HandleCommand(cmd, self.res, inHistory)
+
+with recording(self, trace) as sbuf:
+if self.res.Succeeded():
+print("output:", self.res.GetOutput(), file=sbuf)
+else:
+print("runCmd failed!", file=sbuf)
+print(self.res.GetError(), file=sbuf)
+
+if self.res.Succeeded():
+break
+elif running:
+# For process launch, wait some time before possible next try.
+time.sleep(self.timeWaitNextLaunch)
+with recording(self, trace) as sbuf:
+print("Command '" + cmd + "' failed!", file=sbuf)
+
+if check:
+output = ""
+if self.res.GetOutput():
+   

[Lldb-commits] [lldb] [lldb] Move TestBase.runCmd() to the Base class (PR #92252)

2024-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

runCmd() is called from Base.getCPUInfo() but implemented only in 
TestBase(Base). Usually it works if TestBase is used. But call getCPUInfo() 
from a class based on Base will cause something like
```
File 
"E:\projects\llvm-nino\lldb\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 1256, in getCPUInfo
  self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path)
AttributeError: 'TestGdbRemoteExpeditedRegisters' object has no attribute 
'runCmd'
```
BTW, TestBase.setUp() called runCmd() before applying LLDB_MAX_LAUNCH_COUNT and 
LLDB_TIME_WAIT_NEXT_LAUNCH.

This patch fixes the test TestGdbRemoteExpeditedRegisters in case of Windows 
host and Linux target.

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


1 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+65-65) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 5fd686c143e9f..1ad8ab6e6e462 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -531,6 +531,14 @@ class Base(unittest.TestCase):
 # Keep track of the old current working directory.
 oldcwd = None
 
+# Maximum allowed attempts when launching the inferior process.
+# Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable.
+maxLaunchCount = 1
+
+# Time to wait before the next launching attempt in second(s).
+# Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable.
+timeWaitNextLaunch = 1.0
+
 @staticmethod
 def compute_mydir(test_file):
 """Subclasses should call this function to correctly calculate the
@@ -796,6 +804,12 @@ def setUp(self):
 # import traceback
 # traceback.print_stack()
 
+if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
+self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"])
+
+if "LLDB_TIME_WAIT_NEXT_LAUNCH" in os.environ:
+self.timeWaitNextLaunch = 
float(os.environ["LLDB_TIME_WAIT_NEXT_LAUNCH"])
+
 if "LIBCXX_PATH" in os.environ:
 self.libcxxPath = os.environ["LIBCXX_PATH"]
 else:
@@ -937,6 +951,57 @@ def spawnSubprocess(self, executable, args=[], 
extra_env=None, install_remote=Tr
 self.subprocesses.append(proc)
 return proc
 
+def runCmd(self, cmd, msg=None, check=True, trace=False, inHistory=False):
+"""
+Ask the command interpreter to handle the command and then check its
+return status.
+"""
+# Fail fast if 'cmd' is not meaningful.
+if cmd is None:
+raise Exception("Bad 'cmd' parameter encountered")
+
+trace = True if traceAlways else trace
+
+if cmd.startswith("target create "):
+cmd = cmd.replace("target create ", "file ")
+
+running = cmd.startswith("run") or cmd.startswith("process launch")
+
+for i in range(self.maxLaunchCount if running else 1):
+with recording(self, trace) as sbuf:
+print("runCmd:", cmd, file=sbuf)
+if not check:
+print("check of return status not required", file=sbuf)
+
+self.ci.HandleCommand(cmd, self.res, inHistory)
+
+with recording(self, trace) as sbuf:
+if self.res.Succeeded():
+print("output:", self.res.GetOutput(), file=sbuf)
+else:
+print("runCmd failed!", file=sbuf)
+print(self.res.GetError(), file=sbuf)
+
+if self.res.Succeeded():
+break
+elif running:
+# For process launch, wait some time before possible next try.
+time.sleep(self.timeWaitNextLaunch)
+with recording(self, trace) as sbuf:
+print("Command '" + cmd + "' failed!", file=sbuf)
+
+if check:
+output = ""
+if self.res.GetOutput():
+output += "\nCommand output:\n" + self.res.GetOutput()
+if self.res.GetError():
+output += "\nError output:\n" + self.res.GetError()
+if msg:
+msg += output
+if cmd:
+cmd += output
+self.assertTrue(self.res.Succeeded(), msg if (msg) else 
CMD_MSG(cmd))
+
 def HideStdout(self):
 """Hide output to stdout from the user.
 
@@ -1764,14 +1829,6 @@ class TestBase(Base, metaclass=LLDBTestCaseFactory):
 # test multiple times with various debug info types.
 NO_DEBUG_INFO_TESTCASE = False
 
-# Maximum allowed attempts when launching the inferior process.
-# Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable.
-maxLaunchCount = 1
-
-# Time to wait before the next launching attempt in second(s)

[Lldb-commits] [lldb] [lldb][Windows] Fixed the test gdb_remote_client/TestGDBRemotePlatformFile (PR #92088)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

>From 7dcfe773b6eef27aabbcc7fc68cd6448bc3c2e88 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Tue, 14 May 2024 13:08:35 +0400
Subject: [PATCH 1/3] [lldb][Windows] Fixed the test
 gdb_remote_client/TestGDBRemotePlatformFile

The tests `test_file_permissions` and `test_file_permissions_fallback` are 
disabled for Windows target. These tests use MockGDBServerResponder and do not 
depend on the real target. These tests failed in case of Windows host and Linux 
target. Disable them for Windows host too.
---
 .../gdb_remote_client/TestGDBRemotePlatformFile.py  | 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
index 2be5ae3132038..9ef0954af1fe3 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
@@ -148,6 +148,7 @@ def vFile(self, packet):
 )
 
 @skipIfWindows
+@skipIf(hostoslist=["windows"])
 def test_file_permissions(self):
 """Test 'platform get-permissions'"""
 
@@ -168,6 +169,7 @@ def vFile(self, packet):
 )
 
 @skipIfWindows
+@skipIf(hostoslist=["windows"])
 def test_file_permissions_fallback(self):
 """Test 'platform get-permissions' fallback to fstat"""
 

>From 478d251691d511916cae5fc344d549450222d584 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Tue, 14 May 2024 20:23:56 +0400
Subject: [PATCH 2/3] Removed @skipIfWindows

---
 .../gdb_remote_client/TestGDBRemotePlatformFile.py  | 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
index 9ef0954af1fe3..b1c6f0822d1a8 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
@@ -147,7 +147,6 @@ def vFile(self, packet):
 log=server2.responder.packetLog,
 )
 
-@skipIfWindows
 @skipIf(hostoslist=["windows"])
 def test_file_permissions(self):
 """Test 'platform get-permissions'"""
@@ -168,7 +167,6 @@ def vFile(self, packet):
 ]
 )
 
-@skipIfWindows
 @skipIf(hostoslist=["windows"])
 def test_file_permissions_fallback(self):
 """Test 'platform get-permissions' fallback to fstat"""

>From 4f85d2379350306d915a94e0dd67377feb049fdb Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 17:10:26 +0400
Subject: [PATCH 3/3] Replaced @skipIf with @expectedFailureAll and bugnumber

---
 .../gdb_remote_client/TestGDBRemotePlatformFile.py| 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
index b1c6f0822d1a8..c902722a2f74b 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
@@ -147,7 +147,9 @@ def vFile(self, packet):
 log=server2.responder.packetLog,
 )
 
-@skipIf(hostoslist=["windows"])
+@expectedFailureAll(
+hostoslist=["windows"], 
bugnumber="github.com/llvm/llvm-project/issues/92255"
+)
 def test_file_permissions(self):
 """Test 'platform get-permissions'"""
 
@@ -167,7 +169,9 @@ def vFile(self, packet):
 ]
 )
 
-@skipIf(hostoslist=["windows"])
+@expectedFailureAll(
+hostoslist=["windows"], 
bugnumber="github.com/llvm/llvm-project/issues/92255"
+)
 def test_file_permissions_fallback(self):
 """Test 'platform get-permissions' fallback to fstat"""
 

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the test gdb_remote_client/TestGDBRemotePlatformFile (PR #92088)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Now we are in the middle of configuring buildbot and trying to get it green. I 
have added [the issues 
92255](https://github.com/llvm/llvm-project/issues/92255). Hope we will fix it 
later. Thanks.

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the test gdb_remote_client/TestGDBRemotePlatformFile (PR #92088)

2024-05-15 Thread Pavel Labath via lldb-commits

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

Sounds good. Looking forward to it.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestGdbRemoteCompletion test (PR #92268)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

Do not try to run lldb-server on localhost in case of the remote target.

>From 1b200d1844d0241459fdc11064dc6b61a963e62f Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 18:29:17 +0400
Subject: [PATCH] [lldb] Fixed the TestGdbRemoteCompletion test

Do not try to run lldb-server on localhost in case of the remote target.
---
 lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
index 04d6abe9d88c1..58373d2f85bb9 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
@@ -26,6 +26,7 @@ def init_lldb_server(self):
 def generate_hex_path(self, target):
 return str(os.path.join(self.getBuildDir(), target)).encode().hex()
 
+@skipIfRemote
 @add_test_categories(["llgs"])
 def test_autocomplete_path(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] Fixed the TestGdbRemoteCompletion test (PR #92268)

2024-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

Do not try to run lldb-server on localhost in case of the remote target.

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


1 Files Affected:

- (modified) lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py (+1) 


``diff
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
index 04d6abe9d88c1..58373d2f85bb9 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
@@ -26,6 +26,7 @@ def init_lldb_server(self):
 def generate_hex_path(self, target):
 return str(os.path.join(self.getBuildDir(), target)).encode().hex()
 
+@skipIfRemote
 @add_test_categories(["llgs"])
 def test_autocomplete_path(self):
 self.build()

``




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


[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)

2024-05-15 Thread Pavel Labath via lldb-commits

labath wrote:

Thanks for checking this out. I'll try to whip something up tomorrow.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestFdLeak test (PR #92273)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

Use `NUL` instead of `/dev/null` in case of the Windows host.

>From 6341c038d41ac3b533314568187b8d5d390dc861 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 18:38:16 +0400
Subject: [PATCH] [lldb] Fixed the TestFdLeak test

Use `NUL` instead of `/dev/null` in case of the Windows host.
---
 lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py 
b/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
index e4f5cd3a03f86..e292885ec390d 100644
--- a/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
+++ b/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
@@ -26,7 +26,10 @@ def test_fd_leak_basic(self):
 @skipIfTargetAndroid()  # Android have some other file descriptors open by 
the shell
 @skipIfDarwinEmbedded  #   # debugserver on ios 
has an extra fd open on launch
 def test_fd_leak_log(self):
-self.do_test(["log enable -f '/dev/null' lldb commands"])
+if lldbplatformutil.getHostPlatform() == "windows":
+self.do_test(["log enable -f 'NUL' lldb commands"])
+else:
+self.do_test(["log enable -f '/dev/null' lldb commands"])
 
 def do_test(self, commands):
 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] Fixed the TestFdLeak test (PR #92273)

2024-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

Use `NUL` instead of `/dev/null` in case of the Windows host.

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py (+4-1) 


``diff
diff --git a/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py 
b/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
index e4f5cd3a03f86..e292885ec390d 100644
--- a/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
+++ b/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
@@ -26,7 +26,10 @@ def test_fd_leak_basic(self):
 @skipIfTargetAndroid()  # Android have some other file descriptors open by 
the shell
 @skipIfDarwinEmbedded  #   # debugserver on ios 
has an extra fd open on launch
 def test_fd_leak_log(self):
-self.do_test(["log enable -f '/dev/null' lldb commands"])
+if lldbplatformutil.getHostPlatform() == "windows":
+self.do_test(["log enable -f 'NUL' lldb commands"])
+else:
+self.do_test(["log enable -f '/dev/null' lldb commands"])
 
 def do_test(self, commands):
 self.build()

``




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


[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test running on a remote target (PR #92281)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

Install the image to the remote target if necessary. Platform::LoadImage() uses 
the following logic before DoLoadImage()
```
if (IsRemote() || local_file != remote_file) {
  error = Install(local_file, remote_file);
  ...
}
```
The FileSpec for the local path may be resolved, so it is necessary to use the 
condition `if lldb.remote_platform:`.

>From f2badfe871dc3d17d4053be1c25f9abdf8d10a0c Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 19:21:25 +0400
Subject: [PATCH] [lldb] Fixed the TestCompletion test running on a remote
 target

Install the image to the remote target if necessary. Platform::LoadImage() uses 
the following logic before DoLoadImage()
```
if (IsRemote() || local_file != remote_file) {
  error = Install(local_file, remote_file);
  ...
}
```
The FileSpec for the local path may be resolved, so it is necessary to use the 
condition `if lldb.remote_platform:`.
---
 .../completion/TestCompletion.py| 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 0d6907e0c3d22..9959c7363aa2b 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -107,9 +107,20 @@ def test_process_unload(self):
 self, "// Break here", lldb.SBFileSpec("main.cpp")
 )
 err = lldb.SBError()
-self.process().LoadImage(
-lldb.SBFileSpec(self.getBuildArtifact("libshared.so")), err
-)
+if lldb.remote_platform:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+lldb.SBFileSpec(
+lldbutil.append_to_process_working_directory(self, 
"libshared.so"),
+False,
+),
+err,
+)
+else:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+err,
+)
 self.assertSuccess(err)
 
 self.complete_from_to("process unload ", "process unload 0")

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


[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test running on a remote target (PR #92281)

2024-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

Install the image to the remote target if necessary. Platform::LoadImage() uses 
the following logic before DoLoadImage()
```
if (IsRemote() || local_file != remote_file) {
  error = Install(local_file, remote_file);
  ...
}
```
The FileSpec for the local path may be resolved, so it is necessary to use the 
condition `if lldb.remote_platform:`.

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/completion/TestCompletion.py (+14-3) 


``diff
diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 0d6907e0c3d22..9959c7363aa2b 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -107,9 +107,20 @@ def test_process_unload(self):
 self, "// Break here", lldb.SBFileSpec("main.cpp")
 )
 err = lldb.SBError()
-self.process().LoadImage(
-lldb.SBFileSpec(self.getBuildArtifact("libshared.so")), err
-)
+if lldb.remote_platform:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+lldb.SBFileSpec(
+lldbutil.append_to_process_working_directory(self, 
"libshared.so"),
+False,
+),
+err,
+)
+else:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+err,
+)
 self.assertSuccess(err)
 
 self.complete_from_to("process unload ", "process unload 0")

``




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


[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

TestNetBSDCore.py contains 3 classes with the same test names test_aarch64 and 
test_amd64. It causes conflicts because the same build dir. Add suffixes to 
avoid conflicts.

The error message on the Windows host running with `-j 2` is the following:
```
PermissionError: [WinError 32] The process cannot access the file because it is 
being used by another process:
'E:\\projects\\lldb\\build-lldb\\lldb-test-build.noindex\\functionalities\\postmortem\\netbsd-core\\TestNetBSDCore.test_aarch64\\Incomplete.log'
```

>From cd181f2b87008ae86c4195a74e9405b8a6e78da2 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 19:39:05 +0400
Subject: [PATCH] [lldb] Fixed the TestNetBSDCore test

TestNetBSDCore.py contains 3 classes with the same test names test_aarch64 and 
test_amd64. It causes conflicts because the same build dir. Add suffixes to 
avoid conflicts.

The error message on the Windows host running with `-j 2` is the following:
```
PermissionError: [WinError 32] The process cannot access the file because it is 
being used by another process: 
'E:\\projects\\lldb\\build-lldb\\lldb-test-build.noindex\\functionalities\\postmortem\\netbsd-core\\TestNetBSDCore.test_aarch64\\Incomplete.log'
```
---
 .../postmortem/netbsd-core/TestNetBSDCore.py | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py 
b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
index 756f4d1e81caa..d56b38eb513e9 100644
--- a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
+++ b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
@@ -147,12 +147,12 @@ def check_stack(self, process, pid, filename):
 self.check_backtrace(thread, filename, backtrace)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_A(self):
 """Test single-threaded aarch64 core dump."""
 self.do_test("1lwp_SIGSEGV.aarch64", pid=8339, region_count=32)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_A(self):
 """Test single-threaded amd64 core dump."""
 self.do_test("1lwp_SIGSEGV.amd64", pid=693, region_count=21)
 
@@ -177,12 +177,12 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_B(self):
 """Test double-threaded aarch64 core dump where thread 2 is 
signalled."""
 self.do_test("2lwp_t2_SIGSEGV.aarch64", pid=14142, region_count=31)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_B(self):
 """Test double-threaded amd64 core dump where thread 2 is signalled."""
 self.do_test("2lwp_t2_SIGSEGV.amd64", pid=622, region_count=24)
 
@@ -207,11 +207,11 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_C(self):
 """Test double-threaded aarch64 core dump where process is 
signalled."""
 self.do_test("2lwp_process_SIGSEGV.aarch64", pid=1403, region_count=30)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_C(self):
 """Test double-threaded amd64 core dump where process is signalled."""
 self.do_test("2lwp_process_SIGSEGV.amd64", pid=665, region_count=24)

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


[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

TestNetBSDCore.py contains 3 classes with the same test names test_aarch64 and 
test_amd64. It causes conflicts because the same build dir. Add suffixes to 
avoid conflicts.

The error message on the Windows host running with `-j 2` is the following:
```
PermissionError: [WinError 32] The process cannot access the file because it is 
being used by another process:
'E:\\projects\\lldb\\build-lldb\\lldb-test-build.noindex\\functionalities\\postmortem\\netbsd-core\\TestNetBSDCore.test_aarch64\\Incomplete.log'
```

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


1 Files Affected:

- (modified) 
lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py (+6-6) 


``diff
diff --git 
a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py 
b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
index 756f4d1e81caa..d56b38eb513e9 100644
--- a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
+++ b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
@@ -147,12 +147,12 @@ def check_stack(self, process, pid, filename):
 self.check_backtrace(thread, filename, backtrace)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_A(self):
 """Test single-threaded aarch64 core dump."""
 self.do_test("1lwp_SIGSEGV.aarch64", pid=8339, region_count=32)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_A(self):
 """Test single-threaded amd64 core dump."""
 self.do_test("1lwp_SIGSEGV.amd64", pid=693, region_count=21)
 
@@ -177,12 +177,12 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_B(self):
 """Test double-threaded aarch64 core dump where thread 2 is 
signalled."""
 self.do_test("2lwp_t2_SIGSEGV.aarch64", pid=14142, region_count=31)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_B(self):
 """Test double-threaded amd64 core dump where thread 2 is signalled."""
 self.do_test("2lwp_t2_SIGSEGV.amd64", pid=622, region_count=24)
 
@@ -207,11 +207,11 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_C(self):
 """Test double-threaded aarch64 core dump where process is 
signalled."""
 self.do_test("2lwp_process_SIGSEGV.aarch64", pid=1403, region_count=30)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_C(self):
 """Test double-threaded amd64 core dump where process is signalled."""
 self.do_test("2lwp_process_SIGSEGV.amd64", pid=665, region_count=24)

``




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


[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test running on a remote target (PR #92281)

2024-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -107,9 +107,20 @@ def test_process_unload(self):
 self, "// Break here", lldb.SBFileSpec("main.cpp")
 )
 err = lldb.SBError()
-self.process().LoadImage(
-lldb.SBFileSpec(self.getBuildArtifact("libshared.so")), err
-)
+if lldb.remote_platform:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+lldb.SBFileSpec(
+lldbutil.append_to_process_working_directory(self, 
"libshared.so"),
+False,
+),
+err,
+)
+else:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+err,
+)

JDevlieghere wrote:

I think this can be simplified to:

```
err = lldb.SBError()
local_spec = lldb.SBFileSpec(self.getBuildArtifact("libshared.so"))
remote_spec = 
lldb.SBFileSpec(lldbutil.append_to_process_working_directory(self, 
"libshared.so"), false) if lldb.remote_platform else lldb.SBFileSpec()
self.process().LoadImage(local_spec, remote_spec)
```

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the TestIOHandlerResizeNoEditline test (PR #92286)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

This test caused python crash on Windows x86_64 host with the exit code 
0xC409 (STATUS_STACK_BUFFER_OVERRUN). Close the input stream before exit to 
avoid this crash.

>From b6d9b129dc92eea0bd7347ea6ae2a305178dbd46 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 19:47:48 +0400
Subject: [PATCH] [lldb][Windows] Fixed the TestIOHandlerResizeNoEditline test

This test caused python crash on Windows x86_64 host with the exit code 
0xC409 (STATUS_STACK_BUFFER_OVERRUN).
Close the input stream before exit to avoid this crash.
---
 lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py 
b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
index 3c07554f6cafd..bbc2dcbe4e30a 100644
--- a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
+++ b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
@@ -18,3 +18,4 @@ def test_resize_no_editline(self):
 dbg.RunCommandInterpreter(True, True, opts, 0, False, False)
 # Try resizing the terminal which shouldn't crash.
 dbg.SetTerminalWidth(47)
+dbg.GetInputFile().Close()

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the TestIOHandlerResizeNoEditline test (PR #92286)

2024-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

This test caused python crash on Windows x86_64 host with the exit code 
0xC409 (STATUS_STACK_BUFFER_OVERRUN). Close the input stream before exit to 
avoid this crash.

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


1 Files Affected:

- (modified) lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py 
(+1) 


``diff
diff --git a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py 
b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
index 3c07554f6cafd..bbc2dcbe4e30a 100644
--- a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
+++ b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
@@ -18,3 +18,4 @@ def test_resize_no_editline(self):
 dbg.RunCommandInterpreter(True, True, opts, 0, False, False)
 # Try resizing the terminal which shouldn't crash.
 dbg.SetTerminalWidth(47)
+dbg.GetInputFile().Close()

``




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


[Lldb-commits] [lldb] [lldb] Fixed the TestFdLeak test (PR #92273)

2024-05-15 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

Could this use `os.devnull` to pick the right one based on the platform this is 
running on?
```
self.do_test(["log enable -f '{}}' lldb commands".format(os.devnull)])
```

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


[Lldb-commits] [lldb] [lldb] Fixed the TestGdbRemoteCompletion test (PR #92268)

2024-05-15 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-15 Thread Fred Grim via lldb-commits

https://github.com/feg208 updated 
https://github.com/llvm/llvm-project/pull/91544

>From b35ded1c20bb67df941bb7c54aece789a18cde99 Mon Sep 17 00:00:00 2001
From: Fred Grim 
Date: Wed, 8 May 2024 15:36:16 -0700
Subject: [PATCH] [lldb] Adds additional fields to ProcessInfo

To implement SaveCore for elf binaries we need to populate some
additional fields in the prpsinfo struct. Those fields are the nice
value of the process whose core is to be taken as well as a boolean
flag indicating whether or not that process is a zombie. This commit
adds those as well as tests to ensure that the values are consistent
with expectations
---
 lldb/include/lldb/Utility/ProcessInfo.h | 64 -
 lldb/source/Host/linux/Host.cpp | 32 +
 lldb/source/Utility/ProcessInfo.cpp | 11 +++--
 lldb/unittests/Host/linux/HostTest.cpp  | 21 
 4 files changed, 94 insertions(+), 34 deletions(-)

diff --git a/lldb/include/lldb/Utility/ProcessInfo.h 
b/lldb/include/lldb/Utility/ProcessInfo.h
index 54ac000dc7fc2..363a81d4e874f 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -15,6 +15,7 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/NameMatches.h"
 #include "lldb/Utility/StructuredData.h"
+#include 
 #include 
 
 namespace lldb_private {
@@ -147,8 +148,7 @@ class ProcessInstanceInfo : public ProcessInfo {
   ProcessInstanceInfo() = default;
 
   ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid)
-  : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX),
-m_parent_pid(LLDB_INVALID_PROCESS_ID) {}
+  : ProcessInfo(name, arch, pid) {}
 
   void Clear() {
 ProcessInfo::Clear();
@@ -173,19 +173,17 @@ class ProcessInstanceInfo : public ProcessInfo {
 
   void SetParentProcessID(lldb::pid_t pid) { m_parent_pid = pid; }
 
-  bool ParentProcessIDIsValid() const {
-return m_parent_pid != LLDB_INVALID_PROCESS_ID;
-  }
+  bool ParentProcessIDIsValid() const { return m_parent_pid != 
LLDB_INVALID_PROCESS_ID; }
 
   lldb::pid_t GetProcessGroupID() const { return m_process_group_id; }
 
   void SetProcessGroupID(lldb::pid_t pgrp) { m_process_group_id = pgrp; }
 
-  bool ProcessGroupIDIsValid() const {
-return m_process_group_id != LLDB_INVALID_PROCESS_ID;
-  }
+  bool ProcessGroupIDIsValid() const { return m_process_group_id != 
LLDB_INVALID_PROCESS_ID; }
 
-  lldb::pid_t GetProcessSessionID() const { return m_process_session_id; }
+  lldb::pid_t GetProcessSessionID() const {
+return m_process_session_id;
+  }
 
   void SetProcessSessionID(lldb::pid_t session) {
 m_process_session_id = session;
@@ -195,24 +193,26 @@ class ProcessInstanceInfo : public ProcessInfo {
 return m_process_session_id != LLDB_INVALID_PROCESS_ID;
   }
 
-  struct timespec GetUserTime() const { return m_user_time; }
+  struct timespec GetUserTime() const { return m_user_time.value(); }
 
   void SetUserTime(struct timespec utime) { m_user_time = utime; }
 
   bool UserTimeIsValid() const {
-return m_user_time.tv_sec > 0 || m_user_time.tv_usec > 0;
+return m_user_time.has_value() &&
+   (m_user_time->tv_sec > 0 || m_user_time->tv_usec > 0);
   }
 
-  struct timespec GetSystemTime() const { return m_system_time; }
+  struct timespec GetSystemTime() const { return m_system_time.value(); }
 
   void SetSystemTime(struct timespec stime) { m_system_time = stime; }
 
   bool SystemTimeIsValid() const {
-return m_system_time.tv_sec > 0 || m_system_time.tv_usec > 0;
+return m_system_time.has_value() &&
+   (m_system_time->tv_sec > 0 || m_system_time->tv_usec > 0);
   }
 
   struct timespec GetCumulativeUserTime() const {
-return m_cumulative_user_time;
+return m_cumulative_user_time.value();
   }
 
   void SetCumulativeUserTime(struct timespec cutime) {
@@ -220,12 +220,13 @@ class ProcessInstanceInfo : public ProcessInfo {
   }
 
   bool CumulativeUserTimeIsValid() const {
-return m_cumulative_user_time.tv_sec > 0 ||
-   m_cumulative_user_time.tv_usec > 0;
+return m_cumulative_user_time.has_value() &&
+   (m_cumulative_user_time->tv_sec > 0 ||
+m_cumulative_user_time->tv_usec > 0);
   }
 
   struct timespec GetCumulativeSystemTime() const {
-return m_cumulative_system_time;
+return m_cumulative_system_time.value();
   }
 
   void SetCumulativeSystemTime(struct timespec cstime) {
@@ -233,10 +234,25 @@ class ProcessInstanceInfo : public ProcessInfo {
   }
 
   bool CumulativeSystemTimeIsValid() const {
-return m_cumulative_system_time.tv_sec > 0 ||
-   m_cumulative_system_time.tv_usec > 0;
+return m_cumulative_system_time.has_value() &&
+   (m_cumulative_system_time->tv_sec > 0 ||
+m_cumulative_system_time->tv_usec > 0);
+  }
+
+  int8_t GetPriorityValue() const { return m_priority_value.value(); }
+
+  void SetPriorityValue(int8_t priority_value) {
+m_priority_value = priorit

[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-15 Thread Fred Grim via lldb-commits


@@ -147,96 +148,111 @@ class ProcessInstanceInfo : public ProcessInfo {
   ProcessInstanceInfo() = default;
 
   ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid)
-  : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX),
-m_parent_pid(LLDB_INVALID_PROCESS_ID) {}
+  : ProcessInfo(name, arch, pid) {}
 
   void Clear() {
 ProcessInfo::Clear();
-m_euid = UINT32_MAX;
-m_egid = UINT32_MAX;
-m_parent_pid = LLDB_INVALID_PROCESS_ID;
+m_euid = std::nullopt;
+m_egid = std::nullopt;
+m_parent_pid = std::nullopt;
   }
 
-  uint32_t GetEffectiveUserID() const { return m_euid; }
+  uint32_t GetEffectiveUserID() const { return m_euid.value(); }

feg208 wrote:

@clayborg I made the changes referenced above (i.e. backed out the optionals 
for the pid/uid/gid fields). Is this a dealbreaker for you? Or do you think we 
can revisit at a later time?

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


[Lldb-commits] [lldb] [lldb] Adds additional fields to ProcessInfo (PR #91544)

2024-05-15 Thread Fred Grim via lldb-commits

https://github.com/feg208 updated 
https://github.com/llvm/llvm-project/pull/91544

>From 8b9ffe9bfb20c5c911c1c08ef966b4ac1ac587a0 Mon Sep 17 00:00:00 2001
From: Fred Grim 
Date: Wed, 8 May 2024 15:36:16 -0700
Subject: [PATCH] [lldb] Adds additional fields to ProcessInfo

To implement SaveCore for elf binaries we need to populate some
additional fields in the prpsinfo struct. Those fields are the nice
value of the process whose core is to be taken as well as a boolean
flag indicating whether or not that process is a zombie. This commit
adds those as well as tests to ensure that the values are consistent
with expectations
---
 lldb/include/lldb/Utility/ProcessInfo.h | 52 +
 lldb/source/Host/linux/Host.cpp | 32 +++
 lldb/source/Utility/ProcessInfo.cpp | 11 --
 lldb/unittests/Host/linux/HostTest.cpp  | 21 ++
 4 files changed, 89 insertions(+), 27 deletions(-)

diff --git a/lldb/include/lldb/Utility/ProcessInfo.h 
b/lldb/include/lldb/Utility/ProcessInfo.h
index 54ac000dc7fc2..6844211f05c74 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -15,6 +15,7 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/NameMatches.h"
 #include "lldb/Utility/StructuredData.h"
+#include 
 #include 
 
 namespace lldb_private {
@@ -147,8 +148,7 @@ class ProcessInstanceInfo : public ProcessInfo {
   ProcessInstanceInfo() = default;
 
   ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid)
-  : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX),
-m_parent_pid(LLDB_INVALID_PROCESS_ID) {}
+  : ProcessInfo(name, arch, pid) {}
 
   void Clear() {
 ProcessInfo::Clear();
@@ -195,24 +195,26 @@ class ProcessInstanceInfo : public ProcessInfo {
 return m_process_session_id != LLDB_INVALID_PROCESS_ID;
   }
 
-  struct timespec GetUserTime() const { return m_user_time; }
+  struct timespec GetUserTime() const { return m_user_time.value(); }
 
   void SetUserTime(struct timespec utime) { m_user_time = utime; }
 
   bool UserTimeIsValid() const {
-return m_user_time.tv_sec > 0 || m_user_time.tv_usec > 0;
+return m_user_time.has_value() &&
+   (m_user_time->tv_sec > 0 || m_user_time->tv_usec > 0);
   }
 
-  struct timespec GetSystemTime() const { return m_system_time; }
+  struct timespec GetSystemTime() const { return m_system_time.value(); }
 
   void SetSystemTime(struct timespec stime) { m_system_time = stime; }
 
   bool SystemTimeIsValid() const {
-return m_system_time.tv_sec > 0 || m_system_time.tv_usec > 0;
+return m_system_time.has_value() &&
+   (m_system_time->tv_sec > 0 || m_system_time->tv_usec > 0);
   }
 
   struct timespec GetCumulativeUserTime() const {
-return m_cumulative_user_time;
+return m_cumulative_user_time.value();
   }
 
   void SetCumulativeUserTime(struct timespec cutime) {
@@ -220,12 +222,13 @@ class ProcessInstanceInfo : public ProcessInfo {
   }
 
   bool CumulativeUserTimeIsValid() const {
-return m_cumulative_user_time.tv_sec > 0 ||
-   m_cumulative_user_time.tv_usec > 0;
+return m_cumulative_user_time.has_value() &&
+   (m_cumulative_user_time->tv_sec > 0 ||
+m_cumulative_user_time->tv_usec > 0);
   }
 
   struct timespec GetCumulativeSystemTime() const {
-return m_cumulative_system_time;
+return m_cumulative_system_time.value();
   }
 
   void SetCumulativeSystemTime(struct timespec cstime) {
@@ -233,10 +236,25 @@ class ProcessInstanceInfo : public ProcessInfo {
   }
 
   bool CumulativeSystemTimeIsValid() const {
-return m_cumulative_system_time.tv_sec > 0 ||
-   m_cumulative_system_time.tv_usec > 0;
+return m_cumulative_system_time.has_value() &&
+   (m_cumulative_system_time->tv_sec > 0 ||
+m_cumulative_system_time->tv_usec > 0);
   }
 
+  int8_t GetPriorityValue() const { return m_priority_value.value(); }
+
+  void SetPriorityValue(int8_t priority_value) {
+m_priority_value = priority_value;
+  }
+
+  bool PriorityValueIsValid() const;
+
+  void SetIsZombie(bool is_zombie) { m_zombie = is_zombie; }
+
+  bool IsZombieValid() const { return m_zombie.has_value(); }
+
+  bool IsZombie() const { return m_zombie.value(); }
+
   void Dump(Stream &s, UserIDResolver &resolver) const;
 
   static void DumpTableHeader(Stream &s, bool show_args, bool verbose);
@@ -250,10 +268,12 @@ class ProcessInstanceInfo : public ProcessInfo {
   lldb::pid_t m_parent_pid = LLDB_INVALID_PROCESS_ID;
   lldb::pid_t m_process_group_id = LLDB_INVALID_PROCESS_ID;
   lldb::pid_t m_process_session_id = LLDB_INVALID_PROCESS_ID;
-  struct timespec m_user_time {};
-  struct timespec m_system_time {};
-  struct timespec m_cumulative_user_time {};
-  struct timespec m_cumulative_system_time {};
+  std::optional m_user_time = std::nullopt;
+  std::optional m_system_time = std::nullopt;
+  std::optional m_cumulative_user_time = std::nullopt

[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test running on a remote target (PR #92281)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

>From f2badfe871dc3d17d4053be1c25f9abdf8d10a0c Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 19:21:25 +0400
Subject: [PATCH 1/2] [lldb] Fixed the TestCompletion test running on a remote
 target

Install the image to the remote target if necessary. Platform::LoadImage() uses 
the following logic before DoLoadImage()
```
if (IsRemote() || local_file != remote_file) {
  error = Install(local_file, remote_file);
  ...
}
```
The FileSpec for the local path may be resolved, so it is necessary to use the 
condition `if lldb.remote_platform:`.
---
 .../completion/TestCompletion.py| 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 0d6907e0c3d22..9959c7363aa2b 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -107,9 +107,20 @@ def test_process_unload(self):
 self, "// Break here", lldb.SBFileSpec("main.cpp")
 )
 err = lldb.SBError()
-self.process().LoadImage(
-lldb.SBFileSpec(self.getBuildArtifact("libshared.so")), err
-)
+if lldb.remote_platform:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+lldb.SBFileSpec(
+lldbutil.append_to_process_working_directory(self, 
"libshared.so"),
+False,
+),
+err,
+)
+else:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+err,
+)
 self.assertSuccess(err)
 
 self.complete_from_to("process unload ", "process unload 0")

>From 3661437dd9df68210b5f92b03ac53abc65922189 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 20:43:42 +0400
Subject: [PATCH 2/2] Optimized.

---
 .../completion/TestCompletion.py  | 24 ---
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 9959c7363aa2b..63842487fc338 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -107,20 +107,16 @@ def test_process_unload(self):
 self, "// Break here", lldb.SBFileSpec("main.cpp")
 )
 err = lldb.SBError()
-if lldb.remote_platform:
-self.process().LoadImage(
-lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
-lldb.SBFileSpec(
-lldbutil.append_to_process_working_directory(self, 
"libshared.so"),
-False,
-),
-err,
-)
-else:
-self.process().LoadImage(
-lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
-err,
+local_spec = lldb.SBFileSpec(self.getBuildArtifact("libshared.so"))
+remote_spec = (
+lldb.SBFileSpec(
+lldbutil.append_to_process_working_directory(self, 
"libshared.so"),
+False,
 )
+if lldb.remote_platform
+else lldb.SBFileSpec()
+)
+self.process().LoadImage(local_spec, remote_spec, err)
 self.assertSuccess(err)
 
 self.complete_from_to("process unload ", "process unload 0")
@@ -484,7 +480,7 @@ def test_custom_command_completion(self):
 self.complete_from_to("my_test_cmd main.cp", ["main.cpp"])
 self.expect("my_test_cmd main.cpp", substrs=["main.cpp"])
 
-@skipIfWindows
+@skipIf(hostoslist=["windows"])
 def test_completion_target_create_from_root_dir(self):
 """Tests source file completion by completing ."""
 root_dir = os.path.abspath(os.sep)

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


[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -207,11 +207,11 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_C(self):

JDevlieghere wrote:

`test_aarch64_process_signaled`? 

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


[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -147,12 +147,12 @@ def check_stack(self, process, pid, filename):
 self.check_backtrace(thread, filename, backtrace)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_A(self):

JDevlieghere wrote:

Can we give this a more meaningful name, like `test_aarch64_single` or 
`test_aarch64_single_threaded`? Or maybe keep these and only rename the ones 
below. 

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


[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread Jonas Devlieghere via lldb-commits


@@ -177,12 +177,12 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_B(self):

JDevlieghere wrote:

`test_aarch64_thread_signaled`?

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


[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test running on a remote target (PR #92281)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits


@@ -107,9 +107,20 @@ def test_process_unload(self):
 self, "// Break here", lldb.SBFileSpec("main.cpp")
 )
 err = lldb.SBError()
-self.process().LoadImage(
-lldb.SBFileSpec(self.getBuildArtifact("libshared.so")), err
-)
+if lldb.remote_platform:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+lldb.SBFileSpec(
+lldbutil.append_to_process_working_directory(self, 
"libshared.so"),
+False,
+),
+err,
+)
+else:
+self.process().LoadImage(
+lldb.SBFileSpec(self.getBuildArtifact("libshared.so")),
+err,
+)

slydiman wrote:

I have updated the patch. Thanks.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test running on a remote target (PR #92281)

2024-05-15 Thread Jonas Devlieghere via lldb-commits

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

Thanks. LGTM!

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the TestIOHandlerResizeNoEditline test (PR #92286)

2024-05-15 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] 34f33ba - [lldb] Fixed the TestGdbRemoteCompletion test (#92268)

2024-05-15 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-15T20:48:16+04:00
New Revision: 34f33babc28d240d4ceee69f9afe7d6f5e8ac29b

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

LOG: [lldb] Fixed the TestGdbRemoteCompletion test (#92268)

Do not try to run lldb-server on localhost in case of the remote target.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
index 04d6abe9d88c1..58373d2f85bb9 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
@@ -26,6 +26,7 @@ def init_lldb_server(self):
 def generate_hex_path(self, target):
 return str(os.path.join(self.getBuildDir(), target)).encode().hex()
 
+@skipIfRemote
 @add_test_categories(["llgs"])
 def test_autocomplete_path(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] Fixed the TestGdbRemoteCompletion test (PR #92268)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] fc1df55 - [lldb][Windows] Fixed the test gdb_remote_client/TestGDBRemotePlatformFile (#92088)

2024-05-15 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-15T20:50:58+04:00
New Revision: fc1df55bcf9b6cc2dec157bcd188b471bc91b945

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

LOG: [lldb][Windows] Fixed the test gdb_remote_client/TestGDBRemotePlatformFile 
(#92088)

The tests `test_file_permissions` and `test_file_permissions_fallback`
are disabled for Windows target. These tests use MockGDBServerResponder
and do not depend on the real target. These tests failed in case of
Windows host and Linux target. Disable them for Windows host too.

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
index 2be5ae3132038..c902722a2f74b 100644
--- 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
@@ -147,7 +147,9 @@ def vFile(self, packet):
 log=server2.responder.packetLog,
 )
 
-@skipIfWindows
+@expectedFailureAll(
+hostoslist=["windows"], 
bugnumber="github.com/llvm/llvm-project/issues/92255"
+)
 def test_file_permissions(self):
 """Test 'platform get-permissions'"""
 
@@ -167,7 +169,9 @@ def vFile(self, packet):
 ]
 )
 
-@skipIfWindows
+@expectedFailureAll(
+hostoslist=["windows"], 
bugnumber="github.com/llvm/llvm-project/issues/92255"
+)
 def test_file_permissions_fallback(self):
 """Test 'platform get-permissions' fallback to fstat"""
 



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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the test gdb_remote_client/TestGDBRemotePlatformFile (PR #92088)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

>From cd181f2b87008ae86c4195a74e9405b8a6e78da2 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 19:39:05 +0400
Subject: [PATCH 1/2] [lldb] Fixed the TestNetBSDCore test

TestNetBSDCore.py contains 3 classes with the same test names test_aarch64 and 
test_amd64. It causes conflicts because the same build dir. Add suffixes to 
avoid conflicts.

The error message on the Windows host running with `-j 2` is the following:
```
PermissionError: [WinError 32] The process cannot access the file because it is 
being used by another process: 
'E:\\projects\\lldb\\build-lldb\\lldb-test-build.noindex\\functionalities\\postmortem\\netbsd-core\\TestNetBSDCore.test_aarch64\\Incomplete.log'
```
---
 .../postmortem/netbsd-core/TestNetBSDCore.py | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py 
b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
index 756f4d1e81caa..d56b38eb513e9 100644
--- a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
+++ b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
@@ -147,12 +147,12 @@ def check_stack(self, process, pid, filename):
 self.check_backtrace(thread, filename, backtrace)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_A(self):
 """Test single-threaded aarch64 core dump."""
 self.do_test("1lwp_SIGSEGV.aarch64", pid=8339, region_count=32)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_A(self):
 """Test single-threaded amd64 core dump."""
 self.do_test("1lwp_SIGSEGV.amd64", pid=693, region_count=21)
 
@@ -177,12 +177,12 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_B(self):
 """Test double-threaded aarch64 core dump where thread 2 is 
signalled."""
 self.do_test("2lwp_t2_SIGSEGV.aarch64", pid=14142, region_count=31)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_B(self):
 """Test double-threaded amd64 core dump where thread 2 is signalled."""
 self.do_test("2lwp_t2_SIGSEGV.amd64", pid=622, region_count=24)
 
@@ -207,11 +207,11 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_C(self):
 """Test double-threaded aarch64 core dump where process is 
signalled."""
 self.do_test("2lwp_process_SIGSEGV.aarch64", pid=1403, region_count=30)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_C(self):
 """Test double-threaded amd64 core dump where process is signalled."""
 self.do_test("2lwp_process_SIGSEGV.amd64", pid=665, region_count=24)

>From 9032144a256cf8ba2838e935dfc3fc79fddff9ce Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 21:00:30 +0400
Subject: [PATCH 2/2] Renamed to more meaningful names.

---
 .../postmortem/netbsd-core/TestNetBSDCore.py | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py 
b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
index d56b38eb513e9..ff1ef21e02e31 100644
--- a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
+++ b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
@@ -147,12 +147,12 @@ def check_stack(self, process, pid, filename):
 self.check_backtrace(thread, filename, backtrace)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64_A(self):
+def test_aarch64_single_threaded(self):
 """Test single-threaded aarch64 core dump."""
 self.do_test("1lwp_SIGSEGV.aarch64", pid=8339, region_count=32)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64_A(self):
+def test_amd64_single_threaded(self):
 """Test single-threaded amd64 core dump."""
 self.do_test("1lwp_SIGSEGV.amd64", pid=693, region_count=21)
 
@@ -177,12 +177,12 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64_B(self):
+def test_aarch64_thread_signaled(self):
 """Test double-threaded aarch64 core dump where thread 2 is 
signalled."""
 self.do_test("2lwp_t2_SIGSEGV.aarch64", pid=14142, region_count=31)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64_B(self):
+def test_amd64_thread_signaled(self):
 """Test dou

[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits


@@ -147,12 +147,12 @@ def check_stack(self, process, pid, filename):
 self.check_backtrace(thread, filename, backtrace)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_A(self):

slydiman wrote:

Sure. I have renamed them to suggested names. Thanks.

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


[Lldb-commits] [lldb] eb822dc - [lldb] Fixed the TestCompletion test running on a remote target (#92281)

2024-05-15 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-15T21:03:15+04:00
New Revision: eb822dc25853299ea81166f9bb8a43436ab8b0c8

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

LOG: [lldb] Fixed the TestCompletion test running on a remote target (#92281)

Install the image to the remote target if necessary.

Added: 


Modified: 
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 0d6907e0c3d22..63842487fc338 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -107,9 +107,16 @@ def test_process_unload(self):
 self, "// Break here", lldb.SBFileSpec("main.cpp")
 )
 err = lldb.SBError()
-self.process().LoadImage(
-lldb.SBFileSpec(self.getBuildArtifact("libshared.so")), err
+local_spec = lldb.SBFileSpec(self.getBuildArtifact("libshared.so"))
+remote_spec = (
+lldb.SBFileSpec(
+lldbutil.append_to_process_working_directory(self, 
"libshared.so"),
+False,
+)
+if lldb.remote_platform
+else lldb.SBFileSpec()
 )
+self.process().LoadImage(local_spec, remote_spec, err)
 self.assertSuccess(err)
 
 self.complete_from_to("process unload ", "process unload 0")
@@ -473,7 +480,7 @@ def test_custom_command_completion(self):
 self.complete_from_to("my_test_cmd main.cp", ["main.cpp"])
 self.expect("my_test_cmd main.cpp", substrs=["main.cpp"])
 
-@skipIfWindows
+@skipIf(hostoslist=["windows"])
 def test_completion_target_create_from_root_dir(self):
 """Tests source file completion by completing ."""
 root_dir = os.path.abspath(os.sep)



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


[Lldb-commits] [lldb] [lldb] Fixed the TestCompletion test running on a remote target (PR #92281)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] 7645269 - [lldb] Fixed the TestNetBSDCore test (#92285)

2024-05-15 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-15T21:06:30+04:00
New Revision: 7645269710493c188d1d270b9e4e085b3e92b9b0

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

LOG: [lldb] Fixed the TestNetBSDCore test (#92285)

TestNetBSDCore.py contains 3 classes with the same test names
test_aarch64 and test_amd64. It causes conflicts because the same build
dir. Add suffixes to avoid conflicts.

Added: 


Modified: 
lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py 
b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
index 756f4d1e81caa..ff1ef21e02e31 100644
--- a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
+++ b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
@@ -147,12 +147,12 @@ def check_stack(self, process, pid, filename):
 self.check_backtrace(thread, filename, backtrace)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_single_threaded(self):
 """Test single-threaded aarch64 core dump."""
 self.do_test("1lwp_SIGSEGV.aarch64", pid=8339, region_count=32)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_single_threaded(self):
 """Test single-threaded amd64 core dump."""
 self.do_test("1lwp_SIGSEGV.amd64", pid=693, region_count=21)
 
@@ -177,12 +177,12 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_thread_signaled(self):
 """Test double-threaded aarch64 core dump where thread 2 is 
signalled."""
 self.do_test("2lwp_t2_SIGSEGV.aarch64", pid=14142, region_count=31)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_thread_signaled(self):
 """Test double-threaded amd64 core dump where thread 2 is signalled."""
 self.do_test("2lwp_t2_SIGSEGV.amd64", pid=622, region_count=24)
 
@@ -207,11 +207,11 @@ def check_stack(self, process, pid, filename):
 self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
 
 @skipIfLLVMTargetMissing("AArch64")
-def test_aarch64(self):
+def test_aarch64_process_signaled(self):
 """Test double-threaded aarch64 core dump where process is 
signalled."""
 self.do_test("2lwp_process_SIGSEGV.aarch64", pid=1403, region_count=30)
 
 @skipIfLLVMTargetMissing("X86")
-def test_amd64(self):
+def test_amd64_process_signaled(self):
 """Test double-threaded amd64 core dump where process is signalled."""
 self.do_test("2lwp_process_SIGSEGV.amd64", pid=665, region_count=24)



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


[Lldb-commits] [lldb] [lldb] Fixed the TestNetBSDCore test (PR #92285)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] d92c677 - [lldb][Windows] Fixed the TestIOHandlerResizeNoEditline test (#92286)

2024-05-15 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-05-15T21:08:35+04:00
New Revision: d92c67784f21063d6334a009dbf4f9e0f8217b41

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

LOG: [lldb][Windows] Fixed the TestIOHandlerResizeNoEditline test (#92286)

This test caused python crash on Windows x86_64 host with the exit code
0xC409 (STATUS_STACK_BUFFER_OVERRUN). Close the input stream before
exit to avoid this crash.

Added: 


Modified: 
lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py

Removed: 




diff  --git a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py 
b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
index 3c07554f6cafd..bbc2dcbe4e30a 100644
--- a/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
+++ b/lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py
@@ -18,3 +18,4 @@ def test_resize_no_editline(self):
 dbg.RunCommandInterpreter(True, True, opts, 0, False, False)
 # Try resizing the terminal which shouldn't crash.
 dbg.SetTerminalWidth(47)
+dbg.GetInputFile().Close()



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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the TestIOHandlerResizeNoEditline test (PR #92286)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-15 Thread Teresa Johnson via lldb-commits

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

compiler-rt changes lgtm

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Alex Langford via lldb-commits


@@ -0,0 +1,58 @@
+//===-- SBAddressRangeList.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_API_SBADDRESSRANGELIST_H
+#define LLDB_API_SBADDRESSRANGELIST_H
+
+#include 
+
+#include "lldb/API/SBDefines.h"
+
+class AddressRangeListImpl;
+
+namespace lldb {
+
+class LLDB_API SBAddressRangeList {
+public:
+  SBAddressRangeList();
+
+  SBAddressRangeList(const lldb::SBAddressRangeList &rhs);
+
+  ~SBAddressRangeList();
+
+  const lldb::SBAddressRangeList &
+  operator=(const lldb::SBAddressRangeList &rhs);
+
+  uint32_t GetSize() const;
+
+  void Clear();
+
+  bool GetAddressRangeAtIndex(uint64_t idx, SBAddressRange &addr_range);
+
+  void Append(const lldb::SBAddressRange &addr_range);
+
+  void Append(const lldb::SBAddressRangeList &addr_range_list);
+
+protected:
+  const AddressRangeListImpl *operator->() const;
+
+  const AddressRangeListImpl &operator*() const;
+
+private:
+  friend class SBProcess;
+
+  lldb_private::AddressRanges &ref();
+
+  const lldb_private::AddressRanges &ref() const;

bulbazord wrote:

Even if other APIs need a reference to the combined address ranges, we could 
have a private header for `AddressRangeListImpl` in `source/API` so other 
classes can access it. I don't think we need to expose 
`lldb_private::AddressRanges` here. I don't want to expose the `AddressRanges` 
class in the ABI (through mangled names).

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Alex Langford via lldb-commits


@@ -242,6 +244,12 @@ class AddressRange {
   lldb::addr_t m_byte_size = 0; ///< The size in bytes of this address range.
 };
 
+// Forward-declarable wrapper.
+class AddressRanges : public std::vector {
+public:
+  using std::vector::vector;
+};

bulbazord wrote:

I see, you're following the convention for `SBMemoryRegionInfoList`. In the 
discussion above with Greg I proposed a different solution. 

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


[Lldb-commits] [lldb] 411bf38 - [lldb-dap] Include npm install in the extension installation steps (#92028)

2024-05-15 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2024-05-15T14:44:12-04:00
New Revision: 411bf385ba27f15145c635c7d8ff2701fe8de5b9

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

LOG: [lldb-dap] Include npm install in the extension installation steps (#92028)

Otherwise the build step fails due to missing dependencies.

Added: 


Modified: 
lldb/tools/lldb-dap/README.md

Removed: 




diff  --git a/lldb/tools/lldb-dap/README.md b/lldb/tools/lldb-dap/README.md
index 274b1519208a1..16ce4672be71c 100644
--- a/lldb/tools/lldb-dap/README.md
+++ b/lldb/tools/lldb-dap/README.md
@@ -46,6 +46,7 @@ Installing the plug-in is very straightforward and involves 
just a few steps.
 
 ```bash
 cd /path/to/lldb/tools/lldb-dap
+npm install
 npm run package # This also compiles the extension.
 npm run vscode-install
 ```
@@ -69,6 +70,7 @@ no effect.
 ```bash
 # Bump version in package.json
 cd /path/to/lldb/tools/lldb-dap
+npm install
 npm run package
 npm run vscode-install
 ```



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


[Lldb-commits] [lldb] [lldb-dap] Include npm install in the extension installation steps (PR #92028)

2024-05-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Miro Bucko via lldb-commits

https://github.com/mbucko updated 
https://github.com/llvm/llvm-project/pull/92014

>From 4255281194148b59dab6928b59f8bc7df93ca10e Mon Sep 17 00:00:00 2001
From: Miro Bucko 
Date: Fri, 10 May 2024 12:42:03 -0700
Subject: [PATCH] Add AddressRange to SB API

Summary:
This adds new SB API calls and classes to allow a user of the SB API to
obtain an address range from SBFunction and SBBlock.

Test Plan:

Reviewers: clayborg

Subscribers: lldb-commits

Tasks:

Tags:
---
 lldb/bindings/headers.swig|   2 +
 .../interface/SBAddressRangeDocstrings.i  |   3 +
 .../interface/SBAddressRangeExtensions.i  |   1 +
 .../interface/SBAddressRangeListDocstrings.i  |   3 +
 .../interface/SBAddressRangeListExtensions.i  |  23 +++
 lldb/bindings/interfaces.swig |   6 +
 lldb/include/lldb/API/LLDB.h  |   2 +
 lldb/include/lldb/API/SBAddress.h |   1 +
 lldb/include/lldb/API/SBAddressRange.h|  66 +++
 lldb/include/lldb/API/SBAddressRangeList.h|  58 ++
 lldb/include/lldb/API/SBBlock.h   |   3 +
 lldb/include/lldb/API/SBDefines.h |   2 +
 lldb/include/lldb/API/SBFunction.h|   3 +
 lldb/include/lldb/API/SBStream.h  |   2 +
 lldb/include/lldb/Core/AddressRange.h |  12 ++
 lldb/include/lldb/lldb-forward.h  |   3 +
 lldb/source/API/CMakeLists.txt|   2 +
 lldb/source/API/SBAddressRange.cpp| 103 ++
 lldb/source/API/SBAddressRangeList.cpp| 139 +
 lldb/source/API/SBBlock.cpp   |   9 +
 lldb/source/API/SBFunction.cpp|  11 ++
 lldb/source/Core/AddressRange.cpp |  15 ++
 .../API/python_api/address_range/Makefile |   3 +
 .../address_range/TestAddressRange.py | 184 ++
 .../API/python_api/address_range/main.cpp |   8 +
 25 files changed, 664 insertions(+)
 create mode 100644 lldb/bindings/interface/SBAddressRangeDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeExtensions.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListExtensions.i
 create mode 100644 lldb/include/lldb/API/SBAddressRange.h
 create mode 100644 lldb/include/lldb/API/SBAddressRangeList.h
 create mode 100644 lldb/source/API/SBAddressRange.cpp
 create mode 100644 lldb/source/API/SBAddressRangeList.cpp
 create mode 100644 lldb/test/API/python_api/address_range/Makefile
 create mode 100644 lldb/test/API/python_api/address_range/TestAddressRange.py
 create mode 100644 lldb/test/API/python_api/address_range/main.cpp

diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index e8d0cda288141..2b53eefc8568b 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -8,6 +8,8 @@
 %{
 #include "lldb/lldb-public.h"
 #include "lldb/API/SBAddress.h"
+#include "lldb/API/SBAddressRange.h"
+#include "lldb/API/SBAddressRangeList.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBlock.h"
 #include "lldb/API/SBBreakpoint.h"
diff --git a/lldb/bindings/interface/SBAddressRangeDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeDocstrings.i
new file mode 100644
index 0..650195704d73e
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"API clients can get address range information."
+) lldb::SBAddressRange;
diff --git a/lldb/bindings/interface/SBAddressRangeExtensions.i 
b/lldb/bindings/interface/SBAddressRangeExtensions.i
new file mode 100644
index 0..bca359868232d
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeExtensions.i
@@ -0,0 +1 @@
+STRING_EXTENSION_OUTSIDE(SBAddressRange)
diff --git a/lldb/bindings/interface/SBAddressRangeListDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
new file mode 100644
index 0..e4b96b9ca5931
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"Represents a list of :py:class:`SBAddressRange`."
+) lldb::SBAddressRangeList;
diff --git a/lldb/bindings/interface/SBAddressRangeListExtensions.i 
b/lldb/bindings/interface/SBAddressRangeListExtensions.i
new file mode 100644
index 0..23ff5a4f7c41b
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListExtensions.i
@@ -0,0 +1,23 @@
+STRING_EXTENSION_OUTSIDE(SBAddressRangeList)
+
+%extend lldb::SBAddressRangeList {
+#ifdef SWIGPYTHON
+%pythoncode%{
+def __len__(self):
+  '''Return the number of address ranges in a lldb.SBAddressRangeList 
object.'''
+  return self.GetSize()
+
+def __iter__(self):
+  '''Iterate over all the address ranges in a lldb.SBAddressRangeList 
object.'''
+  return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex')
+
+def __getitem__(self, idx):
+  '''Get the address range at a given index in an lldb.SBAddressRangeList 
objec

[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Miro Bucko via lldb-commits

https://github.com/mbucko updated 
https://github.com/llvm/llvm-project/pull/92014

>From f857042f377e107310b5cddfb4fcaed57706b5cc Mon Sep 17 00:00:00 2001
From: Miro Bucko 
Date: Fri, 10 May 2024 12:42:03 -0700
Subject: [PATCH] Add AddressRange to SB API

Summary:
This adds new SB API calls and classes to allow a user of the SB API to
obtain an address range from SBFunction and SBBlock.

Test Plan:

Reviewers: clayborg

Subscribers: lldb-commits

Tasks:

Tags:
---
 lldb/bindings/headers.swig|   2 +
 .../interface/SBAddressRangeDocstrings.i  |   3 +
 .../interface/SBAddressRangeExtensions.i  |   1 +
 .../interface/SBAddressRangeListDocstrings.i  |   3 +
 .../interface/SBAddressRangeListExtensions.i  |  23 +++
 lldb/bindings/interfaces.swig |   6 +
 lldb/include/lldb/API/LLDB.h  |   2 +
 lldb/include/lldb/API/SBAddress.h |   1 +
 lldb/include/lldb/API/SBAddressRange.h|  66 +++
 lldb/include/lldb/API/SBAddressRangeList.h|  58 ++
 lldb/include/lldb/API/SBBlock.h   |   3 +
 lldb/include/lldb/API/SBDefines.h |   2 +
 lldb/include/lldb/API/SBFunction.h|   3 +
 lldb/include/lldb/API/SBStream.h  |   2 +
 lldb/include/lldb/Core/AddressRange.h |  12 ++
 lldb/include/lldb/lldb-forward.h  |   3 +
 lldb/source/API/CMakeLists.txt|   2 +
 lldb/source/API/SBAddressRange.cpp| 102 ++
 lldb/source/API/SBAddressRangeList.cpp| 139 +
 lldb/source/API/SBBlock.cpp   |   9 +
 lldb/source/API/SBFunction.cpp|  11 ++
 lldb/source/Core/AddressRange.cpp |  15 ++
 .../API/python_api/address_range/Makefile |   3 +
 .../address_range/TestAddressRange.py | 184 ++
 .../API/python_api/address_range/main.cpp |   8 +
 25 files changed, 663 insertions(+)
 create mode 100644 lldb/bindings/interface/SBAddressRangeDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeExtensions.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListExtensions.i
 create mode 100644 lldb/include/lldb/API/SBAddressRange.h
 create mode 100644 lldb/include/lldb/API/SBAddressRangeList.h
 create mode 100644 lldb/source/API/SBAddressRange.cpp
 create mode 100644 lldb/source/API/SBAddressRangeList.cpp
 create mode 100644 lldb/test/API/python_api/address_range/Makefile
 create mode 100644 lldb/test/API/python_api/address_range/TestAddressRange.py
 create mode 100644 lldb/test/API/python_api/address_range/main.cpp

diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index e8d0cda288141..2b53eefc8568b 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -8,6 +8,8 @@
 %{
 #include "lldb/lldb-public.h"
 #include "lldb/API/SBAddress.h"
+#include "lldb/API/SBAddressRange.h"
+#include "lldb/API/SBAddressRangeList.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBlock.h"
 #include "lldb/API/SBBreakpoint.h"
diff --git a/lldb/bindings/interface/SBAddressRangeDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeDocstrings.i
new file mode 100644
index 0..650195704d73e
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"API clients can get address range information."
+) lldb::SBAddressRange;
diff --git a/lldb/bindings/interface/SBAddressRangeExtensions.i 
b/lldb/bindings/interface/SBAddressRangeExtensions.i
new file mode 100644
index 0..bca359868232d
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeExtensions.i
@@ -0,0 +1 @@
+STRING_EXTENSION_OUTSIDE(SBAddressRange)
diff --git a/lldb/bindings/interface/SBAddressRangeListDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
new file mode 100644
index 0..e4b96b9ca5931
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"Represents a list of :py:class:`SBAddressRange`."
+) lldb::SBAddressRangeList;
diff --git a/lldb/bindings/interface/SBAddressRangeListExtensions.i 
b/lldb/bindings/interface/SBAddressRangeListExtensions.i
new file mode 100644
index 0..23ff5a4f7c41b
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListExtensions.i
@@ -0,0 +1,23 @@
+STRING_EXTENSION_OUTSIDE(SBAddressRangeList)
+
+%extend lldb::SBAddressRangeList {
+#ifdef SWIGPYTHON
+%pythoncode%{
+def __len__(self):
+  '''Return the number of address ranges in a lldb.SBAddressRangeList 
object.'''
+  return self.GetSize()
+
+def __iter__(self):
+  '''Iterate over all the address ranges in a lldb.SBAddressRangeList 
object.'''
+  return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex')
+
+def __getitem__(self, idx):
+  '''Get the address range at a given index in an lldb.SBAddressRangeList 
objec

[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Miro Bucko via lldb-commits


@@ -52,6 +53,8 @@ class LLDB_API SBBlock {
 
   lldb::SBAddress GetRangeEndAddress(uint32_t idx);
 
+  lldb::SBAddressRange GetRangeAtIndex(uint32_t idx);
+

mbucko wrote:

Currently Block doesn't have GetRanges() function but it does have 
GetRangeAtIndex().
Would you like me to add GetRanges() to Block and then expose both, GetRanges() 
and GetRangeAtIndex(), to SBBlock

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-15 Thread Santhosh Kumar Ellendula via lldb-commits


@@ -0,0 +1,137 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+def runTargetProgramOnPort(self, port=None, program=None):
+server_tool = "lldb-server"

santhoshe447 wrote:

I think "**lldbgdbserverutils.get_debugserver_exe()**" this function would help 
us to get gdbserver path.

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

kastiglione wrote:

@adrian-prantl updated the description:

> Re-apply https://github.com/llvm/llvm-project/pull/81196, with a fix that 
> handles the absence of llvm formatting: 
> https://github.com/llvm/llvm-project/commit/3ba650e91eded3543764f37921dcce3bb47d425f

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Miro Bucko via lldb-commits


@@ -44,6 +45,8 @@ class LLDB_API SBFunction {
 
   lldb::SBAddress GetEndAddress();
 
+  lldb::SBAddressRange GetRange();
+

mbucko wrote:

GetRange() is just a forwarded function from lldb_private::Function::GetRange()

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Miro Bucko via lldb-commits

https://github.com/mbucko updated 
https://github.com/llvm/llvm-project/pull/92014

>From c28e0952a8c422a6dcadae0b2dce8f31a45c8d06 Mon Sep 17 00:00:00 2001
From: Miro Bucko 
Date: Fri, 10 May 2024 12:42:03 -0700
Subject: [PATCH] Add AddressRange to SB API

Summary:
This adds new SB API calls and classes to allow a user of the SB API to
obtain an address range from SBFunction and SBBlock.

Test Plan:

Reviewers: clayborg

Subscribers: lldb-commits

Tasks:

Tags:
---
 lldb/bindings/headers.swig|   2 +
 .../interface/SBAddressRangeDocstrings.i  |   3 +
 .../interface/SBAddressRangeExtensions.i  |   1 +
 .../interface/SBAddressRangeListDocstrings.i  |   3 +
 .../interface/SBAddressRangeListExtensions.i  |  23 +++
 lldb/bindings/interfaces.swig |   6 +
 lldb/include/lldb/API/LLDB.h  |   2 +
 lldb/include/lldb/API/SBAddress.h |   1 +
 lldb/include/lldb/API/SBAddressRange.h|  66 ++
 lldb/include/lldb/API/SBAddressRangeList.h|  59 ++
 lldb/include/lldb/API/SBBlock.h   |   6 +
 lldb/include/lldb/API/SBDefines.h |   2 +
 lldb/include/lldb/API/SBFunction.h|   3 +
 lldb/include/lldb/API/SBStream.h  |   2 +
 lldb/include/lldb/Core/AddressRange.h |  12 ++
 lldb/include/lldb/Symbol/Block.h  |   2 +
 lldb/include/lldb/lldb-forward.h  |   3 +
 lldb/source/API/CMakeLists.txt|   2 +
 lldb/source/API/SBAddressRange.cpp| 102 ++
 lldb/source/API/SBAddressRangeList.cpp| 139 +
 lldb/source/API/SBBlock.cpp   |  18 ++
 lldb/source/API/SBFunction.cpp|  10 +
 lldb/source/Core/AddressRange.cpp |  15 ++
 lldb/source/Symbol/Block.cpp  |  29 ++-
 .../API/python_api/address_range/Makefile |   3 +
 .../address_range/TestAddressRange.py | 188 ++
 .../API/python_api/address_range/main.cpp |   8 +
 27 files changed, 702 insertions(+), 8 deletions(-)
 create mode 100644 lldb/bindings/interface/SBAddressRangeDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeExtensions.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListExtensions.i
 create mode 100644 lldb/include/lldb/API/SBAddressRange.h
 create mode 100644 lldb/include/lldb/API/SBAddressRangeList.h
 create mode 100644 lldb/source/API/SBAddressRange.cpp
 create mode 100644 lldb/source/API/SBAddressRangeList.cpp
 create mode 100644 lldb/test/API/python_api/address_range/Makefile
 create mode 100644 lldb/test/API/python_api/address_range/TestAddressRange.py
 create mode 100644 lldb/test/API/python_api/address_range/main.cpp

diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index e8d0cda288141..2b53eefc8568b 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -8,6 +8,8 @@
 %{
 #include "lldb/lldb-public.h"
 #include "lldb/API/SBAddress.h"
+#include "lldb/API/SBAddressRange.h"
+#include "lldb/API/SBAddressRangeList.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBlock.h"
 #include "lldb/API/SBBreakpoint.h"
diff --git a/lldb/bindings/interface/SBAddressRangeDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeDocstrings.i
new file mode 100644
index 0..650195704d73e
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"API clients can get address range information."
+) lldb::SBAddressRange;
diff --git a/lldb/bindings/interface/SBAddressRangeExtensions.i 
b/lldb/bindings/interface/SBAddressRangeExtensions.i
new file mode 100644
index 0..bca359868232d
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeExtensions.i
@@ -0,0 +1 @@
+STRING_EXTENSION_OUTSIDE(SBAddressRange)
diff --git a/lldb/bindings/interface/SBAddressRangeListDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
new file mode 100644
index 0..e4b96b9ca5931
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"Represents a list of :py:class:`SBAddressRange`."
+) lldb::SBAddressRangeList;
diff --git a/lldb/bindings/interface/SBAddressRangeListExtensions.i 
b/lldb/bindings/interface/SBAddressRangeListExtensions.i
new file mode 100644
index 0..23ff5a4f7c41b
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListExtensions.i
@@ -0,0 +1,23 @@
+STRING_EXTENSION_OUTSIDE(SBAddressRangeList)
+
+%extend lldb::SBAddressRangeList {
+#ifdef SWIGPYTHON
+%pythoncode%{
+def __len__(self):
+  '''Return the number of address ranges in a lldb.SBAddressRangeList 
object.'''
+  return self.GetSize()
+
+def __iter__(self):
+  '''Iterate over all the address ranges in a lldb.SBAddressRangeList 
object.'''
+  return lldb_iter(self, 'GetSize', 'GetAddressRangeAtI

[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Miro Bucko via lldb-commits

https://github.com/mbucko updated 
https://github.com/llvm/llvm-project/pull/92014

>From 44871da2279dc2fe001584f0cd41dc9b76b43fbd Mon Sep 17 00:00:00 2001
From: Miro Bucko 
Date: Fri, 10 May 2024 12:42:03 -0700
Subject: [PATCH] Add AddressRange to SB API

Summary:
This adds new SB API calls and classes to allow a user of the SB API to
obtain an address range from SBFunction and SBBlock.

Test Plan:
llvm-lit -sv 
llvm-project/lldb/test/API/python_api/address_range/TestAddressRange.py

Reviewers: clayborg

Subscribers: lldb-commits

Tasks:

Tags:
---
 lldb/bindings/headers.swig|   2 +
 .../interface/SBAddressRangeDocstrings.i  |   3 +
 .../interface/SBAddressRangeExtensions.i  |   1 +
 .../interface/SBAddressRangeListDocstrings.i  |   3 +
 .../interface/SBAddressRangeListExtensions.i  |  23 +++
 lldb/bindings/interfaces.swig |   6 +
 lldb/include/lldb/API/LLDB.h  |   2 +
 lldb/include/lldb/API/SBAddress.h |   1 +
 lldb/include/lldb/API/SBAddressRange.h|  66 ++
 lldb/include/lldb/API/SBAddressRangeList.h|  59 ++
 lldb/include/lldb/API/SBBlock.h   |   6 +
 lldb/include/lldb/API/SBDefines.h |   2 +
 lldb/include/lldb/API/SBFunction.h|   3 +
 lldb/include/lldb/API/SBStream.h  |   2 +
 lldb/include/lldb/Core/AddressRange.h |  12 ++
 lldb/include/lldb/Symbol/Block.h  |   2 +
 lldb/include/lldb/lldb-forward.h  |   3 +
 lldb/source/API/CMakeLists.txt|   2 +
 lldb/source/API/SBAddressRange.cpp| 102 ++
 lldb/source/API/SBAddressRangeList.cpp| 139 +
 lldb/source/API/SBBlock.cpp   |  18 ++
 lldb/source/API/SBFunction.cpp|  10 +
 lldb/source/Core/AddressRange.cpp |  15 ++
 lldb/source/Symbol/Block.cpp  |  29 ++-
 .../API/python_api/address_range/Makefile |   3 +
 .../address_range/TestAddressRange.py | 188 ++
 .../API/python_api/address_range/main.cpp |   8 +
 27 files changed, 702 insertions(+), 8 deletions(-)
 create mode 100644 lldb/bindings/interface/SBAddressRangeDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeExtensions.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListDocstrings.i
 create mode 100644 lldb/bindings/interface/SBAddressRangeListExtensions.i
 create mode 100644 lldb/include/lldb/API/SBAddressRange.h
 create mode 100644 lldb/include/lldb/API/SBAddressRangeList.h
 create mode 100644 lldb/source/API/SBAddressRange.cpp
 create mode 100644 lldb/source/API/SBAddressRangeList.cpp
 create mode 100644 lldb/test/API/python_api/address_range/Makefile
 create mode 100644 lldb/test/API/python_api/address_range/TestAddressRange.py
 create mode 100644 lldb/test/API/python_api/address_range/main.cpp

diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index e8d0cda288141..2b53eefc8568b 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -8,6 +8,8 @@
 %{
 #include "lldb/lldb-public.h"
 #include "lldb/API/SBAddress.h"
+#include "lldb/API/SBAddressRange.h"
+#include "lldb/API/SBAddressRangeList.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBlock.h"
 #include "lldb/API/SBBreakpoint.h"
diff --git a/lldb/bindings/interface/SBAddressRangeDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeDocstrings.i
new file mode 100644
index 0..650195704d73e
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"API clients can get address range information."
+) lldb::SBAddressRange;
diff --git a/lldb/bindings/interface/SBAddressRangeExtensions.i 
b/lldb/bindings/interface/SBAddressRangeExtensions.i
new file mode 100644
index 0..bca359868232d
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeExtensions.i
@@ -0,0 +1 @@
+STRING_EXTENSION_OUTSIDE(SBAddressRange)
diff --git a/lldb/bindings/interface/SBAddressRangeListDocstrings.i 
b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
new file mode 100644
index 0..e4b96b9ca5931
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListDocstrings.i
@@ -0,0 +1,3 @@
+%feature("docstring",
+"Represents a list of :py:class:`SBAddressRange`."
+) lldb::SBAddressRangeList;
diff --git a/lldb/bindings/interface/SBAddressRangeListExtensions.i 
b/lldb/bindings/interface/SBAddressRangeListExtensions.i
new file mode 100644
index 0..23ff5a4f7c41b
--- /dev/null
+++ b/lldb/bindings/interface/SBAddressRangeListExtensions.i
@@ -0,0 +1,23 @@
+STRING_EXTENSION_OUTSIDE(SBAddressRangeList)
+
+%extend lldb::SBAddressRangeList {
+#ifdef SWIGPYTHON
+%pythoncode%{
+def __len__(self):
+  '''Return the number of address ranges in a lldb.SBAddressRangeList 
object.'''
+  return self.GetSize()
+
+def __iter__(self):
+  '''Iterate over all the address ranges in a lldb.SBAdd

[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Miro Bucko via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-15 Thread Zequan Wu via lldb-commits

ZequanWu wrote:

I had a fix to this:  Let `SymbolFileDWARF::GetForwardDeclCompilerTypeToDIE` do 
the same as `SymbolFileDWARF::GetUniqueDWARFASTTypeMap`: inquery 
SymbolFileDWARFDebugMap first to get the shared underlying SymbolFile so the 
map is shared among multiple SymbolFileDWARF. It's here: 
https://github.com/ZequanWu/llvm-project/commit/2172c660821e273205e7ad3a64eb7f3623b21606

It fixes those failed tests shown on the macos bot. However, I noticed that 
lldb crashes on three tests related to clang module (they also crashes when the 
fix is not given, but not crash after reverting this PR):
```
Unresolved Tests (3):
  lldb-api :: 
commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
  lldb-api :: 
commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
  lldb-api :: 
commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
```

I found it's the following commands causing crash.
```
$ out/cmake/bin/lldb 
out/cmake/lldb-test-build.noindex/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.test_dwarf/a.out
 -o "settings set symbols.clang-modules-cache-path 
/Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/module-cache-lldb/lldb-api"
 -o "settings set target.import-std-module true" -o "b 9" -o "r"  -o "expr a"
(lldb) target create 
"../cmake/lldb-test-build.noindex/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.test_dwarf/a.out"
Current executable set to 
'/Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.test_dwarf/a.out'
 (arm64).
(lldb) settings set symbols.clang-modules-cache-path 
/Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/module-cache-lldb/lldb-api
(lldb) settings set target.import-std-module true
(lldb) b 9
Breakpoint 1: where = a.out`main + 104 at main.cpp:9:3, address = 
0x00012508
(lldb) r
Process 12273 launched: 
'/Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.test_dwarf/a.out'
 (arm64)
Process 12273 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x00012508 a.out`main(argc=1, argv=0x00016fdff428) at 
main.cpp:9:3
   6
   7int main(int argc, char **argv) {
   8  std::vector a = {{3}, {1}, {2}};
-> 9  return 0; // Set break point at this line.
   10   }
(lldb) expr a
Assertion failed: (0 && "Invalid SLocOffset or bad function choice"), function 
getFileIDLoaded, file SourceManager.cpp, line 865.
LLDB diagnostics will be written to 
/var/folders/jf/zylbx28s05n0d_xwqdf5jnrc00lnhs/T/diagnostics-512963
Please include the directory content when filing a bug report
[1]12267 abort  bin/lldb  -o  -o "settings set target.import-std-module 
true" -o "b 9" -o "r"
```

The clang module in 
`out/cmake/lldb-test-build.noindex/module-cache-lldb/lldb-api` was created when 
running `check-lldb`. If I delete the clang modules in that directory and run 
the above command again, it no longer crashes and able to give correct result 
(after the first run, a new clang module is created in the directory. Following 
runs of the above commands no longer crashes). So, it looks like related to 
stale clang module. If I use debug built lldb, it no longer crashes. Do you 
have any idea how to debug this crash? I'm not familiar with how clang module 
interact with type completion etc.

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


[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/91868

>From 30a36018b9c96d7ddd969815ef850987d781338e Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 30 Apr 2024 10:45:10 -0700
Subject: [PATCH 1/3] [lldb] Support custom LLVM formatting for variables
 (#81196)

Adds support for applying LLVM formatting to variables.

The reason for this is to support cases such as the following.

Let's say you have two separate bytes that you want to print as a
combined hex value. Consider the following summary string:

```
${var.byte1%x}${var.byte2%x}
```

The output of this will be: `0x120x34`. That is, a `0x` prefix is
unconditionally applied to each byte. This is unlike printf formatting
where you must include the `0x` yourself.

Currently, there's no way to do this with summary strings, instead
you'll need a summary provider in python or c++.

This change introduces formatting support using LLVM's formatter system.
This allows users to achieve the desired custom formatting using:

```
${var.byte1:x-}${var.byte2:x-}
```

Here, each variable is suffixed with `:x-`. This is passed to the LLVM
formatter as `{0:x-}`. For integer values, `x` declares the output as
hex, and `-` declares that no `0x` prefix is to be used. Further, one
could write:

```
${var.byte1:x-2}${var.byte2:x-2}
```

Where the added `2` results in these bytes being written with a minimum
of 2 digits.

An alternative considered was to add a new format specifier that would
print hex values without the `0x` prefix. The reason that approach was
not taken is because in addition to forcing a `0x` prefix, hex values
are also forced to use leading zeros. This approach lets the user have
full control over formatting.
---
 lldb/docs/use/variable.rst|  9 +++
 lldb/source/Core/FormatEntity.cpp | 70 ---
 .../custom-printf-summary/Makefile|  2 +
 .../TestCustomSummaryLLVMFormat.py| 20 ++
 .../custom-printf-summary/main.c  | 13 
 5 files changed, 104 insertions(+), 10 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c

diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index 8eaed6405315b..e9175b25336ba 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -460,6 +460,15 @@ summary strings, regardless of the format they have 
applied to their types. To
 do that, you can use %format inside an expression path, as in ${var.x->x%u},
 which would display the value of x as an unsigned integer.
 
+Additionally, custom output can be achieved by using an LLVM format string,
+commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and
+``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``),
+which unconditionally inserts a ``0x`` prefix, and also zero pads the value to
+match the size of the type. The latter uses ``llvm::formatv`` formatting
+(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no
+padding. This raw control is useful when composing multiple pieces into a
+larger whole.
+
 You can also use some other special format markers, not available for formats
 themselves, but which carry a special meaning when used in this context:
 
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index ba62e26252591..da5b1cfce74ac 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -57,6 +57,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/TargetParser/Triple.h"
 
 #include 
@@ -658,6 +659,38 @@ static char ConvertValueObjectStyleToChar(
   return '\0';
 }
 
+static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", 
llvm::Regex::IgnoreCase};
+
+static bool DumpValueWithLLVMFormat(Stream &s, llvm::StringRef options,
+ValueObject &valobj) {
+  std::string formatted;
+  std::string llvm_format = ("{0:" + options + "}").str();
+
+  // Options supported by format_provider for integral arithmetic types.
+  // See table in FormatProviders.h.
+
+  auto type_info = valobj.GetTypeInfo();
+  if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) {
+if (type_info & eTypeIsSigned) {
+  bool success = false;
+  int64_t integer = valobj.GetValueAsSigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+} else {
+  bool success = false;
+  uint64_t integer = valobj.GetValueAsUnsigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+}
+  }
+
+  if (formatted.empt

[Lldb-commits] [lldb] [lldb] Support custom LLVM formatting for variables (PR #91868)

2024-05-15 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/91868

>From 30a36018b9c96d7ddd969815ef850987d781338e Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Tue, 30 Apr 2024 10:45:10 -0700
Subject: [PATCH 1/4] [lldb] Support custom LLVM formatting for variables
 (#81196)

Adds support for applying LLVM formatting to variables.

The reason for this is to support cases such as the following.

Let's say you have two separate bytes that you want to print as a
combined hex value. Consider the following summary string:

```
${var.byte1%x}${var.byte2%x}
```

The output of this will be: `0x120x34`. That is, a `0x` prefix is
unconditionally applied to each byte. This is unlike printf formatting
where you must include the `0x` yourself.

Currently, there's no way to do this with summary strings, instead
you'll need a summary provider in python or c++.

This change introduces formatting support using LLVM's formatter system.
This allows users to achieve the desired custom formatting using:

```
${var.byte1:x-}${var.byte2:x-}
```

Here, each variable is suffixed with `:x-`. This is passed to the LLVM
formatter as `{0:x-}`. For integer values, `x` declares the output as
hex, and `-` declares that no `0x` prefix is to be used. Further, one
could write:

```
${var.byte1:x-2}${var.byte2:x-2}
```

Where the added `2` results in these bytes being written with a minimum
of 2 digits.

An alternative considered was to add a new format specifier that would
print hex values without the `0x` prefix. The reason that approach was
not taken is because in addition to forcing a `0x` prefix, hex values
are also forced to use leading zeros. This approach lets the user have
full control over formatting.
---
 lldb/docs/use/variable.rst|  9 +++
 lldb/source/Core/FormatEntity.cpp | 70 ---
 .../custom-printf-summary/Makefile|  2 +
 .../TestCustomSummaryLLVMFormat.py| 20 ++
 .../custom-printf-summary/main.c  | 13 
 5 files changed, 104 insertions(+), 10 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py
 create mode 100644 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c

diff --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index 8eaed6405315b..e9175b25336ba 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -460,6 +460,15 @@ summary strings, regardless of the format they have 
applied to their types. To
 do that, you can use %format inside an expression path, as in ${var.x->x%u},
 which would display the value of x as an unsigned integer.
 
+Additionally, custom output can be achieved by using an LLVM format string,
+commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and
+``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``),
+which unconditionally inserts a ``0x`` prefix, and also zero pads the value to
+match the size of the type. The latter uses ``llvm::formatv`` formatting
+(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no
+padding. This raw control is useful when composing multiple pieces into a
+larger whole.
+
 You can also use some other special format markers, not available for formats
 themselves, but which carry a special meaning when used in this context:
 
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index ba62e26252591..da5b1cfce74ac 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -57,6 +57,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/TargetParser/Triple.h"
 
 #include 
@@ -658,6 +659,38 @@ static char ConvertValueObjectStyleToChar(
   return '\0';
 }
 
+static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", 
llvm::Regex::IgnoreCase};
+
+static bool DumpValueWithLLVMFormat(Stream &s, llvm::StringRef options,
+ValueObject &valobj) {
+  std::string formatted;
+  std::string llvm_format = ("{0:" + options + "}").str();
+
+  // Options supported by format_provider for integral arithmetic types.
+  // See table in FormatProviders.h.
+
+  auto type_info = valobj.GetTypeInfo();
+  if (type_info & eTypeIsInteger && LLVMFormatPattern.match(options)) {
+if (type_info & eTypeIsSigned) {
+  bool success = false;
+  int64_t integer = valobj.GetValueAsSigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+} else {
+  bool success = false;
+  uint64_t integer = valobj.GetValueAsUnsigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+}
+  }
+
+  if (formatted.empt

[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-15 Thread Santhosh Kumar Ellendula via lldb-commits

https://github.com/santhoshe447 updated 
https://github.com/llvm/llvm-project/pull/91570

>From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001
From: Santhosh Kumar Ellendula 
Date: Fri, 17 Nov 2023 15:09:10 +0530
Subject: [PATCH 1/6] [lldb][test] Add the ability to extract the variable
 value out of the summary.

---
 .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py   | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 9d79872b029a3..0cf9d4fde4948 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -195,6 +195,9 @@ def collect_console(self, duration):
 
 def get_local_as_int(self, name, threadId=None):
 value = self.dap_server.get_local_variable_value(name, 
threadId=threadId)
+# 'value' may have the variable value and summary.
+# Extract the variable value since summary can have nonnumeric 
characters.
+value = value.split(" ")[0]
 if value.startswith("0x"):
 return int(value, 16)
 elif value.startswith("0"):

>From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001
From: Santhosh Kumar Ellendula 
Date: Fri, 3 May 2024 02:47:05 -0700
Subject: [PATCH 2/6] [lldb-dap] Added "port" property to vscode "attach"
 command.

Adding a "port" property to the VsCode "attach" command likely extends the 
functionality of the debugger configuratiuon to allow attaching to a process 
using PID or PORT number.
Currently, the "Attach" configuration lets the user specify a pid. We tell the 
user to use the attachCommands property to run "gdb-remote ".
Followed the below conditions for "attach" command with "port" and "pid"
We should add a "port" property. If port is specified and pid is not, use that 
port to attach. If both port and pid are specified, return an error saying that 
the user can't specify both pid and port.

Ex - launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "lldb-dap Debug",
"type": "lldb-dap",
"request": "attach",
"port":1234,
"program": "${workspaceFolder}/a.out",
"args": [],
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"env": [],

}
]
}
---
 lldb/include/lldb/lldb-defines.h  |   1 +
 .../Python/lldbsuite/test/lldbtest.py |   9 ++
 .../test/tools/lldb-dap/dap_server.py |   6 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  20 +++
 .../attach/TestDAP_attachByPortNum.py | 120 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  36 +-
 lldb/tools/lldb-dap/package.json  |  11 ++
 7 files changed, 199 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py

diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h
index c7bd019c5c90e..a1e6ee2ce468c 100644
--- a/lldb/include/lldb/lldb-defines.h
+++ b/lldb/include/lldb/lldb-defines.h
@@ -96,6 +96,7 @@
 #define LLDB_INVALID_QUEUE_ID 0
 #define LLDB_INVALID_CPU_ID UINT32_MAX
 #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX
+#define LLDB_INVALID_PORT_NUMBER 0
 
 /// CPU Type definitions
 #define LLDB_ARCH_DEFAULT "systemArch"
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 5fd686c143e9f..fb3cd22959df2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1572,6 +1572,15 @@ def findBuiltClang(self):
 
 return os.environ["CC"]
 
+def getBuiltServerTool(self, server_tool):
+# Tries to find simulation/lldb-server/gdbserver tool at the same 
folder as the lldb.
+lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
+path = shutil.which(server_tool, path=lldb_dir)
+if path is not None:
+return path
+
+return ""
+
 def yaml2obj(self, yaml_path, obj_path, max_size=None):
 """
 Create an object file at the given path from a yaml file.
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 5838281bcb1a1..96d312565f953 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
@@ -568,6 +568,8 @@ def request_attach(
 coreFile=None,
 postRunCommands=None,
 sourceMap=None,
+port=None,
+hostname=None
 ):
 args_dict = {}
 if pid is not None:
@@ -597,6 +599,10 @@ def request_attach(
 args_dict["postRunCommands"] = postRunComman

[Lldb-commits] [lldb] 8530b1c - [lldb] Support custom LLVM formatting for variables (#91868)

2024-05-15 Thread via lldb-commits

Author: Dave Lee
Date: 2024-05-15T14:44:42-07:00
New Revision: 8530b1c464ae9af4a5c8be145a8db043798634f6

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

LOG: [lldb] Support custom LLVM formatting for variables (#91868)

Re-apply https://github.com/llvm/llvm-project/pull/81196, with a fix that 
handles the 
absence of llvm formatting: 
https://github.com/llvm/llvm-project/pull/91868/commits/3ba650e91eded3543764f37921dcce3b
b47d425f

Added: 
lldb/test/API/functionalities/data-formatter/custom-printf-summary/Makefile

lldb/test/API/functionalities/data-formatter/custom-printf-summary/TestCustomSummaryLLVMFormat.py
lldb/test/API/functionalities/data-formatter/custom-printf-summary/main.c

Modified: 
lldb/docs/use/variable.rst
lldb/source/Core/FormatEntity.cpp

Removed: 




diff  --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index 8eaed6405315b..e9175b25336ba 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -460,6 +460,15 @@ summary strings, regardless of the format they have 
applied to their types. To
 do that, you can use %format inside an expression path, as in ${var.x->x%u},
 which would display the value of x as an unsigned integer.
 
+Additionally, custom output can be achieved by using an LLVM format string,
+commencing with the ``:`` marker. To illustrate, compare ``${var.byte%x}`` and
+``${var.byte:x-}``. The former uses lldb's builtin hex formatting (``x``),
+which unconditionally inserts a ``0x`` prefix, and also zero pads the value to
+match the size of the type. The latter uses ``llvm::formatv`` formatting
+(``:x-``), and will print only the hex value, with no ``0x`` prefix, and no
+padding. This raw control is useful when composing multiple pieces into a
+larger whole.
+
 You can also use some other special format markers, not available for formats
 themselves, but which carry a special meaning when used in this context:
 

diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index ba62e26252591..07978d3882961 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -57,6 +57,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/TargetParser/Triple.h"
 
 #include 
@@ -658,6 +659,37 @@ static char ConvertValueObjectStyleToChar(
   return '\0';
 }
 
+/// Options supported by format_provider for integral arithmetic types.
+/// See table in FormatProviders.h.
+static llvm::Regex LLVMFormatPattern{"x[-+]?\\d*|n|d", 
llvm::Regex::IgnoreCase};
+
+static bool DumpValueWithLLVMFormat(Stream &s, llvm::StringRef options,
+ValueObject &valobj) {
+  std::string formatted;
+  std::string llvm_format = ("{0:" + options + "}").str();
+
+  auto type_info = valobj.GetTypeInfo();
+  if ((type_info & eTypeIsInteger) && LLVMFormatPattern.match(options)) {
+if (type_info & eTypeIsSigned) {
+  bool success = false;
+  int64_t integer = valobj.GetValueAsSigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+} else {
+  bool success = false;
+  uint64_t integer = valobj.GetValueAsUnsigned(0, &success);
+  if (success)
+formatted = llvm::formatv(llvm_format.data(), integer);
+}
+  }
+
+  if (formatted.empty())
+return false;
+
+  s.Write(formatted.data(), formatted.size());
+  return true;
+}
+
 static bool DumpValue(Stream &s, const SymbolContext *sc,
   const ExecutionContext *exe_ctx,
   const FormatEntity::Entry &entry, ValueObject *valobj) {
@@ -728,9 +760,12 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
 return RunScriptFormatKeyword(s, sc, exe_ctx, valobj, 
entry.string.c_str());
   }
 
-  llvm::StringRef subpath(entry.string);
+  auto split = llvm::StringRef(entry.string).split(':');
+  auto subpath = split.first;
+  auto llvm_format = split.second;
+
   // simplest case ${var}, just print valobj's value
-  if (entry.string.empty()) {
+  if (subpath.empty()) {
 if (entry.printf_format.empty() && entry.fmt == eFormatDefault &&
 entry.number == ValueObject::eValueObjectRepresentationStyleValue)
   was_plain_var = true;
@@ -739,7 +774,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
 target = valobj;
   } else // this is ${var.something} or multiple .something nested
   {
-if (entry.string[0] == '[')
+if (subpath[0] == '[')
   was_var_indexed = true;
 ScanBracketedRange(subpath, close_bracket_index,
var_name_final_if_array_range, index_lower,
@@ -747,14 +782,11 @@ static bool DumpValue(Stream &s, const Symb

[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-15 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,102 @@
+//===-- SBAddressRange.cpp 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/API/SBAddressRange.h"
+#include "Utils.h"
+#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/Core/AddressRange.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Utility/Instrumentation.h"
+#include "lldb/Utility/Stream.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBAddressRange::SBAddressRange()
+: m_opaque_up(std::make_unique()) {
+  LLDB_INSTRUMENT_VA(this);
+}
+
+SBAddressRange::SBAddressRange(const SBAddressRange &rhs) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  m_opaque_up = clone(rhs.m_opaque_up);
+}
+
+SBAddressRange::SBAddressRange(lldb::SBAddress addr, lldb::addr_t byte_size)
+: m_opaque_up(std::make_unique(addr.ref(), byte_size)) {
+  LLDB_INSTRUMENT_VA(this, addr, byte_size);
+}
+
+SBAddressRange::~SBAddressRange() = default;
+
+const SBAddressRange &SBAddressRange::operator=(const SBAddressRange &rhs) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  if (this != &rhs)
+m_opaque_up = clone(rhs.m_opaque_up);
+  return *this;
+}
+
+bool SBAddressRange::operator==(const SBAddressRange &rhs) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  if (!IsValid() || !rhs.IsValid())
+return false;
+  return m_opaque_up->operator==(*(rhs.m_opaque_up));
+}
+
+bool SBAddressRange::operator!=(const SBAddressRange &rhs) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  return !(*this == rhs);
+}
+
+void SBAddressRange::Clear() {
+  LLDB_INSTRUMENT_VA(this);
+
+  m_opaque_up.reset();
+}
+
+bool SBAddressRange::IsValid() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  return m_opaque_up && m_opaque_up->IsValid();
+}
+
+lldb::SBAddress SBAddressRange::GetBaseAddress() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (!IsValid())
+return lldb::SBAddress();
+  return lldb::SBAddress(m_opaque_up->GetBaseAddress());
+}
+
+lldb::addr_t SBAddressRange::GetByteSize() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (!IsValid())
+return 0;
+  return m_opaque_up->GetByteSize();
+}
+
+bool SBAddressRange::GetDescription(SBStream &description) {
+  LLDB_INSTRUMENT_VA(this, description);
+
+  Stream &stream = description.ref();
+
+  if (!IsValid()) {
+stream << "Invalid address range";
+return true;
+  }
+  m_opaque_up->DumpDebug(&stream);

clayborg wrote:

How does this look in the output? Can you paste an example? 

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


[Lldb-commits] [lldb] [lldb-dap] Support publishing to the VSCode market place (PR #92320)

2024-05-15 Thread Walter Erquinigo via lldb-commits

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

lgtm!

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


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-15 Thread via lldb-commits


@@ -743,9 +743,28 @@ DebuggerSP 
Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 }
 
 void Debugger::HandleDestroyCallback() {
-  if (m_destroy_callback) {
-m_destroy_callback(GetID(), m_destroy_callback_baton);
-m_destroy_callback = nullptr;
+  std::lock_guard guard(m_destroy_callback_mutex);
+  const lldb::user_id_t user_id = GetID();
+  // This loop handles the case where callbacks are added/removed by existing
+  // callbacks during the loop, as the following:
+  // - Added callbacks will always be invoked.
+  // - Removed callbacks will never be invoked. That is *unless* the loop
+  //   happens to invoke the said callbacks first, before they get removed.
+  //   In this case, the callbacks gets invoked, and the removal return false.
+  //
+  // In the removal case, because the order of the container is random, it's
+  // wise to not depend on the order and instead implement logic inside the
+  // callbacks to decide if their work should be skipped.
+  while (m_destroy_callback_and_baton.size()) {
+auto iter = m_destroy_callback_and_baton.begin();
+const lldb::destroy_callback_token_t &token = iter->first;
+const lldb_private::DebuggerDestroyCallback &callback = iter->second.first;
+void *const &baton = iter->second.second;
+callback(user_id, baton);
+// Using `token` to erase, because elements may have been added/removed, 
and
+// that will cause error "invalid iterator access!" if `iter` is used
+// instead.
+m_destroy_callback_and_baton.erase(token);

jeffreytan81 wrote:

The biggest concern is that, this implementation completely changes the 
semantics -- now, client using this API has to re-register the callbacks after 
destroying debugger which is weird and not expected because there is no 
removeCallback() called from client. For example, the following user case won't 
work anymore:
```
void MyDestroyCallback() {
...
}

SBDebugger::AddDestroyCallbac(MyDestroyCallback);
SBDebugger::Create();
...
SBDebugger::Destroy();

// Recreate another debugger
SBDebugger::Create();
SBDebugger::Destroy();   // Now the MyDestroyCallback won't be called even user 
did not call RemoveDestroyCallback() which is not expected
```

There are several ways to handle this issue without clearing 
`m_destroy_callback_and_baton`. One simply way is making a copy of 
`m_destroy_callback_and_baton`, and calling callbacks from the copy (by 
checking if it still exists in original `m_destroy_callback_and_baton`). And at 
the end, checking there is no new entries in `m_destroy_callback_and_baton`, 
otherwise, getting the delta of the local copy and original copy, and redo the 
process in a loop.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestFdLeak test (PR #92273)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

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

>From 6341c038d41ac3b533314568187b8d5d390dc861 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Wed, 15 May 2024 18:38:16 +0400
Subject: [PATCH 1/2] [lldb] Fixed the TestFdLeak test

Use `NUL` instead of `/dev/null` in case of the Windows host.
---
 lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py 
b/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
index e4f5cd3a03f86..e292885ec390d 100644
--- a/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
+++ b/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
@@ -26,7 +26,10 @@ def test_fd_leak_basic(self):
 @skipIfTargetAndroid()  # Android have some other file descriptors open by 
the shell
 @skipIfDarwinEmbedded  #   # debugserver on ios 
has an extra fd open on launch
 def test_fd_leak_log(self):
-self.do_test(["log enable -f '/dev/null' lldb commands"])
+if lldbplatformutil.getHostPlatform() == "windows":
+self.do_test(["log enable -f 'NUL' lldb commands"])
+else:
+self.do_test(["log enable -f '/dev/null' lldb commands"])
 
 def do_test(self, commands):
 self.build()

>From bace750680865ff5edd0314c3c11418f45f96439 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 16 May 2024 02:10:23 +0400
Subject: [PATCH 2/2] Updated to use os.devnull

---
 lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py 
b/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
index e292885ec390d..c840d38df5c76 100644
--- a/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
+++ b/lldb/test/API/functionalities/avoids-fd-leak/TestFdLeak.py
@@ -26,10 +26,7 @@ def test_fd_leak_basic(self):
 @skipIfTargetAndroid()  # Android have some other file descriptors open by 
the shell
 @skipIfDarwinEmbedded  #   # debugserver on ios 
has an extra fd open on launch
 def test_fd_leak_log(self):
-if lldbplatformutil.getHostPlatform() == "windows":
-self.do_test(["log enable -f 'NUL' lldb commands"])
-else:
-self.do_test(["log enable -f '/dev/null' lldb commands"])
+self.do_test(["log enable -f '{}' lldb commands".format(os.devnull)])
 
 def do_test(self, commands):
 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/Coredump] Only take the Pthread from stack start to the stackpointer + red_zone (PR #92002)

2024-05-15 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
e3ca558ffb1441cb16da7aba021e12c6f11f...25ff389fd2b1ca5caccfe239d8ab1bd166ee75cb
 
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
``





View the diff from darker here.


``diff
--- TestProcessSaveCoreMinidump.py  2024-05-15 21:57:00.00 +
+++ TestProcessSaveCoreMinidump.py  2024-05-15 22:10:33.216415 +
@@ -9,11 +9,16 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
 class ProcessSaveCoreMinidumpTestCase(TestBase):
 def verify_core_file(
-self, core_path, expected_pid, expected_modules, expected_threads, 
stacks_to_sps_map
+self,
+core_path,
+expected_pid,
+expected_modules,
+expected_threads,
+stacks_to_sps_map,
 ):
 # To verify, we'll launch with the mini dump
 target = self.dbg.CreateTarget(None)
 process = target.LoadCore(core_path)
 
@@ -56,12 +61,10 @@
 self.assertTrue(error.Success(), error.GetCString())
 # Try to read just past the red zone and fail
 process.ReadMemory(sp - red_zone - 1, 1, error)
 self.assertTrue(error.Fail(), "No failure when reading past the 
red zone")
 
-
-
 self.dbg.DeleteTarget(target)
 
 @skipUnlessArch("x86_64")
 @skipUnlessPlatform(["linux"])
 def test_save_linux_mini_dump(self):
@@ -100,47 +103,71 @@
 # save core and, kill process and verify corefile existence
 base_command = "process save-core --plugin-name=minidump "
 self.runCmd(base_command + " --style=stack '%s'" % (core_stack))
 self.assertTrue(os.path.isfile(core_stack))
 self.verify_core_file(
-core_stack, expected_pid, expected_modules, expected_threads, 
stacks_to_sp_map
+core_stack,
+expected_pid,
+expected_modules,
+expected_threads,
+stacks_to_sp_map,
 )
 
 self.runCmd(base_command + " --style=modified-memory '%s'" % 
(core_dirty))
 self.assertTrue(os.path.isfile(core_dirty))
 self.verify_core_file(
-core_dirty, expected_pid, expected_modules, expected_threads, 
stacks_to_sp_map
+core_dirty,
+expected_pid,
+expected_modules,
+expected_threads,
+stacks_to_sp_map,
 )
 
 self.runCmd(base_command + " --style=full '%s'" % (core_full))
 self.assertTrue(os.path.isfile(core_full))
 self.verify_core_file(
-core_full, expected_pid, expected_modules, expected_threads, 
stacks_to_sp_map
+core_full,
+expected_pid,
+expected_modules,
+expected_threads,
+stacks_to_sp_map,
 )
 
 # validate saving via SBProcess
 error = process.SaveCore(core_sb_stack, "minidump", 
lldb.eSaveCoreStackOnly)
 self.assertTrue(error.Success())
 self.assertTrue(os.path.isfile(core_sb_stack))
 self.verify_core_file(
-core_sb_stack, expected_pid, expected_modules, 
expected_threads, stacks_to_sp_map
+core_sb_stack,
+expected_pid,
+expected_modules,
+expected_threads,
+stacks_to_sp_map,
 )
 
 error = process.SaveCore(core_sb_dirty, "minidump", 
lldb.eSaveCoreDirtyOnly)
 self.assertTrue(error.Success())
 self.assertTrue(os.path.isfile(core_sb_dirty))
 self.verify_core_file(
-core_sb_dirty, expected_pid, expected_modules, 
expected_threads, stacks_to_sp_map
+core_sb_dirty,
+expected_pid,
+expected_modules,
+expected_threads,
+stacks_to_sp_map,
 )
 
 # Minidump can now save full core files, but they will be huge and
 # they might cause this test to timeout.
 error = process.SaveCore(core_sb_full, "minidump", 
lldb.eSaveCoreFull)
 self.assertTrue(error.Success())
 self.assertTrue(os.path.isfile(core_sb_full))
 self.verify_core_file(
-core_sb_full, expected_pid, expected_modules, 
expected_threads, stacks_to_sp_map
+core_sb_full,
+expected_pid,
+expected_modules,
+expected_threads,
+stacks_to_sp_map,
 )
 
 self.assertSuccess(process.Kill())
 finally:
 # Clean up the mini dump file.

``




https://github.co

[Lldb-commits] [lldb] [LLDB/Coredump] Only take the Pthread from stack start to the stackpointer + red_zone (PR #92002)

2024-05-15 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 e3ca558ffb1441cb16da7aba021e12c6f11f 
25ff389fd2b1ca5caccfe239d8ab1bd166ee75cb -- 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
lldb/source/Target/Process.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 190c7670d1..1f0101bc01 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -491,8 +491,9 @@ findStackHelper(const lldb::ProcessSP &process_sp, uint64_t 
rsp) {
 return llvm::createStringError(
 std::errc::not_supported,
 "unable to load stack segment of the process");
-  // This is a duplicate of the logic in 
Process::SaveOffRegionsWithStackPointers
-  // but ultimately, we need to only save up from the start of `the stack down 
to the stack pointer.
+  // This is a duplicate of the logic in
+  // Process::SaveOffRegionsWithStackPointers but ultimately, we need to only
+  // save up from the start of `the stack down to the stack pointer.
   const addr_t range_end = range_info.GetRange().GetRangeEnd();
   const size_t red_zone = process_sp->GetABI()->GetRedZoneSize();
   const addr_t addr = rsp - red_zone;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6a3bfe0a6a..216d2f21ab 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6335,16 +6335,15 @@ static void AddRegion(const MemoryRegionInfo ®ion, 
bool try_dirty_pages,
   ranges.push_back(CreateCoreFileMemoryRange(region));
 }
 
-static void
-SaveOffRegionsWithStackPointers(Process &process,
-   const MemoryRegionInfos ®ions,
-   Process::CoreFileMemoryRanges &ranges,
-   std::set &stack_ends) {
+static void SaveOffRegionsWithStackPointers(
+Process &process, const MemoryRegionInfos ®ions,
+Process::CoreFileMemoryRanges &ranges, std::set &stack_ends) {
   const bool try_dirty_pages = true;
 
-  // Before we take any dump, we want to save off the used portions of the 
stacks
-  // and mark those memory regions as saved. This prevents us from saving the 
unused portion
-  // of the stack below the stack pointer. Saving space on the dump.
+  // Before we take any dump, we want to save off the used portions of the
+  // stacks and mark those memory regions as saved. This prevents us from 
saving
+  // the unused portion of the stack below the stack pointer. Saving space on
+  // the dump.
   for (lldb::ThreadSP thread_sp : process.GetThreadList().Threads()) {
 if (!thread_sp)
   continue;
@@ -6358,12 +6357,12 @@ SaveOffRegionsWithStackPointers(Process &process,
 const size_t red_zone = process.GetABI()->GetRedZoneSize();
 lldb_private::MemoryRegionInfo sp_region;
 if (process.GetMemoryRegionInfo(sp, sp_region).Success()) {
-const size_t stack_head = (sp - red_zone);
-const size_t stack_size = sp_region.GetRange().GetRangeEnd() - 
stack_head;
-sp_region.GetRange().SetRangeBase(stack_head);
-sp_region.GetRange().SetByteSize(stack_size);
-stack_ends.insert(sp_region.GetRange().GetRangeEnd());
-AddRegion(sp_region, try_dirty_pages, ranges);
+  const size_t stack_head = (sp - red_zone);
+  const size_t stack_size = sp_region.GetRange().GetRangeEnd() - 
stack_head;
+  sp_region.GetRange().SetRangeBase(stack_head);
+  sp_region.GetRange().SetByteSize(stack_size);
+  stack_ends.insert(sp_region.GetRange().GetRangeEnd());
+  AddRegion(sp_region, try_dirty_pages, ranges);
 }
   }
 }
@@ -6386,17 +6385,15 @@ const bool try_dirty_pages = false;
 // least some dirty pages, as some OS versions don't support reporting what
 // pages are dirty within an memory region. If no memory regions have dirty
 // page information fall back to saving out all ranges with write permissions.
-static void
-GetCoreFileSaveRangesDirtyOnly(Process &process,
-   const MemoryRegionInfos ®ions,
-   Process::CoreFileMemoryRanges &ranges,
-   std::set &stack_ends) {
+static void GetCoreFileSaveRangesDirtyOnly(
+Process &process, const MemoryRegionInfos ®ions,
+Process::CoreFileMemoryRanges &ranges, std::set &stack_ends) {
 
   // Iterate over the regions and find all dirty pages.
   bool have_dirty_page_info = false;
   for (const auto ®ion : regions) {
-if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0
-&& AddDirtyPages(region, ranges))
+if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0 &&
+AddD

[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-15 Thread via lldb-commits

https://github.com/jeffreytan81 commented:

Added another inline comment.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestFdLeak test (PR #92273)

2024-05-15 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

> Could this use `os.devnull`

Sure. It is much better. I have updated the patch. Thanks.

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


[Lldb-commits] [lldb] SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` (PR #89868)

2024-05-15 Thread via lldb-commits


@@ -1689,12 +1689,32 @@ void 
SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback,
 void SBDebugger::SetDestroyCallback(
 lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) {
   LLDB_INSTRUMENT_VA(this, destroy_callback, baton);
+
   if (m_opaque_sp) {
-return m_opaque_sp->SetDestroyCallback(
-destroy_callback, baton);
+m_opaque_sp->SetDestroyCallback(destroy_callback, baton);
   }

jeffreytan81 wrote:

Undo the unnecessary format change

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-15 Thread Santhosh Kumar Ellendula via lldb-commits

https://github.com/santhoshe447 updated 
https://github.com/llvm/llvm-project/pull/91570

>From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001
From: Santhosh Kumar Ellendula 
Date: Fri, 17 Nov 2023 15:09:10 +0530
Subject: [PATCH 1/7] [lldb][test] Add the ability to extract the variable
 value out of the summary.

---
 .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py   | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 9d79872b029a3..0cf9d4fde4948 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -195,6 +195,9 @@ def collect_console(self, duration):
 
 def get_local_as_int(self, name, threadId=None):
 value = self.dap_server.get_local_variable_value(name, 
threadId=threadId)
+# 'value' may have the variable value and summary.
+# Extract the variable value since summary can have nonnumeric 
characters.
+value = value.split(" ")[0]
 if value.startswith("0x"):
 return int(value, 16)
 elif value.startswith("0"):

>From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001
From: Santhosh Kumar Ellendula 
Date: Fri, 3 May 2024 02:47:05 -0700
Subject: [PATCH 2/7] [lldb-dap] Added "port" property to vscode "attach"
 command.

Adding a "port" property to the VsCode "attach" command likely extends the 
functionality of the debugger configuratiuon to allow attaching to a process 
using PID or PORT number.
Currently, the "Attach" configuration lets the user specify a pid. We tell the 
user to use the attachCommands property to run "gdb-remote ".
Followed the below conditions for "attach" command with "port" and "pid"
We should add a "port" property. If port is specified and pid is not, use that 
port to attach. If both port and pid are specified, return an error saying that 
the user can't specify both pid and port.

Ex - launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "lldb-dap Debug",
"type": "lldb-dap",
"request": "attach",
"port":1234,
"program": "${workspaceFolder}/a.out",
"args": [],
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"env": [],

}
]
}
---
 lldb/include/lldb/lldb-defines.h  |   1 +
 .../Python/lldbsuite/test/lldbtest.py |   9 ++
 .../test/tools/lldb-dap/dap_server.py |   6 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  20 +++
 .../attach/TestDAP_attachByPortNum.py | 120 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  36 +-
 lldb/tools/lldb-dap/package.json  |  11 ++
 7 files changed, 199 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py

diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h
index c7bd019c5c90e..a1e6ee2ce468c 100644
--- a/lldb/include/lldb/lldb-defines.h
+++ b/lldb/include/lldb/lldb-defines.h
@@ -96,6 +96,7 @@
 #define LLDB_INVALID_QUEUE_ID 0
 #define LLDB_INVALID_CPU_ID UINT32_MAX
 #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX
+#define LLDB_INVALID_PORT_NUMBER 0
 
 /// CPU Type definitions
 #define LLDB_ARCH_DEFAULT "systemArch"
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 5fd686c143e9f..fb3cd22959df2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1572,6 +1572,15 @@ def findBuiltClang(self):
 
 return os.environ["CC"]
 
+def getBuiltServerTool(self, server_tool):
+# Tries to find simulation/lldb-server/gdbserver tool at the same 
folder as the lldb.
+lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
+path = shutil.which(server_tool, path=lldb_dir)
+if path is not None:
+return path
+
+return ""
+
 def yaml2obj(self, yaml_path, obj_path, max_size=None):
 """
 Create an object file at the given path from a yaml file.
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 5838281bcb1a1..96d312565f953 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
@@ -568,6 +568,8 @@ def request_attach(
 coreFile=None,
 postRunCommands=None,
 sourceMap=None,
+port=None,
+hostname=None
 ):
 args_dict = {}
 if pid is not None:
@@ -597,6 +599,10 @@ def request_attach(
 args_dict["postRunCommands"] = postRunComman

[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

2024-05-15 Thread Zequan Wu via lldb-commits

ZequanWu wrote:

It actually still crashes at the same place even without this PR using the 
following command, you can try it on trunk:
```
$ rm -rf lldb/test/API/commands/expression/import-std-module/lldb-api/*
$ out/cmake/bin/lldb-dotest 
--lldb-module-cache-dir=out/cmake/lldb-test-build.noindex/module-cache-lldb/lldb-api
 lldb/test/API/commands/expression/import-std-module/
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9
 /Users/zequanwu/work/llvm/lldb/test/API/dotest.py --arch arm64 --build-dir 
/Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex --executable 
/Users/zequanwu/work/llvm/out/cmake/./bin/lldb --compiler 
/Users/zequanwu/work/llvm/out/cmake/./bin/clang --dsymutil 
/Users/zequanwu/work/llvm/out/cmake/./bin/dsymutil --lldb-libs-dir 
/Users/zequanwu/work/llvm/out/cmake/./lib --llvm-tools-dir 
/Users/zequanwu/work/llvm/out/cmake/./bin --libcxx-include-dir 
/Users/zequanwu/work/llvm/out/cmake/include/c++/v1 --libcxx-library-dir 
/Users/zequanwu/work/llvm/out/cmake/lib --lldb-obj-root 
/Users/zequanwu/work/llvm/out/cmake/tools/lldb 
--lldb-module-cache-dir=/Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/module-cache-lldb/lldb-api
 lldb/test/API/commands/expression/import-std-module/
lldb version 19.0.0git (g...@github.com:ZequanWu/llvm-project.git revision 
71fbbb69d63c461f391cbabf1e32cd9977c4ce68)
  clang revision 71fbbb69d63c461f391cbabf1e32cd9977c4ce68
  llvm revision 71fbbb69d63c461f391cbabf1e32cd9977c4ce68
Skipping the following test categories: ['libstdcxx', 'dwo', 'llgs', 'fork']
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dsym 
(TestDbgInfoContentForwardListFromStdModule.TestDbgInfoContentForwardList)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dwarf 
(TestDbgInfoContentForwardListFromStdModule.TestDbgInfoContentForwardList)
UNSUPPORTED: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: 
test_dwo 
(TestDbgInfoContentForwardListFromStdModule.TestDbgInfoContentForwardList) 
(test case does not fall in any category of interest for this run)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dsym 
(TestForwardListFromStdModule.TestBasicForwardList)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dwarf 
(TestForwardListFromStdModule.TestBasicForwardList)
UNSUPPORTED: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: 
test_dwo (TestForwardListFromStdModule.TestBasicForwardList) (test case does 
not fall in any category of interest for this run)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dsym 
(TestRetryWithStdModule.TestCase)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dwarf 
(TestRetryWithStdModule.TestCase)
UNSUPPORTED: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: 
test_dwo (TestRetryWithStdModule.TestCase) (test case does not fall in any 
category of interest for this run)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dsym 
(TestSharedPtrFromStdModule.TestSharedPtr)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dwarf 
(TestSharedPtrFromStdModule.TestSharedPtr)
UNSUPPORTED: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: 
test_dwo (TestSharedPtrFromStdModule.TestSharedPtr) (test case does not fall in 
any category of interest for this run)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dsym 
(TestEmptyStdModule.ImportStdModule)
PASS: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: test_dwarf 
(TestEmptyStdModule.ImportStdModule)
UNSUPPORTED: LLDB (/Users/zequanwu/work/llvm/out/cmake/bin/clang-arm64) :: 
test_dwo (TestEmptyStdModule.ImportStdModule) (test case does not fall in any 
category of interest for this run)
Assertion failed: (0 && "Invalid SLocOffset or bad function choice"), function 
getFileIDLoaded, file SourceManager.cpp, line 865.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
```

But I don't know why this change will make this crash explicitly shows up when 
running check-lldb.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestFdLeak test (PR #92273)

2024-05-15 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

2024-05-15 Thread Santhosh Kumar Ellendula via lldb-commits

https://github.com/santhoshe447 updated 
https://github.com/llvm/llvm-project/pull/91570

>From 960351c9abf51f42d92604ac6297aa5b76ddfba5 Mon Sep 17 00:00:00 2001
From: Santhosh Kumar Ellendula 
Date: Fri, 17 Nov 2023 15:09:10 +0530
Subject: [PATCH 1/8] [lldb][test] Add the ability to extract the variable
 value out of the summary.

---
 .../Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py   | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 9d79872b029a3..0cf9d4fde4948 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -195,6 +195,9 @@ def collect_console(self, duration):
 
 def get_local_as_int(self, name, threadId=None):
 value = self.dap_server.get_local_variable_value(name, 
threadId=threadId)
+# 'value' may have the variable value and summary.
+# Extract the variable value since summary can have nonnumeric 
characters.
+value = value.split(" ")[0]
 if value.startswith("0x"):
 return int(value, 16)
 elif value.startswith("0"):

>From ab44a6991c5bc8ac5764c3f71cbe3acc747b3776 Mon Sep 17 00:00:00 2001
From: Santhosh Kumar Ellendula 
Date: Fri, 3 May 2024 02:47:05 -0700
Subject: [PATCH 2/8] [lldb-dap] Added "port" property to vscode "attach"
 command.

Adding a "port" property to the VsCode "attach" command likely extends the 
functionality of the debugger configuratiuon to allow attaching to a process 
using PID or PORT number.
Currently, the "Attach" configuration lets the user specify a pid. We tell the 
user to use the attachCommands property to run "gdb-remote ".
Followed the below conditions for "attach" command with "port" and "pid"
We should add a "port" property. If port is specified and pid is not, use that 
port to attach. If both port and pid are specified, return an error saying that 
the user can't specify both pid and port.

Ex - launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "lldb-dap Debug",
"type": "lldb-dap",
"request": "attach",
"port":1234,
"program": "${workspaceFolder}/a.out",
"args": [],
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"env": [],

}
]
}
---
 lldb/include/lldb/lldb-defines.h  |   1 +
 .../Python/lldbsuite/test/lldbtest.py |   9 ++
 .../test/tools/lldb-dap/dap_server.py |   6 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  20 +++
 .../attach/TestDAP_attachByPortNum.py | 120 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  36 +-
 lldb/tools/lldb-dap/package.json  |  11 ++
 7 files changed, 199 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py

diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h
index c7bd019c5c90e..a1e6ee2ce468c 100644
--- a/lldb/include/lldb/lldb-defines.h
+++ b/lldb/include/lldb/lldb-defines.h
@@ -96,6 +96,7 @@
 #define LLDB_INVALID_QUEUE_ID 0
 #define LLDB_INVALID_CPU_ID UINT32_MAX
 #define LLDB_INVALID_WATCHPOINT_RESOURCE_ID UINT32_MAX
+#define LLDB_INVALID_PORT_NUMBER 0
 
 /// CPU Type definitions
 #define LLDB_ARCH_DEFAULT "systemArch"
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 5fd686c143e9f..fb3cd22959df2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1572,6 +1572,15 @@ def findBuiltClang(self):
 
 return os.environ["CC"]
 
+def getBuiltServerTool(self, server_tool):
+# Tries to find simulation/lldb-server/gdbserver tool at the same 
folder as the lldb.
+lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
+path = shutil.which(server_tool, path=lldb_dir)
+if path is not None:
+return path
+
+return ""
+
 def yaml2obj(self, yaml_path, obj_path, max_size=None):
 """
 Create an object file at the given path from a yaml file.
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 5838281bcb1a1..96d312565f953 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
@@ -568,6 +568,8 @@ def request_attach(
 coreFile=None,
 postRunCommands=None,
 sourceMap=None,
+port=None,
+hostname=None
 ):
 args_dict = {}
 if pid is not None:
@@ -597,6 +599,10 @@ def request_attach(
 args_dict["postRunCommands"] = postRunComman

[Lldb-commits] [lldb] 0585eed - [lldb-dap] Support publishing to the VSCode market place (#92320)

2024-05-15 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-05-15T15:44:05-07:00
New Revision: 0585eed9409c1362f7deaabc42c1d3c3f55c4b6c

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

LOG: [lldb-dap] Support publishing to the VSCode market place (#92320)

Update the publisher and add a publish script that we can use from
Github actions.

Added: 


Modified: 
lldb/tools/lldb-dap/package.json

Removed: 




diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index 2e8ad074256bf..aeb24445551c1 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -2,7 +2,7 @@
   "name": "lldb-dap",
   "displayName": "LLDB DAP",
   "version": "0.2.0",
-  "publisher": "llvm",
+  "publisher": "llvm-vs-code-extensions",
   "homepage": "https://lldb.llvm.org";,
   "description": "LLDB debugging from VSCode",
   "license": "Apache 2.0 License with LLVM exceptions",
@@ -42,6 +42,7 @@
 "watch": "tsc -watch -p ./",
 "format": "npx prettier './src-ts/' --write",
 "package": "vsce package --out ./out/lldb-dap.vsix",
+"publish": "vsce publish",
 "vscode-uninstall": "code --uninstall-extension llvm.lldb-dap",
 "vscode-install": "code --install-extension ./out/lldb-dap.vsix"
   },



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


[Lldb-commits] [lldb] [lldb-dap] Support publishing to the VSCode market place (PR #92320)

2024-05-15 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)

2024-05-15 Thread Zequan Wu via lldb-commits

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

This reapplies 
https://github.com/llvm/llvm-project/commit/9a7262c2601874e5aa64c5db19746770212d4b44
 and 
https://github.com/llvm/llvm-project/commit/a7eff59f78f08f8ef0487dfe2a136fb311af4fd0
 with a fix.

It was causing tests on macos to fail because 
`SymbolFileDWARF::GetForwardDeclCompilerTypeToDIE` returned the map owned by 
this symol file. When there were two symbol files, two different maps were 
created for caching from compiler type to DIE even if they are for the same 
module. The solution is to do the same as 
`SymbolFileDWARF::GetUniqueDWARFASTTypeMap`: inquery SymbolFileDWARFDebugMap 
first to get the shared underlying SymbolFile so the map is shared among 
multiple SymbolFileDWARF.

>From d6de8d9a8bc709b5c4761e9a05f9befede938734 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Wed, 15 May 2024 13:58:42 -0400
Subject: [PATCH 1/2] Reapply [lldb][DWARF] Delay struct/class/union definition
 DIE searching when parsing declaration DIEs.

This reapplies 9a7262c2601874e5aa64c5db19746770212d4b44 and 
a7eff59f78f08f8ef0487dfe2a136fb311af4fd0 with a fix.

It was causing tests on macos to fail because 
`SymbolFileDWARF::GetForwardDeclCompilerTypeToDIE` returned the map owned by 
this symol file. When there were two symbol files, two different maps were 
created for caching from compiler type to DIE even if they are for the same 
module. The solution is to do the same as 
`SymbolFileDWARF::GetUniqueDWARFASTTypeMap`: inquery SymbolFileDWARFDebugMap 
first to get the shared underlying SymbolFile so the map is shared among 
multiple SymbolFileDWARF.
---
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |   2 +
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 402 ++
 .../SymbolFile/DWARF/DWARFASTParserClang.h| 197 -
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  44 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   7 +-
 .../SymbolFile/DWARF/UniqueDWARFASTType.cpp   | 107 ++---
 .../SymbolFile/DWARF/UniqueDWARFASTType.h |  36 +-
 .../delayed-definition-die-searching.test |  36 ++
 8 files changed, 447 insertions(+), 384 deletions(-)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/delayed-definition-die-searching.test

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 66db396279e06..e144cf0f9bd94 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -60,6 +60,8 @@ class DWARFASTParser {
 
   virtual ConstString GetDIEClassTemplateParams(const DWARFDIE &die) = 0;
 
+  virtual lldb_private::Type *FindDefinitionTypeForDIE(const DWARFDIE &die) = 
0;
+
   static std::optional
   ParseChildArrayInfo(const DWARFDIE &parent_die,
   const ExecutionContext *exe_ctx = nullptr);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f8101aba5c627..2a46be9216121 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -154,6 +154,26 @@ static bool TagIsRecordType(dw_tag_t tag) {
   }
 }
 
+static bool IsForwardDeclaration(const DWARFDIE &die,
+ const ParsedDWARFTypeAttributes &attrs,
+ LanguageType cu_language) {
+  if (attrs.is_forward_declaration)
+return true;
+
+  // Work around an issue with clang at the moment where forward
+  // declarations for objective C classes are emitted as:
+  //  DW_TAG_structure_type [2]
+  //  DW_AT_name( "ForwardObjcClass" )
+  //  DW_AT_byte_size( 0x00 )
+  //  DW_AT_decl_file( "..." )
+  //  DW_AT_decl_line( 1 )
+  //
+  // Note that there is no DW_AT_declaration and there are no children,
+  // and the byte size is zero.
+  return attrs.byte_size && *attrs.byte_size == 0 && attrs.name &&
+ !die.HasChildren() && cu_language == eLanguageTypeObjC;
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,
  Log *log) {
@@ -249,11 +269,9 @@ static void ForcefullyCompleteType(CompilerType type) {
 /// This function serves a similar purpose as RequireCompleteType above, but it
 /// avoids completing the type if it is not immediately necessary. It only
 /// ensures we _can_ complete the type later.
-static void PrepareContextToReceiveMembers(TypeSystemClang &ast,
-   ClangASTImporter &ast_importer,
-   clang::DeclContext *decl_ctx,
-   DWARFDIE die,
-   const char *type_name_cstr) {
+void DWARFASTParserClang::PrepareContextToReceiveMember

[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)

2024-05-15 Thread Zequan Wu via lldb-commits

ZequanWu wrote:

The second commit is the fix.

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


[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)

2024-05-15 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Zequan Wu (ZequanWu)


Changes

This reapplies 
https://github.com/llvm/llvm-project/commit/9a7262c2601874e5aa64c5db19746770212d4b44
 and 
https://github.com/llvm/llvm-project/commit/a7eff59f78f08f8ef0487dfe2a136fb311af4fd0
 with a fix.

It was causing tests on macos to fail because 
`SymbolFileDWARF::GetForwardDeclCompilerTypeToDIE` returned the map owned by 
this symol file. When there were two symbol files, two different maps were 
created for caching from compiler type to DIE even if they are for the same 
module. The solution is to do the same as 
`SymbolFileDWARF::GetUniqueDWARFASTTypeMap`: inquery SymbolFileDWARFDebugMap 
first to get the shared underlying SymbolFile so the map is shared among 
multiple SymbolFileDWARF.

---

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


11 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h (+2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(+223-179) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
(+88-109) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+32-19) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+8-7) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h 
(+9) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (+2-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp 
(+54-53) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h (+13-23) 
- (added) 
lldb/test/Shell/SymbolFile/DWARF/delayed-definition-die-searching.test (+36) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 66db396279e06..e144cf0f9bd94 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -60,6 +60,8 @@ class DWARFASTParser {
 
   virtual ConstString GetDIEClassTemplateParams(const DWARFDIE &die) = 0;
 
+  virtual lldb_private::Type *FindDefinitionTypeForDIE(const DWARFDIE &die) = 
0;
+
   static std::optional
   ParseChildArrayInfo(const DWARFDIE &parent_die,
   const ExecutionContext *exe_ctx = nullptr);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f8101aba5c627..2a46be9216121 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -154,6 +154,26 @@ static bool TagIsRecordType(dw_tag_t tag) {
   }
 }
 
+static bool IsForwardDeclaration(const DWARFDIE &die,
+ const ParsedDWARFTypeAttributes &attrs,
+ LanguageType cu_language) {
+  if (attrs.is_forward_declaration)
+return true;
+
+  // Work around an issue with clang at the moment where forward
+  // declarations for objective C classes are emitted as:
+  //  DW_TAG_structure_type [2]
+  //  DW_AT_name( "ForwardObjcClass" )
+  //  DW_AT_byte_size( 0x00 )
+  //  DW_AT_decl_file( "..." )
+  //  DW_AT_decl_line( 1 )
+  //
+  // Note that there is no DW_AT_declaration and there are no children,
+  // and the byte size is zero.
+  return attrs.byte_size && *attrs.byte_size == 0 && attrs.name &&
+ !die.HasChildren() && cu_language == eLanguageTypeObjC;
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,
  Log *log) {
@@ -249,11 +269,9 @@ static void ForcefullyCompleteType(CompilerType type) {
 /// This function serves a similar purpose as RequireCompleteType above, but it
 /// avoids completing the type if it is not immediately necessary. It only
 /// ensures we _can_ complete the type later.
-static void PrepareContextToReceiveMembers(TypeSystemClang &ast,
-   ClangASTImporter &ast_importer,
-   clang::DeclContext *decl_ctx,
-   DWARFDIE die,
-   const char *type_name_cstr) {
+void DWARFASTParserClang::PrepareContextToReceiveMembers(
+clang::DeclContext *decl_ctx, const DWARFDIE &decl_ctx_die,
+const DWARFDIE &die, const char *type_name_cstr) {
   auto *tag_decl_ctx = clang::dyn_cast(decl_ctx);
   if (!tag_decl_ctx)
 return; // Non-tag context are always ready.
@@ -268,7 +286,8 @@ static void PrepareContextToReceiveMembers(TypeSystemClang 
&ast,
   // gmodules case), we can complete the type by doing a full import.
 
   // If this type was not

  1   2   >