[Lldb-commits] [PATCH] D98749: [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 331176.
mgorny edited the summary of this revision.
mgorny added a comment.

Added a helper `send_and_check_signal` method to reduce code duplication.


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

https://reviews.llvm.org/D98749

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


Index: lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -31,6 +31,34 @@
 self.reset_test_sequence()
 return threads
 
+def send_and_check_signal(self, vCont_data, threads):
+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"),
+ "capture": dict((i, "tid{0}".format(i)) for i
+ in range(1, len(threads)+1)),
+ },
+], True)
+
+context = self.expect_gdbremote_sequence()
+self.assertIsNotNone(context)
+tids = sorted(int(context["tid{0}".format(x)], 16)
+  for x in range(1, len(threads)+1))
+self.assertEqual(tids, sorted(threads))
+
+@expectedFailureNetBSD
+def test_signal_process_without_tid(self):
+self.build()
+self.set_inferior_startup_launch()
+
+threads = self.start_threads(1)
+self.send_and_check_signal(
+"C{0:x}".format(lldbutil.get_signal_number('SIGUSR1')),
+threads)
+
 @skipUnlessPlatform(["netbsd"])
 @expectedFailureNetBSD
 def test_signal_one_thread(self):
@@ -39,16 +67,10 @@
 
 threads = self.start_threads(1)
 # try sending a signal to one of the two threads
-self.test_sequence.add_log_lines([
-"read packet: $vCont;C{0:x}:{1:x};c#00".format(
-lldbutil.get_signal_number('SIGUSR1'), threads[0]),
-{"direction": "send", "regex": r"^\$W00#b7$"},
-], True)
-
-context = self.expect_gdbremote_sequence()
-self.assertIsNotNone(context)
+self.send_and_check_signal(
+"C{0:x}:{1:x};c".format(lldbutil.get_signal_number('SIGUSR1')),
+threads[:1])
 
-@skipUnlessPlatform(["netbsd"])
 @expectedFailureNetBSD
 def test_signal_all_threads(self):
 self.build()
@@ -56,15 +78,11 @@
 
 threads = self.start_threads(1)
 # try sending a signal to two threads (= the process)
-self.test_sequence.add_log_lines([
-"read packet: $vCont;C{0:x}:{1:x};C{0:x}:{2:x}#00".format(
+self.send_and_check_signal(
+"C{0:x}:{1:x};C{0:x}:{2:x}".format(
 lldbutil.get_signal_number('SIGUSR1'),
-threads[0], threads[1]),
-{"direction": "send", "regex": r"^\$W00#b7$"},
-], True)
-
-context = self.expect_gdbremote_sequence()
-self.assertIsNotNone(context)
+*threads),
+threads)
 
 @skipUnlessPlatform(["netbsd"])
 def test_signal_two_of_three_threads(self):


Index: lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -31,6 +31,34 @@
 self.reset_test_sequence()
 return threads
 
+def send_and_check_signal(self, vCont_data, threads):
+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"),
+ "capture": dict((i, "tid{0}".format(i)) for i
+ in range(1, len(threads)+1)),
+ },
+], True)
+
+context = self.expect_gdbremote_sequence()
+self.assertIsNotNone(context)
+tids = sorted(int(context["tid{0}".format(x)], 16)
+  for x in range(1, len(threads)+1))
+self.assertEqual(tids, sorted(threads))
+
+@expectedFailureNetBSD
+def test_signal_process_without_tid(self):
+self.build()
+self.set_inferior_startup_launch()
+
+threads = self.start_threads(1)
+self.send_and_check_signal(
+"C{0:x}".format(lldbutil.get_signal_number('SIGUSR1')),
+threads)
+
 @skipUnlessPlatform(["netbsd"])
 @expectedFailureNetBSD
 def test_signal_one_thread(self):
@@ -39,16 +67,10 @@
 
 threads = self.start_threads(1)

[Lldb-commits] [PATCH] D98770: [lldb] Correct typo in memory read error

2021-03-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98770

Files:
  lldb/source/Commands/CommandObjectMemory.cpp


Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -608,7 +608,7 @@
   } else if (end_addr <= addr) {
 result.AppendErrorWithFormat(
 "end address (0x%" PRIx64
-") must be greater that the start address (0x%" PRIx64 ").\n",
+") must be greater than the start address (0x%" PRIx64 ").\n",
 end_addr, addr);
 result.SetStatus(eReturnStatusFailed);
 return false;


Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -608,7 +608,7 @@
   } else if (end_addr <= addr) {
 result.AppendErrorWithFormat(
 "end address (0x%" PRIx64
-") must be greater that the start address (0x%" PRIx64 ").\n",
+") must be greater than the start address (0x%" PRIx64 ").\n",
 end_addr, addr);
 result.SetStatus(eReturnStatusFailed);
 return false;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D98770: [lldb] Correct typo in memory read error

2021-03-17 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM (You can just land these straightforward patches directly without waiting 
for review, the dev policy allows that)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98770

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


[Lldb-commits] [PATCH] D98770: [lldb] Correct typo in memory read error

2021-03-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Thanks, I'll do that in future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98770

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


[Lldb-commits] [PATCH] D98770: [lldb] Correct typo in memory read error

2021-03-17 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Thanks! (and thanks for the patch)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98770

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


[Lldb-commits] [lldb] 4b513b2 - [lldb] Correct typo in memory read error

2021-03-17 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2021-03-17T10:38:31Z
New Revision: 4b513b2458d93a77ce6c45013ffc3e6838f4645f

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

LOG: [lldb] Correct typo in memory read error

Reviewed By: teemperor

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectMemory.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index 2aac4920a73b..3e7f67fcbc1f 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -608,7 +608,7 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
   } else if (end_addr <= addr) {
 result.AppendErrorWithFormat(
 "end address (0x%" PRIx64
-") must be greater that the start address (0x%" PRIx64 ").\n",
+") must be greater than the start address (0x%" PRIx64 ").\n",
 end_addr, addr);
 result.SetStatus(eReturnStatusFailed);
 return false;



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


[Lldb-commits] [PATCH] D98770: [lldb] Correct typo in memory read error

2021-03-17 Thread David Spickett via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b513b2458d9: [lldb] Correct typo in memory read error 
(authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98770

Files:
  lldb/source/Commands/CommandObjectMemory.cpp


Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -608,7 +608,7 @@
   } else if (end_addr <= addr) {
 result.AppendErrorWithFormat(
 "end address (0x%" PRIx64
-") must be greater that the start address (0x%" PRIx64 ").\n",
+") must be greater than the start address (0x%" PRIx64 ").\n",
 end_addr, addr);
 result.SetStatus(eReturnStatusFailed);
 return false;


Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -608,7 +608,7 @@
   } else if (end_addr <= addr) {
 result.AppendErrorWithFormat(
 "end address (0x%" PRIx64
-") must be greater that the start address (0x%" PRIx64 ").\n",
+") must be greater than the start address (0x%" PRIx64 ").\n",
 end_addr, addr);
 result.SetStatus(eReturnStatusFailed);
 return false;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D95602: [lldb][AArch64] Add MTE memory tag reading to lldb

2021-03-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 331209.
DavidSpickett added a comment.

- Use PRIx64 to properly print 64 bit addresses in invalid range error message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95602

Files:
  lldb/include/lldb/Core/Architecture.h
  lldb/include/lldb/Target/Process.h
  lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
  lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.h
  lldb/source/Plugins/Architecture/AArch64/CMakeLists.txt
  lldb/source/Plugins/Architecture/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/Process.cpp
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -657,3 +657,68 @@
   EXPECT_EQ(llvm::None, GetQOffsets("TextSeg=0x1234"));
   EXPECT_EQ(llvm::None, GetQOffsets("TextSeg=12345678123456789"));
 }
+
+static void
+check_qmemtags(TestClient &client, MockServer &server, size_t read_len,
+   const char *packet, llvm::StringRef response,
+   llvm::Optional> expected_tag_data) {
+  const auto &ReadMemoryTags = [&](size_t len, const char *packet,
+   llvm::StringRef response) {
+std::future result = std::async(std::launch::async, [&] {
+  return client.ReadMemoryTags(0xDEF0, read_len, 1);
+});
+
+HandlePacket(server, packet, response);
+return result.get();
+  };
+
+  auto result = ReadMemoryTags(0, packet, response);
+  if (expected_tag_data) {
+ASSERT_TRUE(result);
+llvm::ArrayRef expected(*expected_tag_data);
+llvm::ArrayRef got = result->GetData();
+ASSERT_THAT(expected, testing::ContainerEq(got));
+  } else {
+ASSERT_FALSE(result);
+  }
+}
+
+TEST_F(GDBRemoteCommunicationClientTest, ReadMemoryTags) {
+  // Zero length reads are valid
+  check_qmemtags(client, server, 0, "qMemTags:def0,0:1", "m",
+ std::vector{});
+
+  // The client layer does not check the length of the received data.
+  // All we need is the "m" and for the decode to use all of the chars
+  check_qmemtags(client, server, 32, "qMemTags:def0,20:1", "m09",
+ std::vector{0x9});
+
+  // Zero length response is fine as long as the "m" is present
+  check_qmemtags(client, server, 0, "qMemTags:def0,0:1", "m",
+ std::vector{});
+
+  // Normal responses
+  check_qmemtags(client, server, 16, "qMemTags:def0,10:1", "m66",
+ std::vector{0x66});
+  check_qmemtags(client, server, 32, "qMemTags:def0,20:1", "m0102",
+ std::vector{0x1, 0x2});
+
+  // Empty response is an error
+  check_qmemtags(client, server, 17, "qMemTags:def0,11:1", "", llvm::None);
+  // Usual error response
+  check_qmemtags(client, server, 17, "qMemTags:def0,11:1", "E01", llvm::None);
+  // Leading m missing
+  check_qmemtags(client, server, 17, "qMemTags:def0,11:1", "01", llvm::None);
+  // Anything other than m is an error
+  check_qmemtags(client, server, 17, "qMemTags:def0,11:1", "z01", llvm::None);
+  // Decoding tag data doesn't use all the chars in the packet
+  check_qmemtags(client, server, 32, "qMemTags:def0,20:1", "m09zz", llvm::None);
+  // Data that is not hex bytes
+  check_qmemtags(client, server, 32, "qMemTags:def0,20:1", "mhello",
+ llvm::None);
+  // Data is not a complete hex char
+  check_qmemtags(client, server, 32, "qMemTags:def0,20:1", "m9", llvm::None);
+  // Data has a trailing hex char
+  check_qmemtags(client, server, 32, "qMemTags:def0,20:1", "m01020",
+ llvm::None);
+}
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -6019,3 +6019,84 @@
 
   return false;
 }
