[Lldb-commits] [PATCH] D127048: [lldb] Set COFF module ABI from default triple and make it an option

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

In D127048#3565557 , @omjavaid wrote:

> I am not fully familiar with PE/COFF but lets try to get this merged. For 
> starters I have a couple of questions here:
>
> 1. This rev apparently assumes x86_64 only but what about Arm/AArch64?

Where do you get that impression? This should all be architecture independent 
(or done in the same way for all architectures).

> 2. If we have DLLs what abi setting they ll follow the one set by the user or 
> default which may be MSVC?

Here, all DLLs are expected to use the same ABI (either the implicit one based 
on the LLDB build). D127234  is a follow-up 
that allows you to set a specific ABI choice per DLL.

> 3. Is there anything in PE/COFF header information that can serve is a good 
> guess for the underlying ABI.

No, there's no such hint. It's possible to make heuristic guesses based on e.g. 
what DLLs they import, but it's all guesses, possibly brittle. Having an option 
allows you to get it right even for the cases where the default is wrong.

> 4. What more information can we get from debug info in this case? DWARF may 
> not be a good guess as we can generate it for MSVC abi as well.

Exactly, one could use presence of DWARF as a heuristic hint for this, but it's 
not always right (you can use PDB for mingw uses too, and DWARF for msvc abi 
too in uncommon cases).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127048

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


[Lldb-commits] [PATCH] D126702: [lldb] Fix TCPSocket::Connect when getaddrinfo returns multiple addrs

2022-06-08 Thread Daniele Di Proietto via Phabricator via lldb-commits
ddiproietto added a comment.

I do not have commit access, can someone commit this for me, please?

Also, would it be possible for this to be cherry picked somewhere (apologies, 
I'm not familiar with the LLVM branching model), for an eventual 14.0.1 release?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126702

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


[Lldb-commits] [PATCH] D127289: [lldb] [llgs] Refactor SendStopReplyPacketForThread for multiprocess

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

Refactor SendStopReplyPacketForThread() to accept process instance
as a parameter rather than use m_current_process.  This future-proofs
it for multiprocess support.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D127289

Files:
  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
@@ -113,7 +113,8 @@
 
   PacketResult SendWResponse(NativeProcessProtocol *process);
 
-  PacketResult SendStopReplyPacketForThread(lldb::tid_t tid);
+  PacketResult SendStopReplyPacketForThread(NativeProcessProtocol &process,
+lldb::tid_t tid);
 
   PacketResult SendStopReasonForState(lldb::StateType process_state);
 
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
@@ -778,19 +778,13 @@
 
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
-lldb::tid_t tid) {
+NativeProcessProtocol &process, lldb::tid_t tid) {
   Log *log = GetLog(LLDBLog::Process | LLDBLog::Thread);
 
-  // Ensure we have a debugged process.
-  if (!m_current_process ||
-  (m_current_process->GetID() == LLDB_INVALID_PROCESS_ID))
-return SendErrorResponse(50);
-
-  LLDB_LOG(log, "preparing packet for pid {0} tid {1}",
-   m_current_process->GetID(), tid);
+  LLDB_LOG(log, "preparing packet for pid {0} tid {1}", process.GetID(), tid);
 
   // Ensure we can get info on the given thread.
-  NativeThreadProtocol *thread = m_current_process->GetThreadByID(tid);
+  NativeThreadProtocol *thread = process.GetThreadByID(tid);
   if (!thread)
 return SendErrorResponse(51);
 
@@ -813,7 +807,7 @@
   LLDB_LOG(
   log,
   "pid {0}, tid {1}, got signal signo = {2}, reason = {3}, exc_type = {4}",
-  m_current_process->GetID(), tid, signum, int(tid_stop_info.reason),
+  process.GetID(), tid, signum, int(tid_stop_info.reason),
   tid_stop_info.details.exception.type);
 
   // Print the signal number.
@@ -823,7 +817,7 @@
   response.PutCString("thread:");
   if (bool(m_extensions_supported &
NativeProcessProtocol::Extension::multiprocess))
-response.Format("p{0:x-}.", m_current_process->GetID());
+response.Format("p{0:x-}.", process.GetID());
   response.Format("{0:x-};", tid);
 
   // Include the thread name if there is one.
@@ -855,9 +849,9 @@
 
 uint32_t thread_index = 0;
 NativeThreadProtocol *listed_thread;
-for (listed_thread = m_current_process->GetThreadAtIndex(thread_index);
- listed_thread; ++thread_index,
-listed_thread = m_current_process->GetThreadAtIndex(thread_index)) {
+for (listed_thread = process.GetThreadAtIndex(thread_index); listed_thread;
+ ++thread_index,
+listed_thread = process.GetThreadAtIndex(thread_index)) {
   if (thread_index > 0)
 response.PutChar(',');
   response.Printf("%" PRIx64, listed_thread->GetID());
@@ -882,7 +876,7 @@
   } else {
 LLDB_LOG_ERROR(log, threads_info.takeError(),
"failed to prepare a jstopinfo field for pid {1}: {0}",
-   m_current_process->GetID());
+   process.GetID());
   }
 }
 
@@ -890,7 +884,7 @@
 response.PutCString("thread-pcs");
 char delimiter = ':';
 for (NativeThreadProtocol *thread;
- (thread = m_current_process->GetThreadAtIndex(i)) != nullptr; ++i) {
+ (thread = process.GetThreadAtIndex(i)) != nullptr; ++i) {
   NativeRegisterContext& reg_ctx = thread->GetRegisterContext();
 
   uint32_t reg_to_read = reg_ctx.ConvertRegisterKindToRegisterNumber(
@@ -1728,7 +1722,7 @@
 // Make sure we set the current thread so g and p packets return the data
 // the gdb will expect.
 SetCurrentThreadID(tid);
-return SendStopReplyPacketForThread(tid);
+return SendStopReplyPacketForThread(*m_current_process, tid);
   }
 
   case eStateInvalid:
@@ -3341,6 +3335,10 @@
 StringExtractorGDBRemote &packet) {
   Log *log = GetLog(LLDBLog::Thread);
 
+  if (!m_current_process ||
+  (m_current_process->GetID() == LLDB_INVALID_PROCESS_ID))
+return SendErrorResponse(50);
+
   packet.SetFilePos(strlen("qThre

[Lldb-commits] [PATCH] D127290: [lldb] [llgs] Refactor fork/vfork tests, verify state

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

Refactor the fork and vfork tests to reuse the code better, avoid
unnecessary regexps and avoid unnecessary conversions between
hex-strings and integers.

Verify the server state after detaching.  In particular, verify that
the detached process' PID/TID pair is no longer valid,
and that the correct process remains running.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D127290

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
@@ -6,6 +6,12 @@
 class TestGdbRemoteFork(gdbremote_testcase.GdbRemoteTestCaseBase):
 mydir = TestBase.compute_mydir(__file__)
 
+fork_regex = ("[$]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"}
+procinfo_regex = "[$]pid:([0-9a-f]+);.*"
+
 @add_test_categories(["fork"])
 def test_fork_multithreaded(self):
 self.build()
@@ -19,23 +25,17 @@
 fork_regex = "[$]T05.*;fork:p([0-9a-f]+)[.]([0-9a-f]+).*"
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": fork_regex,
- "capture": {1: "pid", 2: "tid"}},
+{"direction": "send", "regex": self.fork_regex.format("fork"),
+ "capture": self.fork_capture},
 ], True)
 ret = self.expect_gdbremote_sequence()
-pid = int(ret["pid"], 16)
+child_pid = ret["child_pid"]
 self.reset_test_sequence()
 
 # detach the forked child
 self.test_sequence.add_log_lines([
-"read packet: $D;{:x}#00".format(pid),
-{"direction": "send", "regex": r"[$]OK#.*"},
-], True)
-ret = self.expect_gdbremote_sequence()
-self.reset_test_sequence()
-
-# resume the parent
-self.test_sequence.add_log_lines([
+"read packet: $D;{}#00".format(child_pid),
+"send packet: $OK#00",
 "read packet: $k#00",
 ], True)
 self.expect_gdbremote_sequence()
@@ -50,45 +50,59 @@
 self.reset_test_sequence()
 
 # continue and expect fork
-fork_regex = "[$]T05.*;{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant)
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": fork_regex,
- "capture": {1: "pid", 2: "tid"}},
+{"direction": "send", "regex": self.fork_regex.format(variant),
+ "capture": self.fork_capture},
 ], True)
 ret = self.expect_gdbremote_sequence()
-pid = int(ret["pid"], 16)
+parent_pid = ret["parent_pid"]
+parent_tid = ret["parent_tid"]
+child_pid = ret["child_pid"]
+child_tid = ret["child_tid"]
 self.reset_test_sequence()
 
 # detach the forked child
 self.test_sequence.add_log_lines([
-"read packet: $D;{:x}#00".format(pid),
-{"direction": "send", "regex": r"[$]OK#.*"},
+"read packet: $D;{}#00".format(child_pid),
+"send packet: $OK#00",
+# verify that the current process is correct
+"read packet: $qC#00",
+"send packet: $QC{}#00".format(parent_tid),
+# verify that the correct processes are detached/available
+"read packet: $Hgp{}.{}#00".format(child_pid, child_tid),
+"send packet: $Eff#00",
+"read packet: $Hgp{}.{}#00".format(parent_pid, parent_tid),
+"send packet: $OK#00",
 ], True)
-ret = self.expect_gdbremote_sequence()
+self.expect_gdbremote_sequence()
 self.reset_test_sequence()
+return parent_pid, parent_tid
 
 @add_test_categories(["fork"])
 def test_fork(self):
-self.fork_and_detach_test("fork")
+parent_pid, _ = self.fork_and_detach_test("fork")
 
 # resume the parent
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
+"send packet: $W00;process:{}#00".format(parent_pid),
 ], True)
 self.expect_gdbremote_sequence()
 
 @add_test_categories(["fork"])
 def test_vfork(self):
-self.fork_and_detach_test("vfork")
+parent_pid, parent_tid = self.fork_and_detach_test("vfork")
 
 # resume the parent
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": 

[Lldb-commits] [PATCH] D127291: [lldb] [llgs] Add a test for detach-all packet

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

Add a test verifying that plain 'D' packet correctly detaches all
processes.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D127291

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
@@ -224,3 +224,44 @@
 "send packet: $E44#00",
 ], True)
 self.expect_gdbremote_sequence()
+
+@add_test_categories(["fork"])
+def test_detach_all(self):
+self.build()
+self.prep_debug_monitor_and_inferior(inferior_args=["fork"])
+self.add_qSupported_packets(["multiprocess+",
+ "fork-events+"])
+ret = self.expect_gdbremote_sequence()
+self.assertIn("fork-events+", ret["qSupported_response"])
+self.reset_test_sequence()
+
+# continue and expect fork
+fork_regex = "[$]T05.*;fork:p([0-9a-f]+)[.]([0-9a-f]+).*"
+self.test_sequence.add_log_lines([
+"read packet: $c#00",
+{"direction": "send", "regex": self.fork_regex.format("fork"),
+ "capture": self.fork_capture},
+], True)
+ret = self.expect_gdbremote_sequence()
+parent_pid = ret["parent_pid"]
+parent_tid = ret["parent_tid"]
+child_pid = ret["child_pid"]
+child_tid = ret["child_tid"]
+self.reset_test_sequence()
+
+self.test_sequence.add_log_lines([
+# double-check our PIDs
+"read packet: $Hgp{}.{}#00".format(parent_pid, parent_tid),
+"send packet: $OK#00",
+"read packet: $Hgp{}.{}#00".format(child_pid, child_tid),
+"send packet: $OK#00",
+# detach all processes
+"read packet: $D#00",
+"send packet: $OK#00",
+# verify that both PIDs are invalid now
+"read packet: $Hgp{}.{}#00".format(parent_pid, parent_tid),
+"send packet: $Eff#00",
+"read packet: $Hgp{}.{}#00".format(child_pid, child_tid),
+"send packet: $Eff#00",
+], True)
+self.expect_gdbremote_sequence()
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
@@ -3285,6 +3285,7 @@
 
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::Handle_D(StringExtractorGDBRemote &packet) {
+  Log *log = GetLog(LLDBLog::Process);
   StopSTDIOForwarding();
 
   lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
@@ -3308,6 +3309,9 @@
   for (auto it = m_debugged_processes.begin();
it != m_debugged_processes.end();) {
 if (pid == LLDB_INVALID_PROCESS_ID || pid == it->first) {
+  LLDB_LOGF(log,
+"GDBRemoteCommunicationServerLLGS::%s detaching %" PRId64,
+__FUNCTION__, it->first);
   if (llvm::Error e = it->second->Detach().ToError())
 detach_error = llvm::joinErrors(std::move(detach_error), std::move(e));
   else {


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
@@ -224,3 +224,44 @@
 "send packet: $E44#00",
 ], True)
 self.expect_gdbremote_sequence()
+
+@add_test_categories(["fork"])
+def test_detach_all(self):
+self.build()
+self.prep_debug_monitor_and_inferior(inferior_args=["fork"])
+self.add_qSupported_packets(["multiprocess+",
+ "fork-events+"])
+ret = self.expect_gdbremote_sequence()
+self.assertIn("fork-events+", ret["qSupported_response"])
+self.reset_test_sequence()
+
+# continue and expect fork
+fork_regex = "[$]T05.*;fork:p([0-9a-f]+)[.]([0-9a-f]+).*"
+self.test_sequence.add_log_lines([
+"read packet: $c#00",
+{"direction": "send", "regex": self.fork_regex.format("fork"),
+ "capture": self.fork_capture},
+], True)
+ret = self.expect_gdbremote_sequence()
+parent_pid = ret["parent_pid"]
+parent_tid = ret["parent_tid"]
+child_pid = ret["child_pid"]
+child_tid = ret["child_tid"]
+self.reset_test_sequence()
+
+self.test_sequence.add_log_l

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

2022-06-08 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] [PATCH] D127048: [lldb] Set COFF module ABI from default triple and make it an option

2022-06-08 Thread Alvin Wong via Phabricator via lldb-commits
alvinhochun added a comment.

Thanks @mstorsjo for answering for me.

>> 4. What more information can we get from debug info in this case? DWARF may 
>> not be a good guess as we can generate it for MSVC abi as well.
>
> Exactly, one could use presence of DWARF as a heuristic hint for this, but 
> it's not always right (you can use PDB for mingw uses too, and DWARF for msvc 
> abi too in uncommon cases).

