[Lldb-commits] [PATCH] D122974: prevent ConstString from calling djbHash() more than once

2022-06-27 Thread Luboš Luňák via Phabricator via lldb-commits
llunak added a comment.

Ping.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122974/new/

https://reviews.llvm.org/D122974

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


[Lldb-commits] [lldb] fe6db8d - Revert "[lldb] Fix thread step until to not set breakpoint(s) on incorrect line numbers"

2022-06-27 Thread Mikhail Goncharov via lldb-commits

Author: Mikhail Goncharov
Date: 2022-06-27T10:18:39+02:00
New Revision: fe6db8d03ff16a65f57af24d2cb04f489e2e9b0c

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

LOG: Revert "[lldb] Fix thread step until to not set breakpoint(s) on incorrect 
line numbers"

This reverts commit a57b62deef37c7f2ec31bca3bf9173a6206bfb9b.

lldb-aarch64-ubuntu buildbot test fails since 
https://lab.llvm.org/buildbot/#/builders/96/builds/25128

Added: 


Modified: 
lldb/source/Commands/CommandObjectThread.cpp
lldb/test/API/functionalities/thread/step_until/TestStepUntil.py

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectThread.cpp 
b/lldb/source/Commands/CommandObjectThread.cpp
index 9396c3615497..037bbafdf894 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -1033,21 +1033,11 @@ class CommandObjectThreadUntil : public 
CommandObjectParsed {
 line_table->FindLineEntryByAddress(fun_end_addr, function_start,
&end_ptr);
 
-// Since not all source lines will contribute code, check if we are
-// setting the breakpoint on the exact line number or the nearest
-// subsequent line number and set breakpoints at all the line table
-// entries of the chosen line number (exact or nearest subsequent).
 for (uint32_t line_number : line_numbers) {
-  LineEntry line_entry;
-  bool exact = false;
   uint32_t start_idx_ptr = index_ptr;
-  start_idx_ptr = sc.comp_unit->FindLineEntry(
-  index_ptr, line_number, nullptr, exact, &line_entry);
-  if (start_idx_ptr != UINT32_MAX)
-line_number = line_entry.line;
-  exact = true;
-  start_idx_ptr = index_ptr;
   while (start_idx_ptr <= end_ptr) {
+LineEntry line_entry;
+const bool exact = false;
 start_idx_ptr = sc.comp_unit->FindLineEntry(
 start_idx_ptr, line_number, nullptr, exact, &line_entry);
 if (start_idx_ptr == UINT32_MAX)

diff  --git a/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py 
b/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
index ee25d1343735..0145b34f31de 100644
--- a/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
+++ b/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
@@ -19,7 +19,7 @@ def setUp(self):
 self.greater_than_two = line_number('main.c', 'Greater than or equal 
to 2.')
 self.back_out_in_main = line_number('main.c', 'Back out in main')
 
-def common_setup (self, args):
+def do_until (self, args, until_lines, expected_linenum):
 self.build()
 exe = self.getBuildArtifact("a.out")
 
@@ -48,8 +48,7 @@ def common_setup (self, args):
 thread = threads[0]
 return thread
 
-def do_until (self, args, until_lines, expected_linenum):
-thread = self.common_setup(args)
+thread = self.common_setup(None)
 
 cmd_interp = self.dbg.GetCommandInterpreter()
 ret_obj = lldb.SBCommandReturnObject()
@@ -78,7 +77,7 @@ def test_targetting_two_hitting_second (self):
 self.do_until(None, [self.less_than_two, self.greater_than_two], 
self.less_than_two)
 
 def test_missing_one (self):
-"""Test thread step until - targeting one line and missing it by 
stepping out to call site"""
+"""Test thread step until - targeting one line and missing it."""
 self.do_until(["foo", "bar", "baz"], [self.less_than_two], 
self.back_out_in_main)
 
 



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


[Lldb-commits] [PATCH] D50304: [lldb] Fix thread step until to not set breakpoint(s) on incorrect line numbers

2022-06-27 Thread Mikhail Goncharov via Phabricator via lldb-commits
goncharov added a comment.

FYI this caused a test breakage at lldb-aarch64-ubuntu, 
https://lab.llvm.org/buildbot/#/builders/96/builds/25128. I have reverted this 
in fe6db8d03ff16a65f57af24d2cb04f489e2e9b0c 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50304/new/

https://reviews.llvm.org/D50304

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


[Lldb-commits] [PATCH] D128221: [LLDB] Add Arm64 CodeView to LLDB regnum mapping

2022-06-27 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp:51
+gpr_w27_arm64, // ARM64_W27, 37)
+gpr_w28_arm64, // ARM64_W28, 38)
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,

Is there a reason W29/W30/WZR are missing here?



Comment at: 
lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp:88
+gpr_sp_arm64,  // ARM64_SP, 81)
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,

ARM64_ZR here? Though they're the same encoding in the instructions so it 
probably doesn't change much.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128221/new/

https://reviews.llvm.org/D128221

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


[Lldb-commits] [PATCH] D128638: [lldb] [llgs] Add nonstop fork/vfork tests

2022-06-27 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

BTW this test is getting a bit long as well but I don't have a good idea how to 
split it, except for just moving some functions into a second file and making 
some reusable base class.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128638/new/

https://reviews.llvm.org/D128638

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


[Lldb-commits] [PATCH] D128639: [lldb] [llgs] Fix premature server exit if multiprocess+nonstop

2022-06-27 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Fix lldb-server in the non-stop + multiprocess mode to exit on vStopped
only if all processes have exited, rather than when the first one exits.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D128639

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py


Index: lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -392,17 +392,17 @@
 def test_vkill_both_nonstop(self):
 self.vkill_test(kill_parent=True, kill_child=True, nonstop=True)
 
-def resume_one_test(self, run_order, use_vCont=False):
+def resume_one_test(self, run_order, use_vCont=False, nonstop=False):
 parent_pid, parent_tid, child_pid, child_tid = (
-self.start_fork_test(["fork", "trap"]))
+self.start_fork_test(["fork", "trap"], nonstop=nonstop))
 
 parent_expect = [
-"[$]T05thread:p{}.{};.*".format(parent_pid, parent_tid),
-"[$]W00;process:{}#.*".format(parent_pid),
+"T05thread:p{}.{};.*".format(parent_pid, parent_tid),
+"W00;process:{}#.*".format(parent_pid),
 ]
 child_expect = [
-"[$]T05thread:p{}.{};.*".format(child_pid, child_tid),
-"[$]W00;process:{}#.*".format(child_pid),
+"T05thread:p{}.{};.*".format(child_pid, child_tid),
+"W00;process:{}#.*".format(child_pid),
 ]
 
 for x in run_order:
@@ -427,9 +427,17 @@
 "send packet: $OK#00",
 "read packet: $c#00",
 ], True)
-self.test_sequence.add_log_lines([
-{"direction": "send", "regex": expect},
-], True)
+if nonstop:
+self.test_sequence.add_log_lines([
+"send packet: $OK#00",
+{"direction": "send", "regex": "%Stop:" + expect},
+"read packet: $vStopped#00",
+"send packet: $OK#00",
+], True)
+else:
+self.test_sequence.add_log_lines([
+{"direction": "send", "regex": "[$]" + expect},
+], True)
 # if at least one process remained, check both PIDs
 if parent_expect or child_expect:
 self.test_sequence.add_log_lines([
@@ -460,6 +468,11 @@
 def test_c_interspersed(self):
 self.resume_one_test(run_order=["parent", "child", "parent", "child"])
 
+@add_test_categories(["fork"])
+def test_c_interspersed_nonstop(self):
+self.resume_one_test(run_order=["parent", "child", "parent", "child"],
+ nonstop=True)
+
 @add_test_categories(["fork"])
 def test_vCont_parent(self):
 self.resume_one_test(run_order=["parent", "parent"], use_vCont=True)
@@ -483,6 +496,11 @@
 self.resume_one_test(run_order=["parent", "child", "parent", "child"],
  use_vCont=True)
 
+@add_test_categories(["fork"])
+def test_vCont_interspersed_nonstop(self):
+self.resume_one_test(run_order=["parent", "child", "parent", "child"],
+ use_vCont=True, nonstop=True)
+
 @add_test_categories(["fork"])
 def test_vCont_two_processes(self):
 parent_pid, parent_tid, child_pid, child_tid = (
Index: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3871,9 +3871,9 @@
   m_stop_notification_queue.pop_front();
   if (!m_stop_notification_queue.empty())
 return SendPacketNoLock(m_stop_notification_queue.front());
-  // If this was the last notification and the process exited, terminate
-  // the server.
-  if (m_inferior_prev_state == eStateExited) {
+  // If this was the last notification and all the processes exited,
+  // terminate the server.
+  if (m_debugged_processes.empty()) {
 m_exit_now = true;
 m_mainloop.RequestTermination();
   }


Index: lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -392,17 +392,17 @@
 def test_vkill_both_nonstop(self):
 self.vkill_test(kill_parent=True, kill_child=True, nonstop=True)
 
-def resume_one_test(se

[Lldb-commits] [PATCH] D128638: [lldb] [llgs] Add nonstop fork/vfork tests

2022-06-27 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D128638

Files:
  lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py

Index: lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -9,10 +9,12 @@
 
 fork_regex = ("[$]T05thread:p([0-9a-f]+)[.]([0-9a-f]+);.*"
   "{}:p([0-9a-f]+)[.]([0-9a-f]+).*")
+fork_regex_nonstop = ("%Stop:T05thread:p([0-9a-f]+)[.]([0-9a-f]+);.*"
+  "{}:p([0-9a-f]+)[.]([0-9a-f]+).*")
 fork_capture = {1: "parent_pid", 2: "parent_tid",
 3: "child_pid", 4: "child_tid"}
 
-def start_fork_test(self, args, variant="fork"):
+def start_fork_test(self, args, variant="fork", nonstop=False):
 self.build()
 self.prep_debug_monitor_and_inferior(inferior_args=args)
 self.add_qSupported_packets(["multiprocess+",
@@ -22,11 +24,24 @@
 self.reset_test_sequence()
 
 # continue and expect fork
-self.test_sequence.add_log_lines([
-"read packet: $c#00",
-{"direction": "send", "regex": self.fork_regex.format(variant),
- "capture": self.fork_capture},
-], True)
+if nonstop:
+self.test_sequence.add_log_lines([
+"read packet: $QNonStop:1#00",
+"send packet: $OK#00",
+"read packet: $c#00",
+"send packet: $OK#00",
+{"direction": "send",
+ "regex": self.fork_regex_nonstop.format(variant),
+ "capture": self.fork_capture},
+"read packet: $vStopped#00",
+"send packet: $OK#00",
+], True)
+else:
+self.test_sequence.add_log_lines([
+"read packet: $c#00",
+{"direction": "send", "regex": self.fork_regex.format(variant),
+ "capture": self.fork_capture},
+], True)
 ret = self.expect_gdbremote_sequence()
 self.reset_test_sequence()
 
@@ -45,9 +60,9 @@
 ], True)
 self.expect_gdbremote_sequence()
 
-def fork_and_detach_test(self, variant):
+def fork_and_detach_test(self, variant, nonstop=False):
 parent_pid, parent_tid, child_pid, child_tid = (
-self.start_fork_test([variant], variant))
+self.start_fork_test([variant], variant, nonstop=nonstop))
 
 # detach the forked child
 self.test_sequence.add_log_lines([
@@ -77,6 +92,20 @@
 ], True)
 self.expect_gdbremote_sequence()
 
+@add_test_categories(["fork"])
+def test_fork_nonstop(self):
+parent_pid, _ = self.fork_and_detach_test("fork", nonstop=True)
+
+# resume the parent
+self.test_sequence.add_log_lines([
+"read packet: $c#00",
+"send packet: $OK#00",
+"send packet: %Stop:W00;process:{}#00".format(parent_pid),
+"read packet: $vStopped#00",
+"send packet: $OK#00",
+], True)
+self.expect_gdbremote_sequence()
+
 @add_test_categories(["fork"])
 def test_vfork(self):
 parent_pid, parent_tid = self.fork_and_detach_test("vfork")
@@ -93,9 +122,32 @@
 ], True)
 self.expect_gdbremote_sequence()
 
-def fork_and_follow_test(self, variant):
+@add_test_categories(["fork"])
+def test_vfork_nonstop(self):
+parent_pid, parent_tid = self.fork_and_detach_test("vfork",
+   nonstop=True)
+
+# resume the parent
+self.test_sequence.add_log_lines([
+"read packet: $c#00",
+"send packet: $OK#00",
+{"direction": "send",
+ "regex": r"%Stop:T05thread:p{}[.]{}.*vforkdone.*".format(
+ parent_pid, parent_tid),
+ },
+"read packet: $vStopped#00",
+"send packet: $OK#00",
+"read packet: $c#00",
+"send packet: $OK#00",
+"send packet: %Stop:W00;process:{}#00".format(parent_pid),
+"read packet: $vStopped#00",
+"send packet: $OK#00",
+], True)
+self.expect_gdbremote_sequence()
+
+def fork_and_follow_test(self, variant, nonstop=False):
 parent_pid, parent_tid, child_pid, child_tid = (
-self.start_fork_test([variant], variant))
+self.start_fork_test([variant], variant, nonstop=nonstop))
 
 # switch to the forked child
 self.test_sequence.add_log_lines([
@@ -113,18 +165,37 @@
 "send packet: $OK#00",
 # then resume the child
 

[Lldb-commits] [PATCH] D128557: [lldb] Add a log dump command to dump the circular log buffer

2022-06-27 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

In D128557#3609545 , @JDevlieghere 
wrote:

> One solution would be to keep a circular buffer per category. I'll think 
> about it and if I come up with a good solution I'll put up another patch.

This isn't completely trivial, because there it's not possible to associate 
each log message with a specific log category -- `GetLog(FOO | BAR)` will 
return a log object if either of the two categories are set. So we'd either 
need to attach a set of categories to each log message, give up the 
multi-category messages, or do something more complicated...




Comment at: lldb/test/API/commands/log/basic/TestLogHandlers.py:20
+
+self.runCmd("log enable -b 5 -h circular lldb commands")
+self.runCmd("bogus", check=False)

clayborg wrote:
> Do we want to test that non circular buffers can't be dumped too to make sure 
> nothing goes wrong or that we get a good error message stating that this log 
> channel isn't circular?
Is that done? I would expect to see a test which runs something like "log 
enable -h XXX" and then checks that "log dump" errors out with something like 
"log handler XXX does not support dumping"...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128557/new/

https://reviews.llvm.org/D128557

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


[Lldb-commits] [PATCH] D126983: [lldb] [llgs] Support "t" vCont action

2022-06-27 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4f2d7cde54c: [lldb] [llgs] Support "t" vCont 
action (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126983/new/

https://reviews.llvm.org/D126983

Files:
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py
  lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
  lldb/test/API/tools/lldb-server/vCont-threads/main.cpp

Index: lldb/test/API/tools/lldb-server/vCont-threads/main.cpp
===
--- lldb/test/API/tools/lldb-server/vCont-threads/main.cpp
+++ lldb/test/API/tools/lldb-server/vCont-threads/main.cpp
@@ -22,7 +22,10 @@
 
 static void thread_func() {
   pseudo_barrier_wait(barrier);
-  std::this_thread::sleep_for(std::chrono::minutes(1));
+  for (int i = 0; i < 300; ++i) {
+std::printf("thread %" PRIx64 " running\n", get_thread_id());
+std::this_thread::sleep_for(std::chrono::milliseconds(200));
+  }
 }
 
 int main(int argc, char **argv) {
Index: lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
===
--- lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
+++ lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
@@ -1,5 +1,6 @@
 import json
 import re
+import time
 
 import gdbremote_testcase
 from lldbsuite.test.decorators import *
@@ -13,8 +14,7 @@
 # start the process and wait for output
 self.test_sequence.add_log_lines([
 "read packet: $c#63",
-{"type": "output_match", "regex": self.maybe_strict_output_regex(
-r"@started\r\n")},
+{"type": "output_match", "regex": r".*@started\r\n.*"},
 ], True)
 # then interrupt it
 self.add_interrupt_packets()
@@ -33,9 +33,8 @@
 self.test_sequence.add_log_lines([
 "read packet: $vCont;{0}#00".format(vCont_data),
 {"type": "output_match",
- "regex": self.maybe_strict_output_regex(
- len(threads) *
- r"received SIGUSR1 on thread id: ([0-9a-f]+)\r\n"),
+ "regex": len(threads) *
+  r".*received SIGUSR1 on thread id: ([0-9a-f]+)\r\n.*",
  "capture": dict((i, "tid{0}".format(i)) for i
  in range(1, len(threads)+1)),
  },
@@ -243,3 +242,71 @@
 
 context = self.expect_gdbremote_sequence()
 self.assertIsNotNone(context)
+
+THREAD_MATCH_RE = re.compile(r"thread ([0-9a-f]+) running")
+
+def continue_and_get_threads_running(self, continue_packet):
+self.test_sequence.add_log_lines(
+["read packet: ${}#00".format(continue_packet),
+ ], True)
+self.expect_gdbremote_sequence()
+self.reset_test_sequence()
+time.sleep(1)
+self.add_interrupt_packets()
+exp = self.expect_gdbremote_sequence()
+found = set()
+for line in exp["O_content"].decode().splitlines():
+m = self.THREAD_MATCH_RE.match(line)
+if m is not None:
+found.add(int(m.group(1), 16))
+return found
+
+@add_test_categories(["llgs"])
+def test_vCont_run_subset_of_threads(self):
+self.build()
+self.set_inferior_startup_launch()
+
+threads = set(self.start_threads(3))
+all_subthreads = self.continue_and_get_threads_running("c")
+all_subthreads_list = list(all_subthreads)
+self.assertEqual(len(all_subthreads), 3)
+self.assertEqual(threads & all_subthreads, all_subthreads)
+
+# resume two threads explicitly, stop the third one implicitly
+self.assertEqual(
+self.continue_and_get_threads_running(
+"vCont;c:{:x};c:{:x}".format(*all_subthreads_list[:2])),
+set(all_subthreads_list[:2]))
+
+# resume two threads explicitly, stop others explicitly
+self.assertEqual(
+self.continue_and_get_threads_running(
+"vCont;c:{:x};c:{:x};t".format(*all_subthreads_list[:2])),
+set(all_subthreads_list[:2]))
+
+# stop one thread explicitly, resume others
+self.assertEqual(
+self.continue_and_get_threads_running(
+"vCont;t:{:x};c".format(all_subthreads_list[-1])),
+set(all_subthreads_list[:2]))
+
+# resume one thread explicitly, stop one explicitly,
+# resume others
+self.assertEqual(
+self.continue_and_get_threads_running(
+"vCont;c:{:x};t:{:x};c".fo

[Lldb-commits] [lldb] b4f2d7c - [lldb] [llgs] Support "t" vCont action

2022-06-27 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-06-27T17:33:59+02:00
New Revision: b4f2d7cde54c301f591a8e2a16135bb113c5e7ed

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

LOG: [lldb] [llgs] Support "t" vCont action

Implement support for the "t" action that is used to stop a thread.
Normally this action is used only in non-stop mode.  However, there's
no technical reason why it couldn't be also used in all-stop mode,
e.g. to express "resume all threads except ..." (`t:...;c`).

While at it, add a more complete test for vCont correctly resuming
a subset of program's threads.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D126983

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py
lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
lldb/test/API/tools/lldb-server/vCont-threads/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 5324a2c0bf51e..0fb4c691118b7 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -947,7 +947,7 @@ Status NativeProcessLinux::Resume(const ResumeActionList 
&resume_actions) {
 
 case eStateSuspended:
 case eStateStopped:
-  llvm_unreachable("Unexpected state");
+  break;
 
 default:
   return Status("NativeProcessLinux::%s (): unexpected state %s specified "

diff  --git 
a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
index 10647839eec2e..a6d7500f41792 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -117,7 +117,7 @@ Status NativeProcessWindows::Resume(const ResumeActionList 
&resume_actions) {
   }
   case eStateSuspended:
   case eStateStopped:
-llvm_unreachable("Unexpected state");
+break;
 
   default:
 return Status(

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 2c009ef7fcd9a..ae8b8ef8ae156 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1654,7 +1654,7 @@ GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::Handle_vCont_actions(
 StringExtractorGDBRemote &packet) {
   StreamString response;
-  response.Printf("vCont;c;C;s;S");
+  response.Printf("vCont;c;C;s;S;t");
 
   return SendPacketNoLock(response.GetString());
 }
@@ -1723,6 +1723,11 @@ GDBRemoteCommunicationServerLLGS::Handle_vCont(
   thread_action.state = eStateStepping;
   break;
 
+case 't':
+  // Stop
+  thread_action.state = eStateSuspended;
+  break;
+
 default:
   return SendIllFormedResponse(packet, "Unsupported vCont action");
   break;

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py
index db1e39b9759d7..c17d0b7740dde 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py
@@ -39,6 +39,10 @@ def test_vCont_supports_S(self):
 self.build()
 self.vCont_supports_mode("S")
 
+def test_vCont_supports_t(self):
+self.build()
+self.vCont_supports_mode("t")
+
 @skipIfWindows # No pty support to test O* & I* notification packets.
 @skipIf(triple='^mips')
 def test_single_step_only_steps_one_instruction_with_Hc_vCont_s(self):

diff  --git 
a/lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py 
b/lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
index 30a136f127787..2a3275004e831 100644
--- 
a/lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
+++ 
b/lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
@@ -1,5 +1,6 @@
 import json
 import re
+import time
 
 import gdbremote_testcase
 from lldbsuite.test.decorators import *
@@ -13,8 +14,7 @@ def start_threads(self, num):
 # start the process and wait for output
 self.test_sequence.add_log_lines([
 "read packet: $c#63",
-{"type": "output_match", "regex": self.mayb

[Lldb-commits] [lldb] fe80829 - [lldb] [llgs] Skip new vCont test on Windows

2022-06-27 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-06-27T18:22:38+02:00
New Revision: fe80829289bf5462bff5d6739603e7040d07a391

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

LOG: [lldb] [llgs] Skip new vCont test on Windows

Sponsored by: The FreeBSD Foundation

Added: 


Modified: 
lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py 
b/lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
index 2a3275004e83..fd3deecd2fab 100644
--- 
a/lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
+++ 
b/lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
@@ -261,6 +261,7 @@ def continue_and_get_threads_running(self, continue_packet):
 found.add(int(m.group(1), 16))
 return found
 
+@skipIfWindows
 @add_test_categories(["llgs"])
 def test_vCont_run_subset_of_threads(self):
 self.build()



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


[Lldb-commits] [PATCH] D50304: [lldb] Fix thread step until to not set breakpoint(s) on incorrect line numbers

2022-06-27 Thread Venkata Ramanaiah Nalamothu via Phabricator via lldb-commits
RamNalamothu added a comment.

In D50304#3611390 , @goncharov wrote:

> FYI this caused a test breakage at lldb-aarch64-ubuntu, 
> https://lab.llvm.org/buildbot/#/builders/96/builds/25128. I have reverted 
> this in fe6db8d03ff16a65f57af24d2cb04f489e2e9b0c 
> 

Thank you.

Interestingly, the test is not failing for `x86-64` and `arm` but fails for 
only `aarch64`. I don't have an `aarch64' system and need to find an 
alternative way to get access to the system.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50304/new/

https://reviews.llvm.org/D50304

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


[Lldb-commits] [PATCH] D128557: [lldb] Add a log dump command to dump the circular log buffer

2022-06-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 440271.
JDevlieghere added a comment.

Print error message when dumping is not supported.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128557/new/

https://reviews.llvm.org/D128557

Files:
  lldb/include/lldb/Host/Host.h
  lldb/include/lldb/Utility/Log.h
  lldb/source/Commands/CommandObjectLog.cpp
  lldb/source/Commands/Options.td
  lldb/source/Host/common/Host.cpp
  lldb/source/Utility/Log.cpp
  lldb/test/API/commands/log/basic/TestLogHandlers.py

Index: lldb/test/API/commands/log/basic/TestLogHandlers.py
===
--- /dev/null
+++ lldb/test/API/commands/log/basic/TestLogHandlers.py
@@ -0,0 +1,55 @@
+"""
+Test lldb log handlers.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LogHandlerTestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+TestBase.setUp(self)
+self.log_file = self.getBuildArtifact("log-file.txt")
+if (os.path.exists(self.log_file)):
+os.remove(self.log_file)
+
+def test_circular(self):
+self.runCmd("log enable -b 5 -h circular lldb commands")
+self.runCmd("bogus", check=False)
+self.runCmd("log dump lldb -f {}".format(self.log_file))
+
+with open(self.log_file, 'r') as f:
+log_lines = f.readlines()
+
+self.assertEqual(len(log_lines), 5)
+
+found_command_log_dump = False
+found_command_bogus = False
+
+for line in log_lines:
+if 'Processing command: log dump' in line:
+found_command_log_dump = True
+if 'Processing command: bogus' in line:
+found_command_bogus = True
+
+self.assertTrue(found_command_log_dump)
+self.assertFalse(found_command_bogus)
+
+def test_circular_no_buffer_size(self):
+self.expect(
+"log enable -h circular lldb commands",
+error=True,
+substrs=[
+'the circular buffer handler requires a non-zero buffer size'
+])
+
+def test_dump_unsupported(self):
+self.runCmd("log enable lldb commands -f {}".format(self.log_file))
+self.expect("log dump lldb",
+error=True,
+substrs=["log channel 'lldb' does not support dumping"])
Index: lldb/source/Utility/Log.cpp
===
--- lldb/source/Utility/Log.cpp
+++ lldb/source/Utility/Log.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator.h"
 
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Chrono.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
@@ -34,6 +35,11 @@
 
 using namespace lldb_private;
 
+char LogHandler::ID;
+char StreamLogHandler::ID;
+char CallbackLogHandler::ID;
+char RotatingLogHandler::ID;
+
 llvm::ManagedStatic Log::g_channel_map;
 
 void Log::ForEachCategory(
@@ -106,6 +112,16 @@
   }
 }
 
+bool Log::Dump(llvm::raw_ostream &output_stream) {
+  llvm::sys::ScopedReader lock(m_mutex);
+  if (RotatingLogHandler *handler =
+  llvm::dyn_cast_or_null(m_handler.get())) {
+handler->Dump(output_stream);
+return true;
+  }
+  return false;
+}
+
 const Flags Log::GetOptions() const {
   return m_options.load(std::memory_order_relaxed);
 }
@@ -222,6 +238,22 @@
   return true;
 }
 
+bool Log::DumpLogChannel(llvm::StringRef channel,
+ llvm::raw_ostream &output_stream,
+ llvm::raw_ostream &error_stream) {
+  auto iter = g_channel_map->find(channel);
+  if (iter == g_channel_map->end()) {
+error_stream << llvm::formatv("Invalid log channel '{0}'.\n", channel);
+return false;
+  }
+  if (!iter->second.Dump(output_stream)) {
+error_stream << llvm::formatv(
+"log channel '{0}' does not support dumping.\n", channel);
+return false;
+  }
+  return true;
+}
+
 bool Log::ListChannelCategories(llvm::StringRef channel,
 llvm::raw_ostream &stream) {
   auto ch = g_channel_map->find(channel);
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -632,6 +632,8 @@
   return result;
 }
 
+char SystemLogHandler::ID;
+
 SystemLogHandler::SystemLogHandler() {}
 
 void SystemLogHandler::Emit(llvm::StringRef message) {
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -456,6 +456,11 @@
 Desc<"Prepend the names of files and function that generate the logs.">;
 }
 
+let Command = "log dump" in {
+  def log_dump_file : Option<"file", "f">, Group<1>, Arg<"Filename">,
+Desc<"Set the destination

[Lldb-commits] [PATCH] D128557: [lldb] Add a log dump command to dump the circular log buffer

2022-06-27 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D128557#3609545 , @JDevlieghere 
wrote:

> Thanks for pointing that out. I blindly copied the categories logic from 
> `Log::Disable` which uses it when computing the flags. I've omitted it for 
> now because I think it would be weird to set the circular buffer size to 5 
> and then have 0 messages printed for the process category because 5 log 
> messages from the commands category pushed them out. One solution would be to 
> keep a circular buffer per category. I'll think about it and if I come up 
> with a good solution I'll put up another patch.

Sounds good. We would still want to keep a circular buffer and keep all 
messages in order in case they want to dump just a few of the total categories 
as those log messages still need to come out in order.

> This isn't completely trivial, because there it's not possible to associate 
> each log message with a specific log category -- GetLog(FOO | BAR) will 
> return a log object if either of the two categories are set. So we'd either 
> need to attach a set of categories to each log message, give up the 
> multi-category messages, or do something more complicated...

If we keep a list of messages and the log mask as the other part of the pair, 
it is very easy to keep as bot the "FOO" and "BAR" bits will be set in the 64 
bit log mask.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128557/new/

https://reviews.llvm.org/D128557

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


[Lldb-commits] [PATCH] D126359: [LLDB] Add basic floating point ops to IR interpreter

2022-06-27 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Will the floating point emulation be perfect compared to actually JITing the 
code? If we are going to enable this feature I would like to see tests that 
actually JIT code do the same operations somehow to verify that things match up 
with the IR interpreted results produce. The main reason we didn't include 
floating point code in the IR interpreter before is it is harder to make things 
match up with exactly how things are going to be run if it were JIT'ed into the 
process. On x86_64 or x64 there are floating point settings that can be changed 
and affect how operations happen in the current thread. The main example I 
always think of is how older debuggers would create recursive descent parsers 
and evaluate floating point operations using native floating point types. I 
believe that our APFloat classes can do everything correctly, but I would like 
to see tests that verify that we get the same results as if we were running 
actual code in the process. For this you can add an extra function to the 
lldb/test/API/lang/c/fpeval/main.c source like:

  typedef enum FloatOperation { add, subtract, multiply, ... };
  double eval(double a, double b, FloatOperation op) {
switch (op) {
case add: return a+b;
case subtract: return a-b;
...
}
  }




Comment at: lldb/test/API/lang/c/fpeval/TestFPEval.py:32
+self.runCmd("run", RUN_SUCCEEDED)
+self.expect("expr --allow-jit false  -- a + b", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['double', '44'])

You might be able to get away with not actually even creating a target or 
running to main if you define variables in your expression:

```
self.expect('expr --allow-jit false  -- float x=2.2; float y=4.4; x+y', ...
```



Comment at: lldb/test/API/lang/c/fpeval/main.c:3-4
+{
+double a = 42.0;
+double b = 2.0;
+return 0;  Set break point at this line.

We should be testing "float" and "long double" as well to verify those work.



Comment at: lldb/test/API/lang/c/fpeval/main.c:1-10
+#include 
+#include 
+#include 
+
+int main (int argc, char const *argv[])
+{
+double a = 42.0;

I don't think this file is even needed if you define variables locally in your 
own expression each time like I mentioned above ("expr float x=2.2; float 
y=4.4; x+y")


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126359/new/

https://reviews.llvm.org/D126359

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


[Lldb-commits] [lldb] 9bdb7e5 - [lldb] Add a log dump command

2022-06-27 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-06-27T10:02:34-07:00
New Revision: 9bdb7e573427ac3785cb10829da57ee18ef65ce3

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

LOG: [lldb] Add a log dump command

Add a log dump command to dump logs to a file. This only works for
channels that have a log handler associated that supports dumping. For
now that's limited to the circular log handler, but more could be added
in the future.

Differential revision: https://reviews.llvm.org/D128557

Added: 
lldb/test/API/commands/log/basic/TestLogHandlers.py

Modified: 
lldb/include/lldb/Host/Host.h
lldb/include/lldb/Utility/Log.h
lldb/source/Commands/CommandObjectLog.cpp
lldb/source/Commands/Options.td
lldb/source/Host/common/Host.cpp
lldb/source/Utility/Log.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index b3e0cbaff19ed..4fc2bd128b025 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -261,6 +261,12 @@ class SystemLogHandler : public LogHandler {
 public:
   SystemLogHandler();
   void Emit(llvm::StringRef message) override;
+
+  bool isA(const void *ClassID) const override { return ClassID == &ID; }
+  static bool classof(const LogHandler *obj) { return obj->isA(&ID); }
+
+private:
+  static char ID;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h
index 4772291e43079..404cbed14c18b 100644
--- a/lldb/include/lldb/Utility/Log.h
+++ b/lldb/include/lldb/Utility/Log.h
@@ -49,6 +49,12 @@ class LogHandler {
 public:
   virtual ~LogHandler() = default;
   virtual void Emit(llvm::StringRef message) = 0;
+
+  virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
+  static bool classof(const LogHandler *obj) { return obj->isA(&ID); }
+
+private:
+  static char ID;
 };
 
 class StreamLogHandler : public LogHandler {
@@ -59,9 +65,13 @@ class StreamLogHandler : public LogHandler {
   void Emit(llvm::StringRef message) override;
   void Flush();
 
+  bool isA(const void *ClassID) const override { return ClassID == &ID; }
+  static bool classof(const LogHandler *obj) { return obj->isA(&ID); }
+
 private:
   std::mutex m_mutex;
   llvm::raw_fd_ostream m_stream;
+  static char ID;
 };
 
 class CallbackLogHandler : public LogHandler {
@@ -70,9 +80,13 @@ class CallbackLogHandler : public LogHandler {
 
   void Emit(llvm::StringRef message) override;
 
+  bool isA(const void *ClassID) const override { return ClassID == &ID; }
+  static bool classof(const LogHandler *obj) { return obj->isA(&ID); }
+
 private:
   lldb::LogOutputCallback m_callback;
   void *m_baton;
+  static char ID;
 };
 
 class RotatingLogHandler : public LogHandler {
@@ -82,6 +96,9 @@ class RotatingLogHandler : public LogHandler {
   void Emit(llvm::StringRef message) override;
   void Dump(llvm::raw_ostream &stream) const;
 
+  bool isA(const void *ClassID) const override { return ClassID == &ID; }
+  static bool classof(const LogHandler *obj) { return obj->isA(&ID); }
+
 private:
   size_t NormalizeIndex(size_t i) const;
   size_t GetNumMessages() const;
@@ -92,6 +109,7 @@ class RotatingLogHandler : public LogHandler {
   const size_t m_size = 0;
   size_t m_next_index = 0;
   size_t m_total_count = 0;
+  static char ID;
 };
 
 class Log final {
@@ -169,6 +187,10 @@ class Log final {
 llvm::ArrayRef categories,
 llvm::raw_ostream &error_stream);
 
+  static bool DumpLogChannel(llvm::StringRef channel,
+ llvm::raw_ostream &output_stream,
+ llvm::raw_ostream &error_stream);
+
   static bool ListChannelCategories(llvm::StringRef channel,
 llvm::raw_ostream &stream);
 
@@ -258,6 +280,8 @@ class Log final {
 
   void Disable(uint32_t flags);
 
+  bool Dump(llvm::raw_ostream &stream);
+
   typedef llvm::StringMap ChannelMap;
   static llvm::ManagedStatic g_channel_map;
 

diff  --git a/lldb/source/Commands/CommandObjectLog.cpp 
b/lldb/source/Commands/CommandObjectLog.cpp
index 349af26691de9..684cb35da1ccb 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -56,6 +56,9 @@ static constexpr OptionEnumValues LogHandlerType() {
 #define LLDB_OPTIONS_log_enable
 #include "CommandOptions.inc"
 
+#define LLDB_OPTIONS_log_dump
+#include "CommandOptions.inc"
+
 /// Common completion logic for log enable/disable.
 static void CompleteEnableDisable(CompletionRequest &request) {
   size_t arg_index = request.GetCursorIndex();
@@ -345,6 +348,114 @@ class CommandObjectLogList : public CommandObjectParsed {
 return result.Succeeded();
   }
 };
+class CommandObjectLogDump : pu

[Lldb-commits] [PATCH] D128557: [lldb] Add a log dump command to dump the circular log buffer

2022-06-27 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9bdb7e573427: [lldb] Add a log dump command (authored by 
JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128557/new/

https://reviews.llvm.org/D128557

Files:
  lldb/include/lldb/Host/Host.h
  lldb/include/lldb/Utility/Log.h
  lldb/source/Commands/CommandObjectLog.cpp
  lldb/source/Commands/Options.td
  lldb/source/Host/common/Host.cpp
  lldb/source/Utility/Log.cpp
  lldb/test/API/commands/log/basic/TestLogHandlers.py

Index: lldb/test/API/commands/log/basic/TestLogHandlers.py
===
--- /dev/null
+++ lldb/test/API/commands/log/basic/TestLogHandlers.py
@@ -0,0 +1,55 @@
+"""
+Test lldb log handlers.
+"""
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LogHandlerTestCase(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+TestBase.setUp(self)
+self.log_file = self.getBuildArtifact("log-file.txt")
+if (os.path.exists(self.log_file)):
+os.remove(self.log_file)
+
+def test_circular(self):
+self.runCmd("log enable -b 5 -h circular lldb commands")
+self.runCmd("bogus", check=False)
+self.runCmd("log dump lldb -f {}".format(self.log_file))
+
+with open(self.log_file, 'r') as f:
+log_lines = f.readlines()
+
+self.assertEqual(len(log_lines), 5)
+
+found_command_log_dump = False
+found_command_bogus = False
+
+for line in log_lines:
+if 'Processing command: log dump' in line:
+found_command_log_dump = True
+if 'Processing command: bogus' in line:
+found_command_bogus = True
+
+self.assertTrue(found_command_log_dump)
+self.assertFalse(found_command_bogus)
+
+def test_circular_no_buffer_size(self):
+self.expect(
+"log enable -h circular lldb commands",
+error=True,
+substrs=[
+'the circular buffer handler requires a non-zero buffer size'
+])
+
+def test_dump_unsupported(self):
+self.runCmd("log enable lldb commands -f {}".format(self.log_file))
+self.expect("log dump lldb",
+error=True,
+substrs=["log channel 'lldb' does not support dumping"])
Index: lldb/source/Utility/Log.cpp
===
--- lldb/source/Utility/Log.cpp
+++ lldb/source/Utility/Log.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator.h"
 
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Chrono.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
@@ -34,6 +35,11 @@
 
 using namespace lldb_private;
 
+char LogHandler::ID;
+char StreamLogHandler::ID;
+char CallbackLogHandler::ID;
+char RotatingLogHandler::ID;
+
 llvm::ManagedStatic Log::g_channel_map;
 
 void Log::ForEachCategory(
@@ -106,6 +112,16 @@
   }
 }
 
+bool Log::Dump(llvm::raw_ostream &output_stream) {
+  llvm::sys::ScopedReader lock(m_mutex);
+  if (RotatingLogHandler *handler =
+  llvm::dyn_cast_or_null(m_handler.get())) {
+handler->Dump(output_stream);
+return true;
+  }
+  return false;
+}
+
 const Flags Log::GetOptions() const {
   return m_options.load(std::memory_order_relaxed);
 }
@@ -222,6 +238,22 @@
   return true;
 }
 
+bool Log::DumpLogChannel(llvm::StringRef channel,
+ llvm::raw_ostream &output_stream,
+ llvm::raw_ostream &error_stream) {
+  auto iter = g_channel_map->find(channel);
+  if (iter == g_channel_map->end()) {
+error_stream << llvm::formatv("Invalid log channel '{0}'.\n", channel);
+return false;
+  }
+  if (!iter->second.Dump(output_stream)) {
+error_stream << llvm::formatv(
+"log channel '{0}' does not support dumping.\n", channel);
+return false;
+  }
+  return true;
+}
+
 bool Log::ListChannelCategories(llvm::StringRef channel,
 llvm::raw_ostream &stream) {
   auto ch = g_channel_map->find(channel);
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -632,6 +632,8 @@
   return result;
 }
 
+char SystemLogHandler::ID;
+
 SystemLogHandler::SystemLogHandler() {}
 
 void SystemLogHandler::Emit(llvm::StringRef message) {
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -456,6 +456,11 @@
 Desc<"Prepend the names of files and function that generate the logs.">;
 }
 
+let Command = "log dump" in {

[Lldb-commits] [PATCH] D128668: [LLDB] Fix PDB/pointers.test for 32bit Arm/Windows

2022-06-27 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added reviewers: mstorsjo, DavidSpickett.
Herald added subscribers: jsji, pengfei, kristof.beyls.
Herald added a project: All.
omjavaid requested review of this revision.

PDB/pointers.test was orignally written for 32bit x86 keeping in mind

  __cdecl and __stdcall calling conventions which does name mangling for
  example like adding "_" underscore before function name.
  This is only x86 specific but purpose of pointers.test is NOT to test
  calling convention.
  I am have made a few minor changes to this test which will make it pass
  when run on Windows/Arm platform.


https://reviews.llvm.org/D128668

Files:
  lldb/test/Shell/SymbolFile/PDB/pointers.test


Index: lldb/test/Shell/SymbolFile/PDB/pointers.test
===
--- lldb/test/Shell/SymbolFile/PDB/pointers.test
+++ lldb/test/Shell/SymbolFile/PDB/pointers.test
@@ -19,7 +19,7 @@
 MAIN-ST-NEXT: int {{.*}}f(int);
 MAIN-ST-NEXT:}
 
-MAIN:   Function{[[FID1:.*]]}, mangled = _main
+MAIN:   Function{[[FID1:.*]]}, mangled = {{_?}}main
 MAIN-NEXT:  Block{[[FID1]]}
 MAIN: Variable{{.*}}, name = "array_pointer"
 MAIN-SAME:(int (*)[2][4]), scope = local
@@ -28,11 +28,11 @@
 MAIN: Variable{{.*}}, name = "p_member_field"
 MAIN-SAME:(int ST::*), scope = local
 MAIN: Variable{{.*}}, name = "p_member_method"
-MAIN-SAME:(int (ST::*)(int) __attribute__((thiscall))), scope = local
+MAIN-SAME:(int (ST::*)(int){{( __attribute__\(\(thiscall\)\))?}}), scope = 
local
 
 F:   Function{[[FID2:.*]]}, demangled = {{.*}}f(int)
 F-NEXT:  Block{[[FID2]]}
 F: Variable{{.*}}, name = "this"
-F-SAME:(ST *), scope = parameter, location = {{.*}}, artificial
+F-SAME:(ST *), scope = parameter,{{( location = DW_OP.*,)?}} artificial
 F: Variable{{.*}}, name = "x"
 F-SAME:(int), scope = parameter, decl = PointerTypeTest.cpp:8


Index: lldb/test/Shell/SymbolFile/PDB/pointers.test
===
--- lldb/test/Shell/SymbolFile/PDB/pointers.test
+++ lldb/test/Shell/SymbolFile/PDB/pointers.test
@@ -19,7 +19,7 @@
 MAIN-ST-NEXT: int {{.*}}f(int);
 MAIN-ST-NEXT:}
 
-MAIN:   Function{[[FID1:.*]]}, mangled = _main
+MAIN:   Function{[[FID1:.*]]}, mangled = {{_?}}main
 MAIN-NEXT:  Block{[[FID1]]}
 MAIN: Variable{{.*}}, name = "array_pointer"
 MAIN-SAME:(int (*)[2][4]), scope = local
@@ -28,11 +28,11 @@
 MAIN: Variable{{.*}}, name = "p_member_field"
 MAIN-SAME:(int ST::*), scope = local
 MAIN: Variable{{.*}}, name = "p_member_method"
-MAIN-SAME:(int (ST::*)(int) __attribute__((thiscall))), scope = local
+MAIN-SAME:(int (ST::*)(int){{( __attribute__\(\(thiscall\)\))?}}), scope = local
 
 F:   Function{[[FID2:.*]]}, demangled = {{.*}}f(int)
 F-NEXT:  Block{[[FID2]]}
 F: Variable{{.*}}, name = "this"
-F-SAME:(ST *), scope = parameter, location = {{.*}}, artificial
+F-SAME:(ST *), scope = parameter,{{( location = DW_OP.*,)?}} artificial
 F: Variable{{.*}}, name = "x"
 F-SAME:(int), scope = parameter, decl = PointerTypeTest.cpp:8
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D126359: [LLDB] Add basic floating point ops to IR interpreter

2022-06-27 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/test/API/lang/c/fpeval/TestFPEval.py:32-33
+self.runCmd("run", RUN_SUCCEEDED)
+self.expect("expr --allow-jit false  -- a + b", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['double', '44'])
+self.expect("expr --allow-jit false  -- a - b", 
VARIABLES_DISPLAYED_CORRECTLY,

if we want to verify if the above "a+b" works as expected compared to JITed 
code, you can also run an expression like:

```
expr eval(a, b, add)
```
Then then we would want to compare the expression results to make sure the 
binary answer matches exactly. To do this, we will want to use the LLDB native 
APIs:
```
no_jit_options = lldb.SBExpressionOptions()
no_jit_options = expt_options.SetAllowJIT(False)
jit_options = lldb.SBExpressionOptions()
jit_options = expt_options.SetAllowJIT(True)
no_jit_value = frame.EvaluateExpression("a+b", no_jit_options)
jit_value = frame.EvaluateExpression("eval(a, b, add)", jit_options)
no_jit_data = no_jit_value.GetData()
jit_data = no_jit_value.GetData()
```
Then we need to compare the data byte for byte.





Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126359/new/

https://reviews.llvm.org/D126359

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


[Lldb-commits] [PATCH] D128668: [LLDB] Fix PDB/pointers.test for 32bit Arm/Windows

2022-06-27 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added inline comments.



Comment at: lldb/test/Shell/SymbolFile/PDB/pointers.test:36
 F: Variable{{.*}}, name = "this"
-F-SAME:(ST *), scope = parameter, location = {{.*}}, artificial
+F-SAME:(ST *), scope = parameter,{{( location = DW_OP.*,)?}} artificial
 F: Variable{{.*}}, name = "x"

Explaining this change a dwarf location expression tag is added for variables 
deriving their address location from stack. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128668/new/

https://reviews.llvm.org/D128668

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


[Lldb-commits] [PATCH] D128668: [LLDB] Fix PDB/pointers.test for 32bit Arm/Windows

2022-06-27 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

I presume this is ok - if the main intent of this test is to test handling of 
pointers and the size thereof in PDBs.




Comment at: lldb/test/Shell/SymbolFile/PDB/pointers.test:2
 REQUIRES: system-windows, msvc
 RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib 
--output=%T/PointerTypeTest.cpp.obj %S/Inputs/PointerTypeTest.cpp
 RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib 
--output=%T/PointerTypeTest.cpp.exe %T/PointerTypeTest.cpp.obj

I wonder if it'd be better to hardcode this to build for `i386` (assuming the 
`%build` script allows that?) to keep it testing what it was originally made to 
test?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128668/new/

https://reviews.llvm.org/D128668

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


[Lldb-commits] [lldb] ef5510d - [NFC][lldb] Correct Module::FindFunctions documentation

2022-06-27 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2022-06-27T12:33:05-07:00
New Revision: ef5510d81b64fa64a75b9c9c024d7c0f6cb8e241

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

LOG: [NFC][lldb] Correct Module::FindFunctions documentation

Looks like a copy/paste from ModuleList::FindCompileUnits.

Added: 


Modified: 
lldb/include/lldb/Core/Module.h

Removed: 




diff  --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 38051788b9a7f..cc3edbb3f1bbe 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -300,7 +300,7 @@ class Module : public std::enable_shared_from_this,
   /// containing function.  If it is not inlined, then the block will be NULL.
   ///
   /// \param[in] name
-  /// The name of the compile unit we are looking for.
+  /// The name of the function we are looking for.
   ///
   /// \param[in] name_type_mask
   /// A bit mask of bits that indicate what kind of names should



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


[Lldb-commits] [PATCH] D128668: [LLDB] Fix PDB/pointers.test for 32bit Arm/Windows

2022-06-27 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added inline comments.



Comment at: lldb/test/Shell/SymbolFile/PDB/pointers.test:2
 REQUIRES: system-windows, msvc
 RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib 
--output=%T/PointerTypeTest.cpp.obj %S/Inputs/PointerTypeTest.cpp
 RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib 
--output=%T/PointerTypeTest.cpp.exe %T/PointerTypeTest.cpp.obj

mstorsjo wrote:
> I wonder if it'd be better to hardcode this to build for `i386` (assuming the 
> `%build` script allows that?) to keep it testing what it was originally made 
> to test?
Given we expect this to pass for Windows/Arm it will reduce coverage if made to 
run only for x86.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128668/new/

https://reviews.llvm.org/D128668

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


[Lldb-commits] [PATCH] D128678: [LLDB] Add PDB/Calling-conentions.test for Arm/Windows

2022-06-27 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added reviewers: mstorsjo, DavidSpickett.
omjavaid added a project: LLDB.
Herald added subscribers: jsji, JDevlieghere, pengfei, kristof.beyls.
Herald added a project: All.
omjavaid requested review of this revision.

This patch renames PDB/Calling-conentions.test to Calling-conentions-x86.test.
Also restrict it to run only for target-x86*. This patch also adds a arm 
specific test
which tests that x86 specifc calling conventions are ignored by Arm compiler.


https://reviews.llvm.org/D128678

Files:
  lldb/test/Shell/SymbolFile/PDB/calling-conventions-arm.test
  lldb/test/Shell/SymbolFile/PDB/calling-conventions-x86.test
  lldb/test/Shell/SymbolFile/PDB/calling-conventions.test


Index: lldb/test/Shell/SymbolFile/PDB/calling-conventions-x86.test
===
--- lldb/test/Shell/SymbolFile/PDB/calling-conventions-x86.test
+++ lldb/test/Shell/SymbolFile/PDB/calling-conventions-x86.test
@@ -1,4 +1,4 @@
-REQUIRES: system-windows, lld
+REQUIRES: system-windows, lld, (target-x86 || target-x86_64) 
 RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe 
%S/Inputs/CallingConventionsTest.cpp
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s
 
Index: lldb/test/Shell/SymbolFile/PDB/calling-conventions-arm.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/PDB/calling-conventions-arm.test
@@ -0,0 +1,10 @@
+REQUIRES: system-windows, lld, (target-arm || target-aarch64) 
+RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe 
%S/Inputs/CallingConventionsTest.cpp
+RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s
+
+CHECK: Module: {{.*}}
+CHECK-DAG: int (*FuncCCallPtr)();
+CHECK-DAG: int (*FuncStdCallPtr)();
+CHECK-DAG: int (*FuncFastCallPtr)();
+CHECK-DAG: int (*FuncVectorCallPtr)();
+CHECK-DAG: int (S::*FuncThisCallPtr)();


Index: lldb/test/Shell/SymbolFile/PDB/calling-conventions-x86.test
===
--- lldb/test/Shell/SymbolFile/PDB/calling-conventions-x86.test
+++ lldb/test/Shell/SymbolFile/PDB/calling-conventions-x86.test
@@ -1,4 +1,4 @@
-REQUIRES: system-windows, lld
+REQUIRES: system-windows, lld, (target-x86 || target-x86_64) 
 RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe %S/Inputs/CallingConventionsTest.cpp
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s
 
Index: lldb/test/Shell/SymbolFile/PDB/calling-conventions-arm.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/PDB/calling-conventions-arm.test
@@ -0,0 +1,10 @@
+REQUIRES: system-windows, lld, (target-arm || target-aarch64) 
+RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe %S/Inputs/CallingConventionsTest.cpp
+RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s
+
+CHECK: Module: {{.*}}
+CHECK-DAG: int (*FuncCCallPtr)();
+CHECK-DAG: int (*FuncStdCallPtr)();
+CHECK-DAG: int (*FuncFastCallPtr)();
+CHECK-DAG: int (*FuncVectorCallPtr)();
+CHECK-DAG: int (S::*FuncThisCallPtr)();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D128668: [LLDB] Fix PDB/pointers.test for 32bit Arm/Windows

2022-06-27 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo accepted this revision.
mstorsjo added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/test/Shell/SymbolFile/PDB/pointers.test:2
 REQUIRES: system-windows, msvc
 RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib 
--output=%T/PointerTypeTest.cpp.obj %S/Inputs/PointerTypeTest.cpp
 RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib 
--output=%T/PointerTypeTest.cpp.exe %T/PointerTypeTest.cpp.obj

omjavaid wrote:
> mstorsjo wrote:
> > I wonder if it'd be better to hardcode this to build for `i386` (assuming 
> > the `%build` script allows that?) to keep it testing what it was originally 
> > made to test?
> Given we expect this to pass for Windows/Arm it will reduce coverage if made 
> to run only for x86.
Right, as we probably need to link, that would require more of the host 
environment than we normally require (for other tests where we don't link 
things, we can compile things for x86 even if we're running on arm, as long as 
the x86 support is available in the compiler).

Given the structure of the lldb tests I guess this is more in line with how 
things normally are done here, so I guess this is fine.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128668/new/

https://reviews.llvm.org/D128668

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


[Lldb-commits] [PATCH] D128678: [LLDB] Add PDB/Calling-conentions.test for Arm/Windows

2022-06-27 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

There's consistent typos about the test name in the commit subject and 
description.




Comment at: lldb/test/Shell/SymbolFile/PDB/calling-conventions-arm.test:1
+REQUIRES: system-windows, lld, (target-arm || target-aarch64) 
+RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe 
%S/Inputs/CallingConventionsTest.cpp

Hmm, I wasn't aware of the fact that you can do such `||` expressions in the 
`REQUIRES` line - I presume you've verified that this test actually does get 
picked up and executed?



Comment at: lldb/test/Shell/SymbolFile/PDB/calling-conventions-arm.test:2
+REQUIRES: system-windows, lld, (target-arm || target-aarch64) 
+RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe 
%S/Inputs/CallingConventionsTest.cpp
+RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s

Here, there's probably no need to force it to 32 bit mode - unless we expect to 
have a similar test for the undecorated mangling in aarch64 and x86_64 mode too?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128678/new/

https://reviews.llvm.org/D128678

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


[Lldb-commits] [lldb] c1b07d6 - Have CommandObjectParsed check for "commands that take no arguments".

2022-06-27 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2022-06-27T15:14:41-07:00
New Revision: c1b07d617705dfdb3aabbdda51c1a40d99f7cc1a

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

LOG: Have CommandObjectParsed check for "commands that take no arguments".

This is currently being done in an ad hoc way, and so for some
commands it isn't being checked.  We have the info to make this check,
since commands are supposed to add their arguments to the m_arguments
field of the CommandObject.  This change uses that info to check whether
the command received arguments in error.

A handful of commands weren't defining their argument types, I also had
to fix them.  And a bunch of commands were checking for arguments by
hand, so I removed those checks in favor of the CommandObject one.  That
also meant I had to change some tests that were checking for the ad hoc
error outputs.

Differential Revision: https://reviews.llvm.org/D128453

Added: 


Modified: 
lldb/include/lldb/lldb-enumerations.h
lldb/source/API/SBCommandInterpreter.cpp
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/CommandObjectGUI.cpp
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/CommandObjectQuit.cpp
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Commands/CommandObjectSource.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/CommandObjectThreadUtil.cpp
lldb/source/Commands/CommandObjectTrace.cpp
lldb/source/Commands/CommandObjectType.cpp
lldb/source/Commands/CommandObjectVersion.cpp
lldb/source/Interpreter/CommandObject.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/test/API/commands/gui/invalid-args/TestInvalidArgsGui.py
lldb/test/API/commands/reproducer/invalid-args/TestInvalidArgsReproducer.py
lldb/test/API/commands/target/basic/TestTargetCommand.py
lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
lldb/test/API/commands/version/TestVersion.py

lldb/test/API/commands/watchpoints/multi_watchpoint_slots/TestWatchpointMultipleSlots.py
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 74a82f6216c7f..e1e3332eddc58 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -603,6 +603,11 @@ enum CommandArgumentType {
   eArgTypeModuleUUID,
   eArgTypeSaveCoreStyle,
   eArgTypeLogHandler,
+  eArgTypeSEDStylePair,
+  eArgTypeRecognizerID,
+  eArgTypeConnectURL,
+  eArgTypeTargetID,
+  eArgTypeStopHookID,
   eArgTypeLastArg // Always keep this entry as the last entry in this
   // enumeration!!
 };

diff  --git a/lldb/source/API/SBCommandInterpreter.cpp 
b/lldb/source/API/SBCommandInterpreter.cpp
index a19ad48dde042..aa46f1085dc9f 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -47,6 +47,10 @@ class CommandPluginInterfaceImplementation : public 
CommandObjectParsed {
 auto_repeat_command == nullptr
 ? llvm::None
 : llvm::Optional(auto_repeat_command);
+// We don't know whether any given command coming from this interface takes
+// arguments or not so here we're just disabling the basic args check.
+CommandArgumentData none_arg{eArgTypeNone, eArgRepeatStar};
+m_arguments.push_back({none_arg});
   }
 
   bool IsRemovable() const override { return true; }

diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index 2334759ea0f47..39c7207bbdbec 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -824,6 +824,8 @@ a number follows 'f':"
 R"(
 
 (lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/')");
+CommandArgumentData thread_arg{eArgTypeSEDStylePair, eArgRepeatOptional};
+m_arguments.push_back({thread_arg});
   }
 
   ~CommandObjectCommandsAddRegex() override = default;
@@ -1664,11 +1666,6 @@ class CommandObjectCommandsScriptList : public 
CommandObjectParsed {
   ~CommandObjectCommandsScriptList() override = default;
 
   bool DoExecute(Args &command, CommandReturnObject &result) override {
-if (command.GetArgumentCount() != 0) {
-  result.AppendError("'command script list' doesn

[Lldb-commits] [PATCH] D128453: Automate checking for "command that takes no arguments" being passed arguments in CommandObjectParsed

2022-06-27 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1b07d617705: Have CommandObjectParsed check for 
"commands that take no arguments". (authored by jingham).

Changed prior to commit:
  https://reviews.llvm.org/D128453?vs=439443&id=440411#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128453/new/

https://reviews.llvm.org/D128453

Files:
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Commands/CommandObjectGUI.cpp
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Commands/CommandObjectReproducer.cpp
  lldb/source/Commands/CommandObjectSource.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/CommandObjectThreadUtil.cpp
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Commands/CommandObjectVersion.cpp
  lldb/source/Interpreter/CommandObject.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/commands/gui/invalid-args/TestInvalidArgsGui.py
  lldb/test/API/commands/reproducer/invalid-args/TestInvalidArgsReproducer.py
  lldb/test/API/commands/target/basic/TestTargetCommand.py
  lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
  lldb/test/API/commands/version/TestVersion.py
  
lldb/test/API/commands/watchpoints/multi_watchpoint_slots/TestWatchpointMultipleSlots.py
  lldb/test/API/functionalities/completion/TestCompletion.py

Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -675,7 +675,7 @@
 
 self.build()
 self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
-self.runCmd('target stop-hook add test DONE')
+self.runCmd('target stop-hook add -o test')
 
 for subcommand in subcommands:
 self.complete_from_to('target stop-hook ' + subcommand + ' ',
Index: lldb/test/API/commands/watchpoints/multi_watchpoint_slots/TestWatchpointMultipleSlots.py
===
--- lldb/test/API/commands/watchpoints/multi_watchpoint_slots/TestWatchpointMultipleSlots.py
+++ lldb/test/API/commands/watchpoints/multi_watchpoint_slots/TestWatchpointMultipleSlots.py
@@ -88,10 +88,10 @@
 # The stop reason of the thread should be watchpoint.
 if self.platformIsDarwin():
 # On darwin we'll hit byteArray[3] which is watchpoint 2
-self.expect("thread list -v", STOPPED_DUE_TO_WATCHPOINT,
+self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT,
 substrs=['stopped', 'stop reason = watchpoint 2'])
 else:
-self.expect("thread list -v", STOPPED_DUE_TO_WATCHPOINT,
+self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT,
 substrs=['stopped', 'stop reason = watchpoint 3'])
 
 # Resume inferior.
Index: lldb/test/API/commands/version/TestVersion.py
===
--- lldb/test/API/commands/version/TestVersion.py
+++ lldb/test/API/commands/version/TestVersion.py
@@ -14,4 +14,4 @@
 @no_debug_info_test
 def test_version_invalid_invocation(self):
 self.expect("version a", error=True,
-substrs=['the version command takes no arguments.'])
+substrs=["'version' doesn't take any arguments."])
Index: lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
===
--- lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
+++ lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
@@ -28,4 +28,4 @@
 self.build()
 self.createTestTarget()
 self.expect("target dump typesystem arg", error=True,
-substrs=["error: target dump typesystem doesn't take arguments."])
+substrs=["'target dump typesystem' doesn't take any arguments."])
Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -325,7 +325,7 @@
 @no_debug_info_test
 def test_target_list_args(self):
 s

[Lldb-commits] [lldb] e06a88c - [lldb] Use assertState in TestIgnoredExceptions

2022-06-27 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-06-27T16:30:47-07:00
New Revision: e06a88cbe9cb639b0ee11026d6888455df1de214

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

LOG: [lldb] Use assertState in TestIgnoredExceptions

Added: 


Modified: 
lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py

Removed: 




diff  --git a/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py 
b/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
index 16fa762245825..e90b2ef8dbb30 100644
--- a/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
+++ b/lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
@@ -56,8 +56,8 @@ def suspended_thread_test(self):
 self.assertEqual(len(threads), 1, "Stopped at return breakpoint")
 
 # Make sure we really changed the value:
-
+
 process.Continue()
-self.assertEqual(process.state, lldb.eStateExited, "Process exited")
+self.assertState(process.state, lldb.eStateExited, "Process exited")
 self.assertEqual(process.exit_state, 20, "Got the right exit status")
- 
+



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


[Lldb-commits] [PATCH] D128694: [lldb/Dataformatters] Adapt C++ std::string dataformatter for D128285

2022-06-27 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: aprantl, JDevlieghere.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch changes the C++ `std::string` dataformatter to reflect
internal layout changes following D128285 .

Now, on short strings, in order to access the `__size` attributes, we
need to access a packed anonymous struct, which introduces another
indirection.

This should fix the various test failures that are happening on
GreenDragon:

https://green.lab.llvm.org/green/job/lldb-cmake/44918/

rdar://96010248

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128694

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -624,11 +624,17 @@
 ValueObjectSP short_sp(dataval_sp->GetChildAtIndex(1, true));
 if (!short_sp)
   return {};
-ValueObjectSP location_sp = short_sp->GetChildAtIndex(
+
+// After D128285, we need to access the size from a packed anonymous struct
+ValueObjectSP packed_fields_sp = short_sp->GetChildAtIndex(0, true);
+if (!packed_fields_sp)
+  return {};
+
+ValueObjectSP location_sp = packed_fields_sp->GetChildAtIndex(
 (layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
 // After D125496, there is a flat layout.
 if (location_sp->GetName() == g_size_name)
-  location_sp = short_sp->GetChildAtIndex(3, true);
+  location_sp = short_sp->GetChildAtIndex(2, true);
 if (using_bitmasks)
   size = (layout == eLibcxxStringLayoutModeDSC)
  ? size_mode_value


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -624,11 +624,17 @@
 ValueObjectSP short_sp(dataval_sp->GetChildAtIndex(1, true));
 if (!short_sp)
   return {};
-ValueObjectSP location_sp = short_sp->GetChildAtIndex(
+
+// After D128285, we need to access the size from a packed anonymous struct
+ValueObjectSP packed_fields_sp = short_sp->GetChildAtIndex(0, true);
+if (!packed_fields_sp)
+  return {};
+
+ValueObjectSP location_sp = packed_fields_sp->GetChildAtIndex(
 (layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
 // After D125496, there is a flat layout.
 if (location_sp->GetName() == g_size_name)
-  location_sp = short_sp->GetChildAtIndex(3, true);
+  location_sp = short_sp->GetChildAtIndex(2, true);
 if (using_bitmasks)
   size = (layout == eLibcxxStringLayoutModeDSC)
  ? size_mode_value
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D128694: [lldb/Dataformatters] Adapt C++ std::string dataformatter for D128285

2022-06-27 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp:637
 if (location_sp->GetName() == g_size_name)
-  location_sp = short_sp->GetChildAtIndex(3, true);
+  location_sp = short_sp->GetChildAtIndex(2, true);
 if (using_bitmasks)

Let me know if I',m misunderstanding what the code is doing, but this looks 
like it is replacing the previous implementation? Ideally we would detect the 
layout and then parse it correctly depending on which version we're dealing 
with. Otherwise we risk breaking the matrix bot that checks that LLDB can debug 
C++ produced by older versions of LLVM (and by extension libcxx).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128694/new/

https://reviews.llvm.org/D128694

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


[Lldb-commits] [PATCH] D128694: [lldb/Dataformatters] Adapt C++ std::string dataformatter for D128285

2022-06-27 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added subscribers: ldionne, labath.
mib added inline comments.



Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp:637
 if (location_sp->GetName() == g_size_name)
-  location_sp = short_sp->GetChildAtIndex(3, true);
+  location_sp = short_sp->GetChildAtIndex(2, true);
 if (using_bitmasks)

aprantl wrote:
> Let me know if I',m misunderstanding what the code is doing, but this looks 
> like it is replacing the previous implementation? Ideally we would detect the 
> layout and then parse it correctly depending on which version we're dealing 
> with. Otherwise we risk breaking the matrix bot that checks that LLDB can 
> debug C++ produced by older versions of LLVM (and by extension libcxx).
I've look at D12828 and D123580, and I don't see any way of versioning these 
changes ... may be @ldionne have an idea on how we could do this properly ?

Also, in D124113, @labath mentions that this data formatter uses mostly indices 
to parse and access the various fields of the type data structure (because it 
uses some anonymous structs). This makes it very fragile on our end because our 
data formatter break every time they make a change in the layout ...

@aprantl, I'll update the line your pointed at to the the field identifier 
instead of using changing the index while waiting for a better way to version 
this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128694/new/

https://reviews.llvm.org/D128694

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


[Lldb-commits] [PATCH] D126983: [lldb] [llgs] Support "t" vCont action

2022-06-27 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.
Herald added a subscriber: JDevlieghere.

Hey @mgorny,

This patch is causing a test to fail on the macOS bot: 
https://green.lab.llvm.org/green/job/lldb-cmake/44921/consoleText

Feel free to skip it or let me know if you need help reproducing the issue.

  FAIL: lldb-api :: tools/lldb-server/TestGdbRemote_vCont.py (734 of 1734)
   TEST 'lldb-api :: 
tools/lldb-server/TestGdbRemote_vCont.py' FAILED 
  FAIL: LLDB 
(/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-x86_64) :: 
test_vCont_supports_t_debugserver (TestGdbRemote_vCont.TestGdbRemote_vCont)
  UNSUPPORTED: LLDB 
(/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-x86_64) :: 
test_vCont_supports_t_llgs (TestGdbRemote_vCont.TestGdbRemote_vCont) (test case 
does not fall in any category of interest for this run) 
  Restore dir to: 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/tools/lldb/test
  ==
  FAIL: test_vCont_supports_t_debugserver 
(TestGdbRemote_vCont.TestGdbRemote_vCont)
  --
  Traceback (most recent call last):
File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py",
 line 52, in test_method
  return attrvalue(self)
File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py",
 line 44, in test_vCont_supports_t
  self.vCont_supports_mode("t")
File 
"/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py",
 line 23, in vCont_supports_mode
  self.assertIn(mode, supported_vCont_modes)
  AssertionError: 't' not found in {'c': 1, 'C': 1, 's': 1, 'S': 1}
  
Config=x86_64-/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang
  --
  Ran 14 tests in 17.353s
  
  RESULT: FAILED (6 passes, 1 failures, 0 errors, 7 skipped, 0 expected 
failures, 0 unexpected successes)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126983/new/

https://reviews.llvm.org/D126983

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


[Lldb-commits] [PATCH] D128694: [lldb/Dataformatters] Adapt C++ std::string dataformatter for D128285

2022-06-27 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp:637
 if (location_sp->GetName() == g_size_name)
-  location_sp = short_sp->GetChildAtIndex(3, true);
+  location_sp = short_sp->GetChildAtIndex(2, true);
 if (using_bitmasks)

mib wrote:
> aprantl wrote:
> > Let me know if I',m misunderstanding what the code is doing, but this looks 
> > like it is replacing the previous implementation? Ideally we would detect 
> > the layout and then parse it correctly depending on which version we're 
> > dealing with. Otherwise we risk breaking the matrix bot that checks that 
> > LLDB can debug C++ produced by older versions of LLVM (and by extension 
> > libcxx).
> I've look at D12828 and D123580, and I don't see any way of versioning these 
> changes ... may be @ldionne have an idea on how we could do this properly ?
> 
> Also, in D124113, @labath mentions that this data formatter uses mostly 
> indices to parse and access the various fields of the type data structure 
> (because it uses some anonymous structs). This makes it very fragile on our 
> end because our data formatter break every time they make a change in the 
> layout ...
> 
> @aprantl, I'll update the line your pointed at to the the field identifier 
> instead of using changing the index while waiting for a better way to version 
> this.
@aprantl, I'll update the line you pointed at to *use* the field identifier 
instead of using changing the index, while waiting for a better way to version 
this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128694/new/

https://reviews.llvm.org/D128694

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


[Lldb-commits] [PATCH] D128694: [lldb/Dataformatters] Adapt C++ std::string dataformatter for D128285

2022-06-27 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 440452.
mib edited the summary of this revision.
mib added a comment.

Use field identifiers instead of indices and add long-mode support.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128694/new/

https://reviews.llvm.org/D128694

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -583,8 +583,18 @@
   : eLibcxxStringLayoutModeCSD;
   uint64_t size_mode_value = 0;
 
-  if (ValueObjectSP is_long = dataval_sp->GetChildAtNamePath(
-  {ConstString("__s"), ConstString("__is_long_")})) {
+  ValueObjectSP short_sp(dataval_sp->GetChildAtIndex(1, true));
+  if (!short_sp)
+return {};
+
+  // After D128285, we need to access the `__is_long_` and `__size_` fields 
from
+  // a packed anonymous struct
+  ValueObjectSP packed_fields_sp = short_sp->GetChildAtIndex(0, true);
+  if (!packed_fields_sp)
+return {};
+
+  if (ValueObjectSP is_long = packed_fields_sp->GetChildMemberWithName(
+  ConstString("__is_long_"), true)) {
 using_bitmasks = false;
 short_mode = !is_long->GetValueAsUnsigned(/*fail_value=*/0);
 if (ValueObjectSP size_member =
@@ -621,14 +631,11 @@
   }
 
   if (short_mode) {
-ValueObjectSP short_sp(dataval_sp->GetChildAtIndex(1, true));
-if (!short_sp)
-  return {};
-ValueObjectSP location_sp = short_sp->GetChildAtIndex(
+ValueObjectSP location_sp = packed_fields_sp->GetChildAtIndex(
 (layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
 // After D125496, there is a flat layout.
 if (location_sp->GetName() == g_size_name)
-  location_sp = short_sp->GetChildAtIndex(3, true);
+  location_sp = short_sp->GetChildMemberWithName(g_data_name, true);
 if (using_bitmasks)
   size = (layout == eLibcxxStringLayoutModeDSC)
  ? size_mode_value
@@ -650,13 +657,19 @@
   ValueObjectSP l(dataval_sp->GetChildAtIndex(0, true));
   if (!l)
 return {};
+
+  // After D128285, we need to access the `__cap_` field from a packed 
anonymous
+  // struct
+  packed_fields_sp = l->GetChildAtIndex(0, true);
+  if (!packed_fields_sp)
+return {};
   // we can use the layout_decider object as the data pointer
   ValueObjectSP location_sp =
   l->GetChildMemberWithName(ConstString("__data_"), /*can_create=*/true);
   ValueObjectSP size_vo =
   l->GetChildMemberWithName(ConstString("__size_"), /*can_create=*/true);
-  ValueObjectSP capacity_vo =
-  l->GetChildMemberWithName(ConstString("__cap_"), /*can_create=*/true);
+  ValueObjectSP capacity_vo = packed_fields_sp->GetChildMemberWithName(
+  ConstString("__cap_"), /*can_create=*/true);
   if (!size_vo || !location_sp || !capacity_vo)
 return {};
   size = size_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -583,8 +583,18 @@
   : eLibcxxStringLayoutModeCSD;
   uint64_t size_mode_value = 0;
 
-  if (ValueObjectSP is_long = dataval_sp->GetChildAtNamePath(
-  {ConstString("__s"), ConstString("__is_long_")})) {
+  ValueObjectSP short_sp(dataval_sp->GetChildAtIndex(1, true));
+  if (!short_sp)
+return {};
+
+  // After D128285, we need to access the `__is_long_` and `__size_` fields from
+  // a packed anonymous struct
+  ValueObjectSP packed_fields_sp = short_sp->GetChildAtIndex(0, true);
+  if (!packed_fields_sp)
+return {};
+
+  if (ValueObjectSP is_long = packed_fields_sp->GetChildMemberWithName(
+  ConstString("__is_long_"), true)) {
 using_bitmasks = false;
 short_mode = !is_long->GetValueAsUnsigned(/*fail_value=*/0);
 if (ValueObjectSP size_member =
@@ -621,14 +631,11 @@
   }
 
   if (short_mode) {
-ValueObjectSP short_sp(dataval_sp->GetChildAtIndex(1, true));
-if (!short_sp)
-  return {};
-ValueObjectSP location_sp = short_sp->GetChildAtIndex(
+ValueObjectSP location_sp = packed_fields_sp->GetChildAtIndex(
 (layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
 // After D125496, there is a flat layout.
 if (location_sp->GetName() == g_size_name)
-  location_sp = short_sp->GetChildAtIndex(3, true);
+  location_sp = short_sp->GetChildMemberWithName(g_data_name, true);
 if (using_bitmasks)
   size = (layout == eLibcxxStringLayoutModeDSC)
  ? size_mode_value
@@ -650,13 +657,19 @@
   ValueObjectSP l(dataval_sp->GetChildAtIndex(0, true));
   if (!l)
 return {};
+
+  // After D128285, we need to access the `__cap_` field from a packed anonymous
+  // struct
+  packed_f

[Lldb-commits] [lldb] f1dcc6a - [lldb] [test] Mark test_vCont_supports_t llgs-only

2022-06-27 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-06-28T06:06:54+02:00
New Revision: f1dcc6af30d98cef6d0aa9579148fa223dbb5d7c

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

LOG: [lldb] [test] Mark test_vCont_supports_t llgs-only

Sponsored by: The FreeBSD Foundation

Added: 


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

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py
index c17d0b7740dde..7b20ef230ba94 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_vCont.py
@@ -39,6 +39,7 @@ def test_vCont_supports_S(self):
 self.build()
 self.vCont_supports_mode("S")
 
+@add_test_categories(["llgs"])
 def test_vCont_supports_t(self):
 self.build()
 self.vCont_supports_mode("t")



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


[Lldb-commits] [PATCH] D126983: [lldb] [llgs] Support "t" vCont action

2022-06-27 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Thanks, I've pushed a skip. I'm sorry, I keep forgetting to mark these new 
tests llgs-only :-(.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126983/new/

https://reviews.llvm.org/D126983

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


[Lldb-commits] [PATCH] D128698: [lldb] Add a NativeProcessProtocol::Threads() iterable

2022-06-27 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D128698

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
  lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -724,17 +724,12 @@
   json::Array threads_array;
 
   // Ensure we can get info on the given thread.
-  uint32_t thread_idx = 0;
-  for (NativeThreadProtocol *thread;
-   (thread = process.GetThreadAtIndex(thread_idx)) != nullptr;
-   ++thread_idx) {
-
-lldb::tid_t tid = thread->GetID();
-
+  for (NativeThreadProtocol &thread : process.Threads()) {
+lldb::tid_t tid = thread.GetID();
 // Grab the reason this thread stopped.
 struct ThreadStopInfo tid_stop_info;
 std::string description;
-if (!thread->GetStopReason(tid_stop_info, description))
+if (!thread.GetStopReason(tid_stop_info, description))
   return llvm::make_error(
   "failed to get stop reason", llvm::inconvertibleErrorCode());
 
@@ -751,7 +746,7 @@
 json::Object thread_obj;
 
 if (!abridged) {
-  if (llvm::Optional registers = GetRegistersAsJSON(*thread))
+  if (llvm::Optional registers = GetRegistersAsJSON(thread))
 thread_obj.try_emplace("registers", std::move(*registers));
 }
 
@@ -760,7 +755,7 @@
 if (signum != 0)
   thread_obj.try_emplace("signal", signum);
 
-const std::string thread_name = thread->GetName();
+const std::string thread_name = thread.GetName();
 if (!thread_name.empty())
   thread_obj.try_emplace("name", thread_name);
 
@@ -856,14 +851,12 @@
   if (m_list_threads_in_stop_reply) {
 response.PutCString("threads:");
 
-uint32_t thread_index = 0;
-NativeThreadProtocol *listed_thread;
-for (listed_thread = process.GetThreadAtIndex(thread_index); listed_thread;
- ++thread_index,
-listed_thread = process.GetThreadAtIndex(thread_index)) {
-  if (thread_index > 0)
+uint32_t thread_num = 0;
+for (NativeThreadProtocol &listed_thread : process.Threads()) {
+  if (thread_num > 0)
 response.PutChar(',');
-  response.Printf("%" PRIx64, listed_thread->GetID());
+  response.Printf("%" PRIx64, listed_thread.GetID());
+  ++thread_num;
 }
 response.PutChar(';');
 
@@ -872,7 +865,7 @@
 // is hex ascii JSON that contains the thread IDs thread stop info only for
 // threads that have stop reasons. Only send this if we have more than one
 // thread otherwise this packet has all the info it needs.
-if (thread_index > 1) {
+if (thread_num > 1) {
   const bool threads_with_valid_stop_info_only = true;
   llvm::Expected threads_info = GetJSONThreadsInfo(
   *m_current_process, threads_with_valid_stop_info_only);
@@ -889,12 +882,10 @@
   }
 }
 
-uint32_t i = 0;
 response.PutCString("thread-pcs");
 char delimiter = ':';
-for (NativeThreadProtocol *thread;
- (thread = process.GetThreadAtIndex(i)) != nullptr; ++i) {
-  NativeRegisterContext ®_ctx = thread->GetRegisterContext();
+for (NativeThreadProtocol &thread : process.Threads()) {
+  NativeRegisterContext ®_ctx = thread.GetRegisterContext();
 
   uint32_t reg_to_read = reg_ctx.ConvertRegisterKindToRegisterNumber(
   eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
@@ -1024,12 +1015,10 @@
   if (!m_non_stop)
 return;
 
-  uint32_t thread_index = 0;
-  while (NativeThreadProtocol *listed_thread =
- m_current_process->GetThreadAtIndex(thread_index++)) {
-if (listed_thread->GetID() != thread_to_skip)
+  for (NativeThreadProtocol &listed_thread : m_current_process->Threads()) {
+if (listed_thread.GetID() != thread_to_skip)
   m_stop_notification_queue.push_back(
-  PrepareStopReplyPacketForThread(*listed_thread).GetString().str());
+  PrepareStopReplyPacketForThread(listed_thread).GetString().str());
   }
 }
 
@@ -1990,15 +1979,10 @@
 return;
 
   LLDB_LOG(log, "iterating over threads of process {0}", process.GetID());
-  NativeThreadProtocol *thread;
-  uint32_t thread_index;
-  for (thread_index = 0, thread = process.GetThreadAtIndex(thread_index);
-   thread;
-   ++thread_index, thread = process.GetThreadAtIndex(thread_index)) {
-LLDB_LOG(log, "iterated thread {0} (tid={1})", thread_index,
- thread->GetID());
+  for (NativeThreadProtocol