+
+llvm::Expected
+Process::GetMemoryTagManager(lldb::addr_t addr, lldb::addr_t end_addr) {
+  Architecture *arch = GetTarget().GetArchitecturePlugin();
+  const MemoryTagManager *tag_manager =
+  arch ? arch->GetMemoryTagManager() : nullptr;
+  if (!arch || !tag_manager) {
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"This architecture does not support memory tagging",
+GetPluginName().GetCString());
+  }
+
+  if (!SupportsMemoryTagging()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Process does not support memory tagging");
+  }

[Lldb-commits] [PATCH] D98482: [lldb] Support for multiprocess extension [WIP]

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 331220.
mgorny edited the summary of this revision.
mgorny added a comment.

I've just discovered that `LLDB_INVALID_*_ID` isn't -1/UINT_MAX as I thought, 
so I've had to introduce additional constants. That said, I'm not convinced 
about the current 0/-1 API. Maybe it'd make sense to handle them directly in 
`ReadTid()` and return some (current?) thread ID for 0, and `LLDB_INVALID_*_ID` 
for -1?

Added vCont support along with tests.


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

https://reviews.llvm.org/D98482

Files:
  lldb/include/lldb/Utility/GDBRemoteError.h
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/source/Utility/CMakeLists.txt
  lldb/source/Utility/GDBRemoteError.cpp
  lldb/source/Utility/Status.cpp
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
  lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/StringExtractorGDBRemoteTest.cpp