I suppose we may try to look for mangled names and identify which name mangling 
scheme was used (MSVC vs Itanium ABI)? Though I am not keen on implementing it 
myself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127048

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


[Lldb-commits] [PATCH] D127290: [lldb] [llgs] Refactor fork/vfork tests, verify state

2022-06-08 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 435160.
mgorny added a comment.

Remove leftover local `fork_regex`.


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

https://reviews.llvm.org/D127290

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
@@ -6,6 +6,12 @@
 class TestGdbRemoteFork(gdbremote_testcase.GdbRemoteTestCaseBase):
 mydir = TestBase.compute_mydir(__file__)
 
+fork_regex = ("[$]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"}
+procinfo_regex = "[$]pid:([0-9a-f]+);.*"
+
 @add_test_categories(["fork"])
 def test_fork_multithreaded(self):
 self.build()
@@ -16,26 +22,19 @@
 self.reset_test_sequence()
 
 # continue and expect fork
-fork_regex = "[$]T05.*;fork:p([0-9a-f]+)[.]([0-9a-f]+).*"
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": fork_regex,
- "capture": {1: "pid", 2: "tid"}},
+{"direction": "send", "regex": self.fork_regex.format("fork"),
+ "capture": self.fork_capture},
 ], True)
 ret = self.expect_gdbremote_sequence()
-pid = int(ret["pid"], 16)
+child_pid = ret["child_pid"]
 self.reset_test_sequence()
 
 # detach the forked child
 self.test_sequence.add_log_lines([
-"read packet: $D;{:x}#00".format(pid),
-{"direction": "send", "regex": r"[$]OK#.*"},
-], True)
-ret = self.expect_gdbremote_sequence()
-self.reset_test_sequence()
-
-# resume the parent
-self.test_sequence.add_log_lines([
+"read packet: $D;{}#00".format(child_pid),
+"send packet: $OK#00",
 "read packet: $k#00",
 ], True)
 self.expect_gdbremote_sequence()
@@ -50,45 +49,59 @@
 self.reset_test_sequence()
 
 # continue and expect fork
-fork_regex = "[$]T05.*;{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant)
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": fork_regex,
- "capture": {1: "pid", 2: "tid"}},
+{"direction": "send", "regex": self.fork_regex.format(variant),
+ "capture": self.fork_capture},
 ], True)
 ret = self.expect_gdbremote_sequence()
-pid = int(ret["pid"], 16)
+parent_pid = ret["parent_pid"]
+parent_tid = ret["parent_tid"]
+child_pid = ret["child_pid"]
+child_tid = ret["child_tid"]
 self.reset_test_sequence()
 
 # detach the forked child
 self.test_sequence.add_log_lines([
-"read packet: $D;{:x}#00".format(pid),
-{"direction": "send", "regex": r"[$]OK#.*"},
+"read packet: $D;{}#00".format(child_pid),
+"send packet: $OK#00",
+# verify that the current process is correct
+"read packet: $qC#00",
+"send packet: $QC{}#00".format(parent_tid),
+# verify that the correct processes are detached/available
+"read packet: $Hgp{}.{}#00".format(child_pid, child_tid),
+"send packet: $Eff#00",
+"read packet: $Hgp{}.{}#00".format(parent_pid, parent_tid),
+"send packet: $OK#00",
 ], True)
-ret = self.expect_gdbremote_sequence()
+self.expect_gdbremote_sequence()
 self.reset_test_sequence()
+return parent_pid, parent_tid
 
 @add_test_categories(["fork"])
 def test_fork(self):
-self.fork_and_detach_test("fork")
+parent_pid, _ = self.fork_and_detach_test("fork")
 
 # resume the parent
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
+"send packet: $W00;process:{}#00".format(parent_pid),
 ], True)
 self.expect_gdbremote_sequence()
 
 @add_test_categories(["fork"])
 def test_vfork(self):
-self.fork_and_detach_test("vfork")
+parent_pid, parent_tid = self.fork_and_detach_test("vfork")
 
 # resume the parent
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]T05.*vforkdone.*"},
+{"direction": "send",
+ "regex": r"[$]T05thread:p{}[.]{}.*vforkdone.*".format(parent_pid,
+   parent_tid),
+ },
 "read packet: $c#00",
-{"direct

[Lldb-commits] [PATCH] D127291: [lldb] [llgs] Add a test for detach-all packet

2022-06-08 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 435162.
mgorny added a comment.

Remove leftover local `fork_regex`.


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

https://reviews.llvm.org/D127291

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
@@ -223,3 +223,43 @@
 "send packet: $E44#00",
 ], True)
 self.expect_gdbremote_sequence()
+
+@add_test_categories(["fork"])
+def test_detach_all(self):
+self.build()
+self.prep_debug_monitor_and_inferior(inferior_args=["fork"])
+self.add_qSupported_packets(["multiprocess+",
+ "fork-events+"])
+ret = self.expect_gdbremote_sequence()
+self.assertIn("fork-events+", ret["qSupported_response"])
+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("fork"),
+ "capture": self.fork_capture},
+], True)
+ret = self.expect_gdbremote_sequence()
+parent_pid = ret["parent_pid"]
+parent_tid = ret["parent_tid"]
+child_pid = ret["child_pid"]
+child_tid = ret["child_tid"]
+self.reset_test_sequence()
+
+self.test_sequence.add_log_lines([
+# double-check our PIDs
+"read packet: $Hgp{}.{}#00".format(parent_pid, parent_tid),
+"send packet: $OK#00",
+"read packet: $Hgp{}.{}#00".format(child_pid, child_tid),
+"send packet: $OK#00",
+# detach all processes
+"read packet: $D#00",
+"send packet: $OK#00",
+# verify that both PIDs are invalid now
+"read packet: $Hgp{}.{}#00".format(parent_pid, parent_tid),
+"send packet: $Eff#00",
+"read packet: $Hgp{}.{}#00".format(child_pid, child_tid),
+"send packet: $Eff#00",
+], True)
+self.expect_gdbremote_sequence()
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
@@ -3285,6 +3285,7 @@
 
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::Handle_D(StringExtractorGDBRemote &packet) {
+  Log *log = GetLog(LLDBLog::Process);
   StopSTDIOForwarding();
 
   lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
@@ -3308,6 +3309,9 @@
   for (auto it = m_debugged_processes.begin();
it != m_debugged_processes.end();) {
 if (pid == LLDB_INVALID_PROCESS_ID || pid == it->first) {
+  LLDB_LOGF(log,
+"GDBRemoteCommunicationServerLLGS::%s detaching %" PRId64,
+__FUNCTION__, it->first);
   if (llvm::Error e = it->second->Detach().ToError())
 detach_error = llvm::joinErrors(std::move(detach_error), std::move(e));
   else {


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
@@ -223,3 +223,43 @@
 "send packet: $E44#00",
 ], True)
 self.expect_gdbremote_sequence()
+
+@add_test_categories(["fork"])
+def test_detach_all(self):
+self.build()
+self.prep_debug_monitor_and_inferior(inferior_args=["fork"])
+self.add_qSupported_packets(["multiprocess+",
+ "fork-events+"])
+ret = self.expect_gdbremote_sequence()
+self.assertIn("fork-events+", ret["qSupported_response"])
+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("fork"),
+ "capture": self.fork_capture},
+], True)
+ret = self.expect_gdbremote_sequence()
+parent_pid = ret["parent_pid"]
+parent_tid = ret["parent_tid"]
+child_pid = ret["child_pid"]
+child_tid = ret["child_tid"]
+self.reset_test_sequence()
+
+self.test_sequence.add_log_lines([
+# double-check our PIDs
+"read packet: $Hgp{}.{}#00".format(parent_pid, parent_tid),
+"send packet: $OK#00",
+"read packet: $Hgp{}.{}#00".format(child_pid, child_tid),
+"send packet: $OK#00",
+  

[Lldb-commits] [PATCH] D127258: [lldb] Parse the dotest output to determine the most appropriate result code

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

Mark the test as FAIL or PASS if there's at least one test that respectively 
failed or passed.


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

https://reviews.llvm.org/D127258

Files:
  lldb/test/API/lldbtest.py


Index: lldb/test/API/lldbtest.py
===
--- lldb/test/API/lldbtest.py
+++ lldb/test/API/lldbtest.py
@@ -1,9 +1,11 @@
 from __future__ import absolute_import
 import os
-import tempfile
+import platform
+import re
 import subprocess
 import sys
-import platform
+import operator
+import tempfile
 
 import lit.Test
 import lit.TestRunner
@@ -88,20 +90,38 @@
 if timeoutInfo:
 return lit.Test.TIMEOUT, output
 
-if exitCode:
-if 'XPASS:' in out or 'XPASS:' in err:
-return lit.Test.XPASS, output
+# Parse the dotest output from stderr.
+result_regex = r"\((\d+) passes, (\d+) failures, (\d+) errors, (\d+) 
skipped, (\d+) expected failures, (\d+) unexpected successes\)"
+results = re.search(result_regex, err)
 
-# Otherwise this is just a failure.
-return lit.Test.FAIL, output
-
-has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
-has_passing_tests = 'PASS:' in out or 'PASS:' in err
-if has_unsupported_tests and not has_passing_tests:
-return lit.Test.UNSUPPORTED, output
-
-passing_test_line = 'RESULT: PASSED'
-if passing_test_line not in out and passing_test_line not in err:
+# If parsing fails mark this test as unresolved.
+if not results:
 return lit.Test.UNRESOLVED, output
 
-return lit.Test.PASS, output
+passes = int(results.group(1))
+failures = int(results.group(2))
+errors = int(results.group(3))
+skipped = int(results.group(4))
+expected_failures = int(results.group(5))
+unexpected_successes = int(results.group(6))
+
+if exitCode:
+# Mark this test as FAIL if at least one test failed.
+if failures > 0:
+return lit.Test.FAIL, output
+lit_results = [(failures, lit.Test.FAIL),
+   (errors, lit.Test.UNRESOLVED),
+   (unexpected_successes, lit.Test.XPASS)]
+else:
+# Mark this test as PASS if at least one test passes.
+if passes > 0:
+return lit.Test.PASS, output
+lit_results = [(passes, lit.Test.PASS),
+   (skipped, lit.Test.UNSUPPORTED),
+   (expected_failures, lit.Test.XFAIL)]
+
+# Sort the lit result codes by their corresponding number of
+# occurrences. Only look at the first element and rely on sorting
+# being stable for ties.
+lit_results.sort(reverse=True, key=operator.itemgetter(0))
+return lit_results[0][1], output


Index: lldb/test/API/lldbtest.py
===
--- lldb/test/API/lldbtest.py
+++ lldb/test/API/lldbtest.py
@@ -1,9 +1,11 @@
 from __future__ import absolute_import
 import os
-import tempfile
+import platform
+import re
 import subprocess
 import sys
-import platform
+import operator
+import tempfile
 
 import lit.Test
 import lit.TestRunner
@@ -88,20 +90,38 @@
 if timeoutInfo:
 return lit.Test.TIMEOUT, output
 
-if exitCode:
-if 'XPASS:' in out or 'XPASS:' in err:
-return lit.Test.XPASS, output
+# Parse the dotest output from stderr.
+result_regex = r"\((\d+) passes, (\d+) failures, (\d+) errors, (\d+) skipped, (\d+) expected failures, (\d+) unexpected successes\)"
+results = re.search(result_regex, err)
 
-# Otherwise this is just a failure.
-return lit.Test.FAIL, output
-
-has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
-has_passing_tests = 'PASS:' in out or 'PASS:' in err
-if has_unsupported_tests and not has_passing_tests:
-return lit.Test.UNSUPPORTED, output
-
-passing_test_line = 'RESULT: PASSED'
-if passing_test_line not in out and passing_test_line not in err:
+# If parsing fails mark this test as unresolved.
+if not results:
 return lit.Test.UNRESOLVED, output
 
-return lit.Test.PASS, output
+passes = int(results.group(1))
+failures = int(results.group(2))
+errors = int(results.group(3))
+skipped = int(results.group(4))
+expected_failures = int(results.group(5))
+unexpected_successes = int(results.group(6))
+
+if exitCode:
+# Mark this test as FAIL if at least one test failed.
+if failures > 0:
+return lit.Test.FAIL, output
+lit_res

[Lldb-commits] [PATCH] D127258: [lldb] Parse the dotest output to determine the most appropriate result code

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D127258#3565279 , @kastiglione 
wrote:

> instead of reducing and picking returning a single result, can we return the 
> raw counts and then report the totals of the counts?

No, the lit test format does not support that.


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

https://reviews.llvm.org/D127258

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


[Lldb-commits] [PATCH] D127258: [lldb] Parse the dotest output to determine the most appropriate result code

2022-06-08 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added inline comments.



Comment at: lldb/test/API/lldbtest.py:126
+# being stable for ties.
+lit_results.sort(reverse=True, key=operator.itemgetter(0))
+return lit_results[0][1], output

you could alternatively use `max(lit_results, key=...)`


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

https://reviews.llvm.org/D127258

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


[Lldb-commits] [lldb] d3202a5 - [lldb] Parse the dotest output to determine the most appropriate result code

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

Author: Jonas Devlieghere
Date: 2022-06-08T08:58:15-07:00
New Revision: d3202a5923173bc69767d86e605b012ad09de2a2

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

LOG: [lldb] Parse the dotest output to determine the most appropriate result 
code

Currently we look for keywords in the dotest.py output to determine the
lit result code. This binary approach of a keyword being present works
for PASS and FAIL, where having at least one test pass or fail
respectively results in that exit code. Things are more complicated
for tests that neither passed or failed, but report a combination of
(un)expected failures, skips or unresolved tests.

This patch changes the logic to parse the number of tests with a
particular result from the dotest.py output. For tests that did not PASS
or FAIL, we now report the lit result code for the one that occurred the
most. For example, if we had a test with 3 skips and 4 expected
failures, we report the test as XFAIL.

We're still mapping multiple tests to one result code, so some loss of
information is inevitable.

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

Added: 


Modified: 
lldb/test/API/lldbtest.py

Removed: 




diff  --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py
index 7f620c08ef856..e48e4c97a60b6 100644
--- a/lldb/test/API/lldbtest.py
+++ b/lldb/test/API/lldbtest.py
@@ -1,9 +1,7 @@
 from __future__ import absolute_import
 import os
-import tempfile
-import subprocess
-import sys
-import platform
+import re
+import operator
 
 import lit.Test
 import lit.TestRunner
@@ -88,20 +86,36 @@ def execute(self, test, litConfig):
 if timeoutInfo:
 return lit.Test.TIMEOUT, output
 
-if exitCode:
-if 'XPASS:' in out or 'XPASS:' in err:
-return lit.Test.XPASS, output
-
-# Otherwise this is just a failure.
-return lit.Test.FAIL, output
-
-has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
-has_passing_tests = 'PASS:' in out or 'PASS:' in err
-if has_unsupported_tests and not has_passing_tests:
-return lit.Test.UNSUPPORTED, output
+# Parse the dotest output from stderr.
+result_regex = r"\((\d+) passes, (\d+) failures, (\d+) errors, (\d+) 
skipped, (\d+) expected failures, (\d+) unexpected successes\)"
+results = re.search(result_regex, err)
 
