[Lldb-commits] [PATCH] D64647: [lldb] [Process/NetBSD] Implement per-thread execution control

2019-07-13 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

In D64647#1584340 , @mgorny wrote:

> In D64647#1583429 , @krytarowski 
> wrote:
>
> > Something that we do not cover here is that once a tracee reports a signal 
> > (like someone poked it with SIGUSR1) and we want to pass it over to the 
> > tracee, we will reset siginfo.
> >
> > This scenario should be covered by a test and we should handle it properly..
> >
> > The solution in NetBSD for passing over signals without changing siginfo, 
> > is to not calling PT_SET_SIGINFO as the default one will be kept by the 
> > kernel. Optionally pick old siginfo with PT_GET_SIGINFO and optionally 
> > change destination lwp.
>
>
> How is 'properly'? Should we reject resuming with a signal when there's 
> already another signal pending?


We need to pass the same signal (with unchanged siginfo) to the tracee.

The easiest way is to not changing it, however as we can emit a signal over to 
tracee specifying LWP. we can go for the sequence of PT_GET_SIGINFO, change 
lwp, PT_SET_SIGINFO, PT_CONTINUE with a signal.


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

https://reviews.llvm.org/D64647



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


[Lldb-commits] [PATCH] D64647: [lldb] [Process/NetBSD] Implement per-thread execution control

2019-07-13 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:394
+siginfo.psi_siginfo.si_signo = signal;
+siginfo.psi_siginfo.si_code = SI_NOINFO;
+if (signaled_threads == m_threads.size()) // signal aimed at all threads

For extra completeness, all basic signals (without specified siginfo) from 
debugger (that weren't intercepted by a debugger as they were routed into 
debuggee) that are emitted should be of type `SI_USER` with filled `si_pid` and 
`si_uid` of the debugger.

We thought have the power to set it to whatever value we want, but LLDB 
probably doesn't allow to set defailed siginfo.


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

https://reviews.llvm.org/D64647



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


[Lldb-commits] [PATCH] D64647: [lldb] [Process/NetBSD] Implement per-thread execution control

2019-07-13 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp:354
+  if (signal != LLDB_INVALID_SIGNAL_NUMBER && signal != action->signal)
+return Status("NetBSD does not support passing multiple signals 
simultaneously");
 

mgorny wrote:
> labath wrote:
> > krytarowski wrote:
> > > mgorny wrote:
> > > > labath wrote:
> > > > > Is this "passing multiple signals simultaneously", or "passing 
> > > > > multiple *distinct* signals simultaneously". (E.g,. thread 1 gets a 
> > > > > SIGALRM, thread 2 gets SIGIO, etc.).
> > > > The former. Basically there's one siginfo slot, so you can either put a 
> > > > signal for whole process, or for one LWP.
> > > Once we emit a single signal to all threads, it's still technically a 
> > > single signal that hits the process.
> > Ok, that makes sense. But I don't think that's what the code does right now 
> > (IIUC, this line will only fire if the current signal is different that the 
> > signal sent to the previous thread).
> There's a second `if` on line 400 that verifies the number of threads 
> signaled.
> 
> The idea is that we have either:
> * exactly one thread signaled,
> * all threads signaled with the same signal.
> 
> Here we check for the 'same signal' condition.
Ah, I see. That makes sense.

It might be more readable to move all the checks up front, perhaps into some 
function like `Expected< ptrace_siginfo_t> ComputeSignalInfo(const 
ResumeActionList&)`. Apart from readability, doing this will make sure you 
don't issue ptrace commands before you before realize that  the resume packet 
was bogus (and leave the inferior in a weird state in the process).


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

https://reviews.llvm.org/D64647



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


[Lldb-commits] [PATCH] D64698: Handle EOF from `lldb-vscode`

2019-07-13 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: clayborg, labath, JDevlieghere.
jankratochvil added a project: LLDB.

Sometimes (when running `lldb-vscode` under `strace`) I get:

  read(0, "", 16) = 0
  read(0, "", 16) = 0
  read(0, "", 16) = 0
  ...

Patch is obvious, isn't it?  With this patch testcases finish properly even 
with `strace`:

  read(0, "", 16) = 0
  futex(0x1346508, FUTEX_WAKE_PRIVATE, 2147483647) = 0
  stat("", 0x7ffe8f2634c8)= -1 ENOENT (No such file or 
directory)
  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=9124, si_uid=1001, 
si_status=SIGINT, si_utime=1, si_stime=0} ---
  close(4)= 0
  exit_group(0)   = ?
  +++ exited with 0 +++


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64698

Files:
  lldb/tools/lldb-vscode/IOStream.cpp


Index: lldb/tools/lldb-vscode/IOStream.cpp
===
--- lldb/tools/lldb-vscode/IOStream.cpp
+++ lldb/tools/lldb-vscode/IOStream.cpp
@@ -101,6 +101,11 @@
 else
   bytes_read = ::read(descriptor.m_fd, ptr, length);
 
+if (bytes_read == 0) {
+  if (log)
+*log << "End of file (EOF) reading from input file.\n";
+  return false;
+}
 if (bytes_read < 0) {
   int reason = 0;
 #if defined(_WIN32)


Index: lldb/tools/lldb-vscode/IOStream.cpp
===
--- lldb/tools/lldb-vscode/IOStream.cpp
+++ lldb/tools/lldb-vscode/IOStream.cpp
@@ -101,6 +101,11 @@
 else
   bytes_read = ::read(descriptor.m_fd, ptr, length);
 
+if (bytes_read == 0) {
+  if (log)
+*log << "End of file (EOF) reading from input file.\n";
+  return false;
+}
 if (bytes_read < 0) {
   int reason = 0;
 #if defined(_WIN32)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits