[Lldb-commits] [PATCH] D128156: [lldb] [llgs] Include PID in QC response in multiprocess mode

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

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D128156

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
@@ -817,3 +817,56 @@
 data = ret.get("data")
 self.assertIsNotNone(data)
 self.assertEqual(data, old_val[1])
+
+@add_test_categories(["fork"])
+def test_qC(self):
+self.build()
+self.prep_debug_monitor_and_inferior(
+inferior_args=["fork",
+   "thread:new",
+   "trap",
+   ])
+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)
+self.add_threadinfo_collection_packets()
+ret = self.expect_gdbremote_sequence()
+pidtids = [
+(ret["parent_pid"], ret["parent_tid"]),
+(ret["child_pid"], ret["child_tid"]),
+]
+self.reset_test_sequence()
+
+for pidtid in pidtids:
+self.test_sequence.add_log_lines(
+["read packet: $Hcp{}.{}#00".format(*pidtid),
+ "send packet: $OK#00",
+ "read packet: $c#00",
+ {"direction": "send",
+  "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+  },
+ ], True)
+
+self.add_threadinfo_collection_packets()
+ret = self.expect_gdbremote_sequence()
+self.reset_test_sequence()
+
+pidtids = set(self.parse_threadinfo_packets(ret))
+self.assertEqual(len(pidtids), 4)
+for pidtid in pidtids:
+self.test_sequence.add_log_lines(
+["read packet: $Hgp{:x}.{:x}#00".format(*pidtid),
+ "send packet: $OK#00",
+ "read packet: $qC#00",
+ "send packet: $QCp{:x}.{:x}#00".format(*pidtid),
+ ], 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
@@ -1412,7 +1412,10 @@
 return SendErrorResponse(69);
 
   StreamString response;
-  response.Printf("QC%" PRIx64, thread->GetID());
+  response.PutCString("QC");
+  if (bool(m_extensions_supported & 
NativeProcessProtocol::Extension::multiprocess))
+response.Format("p{0:x-}.", m_current_process->GetID());
+  response.Format("{0:x-}", thread->GetID());
 
   return SendPacketNoLock(response.GetString());
 }


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
@@ -817,3 +817,56 @@
 data = ret.get("data")
 self.assertIsNotNone(data)
 self.assertEqual(data, old_val[1])
+
+@add_test_categories(["fork"])
+def test_qC(self):
+self.build()
+self.prep_debug_monitor_and_inferior(
+inferior_args=["fork",
+   "thread:new",
+   "trap",
+   ])
+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)
+self.add_threadinfo_collection_packets()
+ret = self.expect_gdbremote_sequence()
+pidtids = [
+(ret["parent_pid"], ret["parent_tid"]),
+(ret["child_pid"], ret["child_tid"]),
+  

[Lldb-commits] [PATCH] D128156: [lldb] [llgs] Include PID in QC response in multiprocess mode

2022-06-20 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:1415-1419
+  response.PutCString("QC");
+  if (bool(m_extensions_supported & 
NativeProcessProtocol::Extension::multiprocess))
+response.Format("p{0:x-}.", m_current_process->GetID());
+  response.Format("{0:x-}", thread->GetID());
 

How many of these are we going to have? Should we add a helper fn?


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

https://reviews.llvm.org/D128156

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


[Lldb-commits] [PATCH] D127193: [lldb] [llgs] Fix signo sent with fork/vfork/vforkdone events

2022-06-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:697
 
+static int GetSignalForStopReason(const struct ThreadStopInfo &tid_stop_info) {
+  if (tid_stop_info.reason == eStopReasonException)

It seems this struct is only used in the lldb-server. Maybe we could make this 
a member function instead? Or move the signo field out of the union?


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

https://reviews.llvm.org/D127193

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


[Lldb-commits] [PATCH] D126240: [lldb] Tighten the scope of a couple of locks in DataFormatters.

2022-06-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D126240#3564913 , @jgorbe wrote:

> I've been experimenting a little bit and it seems that I can avoid the 
> deadlocks I was seeing by applying only the modification to 
> `TypeCategoryMap::Add`. This would avoid the problem that @hawkinsw pointed 
> out in my change to `FormatManager::GetCategoryForLanguage`. However, the 
> following problem could still happen with the change to 
> `TypeCategoryMap::Add`:
>
> 1. Thread A acquires the lock, runs `m_map[key1] = value1`, and releases the 
> lock
> 2. Thread B acquires the lock, runs `m_map[key2] = value2`, and releases the 
> lock
> 3. Thread A runs `listener->Changed()`
> 4. Thread B runs `listener->Changed()`
>
> So we would have two changes, the listener would be called twice, but both 
> listener calls would see the same state with the two changes already applied, 
> instead of observing each change individually. I'll keep thinking to see if I 
> can fix this elsewhere.

[disclaimer: I suggested this approach offline]

Yes, that could happen, but is that a problem? That sequence of actions is 
indistinguishable (to the object receiving the Changed notifications) from an 
action which modifies two keys, followed by a no-op action.

I know we currently don't have such actions, but I don't see why should the 
receiver care about that. The notifications don't carry any information about 
the change anyway, so the only way it could notice that is if it made a 
snapshot of the state each time it is called and then done a diff. If we really 
wanted it to receive granular update informations like this, we would have 
designed the interface differently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126240

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


[Lldb-commits] [PATCH] D128026: [lldb] Add a BufferedLogHandler

2022-06-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I feel I should note that the llvm streams already have a buffered mode, and 
given the way things are implemented now (our log class writes the entire log 
message in one call, and the raw_ostream flushing the entire buffer whenever a 
message does not fit), I don't think this class has any advantages over using 
stream buffering (that's a very long-winded way of saying you're not going to 
get partial messages in either of the solutions). The only two differences I 
see are:

- one of them specifies the size, the other specifies the number of messages
- different behavior in case of races (in non-thread-safe mode). I'll write 
more on that elsewhere.


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

https://reviews.llvm.org/D128026

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


[Lldb-commits] [PATCH] D126464: [lldb] Add support to load object files from thin archives

2022-06-20 Thread Kaining Zhong via Phabricator via lldb-commits
PRESIDENT810 added a comment.

Hi, sorry to interrupt but I just forgot to mention that I didn't have access 
to commit. Anyone can please help me land this one if it looks ok?


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

https://reviews.llvm.org/D126464

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


[Lldb-commits] [PATCH] D127922: [lldb] Introduce the concept of a log handler (NFC)

2022-06-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I think we should talk about the threadsafe flag. The reason that the 
non-threadsafe mode is safe now is because we're using unbuffered streams, 
where each stream operation will map to a single write syscall (which will then 
be serialized by the OS somehow). And since we pre-format the log messages into 
a temporary buffer, we shouldn't even get overlapping messages in the output. 
In fact, I would say that, before this, the threadsafe mode was mostly useless.

All of that goes out the window once you start doing arbitrary logic in place 
of log writing. As they're implemented now, neither BufferedLogHandler nor 
RotatingLogHandler are thread-safe. (Making the rotating handler thread safe 
(without locks) should be relatively easy -- assuming we're willing to accept 
races between printing messages, and new messages coming in -- but I don't 
think that the Buffered handler can be made safe without locking at least the 
flushing part). An it's not just that the messages may be slightly wonky. I 
think it wouldn't be hard to crash the process by spewing log messages from 
multiple threads (and we're pretty good at spewing :P).

So, what I'd recommend is to drop the thread-safe flag, and make the locking 
strategy the responsibility of the individual log handler. When writing to an 
unbuffered stream, we wouldn't need any locks at all. The circular handler 
could either lock into that or, if you're into that sort of thing, use atomics 
to make enqueueing lock-free. The buffered handler could either use a buffered 
ostream, wrapped in a mutex, or do something similar to the circular one, while 
locking only the flushing code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127922

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


[Lldb-commits] [PATCH] D127500: [lldb] [llgs] Make `k` kill all processes, and fix multiple exits

2022-06-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I've ran into the "dynamic uninitialization order fiasco" problem as well. I'm 
wondering if, instead of the trick (which is pretty neat, but still a trick) 
with the limbo member variable, we could add something like the 
`asyncio.loop.call_soon` function in python to our MainLoop class. So, instead 
of immediately calling the exited callback (and possibly others as well), the 
process class would schedule the call to be made upon return to the top-level 
loop.

What do you think about that?




Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:1196
+  if (!bool(m_extensions_supported &
+NativeProcessProtocol::Extension::multiprocess))
+assert(!m_stdio_handle_up);

I don't think this is right. I believe the important distinction is whether we 
have non-stop mode enabled or not, because in all-stop mode we are not able to 
send stdio while stopped, regardless of how many processes we're debugging.


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

https://reviews.llvm.org/D127500

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


[Lldb-commits] [PATCH] D128069: [lldb] add SBSection.alignment to python bindings

2022-06-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

For the underlying functionality, I think it'd be best to extend `lldb-test` to 
print section alignment (`dumpSectionList` in 
`lldb/tools/lldb-test/lldb-test.cpp`) and then write (or extend) some test in 
`test/Shell/ObjectFile/ELF` (or your favourite object format).

That won't test the code added here though, as lldb-test does not use the SB 
API.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128069

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


[Lldb-commits] [PATCH] D128170: [lldb] [llgs] Implement the 'T' packet

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

Implement the 'T' packet that is used to verify whether the specified
thread belongs to the debugged processes.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D128170

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  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
@@ -870,3 +870,76 @@
  "send packet: $QCp{:x}.{:x}#00".format(*pidtid),
  ], True)
 self.expect_gdbremote_sequence()
+
+@add_test_categories(["fork"])
+def test_T(self):
+self.build()
+self.prep_debug_monitor_and_inferior(
+inferior_args=["fork",
+   "thread:new",
+   "trap",
+   ])
+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)
+self.add_threadinfo_collection_packets()
+ret = self.expect_gdbremote_sequence()
+pidtids = [
+(ret["parent_pid"], ret["parent_tid"]),
+(ret["child_pid"], ret["child_tid"]),
+]
+self.reset_test_sequence()
+
+for pidtid in pidtids:
+self.test_sequence.add_log_lines(
+["read packet: $Hcp{}.{}#00".format(*pidtid),
+ "send packet: $OK#00",
+ "read packet: $c#00",
+ {"direction": "send",
+  "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+  },
+ ], True)
+
+self.add_threadinfo_collection_packets()
+ret = self.expect_gdbremote_sequence()
+self.reset_test_sequence()
+
+pidtids = set(self.parse_threadinfo_packets(ret))
+self.assertEqual(len(pidtids), 4)
+max_pid = max(pid for pid, tid in pidtids)
+max_tid = max(tid for pid, tid in pidtids)
+bad_pidtids = (
+(max_pid, max_tid + 1, "E02"),
+(max_pid + 1, max_tid, "E01"),
+(max_pid + 1, max_tid + 1, "E01"),
+)
+
+for pidtid in pidtids:
+self.test_sequence.add_log_lines(
+[
+ # test explicit PID+TID
+ "read packet: $Tp{:x}.{:x}#00".format(*pidtid),
+ "send packet: $OK#00",
+ # test implicit PID via Hg
+ "read packet: $Hgp{:x}.{:x}#00".format(*pidtid),
+ "send packet: $OK#00",
+ "read packet: $T{:x}#00".format(max_tid + 1),
+ "send packet: $E02#00",
+ "read packet: $T{:x}#00".format(pidtid[1]),
+ "send packet: $OK#00",
+ ], True)
+for pid, tid, expected in bad_pidtids:
+self.test_sequence.add_log_lines(
+["read packet: $Tp{:x}.{:x}#00".format(pid, tid),
+ "send packet: ${}#00".format(expected),
+ ], True)
+self.expect_gdbremote_sequence()
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
@@ -231,6 +231,8 @@
 
   PacketResult Handle_QMemTags(StringExtractorGDBRemote &packet);
 
+  PacketResult Handle_T(StringExtractorGDBRemote &packet);
+
   void SetCurrentThreadID(lldb::tid_t tid);
 
   lldb::tid_t GetCurrentThreadID() const;
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
@@ -107,6 +107,8 @@
 &GDBRemoteCommunicationServerLLGS::Handle_P);
   RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_qC,
 &GDBRemoteCommunicationServerLLG

[Lldb-commits] [PATCH] D128156: [lldb] [llgs] Include PID in QC response in multiprocess mode

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:1415-1419
+  response.PutCString("QC");
+  if (bool(m_extensions_supported & 
NativeProcessProtocol::Extension::multiprocess))
+response.Format("p{0:x-}.", m_current_process->GetID());
+  response.Format("{0:x-}", thread->GetID());
 

labath wrote:
> How many of these are we going to have? Should we add a helper fn?
Hmm, that's probably a good idea ;-). I'm going to count and see about adding 
one in a separate patch.


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

https://reviews.llvm.org/D128156

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


[Lldb-commits] [PATCH] D127193: [lldb] [llgs] Fix signo sent with fork/vfork/vforkdone events

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:697
 
+static int GetSignalForStopReason(const struct ThreadStopInfo &tid_stop_info) {
+  if (tid_stop_info.reason == eStopReasonException)

labath wrote:
> It seems this struct is only used in the lldb-server. Maybe we could make 
> this a member function instead? Or move the signo field out of the union?
I would lean towards the latter, I guess. Lemme look about updating the patch.


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

https://reviews.llvm.org/D127193

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


[Lldb-commits] [lldb] 1f9f7a2 - [lldb] Relax backtrace checks in TestDyldLaunchLinux

2022-06-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2022-06-20T12:59:31+02:00
New Revision: 1f9f7a2f5d75dd7b1a361a9e22138c98fcdc532b

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

LOG: [lldb] Relax backtrace checks in TestDyldLaunchLinux

Newer versions of glibc (2.34) have an extra frame inside the `raise`
function.

Added: 


Modified: 
lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py 
b/lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py
index 87952863747af..a9f28ccc325b1 100644
--- a/lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py
+++ b/lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py
@@ -54,5 +54,4 @@ def test(self):
 
 # Stopped because of generated signal.
 self.assertState(process.GetState(), lldb.eStateStopped)
-self.assertIn("raise", 
thread.GetFrameAtIndex(0).GetDisplayFunctionName())
-self.assertIn("get_signal_crash", 
thread.GetFrameAtIndex(1).GetDisplayFunctionName())
+self.assertIn("raise", lldbutil.get_function_names(thread))



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


[Lldb-commits] [lldb] e4d6ed5 - [lldb] [llgs] Include process id in W/X stop reasons

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

Author: Michał Górny
Date: 2022-06-20T13:37:23+02:00
New Revision: e4d6ed58a86edc339ae124b74668b600f2a0f6d5

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

LOG: [lldb] [llgs] Include process id in W/X stop reasons

Include the process identifier in W/X stop reasons when multiprocess
extensions are enabled.

The LLDB client does not support process identifiers there at the moment
but it parses packets in such a way that their presence does not cause
any problems.

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

Added: 


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

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 0a44929ce2b7b..2b491f505aca1 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -474,6 +474,8 @@ GDBRemoteCommunicationServerLLGS::SendWResponse(
 
   StreamGDBRemote response;
   response.Format("{0:g}", *wait_status);
+  if (bool(m_extensions_supported & 
NativeProcessProtocol::Extension::multiprocess))
+response.Format(";process:{0:x-}", process->GetID());
   return SendPacketNoLock(response.GetString());
 }
 

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
index 3ce10f5964b8e..45f3c95809da0 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -74,7 +74,7 @@ def test_fork(self):
 # resume the parent
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], True)
 self.expect_gdbremote_sequence()
 
@@ -87,7 +87,7 @@ def test_vfork(self):
 "read packet: $c#00",
 {"direction": "send", "regex": r"[$]T.*vforkdone.*"},
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], True)
 self.expect_gdbremote_sequence()
 
@@ -135,7 +135,7 @@ def fork_and_follow_test(self, variant):
 # resume the child
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], True)
 self.expect_gdbremote_sequence()
 



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


[Lldb-commits] [lldb] ac570fb - [lldb] [llgs] Include process ID in stop responses

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

Author: Michał Górny
Date: 2022-06-20T13:37:23+02:00
New Revision: ac570fbb8521a31a1931cc070e1b259fcac6a30f

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

LOG: [lldb] [llgs] Include process ID in stop responses

Include the process identifier in the `T` stop responses when
multiprocess extension is enabled (i.e. prepend it to the thread
identifier).  Use the exposed identifier to simplify the fork-and-follow
tests.

The LLDB client accounts for the possible PID since the multiprocess
extension support was added in b601c6719226fb83c43dae62a581e5ee08bfb169.

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

Added: 


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

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 2b491f505aca..e173f04bebe4 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -809,8 +809,12 @@ 
GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
   // Print the signal number.
   response.PutHex8(signum & 0xff);
 
-  // Include the tid.
-  response.Printf("thread:%" PRIx64 ";", tid);
+  // Include the (pid and) tid.
+  response.PutCString("thread:");
+  if (bool(m_extensions_supported &
+   NativeProcessProtocol::Extension::multiprocess))
+response.Format("p{0:x-}.", m_current_process->GetID());
+  response.Format("{0:x-};", tid);
 
   // Include the thread name if there is one.
   const std::string thread_name = thread->GetName();

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
index 45f3c95809da..2156180e7423 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -101,15 +101,12 @@ def fork_and_follow_test(self, variant):
 self.reset_test_sequence()
 
 # continue and expect fork