-passing_test_line = 'RESULT: PASSED'
-if passing_test_line not in out and passing_test_line not in err:
+# If parsing fails mark this test as unresolved.
+if not results:
 return lit.Test.UNRESOLVED, output
 
-return lit.Test.PASS, output
+passes = int(results.group(1))
+failures = int(results.group(2))
+errors = int(results.group(3))
+skipped = int(results.group(4))
+expected_failures = int(results.group(5))
+unexpected_successes = int(results.group(6))
+
+if exitCode:
+# Mark this test as FAIL if at least one test failed.
+if failures > 0:
+return lit.Test.FAIL, output
+lit_results = [(failures, lit.Test.FAIL),
+   (errors, lit.Test.UNRESOLVED),
+   (unexpected_successes, lit.Test.XPASS)]
+else:
+# Mark this test as PASS if at least one test passed.
+if passes > 0:
+return lit.Test.PASS, output
+lit_results = [(passes, lit.Test.PASS),
+   (skipped, lit.Test.UNSUPPORTED),
+   (expected_failures, lit.Test.XFAIL)]
+
+# Return the lit result code with the maximum occurrence. Only look at
+# the first element and rely on the original order to break ties.
+return max(lit_results, key=operator.itemgetter(0))[1], output



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


[Lldb-commits] [lldb] 37028d3 - [lldb] Update TestMultithreaded to report FAIL for a non-zero exit code

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

Author: Jonas Devlieghere
Date: 2022-06-08T08:58:15-07:00
New Revision: 37028d3ea7fc9fa7e640c91faa9c347808598dd6

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

LOG: [lldb] Update TestMultithreaded to report FAIL for a non-zero exit code

A non-zero exit code from the test binary results in a
CalledProcessError. Without catching the exception, that would result in
a error (unresolved test) instead of a failure. This patch fixes that.

Added: 


Modified: 
lldb/test/API/api/multithreaded/TestMultithreaded.py

Removed: 




diff  --git a/lldb/test/API/api/multithreaded/TestMultithreaded.py 
b/lldb/test/API/api/multithreaded/TestMultithreaded.py
index 60c2c3b372cb3..71bc5db287296 100644
--- a/lldb/test/API/api/multithreaded/TestMultithreaded.py
+++ b/lldb/test/API/api/multithreaded/TestMultithreaded.py
@@ -108,12 +108,15 @@ def build_and_test(self, sources, test_name, args=None):
 env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
 if 'LLDB_DEBUGSERVER_PATH' in os.environ:
 env['LLDB_DEBUGSERVER_PATH'] = os.environ['LLDB_DEBUGSERVER_PATH']
-if self.TraceOn():
-print("Running test %s" % " ".join(exe))
-check_call(exe, env=env)
-else:
-with open(os.devnull, 'w') as fnull:
-check_call(exe, env=env, stdout=fnull, stderr=fnull)
+try:
+if self.TraceOn():
+print("Running test %s" % " ".join(exe))
+check_call(exe, env=env)
+else:
+with open(os.devnull, 'w') as fnull:
+check_call(exe, env=env, stdout=fnull, stderr=fnull)
+except subprocess.CalledProcessError as e:
+self.fail(e)
 
 def build_program(self, sources, program):
 return self.buildDriver(sources, program)



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


[Lldb-commits] [PATCH] D127258: [lldb] Parse the dotest output to determine the most appropriate result code

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd3202a592317: [lldb] Parse the dotest output to determine 
the most appropriate result code (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D127258?vs=435170&id=435199#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127258

Files:
  lldb/test/API/lldbtest.py


Index: lldb/test/API/lldbtest.py
===
--- lldb/test/API/lldbtest.py
+++ lldb/test/API/lldbtest.py
@@ -1,9 +1,7 @@
 from __future__ import absolute_import
 import os
-import tempfile
-import subprocess
-import sys
-import platform
+import re
+import operator
 
 import lit.Test
 import lit.TestRunner
@@ -88,20 +86,36 @@
 if timeoutInfo:
 return lit.Test.TIMEOUT, output
 
-if exitCode:
-if 'XPASS:' in out or 'XPASS:' in err:
-return lit.Test.XPASS, output
-
-# Otherwise this is just a failure.
-return lit.Test.FAIL, output
-
-has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
-has_passing_tests = 'PASS:' in out or 'PASS:' in err
-if has_unsupported_tests and not has_passing_tests:
-return lit.Test.UNSUPPORTED, output
+# Parse the dotest output from stderr.
+result_regex = r"\((\d+) passes, (\d+) failures, (\d+) errors, (\d+) 
skipped, (\d+) expected failures, (\d+) unexpected successes\)"
+results = re.search(result_regex, err)
 
-passing_test_line = 'RESULT: PASSED'
-if passing_test_line not in out and passing_test_line not in err:
+# If parsing fails mark this test as unresolved.
+if not results:
 return lit.Test.UNRESOLVED, output
 
-return lit.Test.PASS, output
+passes = int(results.group(1))
+failures = int(results.group(2))
+errors = int(results.group(3))
+skipped = int(results.group(4))
+expected_failures = int(results.group(5))
+unexpected_successes = int(results.group(6))
+
+if exitCode:
+# Mark this test as FAIL if at least one test failed.
+if failures > 0:
+return lit.Test.FAIL, output
+lit_results = [(failures, lit.Test.FAIL),
+   (errors, lit.Test.UNRESOLVED),
+   (unexpected_successes, lit.Test.XPASS)]
+else:
+# Mark this test as PASS if at least one test passed.
+if passes > 0:
+return lit.Test.PASS, output
+lit_results = [(passes, lit.Test.PASS),
+   (skipped, lit.Test.UNSUPPORTED),
+   (expected_failures, lit.Test.XFAIL)]
+
+# Return the lit result code with the maximum occurrence. Only look at
+# the first element and rely on the original order to break ties.
+return max(lit_results, key=operator.itemgetter(0))[1], output


Index: lldb/test/API/lldbtest.py
===
--- lldb/test/API/lldbtest.py
+++ lldb/test/API/lldbtest.py
@@ -1,9 +1,7 @@
 from __future__ import absolute_import
 import os
-import tempfile
-import subprocess
-import sys
-import platform
+import re
+import operator
 
 import lit.Test
 import lit.TestRunner
@@ -88,20 +86,36 @@
 if timeoutInfo:
 return lit.Test.TIMEOUT, output
 
-if exitCode:
-if 'XPASS:' in out or 'XPASS:' in err:
-return lit.Test.XPASS, output
-
-# Otherwise this is just a failure.
-return lit.Test.FAIL, output
-
-has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
-has_passing_tests = 'PASS:' in out or 'PASS:' in err
-if has_unsupported_tests and not has_passing_tests:
-return lit.Test.UNSUPPORTED, output
+# Parse the dotest output from stderr.
+result_regex = r"\((\d+) passes, (\d+) failures, (\d+) errors, (\d+) skipped, (\d+) expected failures, (\d+) unexpected successes\)"
+results = re.search(result_regex, err)
 
-passing_test_line = 'RESULT: PASSED'
-if passing_test_line not in out and passing_test_line not in err:
+# If parsing fails mark this test as unresolved.
+if not results:
 return lit.Test.UNRESOLVED, output
 
-return lit.Test.PASS, output
+passes = int(results.group(1))
+failures = int(results.group(2))
+errors = int(results.group(3))
+skipped = int(results.group(4))
+expected_failures = int(results.group(5))
+unexpected_successes = int(results.group(6))
+
+if exitCode:
+# Mark this test as FAIL if at least one test failed.
+if failures > 0:
+ 

[Lldb-commits] [PATCH] D126367: [lldb] Add gnu-debuglink support for Windows PE/COFF

2022-06-08 Thread Alvin Wong via Phabricator via lldb-commits
alvinhochun updated this revision to Diff 435214.
alvinhochun edited the summary of this revision.
alvinhochun added a comment.
This revision is now accepted and ready to land.