Index: lldb/unittests/Utility/StringExtractorGDBRemoteTest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/StringExtractorGDBRemoteTest.cpp
@@ -0,0 +1,175 @@
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+#include "lldb/Utility/StringExtractorGDBRemote.h"
+#include "lldb/lldb-defines.h"
+
+namespace {
+class StringExtractorGDBRemoteTest : public ::testing::Test {};
+} // namespace
+
+TEST_F(StringExtractorGDBRemoteTest, GetPidTid) {
+  StringExtractorGDBRemote ex("");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  // invalid/short values
+
+  ex.Reset("narf");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset(";1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset(".1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("pnarf");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p;1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p.1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1234.");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1234.;1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("-2");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1234.-2");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p-2");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p-2.1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  // overflow
+
+  ex.Reset("p1");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1.0");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("1");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p0.1");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1.1");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  // pure thread id
+
+  ex.Reset("0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(), ::testing::Pair(100, 0));
+
+  ex.Reset("-1");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(100, LLDB_ALL_THREADS));
+
+  ex.Reset("1234");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(), ::testing::Pair(100, 0x1234ULL));
+
+  ex.Reset("123456789ABCDEF0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(100, 0x123456789ABCDEF0ULL));
+
+  // pure process id
+
+  ex.Reset("p0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(0, LLDB_ALL_THREADS));
+
+  ex.Reset("p-1");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(LLDB_ALL_PROCESSES, LLDB_ALL_THREADS));
+
+  ex.Reset("p1234");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(0x1234ULL, LLDB_ALL_THREADS));
+
+  ex.Reset("p123456789ABCDEF0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(0x123456789ABCDEF0ULL, LLDB_ALL_THREADS));
+
+  // combined thread id + process id
+
+  ex.Reset("p0.0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(), ::testing::Pair(0, 0));
+
+  ex.Reset("p0.-1");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(0, LLDB_ALL_THREADS));
+
+  // NB: technically, specific thread with unspecified process is invalid
+  // but we do not filter that in StringExtractor
+
+  ex.Reset("p0.1234");
+  EXPECT_THAT(ex.GetPidTid(100).

[Lldb-commits] [PATCH] D98179: [lit] Sort test start times based on prior test timing data

2021-03-17 Thread David Zarzycki via Phabricator via lldb-commits
davezarzycki added a comment.

Ah yes, of course. I've marked that test as unavailable on Window for now: 
61ca706461c5e1edc18526c9ddc3250fe074ed94 


In the long run, We'll need to figure out a way for people to commit 
cross-platform trace files but for now the more important record-and-reorder 
feature works cross platform.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98179

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


[Lldb-commits] [PATCH] D98179: [lit] Sort test start times based on prior test timing data

2021-03-17 Thread David Zarzycki via Phabricator via lldb-commits
davezarzycki added a comment.

I've run out of time for today, but for the record, I think we should use slash 
as the canonical separator for the timing data file. The actual separator 
doesn't matter because these strings are never used as paths, just as keys into 
a dictionary. (Therefore any character would work.) This would let us harmonize 
the Unix and Windows timing data files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98179

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


[Lldb-commits] [PATCH] D91524: Make iteration over the DeclContext::lookup_result safe.

2021-03-17 Thread Vassil Vassilev via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0cb7e7ca0c86: Make iteration over the 
DeclContext::lookup_result safe. (authored by v.g.vassilev).
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91524

Files:
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/CXXInheritance.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclContextInternals.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/ExternalASTMerger.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/PCH/cxx-explicit-specifier.cpp
  clang/tools/libclang/CXType.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -265,7 +265,7 @@
   clang::DeclContext::lookup_result result = decl_context->lookup(myName);
 
   if (!result.empty()) {
-clang::NamedDecl *named_decl = result[0];
+clang::NamedDecl *named_decl = *result.begin();
 if (const RecordDeclType *record_decl =
 llvm::dyn_cast(named_decl))
   compiler_type.SetCompilerType(
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -163,7 +163,6 @@
   if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
 if (auto *baseDtorDecl = base_record->getDestructor()) {
   if (baseDtorDecl->isVirtual()) {
-path.Decls = baseDtorDecl;
 decls.push_back(baseDtorDecl);
 return true;
   } else
@@ -171,12 +170,11 @@
 }
 
   // Otherwise, search for name in the base class.
-  for (path.Decls = base_record->lookup(name); !path.Decls.empty();
-   path.Decls = path.Decls.slice(1)) {
+  for (path.Decls = base_record->lookup(name).begin();
+   path.Decls != path.Decls.end(); ++path.Decls) {
 if (auto *method_decl =
-llvm::dyn_cast(path.Decls.front()))
+llvm::dyn_cast(*path.Decls))
   if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
-path.Decls = method_decl;
 decls.push_back(method_decl);
 return true;
   }
@@ -6605,10 +6603,11 @@
   if (cxx_record_decl->lookupInBases(
   [decl_name](const clang::CXXBaseSpecifier *specifier,
   clang::CXXBasePath &path) {
-path.Decls =
-specifier->getType()->getAsCXXRecordDecl()->lookup(
-decl_name);
-return !path.Decls.empty();
+CXXRecordDecl *record =
+  specifier->getType()->getAsCXXRecordDecl();
+auto r = record->lookup(decl_name);
+path.Decls = r.begin();
+return !r.empty();
   },
   paths)) {
 clang::CXXBasePaths::const_paths_iterator path,
@@ -6631,9 +6630,10 @@
   ->getDecl());
 }
   }
-  for (clang::NamedDecl *path_decl : path->Decls) {
+  for (clang::DeclContext::lookup_iterator I = path->Decls, E;
+   I != E; ++I) {
 child_idx = GetIndexForRecordChild(
-parent_record_decl, path_decl, omit_empty_base_classes);
+parent_record_decl, *I, omit_empty_base_classes);
 if (child

[Lldb-commits] [PATCH] D98179: [lit] Sort test start times based on prior test timing data

2021-03-17 Thread Julian Lettner via Phabricator via lldb-commits
yln added a comment.

In D98179#2629578 , @davezarzycki 
wrote:

> ... I think we should use slash as the canonical separator for the timing 
> data file.

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98179

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


[Lldb-commits] [PATCH] D91524: Make iteration over the DeclContext::lookup_result safe.

2021-03-17 Thread Vassil Vassilev via Phabricator via lldb-commits
v.g.vassilev added a comment.
Herald added a subscriber: JDevlieghere.

argh... I only now see the pre-merge suggestions -- almost all of them seem not 
super essential -- let me know if I should address them in a subsequent 
commit...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91524

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


[Lldb-commits] [PATCH] D98619: [lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF

2021-03-17 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I remember seeing this that this (duplicated) code was not dwarf5 ready, but I 
did not want to change it without understanding when it actually gets used. It 
looks like you've found that. Thanks for doing that, and for removing the 
duplication.




Comment at: lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s:98
+   .byte   86
+   .byte   3   # DW_AT_name
+   .byte   0   # DW_AT_decl_file

I was puzzled by this line as the string 3 is nowhere to be found. I take it 
this was manually reduced? If so, I think you should be able to delete the 
entire subprogram and base_type tags (and the relevant abbreviations), as that 
is not necessary for the line tables to work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98619

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


[Lldb-commits] [PATCH] D98482: [lldb] Support for multiprocess extension [WIP]

2021-03-17 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D98482#2626237 , @mgorny wrote:

> Create a new `GDBRemoteError` class to pass gdb-remote `$E` codes through 
> cleanly.

The error codes we use right now are completely meaningless, so don't bother 
preserving them. I don't think we should be introducing a separate error class 
on their account, and I'm particularly unhappy about how this class has 
insinuated itself into the Status object.

In D98482#2631420 , @mgorny wrote:

> I've just discovered that `LLDB_INVALID_*_ID` isn't -1/UINT_MAX as I thought, 
> so I've had to introduce additional constants. That said, I'm not convinced 
> about the current 0/-1 API. Maybe it'd make sense to handle them directly in 
> `ReadTid()` and return some (current?) thread ID for 0, and 
> `LLDB_INVALID_*_ID` for -1?

I think that decision which thread to use for the "any" thread should not be 
handled at such a low level, as it can have real impact on how the inferior 
behaves. I think using constants for this is fine. Although I applaud the 
avoidance of macros, I think the constants should also use non-macro 
nomenclature. Maybe just put the names inside the StringExtractorGdbRemote 
class, and call them `AnyThread` (etc.) ? Also, I think that these days we can 
just use constexpr variables instead of the enum hack.




Comment at: lldb/source/Utility/StringExtractorGDBRemote.cpp:625
+  uint64_t prev_index = m_index;
+  pid = GetHexMaxU64(false, 0);
+  if (m_index == prev_index || m_index == UINT64_MAX) {

This should be something like `view.consumeInteger(16, pid)`. At that point you 
can stop keeping m_index in sync, and just update it at the very end (maybe 
even via llvm::scope_exit).



Comment at: lldb/unittests/Utility/StringExtractorGDBRemoteTest.cpp:8-10
+namespace {
+class StringExtractorGDBRemoteTest : public ::testing::Test {};
+} // namespace

For empty fixtures, you can just drop this, along with the _F in the TEST_F 
macro.


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

https://reviews.llvm.org/D98482

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread Justin Cohen via Phabricator via lldb-commits
justincohen added a comment.

In the meantime, I'll look into adding something to the Crashpad minidump 
format to store an `addrable bits` mask, although I'm not clear how to grab 
this in userspace.  Should `sysctl machdep.virtual_address_size` work on iOS?  
Can I grab TCR_ELx.T0SZ directly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

Minidumps should have the registers in the processor context.  It seems LLDB 
knows about TCR_ELn for n > 0.  Maybe TCR_EL0 is special?

If it's not available in the minidump, we'll need a plan for how to deal with 
these regardless of when Jason's implementation lands.

Before reading Jason's response, I was independently wondering whether it makes 
sense to temporarily introduce a variable to let the user set the mask, just 
until the workaround is replaced with final code.  Given that there's 
precedent, I would support that.  (I've not implemented one of these LLDB 
settings before, but I imagine it's pretty straightforward.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

TCR_ELx begins at 1 (see `D13.2.123 TCR_EL1, Translation Control Register 
(EL1)` in the armarm) and covers EL0 and 1. Looking at the pseudocode access to 
this is undefined at EL0.

So the OS would have to provide you some other way to read that, I know this is 
missing on Linux at the moment. A user setting might be good for us supporting 
Linux too. (though I realise your immediate concern is MacOS)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [lldb] 96927ba - [lldb] Correct unsigned decimal argument check in memory write

2021-03-17 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2021-03-17T16:08:54Z
New Revision: 96927bafa41397f3f053ad705a57f5d834e3fb03

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

LOG: [lldb] Correct unsigned decimal argument check in memory write

getAsInteger returns false when it succeeds.

Before:
(lldb) memory write 0x77dd3000 99 -f "unsigned decimal"
error: '99' is not a valid unsigned decimal string value.

After:
(lldb) memory write 0x77dd3000 99 -f "unsigned decimal"
(lldb) memory read 0x77dd3000 0x77dd3001
0x77dd3000: 63   c

Added: 


Modified: 
lldb/source/Commands/CommandObjectMemory.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index 3e7f67fcbc1f..ca8487906fd0 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -1505,7 +1505,7 @@ class CommandObjectMemoryWrite : public 
CommandObjectParsed {
 
   case eFormatUnsigned:
 
-if (!entry.ref().getAsInteger(0, uval64)) {
+if (entry.ref().getAsInteger(0, uval64)) {
   result.AppendErrorWithFormat(
   "'%s' is not a valid unsigned decimal string value.\n",
   entry.c_str());



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


[Lldb-commits] [PATCH] D98482: [lldb] Support for multiprocess extension [WIP]

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

In D98482#2631817 , @labath wrote:

> In D98482#2626237 , @mgorny wrote:
>
>> Create a new `GDBRemoteError` class to pass gdb-remote `$E` codes through 
>> cleanly.
>
> The error codes we use right now are completely meaningless, so don't bother 
> preserving them. I don't think we should be introducing a separate error 
> class on their account, and I'm particularly unhappy about how this class has 
> insinuated itself into the Status object.

Well, I found the ability to use different codes useful for debugging tests but 
I guess it doesn't matter much. So a plain `StringError` then?




Comment at: lldb/source/Utility/StringExtractorGDBRemote.cpp:625
+  uint64_t prev_index = m_index;
+  pid = GetHexMaxU64(false, 0);
+  if (m_index == prev_index || m_index == UINT64_MAX) {

labath wrote:
> This should be something like `view.consumeInteger(16, pid)`. At that point 
> you can stop keeping m_index in sync, and just update it at the very end 
> (maybe even via llvm::scope_exit).
Do you have some specific method of updating it mind? Comparing size before and 
after?


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

https://reviews.llvm.org/D98482

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


[Lldb-commits] [PATCH] D98749: [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9cf21da776b5: [lldb] [test] Fix 
TestGdbRemote_vContThreads.py logic (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98749

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


Index: lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -31,6 +31,34 @@
 self.reset_test_sequence()
 return threads
 
+def send_and_check_signal(self, vCont_data, threads):
+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"),
+ "capture": dict((i, "tid{0}".format(i)) for i
+ in range(1, len(threads)+1)),
+ },
+], True)
+
+context = self.expect_gdbremote_sequence()
+self.assertIsNotNone(context)
+tids = sorted(int(context["tid{0}".format(x)], 16)
+  for x in range(1, len(threads)+1))
+self.assertEqual(tids, sorted(threads))
+
+@expectedFailureNetBSD
+def test_signal_process_without_tid(self):
+self.build()
+self.set_inferior_startup_launch()
+
+threads = self.start_threads(1)
+self.send_and_check_signal(
+"C{0:x}".format(lldbutil.get_signal_number('SIGUSR1')),
+threads)
+
 @skipUnlessPlatform(["netbsd"])
 @expectedFailureNetBSD
 def test_signal_one_thread(self):
@@ -39,16 +67,10 @@
 
 threads = self.start_threads(1)
 # try sending a signal to one of the two threads
-self.test_sequence.add_log_lines([
-"read packet: $vCont;C{0:x}:{1:x};c#00".format(
-lldbutil.get_signal_number('SIGUSR1'), threads[0]),
-{"direction": "send", "regex": r"^\$W00#b7$"},
-], True)
-
-context = self.expect_gdbremote_sequence()
-self.assertIsNotNone(context)
+self.send_and_check_signal(
+"C{0:x}:{1:x};c".format(lldbutil.get_signal_number('SIGUSR1')),
+threads[:1])
 
-@skipUnlessPlatform(["netbsd"])
 @expectedFailureNetBSD
 def test_signal_all_threads(self):
 self.build()
@@ -56,15 +78,11 @@
 
 threads = self.start_threads(1)
 # try sending a signal to two threads (= the process)
-self.test_sequence.add_log_lines([
-"read packet: $vCont;C{0:x}:{1:x};C{0:x}:{2:x}#00".format(
+self.send_and_check_signal(
+"C{0:x}:{1:x};C{0:x}:{2:x}".format(
 lldbutil.get_signal_number('SIGUSR1'),
-threads[0], threads[1]),
-{"direction": "send", "regex": r"^\$W00#b7$"},
-], True)
-
-context = self.expect_gdbremote_sequence()
-self.assertIsNotNone(context)
+*threads),
+threads)
 
 @skipUnlessPlatform(["netbsd"])
 def test_signal_two_of_three_threads(self):


Index: lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -31,6 +31,34 @@
 self.reset_test_sequence()
 return threads
 
+def send_and_check_signal(self, vCont_data, threads):
+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"),
+ "capture": dict((i, "tid{0}".format(i)) for i
+ in range(1, len(threads)+1)),
+ },
+], True)
+
+context = self.expect_gdbremote_sequence()
+self.assertIsNotNone(context)
+tids = sorted(int(context["tid{0}".format(x)], 16)
+  for x in range(1, len(threads)+1))
+self.assertEqual(tids, sorted(threads))
+
+@expectedFailureNetBSD
+def test_signal_process_without_tid(self):
+self.build()
+self.set_inferior_startup_launch()
+
+threads = self.start_threads(1)
+self.send_and_check_signal(
+"C{0:x}".format(lldbutil.get_signal_number('SIGUSR1')),
+threads)
+
 @skipUnlessPlatform(["netbsd"])
 @expectedFailureNetBSD
 def test_signal_one_thread(self):
@@ -39,

[Lldb-commits] [lldb] 9cf21da - [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

2021-03-17 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-03-17T17:30:28+01:00
New Revision: 9cf21da776b5e71da46826ba941147495285f106

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

LOG: [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

The TestGdbRemote_vContThreads.py were introduced to test NetBSD process
plugin's capability of sending per-thread and per-process signals.
However, at some point the tests started failing.  From retrospective,
it is possible that they were relying on some bug in the plugin's
original signal handling.

Fix the tests not to expect the process to terminate after receiving
the signals.  Instead, scan for output indicating that the signals were
received and match thread IDs in it.  Enable 'signal to all threads'
test everywhere as it works fine on Linux.  Add a new test for vCont
packet without specific thread IDs.  Introduce a helper function
to cover the common part of tests.

While this does not fix all the problems on NetBSD, it enables a subset
of the tests on other systems.  I am planning to add more tests
to the group while implementing multiprocess extension for vCont.

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

Added: 


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

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
index 5278d59fb06a..9243f71e8650 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -31,6 +31,34 @@ def start_threads(self, num):
 self.reset_test_sequence()
 return threads
 
+def send_and_check_signal(self, vCont_data, threads):
+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"),
+ "capture": dict((i, "tid{0}".format(i)) for i
+ in range(1, len(threads)+1)),
+ },
+], True)
+
+context = self.expect_gdbremote_sequence()
+self.assertIsNotNone(context)
+tids = sorted(int(context["tid{0}".format(x)], 16)
+  for x in range(1, len(threads)+1))
+self.assertEqual(tids, sorted(threads))
+
+@expectedFailureNetBSD
+def test_signal_process_without_tid(self):
+self.build()
+self.set_inferior_startup_launch()
+
+threads = self.start_threads(1)
+self.send_and_check_signal(
+"C{0:x}".format(lldbutil.get_signal_number('SIGUSR1')),
+threads)
+
 @skipUnlessPlatform(["netbsd"])
 @expectedFailureNetBSD
 def test_signal_one_thread(self):
@@ -39,16 +67,10 @@ def test_signal_one_thread(self):
 
 threads = self.start_threads(1)
 # try sending a signal to one of the two threads
-self.test_sequence.add_log_lines([
-"read packet: $vCont;C{0:x}:{1:x};c#00".format(
-lldbutil.get_signal_number('SIGUSR1'), threads[0]),
-{"direction": "send", "regex": r"^\$W00#b7$"},
-], True)
-
-context = self.expect_gdbremote_sequence()
-self.assertIsNotNone(context)
+self.send_and_check_signal(
+"C{0:x}:{1:x};c".format(lldbutil.get_signal_number('SIGUSR1')),
+threads[:1])
 
-@skipUnlessPlatform(["netbsd"])
 @expectedFailureNetBSD
 def test_signal_all_threads(self):
 self.build()
@@ -56,15 +78,11 @@ def test_signal_all_threads(self):
 
 threads = self.start_threads(1)
 # try sending a signal to two threads (= the process)
-self.test_sequence.add_log_lines([
-"read packet: $vCont;C{0:x}:{1:x};C{0:x}:{2:x}#00".format(
+self.send_and_check_signal(
+"C{0:x}:{1:x};C{0:x}:{2:x}".format(
 lldbutil.get_signal_number('SIGUSR1'),
-threads[0], threads[1]),
-{"direction": "send", "regex": r"^\$W00#b7$"},
-], True)
-
-context = self.expect_gdbremote_sequence()
-self.assertIsNotNone(context)
+*threads),
+threads)
 
 @skipUnlessPlatform(["netbsd"])
 def test_signal_two_of_three_threads(self):



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


[Lldb-commits] [PATCH] D98749: [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

2021-03-17 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.
Herald added a subscriber: JDevlieghere.

This broke the windows bot:

https://lab.llvm.org/buildbot/#/builders/83/builds/4725


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98749

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


[Lldb-commits] [PATCH] D98482: [lldb] Support for multiprocess extension [WIP]

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 331327.
mgorny marked 2 inline comments as done.
mgorny added a comment.

- switched thread-id parsing to use `view.consumeInteger()` and replaced 
`m_index` manipulations with a single update at the very end
- added additional test for parsing multiple thread-ids in a single packet (to 
verify that `m_index` is correctly updated)
- moved thread-id constants to `static constexpr` inside the class
- replaced `GDBError` with plain `StringError`s


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

https://reviews.llvm.org/D98482

Files:
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
  lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/StringExtractorGDBRemoteTest.cpp

Index: lldb/unittests/Utility/StringExtractorGDBRemoteTest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/StringExtractorGDBRemoteTest.cpp
@@ -0,0 +1,197 @@
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+#include "lldb/Utility/StringExtractorGDBRemote.h"
+#include "lldb/lldb-defines.h"
+
+TEST(StringExtractorGDBRemoteTest, GetPidTid) {
+  StringExtractorGDBRemote ex("");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  // invalid/short values
+
+  ex.Reset("narf");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset(";1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset(".1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("pnarf");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p;1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p.1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1234.");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1234.;1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("-2");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1234.-2");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p-2");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p-2.1234");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  // overflow
+
+  ex.Reset("p1");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1.0");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("1");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p0.1");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  ex.Reset("p1.1");
+  EXPECT_EQ(ex.GetPidTid(0), llvm::None);
+
+  // pure thread id
+
+  ex.Reset("0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(), ::testing::Pair(100, 0));
+
+  ex.Reset("-1");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(100, StringExtractorGDBRemote::AllThreads));
+
+  ex.Reset("1234");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(), ::testing::Pair(100, 0x1234ULL));
+
+  ex.Reset("123456789ABCDEF0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(100, 0x123456789ABCDEF0ULL));
+
+  // pure process id
+
+  ex.Reset("p0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(0, StringExtractorGDBRemote::AllThreads));
+
+  ex.Reset("p-1");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(StringExtractorGDBRemote::AllProcesses,
+  StringExtractorGDBRemote::AllThreads));
+
+  ex.Reset("p1234");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(0x1234ULL, StringExtractorGDBRemote::AllThreads));
+
+  ex.Reset("p123456789ABCDEF0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(0x123456789ABCDEF0ULL,
+  StringExtractorGDBRemote::AllThreads));
+
+  // combined thread id + process id
+
+  ex.Reset("p0.0");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(StringExtractorGDBRemote::AnyProcess,
+  StringExtractorGDBRemote::AnyThread));
+
+  ex.Reset("p0.-1");
+  EXPECT_THAT(ex.GetPidTid(100).getValue(),
+  ::testing::Pair(StringExtractorGDBRemote::AnyProcess,
+  StringExtractorGDBRemote::AllThreads));
+
+  // NB: technically, specific thread with uns

[Lldb-commits] [PATCH] D98749: [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

In D98749#2632299 , @stella.stamenova 
wrote:

> This broke the windows bot:
>
> https://lab.llvm.org/buildbot/#/builders/83/builds/4725

Just seen the mail, will commit a skip. I see that other similar tests are 
apparently skipped there too due to lack of pty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98749

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


[Lldb-commits] [lldb] 76c8a01 - [lldb] [test] Skip vCont tests on Windows

2021-03-17 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-03-17T19:22:58+01:00
New Revision: 76c8a016a1b5003447c1f875d857660e74343942

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

LOG: [lldb] [test] Skip vCont tests on Windows

Added: 


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

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
index 9243f71e8650..d33a9699f3b9 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -49,6 +49,7 @@ def send_and_check_signal(self, vCont_data, threads):
   for x in range(1, len(threads)+1))
 self.assertEqual(tids, sorted(threads))
 
+@skipIfWindows
 @expectedFailureNetBSD
 def test_signal_process_without_tid(self):
 self.build()
@@ -71,6 +72,7 @@ def test_signal_one_thread(self):
 "C{0:x}:{1:x};c".format(lldbutil.get_signal_number('SIGUSR1')),
 threads[:1])
 
+@skipIfWindows
 @expectedFailureNetBSD
 def test_signal_all_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] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

In D98529#2631946 , @DavidSpickett 
wrote:

> TCR_ELx begins at 1 (see `D13.2.123 TCR_EL1, Translation Control Register 
> (EL1)` in the armarm) and covers EL0 and 1. Looking at the pseudocode access 
> to this is undefined at EL0.

Ah LOL I hadn't read the ARM ARM when I wrote that, I thought this followed 
other control registers where EL0 and EL1 could have different settings here.  
My LC_NOTE only needed to record a single value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

In D98529#2631876 , @amccarth wrote:

> Before reading Jason's response, I was independently wondering whether it 
> makes sense to temporarily introduce a variable to let the user set the mask, 
> just until the workaround is replaced with final code.  Given that there's 
> precedent, I would support that.  (I've not implemented one of these LLDB 
> settings before, but I imagine it's pretty straightforward.)

I have a similar hack for kernel debugging where the kernel has a global gT1Sz 
and I read that in DynamicLoaderDarwinKernel.cpp,

  symbol = m_kernel.GetModule()->FindFirstSymbolWithNameAndType(
 arm64_T1Sz_value, eSymbolTypeData);
  if (symbol) {
if (symbol->GetByteSizeIsValid()) {
  addr_t sym_addr = symbol->GetLoadAddress(&m_process->GetTarget());
  uint64_t sym_value = m_process->GetTarget().ReadUnsignedIntegerFromMemory(
  sym_addr, false, bytesize, 0, error);
// 64 - T1Sz is the highest bit used for auth.
// The value we pass in to SetVirtualAddressableBits is
// the number of bits used for addressing, so if
// T1Sz is 25, then 64-25 == 39, bits 0..38 are used for
// addressing, bits 39..63 are used for PAC/TBI or whatever.
int virt_addr_bits = 64 - sym_value;
m_process->SetVirtualAddressableBits(virt_addr_bits);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

In D98529#2631860 , @justincohen wrote:

> In the meantime, I'll look into adding something to the Crashpad minidump 
> format to store an `addrable bits` mask, although I'm not clear how to grab 
> this in userspace.  Should `sysctl machdep.virtual_address_size` work on iOS? 
>  Can I grab TCR_ELx.T0SZ directly?

fwiw debugserver's code to provide the `addressing_bits:` in qHostInfo is 
upstreamed to the llvm.org sources, and it works on iOS as well,

  static bool GetAddressingBits(uint32_t &addressing_bits) {
static uint32_t g_addressing_bits = 0;
static bool g_tried_addressing_bits_syscall = false;
if (g_tried_addressing_bits_syscall == false) {
  size_t len = sizeof (uint32_t);
  if (::sysctlbyname("machdep.virtual_address_size",
&g_addressing_bits, &len, NULL, 0) != 0) {
g_addressing_bits = 0;
  }
}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread Peter Collingbourne via Phabricator via lldb-commits
pcc added a comment.

In D98529#2631946 , @DavidSpickett 
wrote:

> TCR_ELx begins at 1 (see `D13.2.123 TCR_EL1, Translation Control Register 
> (EL1)` in the armarm) and covers EL0 and 1. Looking at the pseudocode access 
> to this is undefined at EL0.
>
> So the OS would have to provide you some other way to read that, I know this 
> is missing on Linux at the moment. A user setting might be good for us 
> supporting Linux too. (though I realise your immediate concern is MacOS)

On Linux you can query the NT_ARM_PAC_MASK regset and examine the insn_mask 
field of the result.

Note that this is a mask rather than the number of bits as this also allows 
reflecting whether TBI{,D}0 was set at execution time. I would suggest using a 
mask in any persisted storage format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread Justin Cohen via Phabricator via lldb-commits
justincohen added a comment.

  uint32_t addressing_bits;
  size_t len = sizeof (uint32_t);
  ret = sysctlbyname("machdep.virtual_address_size", &addressing_bits, &len, 
NULL, 0);

returns ret == -1 on an iOS 14.4 device.  I do see this work on an m1 mac.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [PATCH] D98529: [lldb] Strip pointer authentication codes from aarch64 pc.

2021-03-17 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

In D98529#2632424 , @justincohen wrote:

>   uint32_t addressing_bits;
>   size_t len = sizeof (uint32_t);
>   ret = sysctlbyname("machdep.virtual_address_size", &addressing_bits, &len, 
> NULL, 0);
>
> returns ret == -1 on an iOS 14.4 device.  I do see this work on an m1 mac.

Hmmm let me install iOS 14.4 on a device and check.  The iOS devices have the 
default number of addressing bits in use (unlike the M1 
 macs) so it could be failing on iOS without me 
ever noticing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98529

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


[Lldb-commits] [lldb] a233d72 - [lldb/Docs] Update docs with new buildbot URLs

2021-03-17 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2021-03-17T20:09:03+01:00
New Revision: a233d72f0e1a5fdbc93bb9ccc4b57667b65272be

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

LOG: [lldb/Docs] Update docs with new buildbot URLs

Added: 


Modified: 
lldb/docs/resources/bots.rst

Removed: 




diff  --git a/lldb/docs/resources/bots.rst b/lldb/docs/resources/bots.rst
index f80a2333992b..8a43f53bd250 100644
--- a/lldb/docs/resources/bots.rst
+++ b/lldb/docs/resources/bots.rst
@@ -7,15 +7,15 @@ Buildbot
 LLVM Buildbot is the place where volunteers provide build machines. Everyone 
can
 `add a buildbot for LLDB `_.
 
-* `lldb-x64-windows-ninja `_
-* `lldb-x86_64-debian `_
-* `lldb-aarch64-ubuntu `_
-* `lldb-arm-ubuntu `_
-* `lldb-x86_64-fedora `_
+* `lldb-x64-windows-ninja `_
+* `lldb-x86_64-debian `_
+* `lldb-aarch64-ubuntu `_
+* `lldb-arm-ubuntu `_
+* `lldb-x86_64-fedora `_
 
-An overview of all LLDB builders can be found here:
+An overview of all LLDB builders (except Fedora) can be found here:
 
-`http://lab.llvm.org:8011/#/builders?tags=lldb 
`_
+`https://lab.llvm.org/buildbot/#/builders?tags=lldb 
`_
 
 GreenDragon
 ---



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


[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
mgorny requested review of this revision.

So far no real meat yet, just taking the API for a test drive.


https://reviews.llvm.org/D98822

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -201,6 +201,8 @@
 
   PacketResult Handle_g(StringExtractorGDBRemote &packet);
 
+  PacketResult Handle_qSupported_LLGS(StringExtractorGDBRemote &packet);
+
   void SetCurrentThreadID(lldb::tid_t tid);
 
   lldb::tid_t GetCurrentThreadID() const;
@@ -255,6 +257,9 @@
   bool allow_any = false,
   bool allow_all = false);
 
+  // Call SetEnabledExtensions() with appropriate flags on the process.
+  void SetEnabledExtensions(NativeProcessProtocol& process);
+
   // For GDBRemoteCommunicationServerLLGS only
   GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) =
   delete;
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
@@ -184,6 +184,9 @@
   RegisterMemberFunctionHandler(
   StringExtractorGDBRemote::eServerPacketType_QPassSignals,
   &GDBRemoteCommunicationServerLLGS::Handle_QPassSignals);
+  RegisterMemberFunctionHandler(
+  StringExtractorGDBRemote::eServerPacketType_qSupported,
+  &GDBRemoteCommunicationServerLLGS::Handle_qSupported_LLGS);
 
   RegisterMemberFunctionHandler(
   StringExtractorGDBRemote::eServerPacketType_jTraceStart,
@@ -254,6 +257,8 @@
 m_debugged_process_up = std::move(*process_or);
   }
 
+  SetEnabledExtensions(*m_debugged_process_up);
+
   // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as
   // needed. llgs local-process debugging may specify PTY paths, which will
   // make these file actions non-null process launch -i/e/o will also make
@@ -321,6 +326,7 @@
 return status;
   }
   m_debugged_process_up = std::move(*process_or);
+  SetEnabledExtensions(*m_debugged_process_up);
 
   // Setup stdout/stderr mapping from inferior.
   auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
@@ -3703,3 +3709,28 @@
 
   return tid;
 }
+
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::Handle_qSupported_LLGS(
+StringExtractorGDBRemote &packet) {
+  auto ret = Handle_qSupported(packet);
+  if (m_debugged_process_up)
+SetEnabledExtensions(*m_debugged_process_up);
+  return ret;
+}
+
+void GDBRemoteCommunicationServerLLGS::SetEnabledExtensions(
+NativeProcessProtocol &process) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  uint32_t flags = 0;
+  if (m_fork_events_supported)
+flags |= NativeProcessProtocol::Extension::fork;
+  if (m_vfork_events_supported)
+flags |= NativeProcessProtocol::Extension::vfork;
+
+  llvm::Error error = process.SetEnabledExtensions(flags);
+  if (error)
+LLDB_LOG_ERROR(log, std::move(error),
+   "Enabling protocol extensions failed: {0}");
+}
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
@@ -38,6 +38,8 @@
   uint32_t m_proc_infos_index;
   bool m_thread_suffix_supported;
   bool m_list_threads_in_stop_reply;
+  bool m_fork_events_supported;
+  bool m_vfork_events_supported;
 
   PacketResult Handle_A(StringExtractorGDBRemote &packet);
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/s

[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp:2026
+llvm::Error NativeProcessLinux::SetEnabledExtensions(uint32_t flags) {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Not implemented");

This is not intended to send errors like this, I've just added it to test 
logging.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:187
   &GDBRemoteCommunicationServerLLGS::Handle_QPassSignals);
+  RegisterMemberFunctionHandler(
+  StringExtractorGDBRemote::eServerPacketType_qSupported,

@labath, I'm not convinced this is the best way of doing it. Do you have any 
suggestions?


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

https://reviews.llvm.org/D98822

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


[Lldb-commits] [PATCH] D98826: [lldb] DWZ 6/9: Workaround DWZ bug dropping DW_TAG_namespace::DW_AT_export_symbols

2021-03-17 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added a reviewer: labath.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a reviewer: shafik.
jankratochvil requested review of this revision.

I have filed for dwz tool: Multifile drops 
DW_TAG_namespace::DW_AT_export_symbols 

Not sure if they fix it but nonetheless there are already corrupted debuginfos 
out there and it is easy to workaround.

All DWZ patches are also applied at: `git clone -b dwz 
git://git.jankratochvil.net/lldb`
There is a copy: `git clone -b dwz 
https://github.com/jankratochvil/llvm-project`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98826

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/test/Shell/SymbolFile/DWARF/dwz-namespace-inline.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwz-namespace-inline.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwz-namespace-inline.s
@@ -0,0 +1,198 @@
+# Workaround for DWZ tool bug producing corrupted DWARF:
+# Multifile drops DW_TAG_namespace::DW_AT_export_symbols
+# https://sourceware.org/bugzilla/show_bug.cgi?id=27572
+
+# REQUIRES: x86
+
+# RUN: %clang_host -o %t %s
+# RUN: %lldb %t -o 'b main' -o r -o 'p N::A::m' -o 'p N::m' \
+# RUN:   -o exit | FileCheck %s
+
+# CHECK-LABEL: (lldb) p N::A::m
+# CHECK-NEXT: (int (*)()) $0 = 0x{{.*}}`N::A::m())
+# CHECK-LABEL: (lldb) p N::m
+# Failing case was:
+# error: :1:4: no member named 'm' in namespace 'N'
+# CHECK-NEXT: (int (*)()) $1 = 0x{{.*}}`N::A::m())
+
+	.text
+	.globl	main# -- Begin function main
+	.type	main,@function
+main:   # @main
+.Lfunc_begin0:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	popq	%rbp
+	retq
+.Lfunc_end0:
+	.size	main, .Lfunc_end0-main
+# -- End function
+	.type	_ZN1N1AL1mEv,@function
+_ZN1N1AL1mEv:   # @_ZN1N1AL1mEv
+.Lfunc_begin1:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$42, %eax
+	popq	%rbp
+	retq
+.Lfunc_end1:
+	.size	_ZN1N1AL1mEv, .Lfunc_end1-_ZN1N1AL1mEv
+# -- End function
+	.section	.debug_abbrev,"",@progbits
+.Labbrev0:
+	.byte	1   # Abbreviation Code
+	.byte	17  # DW_TAG_compile_unit
+	.byte	1   # DW_CHILDREN_yes
+	.byte	37  # DW_AT_producer
+	.byte	8   # DW_FORM_string
+	.byte	19  # DW_AT_language
+	.byte	5   # DW_FORM_data2
+	.byte	3   # DW_AT_name
+	.byte	8   # DW_FORM_string
+	.byte	17  # DW_AT_low_pc
+	.byte	1   # DW_FORM_addr
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	3   # Abbreviation Code
+	.byte	57  # DW_TAG_namespace
+	.byte	1   # DW_CHILDREN_yes
+	.byte	3   # DW_AT_name
+	.byte	8   # DW_FORM_string
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	4   # Abbreviation Code
+	.byte	57  # DW_TAG_namespace
+	.byte	1   # DW_CHILDREN_yes
+	.byte	3   # DW_AT_name
+	.byte	8   # DW_FORM_string
+	.ascii	"\211\001"  # DW_AT_export_symbols
+	.byte	25  # DW_FORM_flag_present
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	5   # Abbreviation Code
+	.byte	46  # DW_TAG_subprogram
+	.byte	0   # DW_CHILDREN_no
+	.byte	17  # DW_AT_low_pc
+	.byte	1   # DW_FORM_addr
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	64  # DW_AT_frame_base
+	.byte	24  # DW_FORM_exprloc
+	.byte	0x47# DW_AT_specification
+	.byte	0x10# DW_FORM_ref_addr
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	6   # Abbreviation Code
+	.byte	36  # DW_TAG_base_type
+	.byte	0  

[Lldb-commits] [PATCH] D98761: Fix "image lookup --address" Summary results for inline functions.

2021-03-17 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 331404.
clayborg added a comment.

Remove extra parameter call to SymbolContext::DumpStopContext() recrusive call 
that was left over from iterating on my patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98761

Files:
  lldb/source/Symbol/SymbolContext.cpp
  lldb/test/Shell/Commands/command-image-lookup.yaml

Index: lldb/test/Shell/Commands/command-image-lookup.yaml
===
--- /dev/null
+++ lldb/test/Shell/Commands/command-image-lookup.yaml
@@ -0,0 +1,810 @@
+# RUN: yaml2obj %s -o %T/a.out
+# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa1" -o exit | FileCheck %s --check-prefix=NOINLINE
+# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa2" -o exit | FileCheck %s --check-prefix=INLINE_1
+# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa8" -o exit | FileCheck %s --check-prefix=INLINE_2
+
+#  NOINLINE: Summary: a.out`main + 33 at main.cpp:10
+# NOINLINE-NEXT: Module: file =
+
+#  INLINE_1: Summary: a.out`main + 34 [inlined] squares(int, int) at main.cpp:7:16
+# INLINE_1-NEXT:  a.out`main + 34 at main.cpp:11
+# INLINE_1-NEXT: Module: file =
+
+#  INLINE_2: Summary: a.out`main + 40 [inlined] square(int) at main.cpp:3:9
+# INLINE_2-NEXT: a.out`main + 40 [inlined] squares(int, int) + 6 at main.cpp:7
+# INLINE_2-NEXT: a.out`main + 34 at main.cpp:11
+# INLINE_2-NEXT: Module: file =
+
+
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x107
+  cpusubtype:  0x3
+  filetype:0xA
+  ncmds:   7
+  sizeofcmds:  1400
+  flags:   0x0
+  reserved:0x0
+LoadCommands:
+  - cmd: LC_UUID
+cmdsize: 24
+uuid:E476BFB9-CC5C-34BC-B968-BF996B298060
+  - cmd: LC_BUILD_VERSION
+cmdsize: 24
+platform:1
+minos:   659200
+sdk: 721152
+ntools:  0
+  - cmd: LC_SYMTAB
+cmdsize: 24
+symoff:  4096
+nsyms:   4
+stroff:  4160
+strsize: 54
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __PAGEZERO
+vmaddr:  0
+vmsize:  4294967296
+fileoff: 0
+filesize:0
+maxprot: 0
+initprot:0
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 232
+segname: __TEXT
+vmaddr:  4294967296
+vmsize:  16384
+fileoff: 0
+filesize:0
+maxprot: 5
+initprot:5
+nsects:  2
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x13F50
+size:100
+offset:  0x0
+align:   4
+reloff:  0x0
+nreloc:  0
+flags:   0x8400
+reserved1:   0x0
+reserved2:   0x0
+reserved3:   0x0
+content: CFFAEDFE070103000A00070078051B001800E476BFB9CC5C34BCB968BF996B29806032001800010F0A010B000200181004004010
+  - sectname:__unwind_info
+segname: __TEXT
+addr:0x13FB4
+size:72
+offset:  0x0
+align:   2
+reloff:  0x0
+nreloc:  0
+flags:   0x0
+reserved1:   0x0
+reserved2:   0x0
+reserved3:   0x0
+content: CFFAEDFE070103000A00070078051B001800E476BFB9CC5C34BCB968BF996B29806032001800010F0A00
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __LINKEDIT
+vmaddr:  4294983680
+vmsize:  4096
+fileoff: 4096
+filesize:118
+maxprot: 1
+initprot:1
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 952
+segname: __DWARF
+vmaddr:  4294987776
+vmsize:  4096
+fileoff: 8192
+filesize:1530
+maxprot: 7
+initprot:3
+nsects:  11
+flags:   0
+Sections:
+  - sectname:__debug_line
+segname: __DWARF
+addr:0x15000
+size:130
+offset:  0x2000
+align:   0
+reloff:  0x0
+nreloc:  0
+flags:   0x0
+reserved1:   0x0
+reserved2:   

[Lldb-commits] [PATCH] D98761: Fix "image lookup --address" Summary results for inline functions.

2021-03-17 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

If anyone wants to try this out, you can yaml2obj the yaml file and then do 
manual lookups. If you are on a mac, you can also debug any binary with inline 
function calls and stop anywhere and compare "bt" to the "image lookup 
--address $pc" to verify this works as expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98761

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


[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 331417.
mgorny added a comment.

Added option setting to the Linux plugin.


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

https://reviews.llvm.org/D98822

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -201,6 +201,8 @@
 
   PacketResult Handle_g(StringExtractorGDBRemote &packet);
 
+  PacketResult Handle_qSupported_LLGS(StringExtractorGDBRemote &packet);
+
   void SetCurrentThreadID(lldb::tid_t tid);
 
   lldb::tid_t GetCurrentThreadID() const;
@@ -255,6 +257,9 @@
   bool allow_any = false,
   bool allow_all = false);
 
+  // Call SetEnabledExtensions() with appropriate flags on the process.
+  void SetEnabledExtensions(NativeProcessProtocol& process);
+
   // For GDBRemoteCommunicationServerLLGS only
   GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) =
   delete;
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
@@ -184,6 +184,9 @@
   RegisterMemberFunctionHandler(
   StringExtractorGDBRemote::eServerPacketType_QPassSignals,
   &GDBRemoteCommunicationServerLLGS::Handle_QPassSignals);
+  RegisterMemberFunctionHandler(
+  StringExtractorGDBRemote::eServerPacketType_qSupported,
+  &GDBRemoteCommunicationServerLLGS::Handle_qSupported_LLGS);
 
   RegisterMemberFunctionHandler(
   StringExtractorGDBRemote::eServerPacketType_jTraceStart,
@@ -254,6 +257,8 @@
 m_debugged_process_up = std::move(*process_or);
   }
 
+  SetEnabledExtensions(*m_debugged_process_up);
+
   // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as
   // needed. llgs local-process debugging may specify PTY paths, which will
   // make these file actions non-null process launch -i/e/o will also make
@@ -321,6 +326,7 @@
 return status;
   }
   m_debugged_process_up = std::move(*process_or);
+  SetEnabledExtensions(*m_debugged_process_up);
 
   // Setup stdout/stderr mapping from inferior.
   auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
@@ -3703,3 +3709,28 @@
 
   return tid;
 }