-procinfo_regex = "[$]pid:([0-9a-f]+);.*"
-fork_regex = "[$]T.*;{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant)
+fork_regex = ("[$]T[0-9a-f]{{2}}thread:p([0-9a-f]+)[.][0-9a-f]+;.*"
+  "{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant))
 self.test_sequence.add_log_lines([
-"read packet: $qProcessInfo#00",
-{"direction": "send", "regex": procinfo_regex,
- "capture": {1: "parent_pid"}},
 "read packet: $c#00",
 {"direction": "send", "regex": fork_regex,
- "capture": {1: "pid", 2: "tid"}},
+ "capture": {1: "parent_pid", 2: "pid", 3: "tid"}},
 ], True)
 ret = self.expect_gdbremote_sequence()
 parent_pid, pid, tid = (int(ret[x], 16) for x



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


[Lldb-commits] [PATCH] D127191: [lldb] [llgs] Include process id in W/X stop reasons

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe4d6ed58a86e: [lldb] [llgs] Include process id in W/X stop 
reasons (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127191

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
@@ -74,7 +74,7 @@
 # resume the parent
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], True)
 self.expect_gdbremote_sequence()
 
@@ -87,7 +87,7 @@
 "read packet: $c#00",
 {"direction": "send", "regex": r"[$]T.*vforkdone.*"},
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], True)
 self.expect_gdbremote_sequence()
 
@@ -135,7 +135,7 @@
 # resume the child
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], 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
@@ -474,6 +474,8 @@
 
   StreamGDBRemote response;
   response.Format("{0:g}", *wait_status);
+  if (bool(m_extensions_supported & 
NativeProcessProtocol::Extension::multiprocess))
+response.Format(";process:{0:x-}", process->GetID());
   return SendPacketNoLock(response.GetString());
 }
 


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
@@ -74,7 +74,7 @@
 # resume the parent
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], True)
 self.expect_gdbremote_sequence()
 
@@ -87,7 +87,7 @@
 "read packet: $c#00",
 {"direction": "send", "regex": r"[$]T.*vforkdone.*"},
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], True)
 self.expect_gdbremote_sequence()
 