Added the fix to the Minidump find-module test, also updated the commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126367

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  lldb/source/Plugins/SymbolVendor/CMakeLists.txt
  lldb/source/Plugins/SymbolVendor/PECOFF/CMakeLists.txt
  lldb/source/Plugins/SymbolVendor/PECOFF/SymbolVendorPECOFF.cpp
  lldb/source/Plugins/SymbolVendor/PECOFF/SymbolVendorPECOFF.h
  lldb/source/Symbol/LocateSymbolFile.cpp
  lldb/test/Shell/Minidump/Windows/Inputs/find-module.exe.yaml
  lldb/test/Shell/ObjectFile/PECOFF/dwarf-gnu-debuglink-i686.yaml
  lldb/test/Shell/ObjectFile/PECOFF/dwarf-gnu-debuglink-mismatched-crc.yaml
  lldb/test/Shell/ObjectFile/PECOFF/dwarf-gnu-debuglink-pdb-buildid.yaml
  lldb/test/Shell/ObjectFile/PECOFF/dwarf-gnu-debuglink.yaml

Index: lldb/test/Shell/ObjectFile/PECOFF/dwarf-gnu-debuglink.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PECOFF/dwarf-gnu-debuglink.yaml
@@ -0,0 +1,50 @@
+# This test produces a stripped version of the object file and adds a
+# gnu-debuglink section to it linking to the unstripped version of the object
+# file. The debug info shall be loaded from the gnu-debuglink reference.
+
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t %t %t.stripped
+# RUN: lldb-test object-file %t.stripped | FileCheck %s
+
+# CHECK: Name: .debug_info
+# CHECK-NEXT: Type: dwarf-info
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 5152
+  ImageBase:   5368709120
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+header:
+  Machine: IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 64
+SectionData: DEADBEEFBAADF00D
+  - Name:.data
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  8192
+VirtualSize: 64
+SectionData: DEADBEEFBAADF00D
+  - Name:.debug_info
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  16384
+VirtualSize: 64
+SectionData: DEADBEEFBAADF00D
+symbols: []
+...
Index: lldb/test/Shell/ObjectFile/PECOFF/dwarf-gnu-debuglink-pdb-buildid.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PECOFF/dwarf-gnu-debuglink-pdb-buildid.yaml
@@ -0,0 +1,63 @@
+# This test produces a stripped version of the object file and adds a
+# gnu-debuglink section to it linking to the unstripped version of the object
+# file. Then the unstripped version is stripped to keep only debug info to
+# cause its crc to change. In this case the object files still have the
+# synthetic PDB build id that LLD adds even for the mingw target. Because this
+# build id still matches, the debug info shall still be loaded from the
+# gnu-debuglink reference.
+
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t %t %t.stripped
+# RUN: llvm-strip --only-keep-debug %t
+# RUN: lldb-test object-file %t.stripped | FileCheck %s
+
+# CHECK: Name: .debug_info
+# CHECK-NEXT: Type: dwarf-info
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 5152
+  ImageBase:   5368709120
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  Debug:
+RelativeVirtualAddress: 16384
+  

[Lldb-commits] [PATCH] D127252: [lldb] Use objc_getRealizedClassList_trylock if available

2022-06-08 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

One grammatical correction and a couple of questions.  But I'm also fine with 
the way it is.




Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp:2017
 
+  // Deallocate the memory we allocated for the Class array
+  if (class_buffer_addr != LLDB_INVALID_ADDRESS)

Is it worth doing these as exit_scope dingii so we don't have to worry about 
returning early w/o doing them?  There's a fairly long way from the 
AllocateMemory to the DeallocateMemory.



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h:318
+  /// objc_getRealizedClassList_trylock. The RealizedClassList variants are
+  /// preferred because it includes lazily named classes, but they are not
+  /// always available or safe to call.

grammar



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h:366
 
+/// Helper to read class info using objc_getRealizedClassList_trylock.
+struct objc_getRealizedClassList_trylock_helper {

You didn't do this, so it's not necessary to address it, but why do we have 
three identical structure definitions with just different names?  Were they 
going to be different at some point then ended up not being?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127252

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


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

2022-06-08 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

>>> If the theory is that this should keep working even with the library 
>>> changing without LLDB rebuild, then as I wrote above that theory needs 
>>> double-checking first. And additionally a good question to ask would be if 
>>> it's really a good idea to do incompatible implementation changes to a 
>>> class that has half of its functionality inline.
>>
>> Sorry, I wasn't meaning to discuss dynamic library versioning 
>> issues/mismatches, just static/fully matched versions.
>
> Then I still don't know what the problem is supposed to be. If the StringMap 
> hash implementation ever changes, the necessary LLDB rebuild will detect 
> this, the relevant LLDB parts will get adjusted and problem solved.

What I mean is if the cache is used across statically linked versions - eg: 
cache is created, someone installs an update to lldb, then the cache is read 
back and misinterprets the hashes in the cache if the hash algorithm had 
changed between versions.

>> Finally, there have been already attempts to change the hash function to use 
>> the better non-zero seed (D97396 ), and 
>> they were reverted because something depended on the hash function not 
>> changing, so I don't see it that likely for the hash function to change just 
>> like that in a minor update.
>
> That something seems to have been another part of lldb - and that's the sort 
> of change I'd like to enable/not make harder by avoiding more dependence on 
> this ordering/hashing.
>
>> But if after all this that's still the theory, I guess StringMap could get 
>> an additional template parameter specifying the hash function, if it's 
>> actually worth the effort.
>
> Yeah, a little traits class or the like is roughly what I'd picture.

^


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] [PATCH] D126513: Add -b (--continue-to-breakpoint) option to the "process continue" command

2022-06-08 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 435248.
jingham added a comment.

Fixed the option definition to specify this is a bkpt_id_list not a breakpoint 
id (since that's what it is now that we're using the breakpoint id list 
parser), and removed the verbiage that that made redundant.

Added one hopefully helpful comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126513

Files:
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/commands/process/continue_to_bkpt/Makefile
  lldb/test/API/commands/process/continue_to_bkpt/TestContinueToBkpts.py
  lldb/test/API/commands/process/continue_to_bkpt/main.c