+
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::Handle_qSupported_LLGS(
+StringExtractorGDBRemote &packet) {
+  auto ret = Handle_qSupported(packet);
+  if (m_debugged_process_up)
+SetEnabledExtensions(*m_debugged_process_up);
+  return ret;
+}
+
+void GDBRemoteCommunicationServerLLGS::SetEnabledExtensions(
+NativeProcessProtocol &process) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  uint32_t flags = 0;
+  if (m_fork_events_supported)
+flags |= NativeProcessProtocol::Extension::fork;
+  if (m_vfork_events_supported)
+flags |= NativeProcessProtocol::Extension::vfork;
+
+  llvm::Error error = process.SetEnabledExtensions(flags);
+  if (error)
+LLDB_LOG_ERROR(log, std::move(error),
+   "Enabling protocol extensions failed: {0}");
+}
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
@@ -38,6 +38,8 @@
   uint32_t m_proc_infos_index;
   bool m_thread_suffix_supported;
   bool m_list_threads_in_stop_reply;
+  bool m_fork_events_supported;
+  bool m_vfork_events_supported;
 
   PacketResult Handle_A(StringExtractorGDBRemote &packet);
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugi

[Lldb-commits] [PATCH] D98842: [lldb] Make the api, shell and unit tests independent lit test suites