@@ -135,7 +135,7 @@
 # resume the child
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]W00#.*"},
+{"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], 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
@@ -474,6 +474,8 @@
 
   StreamGDBRemote response;
   response.Format("{0:g}", *wait_status);
+  if (bool(m_extensions_supported & NativeProcessProtocol::Extension::multiprocess))
+response.Format(";process:{0:x-}", process->GetID());
   return SendPacketNoLock(response.GetString());
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D127192: [lldb] [llgs] Include process ID in stop responses

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac570fbb8521: [lldb] [llgs] Include process ID in stop 
responses (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127192

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
@@ -101,15 +101,12 @@
 self.reset_test_sequence()
 
 # continue and expect fork
-procinfo_regex = "[$]pid:([0-9a-f]+);.*"
-fork_regex = "[$]T.*;{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant)
+fork_regex = ("[$]T[0-9a-f]{{2}}thread:p([0-9a-f]+)[.][0-9a-f]+;.*"
+  "{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant))
 self.test_sequence.add_log_lines([
-"read packet: $qProcessInfo#00",
-{"direction": "send", "regex": procinfo_regex,
- "capture": {1: "parent_pid"}},
 "read packet: $c#00",
 {"direction": "send", "regex": fork_regex,
- "capture": {1: "pid", 2: "tid"}},
+ "capture": {1: "parent_pid", 2: "pid", 3: "tid"}},
 ], True)
 ret = self.expect_gdbremote_sequence()
 parent_pid, pid, tid = (int(ret[x], 16) for x
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
@@ -809,8 +809,12 @@
   // Print the signal number.
   response.PutHex8(signum & 0xff);
 
-  // Include the tid.
-  response.Printf("thread:%" PRIx64 ";", tid);
+  // Include the (pid and) tid.
+  response.PutCString("thread:");
+  if (bool(m_extensions_supported &
+   NativeProcessProtocol::Extension::multiprocess))
+response.Format("p{0:x-}.", m_current_process->GetID());
+  response.Format("{0:x-};", tid);
 
   // Include the thread name if there is one.
   const std::string thread_name = thread->GetName();


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
@@ -101,15 +101,12 @@
 self.reset_test_sequence()
 
 # continue and expect fork
-procinfo_regex = "[$]pid:([0-9a-f]+);.*"
-fork_regex = "[$]T.*;{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant)
+fork_regex = ("[$]T[0-9a-f]{{2}}thread:p([0-9a-f]+)[.][0-9a-f]+;.*"
+  "{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant))
 self.test_sequence.add_log_lines([
-"read packet: $qProcessInfo#00",
-{"direction": "send", "regex": procinfo_regex,
- "capture": {1: "parent_pid"}},
 "read packet: $c#00",
 {"direction": "send", "regex": fork_regex,
- "capture": {1: "pid", 2: "tid"}},
+ "capture": {1: "parent_pid", 2: "pid", 3: "tid"}},
 ], True)
 ret = self.expect_gdbremote_sequence()
 parent_pid, pid, tid = (int(ret[x], 16) for x
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
@@ -809,8 +809,12 @@
   // Print the signal number.
   response.PutHex8(signum & 0xff);
 
-  // Include the tid.
-  response.Printf("thread:%" PRIx64 ";", tid);
+  // Include the (pid and) tid.
+  response.PutCString("thread:");
+  if (bool(m_extensions_supported &
+   NativeProcessProtocol::Extension::multiprocess))
+response.Format("p{0:x-}.", m_current_process->GetID());
+  response.Format("{0:x-};", tid);
 
   // Include the thread name if there is one.
   const std::string thread_name = thread->GetName();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D127999: [lldb] fix stepping through POSIX trampolines

2022-06-20 Thread Michael Daniels via Phabricator via lldb-commits
mdaniels updated this revision to Diff 438347.

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

https://reviews.llvm.org/D127999

Files:
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/test/API/lang/cpp/step-through-trampoline/Makefile
  lldb/test/API/lang/cpp/step-through-trampoline/TestStepThroughTrampoline.py
  lldb/test/API/lang/cpp/step-through-trampoline/foo.cpp
  lldb/test/API/lang/cpp/step-through-trampoline/foo.h
  lldb/test/API/lang/cpp/step-through-trampoline/main.cpp


Index: lldb/test/API/lang/cpp/step-through-trampoline/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/main.cpp
@@ -0,0 +1,6 @@
+#include "foo.h"
+
+int main(void) {
+foo(); // Set a breakpoint here
+}
+
Index: lldb/test/API/lang/cpp/step-through-trampoline/foo.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/foo.h
@@ -0,0 +1,2 @@
+extern void foo();
+
Index: lldb/test/API/lang/cpp/step-through-trampoline/foo.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/foo.cpp
@@ -0,0 +1,4 @@
+#include "foo.h"
+
+void foo() { } // End up here
+
Index: 
lldb/test/API/lang/cpp/step-through-trampoline/TestStepThroughTrampoline.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/TestStepThroughTrampoline.py
@@ -0,0 +1,17 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class StepThroughTrampoline(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def test(self):
+self.build()
+(target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self,
+   "// Set a breakpoint here",
+   lldb.SBFileSpec("main.cpp"),
+   extra_images=["foo"])
+thread.StepInto()
+
+foo_line = line_number("foo.cpp", '// End up here')
+self.expect("frame info", substrs=["foo.cpp:{}:".format(foo_line)])
Index: lldb/test/API/lang/cpp/step-through-trampoline/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/Makefile
@@ -0,0 +1,6 @@
+DYLIB_NAME := foo
+DYLIB_CXX_SOURCES := foo.cpp
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
+
Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
===
--- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -488,7 +488,7 @@
   if (sym == nullptr || !sym->IsTrampoline())
 return thread_plan_sp;
 
-  ConstString sym_name = sym->GetName();
+  ConstString sym_name = sym->GetMangled().GetName(Mangled::ePreferMangled);
   if (!sym_name)
 return thread_plan_sp;
 


Index: lldb/test/API/lang/cpp/step-through-trampoline/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/main.cpp
@@ -0,0 +1,6 @@
+#include "foo.h"
+
+int main(void) {
+foo(); // Set a breakpoint here
+}
+
Index: lldb/test/API/lang/cpp/step-through-trampoline/foo.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/foo.h
@@ -0,0 +1,2 @@
+extern void foo();
+
Index: lldb/test/API/lang/cpp/step-through-trampoline/foo.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/foo.cpp
@@ -0,0 +1,4 @@
+#include "foo.h"
+
+void foo() { } // End up here
+
Index: lldb/test/API/lang/cpp/step-through-trampoline/TestStepThroughTrampoline.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/step-through-trampoline/TestStepThroughTrampoline.py
@@ -0,0 +1,17 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class StepThroughTrampoline(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def test(self):
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+   "// Set a breakpoint here",
+   lldb.SBFileSpec("main.cpp"),
+   extra_images=["foo"])
+thread.StepInto()
+
+foo_line = line_number("foo.cpp", '// End up here')
+self.expect("frame info", substrs=["foo.cpp:{}:".format(foo_line)])
Index: lldb/test/API/lang/cpp/step-through-trampoline/Makefile
===

[Lldb-commits] [PATCH] D127999: [lldb] fix stepping through POSIX trampolines

2022-06-20 Thread Michael Daniels via Phabricator via lldb-commits
mdaniels added inline comments.



Comment at: 
lldb/test/API/lang/cpp/step-into-namespace/TestStepIntoNamespace.py:5
+
+class StepIntoNamespace(TestBase):
+mydir = TestBase.compute_mydir(__file__)

labath wrote:
> Am I correct in assuming that the "namespace" part here comes from the fact 
> that global functions (e.g. `_Z3foov` aka `foo()`) would be found according 
> to their base name (`foo`) or something?
> 
> If yes, that's fine, but it would still be nice to mention (say in a comment 
> or something) that the shared library is an important aspect of the test 
> ("TestStepIntoNamespace" does not convey that notion).
> 
> If this can also be reproduced with regular functions, then it'd be better to 
> rename the test into something else (which includes the word "trampoline").
The lookup will be done with the full demangled name, so in this case it would 
be "foo::foo()".

The namespace part was just because I had trouble reproducing when reducing the 
testcase to a plain function call. Though I tried it again and can reproduce 
the issue fine, so was likely user error on my part.

I will rename as suggested, thanks.



Comment at: 
lldb/test/API/lang/cpp/step-into-namespace/TestStepIntoNamespace.py:8
+
+def test(self):
+self.build()

labath wrote:
> mdaniels wrote:
> > clayborg wrote:
> > > Do we want to limit this to linux? I am not sure this will pass the 
> > > windows buildbots if we don't restrict it
> > Looking at other tests that load a shared library, it seems I should have 
> > at least
> > 
> > ```
> > @skipIfRemote
> > @skipIfWindows
> > ```
> > But I can also just restrict it to the platforms I am able to test on 
> > locally, linux and darwin, if there is still concern that other platforms 
> > might fail.
> Neither of these is strictly necessary. Remote shared library tests need 
> additional care as one has to copy the shared library to the remote system, 
> but afaik, you're using the correct incantation which should do that 
> automatically.
> 
> Windows shared library support is not at the level of other platforms, but a 
> simple setup like this should work. Or rather: if it fails, it will probably 
> be due to the trampoline aspect, and not the shared library loading. So I 
> think you don't need to add any decorators right now. We can add 
> xfail-windows if it turns out to be failing.
Good to know, thanks for the feedback


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

https://reviews.llvm.org/D127999

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


[Lldb-commits] [PATCH] D128201: [lldb][windows] Fix crash on getting nested exception

2022-06-20 Thread Alvin Wong via Phabricator via lldb-commits
alvinhochun created this revision.
Herald added a subscriber: mstorsjo.
Herald added a project: All.
alvinhochun requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

LLDB tries to follow `EXCEPTION_RECORD::ExceptionRecord` to follow the
nested exception chain. In practice this code just causes Access
Violation whenever there is a nested exception. Since there does not
appear to be any code in LLDB that is actually using the nested
exceptions, this change just disables the crashing code and adds a
comment to clarify the reason.

Fixes https://github.com/mstorsjo/llvm-mingw/issues/292


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128201

Files:
  lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h


Index: lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
===
--- lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
+++ lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
@@ -27,9 +27,19 @@
   ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) {
 m_code = record.ExceptionCode;
 m_continuable = (record.ExceptionFlags == 0);
+// This marks some old code which tried to parse the nested exception. In
+// practice, this code just causes Access Violation. I suspect
+// `ExceptionRecord` here actually points to the address space of the
+// debuggee process. However, I did not manage to find any official or
+// unofficial reference that clarifies this point. If anyone would like to
+// reimplement this, please also keep in mind to check how this behaves 
when
+// debugging a WOW64 process. I suspect you may have to use the explicit
+// `EXCEPTION_RECORD32` and `EXCEPTION_RECORD64` structs.
+#if 0
 if (record.ExceptionRecord)
   m_next_exception.reset(
   new ExceptionRecord(*record.ExceptionRecord, thread_id));
+#endif
 m_exception_addr = reinterpret_cast(record.ExceptionAddress);
 m_thread_id = thread_id;
 m_arguments.assign(record.ExceptionInformation,
@@ -39,17 +49,18 @@
   // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
   ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
   : m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 
0),
-m_next_exception(nullptr),
 m_exception_addr(static_cast(record.ExceptionAddress)),
 m_thread_id(thread_id),
 m_arguments(record.ExceptionInformation,
 record.ExceptionInformation + record.NumberParameters) {
+#if 0
 // Set up link to nested exception.
 if (record.ExceptionRecord) {
   m_next_exception.reset(new ExceptionRecord(
   *reinterpret_cast(record.ExceptionRecord),
   thread_id));
 }
+#endif
   }
 
   virtual ~ExceptionRecord() {}
@@ -57,9 +68,11 @@
   DWORD
   GetExceptionCode() const { return m_code; }
   bool IsContinuable() const { return m_continuable; }
+#if 0
   const ExceptionRecord *GetNextException() const {
 return m_next_exception.get();
   }
+#endif
   lldb::addr_t GetExceptionAddress() const { return m_exception_addr; }
 
   lldb::tid_t GetThreadID() const { return m_thread_id; }
@@ -69,7 +82,9 @@
 private:
   DWORD m_code;
   bool m_continuable;
+#if 0
   std::shared_ptr m_next_exception;
+#endif
   lldb::addr_t m_exception_addr;
   lldb::tid_t m_thread_id;
   std::vector m_arguments;


Index: lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
===
--- lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
+++ lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
@@ -27,9 +27,19 @@
   ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) {
 m_code = record.ExceptionCode;
 m_continuable = (record.ExceptionFlags == 0);
+// This marks some old code which tried to parse the nested exception. In
+// practice, this code just causes Access Violation. I suspect
+// `ExceptionRecord` here actually points to the address space of the
+// debuggee process. However, I did not manage to find any official or
+// unofficial reference that clarifies this point. If anyone would like to
+// reimplement this, please also keep in mind to check how this behaves when
+// debugging a WOW64 process. I suspect you may have to use the explicit
+// `EXCEPTION_RECORD32` and `EXCEPTION_RECORD64` structs.
+#if 0
 if (record.ExceptionRecord)
   m_next_exception.reset(
   new ExceptionRecord(*record.ExceptionRecord, thread_id));
+#endif
 m_exception_addr = reinterpret_cast(record.ExceptionAddress);
 m_thread_id = thread_id;
 m_arguments.assign(record.ExceptionInformation,
@@ -39,17 +49,18 @@
   // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
   ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::ti

[Lldb-commits] [PATCH] D127234: [lldb] Add setting to override PE/COFF ABI by module name

2022-06-20 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: DavidSpickett.
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFProperties.td:13
+EnumValues<"OptionEnumValues(g_abi_enums)">,
+Desc<"A mapping of ABI override to use for specific modules. The module 
name is matched by its file name with extension. These versions are checked in 
sequence: exact, lowercase, exact with '.debug' suffix stripped, lowercase with 
'.debug' suffix stripped.">;
 }

What are the values accepted for this?



Comment at: lldb/test/Shell/ObjectFile/PECOFF/settings-abi.yaml:37
+# RUN:   FileCheck -DABI=msvc -DFILENAME=%basename_t.tmp.debug %s
+
 # CHECK-LABEL: image list --triple --basename

You should test that `UPPER_CASE` and `UPPER_CASE.debug` still find the module 
abi.

I think you could test the priority order too.

Start with 1 setting `foo=msvc`, check it gets msvc.
Add the next highest priority `Foo=gnu`, check it gets gnu.
Remove `foo=msvc`, add the next highest priority as `foo.debug=msvc`, check it 
gets msvc.
Remove `Foo=gnu` and add `Foo.debug=gnu`, check it gets gnu.

At each stage you're proving that it'll choose one of a pair, put that all 
together you've proved the order overall.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127234

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


[Lldb-commits] [PATCH] D128201: [lldb][windows] Fix crash on getting nested exception

2022-06-20 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: DavidSpickett.
DavidSpickett added a comment.

Any reason to `#if 0` this instead of just removing it and maybe adding a one 
line comment like "nested exceptions are not supported"? So that someone can 
git blame that and find this commit with the removal.

If this is not used at all this is academic, but what situation would it be 
describing if it did? Is it something like if you had an exception in a signal 
handler, that was handling an initial exception?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128201

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


[Lldb-commits] [PATCH] D128107: [trace] Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-20 Thread Jakob Johnson via Phabricator via lldb-commits
jj10306 updated this revision to Diff 438400.
jj10306 marked 12 inline comments as done.
jj10306 added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128107

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBFileSpec.h
  lldb/include/lldb/API/SBTrace.h
  lldb/include/lldb/Target/Trace.h
  lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBTrace.cpp
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Target/Trace.cpp
  lldb/test/API/commands/trace/TestTraceLoad.py

Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -7,10 +7,11 @@
 class TestTraceLoad(TraceIntelPTTestCaseBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTrace(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -19,10 +20,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTraceWithStringNumbers(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_with_string_numbers.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_with_string_numbers.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -31,10 +33,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 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"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_missing_threads.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, 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",
@@ -43,10 +46,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadTrace(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-trace", "trace.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-trace", "trace.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 
 target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
@@ -88,11 +92,13 @@
   Errors:
 Number of TSC decoding errors: 0'''])
 
+@testSBAPIAndCommands
 def testLoadInvalidTraces(self):
 src_dir = self.getSourceDir()
+
 # We test first an invalid type
-self.expect("trace load -v " + os.path.join(src_dir, "intelpt-trace", "trace_bad.json"), error=True,
-  substrs=['''error: expected object at traceSession.processes[0]
+trace_description_file_path = os.path.join(src_dir, "intelpt-trace", "trace_bad.json")
+expected_substrs = ['''error: expected object at traceSession.processes[0]
 
 Context:
 {

[Lldb-commits] [PATCH] D128107: [trace] Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-20 Thread Jakob Johnson via Phabricator via lldb-commits
jj10306 added inline comments.



Comment at: lldb/include/lldb/API/SBDebugger.h:403
+  /// trace session.
+  SBTrace LoadTraceFromFile(SBError &error, const char *trace_file_path);
+

wallace wrote:
> wallace wrote:
> > JDevlieghere wrote:
> > > Can this take a filespec? 
> > +1
> We need to come up with a good public name for the json file. I've been using 
> trace session file, but I dislike. What about trace description file? Then we 
> can have a "trace bundle" that contains  "trace description file". Do you 
> have better suggestions?
I think trace description file is a more appropriate name as well.



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py:139
+if self.USE_SB_API:
+traceDescriptionFile = lldb.SBFileSpec(traceDescriptionFilePath)
+loadTraceError = lldb.SBError()

the single arg constructor is deprecated, update this to pass `resolve` flag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128107

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


[Lldb-commits] [PATCH] D127193: [lldb] [llgs] Fix signo sent with fork/vfork/vforkdone events

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 438410.
mgorny edited the summary of this revision.
mgorny added a comment.

Update to make `signo` an unconditional member of the struct, and set it for 
fork/vfork/vforkdone events explicitly.


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

https://reviews.llvm.org/D127193

Files:
  lldb/include/lldb/Host/Debug.h
  lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
  lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
  lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
  lldb/tools/debugserver/source/RNBRemote.cpp

Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -2704,7 +2704,7 @@
 std::ostringstream ostrm;
 // Output the T packet with the thread
 ostrm << 'T';
-int signum = tid_stop_info.details.signal.signo;
+int signum = tid_stop_info.signo;
 DNBLogThreadedIf(
 LOG_RNB_PROC, "%8d %s got signal signo = %u, exc_type = %u",
 (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__,
@@ -5450,9 +5450,9 @@
   break;
 
 case eStopTypeSignal:
-  if (tid_stop_info.details.signal.signo != 0) {
+  if (tid_stop_info.signo != 0) {
 thread_dict_sp->AddIntegerItem("signal",
-   tid_stop_info.details.signal.signo);
+   tid_stop_info.signo);
 reason_value = "signal";
   }
   break;
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
@@ -15,7 +15,7 @@
 self.reset_test_sequence()
 
 # continue and expect fork
-fork_regex = "[$]T.*;fork:p([0-9a-f]+)[.]([0-9a-f]+).*"
+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,
@@ -49,7 +49,7 @@
 self.reset_test_sequence()
 
 # continue and expect fork
-fork_regex = "[$]T.*;{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant)
+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,
@@ -85,7 +85,7 @@
 # resume the parent
 self.test_sequence.add_log_lines([
 "read packet: $c#00",
-{"direction": "send", "regex": r"[$]T.*vforkdone.*"},
+{"direction": "send", "regex": r"[$]T05.*vforkdone.*"},
 "read packet: $c#00",
 {"direction": "send", "regex": r"[$]W00;process:[0-9a-f]+#.*"},
 ], True)
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
@@ -715,7 +715,7 @@
   return llvm::make_error(
   "failed to get stop reason", llvm::inconvertibleErrorCode());
 
-const int signum = tid_stop_info.details.signal.signo;
+const int signum = tid_stop_info.signo;
 if (log) {
   LLDB_LOGF(log,
 "GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64
@@ -799,7 +799,7 @@
   StreamString response;
   // Output the T packet with the thread
   response.PutChar('T');
-  int signum = tid_stop_info.details.signal.signo;
+  int signum = tid_stop_info.signo;
   LLDB_LOG(
   log,
   "pid {0}, tid {1}, got signal signo = {2}, reason = {3}, exc_type = {4}",
Index: lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -253,13 +253,12 @@
 
   ThreadStopInfo stop_info;
   stop_info.reason = reason;
-
   // No signal support on Windows but required to provide a 'valid' signum.
+  stop_info.signo = SIGTRAP;
+
   if (reason == StopReason::eStopReasonException) {
 stop_info.details.exception.type = 0;
 stop_info.details.exception.data_count = 0;
-  } else {
-stop_info.details.signal.signo = SIGTRAP;
   }
 
   thread.SetStopReason(stop_info, description);
Index: lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
=

[Lldb-commits] [PATCH] D128156: [lldb] [llgs] Include PID in QC response in multiprocess mode

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

Update more tests. I have no clue how I missed these when testing.


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

https://reviews.llvm.org/D128156

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
@@ -11,7 +11,6 @@
   "{}: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):
@@ -68,7 +67,7 @@
 "send packet: $OK#00",
 # verify that the current process is correct
 "read packet: $qC#00",
-"send packet: $QC{}#00".format(parent_tid),
+"send packet: $QCp{}.{}#00".format(parent_pid, parent_tid),
 # verify that the correct processes are detached/available
 "read packet: $Hgp{}.{}#00".format(child_pid, child_tid),
 "send packet: $Eff#00",
@@ -167,12 +166,9 @@
 
 # get process pid
 self.test_sequence.add_log_lines([
-"read packet: $qProcessInfo#00",
-{"direction": "send", "regex": self.procinfo_regex,
- "capture": {1: "pid"}},
 "read packet: $qC#00",
-{"direction": "send", "regex": "[$]QC([0-9a-f]+)#.*",
- "capture": {1: "tid"}},
+{"direction": "send", "regex": "[$]QCp([0-9a-f]+).([0-9a-f]+)#.*",
+ "capture": {1: "pid", 2: "tid"}},
 ], True)
 ret = self.expect_gdbremote_sequence()
 pid, tid = (int(ret[x], 16) for x in ("pid", "tid"))
@@ -208,8 +204,8 @@
 
 # get process pid
 self.test_sequence.add_log_lines([
-"read packet: $qProcessInfo#00",
-{"direction": "send", "regex": self.procinfo_regex,
+"read packet: $qC#00",
+{"direction": "send", "regex": "[$]QCp([0-9a-f]+).[0-9a-f]+#.*",
  "capture": {1: "pid"}},
 ], True)
 ret = self.expect_gdbremote_sequence()
@@ -817,3 +813,56 @@
 data = ret.get("data")
 self.assertIsNotNone(data)
 self.assertEqual(data, old_val[1])
+
+@add_test_categories(["fork"])
+def test_qC(self):
+self.build()
+self.prep_debug_monitor_and_inferior(
+inferior_args=["fork",
+   "thread:new",
+   "trap",
+   ])
+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)
+self.add_threadinfo_collection_packets()
+ret = self.expect_gdbremote_sequence()
+pidtids = [
+(ret["parent_pid"], ret["parent_tid"]),
+(ret["child_pid"], ret["child_tid"]),
+]
+self.reset_test_sequence()
+
+for pidtid in pidtids:
+self.test_sequence.add_log_lines(
+["read packet: $Hcp{}.{}#00".format(*pidtid),
+ "send packet: $OK#00",
+ "read packet: $c#00",
+ {"direction": "send",
+  "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+  },
+ ], True)
+
+self.add_threadinfo_collection_packets()
+ret = self.expect_gdbremote_sequence()
+self.reset_test_sequence()
+
+pidtids = set(self.parse_threadinfo_packets(ret))
+self.assertEqual(len(pidtids), 4)
+for pidtid in pidtids:
+self.test_sequence.add_log_lines(
+["read packet: $Hgp{:x}.{:x}#00".format(*pidtid),
+ "send packet: $OK#00",
+ "read packet: $qC#00",
+ "send packet: $QCp{:x}.{:x}#00".format(*pidtid),
+ ], 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
@@ -1402,7 +1402,10 @@
 return SendErrorR

[Lldb-commits] [PATCH] D128201: [lldb][windows] Fix crash on getting nested exception

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

> Any reason to `#if 0` this instead of just removing it and maybe adding a one 
> line comment like "nested exceptions are not supported"? So that someone can 
> git blame that and find this commit with the removal.

I want to leave a clear note explaining what not to do with 
`record.ExceptionRecord`. In case someone want to implement handling of nested 
exceptions in the future, they will be more likely to see it and not repeat the 
mistake. Though I suppose just having the comment is fine and we don't really 
need to keep all the code in `#if 0`.

> If this is not used at all this is academic, but what situation would it be 
> describing if it did? Is it something like if you had an exception in a 
> signal handler, that was handling an initial exception?

I am not familiar with the inner workings of exception handling on Windows and 
there aren't any references I could find, so this is just speculation.

In the sample program from 
https://github.com/mstorsjo/llvm-mingw/issues/292#issuecomment-1160239522, I am 
triggering an Access Violation (segfault) inside WindowProc. An Access 
Violation will produce the exception 0xc005, Debuggers will get a first 
chance exception at that point. (GDB and WinDbg both break execution on this, 
but LLDB decides to let the debuggee continue for some reason.) After this, the 
exception is passed to an exception handler if there is one.

Because WindowProc is called by Windows, there seems to have an exception 
handler internally. For whatever reason it then decides to throw its own 
exception 0xc41d (it seems undocumented but does have a message: "An 
unhandled exception was encountered during a user callback."). I suspect here 
the nested exception would contain info about the original exception (Access 
Violation 0xc005).

There seems to be an undocumented `NtRaiseException@12` function that is used 
to raise the exception with a `EXCEPTION_RECORD` directly (which can contain a 
nested exception). The normal `RaiseException` API in kernel32 only allows 
specifying the exception code, flag and arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128201

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


[Lldb-commits] [PATCH] D127234: [lldb] Add setting to override PE/COFF ABI by module name

2022-06-20 Thread Alvin Wong via Phabricator via lldb-commits
alvinhochun added inline comments.



Comment at: 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFFProperties.td:13
+EnumValues<"OptionEnumValues(g_abi_enums)">,
+Desc<"A mapping of ABI override to use for specific modules. The module 
name is matched by its file name with extension. These versions are checked in 
sequence: exact, lowercase, exact with '.debug' suffix stripped, lowercase with 
'.debug' suffix stripped.">;
 }

DavidSpickett wrote:
> What are the values accepted for this?
It's the same enum as the setting `plugin.object-file.pe-coff.abi` added in 
D127048 - `default`, `msvc` and `gnu`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127234

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


[Lldb-commits] [PATCH] D128201: [lldb][windows] Fix crash on getting nested exception

2022-06-20 Thread Alvin Wong via Phabricator via lldb-commits
alvinhochun updated this revision to Diff 438430.
alvinhochun edited the summary of this revision.
alvinhochun added a comment.

Remove old code instead of `#if 0`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128201

Files:
  lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h


Index: lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
===
--- lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
+++ lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
@@ -25,11 +25,17 @@
 class ExceptionRecord {
 public:
   ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) {
+// Notes about the `record.ExceptionRecord` field:
+// In the past, some code tried to parse the nested exception with it, but
+// in practice, that code just causes Access Violation. I suspect
+// `ExceptionRecord` here actually points to the address space of the
+// debuggee process. However, I did not manage to find any official or
+// unofficial reference that clarifies this point. If anyone would like to
+// reimplement this, please also keep in mind to check how this behaves 
when
+// debugging a WOW64 process. I suspect you may have to use the explicit
+// `EXCEPTION_RECORD32` and `EXCEPTION_RECORD64` structs.
 m_code = record.ExceptionCode;
 m_continuable = (record.ExceptionFlags == 0);
-if (record.ExceptionRecord)
-  m_next_exception.reset(
-  new ExceptionRecord(*record.ExceptionRecord, thread_id));
 m_exception_addr = reinterpret_cast(record.ExceptionAddress);
 m_thread_id = thread_id;
 m_arguments.assign(record.ExceptionInformation,
@@ -39,27 +45,16 @@
   // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
   ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
   : m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 
0),
-m_next_exception(nullptr),
 m_exception_addr(static_cast(record.ExceptionAddress)),
 m_thread_id(thread_id),
 m_arguments(record.ExceptionInformation,
-record.ExceptionInformation + record.NumberParameters) {
-// Set up link to nested exception.
-if (record.ExceptionRecord) {
-  m_next_exception.reset(new ExceptionRecord(
-  *reinterpret_cast(record.ExceptionRecord),
-  thread_id));
-}
-  }
+record.ExceptionInformation + record.NumberParameters) {}
 
   virtual ~ExceptionRecord() {}
 
   DWORD
   GetExceptionCode() const { return m_code; }
   bool IsContinuable() const { return m_continuable; }
-  const ExceptionRecord *GetNextException() const {
-return m_next_exception.get();
-  }
   lldb::addr_t GetExceptionAddress() const { return m_exception_addr; }
 
   lldb::tid_t GetThreadID() const { return m_thread_id; }
@@ -69,7 +64,6 @@
 private:
   DWORD m_code;
   bool m_continuable;
-  std::shared_ptr m_next_exception;
   lldb::addr_t m_exception_addr;
   lldb::tid_t m_thread_id;
   std::vector m_arguments;


Index: lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
===
--- lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
+++ lldb/source/Plugins/Process/Windows/Common/ExceptionRecord.h
@@ -25,11 +25,17 @@
 class ExceptionRecord {
 public:
   ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) {
+// Notes about the `record.ExceptionRecord` field:
+// In the past, some code tried to parse the nested exception with it, but
+// in practice, that code just causes Access Violation. I suspect
+// `ExceptionRecord` here actually points to the address space of the
+// debuggee process. However, I did not manage to find any official or
+// unofficial reference that clarifies this point. If anyone would like to
+// reimplement this, please also keep in mind to check how this behaves when
+// debugging a WOW64 process. I suspect you may have to use the explicit
+// `EXCEPTION_RECORD32` and `EXCEPTION_RECORD64` structs.
 m_code = record.ExceptionCode;
 m_continuable = (record.ExceptionFlags == 0);
-if (record.ExceptionRecord)
-  m_next_exception.reset(
-  new ExceptionRecord(*record.ExceptionRecord, thread_id));
 m_exception_addr = reinterpret_cast(record.ExceptionAddress);
 m_thread_id = thread_id;
 m_arguments.assign(record.ExceptionInformation,
@@ -39,27 +45,16 @@
   // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
   ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
   : m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 0),
-m_next_exception(nullptr),
 m_exception_addr(static_cast(record.ExceptionAddress)),
 m_thread_id(thread_id),

[Lldb-commits] [PATCH] D127436: [lldb] Resolve exe location for `target create`

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

In D127436#3574289 , @alvinhochun 
wrote:

> Does this test look good:

With a bunch of minor fixups, this testcase does work - I uploaded a working 
copy of it at https://martin.st/temp/command-target-create-resolve-exe.test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127436

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


[Lldb-commits] [lldb] af93f12 - [lldb] [llgs] Refactor SendStopReplyPacketForThread for multiprocess

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

Author: Michał Górny
Date: 2022-06-20T19:42:21+02:00
New Revision: af93f123b92eb3591d0667c24db9cd325d670912

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

LOG: [lldb] [llgs] Refactor SendStopReplyPacketForThread for multiprocess

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
Differential Revision: https://reviews.llvm.org/D127289

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index e173f04bebe4..5e54be331553 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -768,19 +768,13 @@ GetJSONThreadsInfo(NativeProcessProtocol &process, bool 
abridged) {
 
 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);
 
@@ -803,7 +797,7 @@ 
GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
   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.
@@ -813,7 +807,7 @@ 
GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
   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.
@@ -845,9 +839,9 @@ 
GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
 
 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());
@@ -872,7 +866,7 @@ 
GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
   } else {
 LLDB_LOG_ERROR(log, threads_info.takeError(),
"failed to prepare a jstopinfo field for pid {1}: {0}",
-   m_current_process->GetID());
+   process.GetID());
   }
 }
 
@@ -880,7 +874,7 @@ 
GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
 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(
@@ -1718,7 +1712,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReasonForState(
 // 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:
@@ -3331,6 +3325,10 @@ GDBRemoteCommunicationServerLLGS::Handle_qThreadStopInfo(
 StringExtractorG

[Lldb-commits] [lldb] f8c6de8 - [lldb] [llgs] Refactor SendStopReasonForState for multiprocess

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

Author: Michał Górny
Date: 2022-06-20T19:42:21+02:00
New Revision: f8c6de8dbbd7ee0d037e07a94e3c5a370c2edaff

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

LOG: [lldb] [llgs] Refactor SendStopReasonForState for multiprocess

Refactor GDBRemoteCommunicationServerLLGS::SendStopReasonForState()
to accept process as an argument rather than hardcoding
m_current_process, in order to make it work correctly for multiprocess
scenarios.

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

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 5e54be331553..6fffef8b1eca 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -983,7 +983,8 @@ void 
GDBRemoteCommunicationServerLLGS::HandleInferiorState_Exited(
   Log *log = GetLog(LLDBLog::Process);
   LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
 
-  PacketResult result = SendStopReasonForState(StateType::eStateExited);
+  PacketResult result =
+  SendStopReasonForState(*process, StateType::eStateExited);
   if (result != PacketResult::Success) {
 LLDB_LOGF(log,
   "GDBRemoteCommunicationServerLLGS::%s failed to send stop "
@@ -1015,7 +1016,8 @@ void 
GDBRemoteCommunicationServerLLGS::HandleInferiorState_Stopped(
 break;
   default:
 // In all other cases, send the stop reason.
-PacketResult result = SendStopReasonForState(StateType::eStateStopped);
+PacketResult result =
+SendStopReasonForState(*process, StateType::eStateStopped);
 if (result != PacketResult::Success) {
   LLDB_LOGF(log,
 "GDBRemoteCommunicationServerLLGS::%s failed to send stop "
@@ -1686,12 +1688,13 @@ GDBRemoteCommunicationServerLLGS::Handle_stop_reason(
   if (!m_current_process)
 return SendErrorResponse(02);
 
-  return SendStopReasonForState(m_current_process->GetState());
+  return SendStopReasonForState(*m_current_process,
+m_current_process->GetState());
 }
 
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::SendStopReasonForState(
-lldb::StateType process_state) {
+NativeProcessProtocol &process, lldb::StateType process_state) {
   Log *log = GetLog(LLDBLog::Process);
 
   switch (process_state) {
@@ -1707,22 +1710,21 @@ 
GDBRemoteCommunicationServerLLGS::SendStopReasonForState(
   case eStateSuspended:
   case eStateStopped:
   case eStateCrashed: {
-assert(m_current_process != nullptr);
-lldb::tid_t tid = m_current_process->GetCurrentThreadID();
+lldb::tid_t tid = process.GetCurrentThreadID();
 // Make sure we set the current thread so g and p packets return the data
 // the gdb will expect.
 SetCurrentThreadID(tid);
-return SendStopReplyPacketForThread(*m_current_process, tid);
+return SendStopReplyPacketForThread(process, tid);
   }
 
   case eStateInvalid:
   case eStateUnloaded:
   case eStateExited:
-return SendWResponse(m_current_process);
+return SendWResponse(&process);
 
   default:
 LLDB_LOG(log, "pid {0}, current state reporting not handled: {1}",
- m_current_process->GetID(), process_state);
+ process.GetID(), process_state);
 break;
   }
 
@@ -3172,7 +3174,9 @@ GDBRemoteCommunicationServerLLGS::Handle_vAttach(
   }
 
   // Notify we attached by sending a stop packet.
-  return SendStopReasonForState(m_current_process->GetState());
+  assert(m_current_process);
+  return SendStopReasonForState(*m_current_process,
+m_current_process->GetState());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -3202,7 +3206,9 @@ GDBRemoteCommunicationServerLLGS::Handle_vAttachWait(
   }
 
   // Notify we attached by sending a stop packet.
-  return SendStopReasonForState(m_current_process->GetState());
+  assert(m_current_process);
+  return SendStopReasonForState(*m_current_process,
+m_current_process->GetState());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -3238,7 +3244,9 @@ GDBRemoteCommunicationServerLLGS::Handle_vAttachOrWait(
   }
 
   // Notify we attached by sending a stop packet.
-  return SendStopReasonForState(m_current_process->GetState());
+  assert(m_current_process);
+  return SendStopReasonForState(*m_current_process,
+m_current_process->GetState());
 }

[Lldb-commits] [lldb] 9407439 - [lldb] [test] Disable gmodules testing on FreeBSD

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

Author: Michał Górny
Date: 2022-06-20T19:42:21+02:00
New Revision: 94074399ab0a2caefadc8fe4ecef70a938b396cc

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

LOG: [lldb] [test] Disable gmodules testing on FreeBSD

The -gmodule tests currently fail on FreeBSD due to include bugs:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264730

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

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/test_categories.py 
b/lldb/packages/Python/lldbsuite/test/test_categories.py
index 2fbf1a279042..a396741ccf8f 100644
--- a/lldb/packages/Python/lldbsuite/test/test_categories.py
+++ b/lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -64,7 +64,7 @@ def is_supported_on_platform(category, platform, 
compiler_path):
 return platform in ["darwin", "macosx", "ios", "watchos", "tvos", 
"bridgeos"]
 elif category == "gmodules":
 # First, check to see if the platform can even support gmodules.
-if platform not in ["freebsd", "darwin", "macosx", "ios", "watchos", 
"tvos", "bridgeos"]:
+if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", 
"bridgeos"]:
 return False
 return gmodules.is_compiler_clang_with_gmodules(compiler_path)
 return True



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


[Lldb-commits] [lldb] a36b9b3 - [lldb] [test] Make AVX/MPX register tests more robust and fix on BSD

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

Author: Michał Górny
Date: 2022-06-20T19:42:21+02:00
New Revision: a36b9b382a03f70d6dfe46f0f1ca43d19ea6b6df

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

LOG: [lldb] [test] Make AVX/MPX register tests more robust and fix on BSD

Make the AVX/MPX register tests more robust by checking for the presence
of actual registers rather than register sets.  Account for the option
that the respective registers are defined but not available, as is
the case on FreeBSD and NetBSD.  This fixes test regression on these
platforms.

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

Added: 


Modified: 
lldb/test/API/commands/register/register/register_command/TestRegisters.py

Removed: 




diff  --git 
a/lldb/test/API/commands/register/register/register_command/TestRegisters.py 
b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
index c3b26da3959d..5893acd92653 100644
--- a/lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -393,31 +393,25 @@ def fp_register_write(self):
 st0regname +
 ' = 0'])
 
-has_avx = False
-has_mpx = False
-# Returns an SBValueList.
+# Check if AVX/MPX registers are defined at all.
 registerSets = currentFrame.GetRegisters()
-for registerSet in registerSets:
-set_name = registerSet.GetName().lower()
-if 'advanced vector extensions' in set_name:
-has_avx = True
-# Darwin reports AVX registers as part of "Floating Point 
Registers"
-elif self.platformIsDarwin() and 'floating point registers' in 
set_name:
-has_avx = 
registerSet.GetChildMemberWithName('ymm0').IsValid()
-
-# FreeBSD/NetBSD reports missing register sets 
diff erently
-# at the moment and triggers false positive here.
-# TODO: remove FreeBSD/NetBSD exception when we make 
unsupported
-# register groups correctly disappear.
-if ('memory protection extension' in 
registerSet.GetName().lower()
-and self.getPlatform() not in ["freebsd", "netbsd"]):
-has_mpx = True
+registers = frozenset(reg.GetName() for registerSet in registerSets
+  for reg in registerSet)
+has_avx_regs = "ymm0" in registers
+has_mpx_regs = "bnd0" in registers
+# Check if they are actually present.
+self.runCmd("register read -a")
+output = self.res.GetOutput()
+has_avx = "ymm0 =" in output
+has_mpx = "bnd0 =" in output
 
 if has_avx:
 new_value = "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 
0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x0c 0x0d 0x0e 0x0f}"
 self.write_and_read(currentFrame, "ymm0", new_value)
 self.write_and_read(currentFrame, "ymm7", new_value)
 self.expect("expr $ymm0", substrs=['vector_type'])
+elif has_avx_regs:
+self.expect("register read ymm0", substrs=["error: 
unavailable"])
 else:
 self.expect("register read ymm0", substrs=["Invalid register 
name 'ymm0'"],
 error=True)
@@ -434,6 +428,8 @@ def fp_register_write(self):
 new_value = "{0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08}"
 self.write_and_read(currentFrame, "bndstatus", new_value)
 self.expect("expr $bndstatus", substrs = ['vector_type'])
+elif has_mpx_regs:
+self.expect("register read bnd0", substrs=["error: 
unavailable"])
 else:
 self.expect("register read bnd0", substrs=["Invalid register 
name 'bnd0'"],
 error=True)



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


[Lldb-commits] [lldb] d3292c4 - [lldb] [test] Fix test_platform_file_fstat to account for negative ints

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

Author: Michał Górny
Date: 2022-06-20T19:42:22+02:00
New Revision: d3292c4ba0ce13edb316d7fb63ccae376081a102

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

LOG: [lldb] [test] Fix test_platform_file_fstat to account for negative ints

Fix test_platform_file_fstat to correctly truncate/max out the expected
value when GDB Remote Serial Protocol specifies a value as an unsigned
integer but the underlying platform type uses a signed integer.

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

Added: 


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

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
index 57b2daf96143..fec1e95fa28c 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
@@ -32,11 +32,11 @@ class GDBStat(typing.NamedTuple):
 
 
 def uint32_or_zero(x):
-return x if x < 2**32 else 0
+return x if x < 2**32 and x >= 0 else 0
 
 
 def uint32_or_max(x):
-return x if x < 2**32 else 2**32 - 1
+return x if x < 2**32 and x >= 0 else 2**32 - 1
 
 
 def uint32_trunc(x):



___
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-20 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf93f123b92e: [lldb] [llgs] Refactor 
SendStopReplyPacketForThread for multiprocess (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

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
@@ -768,19 +768,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);
 
@@ -803,7 +797,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.
@@ -813,7 +807,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.
@@ -845,9 +839,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());
@@ -872,7 +866,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());
   }
 }
 
@@ -880,7 +874,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(
@@ -1718,7 +1712,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:
@@ -3331,6 +3325,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("qThreadStopInf

[Lldb-commits] [PATCH] D127497: [lldb] [llgs] Refactor SendStopReasonForState for multiprocess

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8c6de8dbbd7: [lldb] [llgs] Refactor SendStopReasonForState 
for multiprocess (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127497

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
@@ -116,7 +116,8 @@
   PacketResult SendStopReplyPacketForThread(NativeProcessProtocol &process,
 lldb::tid_t tid);
 
-  PacketResult SendStopReasonForState(lldb::StateType process_state);
+  PacketResult SendStopReasonForState(NativeProcessProtocol &process,
+  lldb::StateType process_state);
 
   PacketResult Handle_k(StringExtractorGDBRemote &packet);
 
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
@@ -983,7 +983,8 @@
   Log *log = GetLog(LLDBLog::Process);
   LLDB_LOGF(log, "GDBRemoteCommunicationServerLLGS::%s called", __FUNCTION__);
 
-  PacketResult result = SendStopReasonForState(StateType::eStateExited);
+  PacketResult result =
+  SendStopReasonForState(*process, StateType::eStateExited);
   if (result != PacketResult::Success) {
 LLDB_LOGF(log,
   "GDBRemoteCommunicationServerLLGS::%s failed to send stop "
@@ -1015,7 +1016,8 @@
 break;
   default:
 // In all other cases, send the stop reason.
-PacketResult result = SendStopReasonForState(StateType::eStateStopped);
+PacketResult result =
+SendStopReasonForState(*process, StateType::eStateStopped);
 if (result != PacketResult::Success) {
   LLDB_LOGF(log,
 "GDBRemoteCommunicationServerLLGS::%s failed to send stop "
@@ -1686,12 +1688,13 @@
   if (!m_current_process)
 return SendErrorResponse(02);
 
-  return SendStopReasonForState(m_current_process->GetState());
+  return SendStopReasonForState(*m_current_process,
+m_current_process->GetState());
 }
 
 GDBRemoteCommunication::PacketResult
 GDBRemoteCommunicationServerLLGS::SendStopReasonForState(
-lldb::StateType process_state) {
+NativeProcessProtocol &process, lldb::StateType process_state) {
   Log *log = GetLog(LLDBLog::Process);
 
   switch (process_state) {
@@ -1707,22 +1710,21 @@
   case eStateSuspended:
   case eStateStopped:
   case eStateCrashed: {
-assert(m_current_process != nullptr);
-lldb::tid_t tid = m_current_process->GetCurrentThreadID();
+lldb::tid_t tid = process.GetCurrentThreadID();
 // Make sure we set the current thread so g and p packets return the data
 // the gdb will expect.
 SetCurrentThreadID(tid);
-return SendStopReplyPacketForThread(*m_current_process, tid);
+return SendStopReplyPacketForThread(process, tid);
   }
 
   case eStateInvalid:
   case eStateUnloaded:
   case eStateExited:
-return SendWResponse(m_current_process);
+return SendWResponse(&process);
 
   default:
 LLDB_LOG(log, "pid {0}, current state reporting not handled: {1}",
- m_current_process->GetID(), process_state);
+ process.GetID(), process_state);
 break;
   }
 
@@ -3172,7 +3174,9 @@
   }
 
   // Notify we attached by sending a stop packet.
-  return SendStopReasonForState(m_current_process->GetState());
+  assert(m_current_process);
+  return SendStopReasonForState(*m_current_process,
+m_current_process->GetState());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -3202,7 +3206,9 @@
   }
 
   // Notify we attached by sending a stop packet.
-  return SendStopReasonForState(m_current_process->GetState());
+  assert(m_current_process);
+  return SendStopReasonForState(*m_current_process,
+m_current_process->GetState());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -3238,7 +3244,9 @@
   }
 
   // Notify we attached by sending a stop packet.
-  return SendStopReasonForState(m_current_process->GetState());
+  assert(m_current_process);
+  return SendStopReasonForState(*m_current_process,
+m_current_process->GetState());
 }
 
 GDBRemoteCommunication::PacketResult
@@ -3266,8 +3274,11 @@
 m_process_launch_info.GetExecuta

[Lldb-commits] [PATCH] D128034: [lldb] [test] Disable gmodules testing on FreeBSD

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94074399ab0a: [lldb] [test] Disable gmodules testing on 
FreeBSD (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128034

Files:
  lldb/packages/Python/lldbsuite/test/test_categories.py


Index: lldb/packages/Python/lldbsuite/test/test_categories.py
===
--- lldb/packages/Python/lldbsuite/test/test_categories.py
+++ lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -64,7 +64,7 @@
 return platform in ["darwin", "macosx", "ios", "watchos", "tvos", 
"bridgeos"]
 elif category == "gmodules":
 # First, check to see if the platform can even support gmodules.
-if platform not in ["freebsd", "darwin", "macosx", "ios", "watchos", 
"tvos", "bridgeos"]:
+if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", 
"bridgeos"]:
 return False
 return gmodules.is_compiler_clang_with_gmodules(compiler_path)
 return True


Index: lldb/packages/Python/lldbsuite/test/test_categories.py
===
--- lldb/packages/Python/lldbsuite/test/test_categories.py
+++ lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -64,7 +64,7 @@
 return platform in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]
 elif category == "gmodules":
 # First, check to see if the platform can even support gmodules.
-if platform not in ["freebsd", "darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]:
+if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]:
 return False
 return gmodules.is_compiler_clang_with_gmodules(compiler_path)
 return True
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D128041: [lldb] [test] Make AVX/MPX register tests more robust and fix on BSD

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa36b9b382a03: [lldb] [test] Make AVX/MPX register tests more 
robust and fix on BSD (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128041

Files:
  lldb/test/API/commands/register/register/register_command/TestRegisters.py


Index: 
lldb/test/API/commands/register/register/register_command/TestRegisters.py
===
--- lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -393,31 +393,25 @@
 st0regname +
 ' = 0'])
 
-has_avx = False
-has_mpx = False
-# Returns an SBValueList.
+# Check if AVX/MPX registers are defined at all.
 registerSets = currentFrame.GetRegisters()
-for registerSet in registerSets:
-set_name = registerSet.GetName().lower()
-if 'advanced vector extensions' in set_name:
-has_avx = True
-# Darwin reports AVX registers as part of "Floating Point 
Registers"
-elif self.platformIsDarwin() and 'floating point registers' in 
set_name:
-has_avx = 
registerSet.GetChildMemberWithName('ymm0').IsValid()
-
-# FreeBSD/NetBSD reports missing register sets differently
-# at the moment and triggers false positive here.
-# TODO: remove FreeBSD/NetBSD exception when we make 
unsupported
-# register groups correctly disappear.
-if ('memory protection extension' in 
registerSet.GetName().lower()
-and self.getPlatform() not in ["freebsd", "netbsd"]):
-has_mpx = True
+registers = frozenset(reg.GetName() for registerSet in registerSets
+  for reg in registerSet)
+has_avx_regs = "ymm0" in registers
+has_mpx_regs = "bnd0" in registers
+# Check if they are actually present.
+self.runCmd("register read -a")
+output = self.res.GetOutput()
+has_avx = "ymm0 =" in output
+has_mpx = "bnd0 =" in output
 
 if has_avx:
 new_value = "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 
0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x0c 0x0d 0x0e 0x0f}"
 self.write_and_read(currentFrame, "ymm0", new_value)
 self.write_and_read(currentFrame, "ymm7", new_value)
 self.expect("expr $ymm0", substrs=['vector_type'])
+elif has_avx_regs:
+self.expect("register read ymm0", substrs=["error: 
unavailable"])
 else:
 self.expect("register read ymm0", substrs=["Invalid register 
name 'ymm0'"],
 error=True)
@@ -434,6 +428,8 @@
 new_value = "{0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08}"
 self.write_and_read(currentFrame, "bndstatus", new_value)
 self.expect("expr $bndstatus", substrs = ['vector_type'])
+elif has_mpx_regs:
+self.expect("register read bnd0", substrs=["error: 
unavailable"])
 else:
 self.expect("register read bnd0", substrs=["Invalid register 
name 'bnd0'"],
 error=True)


Index: lldb/test/API/commands/register/register/register_command/TestRegisters.py
===
--- lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -393,31 +393,25 @@
 st0regname +
 ' = 0'])
 
-has_avx = False
-has_mpx = False
-# Returns an SBValueList.
+# Check if AVX/MPX registers are defined at all.
 registerSets = currentFrame.GetRegisters()
-for registerSet in registerSets:
-set_name = registerSet.GetName().lower()
-if 'advanced vector extensions' in set_name:
-has_avx = True
-# Darwin reports AVX registers as part of "Floating Point Registers"
-elif self.platformIsDarwin() and 'floating point registers' in set_name:
-has_avx = registerSet.GetChildMemberWithName('ymm0').IsValid()
-
-# FreeBSD/NetBSD reports missing register sets differently
-# at the moment and triggers false positive here.
-# TODO: remove FreeBSD/NetBSD exception when we make unsupported
-   

[Lldb-commits] [PATCH] D128042: [lldb] [test] Fix test_platform_file_fstat to account for negative ints

2022-06-20 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd3292c4ba0ce: [lldb] [test] Fix test_platform_file_fstat to 
account for negative ints (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128042

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


Index: lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
@@ -32,11 +32,11 @@
 
 
 def uint32_or_zero(x):
-return x if x < 2**32 else 0
+return x if x < 2**32 and x >= 0 else 0
 
 
 def uint32_or_max(x):
-return x if x < 2**32 else 2**32 - 1
+return x if x < 2**32 and x >= 0 else 2**32 - 1
 
 
 def uint32_trunc(x):


Index: lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
@@ -32,11 +32,11 @@
 
 
 def uint32_or_zero(x):
-return x if x < 2**32 else 0
+return x if x < 2**32 and x >= 0 else 0
 
 
 def uint32_or_max(x):
-return x if x < 2**32 else 2**32 - 1
+return x if x < 2**32 and x >= 0 else 2**32 - 1
 
 
 def uint32_trunc(x):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D128107: [trace] Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-20 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

nice job!




Comment at: 
lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py:139
+if self.USE_SB_API:
+traceDescriptionFile = lldb.SBFileSpec(traceDescriptionFilePath)
+loadTraceError = lldb.SBError()

jj10306 wrote:
> the single arg constructor is deprecated, update this to pass `resolve` flag
i don't think it's deprecated, but you should pass the resolve flag anyone


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128107

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


[Lldb-commits] [PATCH] D127702: Support logpoints in lldb-vscode

2022-06-20 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan updated this revision to Diff 438448.
yinghuitan added a comment.

Using a single structured LogMessagePart per suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127702

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_logpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp
  lldb/tools/lldb-vscode/BreakpointBase.cpp
  lldb/tools/lldb-vscode/BreakpointBase.h
  lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1532,6 +1532,8 @@
   body.try_emplace("supportsLoadedSourcesRequest", false);
   // The debug adapter supports sending progress reporting events.
   body.try_emplace("supportsProgressReporting", true);
+  // The debug adapter supports 'logMessage' in breakpoint.
+  body.try_emplace("supportsLogPoints", true);
 
   response.try_emplace("body", std::move(body));
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
@@ -2079,9 +2081,10 @@
   }
 }
 // At this point the breakpoint is new
-src_bp.SetBreakpoint(path.data());
-AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
-g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
+g_vsc.source_breakpoints[path][src_bp.line] = src_bp;
+SourceBreakpoint &new_bp = g_vsc.source_breakpoints[path][src_bp.line];
+new_bp.SetBreakpoint(path.data());
+AppendBreakpoint(new_bp.bp, response_breakpoints, path, new_bp.line);
   }
 }
   }
@@ -2304,10 +2307,11 @@
   // Any breakpoints that are left in "request_bps" are breakpoints that
   // need to be set.
   for (auto &pair : request_bps) {
-pair.second.SetBreakpoint();
 // Add this breakpoint info to the response
-AppendBreakpoint(pair.second.bp, response_breakpoints);
 g_vsc.function_breakpoints[pair.first()] = std::move(pair.second);
+FunctionBreakpoint &new_bp = g_vsc.function_breakpoints[pair.first()];
+new_bp.SetBreakpoint();
+AppendBreakpoint(new_bp.bp, response_breakpoints);
   }
 
   llvm::json::Object body;
Index: lldb/tools/lldb-vscode/SourceBreakpoint.cpp
===
--- lldb/tools/lldb-vscode/SourceBreakpoint.cpp
+++ lldb/tools/lldb-vscode/SourceBreakpoint.cpp
@@ -24,6 +24,8 @@
 SetCondition();
   if (!hitCondition.empty())
 SetHitCondition();
+  if (!logMessage.empty())
+SetLogMessage();
 }
 
 } // namespace lldb_vscode
Index: lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
===
--- lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
+++ lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
@@ -25,6 +25,8 @@
 SetCondition();
   if (!hitCondition.empty())
 SetHitCondition();
+  if (!logMessage.empty())
+SetLogMessage();
 }
 
 } // namespace lldb_vscode
Index: lldb/tools/lldb-vscode/BreakpointBase.h
===
--- lldb/tools/lldb-vscode/BreakpointBase.h
+++ lldb/tools/lldb-vscode/BreakpointBase.h
@@ -13,11 +13,16 @@
 #include "lldb/API/SBBreakpoint.h"
 #include "llvm/Support/JSON.h"
 #include 
+#include 
 
 namespace lldb_vscode {
 
 struct BreakpointBase {
-
+  // logMessage part can be either a raw text or an expression.
+  struct LogMessagePart {
+llvm::StringRef text;
+bool is_expr;
+  };
   // An optional expression for conditional breakpoints.
   std::string condition;
   // An optional expression that controls how many hits of the breakpoint are
@@ -27,6 +32,7 @@
   // (stop) but log the message instead. Expressions within {} are
   // interpolated.
   std::string logMessage;
+  std::vector logMessageParts;
   // The LLDB breakpoint associated wit this source breakpoint
   lldb::SBBreakpoint bp;
 
@@ -35,8 +41,12 @@
 
   void SetCondition();
   void SetHitCondition();
+  void SetLogMessage();
   void UpdateBreakpoint(const BreakpointBase &request_bp);
   static const char *GetBreakpointLabel();
+  static bool BreakpointHitCallback(void *baton, lldb::SBProcess &process,
+lldb::SBThread &thread,
+lldb::SBBreakpointLocation &location);
 };
 
 } // namespace lldb_vscode
Index: lldb/tools/lldb-vscode/BreakpointBase.cpp
===
--- lldb/tools/lldb-vscode/BreakpointBase.cpp
+++ lldb/tools/lldb-vscode/BreakpointBase.cpp

[Lldb-commits] [PATCH] D128107: [trace] Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-20 Thread Jakob Johnson via Phabricator via lldb-commits
jj10306 updated this revision to Diff 438449.
jj10306 marked 2 inline comments as done.
jj10306 added a comment.

rebase and use SBFileSpec constructor with that requires an explicit `resolve` 
flag before landing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128107

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBFileSpec.h
  lldb/include/lldb/API/SBTrace.h
  lldb/include/lldb/Target/Trace.h
  lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBTrace.cpp
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Target/Trace.cpp
  lldb/test/API/commands/trace/TestTraceLoad.py

Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -7,10 +7,11 @@
 class TestTraceLoad(TraceIntelPTTestCaseBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTrace(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -19,10 +20,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTraceWithStringNumbers(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_with_string_numbers.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_with_string_numbers.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -31,10 +33,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 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"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_missing_threads.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, 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",
@@ -43,10 +46,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadTrace(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-trace", "trace.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-trace", "trace.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 
 target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
@@ -88,11 +92,13 @@
   Errors:
 Number of TSC decoding errors: 0'''])
 
+@testSBAPIAndCommands
 def testLoadInvalidTraces(self):
 src_dir = self.getSourceDir()
+
 # We test first an invalid type
-self.expect("trace load -v " + os.path.join(src_dir, "intelpt-trace", "trace_bad.json"), error=True,
-  substrs=['''error: expected object at traceSession.processes[0]
+trace_description_file_path = os.path.join(src_dir, "intelpt-trace", "trace_bad.json")
+expected

[Lldb-commits] [PATCH] D128107: [trace] Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-20 Thread Jakob Johnson via Phabricator via lldb-commits
jj10306 added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py:139
+if self.USE_SB_API:
+traceDescriptionFile = lldb.SBFileSpec(traceDescriptionFilePath)
+loadTraceError = lldb.SBError()

wallace wrote:
> jj10306 wrote:
> > the single arg constructor is deprecated, update this to pass `resolve` flag
> i don't think it's deprecated, but you should pass the resolve flag anyone
You can find the deprecation warning in the comments here:
https://lldb.llvm.org/cpp_reference/SBFileSpec_8cpp_source.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128107

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


[Lldb-commits] [lldb] 5413bf1 - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-06-20T11:33:56-07:00
New Revision: 5413bf1bac2abb9e06901686cdc959e92940143a

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/SemanticSelection.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/pseudo/lib/DirectiveTree.cpp
clang-tools-extra/pseudo/lib/Forest.cpp
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/lib/Lex/PPDirectives.cpp
clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
flang/include/flang/Lower/IterationSpace.h
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/IO.cpp
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
flang/lib/Optimizer/Support/InternalNames.cpp
lld/COFF/Driver.cpp
lld/ELF/Driver.cpp
lld/ELF/InputFiles.cpp
lld/ELF/LinkerScript.cpp
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
lld/wasm/Writer.cpp
lldb/source/Breakpoint/BreakpointIDList.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Utility/SelectHelper.cpp
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp
llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Target/Mips/MipsTargetStreamer.h
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
mlir/lib/Analysis/Presburger/Simplex.cpp
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
mlir/lib/Dialect/Affine/Utils/Utils.cpp

mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
mlir/lib/Tools/lsp-server-support/Protocol.cpp
mlir/test/lib/IR/TestSymbolUses.cpp
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
index b107dd7385c65..6c5d86a69821b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
@@ -53,7 +53,7 @@ void ClangTidyProfiling::printAsJSON(llvm::raw_ostream &OS) {
 }
 
 void ClangTidyProfiling::storeProfileData() {
-  assert(Storage.hasValue() && "We should have a filename.");
+  assert(Storage && "We should have a filename.");
 
   llvm::SmallString<256> OutputDirectory(Storage->StoreFilename);
   llvm::sys::path::remove_filename(OutputDirectory);
@@ -80,7 +80,7 @@ 
ClangTidyProfiling::ClangTidyProfiling(llvm::Optional Storage)
 ClangTidyProfiling::~ClangTidyProfiling() {
   TG.emplace("clang-tidy", "clang-tidy checks profiling", Records);
 
-  if (!Storage.hasValue())
+  if (!Storage)
 printUserFriendlyTable(llvm::errs());
   else
 storeProfileData();

diff  --git

[Lldb-commits] [PATCH] D128107: [trace] Add LoadTraceFromFile to SBDebugger and SBTrace

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



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py:139
+if self.USE_SB_API:
+traceDescriptionFile = lldb.SBFileSpec(traceDescriptionFilePath)
+loadTraceError = lldb.SBError()

jj10306 wrote:
> wallace wrote:
> > jj10306 wrote:
> > > the single arg constructor is deprecated, update this to pass `resolve` 
> > > flag
> > i don't think it's deprecated, but you should pass the resolve flag anyone
> You can find the deprecation warning in the comments here:
> https://lldb.llvm.org/cpp_reference/SBFileSpec_8cpp_source.html
TIL!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128107

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


[Lldb-commits] [lldb] ad7ce1e - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-06-20T11:49:10-07:00
New Revision: ad7ce1e7696148d093b96a6262ebc8fd5e216187

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Driver/Driver.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/TreeTransform.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/Remarks/YAMLRemarkSerializer.cpp
llvm/lib/Target/MSP430/MSP430TargetMachine.cpp
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
mlir/lib/Analysis/IntRangeAnalysis.cpp
mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 938db2a887c59..a7de87b552d28 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1529,10 +1529,7 @@ class CodeGenFunction : public CodeGenTypeCache {
 
   /// Get the profiler's count for the given statement.
   uint64_t getProfileCount(const Stmt *S) {
-Optional Count = PGO.getStmtCount(S);
-if (!Count.hasValue())
-  return 0;
-return *Count;
+return PGO.getStmtCount(S).value_or(0);
   }
 
   /// Set the profiler's current count.

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index cbde26668b78c..167c726c53919 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3282,8 +3282,7 @@ class OffloadingActionBuilder final {
   DDep, CudaDeviceActions[I]->getType());
 }
 
-if (!CompileDeviceOnly || !BundleOutput.hasValue() ||
-BundleOutput.getValue()) {
+if (!CompileDeviceOnly || !BundleOutput || *BundleOutput) {
   // Create HIP fat binary with a special "link" action.
   CudaFatBinary = C.MakeAction(CudaDeviceActions,
   types::TY_HIP_FATBIN);
@@ -3383,8 +3382,7 @@ class OffloadingActionBuilder final {
   // in a fat binary for mixed host-device compilation. For device-only
   // compilation, creates a fat binary.
   OffloadAction::DeviceDependences DDeps;
-  if (!CompileDeviceOnly || !BundleOutput.hasValue() ||
-  BundleOutput.getValue()) {
+  if (!CompileDeviceOnly || !BundleOutput || *BundleOutput) {
 auto *TopDeviceLinkAction = C.MakeAction(
 Actions,
 CompileDeviceOnly ? types::TY_HIP_FATBIN : types::TY_Object);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 62478e7129695..8e59c449ae656 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1996,8 +1996,7 @@ 
TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
   TransRetReq.emplace(TPL);
 }
   }
-  assert(TransRetReq.hasValue() &&
- "All code paths leading here must set TransRetReq");
+  assert(TransRetReq && "All code paths leading here must set TransRetReq");
   if (Expr *E = TransExpr.dyn_cast())
 return RebuildExprRequirement(E, Req->isSimple(), Req->getNoexceptLoc(),
   std::move(*TransRetReq));

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 03f147480421a..ef09352551044 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -12634,8 +12634,7 @@ 
TreeTransform::TransformExprRequirement(concepts::ExprRequirement *Req)
   return nullptr;
 TransRetReq.emplace(TPL);
   }
-  assert(TransRetReq.hasValue() &&
- "All code paths leading here must set TransRetReq");
+  assert(TransRetReq && "All code paths leading here must set TransRetReq");
   if (Expr *E = TransExpr.dyn_cast())
 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
Req->getNoexceptLoc(),

diff  --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index 58e581fce728d..16d84fb01f610 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -698,8 +698,7 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark 
&bookmark,
 
   LineIterator It(*m_objfile_sp, Record::StackWin

[Lldb-commits] [lldb] 50f9367 - Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-20 Thread Jakob Johnson via lldb-commits

Author: Jakob Johnson
Date: 2022-06-20T11:54:47-07:00
New Revision: 50f9367960725b450a9ef779d73e32a35031ee70

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

LOG: Add LoadTraceFromFile to SBDebugger and SBTrace

Add trace load functionality to SBDebugger via the `LoadTraceFromFile` method.
Update intelpt test case class to have `testTraceLoad` method so we can take 
advantage of
the testApiAndSB decorator to test both the CLI and SB without duplicating code.

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

Added: 


Modified: 
lldb/bindings/interface/SBDebugger.i
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/API/SBFileSpec.h
lldb/include/lldb/API/SBTrace.h
lldb/include/lldb/Target/Trace.h
lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py
lldb/source/API/SBDebugger.cpp
lldb/source/API/SBTrace.cpp
lldb/source/Commands/CommandObjectTrace.cpp
lldb/source/Target/Trace.cpp
lldb/test/API/commands/trace/TestTraceLoad.py

Removed: 




diff  --git a/lldb/bindings/interface/SBDebugger.i 
b/lldb/bindings/interface/SBDebugger.i
index 2239f049c6514..5d51a6ac20d2f 100644
--- a/lldb/bindings/interface/SBDebugger.i
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -542,6 +542,8 @@ Example: ::
 lldb::SBError
 RunREPL (lldb::LanguageType language, const char *repl_options);
 
+SBTrace LoadTraceFromFile(SBError &error, const SBFileSpec 
&trace_description_file);
+
 #ifdef SWIGPYTHON
 %pythoncode%{
 def __iter__(self):

diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 6a23077175b92..b9a9b593d0ad4 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -391,6 +391,17 @@ class LLDB_API SBDebugger {
 
   SBError RunREPL(lldb::LanguageType language, const char *repl_options);
 
+  /// Load a trace from a trace description file and create Targets,
+  /// Processes and Threads based on the contents of such file.
+  ///
+  /// \param[out] error
+  ///   An error if the trace could not be created.
+  ///
+  /// \param[in] trace_description_file
+  ///   The file containing the necessary information to load the trace.
+  SBTrace LoadTraceFromFile(SBError &error,
+const SBFileSpec &trace_description_file);
+
 private:
   friend class SBCommandInterpreter;
   friend class SBInputReader;
@@ -398,6 +409,7 @@ class LLDB_API SBDebugger {
   friend class SBProcess;
   friend class SBSourceManager;
   friend class SBTarget;
+  friend class SBTrace;
 
   lldb::SBTarget FindTargetWithLLDBProcess(const lldb::ProcessSP &processSP);
 

diff  --git a/lldb/include/lldb/API/SBFileSpec.h 
b/lldb/include/lldb/API/SBFileSpec.h
index a2f02ac78208b..a286912f109e5 100644
--- a/lldb/include/lldb/API/SBFileSpec.h
+++ b/lldb/include/lldb/API/SBFileSpec.h
@@ -74,6 +74,7 @@ class LLDB_API SBFileSpec {
   friend class SBSourceManager;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBTrace;
 
   SBFileSpec(const lldb_private::FileSpec &fspec);
 

diff  --git a/lldb/include/lldb/API/SBTrace.h b/lldb/include/lldb/API/SBTrace.h
index 1685caaf4efa3..d5cf30f56637f 100644
--- a/lldb/include/lldb/API/SBTrace.h
+++ b/lldb/include/lldb/API/SBTrace.h
@@ -12,8 +12,6 @@
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBError.h"
 
-class TraceImpl;
-
 namespace lldb {
 
 class LLDB_API SBTrace {
@@ -23,6 +21,10 @@ class LLDB_API SBTrace {
 
   SBTrace(const lldb::TraceSP &trace_sp);
 
+  /// See SBDebugger::LoadTraceFromFile.
+  static SBTrace LoadTraceFromFile(SBError &error, SBDebugger &debugger,
+   const SBFileSpec &trace_description_file);
+
   /// \return
   /// A description of the parameters to use for the \a SBTrace::Start
   /// method, or \b null if the object is invalid.

diff  --git a/lldb/include/lldb/Target/Trace.h 
b/lldb/include/lldb/Target/Trace.h
index 2fee3c9274959..216394bdd1847 100644
--- a/lldb/include/lldb/Target/Trace.h
+++ b/lldb/include/lldb/Target/Trace.h
@@ -137,6 +137,23 @@ class Trace : public PluginInterface,
   static llvm::Expected
   FindPluginSchema(llvm::StringRef plugin_name);
 
+  /// Load a trace from a trace description file and create Targets,
+  /// Processes and Threads based on the contents of such file.
+  ///
+  /// \param[in] debugger
+  /// The debugger instance where new Targets will be created as part of 
the
+  /// JSON data parsing.
+  ///
+  /// \param[in] trace_description_file
+  ///   The file containing the necessary information to load the trace.
+  ///
+  /// \return
+  /// A \a TraceSP instance, or an \a llvm::Error if loading the trace
+  /// fails.
+  static llvm::Expected
+  LoadPostMortemTraceFromFile(Debu

[Lldb-commits] [PATCH] D128107: [trace] Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-20 Thread Jakob Johnson via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50f936796072: Add LoadTraceFromFile to SBDebugger and 
SBTrace (authored by jj10306).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128107

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBFileSpec.h
  lldb/include/lldb/API/SBTrace.h
  lldb/include/lldb/Target/Trace.h
  lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBTrace.cpp
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Target/Trace.cpp
  lldb/test/API/commands/trace/TestTraceLoad.py

Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -7,10 +7,11 @@
 class TestTraceLoad(TraceIntelPTTestCaseBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTrace(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -19,10 +20,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTraceWithStringNumbers(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_with_string_numbers.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_with_string_numbers.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -31,10 +33,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 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"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_missing_threads.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, 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",
@@ -43,10 +46,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadTrace(self):
 src_dir = self.getSourceDir()
-trace_definition_file = os.path.join(src_dir, "intelpt-trace", "trace.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+trace_description_file_path = os.path.join(src_dir, "intelpt-trace", "trace.json")
+self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 
 target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
@@ -88,11 +92,13 @@
   Errors:
 Number of TSC decoding errors: 0'''])
 
+@testSBAPIAndCommands
 def testLoadInvalidTraces(self):
 src_dir = self.getSourceDir()
+
 # We test first an invalid type
-self.expect("trace load -v " + os.path.join(src_dir, "intelpt-trace", "trace_bad.json"), error=True,
-  substrs=['''error: expected object at traceSession.processes[0]
+trace_description_file_path = os.path.join(src_dir, "intelpt-trace", "trace_bad.json")
+expected_substrs = ['''error: expected objec

[Lldb-commits] [PATCH] D128126: Support expressions in the context of a reference

2022-06-20 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay updated this revision to Diff 438454.
emrekultursay added a comment.

Use loop instead of code duplication in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128126

Files:
  lldb/source/Expression/UserExpression.cpp
  lldb/test/API/commands/expression/context-object/TestContextObject.py
  lldb/test/API/commands/expression/context-object/main.cpp

Index: lldb/test/API/commands/expression/context-object/main.cpp
===
--- lldb/test/API/commands/expression/context-object/main.cpp
+++ lldb/test/API/commands/expression/context-object/main.cpp
@@ -31,6 +31,9 @@
   cpp_namespace::CppStruct cpp_struct = cpp_namespace::GetCppStruct();
   cpp_struct.function();
 
+  cpp_namespace::CppStruct& cpp_struct_ref = cpp_struct;
+  cpp_struct_ref.function();
+
   int field = ;
 
   cpp_namespace::CppUnion cpp_union;
Index: lldb/test/API/commands/expression/context-object/TestContextObject.py
===
--- lldb/test/API/commands/expression/context-object/TestContextObject.py
+++ lldb/test/API/commands/expression/context-object/TestContextObject.py
@@ -16,34 +16,34 @@
 frame = thread.GetFrameAtIndex(0)
 
 #
-# Test C++ struct variable
+# Test C++ struct variable and reference-to-struct variable
 #
-
-obj_val = frame.FindVariable("cpp_struct")
-self.assertTrue(obj_val.IsValid())
-
-# Test an empty expression evaluation
-value = obj_val.EvaluateExpression("")
-self.assertFalse(value.IsValid())
-self.assertFalse(value.GetError().Success())
-
-# Test retrieveing of a field (not a local with the same name)
-value = obj_val.EvaluateExpression("field")
-self.assertTrue(value.IsValid())
-self.assertSuccess(value.GetError())
-self.assertEqual(value.GetValueAsSigned(), )
-
-# Test functions evaluation
-value = obj_val.EvaluateExpression("function()")
-self.assertTrue(value.IsValid())
-self.assertSuccess(value.GetError())
-self.assertEqual(value.GetValueAsSigned(), )
-
-# Test that we retrieve the right global
-value = obj_val.EvaluateExpression("global.field")
-self.assertTrue(value.IsValid())
-self.assertSuccess(value.GetError())
-self.assertEqual(value.GetValueAsSigned(), )
+for obj in "cpp_struct", "cpp_struct_ref":
+obj_val = frame.FindVariable(obj)
+self.assertTrue(obj_val.IsValid())
+
+# Test an empty expression evaluation
+value = obj_val.EvaluateExpression("")
+self.assertFalse(value.IsValid())
+self.assertFalse(value.GetError().Success())
+
+# Test retrieveing of a field (not a local with the same name)
+value = obj_val.EvaluateExpression("field")
+self.assertTrue(value.IsValid())
+self.assertSuccess(value.GetError())
+self.assertEqual(value.GetValueAsSigned(), )
+
+# Test functions evaluation
+value = obj_val.EvaluateExpression("function()")
+self.assertTrue(value.IsValid())
+self.assertSuccess(value.GetError())
+self.assertEqual(value.GetValueAsSigned(), )
+
+# Test that we retrieve the right global
+value = obj_val.EvaluateExpression("global.field")
+self.assertTrue(value.IsValid())
+self.assertSuccess(value.GetError())
+self.assertEqual(value.GetValueAsSigned(), )
 
 #
 # Test C++ union variable
Index: lldb/source/Expression/UserExpression.cpp
===
--- lldb/source/Expression/UserExpression.cpp
+++ lldb/source/Expression/UserExpression.cpp
@@ -145,8 +145,9 @@
   Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
 
   if (ctx_obj) {
-static unsigned const ctx_type_mask =
-lldb::TypeFlags::eTypeIsClass | lldb::TypeFlags::eTypeIsStructUnion;
+static unsigned const ctx_type_mask = lldb::TypeFlags::eTypeIsClass |
+  lldb::TypeFlags::eTypeIsStructUnion |
+  lldb::TypeFlags::eTypeIsReference;
 if (!(ctx_obj->GetTypeInfo() & ctx_type_mask)) {
   LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a context object of "
 "an invalid type, can't run expressions.");
@@ -155,6 +156,19 @@
 }
   }
 
+  if (ctx_obj && ctx_obj->GetTypeInfo() & lldb::TypeFlags::eTypeIsReference) {
+Status error;
+lldb::ValueObjectSP deref_ctx_sp = ctx_obj->Dereference(error);
+if (!error.Success()) {
+  LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a context object of "
+"a reference type that can't be

[Lldb-commits] [PATCH] D128126: Support expressions in the context of a reference

2022-06-20 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay marked an inline comment as done.
emrekultursay added a comment.

Thanks. Please submit the change on my behalf.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128126

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


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

2022-06-20 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added reviewers: labath, aleksandr.urakov.
omjavaid added a project: LLDB.
Herald added subscribers: JDevlieghere, kristof.beyls.
Herald added a project: All.
omjavaid requested review of this revision.

This patch writes a mapping structure for converting  CodeView Arm64 register 
numbers to LLDB Arm64 regnums.

This fixes various symbols and variable location test failures on 
AArch64/Windows.


https://reviews.llvm.org/D128221

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp

Index: lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
@@ -10,10 +10,196 @@
 
 #include "lldb/lldb-defines.h"
 
+#include "Plugins/Process/Utility/lldb-arm64-register-enums.h"
 #include "Plugins/Process/Utility/lldb-x86-register-enums.h"
 
 using namespace lldb_private;
 
+static const uint32_t g_code_view_to_lldb_registers_arm64[] = {
+LLDB_INVALID_REGNUM, // NONE
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+gpr_w0_arm64,  // ARM64_W0, 10)
+gpr_w1_arm64,  // ARM64_W1, 11)
+gpr_w2_arm64,  // ARM64_W2, 12)
+gpr_w3_arm64,  // ARM64_W3, 13)
+gpr_w4_arm64,  // ARM64_W4, 14)
+gpr_w5_arm64,  // ARM64_W5, 15)
+gpr_w6_arm64,  // ARM64_W6, 16)
+gpr_w7_arm64,  // ARM64_W7, 17)
+gpr_w8_arm64,  // ARM64_W8, 18)
+gpr_w9_arm64,  // ARM64_W9, 19)
+gpr_w10_arm64, // ARM64_W10, 20)
+gpr_w11_arm64, // ARM64_W11, 21)
+gpr_w12_arm64, // ARM64_W12, 22)
+gpr_w13_arm64, // ARM64_W13, 23)
+gpr_w14_arm64, // ARM64_W14, 24)
+gpr_w15_arm64, // ARM64_W15, 25)
+gpr_w16_arm64, // ARM64_W16, 26)
+gpr_w17_arm64, // ARM64_W17, 27)
+gpr_w18_arm64, // ARM64_W18, 28)
+gpr_w19_arm64, // ARM64_W19, 29)
+gpr_w20_arm64, // ARM64_W20, 30)
+gpr_w21_arm64, // ARM64_W21, 31)
+gpr_w22_arm64, // ARM64_W22, 32)
+gpr_w23_arm64, // ARM64_W23, 33)
+gpr_w24_arm64, // ARM64_W24, 34)
+gpr_w25_arm64, // ARM64_W25, 35)
+gpr_w26_arm64, // ARM64_W26, 36)
+gpr_w27_arm64, // ARM64_W27, 37)
+gpr_w28_arm64, // ARM64_W28, 38)
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+gpr_x0_arm64,  // ARM64_X0, 50)
+gpr_x1_arm64,  // ARM64_X1, 51)
+gpr_x2_arm64,  // ARM64_X2, 52)
+gpr_x3_arm64,  // ARM64_X3, 53)
+gpr_x4_arm64,  // ARM64_X4, 54)
+gpr_x5_arm64,  // ARM64_X5, 55)
+gpr_x6_arm64,  // ARM64_X6, 56)
+gpr_x7_arm64,  // ARM64_X7, 57)
+gpr_x8_arm64,  // ARM64_X8, 58)
+gpr_x9_arm64,  // ARM64_X9, 59)
+gpr_x10_arm64, // ARM64_X10, 60)
+gpr_x11_arm64, // ARM64_X11, 61)
+gpr_x12_arm64, // ARM64_X12, 62)
+gpr_x13_arm64, // ARM64_X13, 63)
+gpr_x14_arm64, // ARM64_X14, 64)
+gpr_x15_arm64, // ARM64_X15, 65)
+gpr_x16_arm64, // ARM64_X16, 66)
+gpr_x17_arm64, // ARM64_X17, 67)
+gpr_x18_arm64, // ARM64_X18, 68)
+gpr_x19_arm64, // ARM64_X19, 69)
+gpr_x20_arm64, // ARM64_X20, 70)
+gpr_x21_arm64, // ARM64_X21, 71)
+gpr_x22_arm64, // ARM64_X22, 72)
+gpr_x23_arm64, // ARM64_X23, 73)
+gpr_x24_arm64, // ARM64_X24, 74)
+gpr_x25_arm64, // ARM64_X25, 75)
+gpr_x26_arm64, // ARM64_X26, 76)
+gpr_x27_arm64, // ARM64_X27, 77)
+gpr_x28_arm64, // ARM64_X28, 78)
+gpr_fp_arm64,  // ARM64_FP, 79)
+gpr_lr_arm64,  // ARM64_LR, 80)
+gpr_sp_arm64,  // ARM64_SP, 81)
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+gpr_cpsr_arm64, // ARM64_NZCV, 90)
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+fpu_s0_arm64,  // (ARM64_S0, 100)
+fpu_s1_arm64,  // (ARM64_S1, 101)
+fpu_s2_arm64,  // (ARM64_S2, 102)
+fpu_s3_arm64,  // (ARM64_S3, 103)
+fpu_s4_arm64,  // (ARM64_S4, 104)
+fpu_s5_arm64,  // (ARM64_S5, 105)
+fpu_s6_arm64,  // (ARM64_S6, 106)
+fpu_s7_arm64,  // (ARM64_S7, 107)
+fpu_s8_arm64,  // (ARM64_S8, 108)
+fpu_s9_arm64,  // (ARM64_S9, 109)
+fpu_s10_arm64, // (ARM64_S10, 110)
+fpu_s11_arm64, // (ARM64_S11, 111)
+fpu_s12_arm64, // (ARM64_S12, 112)
+fpu_s13_arm64, // (ARM64_S13, 113)
+fpu_s14_arm64, // (ARM64_S14, 114)
+fpu_s15_arm64, // (ARM64_S15, 115)
+fpu_s16_arm64, // (ARM64_

[Lldb-commits] [PATCH] D127456: [trace][intelpt] Support system-wide tracing [17] - Some improvements

2022-06-20 Thread Max Kudryavtsev via Phabricator via lldb-commits
max-kudr added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:55-59
+Expected>
 IntelPTPerThreadProcessTrace::Start(const TraceIntelPTStartRequest &request,
 ArrayRef current_tids) {
-  IntelPTProcessTraceUP trace(new IntelPTPerThreadProcessTrace(request));
+  std::unique_ptr trace(
+  new IntelPTPerThreadProcessTrace(request));

@wallace, @jj10306

We are getting build errors here on CentOS/GNU 7.3.1:

```
/llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:
 In static member function 'static 
llvm::Expected
 > lldb_private::process_linux::IntelPTPerThreadProcessTrace::Start(const 
lldb_private::TraceIntelPTStartRequest&, llvm::ArrayRef)':
/llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:65:10:
 error: could not convert 'trace' from 
'std::unique_ptr' to 
'llvm::Expected
 >'
   return trace;
  ^
```

Can you please fix this?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127456

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


[Lldb-commits] [PATCH] D127456: [trace][intelpt] Support system-wide tracing [17] - Some improvements

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



Comment at: 
lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:55-59
+Expected>
 IntelPTPerThreadProcessTrace::Start(const TraceIntelPTStartRequest &request,
 ArrayRef current_tids) {
-  IntelPTProcessTraceUP trace(new IntelPTPerThreadProcessTrace(request));
+  std::unique_ptr trace(
+  new IntelPTPerThreadProcessTrace(request));

max-kudr wrote:
> @wallace, @jj10306
> 
> We are getting build errors here on CentOS/GNU 7.3.1:
> 
> ```
> /llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:
>  In static member function 'static 
> llvm::Expected
>  > lldb_private::process_linux::IntelPTPerThreadProcessTrace::Start(const 
> lldb_private::TraceIntelPTStartRequest&, llvm::ArrayRef)':
> /llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:65:10:
>  error: could not convert 'trace' from 
> 'std::unique_ptr' 
> to 
> 'llvm::Expected
>  >'
>return trace;
>   ^
> ```
> 
> Can you please fix this?
> 
Hi Max, I'm aware of this issue because it was reported by someone else. Sadly 
I wasn't able to install that toolchain on my centos machine (I don't manage 
it) so I can't reproduce the issue to make sure I can fix it. This issue 
doesn't happen with other toolchains.

So, I would like to ask for your help to try to fix it. I think the fix might 
be something as simple as doing

return std::move(trace)
or perhaps something like

return 
Expected>(std::move(trace));
At this point I can only rely on you to make sure this is properly fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127456

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


[Lldb-commits] [PATCH] D128226: [lldb] Remove an outdated comment. NFC.

2022-06-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, DavidSpickett, omjavaid, alvinhochun.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLDB.

This comment became outdated in 053eb35651906e693906fad6c695fce11415ade7
(but was moved along); that commit moved the code and the comment
to a separate function, with a separate local variable
`num_of_bytes_read`. On error, the possibly garbage value is never
copied back to the caller's reference, thus the comment is no longer
relevant (and slightly confusing as is).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128226

Files:
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp


Index: lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -281,10 +281,6 @@
   SIZE_T num_of_bytes_read = 0;
   if (!::ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr,
buf, size, &num_of_bytes_read)) {
-// Reading from the process can fail for a number of reasons - set the
-// error code and make sure that the number of bytes read is set back to 0
-// because in some scenarios the value of bytes_read returned from the API
-// is garbage.
 error.SetError(GetLastError(), eErrorTypeWin32);
 LLDB_LOG(log, "reading failed with error: {0}", error);
   } else {


Index: lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -281,10 +281,6 @@
   SIZE_T num_of_bytes_read = 0;
   if (!::ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr,
buf, size, &num_of_bytes_read)) {
-// Reading from the process can fail for a number of reasons - set the
-// error code and make sure that the number of bytes read is set back to 0
-// because in some scenarios the value of bytes_read returned from the API
-// is garbage.
 error.SetError(GetLastError(), eErrorTypeWin32);
 LLDB_LOG(log, "reading failed with error: {0}", error);
   } else {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D127456: [trace][intelpt] Support system-wide tracing [17] - Some improvements

2022-06-20 Thread Max Kudryavtsev via Phabricator via lldb-commits
max-kudr added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:55-59
+Expected>
 IntelPTPerThreadProcessTrace::Start(const TraceIntelPTStartRequest &request,
 ArrayRef current_tids) {
-  IntelPTProcessTraceUP trace(new IntelPTPerThreadProcessTrace(request));
+  std::unique_ptr trace(
+  new IntelPTPerThreadProcessTrace(request));

wallace wrote:
> max-kudr wrote:
> > @wallace, @jj10306
> > 
> > We are getting build errors here on CentOS/GNU 7.3.1:
> > 
> > ```
> > /llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:
> >  In static member function 'static 
> > llvm::Expected
> >  > lldb_private::process_linux::IntelPTPerThreadProcessTrace::Start(const 
> > lldb_private::TraceIntelPTStartRequest&, llvm::ArrayRef > int>)':
> > /llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:65:10:
> >  error: could not convert 'trace' from 
> > 'std::unique_ptr'
> >  to 
> > 'llvm::Expected
> >  >'
> >return trace;
> >   ^
> > ```
> > 
> > Can you please fix this?
> > 
> Hi Max, I'm aware of this issue because it was reported by someone else. 
> Sadly I wasn't able to install that toolchain on my centos machine (I don't 
> manage it) so I can't reproduce the issue to make sure I can fix it. This 
> issue doesn't happen with other toolchains.
> 
> So, I would like to ask for your help to try to fix it. I think the fix might 
> be something as simple as doing
> 
> return std::move(trace)
> or perhaps something like
> 
> return 
> Expected>(std::move(trace));
> At this point I can only rely on you to make sure this is properly fixed
Hi Walter (@wallace),

Thank you for following up and proposing fix. I checked and confirm that the 
code below fixes the issue

```
return std::move(trace)
```

Would you please push this fix to the repository? Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127456

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


[Lldb-commits] [PATCH] D127456: [trace][intelpt] Support system-wide tracing [17] - Some improvements

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



Comment at: 
lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:55-59
+Expected>
 IntelPTPerThreadProcessTrace::Start(const TraceIntelPTStartRequest &request,
 ArrayRef current_tids) {
-  IntelPTProcessTraceUP trace(new IntelPTPerThreadProcessTrace(request));
+  std::unique_ptr trace(
+  new IntelPTPerThreadProcessTrace(request));

max-kudr wrote:
> wallace wrote:
> > max-kudr wrote:
> > > @wallace, @jj10306
> > > 
> > > We are getting build errors here on CentOS/GNU 7.3.1:
> > > 
> > > ```
> > > /llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:
> > >  In static member function 'static 
> > > llvm::Expected
> > >  > lldb_private::process_linux::IntelPTPerThreadProcessTrace::Start(const 
> > > lldb_private::TraceIntelPTStartRequest&, llvm::ArrayRef > > int>)':
> > > /llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:65:10:
> > >  error: could not convert 'trace' from 
> > > 'std::unique_ptr'
> > >  to 
> > > 'llvm::Expected
> > >  >'
> > >return trace;
> > >   ^
> > > ```
> > > 
> > > Can you please fix this?
> > > 
> > Hi Max, I'm aware of this issue because it was reported by someone else. 
> > Sadly I wasn't able to install that toolchain on my centos machine (I don't 
> > manage it) so I can't reproduce the issue to make sure I can fix it. This 
> > issue doesn't happen with other toolchains.
> > 
> > So, I would like to ask for your help to try to fix it. I think the fix 
> > might be something as simple as doing
> > 
> > return std::move(trace)
> > or perhaps something like
> > 
> > return 
> > Expected>(std::move(trace));
> > At this point I can only rely on you to make sure this is properly fixed
> Hi Walter (@wallace),
> 
> Thank you for following up and proposing fix. I checked and confirm that the 
> code below fixes the issue
> 
> ```
> return std::move(trace)
> ```
> 
> Would you please push this fix to the repository? Thank you!
nice! I will do so now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127456

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


[Lldb-commits] [lldb] c9fc433 - [lldb] Fix building with GCC 7

2022-06-20 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2022-06-21T00:19:09+03:00
New Revision: c9fc4336d4b35cd1ed8083336c997c159f286794

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

LOG: [lldb] Fix building with GCC 7

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp 
b/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp
index 7183b213e340f..9e486c15b5302 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp
@@ -62,5 +62,5 @@ IntelPTPerThreadProcessTrace::Start(const 
TraceIntelPTStartRequest &request,
 error = joinErrors(std::move(error), trace->TraceStart(tid));
   if (error)
 return std::move(error);
-  return trace;
+  return std::move(trace);
 }



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


[Lldb-commits] [lldb] 8c6e138 - Support logpoints in lldb-vscode

2022-06-20 Thread Jeffrey Tan via lldb-commits

Author: Jeffrey Tan
Date: 2022-06-20T16:22:12-07:00
New Revision: 8c6e138aa893bb88fc3d5d449e42082741f0e2a2

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

LOG: Support logpoints in lldb-vscode

This patch implements VSCode DAP logpoints feature (also called tracepoint
in other VS debugger).
This will provide a convenient way for user to do printf style logging
debugging without pausing debuggee.

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

Added: 
lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_logpoints.py

Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp
lldb/tools/lldb-vscode/BreakpointBase.cpp
lldb/tools/lldb-vscode/BreakpointBase.h
lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
lldb/tools/lldb-vscode/SourceBreakpoint.cpp
lldb/tools/lldb-vscode/lldb-vscode.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index b0fb17ffa9719..90d90d959592d 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -22,13 +22,15 @@ def build_and_create_debug_adaptor(self, 
lldbVSCodeEnv=None):
 self.build()
 self.create_debug_adaptor(lldbVSCodeEnv)
 
-def set_source_breakpoints(self, source_path, lines, condition=None,
-   hitCondition=None):
+def set_source_breakpoints(self, source_path, lines, data=None):
 '''Sets source breakpoints and returns an array of strings containing
the breakpoint IDs ("1", "2") for each breakpoint that was set.
+   Parameter data is array of data objects for breakpoints.
+   Each object in data is 1:1 mapping with the entry in lines.
+   It contains optional location/hitCondition/logMessage parameters.
 '''
 response = self.vscode.request_setBreakpoints(
-source_path, lines, condition=condition, hitCondition=hitCondition)
+source_path, lines, data)
 if response is None:
 return []
 breakpoints = response['body']['breakpoints']

diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 603b1545cd714..8a871732f7a61 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -750,8 +750,11 @@ def request_scopes(self, frameId):
 }
 return self.send_recv(command_dict)
 
-def request_setBreakpoints(self, file_path, line_array, condition=None,
-   hitCondition=None):
+def request_setBreakpoints(self, file_path, line_array, data=None):
+''' data is array of parameters for breakpoints in line_array.
+Each parameter object is 1:1 mapping with entries in line_entry.
+It contains optional location/hitCondition/logMessage parameters.
+'''
 (dir, base) = os.path.split(file_path)
 source_dict = {
 'name': base,
@@ -764,12 +767,18 @@ def request_setBreakpoints(self, file_path, line_array, 
condition=None,
 if line_array is not None:
 args_dict['lines'] = '%s' % line_array
 breakpoints = []
-for line in line_array:
+for i, line in enumerate(line_array):
+breakpoint_data = None
+if data is not None and i < len(data):
+breakpoint_data = data[i]
 bp = {'line': line}
-if condition is not None:
-bp['condition'] = condition
-if hitCondition is not None:
-bp['hitCondition'] = hitCondition
+if breakpoint_data is not None:
+if 'condition' in breakpoint_data and 
breakpoint_data['condition']:
+bp['condition'] = breakpoint_data['condition']
+if 'hitCondition' in breakpoint_data and 
breakpoint_data['hitCondition']:
+bp['hitCondition'] = breakpoint_data['hitCondition']
+if 'logMessage' in breakpoint_data and 
breakpoint_data['logMessage']:
+bp['logMessage'] = breakpoint_data['logMessage']
 breakpoints.append(bp)
 args_dict['breakpoints'] = 

[Lldb-commits] [PATCH] D127702: Support logpoints in lldb-vscode

2022-06-20 Thread jeffrey tan via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c6e138aa893: Support logpoints in lldb-vscode (authored by 
yinghuitan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127702

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_logpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
  lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp
  lldb/tools/lldb-vscode/BreakpointBase.cpp
  lldb/tools/lldb-vscode/BreakpointBase.h
  lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
  lldb/tools/lldb-vscode/SourceBreakpoint.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1532,6 +1532,8 @@
   body.try_emplace("supportsLoadedSourcesRequest", false);
   // The debug adapter supports sending progress reporting events.
   body.try_emplace("supportsProgressReporting", true);
+  // The debug adapter supports 'logMessage' in breakpoint.
+  body.try_emplace("supportsLogPoints", true);
 
   response.try_emplace("body", std::move(body));
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
@@ -2079,9 +2081,10 @@
   }
 }
 // At this point the breakpoint is new
-src_bp.SetBreakpoint(path.data());
-AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
-g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
+g_vsc.source_breakpoints[path][src_bp.line] = src_bp;
+SourceBreakpoint &new_bp = g_vsc.source_breakpoints[path][src_bp.line];
+new_bp.SetBreakpoint(path.data());
+AppendBreakpoint(new_bp.bp, response_breakpoints, path, new_bp.line);
   }
 }
   }
@@ -2304,10 +2307,11 @@
   // Any breakpoints that are left in "request_bps" are breakpoints that
   // need to be set.
   for (auto &pair : request_bps) {
-pair.second.SetBreakpoint();
 // Add this breakpoint info to the response
-AppendBreakpoint(pair.second.bp, response_breakpoints);
 g_vsc.function_breakpoints[pair.first()] = std::move(pair.second);
+FunctionBreakpoint &new_bp = g_vsc.function_breakpoints[pair.first()];
+new_bp.SetBreakpoint();
+AppendBreakpoint(new_bp.bp, response_breakpoints);
   }
 
   llvm::json::Object body;
Index: lldb/tools/lldb-vscode/SourceBreakpoint.cpp
===
--- lldb/tools/lldb-vscode/SourceBreakpoint.cpp
+++ lldb/tools/lldb-vscode/SourceBreakpoint.cpp
@@ -24,6 +24,8 @@
 SetCondition();
   if (!hitCondition.empty())
 SetHitCondition();
+  if (!logMessage.empty())
+SetLogMessage();
 }
 
 } // namespace lldb_vscode
Index: lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
===
--- lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
+++ lldb/tools/lldb-vscode/FunctionBreakpoint.cpp
@@ -25,6 +25,8 @@
 SetCondition();
   if (!hitCondition.empty())
 SetHitCondition();
+  if (!logMessage.empty())
+SetLogMessage();
 }
 
 } // namespace lldb_vscode
Index: lldb/tools/lldb-vscode/BreakpointBase.h
===
--- lldb/tools/lldb-vscode/BreakpointBase.h
+++ lldb/tools/lldb-vscode/BreakpointBase.h
@@ -13,11 +13,16 @@
 #include "lldb/API/SBBreakpoint.h"
 #include "llvm/Support/JSON.h"
 #include 
+#include 
 
 namespace lldb_vscode {
 
 struct BreakpointBase {
-
+  // logMessage part can be either a raw text or an expression.
+  struct LogMessagePart {
+llvm::StringRef text;
+bool is_expr;
+  };
   // An optional expression for conditional breakpoints.
   std::string condition;
   // An optional expression that controls how many hits of the breakpoint are
@@ -27,6 +32,7 @@
   // (stop) but log the message instead. Expressions within {} are
   // interpolated.
   std::string logMessage;
+  std::vector logMessageParts;
   // The LLDB breakpoint associated wit this source breakpoint
   lldb::SBBreakpoint bp;
 
@@ -35,8 +41,12 @@
 
   void SetCondition();
   void SetHitCondition();
+  void SetLogMessage();
   void UpdateBreakpoint(const BreakpointBase &request_bp);
   static const char *GetBreakpointLabel();
+  static bool BreakpointHitCallback(void *baton, lldb::SBProcess &process,
+lldb::SBThread &thread,
+lldb::SBBreakpointLocation &location);
 };
 
 } // namespace lldb_vscode
Index: lldb/tools/lldb-vscode/BreakpointBase.cpp
===
--- lldb/tools/lldb-vscode/BreakpointBase.cpp
+++ lldb/tools

[Lldb-commits] [PATCH] D127702: Support logpoints in lldb-vscode

2022-06-20 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

Looks like this might not build: http://45.33.8.238/linux/79194/step_4.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127702

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


[Lldb-commits] [PATCH] D127702: Support logpoints in lldb-vscode

2022-06-20 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

Here too: https://lab.llvm.org/buildbot#builders/83/builds/20210


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127702

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


[Lldb-commits] [PATCH] D127702: Support logpoints in lldb-vscode

2022-06-20 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan added a comment.

Sorry, I was fooled by the buildbot which says everything is green. Working on 
a fix for the build break now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127702

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


[Lldb-commits] [PATCH] D128234: Fix build break introduced by https://reviews.llvm.org/D127702

2022-06-20 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan created this revision.
yinghuitan added reviewers: clayborg, thakis, kazu.
Herald added a project: All.
yinghuitan requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Fix build break introduced by https://reviews.llvm.org/D127702


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128234

Files:
  lldb/tools/lldb-vscode/BreakpointBase.cpp
  lldb/tools/lldb-vscode/BreakpointBase.h


Index: lldb/tools/lldb-vscode/BreakpointBase.h
===
--- lldb/tools/lldb-vscode/BreakpointBase.h
+++ lldb/tools/lldb-vscode/BreakpointBase.h
@@ -20,6 +20,8 @@
 struct BreakpointBase {
   // logMessage part can be either a raw text or an expression.
   struct LogMessagePart {
+LogMessagePart(llvm::StringRef text, bool is_expr)
+: text(text), is_expr(is_expr) {}
 llvm::StringRef text;
 bool is_expr;
   };
Index: lldb/tools/lldb-vscode/BreakpointBase.cpp
===
--- lldb/tools/lldb-vscode/BreakpointBase.cpp
+++ lldb/tools/lldb-vscode/BreakpointBase.cpp
@@ -103,7 +103,8 @@
 last_raw_text_start = curly_braces_range.second + 1;
   }
   // Trailing raw text after close curly brace.
-  if (logMessage.size() > last_raw_text_start)
+  assert(last_raw_text_start >= 0);
+  if (logMessage.size() > (size_t)last_raw_text_start)
 logMessageParts.emplace_back(
 llvm::StringRef(logMessage.c_str() + last_raw_text_start,
 logMessage.size() - last_raw_text_start),
@@ -127,7 +128,8 @@
 if (messagePart.is_expr) {
   // Try local frame variables first before fall back to expression
   // evaluation
-  const char *expr = messagePart.text.str().c_str();
+  std::string expr_str = messagePart.text.str();
+  const char *expr = expr_str.c_str();
   lldb::SBValue value =
   frame.GetValueForVariablePath(expr, lldb::eDynamicDontRunTarget);
   if (value.GetError().Fail())


Index: lldb/tools/lldb-vscode/BreakpointBase.h
===
--- lldb/tools/lldb-vscode/BreakpointBase.h
+++ lldb/tools/lldb-vscode/BreakpointBase.h
@@ -20,6 +20,8 @@
 struct BreakpointBase {
   // logMessage part can be either a raw text or an expression.
   struct LogMessagePart {
+LogMessagePart(llvm::StringRef text, bool is_expr)
+: text(text), is_expr(is_expr) {}
 llvm::StringRef text;
 bool is_expr;
   };
Index: lldb/tools/lldb-vscode/BreakpointBase.cpp
===
--- lldb/tools/lldb-vscode/BreakpointBase.cpp
+++ lldb/tools/lldb-vscode/BreakpointBase.cpp
@@ -103,7 +103,8 @@
 last_raw_text_start = curly_braces_range.second + 1;
   }
   // Trailing raw text after close curly brace.
-  if (logMessage.size() > last_raw_text_start)
+  assert(last_raw_text_start >= 0);
+  if (logMessage.size() > (size_t)last_raw_text_start)
 logMessageParts.emplace_back(
 llvm::StringRef(logMessage.c_str() + last_raw_text_start,
 logMessage.size() - last_raw_text_start),
@@ -127,7 +128,8 @@
 if (messagePart.is_expr) {
   // Try local frame variables first before fall back to expression
   // evaluation
-  const char *expr = messagePart.text.str().c_str();
+  std::string expr_str = messagePart.text.str();
+  const char *expr = expr_str.c_str();
   lldb::SBValue value =
   frame.GetValueForVariablePath(expr, lldb::eDynamicDontRunTarget);
   if (value.GetError().Fail())
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D127702: Support logpoints in lldb-vscode

2022-06-20 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan added a comment.

Fixed in https://reviews.llvm.org/D128234


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127702

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


[Lldb-commits] [lldb] 5109de2 - Fix build break introduced by https://reviews.llvm.org/D127702

2022-06-20 Thread Jeffrey Tan via lldb-commits

Author: Jeffrey Tan
Date: 2022-06-20T17:31:26-07:00
New Revision: 5109de2da2e2b2321bd2bc504a3ddcedce51c0f8

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

LOG: Fix build break introduced by https://reviews.llvm.org/D127702

Fix build break introduced by https://reviews.llvm.org/D127702

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

Added: 


Modified: 
lldb/tools/lldb-vscode/BreakpointBase.cpp
lldb/tools/lldb-vscode/BreakpointBase.h

Removed: 




diff  --git a/lldb/tools/lldb-vscode/BreakpointBase.cpp 
b/lldb/tools/lldb-vscode/BreakpointBase.cpp
index 14d279dfd660..0637637b84e5 100644
--- a/lldb/tools/lldb-vscode/BreakpointBase.cpp
+++ b/lldb/tools/lldb-vscode/BreakpointBase.cpp
@@ -103,7 +103,8 @@ void BreakpointBase::SetLogMessage() {
 last_raw_text_start = curly_braces_range.second + 1;
   }
   // Trailing raw text after close curly brace.
-  if (logMessage.size() > last_raw_text_start)
+  assert(last_raw_text_start >= 0);
+  if (logMessage.size() > (size_t)last_raw_text_start)
 logMessageParts.emplace_back(
 llvm::StringRef(logMessage.c_str() + last_raw_text_start,
 logMessage.size() - last_raw_text_start),
@@ -127,7 +128,8 @@ bool BreakpointBase::BreakpointHitCallback(
 if (messagePart.is_expr) {
   // Try local frame variables first before fall back to expression
   // evaluation
-  const char *expr = messagePart.text.str().c_str();
+  std::string expr_str = messagePart.text.str();
+  const char *expr = expr_str.c_str();
   lldb::SBValue value =
   frame.GetValueForVariablePath(expr, lldb::eDynamicDontRunTarget);
   if (value.GetError().Fail())

diff  --git a/lldb/tools/lldb-vscode/BreakpointBase.h 
b/lldb/tools/lldb-vscode/BreakpointBase.h
index 321c8adfbfb9..4becd4aa8196 100644
--- a/lldb/tools/lldb-vscode/BreakpointBase.h
+++ b/lldb/tools/lldb-vscode/BreakpointBase.h
@@ -20,6 +20,8 @@ namespace lldb_vscode {
 struct BreakpointBase {
   // logMessage part can be either a raw text or an expression.
   struct LogMessagePart {
+LogMessagePart(llvm::StringRef text, bool is_expr)
+: text(text), is_expr(is_expr) {}
 llvm::StringRef text;
 bool is_expr;
   };



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


[Lldb-commits] [PATCH] D128234: Fix build break introduced by https://reviews.llvm.org/D127702

2022-06-20 Thread jeffrey tan via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5109de2da2e2: Fix build break introduced by 
https://reviews.llvm.org/D127702 (authored by yinghuitan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128234

Files:
  lldb/tools/lldb-vscode/BreakpointBase.cpp
  lldb/tools/lldb-vscode/BreakpointBase.h


Index: lldb/tools/lldb-vscode/BreakpointBase.h
===
--- lldb/tools/lldb-vscode/BreakpointBase.h
+++ lldb/tools/lldb-vscode/BreakpointBase.h
@@ -20,6 +20,8 @@
 struct BreakpointBase {
   // logMessage part can be either a raw text or an expression.
   struct LogMessagePart {
+LogMessagePart(llvm::StringRef text, bool is_expr)
+: text(text), is_expr(is_expr) {}
 llvm::StringRef text;
 bool is_expr;
   };
Index: lldb/tools/lldb-vscode/BreakpointBase.cpp
===
--- lldb/tools/lldb-vscode/BreakpointBase.cpp
+++ lldb/tools/lldb-vscode/BreakpointBase.cpp
@@ -103,7 +103,8 @@
 last_raw_text_start = curly_braces_range.second + 1;
   }
   // Trailing raw text after close curly brace.
-  if (logMessage.size() > last_raw_text_start)
+  assert(last_raw_text_start >= 0);
+  if (logMessage.size() > (size_t)last_raw_text_start)
 logMessageParts.emplace_back(
 llvm::StringRef(logMessage.c_str() + last_raw_text_start,
 logMessage.size() - last_raw_text_start),
@@ -127,7 +128,8 @@
 if (messagePart.is_expr) {
   // Try local frame variables first before fall back to expression
   // evaluation
-  const char *expr = messagePart.text.str().c_str();
+  std::string expr_str = messagePart.text.str();
+  const char *expr = expr_str.c_str();
   lldb::SBValue value =
   frame.GetValueForVariablePath(expr, lldb::eDynamicDontRunTarget);
   if (value.GetError().Fail())


Index: lldb/tools/lldb-vscode/BreakpointBase.h
===
--- lldb/tools/lldb-vscode/BreakpointBase.h
+++ lldb/tools/lldb-vscode/BreakpointBase.h
@@ -20,6 +20,8 @@
 struct BreakpointBase {
   // logMessage part can be either a raw text or an expression.
   struct LogMessagePart {
+LogMessagePart(llvm::StringRef text, bool is_expr)
+: text(text), is_expr(is_expr) {}
 llvm::StringRef text;
 bool is_expr;
   };
Index: lldb/tools/lldb-vscode/BreakpointBase.cpp
===
--- lldb/tools/lldb-vscode/BreakpointBase.cpp
+++ lldb/tools/lldb-vscode/BreakpointBase.cpp
@@ -103,7 +103,8 @@
 last_raw_text_start = curly_braces_range.second + 1;
   }
   // Trailing raw text after close curly brace.
-  if (logMessage.size() > last_raw_text_start)
+  assert(last_raw_text_start >= 0);
+  if (logMessage.size() > (size_t)last_raw_text_start)
 logMessageParts.emplace_back(
 llvm::StringRef(logMessage.c_str() + last_raw_text_start,
 logMessage.size() - last_raw_text_start),
@@ -127,7 +128,8 @@
 if (messagePart.is_expr) {
   // Try local frame variables first before fall back to expression
   // evaluation
-  const char *expr = messagePart.text.str().c_str();
+  std::string expr_str = messagePart.text.str();
+  const char *expr = expr_str.c_str();
   lldb::SBValue value =
   frame.GetValueForVariablePath(expr, lldb::eDynamicDontRunTarget);
   if (value.GetError().Fail())
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 064a08c - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-06-20T20:05:16-07:00
New Revision: 064a08cd955019da9130f1109bfa534e79b8ec7c

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/FileEntry.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/Sema.h
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
flang/include/flang/Lower/ComponentPath.h
lld/wasm/Writer.cpp
lldb/include/lldb/Core/DataFileCache.h
lldb/source/API/SBMemoryRegionInfo.cpp
lldb/source/Breakpoint/BreakpointID.cpp
llvm/include/llvm/Analysis/LazyCallGraph.h
llvm/include/llvm/CodeGen/SelectionDAGAddressAnalysis.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/IR/Function.h
llvm/include/llvm/ObjectYAML/ELFYAML.h
llvm/include/llvm/Support/Alignment.h
llvm/lib/Analysis/ProfileSummaryInfo.cpp
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/ObjectYAML/COFFEmitter.cpp
llvm/lib/Remarks/RemarkLinker.cpp
llvm/lib/Remarks/RemarkParser.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp
mlir/include/mlir/Analysis/DataFlowAnalysis.h
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
mlir/include/mlir/IR/Diagnostics.h
mlir/include/mlir/Support/StorageUniquer.h
mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/MLIRContext.cpp
mlir/lib/Support/Timing.cpp
mlir/lib/TableGen/Pattern.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
index 4eaf8bc6f392f..f7b4c3ef57938 100644
--- a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -66,7 +66,7 @@ getFileExtension(StringRef FileName, const FileExtensionsSet 
&FileExtensions) {
 
 bool isFileExtension(StringRef FileName,
  const FileExtensionsSet &FileExtensions) {
-  return getFileExtension(FileName, FileExtensions).hasValue();
+  return getFileExtension(FileName, FileExtensions).has_value();
 }
 
 } // namespace utils

diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index ce31f366cf174..2684b0de53bdb 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -530,7 +530,7 @@ class 
DirectoryBasedGlobalCompilationDatabase::BroadcastThread {
   bool blockUntilIdle(Deadline Timeout) {
 std::unique_lock Lock(Mu);
 return wait(Lock, CV, Timeout,
-[&] { return Queue.empty() && !ActiveTask.hasValue(); });
+[&] { return Queue.empty() && !ActiveTask; });
   }
 
   ~BroadcastThread() {

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index f60fbfaa479f9..4bdcf0f3c80cd 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -1196,7 +1196,7 @@ std::shared_ptr 
ASTWorker::getPossiblyStalePreamble(
 
 void ASTWorker::waitForFirstPreamble() const {
   std::unique_lock Lock(Mutex);
-  PreambleCV.wait(Lock, [this] { return LatestPreamble.hasValue() || Done; });
+  PreambleCV.wait(Lock, [this] { return LatestPreamble || Done; });
 }
 
 tooling::CompileCommand ASTWorker::getCurrentCompileCommand() const {

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp 
b/c

[Lldb-commits] [lldb] d66cbc5 - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-06-20T20:26:05-07:00
New Revision: d66cbc565adbea8b7362349e527ac7aa2c75788f

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang/include/clang/APINotes/Types.h
clang/include/clang/Basic/DarwinSDKInfo.h
clang/lib/Lex/MacroInfo.cpp
lldb/tools/lldb-vscode/FifoFiles.cpp
llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
llvm/include/llvm/ProfileData/MemProf.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.h
llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
mlir/include/mlir/TableGen/CodeGenHelpers.h
mlir/lib/Analysis/Presburger/IntegerRelation.cpp
mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
mlir/lib/Dialect/Affine/Analysis/Utils.cpp
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index cd02db3da185c..ed5250f3d5b4e 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -440,8 +440,7 @@ class ParamInfo : public VariableInfo {
   }
   void
   setRetainCountConvention(llvm::Optional Value) {
-RawRetainCountConvention =
-Value.hasValue() ? static_cast(Value.getValue()) + 1 : 0;
+RawRetainCountConvention = Value ? static_cast(*Value) + 1 : 0;
 assert(getRetainCountConvention() == Value && "bitfield too small");
   }
 
@@ -559,8 +558,7 @@ class FunctionInfo : public CommonEntityInfo {
   }
   void
   setRetainCountConvention(llvm::Optional Value) {
-RawRetainCountConvention =
-Value.hasValue() ? static_cast(Value.getValue()) + 1 : 0;
+RawRetainCountConvention = Value ? static_cast(*Value) + 1 : 0;
 assert(getRetainCountConvention() == Value && "bitfield too small");
   }
 

diff  --git a/clang/include/clang/Basic/DarwinSDKInfo.h 
b/clang/include/clang/Basic/DarwinSDKInfo.h
index df16827debfc0..728bbc17c3acb 100644
--- a/clang/include/clang/Basic/DarwinSDKInfo.h
+++ b/clang/include/clang/Basic/DarwinSDKInfo.h
@@ -142,8 +142,7 @@ class DarwinSDKInfo {
 auto Mapping = VersionMappings.find(Kind.Value);
 if (Mapping == VersionMappings.end())
   return nullptr;
-return Mapping->getSecond().hasValue() ? Mapping->getSecond().getPointer()
-   : nullptr;
+return Mapping->getSecond() ? Mapping->getSecond().getPointer() : nullptr;
   }
 
   static Optional

diff  --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp
index f5702130d1819..4a8127d29a459 100644
--- a/clang/lib/Lex/MacroInfo.cpp
+++ b/clang/lib/Lex/MacroInfo.cpp
@@ -201,8 +201,7 @@ MacroDirective::DefInfo MacroDirective::getDefinition() {
   Optional isPublic;
   for (; MD; MD = MD->getPrevious()) {
 if (DefMacroDirective *DefMD = dyn_cast(MD))
-  return DefInfo(DefMD, UndefLoc,
- !isPublic.hasValue() || isPublic.getValue());
+  return DefInfo(DefMD, UndefLoc, !isPublic || *isPublic);
 
 if (UndefMacroDirective *UndefMD = dyn_cast(MD)) {
   UndefLoc = UndefMD->getLocation();

diff  --git a/lldb/tools/lldb-vscode/FifoFiles.cpp 
b/lldb/tools/lldb-vscode/FifoFiles.cpp
index e37f2020d8f19..b97455ba953fb 100644
--- a/lldb/tools/lldb-vscode/FifoFiles.cpp
+++ b/lldb/tools/lldb-vscode/FifoFiles.cpp
@@ -61,8 +61,7 @@ Expected 
FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) {
 if (!buffer.empty())
   line = buffer;
   }));
-  if (future->wait_for(timeout) == std::future_status::timeout ||
-  !line.hasValue())
+  if (future->wait_for(timeout) == std::future_status::timeout || !line)
 return createStringError(inconvertibleErrorCode(),
  "Timed out trying to get messages from the " +
  m_other_endpoint_name);

diff  --git a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h 
b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
index ed41d2b5b9d4c..a41b2fe2a6e76 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
@@ -102,9 +102,7 @@ struct FunctionInfo {
   /// debug info, we might end up with multiple FunctionInfo objects for the
   /// same range and we need to be able to tell which one is the better object
   /// to use.
-  bool hasRichInfo() const {
-return OptLineTable.hasValue() || Inline.hasValue();
-  }
+  bool hasRichInfo() const { return OptLineTable || Inline; }
 
   /// Query if a FunctionInfo object is valid.
   ///

diff 

[Lldb-commits] [PATCH] D127500: [lldb] [llgs] Make `k` kill all processes, and fix multiple exits

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

In D127500#3595605 , @labath wrote:

> I've ran into the "dynamic uninitialization order fiasco" problem as well. 
> I'm wondering if, instead of the trick (which is pretty neat, but still a 
> trick) with the limbo member variable, we could add something like the 
> `asyncio.loop.call_soon` function in python to our MainLoop class. So, 
> instead of immediately calling the exited callback (and possibly others as 
> well), the process class would schedule the call to be made upon return to 
> the top-level loop.
>
> What do you think about that?

Not sure if I follow you. If you mean delaying the whole callback logic, I 
don't think that would change anything — the problem is that the object gets 
destroyed in the middle of it. If you mean delaying just the part where it's 
removed from `m_debugged_processes`, then I suppose that could work.




Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:1196
+  if (!bool(m_extensions_supported &
+NativeProcessProtocol::Extension::multiprocess))
+assert(!m_stdio_handle_up);

labath wrote:
> I don't think this is right. I believe the important distinction is whether 
> we have non-stop mode enabled or not, because in all-stop mode we are not 
> able to send stdio while stopped, regardless of how many processes we're 
> debugging.
Well, the code exploded in all-stop mode as well because in order to kill 
multiple processes, we effectively resume them all. I suppose there could be a 
way around it (synchronously killing one process after another and waiting for 
everything to happen) but I'm not convinced this is really worth the added 
complexity.


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

https://reviews.llvm.org/D127500

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


[Lldb-commits] [lldb] ed8fcea - Don't use Optional::getValue (NFC)

2022-06-20 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-06-20T23:35:53-07:00
New Revision: ed8fceaa09cd66324c6efc1070f962731a62e2dc

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

LOG: Don't use Optional::getValue (NFC)

Added: 


Modified: 
clang-tools-extra/clang-doc/BitcodeWriter.cpp
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/index/YAMLSerialization.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
flang/include/flang/Lower/IterationSpace.h
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/ComponentPath.cpp
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/CustomIntrinsicCall.cpp
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
lld/COFF/Driver.cpp
lld/ELF/InputFiles.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Core/IOHandler.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/source/Plugins/ABI/X86/ABIX86.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Target/TraceInstructionDumper.cpp
lldb/source/Utility/UriParser.cpp
polly/lib/Exchange/JSONExporter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/BitcodeWriter.cpp 
b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
index 33a7814e1f483..f02906e5498a4 100644
--- a/clang-tools-extra/clang-doc/BitcodeWriter.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
@@ -478,7 +478,7 @@ void ClangDocBitcodeWriter::emitBlock(const EnumInfo &I) {
   for (const auto &CI : I.Description)
 emitBlock(CI);
   if (I.DefLoc)
-emitRecord(I.DefLoc.getValue(), ENUM_DEFLOCATION);
+emitRecord(*I.DefLoc, ENUM_DEFLOCATION);
   for (const auto &L : I.Loc)
 emitRecord(L, ENUM_LOCATION);
   emitRecord(I.Scoped, ENUM_SCOPED);
@@ -496,7 +496,7 @@ void ClangDocBitcodeWriter::emitBlock(const RecordInfo &I) {
   for (const auto &CI : I.Description)
 emitBlock(CI);
   if (I.DefLoc)
-emitRecord(I.DefLoc.getValue(), RECORD_DEFLOCATION);
+emitRecord(*I.DefLoc, RECORD_DEFLOCATION);
   for (const auto &L : I.Loc)
 emitRecord(L, RECORD_LOCATION);
   emitRecord(I.TagType, RECORD_TAG_TYPE);
@@ -543,7 +543,7 @@ void ClangDocBitcodeWriter::emitBlock(const FunctionInfo 
&I) {
   emitRecord(I.Access, FUNCTION_ACCESS);
   emitRecord(I.IsMethod, FUNCTION_IS_METHOD);
   if (I.DefLoc)
-emitRecord(I.DefLoc.getValue(), FUNCTION_DEFLOCATION);
+emitRecord(*I.DefLoc, FUNCTION_DEFLOCATION);
   for (const auto &L : I.Loc)
 emitRecord(L, FUNCTION_LOCATION);
   emitBlock(I.Parent, FieldId::F_parent);

diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 4ab962be7864d..3e5a5331b7906 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -312,7 +312,7 @@ genReference(const Reference &Type, StringRef 
CurrentDirectory,
 if (!JumpToSection)
   return std::make_unique(Type.Name);
 else
-  return genLink(Type.Name, "#" + JumpToSection.getValue());
+  return genLink(Type.Name, "#" + *JumpToSection);
   }
   llvm::SmallString<64> Path = Type.getRelativeFilePath(CurrentDirectory);
   llvm::sys::path::append(Path, Type.getFileBaseName() + ".html");
@@ -320,7 +320,7 @@ genReference(const Reference &Type, StringRef 
CurrentDirectory,
   // Paths in HTML must be in posix-style
   llvm::sys::path::native(Path, llvm::sys::path::Style::posix);
   if (JumpToSection)
-Path += ("#" + JumpToSection.getValue()).str();
+Path += ("#"