Index: lldb/test/API/commands/process/continue_to_bkpt/main.c
===
--- /dev/null
+++ lldb/test/API/commands/process/continue_to_bkpt/main.c
@@ -0,0 +1,18 @@
+#include 
+
+int main (int argc, char const *argv[])
+{
+  int pass_me = argc + 10; // Stop here to get started.
+  printf("This is the zeroth stop\n");
+  printf("This is the first stop\n");
+  printf("This is the second stop\n");
+  printf("This is the third stop\n");
+  printf("This is the fourth stop\n");
+  printf("This is the fifth stop\n");
+  printf("This is the sixth stop\n");
+  printf("This is the seventh stop\n");
+  printf("This is the eighth stop\n");
+  printf("This is the nineth stop\n");
+
+  return 0;
+}
Index: lldb/test/API/commands/process/continue_to_bkpt/TestContinueToBkpts.py
===
--- /dev/null
+++ lldb/test/API/commands/process/continue_to_bkpt/TestContinueToBkpts.py
@@ -0,0 +1,124 @@
+"""
+Test the "process continue -t" option.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestContinueToBkpts(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
+mydir = TestBase.compute_mydir(__file__)
+
+@add_test_categories(['pyapi'])
+def test_continue_to_breakpoints(self):
+"""Test that the continue to breakpoints feature works correctly."""
+self.build()
+self.do_test_continue_to_breakpoint()
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+self.main_source_spec = lldb.SBFileSpec("main.c")
+
+def continue_and_check(self, stop_list, bkpt_to_hit, loc_to_hit = 0):
+"""Build up a command that will run a continue -b commands using the breakpoints on stop_list, and
+   ensure that we hit bkpt_to_hit.
+   If loc_to_hit is not 0, also verify that we hit that location."""
+command = "process continue"
+for elem in stop_list:
+command += " -b {0}".format(elem)
+self.expect(command)
+self.assertEqual(self.thread.stop_reason, lldb.eStopReasonBreakpoint, "Hit a breakpoint")
+self.assertEqual(self.thread.GetStopReasonDataAtIndex(0), bkpt_to_hit, "Hit the right breakpoint")
+if loc_to_hit != 0:
+self.assertEqual(self.thread.GetStopReasonDataAtIndex(1), loc_to_hit, "Hit the right location")
+for bkpt_id in self.bkpt_list:
+bkpt = self.target.FindBreakpointByID(bkpt_id)
+self.assertTrue(bkpt.IsValid(), "Breakpoint id's round trip")
+if bkpt.MatchesName("disabled"):
+self.assertFalse(bkpt.IsEnabled(), "Disabled breakpoints stay disabled: {0}".format(bkpt.GetID()))
+else:
+self.assertTrue(bkpt.IsEnabled(), "Enabled breakpoints stay enabled: {0}".format(bkpt.GetID()))
+# Also do our multiple location one:
+bkpt = self.target.FindBreakpointByID(self.multiple_loc_id)
+self.assertTrue(bkpt.IsValid(), "Breakpoint with locations round trip")
+for i in range(1,3):
+loc = bkpt.FindLocationByID(i)
+self.assertTrue(loc.IsValid(), "Locations round trip")
+if i == 2:
+self.assertTrue(loc.IsEnabled(), "Locations that were enabled stay enabled")
+else:
+self.assertFalse(loc.IsEnabled(), "Locations that were disabled stay disabled")
+
+def do_test_continue_to_breakpoint(self):
+"""Test the continue to breakpoint feature."""
+(self.target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+   "Stop here to get started", self.main_source_spec)
+
+# Now set up all our breakpoints:
+bkpt_pattern = "This is the {0} stop"
+bkpt_elements = ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth"]
+disabled_bkpts = ["first", "eigth"]
+bkpts_for_MyBKPT = ["first", "sixth", "nineth"]
+self.bkpt_list = []
+for elem in bkpt_elements:
+bkpt = self.target.BreakpointCreateBy

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

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

In D122974#3567278 , @dblaikie wrote:

>> Then I still don't know what the problem is supposed to be. If the StringMap 
>> hash implementation ever changes, the necessary LLDB rebuild will detect 
>> this, the relevant LLDB parts will get adjusted and problem solved.
>
> What I mean is if the cache is used across statically linked versions - eg: 
> cache is created, someone installs an update to lldb, then the cache is read 
> back and misinterprets the hashes in the cache if the hash algorithm had 
> changed between versions.

That is not going to happen, that updated LLDB will be using a different cache 
version. That's what the part you're replying to means. You cannot have two 
LLDB builds using the same cache version but different hash implementations, as 
long as you do not ignore LLDB unittests failing.


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] [PATCH] D127001: [trace][intelpt] Support system-wide tracing [16] - Create threads automatically from context switch data in the post-mortem case

2022-06-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 435263.
wallace added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127001

Files:
  lldb/include/lldb/Target/Trace.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.h
  lldb/source/Target/Trace.cpp
  lldb/test/API/commands/trace/TestTraceLoad.py
  
lldb/test/API/commands/trace/intelpt-multi-core-trace/trace_missing_threads.json

Index: lldb/test/API/commands/trace/intelpt-multi-core-trace/trace_missing_threads.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-multi-core-trace/trace_missing_threads.json
@@ -0,0 +1,44 @@
+{
+  "cores": [
+{
+  "contextSwitchTrace": "/tmp/trace8/cores/45.perf_context_switch_trace",
+  "coreId": 45,
+  "traceBuffer": "/tmp/trace8/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "/tmp/trace8/cores/51.perf_context_switch_trace",
+  "coreId": 51,
+  "traceBuffer": "/tmp/trace8/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+{
+  "modules": [
+{
+  "file": "modules/m.out",
+  "systemPath": "/tmp/m.out",
+  "loadAddress": 4194304,
+  "uuid": "AEFB0D59-233F-80FF-6D3C-4DED498534CF-11017B3B"
+}
+  ],
+  "pid": 3497234,
+  "threads": [
+{
+  "tid": 3497234
+}
+  ]
+}
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -21,6 +21,18 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+def testLoadMultiCoreTraceWithMissingThreads(self):
+src_dir = self.getSourceDir()
+trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_missing_threads.json")
+self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+self.expect("thread trace dump instructions 3 -t",
+  substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
+   "m.out`foo() + 65 at multi_thread.cpp:12:21",
+   "19520: [tsc=0x008fb5211bfbc69e] 0x00400ba7jg 0x400bb3"])
+self.expect("thread trace dump instructions 2 -t",
+  substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
+   "m.out`bar() + 26 at multi_thread.cpp:20:6"])
+
 def testLoadTrace(self):
 src_dir = self.getSourceDir()
 trace_definition_file = os.path.join(src_dir, "intelpt-trace", "trace.json")
Index: lldb/source/Target/Trace.cpp
===
--- lldb/source/Target/Trace.cpp
+++ lldb/source/Target/Trace.cpp
@@ -449,3 +449,14 @@
 return *m_cores;
   return {};
 }
+
+std::vector Trace::GetTracedProcesses() const {
+  std::vector processes;
+
+  for (Process *proc : m_postmortem_processes)
+processes.push_back(proc);
+
+  if (m_live_process)
+processes.push_back(m_live_process);
+  return processes;
+}
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.h
===
--- lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.h
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.h
@@ -52,7 +52,7 @@
   ///   errors, return a null pointer.
   llvm::Expected Parse();
 
-  lldb::TraceSP
+  llvm::Expected
   CreateTraceIntelPTInstance(JSONTraceSession &session,
  std::vector &parsed_processes);
 
@@ -64,6 +64,11 @@
   lldb::ThreadPostMortemTraceSP ParseThread(lldb::ProcessSP &process_sp,
 const JSONThread &thread);
 
+  /// Create the corresponding Threads and Process objects given the JSON
+  /// process definition.
+  ///
+  /// \param[in] process
+  ///   The JSON process definition
   llvm::Expected ParseProcess(const JSONProcess &process);
 
   llvm::Error ParseModule(lldb::TargetSP &target_sp, const JSONModule &module);
@@ -82,6 +87,8 @@
   llvm::Error CreateJSONError(llvm::json::Path::Root &root,
   const llvm::json::Value &value);
 
+  /// Create the corresp

[Lldb-commits] [PATCH] D125932: [trace][intelpt] Support system-wide tracing [10] - Return warnings and tsc information from lldb-server.

2022-06-08 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp:40
+IntelPTCollector::FetchPerfTscConversionParameters() {
+  if (!m_cached_tsc_conversion) {
+if (Expected tsc_conversion =

jj10306 wrote:
> Don't we want to always reload the parameters here (ie not do this check) 
> since they could potentially change  or is that not the case?
> We had discussions about this when I initially added the tsc conversion logic 
> but I can't remember so maybe you can help refresh my memory:
ahh, that's a good point. We should favor the most recent instructions, which 
means favoring the most recent conversion params


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125932

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


[Lldb-commits] [PATCH] D127252: [lldb] Use objc_getRealizedClassList_trylock if available

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 3 inline comments as done.
JDevlieghere added a comment.

Thanks Jim, I've addressed your comments in the final commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127252

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


[Lldb-commits] [lldb] fc43703 - [lldb] Use objc_getRealizedClassList_trylock on macOS Ventura and later

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

Author: Jonas Devlieghere
Date: 2022-06-08T11:34:27-07:00
New Revision: fc43703481d858351a72d7ea6f439f4f682ba351

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

LOG: [lldb] Use objc_getRealizedClassList_trylock on macOS Ventura and later

In order to avoid stranding the Objective-C runtime lock, we switched
from objc_copyRealizedClassList to its non locking variant
objc_copyRealizedClassList_nolock. Not taking the lock was relatively
safe because we run this expression on one thread only, but it was still
possible that someone was in the middle of modifying this list while we
were trying to read it. Worst case that would result in a crash in the
inferior without side-effects and we'd unwind and try again later.

With the introduction of macOS Ventura, we can use
objc_getRealizedClassList_trylock instead. It has semantics similar to
objc_copyRealizedClassList_nolock, but instead of not locking at all,
the function returns if the lock is already taken, which avoids the
aforementioned crash without stranding the Objective-C runtime lock.
Because LLDB gets to allocate the underlying memory we also avoid
stranding the malloc lock.

rdar://89373233

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

Added: 


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

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

lldb/test/API/lang/objc/conflicting-class-list-function-from-user/TestObjCClassListFunctionFromUser.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 467530fdfd7e7..191a1e0ad7ccc 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -284,7 +284,7 @@ def expectedFailureAll(bugnumber=None,
  archs=archs, triple=triple,
  debug_info=debug_info,
  swig_version=swig_version, py_version=py_version,
- macos_version=None,
+ macos_version=macos_version,
  remote=remote,dwarf_version=dwarf_version,
  setting=setting)
 

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index ccc68b55f5cb5..4194004fe61c7 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -6,20 +6,9 @@
 //
 
//===--===//
 
-#include 
-
-#include 
-#include 
-#include 
-
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/DeclObjC.h"
-
-#include "lldb/Host/OptionParser.h"
-#include "lldb/Symbol/CompilerType.h"
-#include "lldb/lldb-enumerations.h"
-
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/DebuggerEvents.h"
 #include "lldb/Core/Module.h"
@@ -30,11 +19,13 @@
 #include "lldb/Expression/DiagnosticManager.h"
 #include "lldb/Expression/FunctionCaller.h"
 #include "lldb/Expression/UtilityFunction.h"
+#include "lldb/Host/OptionParser.h"
 #include "lldb/Interpreter/CommandObject.h"
 #include "lldb/Interpreter/CommandObjectMultiword.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionValueBoolean.h"
+#include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/TypeList.h"
@@ -56,6 +47,7 @@
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
+#include "lldb/lldb-enumerations.h"
 
 #include "AppleObjCClassDescriptorV2.h"
 #include "AppleObjCDeclVendor.h"
@@ -66,9 +58,11 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/ScopeExit.h"
 
-#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
-
+#include 
+#include 
+#include 
 #include 
 
 using namespace lldb;
@@ -235,6 +229,78 @@ __lldb_apple_objc_v2_get_dynamic_class_info2(void 
*gdb_objc_realized_classes_ptr
 }
 )";
 
+static const char *g_get_dynamic_class_info3_name =
+"__lldb_apple_objc_v2_get_dynamic_class_info3";
+
+static const char *g_get_dynamic_class_info3_body = R"(
+
+extern "C" {
+int printf(const char * format, ...);
+void free(void *ptr);
+size_t 

[Lldb-commits] [PATCH] D127252: [lldb] Use objc_getRealizedClassList_trylock if available

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc43703481d8: [lldb] Use objc_getRealizedClassList_trylock 
on macOS Ventura and later (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D127252?vs=434941&id=435269#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127252

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/test/API/lang/objc/conflicting-class-list-function-from-user/TestObjCClassListFunctionFromUser.py

Index: lldb/test/API/lang/objc/conflicting-class-list-function-from-user/TestObjCClassListFunctionFromUser.py
===
--- lldb/test/API/lang/objc/conflicting-class-list-function-from-user/TestObjCClassListFunctionFromUser.py
+++ lldb/test/API/lang/objc/conflicting-class-list-function-from-user/TestObjCClassListFunctionFromUser.py
@@ -10,7 +10,7 @@
 @skipUnlessDarwin
 # LLDB ends up calling the user-defined function (but at least doesn't
 # crash).
-@expectedFailureDarwin
+@skipIf(macos_version=["<", "13.0"])
 def test(self):
 """
 Tests LLDB's behaviour if the user defines their own conflicting
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -313,13 +313,15 @@
   };
 
   /// We can read the class info from the Objective-C runtime using
-  /// gdb_objc_realized_classes or objc_copyRealizedClassList. The latter is
-  /// preferred because it includes lazily named classes, but it's not always
-  /// available or safe to call.
+  /// gdb_objc_realized_classes, objc_copyRealizedClassList or
+  /// objc_getRealizedClassList_trylock. The RealizedClassList variants are
+  /// preferred because they include lazily named classes, but they are not
+  /// always available or safe to call.
   ///
-  /// We potentially need both for the same process, because we may need to use
-  /// gdb_objc_realized_classes until dyld is initialized and then switch over
-  /// to objc_copyRealizedClassList for lazily named classes.
+  /// We potentially need more than one helper for the same process, because we
+  /// may need to use gdb_objc_realized_classes until dyld is initialized and
+  /// then switch over to objc_copyRealizedClassList or
+  /// objc_getRealizedClassList_trylock for lazily named classes.
   class DynamicClassInfoExtractor : public ClassInfoExtractor {
   public:
 DynamicClassInfoExtractor(AppleObjCRuntimeV2 &runtime)
@@ -329,11 +331,16 @@
 UpdateISAToDescriptorMap(RemoteNXMapTable &hash_table);
 
   private:
-enum Helper { gdb_objc_realized_classes, objc_copyRealizedClassList };
+enum Helper {
+  gdb_objc_realized_classes,
+  objc_copyRealizedClassList,
+  objc_getRealizedClassList_trylock
+};
 
-/// Compute which helper to use. Prefer objc_copyRealizedClassList if it's
-/// available and it's safe to call (i.e. dyld is fully initialized). Use
-/// gdb_objc_realized_classes otherwise.
+/// Compute which helper to use. If dyld is not yet fully initialized we
+/// must use gdb_objc_realized_classes. Otherwise, we prefer
+/// objc_getRealizedClassList_trylock and objc_copyRealizedClassList
+/// respectively, depending on availability.
 Helper ComputeHelper() const;
 
 UtilityFunction *GetClassInfoUtilityFunction(ExecutionContext &exe_ctx,
@@ -341,23 +348,17 @@
 lldb::addr_t &GetClassInfoArgs(Helper helper);
 
 std::unique_ptr
-GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx, std::string code,
-std::string name);
-
-/// Helper to read class info using the gdb_objc_realized_classes.
-struct gdb_objc_realized_classes_helper {
-  std::unique_ptr utility_function;
-  lldb::addr_t args = LLDB_INVALID_ADDRESS;
-};
+GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx, Helper helper,
+std::string code, std::string name);
 