2021-03-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor, stella.stamenova, kastiglione.
Herald added a subscriber: mgorny.
JDevlieghere requested review of this revision.

Make the api, shell and unit tests independent lit test suites. This allows us 
to specify different dependencies and skip rebuilding all the unit test (which 
is particularly expensive) when running `check-lldb-api` or `check-lldb-shell`. 
This does not change the autogenerated targets such as 
`check-lldb-shell-driver` or the top level `check-lldb` target, which all 
continue to work as before.


https://reviews.llvm.org/D98842

Files:
  lldb/test/API/CMakeLists.txt
  lldb/test/CMakeLists.txt
  lldb/test/Shell/CMakeLists.txt
  lldb/test/Unit/CMakeLists.txt
  lldb/unittests/CMakeLists.txt

Index: lldb/unittests/CMakeLists.txt
===
--- lldb/unittests/CMakeLists.txt
+++ lldb/unittests/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_custom_target(LLDBUnitTests)
 set_target_properties(LLDBUnitTests PROPERTIES FOLDER "lldb tests")
-add_dependencies(lldb-test-deps LLDBUnitTests)
+
+add_dependencies(lldb-unit-test-deps LLDBUnitTests)
 
 include_directories(${LLDB_SOURCE_ROOT})
 include_directories(${LLDB_PROJECT_ROOT}/unittests)