-/// Helper to read class info using objc_copyRealizedClassList.
-struct objc_copyRealizedClassList_helper {
+struct UtilityFunctionHelper {
   std::unique_ptr utility_function;
   lldb::addr_t args = LLDB_INVALID_ADDRESS;
 };
 
-gdb_objc_realized_classes_helper m_gdb_objc_realized_classes_helper;
-objc_copyRealizedClassList_helper m_objc_copyRealizedClassList_helper;
+UtilityFunctionHelper m_gdb_objc_realized_classes_helper;
+UtilityFunctionHelper m_objc_copy

[Lldb-commits] [lldb] 4636b93 - [lldb] Improve error reporting from TestAppleSimulatorOSType.py

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

Author: Jonas Devlieghere
Date: 2022-06-08T11:47:26-07:00
New Revision: 4636b93044faf1fbf54139e872af4856adafe435

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

LOG: [lldb] Improve error reporting from TestAppleSimulatorOSType.py

When we can't find a simulator, report the platform and architecture in
the error message.

Added: 


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

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index beb62f1ebe1a5..a9fe3af3d21f1 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -49,7 +49,7 @@ def check_simulator_ostype(self, sdk, platform_name, 
arch=platform.machine()):
 break
 
 # Launch the process using simctl
-self.assertIsNotNone(deviceUDID)
+self.assertIsNotNone(deviceUDID, 'Could not find a simulator for {} 
({})'.format(platform_name, arch))
 
 exe_name = 'test_simulator_platform_{}'.format(platform_name)
 sdkroot = lldbutil.get_xcode_sdk_root(sdk)



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


[Lldb-commits] [PATCH] D127331: [lldb] Update TestModuleLoadedNotifys.py for macOS Ventura

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: jasonmolenda.
Herald added a project: All.
JDevlieghere requested review of this revision.

On macOS Ventura and later, dyld and the main binary will be loaded again when 
dyld moves itself into the shared cache. Update the test accordingly.


https://reviews.llvm.org/D127331

Files:
  
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py


Index: 
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
===
--- 
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -80,14 +80,17 @@
 total_modules_added_events += 1
 total_solibs_added += solib_count
 added_files = []
-i = 0
-while i < solib_count:
+for i in range (solib_count):
 module = lldb.SBTarget.GetModuleAtIndexFromEvent(i, 
event)
-self.assertTrue(module not in already_loaded_modules)
+# On macOS Ventura and later, dyld and the main binary
+# will be loaded again when dyld moves itself into the
+# shared cache.
+if module.file.fullpath in ['/usr/lib/dyld', exe]:
+continue
+self.assertTrue(module not in already_loaded_modules, 
'{} is already loaded'.format(module))
 already_loaded_modules.append(module)
 if self.TraceOn():
 
added_files.append(module.GetFileSpec().GetFilename())
-i = i + 1
 if self.TraceOn():
 # print all of the binaries that have been added
 print("Loaded files: %s" % (', '.join(added_files)))


Index: lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
===
--- lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -80,14 +80,17 @@
 total_modules_added_events += 1
 total_solibs_added += solib_count
 added_files = []
-i = 0
-while i < solib_count:
+for i in range (solib_count):
 module = lldb.SBTarget.GetModuleAtIndexFromEvent(i, event)
-self.assertTrue(module not in already_loaded_modules)
+# On macOS Ventura and later, dyld and the main binary
+# will be loaded again when dyld moves itself into the
+# shared cache.
+if module.file.fullpath in ['/usr/lib/dyld', exe]:
+continue
+self.assertTrue(module not in already_loaded_modules, '{} is already loaded'.format(module))
 already_loaded_modules.append(module)
 if self.TraceOn():
 added_files.append(module.GetFileSpec().GetFilename())
-i = i + 1
 if self.TraceOn():
 # print all of the binaries that have been added
 print("Loaded files: %s" % (', '.join(added_files)))
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D127331: [lldb] Update TestModuleLoadedNotifys.py for macOS Ventura

2022-06-08 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D127331

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


[Lldb-commits] [PATCH] D127336: [lldb] Remove default argument from getBuildArtifact

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
Herald added a project: All.
JDevlieghere requested review of this revision.

Remove default argument from lldbtest.getBuildArtifact.


https://reviews.llvm.org/D127336

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py
  lldb/test/API/iohandler/sigint/TestProcessIOHandlerInterrupt.py
  lldb/test/API/lang/cpp/class_types/TestClassTypes.py
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/test/API/qemu/TestQemuLaunch.py

Index: lldb/test/API/qemu/TestQemuLaunch.py
===
--- lldb/test/API/qemu/TestQemuLaunch.py
+++ lldb/test/API/qemu/TestQemuLaunch.py
@@ -45,7 +45,7 @@
 
 def _create_target(self):
 self.build()
-exe = self.getBuildArtifact()
+exe = self.getBuildArtifact("a.out")
 
 # Create a target using our platform
 error = lldb.SBError()
@@ -78,7 +78,7 @@
 def test_basic_launch(self):
 state = self._run_and_get_state()
 
-self.assertEqual(state["program"], self.getBuildArtifact())
+self.assertEqual(state["program"], self.getBuildArtifact("a.out"))
 self.assertEqual(state["args"],
 ["dump:" + self.getBuildArtifact("state.log")])
 
@@ -118,7 +118,7 @@
 
 def test_stdio_redirect(self):
 self.build()
-exe = self.getBuildArtifact()
+exe = self.getBuildArtifact("a.out")
 
 # Create a target using our platform
 error = lldb.SBError()
@@ -168,7 +168,7 @@
 self.addTearDownHook(cleanup)
 state = self._run_and_get_state()
 
-self.assertEqual(state["program"], self.getBuildArtifact())
+self.assertEqual(state["program"], self.getBuildArtifact("a.out"))
 self.assertEqual(state["args"],
 ["dump:" + self.getBuildArtifact("state.log")])
 
@@ -247,7 +247,7 @@
 self.runCmd("settings set target.arg0 ARG0")
 state = self._run_and_get_state(target)
 
-self.assertEqual(state["program"], self.getBuildArtifact())
+self.assertEqual(state["program"], self.getBuildArtifact("a.out"))
 self.assertEqual(state["0"], "ARG0")
 
 def test_sysroot(self):
Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -14,7 +14,7 @@
 def check_load_commands(self, expected_load_command):
 """sanity check the built binary for the expected number of load commands"""
 load_cmds = subprocess.check_output(
-['otool', '-l', self.getBuildArtifact()]
+['otool', '-l', self.getBuildArtifact("a.out")]
 ).decode("utf-8")
 found = 0
 for line in load_cmds.split('\n'):
Index: lldb/test/API/lang/cpp/class_types/TestClassTypes.py
===
--- lldb/test/API/lang/cpp/class_types/TestClassTypes.py
+++ lldb/test/API/lang/cpp/class_types/TestClassTypes.py
@@ -69,7 +69,7 @@
 fsDir = os.path.normpath(filespec.GetDirectory())
 fsFile = filespec.GetFilename()
 
-self.assertTrue(fsDir == os.path.dirname(self.getBuildArtifact())
+self.assertTrue(fsDir == os.path.dirname(self.getBuildArtifact("a.out"))
 and fsFile == "a.out",
 "FileSpec matches the executable")
 
@@ -184,7 +184,7 @@
 fsDir = os.path.normpath(filespec.GetDirectory())
 fsFile = filespec.GetFilename()
 
-self.assertTrue(fsDir == os.path.dirname(self.getBuildArtifact())
+self.assertTrue(fsDir == os.path.dirname(self.getBuildArtifact("a.out"))
 and fsFile == "a.out",
 "FileSpec matches the executable")
 
Index: lldb/test/API/iohandler/sigint/TestProcessIOHandlerInterrupt.py
===
--- lldb/test/API/iohandler/sigint/TestProcessIOHandlerInterrupt.py
+++ lldb/test/API/iohandler/sigint/TestProcessIOHandlerInterrupt.py
@@ -17,7 +17,7 @@
 @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
 def test(self):
 self.build(dictionary={"CXX_SOURCES":"cat.cpp"})
-self.launch(executable=self.getBuildArtifact())
+self.launch(executable=self.getBuildArtifact("a.out"))
 
 self.child.sendline("process launch")
 self.child.expect("Process .* launched")
Index: lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestPlatformKill.py
@@ -15,7 +15,7 @@
 """Test connecting to a remote linux platform"""
 
 self.build

[Lldb-commits] [PATCH] D127355: [lldb] Add assertState function

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: kastiglione, mib.
Herald added a project: All.
JDevlieghere requested review of this revision.

Add a function to make it easier to debug a test failure caused by an 
unexpected state. Currently, tests are using `assertEqual` which results in a 
cryptic error message: "AssertionError: 5 != 10". Even when a test provides a 
message to make it clear why a particular state is expected, you still have to 
figure out which of the two numbers was the expected state and what the actual 
state corresponds to. We have a function in `lldbutil` that helps you convert 
the state number into a user readable string. This patch adds a wrapper around 
`assertEqual` specifically for comparing states. The aforementioned error 
message now looks like this: "AssertionError: 5 != 10 : stopped != exited". If 
the user provided a message, that gets displayed as well.


https://reviews.llvm.org/D127355

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
  
lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
  lldb/test/API/functionalities/breakpoint/move_nearest/TestMoveNearest.py
  
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/test/API/functionalities/completion/TestCompletion.py
  
lldb/test/API/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
  lldb/test/API/functionalities/launch_stop_at_entry/TestStopAtEntry.py
  lldb/test/API/functionalities/return-value/TestReturnValue.py
  lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
  lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
  lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
  lldb/test/API/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
  lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
  lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
  lldb/test/API/linux/add-symbols/TestTargetSymbolsAddCommand.py
  lldb/test/API/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py
  lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
  lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
  lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
  lldb/test/API/python_api/objc_type/TestObjCType.py
  lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
  lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py

Index: lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
===
--- lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
+++ lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
@@ -27,7 +27,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
Index: lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
===
--- lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
+++ lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
@@ -59,7 +59,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
@@ -136,7 +136,7 @@
 # Now continue.
 process.Continue()
 
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
@@ -169,7 +169,7 @@
 
 process.Continue()
 
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
Index: lldb/test/API/python_api/objc_type/TestObjCType.py
===
--- lldb/test/API/python_api/objc_type/TestObjCType.py
+++ lldb/test/API/python_api/objc_type/TestObjCType.py
@@ -39,7 +39,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(

[Lldb-commits] [lldb] 0f02dd3 - [lldb/Commands] Prevent crash due to reading memory from page zero.

2022-06-08 Thread Chelsea Cassanova via lldb-commits

Author: Chelsea Cassanova
Date: 2022-06-08T18:10:41-04:00
New Revision: 0f02dd34f22650d8af0070e7ad21632525e33da8

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

LOG: [lldb/Commands] Prevent crash due to reading memory from page zero.

Adds a check to ensure that a process exists before attempting to get
its ABI to prevent lldb from crashing due to trying to read from page zero.

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

Added: 
lldb/test/Shell/Driver/TestPageZeroRead.test

Modified: 
lldb/source/Commands/CommandObjectMemory.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index b7678add53995..ab54578898a17 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -592,7 +592,10 @@ class CommandObjectMemoryRead : public CommandObjectParsed 
{
   return false;
 }
 
-ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI();
+ABISP abi;
+if (Process *proc = m_exe_ctx.GetProcessPtr())
+  abi = proc->GetABI();
+
 if (abi)
   addr = abi->FixDataAddress(addr);
 

diff  --git a/lldb/test/Shell/Driver/TestPageZeroRead.test 
b/lldb/test/Shell/Driver/TestPageZeroRead.test
new file mode 100644
index 0..474867f2cce7d
--- /dev/null
+++ b/lldb/test/Shell/Driver/TestPageZeroRead.test
@@ -0,0 +1,6 @@
+# REQUIRES: system-darwin
+# Ensure that the read from memory command doesn't try and read from page zero.
+# RUN: %clang_host %p/Inputs/hello.c -g -o a.out
+# RUN: %lldb -b a.out -o 'settings set 
interpreter.stop-command-source-on-error false' -s %s 2>&1 | FileCheck %s
+x 0
+# CHECK: error: error reading data from section __PAGEZERO



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


[Lldb-commits] [PATCH] D127016: [lldb] Prevent crash due to reading memory from page zero.

2022-06-08 Thread Chelsea Cassanova via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f02dd34f226: [lldb/Commands] Prevent crash due to reading 
memory from page zero. (authored by cassanova).

Changed prior to commit:
  https://reviews.llvm.org/D127016?vs=434172&id=435359#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127016

Files:
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/test/Shell/Driver/TestPageZeroRead.test


Index: lldb/test/Shell/Driver/TestPageZeroRead.test
===
--- /dev/null
+++ lldb/test/Shell/Driver/TestPageZeroRead.test
@@ -0,0 +1,6 @@
+# REQUIRES: system-darwin
+# Ensure that the read from memory command doesn't try and read from page zero.
+# RUN: %clang_host %p/Inputs/hello.c -g -o a.out
+# RUN: %lldb -b a.out -o 'settings set 
interpreter.stop-command-source-on-error false' -s %s 2>&1 | FileCheck %s
+x 0
+# CHECK: error: error reading data from section __PAGEZERO
Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -592,7 +592,10 @@
   return false;
 }
 
-ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI();
+ABISP abi;
+if (Process *proc = m_exe_ctx.GetProcessPtr())
+  abi = proc->GetABI();
+
 if (abi)
   addr = abi->FixDataAddress(addr);
 


Index: lldb/test/Shell/Driver/TestPageZeroRead.test
===
--- /dev/null
+++ lldb/test/Shell/Driver/TestPageZeroRead.test
@@ -0,0 +1,6 @@
+# REQUIRES: system-darwin
+# Ensure that the read from memory command doesn't try and read from page zero.
+# RUN: %clang_host %p/Inputs/hello.c -g -o a.out
+# RUN: %lldb -b a.out -o 'settings set interpreter.stop-command-source-on-error false' -s %s 2>&1 | FileCheck %s
+x 0
+# CHECK: error: error reading data from section __PAGEZERO
Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -592,7 +592,10 @@
   return false;
 }
 
-ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI();
+ABISP abi;
+if (Process *proc = m_exe_ctx.GetProcessPtr())
+  abi = proc->GetABI();
+
 if (abi)
   addr = abi->FixDataAddress(addr);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D127331: [lldb] Update TestModuleLoadedNotifys.py for macOS Ventura

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9b55eb80734: [lldb] Update TestModuleLoadedNotifys.py for 
macOS Ventura (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D127331?vs=435282&id=435365#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127331

Files:
  
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py


Index: 
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
===
--- 
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -80,14 +80,16 @@
 total_modules_added_events += 1
 total_solibs_added += solib_count
 added_files = []
-i = 0
-while i < solib_count:
+for i in range (solib_count):
 module = lldb.SBTarget.GetModuleAtIndexFromEvent(i, 
event)
-self.assertTrue(module not in already_loaded_modules)
+# On macOS Ventura and later, dyld and the main binary
+# will be loaded again when dyld moves itself into the
+# shared cache.
+if module.file.fullpath not in ['/usr/lib/dyld', exe]:
+self.assertTrue(module not in 
already_loaded_modules, '{} is already loaded'.format(module))
 already_loaded_modules.append(module)
 if self.TraceOn():
 
added_files.append(module.GetFileSpec().GetFilename())
-i = i + 1
 if self.TraceOn():
 # print all of the binaries that have been added
 print("Loaded files: %s" % (', '.join(added_files)))
@@ -105,11 +107,11 @@
 
removed_files.append(module.GetFileSpec().GetFilename())
 i = i + 1
 print("Unloaded files: %s" % (', 
'.join(removed_files)))
-
 
-# This is testing that we get back a small number of events with the 
loaded 
-# binaries in batches.  Check that we got back more than 1 solib per 
event.  
-# In practice on Darwin today, we get back two events for a do-nothing 
c 
+
+# This is testing that we get back a small number of events with the 
loaded
+# binaries in batches.  Check that we got back more than 1 solib per 
event.
+# In practice on Darwin today, we get back two events for a do-nothing 
c
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 


Index: lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
===
--- lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -80,14 +80,16 @@
 total_modules_added_events += 1
 total_solibs_added += solib_count
 added_files = []
-i = 0
-while i < solib_count:
+for i in range (solib_count):
 module = lldb.SBTarget.GetModuleAtIndexFromEvent(i, event)
-self.assertTrue(module not in already_loaded_modules)
+# On macOS Ventura and later, dyld and the main binary
+# will be loaded again when dyld moves itself into the
+# shared cache.
+if module.file.fullpath not in ['/usr/lib/dyld', exe]:
+self.assertTrue(module not in already_loaded_modules, '{} is already loaded'.format(module))
 already_loaded_modules.append(module)
 if self.TraceOn():
 added_files.append(module.GetFileSpec().GetFilename())
-i = i + 1
 if self.TraceOn():
 # print all of the binaries that have been added
 print("Loaded files: %s" % (', '.join(added_files)))
@@ -105,11 +107,11 @@
 removed_files.append(module.GetFileSpec().GetFilename())
 i = i + 1
 print("Unloaded files: %s" % (', '.join(removed_files)))
-
 
-# This is testing 

[Lldb-commits] [lldb] c9b55eb - [lldb] Update TestModuleLoadedNotifys.py for macOS Ventura

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

Author: Jonas Devlieghere
Date: 2022-06-08T15:33:33-07:00
New Revision: c9b55eb80734a6a840d3210796149f9042ff60c5

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

LOG: [lldb] Update TestModuleLoadedNotifys.py for macOS Ventura

On macOS Ventura and later, dyld and the main binary will be loaded
again when dyld moves itself into the shared cache. Update the test
accordingly.

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

Added: 


Modified: 

lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index 925fbfff22ba..cda0d283dd40 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -80,14 +80,16 @@ def test_launch_notifications(self):
 total_modules_added_events += 1
 total_solibs_added += solib_count
 added_files = []
-i = 0
-while i < solib_count:
+for i in range (solib_count):
 module = lldb.SBTarget.GetModuleAtIndexFromEvent(i, 
event)
-self.assertTrue(module not in already_loaded_modules)
+# On macOS Ventura and later, dyld and the main binary
+# will be loaded again when dyld moves itself into the
+# shared cache.
+if module.file.fullpath not in ['/usr/lib/dyld', exe]:
+self.assertTrue(module not in 
already_loaded_modules, '{} is already loaded'.format(module))
 already_loaded_modules.append(module)
 if self.TraceOn():
 
added_files.append(module.GetFileSpec().GetFilename())
-i = i + 1
 if self.TraceOn():
 # print all of the binaries that have been added
 print("Loaded files: %s" % (', '.join(added_files)))
@@ -105,11 +107,11 @@ def test_launch_notifications(self):
 
removed_files.append(module.GetFileSpec().GetFilename())
 i = i + 1
 print("Unloaded files: %s" % (', 
'.join(removed_files)))
-
 
-# This is testing that we get back a small number of events with the 
loaded 
-# binaries in batches.  Check that we got back more than 1 solib per 
event.  
-# In practice on Darwin today, we get back two events for a do-nothing 
c 
+
+# This is testing that we get back a small number of events with the 
loaded
+# binaries in batches.  Check that we got back more than 1 solib per 
event.
+# In practice on Darwin today, we get back two events for a do-nothing 
c
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 



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


[Lldb-commits] [PATCH] D127355: [lldb] Add assertState function

2022-06-08 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

Pretty cool but it would be nice to have the following formatting:  
"AssertionError: stopped (5) != exited (10) :  message" ... I feel like it's 
easier to read this way


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

https://reviews.llvm.org/D127355

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


[Lldb-commits] [PATCH] D127355: [lldb] Add assertState function

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

Implement Ismail's suggestion:

  AssertionError: stopped (5) != exited (10) : Got exit event


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

https://reviews.llvm.org/D127355

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
  
lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
  lldb/test/API/functionalities/breakpoint/move_nearest/TestMoveNearest.py
  
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/test/API/functionalities/completion/TestCompletion.py
  
lldb/test/API/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
  lldb/test/API/functionalities/launch_stop_at_entry/TestStopAtEntry.py
  lldb/test/API/functionalities/return-value/TestReturnValue.py
  lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
  lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
  lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
  lldb/test/API/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
  lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
  lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
  lldb/test/API/linux/add-symbols/TestTargetSymbolsAddCommand.py
  lldb/test/API/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py
  lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
  lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
  lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
  lldb/test/API/python_api/objc_type/TestObjCType.py
  lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
  lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py

Index: lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
===
--- lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
+++ lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
@@ -27,7 +27,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
Index: lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
===
--- lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
+++ lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
@@ -59,7 +59,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
@@ -136,7 +136,7 @@
 # Now continue.
 process.Continue()
 
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
@@ -169,7 +169,7 @@
 
 process.Continue()
 
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
Index: lldb/test/API/python_api/objc_type/TestObjCType.py
===
--- lldb/test/API/python_api/objc_type/TestObjCType.py
+++ lldb/test/API/python_api/objc_type/TestObjCType.py
@@ -39,7 +39,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
Index: lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
===
--- lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
+++ lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
@@ -45,7 +45,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil

[Lldb-commits] [PATCH] D127355: [lldb] Add assertState function

2022-06-08 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

Awesome! Thanks!


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

https://reviews.llvm.org/D127355

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


[Lldb-commits] [PATCH] D127362: [lldb/crashlog] Show help when the command is called without any argument

2022-06-08 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added a reviewer: 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 `crashlog` command behavior to print the help
message if no argument was provided with the command.

rdar://94576026

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127362

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1226,6 +1226,11 @@
 
 def SymbolicateCrashLogs(debugger, command_args):
 option_parser = CrashLogOptionParser()
+
+if not len(command_args):
+option_parser.print_help()
+return
+
 try:
 (options, args) = option_parser.parse_args(command_args)
 except:


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1226,6 +1226,11 @@
 
 def SymbolicateCrashLogs(debugger, command_args):
 option_parser = CrashLogOptionParser()
+
+if not len(command_args):
+option_parser.print_help()
+return
+
 try:
 (options, args) = option_parser.parse_args(command_args)
 except:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D127362: [lldb/crashlog] Show help when the command is called without any argument

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM with a test :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127362

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


[Lldb-commits] [lldb] ce825e4 - [lldb] Add assertState function to the API test suite

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

Author: Jonas Devlieghere
Date: 2022-06-08T16:16:38-07:00
New Revision: ce825e46743be3e402820484bef639d12deefc2a

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

LOG: [lldb] Add assertState function to the API test suite

Add a function to make it easier to debug a test failure caused by an
unexpected state.

Currently, tests are using assertEqual which results in a cryptic error
message: "AssertionError: 5 != 10". Even when a test provides a message
to make it clear why a particular state is expected, you still have to
figure out which of the two was the expected state, and what the other
value corresponds to.

We have a function in lldbutil that helps you convert the state number
into a user readable string. This patch adds a wrapper around
assertEqual specifically for comparing states and reporting better error
messages.

The aforementioned error message now looks like this: "AssertionError:
stopped (5) != exited (10)". If the user provided a message, that
continues to get printed as well.

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

Added: 


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

lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py

lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py

lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
lldb/test/API/functionalities/breakpoint/move_nearest/TestMoveNearest.py

lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
lldb/test/API/functionalities/completion/TestCompletion.py

lldb/test/API/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
lldb/test/API/functionalities/launch_stop_at_entry/TestStopAtEntry.py
lldb/test/API/functionalities/return-value/TestReturnValue.py
lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
lldb/test/API/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
lldb/test/API/linux/add-symbols/TestTargetSymbolsAddCommand.py
lldb/test/API/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py
lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
lldb/test/API/python_api/objc_type/TestObjCType.py
lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 5c536f4ed8ae..c3dc2a983611 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -519,9 +519,9 @@ def compute_mydir(test_file):
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
 lldb_test_src = configuration.test_src_root
 if not test_file.startswith(lldb_test_src):
-  raise Exception(
-  "Test file '%s' must reside within lldb_test_src "
-  "(which is '%s')." % (test_file, lldb_test_src))
+raise Exception(
+"Test file '%s' must reside within lldb_test_src "
+"(which is '%s')." % (test_file, lldb_test_src))
 return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src))
 
 def TraceOn(self):
@@ -2474,6 +2474,14 @@ def assertSuccess(self, obj, msg=None):
 self.fail(self._formatMessage(msg,
 "'{}' is not success".format(error)))
 
+"""Assert two states are equal"""
+def assertState(self, first, second, msg=None):
+if first != second:
+error = "{} ({}) != {} ({})".format(
+lldbutil.state_type_to_str(first), first,
+lldbutil.state_type_to_str(second), second)
+self.fail(self._formatMessage(msg, error))
+
 def createTestTarget(self, file_path=None, msg=None,
  load_dependent_modules=True):
 """

diff  --git 
a/lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
 
b/lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
index dd7120326ca6..956070fd509a 100644
--- 
a/lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
+++ 
b/lldb/test/API/commands/process/launch-with-shellexpand/TestLa

[Lldb-commits] [PATCH] D127355: [lldb] Add assertState function

2022-06-08 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce825e46743b: [lldb] Add assertState function to the API 
test suite (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127355

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/test/API/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
  
lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
  lldb/test/API/functionalities/breakpoint/move_nearest/TestMoveNearest.py
  
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/test/API/functionalities/completion/TestCompletion.py
  
lldb/test/API/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
  lldb/test/API/functionalities/launch_stop_at_entry/TestStopAtEntry.py
  lldb/test/API/functionalities/return-value/TestReturnValue.py
  lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
  lldb/test/API/lang/cpp/gmodules/TestWithModuleDebugging.py
  lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
  lldb/test/API/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
  lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
  lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
  lldb/test/API/linux/add-symbols/TestTargetSymbolsAddCommand.py
  lldb/test/API/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py
  lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
  lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
  lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
  lldb/test/API/python_api/objc_type/TestObjCType.py
  lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
  lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py

Index: lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
===
--- lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
+++ lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
@@ -27,7 +27,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
Index: lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
===
--- lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
+++ lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
@@ -59,7 +59,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
@@ -136,7 +136,7 @@
 # Now continue.
 process.Continue()
 
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
@@ -169,7 +169,7 @@
 
 process.Continue()
 
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
Index: lldb/test/API/python_api/objc_type/TestObjCType.py
===
--- lldb/test/API/python_api/objc_type/TestObjCType.py
+++ lldb/test/API/python_api/objc_type/TestObjCType.py
@@ -39,7 +39,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+self.assertState(process.GetState(), lldb.eStateStopped)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 self.assertTrue(
Index: lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
===
--- lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
+++ lldb/test/API/python_api/class_members/TestSBTypeClassMembers.py
@@ -45,7 +45,7 @@
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # Get Frame #0.
-self.assertEquals(process.GetState(), lldb.eStateStopped)
+s

[Lldb-commits] [PATCH] D127362: [lldb/crashlog] Show help when the command is called without any argument

2022-06-08 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 435383.
mib added a comment.

Add test


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

https://reviews.llvm.org/D127362

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test
@@ -0,0 +1,9 @@
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' -o 'crashlog' 
2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" 
options on these commands
+
+# CHECK: Usage: crashlog [options]  [FILE ...]
+# CHECK: Symbolicate one or more darwin crash log files to provide source file 
and line
+# CHECK: Options:
+# CHECK:  -h, --helpshow this help message and exit
+
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1226,6 +1226,11 @@
 
 def SymbolicateCrashLogs(debugger, command_args):
 option_parser = CrashLogOptionParser()
+
+if not len(command_args):
+option_parser.print_help()
+return
+
 try:
 (options, args) = option_parser.parse_args(command_args)
 except:


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test
@@ -0,0 +1,9 @@
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' -o 'crashlog' 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: Usage: crashlog [options]  [FILE ...]
+# CHECK: Symbolicate one or more darwin crash log files to provide source file and line
+# CHECK: Options:
+# CHECK:  -h, --helpshow this help message and exit
+
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1226,6 +1226,11 @@
 
 def SymbolicateCrashLogs(debugger, command_args):
 option_parser = CrashLogOptionParser()
+
+if not len(command_args):
+option_parser.print_help()
+return
+
 try:
 (options, args) = option_parser.parse_args(command_args)
 except:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d671002 - [LLDB][NativePDB] Fix several crashes when parsing debug info.

2022-06-08 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2022-06-08T16:41:23-07:00
New Revision: d6710023e396aa55f92e3906755d68b06489d95f

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

LOG: [LLDB][NativePDB] Fix several crashes when parsing debug info.
1. If array element type is a tag decl, complete it.
2. Fix few places where `asTag` should be used instead of `asClass()`.
3. Handle the case that `PdbAstBuilder::CreateFunctionDecl` return nullptr 
mainly due to an existing workaround (`m_cxx_record_map`).
4. `FindMembersSize` should never return error as this would cause early 
exiting in `CVTypeVisitor::visitFieldListMemberStream` and then cause assertion 
failure.
5. In some pdbs from C++ runtime libraries have S_LPROC32 followed directly by 
S_LOCAL and the local variable location is a S_DEFRANGE_FRAMEPOINTER_REL. There 
is no information about base frame register in this case, ignoring it by 
returning RegisterId::NONE.
6. Add a TODO when S_DEFRANGE_SUBFIELD_REGISTER describes the variable location 
of a pointer type. For now, just ignoring it if the variable is pointer.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 80d51ab656f4a..0217186cf87a3 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -711,6 +711,10 @@ bool PdbAstBuilder::CompleteType(clang::QualType qt) {
   if (qt.isNull())
 return false;
   clang::TagDecl *tag = qt->getAsTagDecl();
+  if (qt->isArrayType()) {
+const clang::Type *element_type = qt->getArrayElementTypeNoTypeQual();
+tag = element_type->getAsTagDecl();
+  }
   if (!tag)
 return false;
 
@@ -1089,6 +1093,7 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId 
func_id,
 ->getCanonicalTypeInternal();
 lldb::opaque_compiler_type_t parent_opaque_ty =
 ToCompilerType(parent_qt).GetOpaqueQualType();
+// FIXME: Remove this workaround.
 auto iter = m_cxx_record_map.find(parent_opaque_ty);
 if (iter != m_cxx_record_map.end()) {
   if (iter->getSecond().contains({func_name, func_ct})) {
@@ -1103,18 +1108,17 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId 
func_id,
 TypeIndex class_index = func_record.getClassType();
 
 CVType parent_cvt = m_index.tpi().getType(class_index);
-ClassRecord class_record = CVTagRecord::create(parent_cvt).asClass();
+TagRecord tag_record = CVTagRecord::create(parent_cvt).asTag();
 // If it's a forward reference, try to get the real TypeIndex.
-if (class_record.isForwardRef()) {
+if (tag_record.isForwardRef()) {
   llvm::Expected eti =
   m_index.tpi().findFullDeclForForwardRef(class_index);
   if (eti) {
-class_record =
-CVTagRecord::create(m_index.tpi().getType(*eti)).asClass();
+tag_record = CVTagRecord::create(m_index.tpi().getType(*eti)).asTag();
   }
 }
-if (!class_record.FieldList.isSimple()) {
-  CVType field_list = m_index.tpi().getType(class_record.FieldList);
+if (!tag_record.FieldList.isSimple()) {
+  CVType field_list = m_index.tpi().getType(tag_record.FieldList);
   CreateMethodDecl process(m_index, m_clang, func_ti, function_decl,
parent_opaque_ty, func_name, func_ct);
   if (llvm::Error err = visitMemberRecordStream(field_list.data(), 
process))
@@ -1156,6 +1160,8 @@ 
PdbAstBuilder::GetOrCreateInlinedFunctionDecl(PdbCompilandSymId inlinesite_id) {
 return llvm::dyn_cast(decl);
   clang::FunctionDecl *function_decl =
   CreateFunctionDeclFromId(func_id, inlinesite_id);
+  if (function_decl == nullptr)
+return nullptr;
 
   // Use inline site id in m_decl_to_status because it's expected to be a
   // PdbCompilandSymId so that we can parse local variables info after it.
@@ -1261,6 +1267,8 @@ PdbAstBuilder::GetOrCreateFunctionDecl(PdbCompilandSymId 
func_id) {
   clang::FunctionDecl *function_decl =
   CreateFunctionDecl(func_id, proc_name, proc.FunctionType, func_ct,
  func_type->getNumParams(), storage, false, parent);
+  if (function_decl == nullptr)
+return nullptr;
 
   lldbassert(m_uid_to_decl.count(toOpaqueUid(func_id)) == 0);
   m_uid_to_decl[toOpaqueUid(func_id)] = function_decl;

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
index 8ef4f21a69694..10e8cbd11482d 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePD

[Lldb-commits] [lldb] aaaf8e4 - Add help text for "breakpoint name", describing the feature more fully.

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

Author: Jim Ingham
Date: 2022-06-08T16:55:53-07:00
New Revision: aaaf8e4c409f080f35ea227b20dc6ac8a45c2fa4

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

LOG: Add help text for "breakpoint name", describing the feature more fully.

https://reviews.llvm.org/D127038

Added: 


Modified: 
lldb/source/Commands/CommandObjectBreakpoint.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 4515c7ee58eee..755cf6c61f26c 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -2018,8 +2018,99 @@ class CommandObjectBreakpointName : public 
CommandObjectMultiword {
 public:
   CommandObjectBreakpointName(CommandInterpreter &interpreter)
   : CommandObjectMultiword(
-interpreter, "name", "Commands to manage name tags for 
breakpoints",
-"breakpoint name  []") {
+interpreter, "name", "Commands to manage breakpoint names") {
+  
+
+SetHelpLong(
+R"(
+Breakpoint names provide a general tagging mechanism for breakpoints.  Each 
+breakpoint name can be added to any number of breakpoints, and each breakpoint 
+can have any number of breakpoint names attached to it. For instance:
+
+(lldb) break name add -N MyName 1-10
+
+adds the name MyName to breakpoints 1-10, and:
+
+(lldb) break set -n myFunc -N Name1 -N Name2
+
+adds two names to the breakpoint set at myFunc.
+
+They have a number of interrelated uses:
+
+1) They provide a stable way to refer to a breakpoint (e.g. in another 
+breakpoint's action). Using the breakpoint ID for this purpose is fragile, 
since
+it depends on the order of breakpoint creation.  Giving a name to the 
breakpoint
+you want to act on, and then referring to it by name, is more robust:
+
+(lldb) break set -n myFunc -N BKPT1
+(lldb) break set -n myOtherFunc -C "break disable BKPT1"
+
+2) This is actually just a specific use of a more general feature of breakpoint
+names.  The  argument type used to specify one or more 
+breakpoints in most of the commands that deal with breakpoints also accepts 
+breakpoint names.  That allows you to refer to one breakpoint in a stable 
+manner, but also makes them a convenient grouping mechanism, allowing you to 
+easily act on a group of breakpoints by using their name, for instance 
disabling
+them all in one action:
+
+(lldb) break set -n myFunc -N Group1
+(lldb) break set -n myOtherFunc -N Group1
+(lldb) break disable Group1
+
+3) But breakpoint names are also entities in their own right, and can be 
+configured with all the modifiable attributes of a breakpoint.  Then when you 
+add a breakpoint name to a breakpoint, the breakpoint will be configured to 
+match the state of the breakpoint name.  The link between the name and the 
+breakpoints sharing it remains live, so if you change the configuration on the 
+name, it will also change the configurations on the breakpoints:
+
+(lldb) break name configure -i 10 IgnoreSome
+(lldb) break set -n myFunc -N IgnoreSome
+(lldb) break list IgnoreSome
+2: name = 'myFunc', locations = 0 (pending) Options: ignore: 10 enabled 
+  Names:
+IgnoreSome
+(lldb) break name configure -i 5 IgnoreSome
+(lldb) break list IgnoreSome
+2: name = 'myFunc', locations = 0 (pending) Options: ignore: 5 enabled 
+  Names:
+IgnoreSome
+
+Options that are not configured on a breakpoint name don't affect the value of 
+those options on the breakpoints they are added to.  So for instance, if Name1
+has the -i option configured and Name2 the -c option, adding both names to a 
+breakpoint will set the -i option from Name1 and the -c option from Name2, and
+the other options will be unaltered.
+
+If you add multiple names to a breakpoint which have configured values for
+the same option, the last name added's value wins.
+
+The "liveness" of these settings is one way, from name to breakpoint.  
+If you use "break modify" to change an option that is also configured on a 
name 
+which that breakpoint has, the "break modify" command will override the 
setting 
+for that breakpoint, but won't change the value configured in the name or on 
the
+other breakpoints sharing that name.
+
+4) Breakpoint names are also a convenient way to copy option sets from one 
+breakpoint to another.  Using the -B option to "breakpoint name configure" 
makes
+a name configured with all the options of the original breakpoint.  Then 
+adding that name to another breakpoint copies over all the values from the 
+original breakpoint to the new one.
+
+5) You can also use breakpoint names to hide breakpoints from the breakpoint
+operations that act o

[Lldb-commits] [PATCH] D127378: [lldb] Use assertState in more tests (NFC)

2022-06-08 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: JDevlieghere, mib.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Follow to D127355 , converting more 
`assertEquals` to `assertState`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127378

Files:
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  lldb/test/API/commands/watchpoints/multiple_hits/TestMultipleHits.py
  
lldb/test/API/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
  lldb/test/API/functionalities/breakpoint/debugbreak/TestDebugBreak.py
  lldb/test/API/functionalities/conditional_break/TestConditionalBreak.py
  lldb/test/API/functionalities/dyld-exec-linux/TestDyldExecLinux.py
  lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py
  lldb/test/API/functionalities/exec/TestExec.py
  lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py
  lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py
  lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
  lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
  
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
  lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
  lldb/test/API/functionalities/signal/handle-segv/TestHandleSegv.py
  lldb/test/API/functionalities/signal/raise/TestRaise.py
  
lldb/test/API/functionalities/step-vrs-interrupt/TestStepVrsInterruptTimeout.py
  lldb/test/API/functionalities/step_scripted/TestStepScripted.py
  
lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
  lldb/test/API/lang/c/step_over_no_deadlock/TestStepOverDoesntBlock.py
  lldb/test/API/lang/cpp/dynamic-value/TestCppValueCast.py
  lldb/test/API/lang/objc/objc-checker/TestObjCCheckers.py
  lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py
  lldb/test/API/macosx/ignore_exceptions/TestIgnoredExceptions.py
  lldb/test/API/python_api/frame/TestFrames.py
  lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py
  lldb/test/API/python_api/function_symbol/TestDisasmAPI.py
  lldb/test/API/python_api/function_symbol/TestSymbolAPI.py
  lldb/test/API/python_api/lldbutil/frame/TestFrameUtils.py
  lldb/test/API/python_api/target/TestTargetAPI.py
  lldb/test/API/python_api/thread/TestThreadAPI.py
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/value/TestValueAPI.py
  lldb/test/API/python_api/value/linked_list/TestValueAPILinkedList.py
  lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py
  lldb/test/API/python_api/watchpoint/TestWatchpointIgnoreCount.py
  lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
  lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py

Index: lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
===
--- lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
+++ lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
@@ -48,8 +48,8 @@
 
 # We should be stopped due to the breakpoint.  Get frame #0.
 process = target.GetProcess()
-self.assertEqual(process.GetState(), lldb.eStateStopped,
-PROCESS_STOPPED)
+self.assertState(process.GetState(), lldb.eStateStopped,
+ PROCESS_STOPPED)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 frame0 = thread.GetFrameAtIndex(0)
@@ -122,8 +122,8 @@
 
 # We should be stopped due to the breakpoint.  Get frame #0.
 process = target.GetProcess()
-self.assertEqual(process.GetState(), lldb.eStateStopped,
-PROCESS_STOPPED)
+self.assertState(process.GetState(), lldb.eStateStopped,
+ PROCESS_STOPPED)
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 frame0 = thread.GetFrameAtIndex(0)
Index: lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
===
--- lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
+++ lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
@@ -50,8 +50,8 @@
 
 # We should be stopped due to the breakpoint.  Get frame #0.
 process = target.GetProcess()
-self.assertEqual(process.GetState(), lldb.eStateStopped,
-PROCESS_STOPPED)
+self.assertState(process.GetState(), lldb.eStateStopped,
+

[Lldb-commits] [PATCH] D127355: [lldb] Add assertState function

2022-06-08 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

nice, I've wanted this too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127355

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