Index: lldb/test/Unit/CMakeLists.txt
===
--- lldb/test/Unit/CMakeLists.txt
+++ lldb/test/Unit/CMakeLists.txt
@@ -1,7 +1,16 @@
-# Configure the Unit test suite.
+add_custom_target(lldb-unit-test-deps)
+add_dependencies(lldb-unit-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-UNIT
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-unit-test-deps)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
+add_lit_testsuite(check-lldb-unit "Running lldb unit test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  DEPENDS lldb-unit-test-deps)
Index: lldb/test/Shell/CMakeLists.txt
===
--- lldb/test/Shell/CMakeLists.txt
+++ lldb/test/Shell/CMakeLists.txt
@@ -1,4 +1,10 @@
-# Configure the Shell test suite.
+add_custom_target(lldb-shell-test-deps)
+add_dependencies(lldb-shell-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-SHELL
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-shell-test-deps)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
@@ -8,10 +14,6 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/lit-lldb-init.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit-lldb-init)
 
-if (CMAKE_GENERATOR STREQUAL "Xcode")
-  # Xcode does not get the auto-generated targets. We need to create
-  # check-lldb-shell manually.
-  add_lit_testsuite(check-lldb-shell "Running lldb shell test suite"
-${CMAKE_CURRENT_BINARY_DIR}
-DEPENDS lldb-test-deps)
-endif()
+add_lit_testsuite(check-lldb-shell "Running lldb shell test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  DEPENDS lldb-shell-test-deps)
Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -182,18 +182,16 @@
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-add_lit_testsuites(LLDB
-  ${CMAKE_CURRENT_SOURCE_DIR}
-  DEPENDS lldb-test-deps)
-
 add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS lldb-test-deps)
+  DEPENDS
+lldb-api-test-deps
+lldb-shell-test-deps
+lldb-unit-test-deps)
 set_target_properties(check-lldb-lit PROPERTIES FOLDER "lldb tests")
 
 add_custom_target(check-lldb)
-add_dependencies(check-lldb lldb-test-deps)
-set_target_properties(check-lldb PROPERTIES FOLDER "lldb misc")
+set_target_properties(check-lldb PROPERTIES FOLDER "lldb tests")
 add_dependencies(check-lldb check-lldb-lit)
 
 # Add a lit test suite that runs the API & shell test while capturing a
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -1,3 +1,10 @@
+add_custom_target(lldb-api-test-deps)
+add_dependencies(lldb-api-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-API
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-api-test-deps)
+
 function(add_python_test_target name test_script args comment)
   set(PYTHON_TEST_COMMAND
 ${Python3_EXECUTABLE}
@@ -153,17 +160,12 @@
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
 
-# Configure the API test suite.
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-if (CMAKE_GENERATOR STREQUAL "X