<div dir="ltr">What is the monitor_signals variable supposed to represent? Windows doesn't have signals, so maybe I can just ignore this variable. Looking through the code, it seems like even MacOSX doesn't use this, and just always sets it to false, and the only place this is ever set to true is in Linux and FreeBSD. Maybe Todd knows? (I don't have his email new address, but maybe you can +cc him on this email if you don't know the answer).<div><br></div><div>I kind of feel like the code would be clearer if ProcessMonitor were an abstract interface in Host, then DefaultWindowsProcessMonitor could do what it needs to do, DefaultPosixProcessMonitor could do what it needs to do, ProcessLaunchInfo could just have a pointer to a ProcessMonitor instead of both a callback and a baton, it would be easier to chain callbacks like this because the class could store a list of callbacks instead of just 1, and this monitor_signals flag could be a member variable of LinuxProcessMonitor so that other platforms wouldn't have to worry about dubiously ignoring it. Anyway, I've had enough refactoring for a while, just thinking out loud.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 24, 2014 at 2:45 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Oct 24, 2014, at 1:58 PM, Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br>
><br>
> So right now I have ProcessWindows::DoLaunch() set up to just call Host::LaunchProcess and pass the ProcessLaunchInfo along. This uses the default default monitoring algorithm that's built into the host layer, which basically just waits for the process to exist and nothing else. This doesn't work in the case of a debugged process, because there's no initial stop so Process::Launch (in Target/Process.cpp) doesn't ever get the notification that the process launched successfully.<br>
><br>
> Is the solution then to just keep the default monitoring algorithm in Host as is, but in ProcessWindows::DoLaunch(), specify a different callback before passing it through to Host::LaunchProcess?<br>
<br>
</span>Yes, this is what you must do since you will want to call Process::SetExitStatus(...).<br>
<span class=""><br>
> This is roughly what ProcessLinux does, but I wonder what happens if ProcessWindows::DoLaunch() has received a ProcessLaunchInfo that has a user-specified monitoring callback.<br>
<br>
</span>You would need to chain it an call theirs from yours.<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> On Fri, Oct 24, 2014 at 1:45 PM, Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:<br>
><br>
> > On Oct 24, 2014, at 11:53 AM, Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br>
> ><br>
> > I'm going to tackle implementing process monitoring for Windows next, and I've started going over how this works for other platforms.<br>
> ><br>
> > There's a bit of a confusing interaction between Host, Target, and the individual plugins, and I'm wondering if it might make more sense to put the monitoring code somewhere other than Host.<br>
> ><br>
> > From what I can tell, launching a process for debugging goes something like this:<br>
> ><br>
> > 1) Call ProcessPlugin::DoLaunch<br>
> > 2) some system calls to actually launch the process<br>
> > 3) Call Host::StartMonitoringChildProcess with callback set to somewhere in your plugin.<br>
> > 4) The monitoring thread (in Host) periodically calls back into ProcessPlugin<br>
> ><br>
> > For starters, this seems to be broken in the case where the ProcessLaunchInfo has pre-set an m_monitor_callback because the plugins end up just ignoring this and using their own callback.<br>
> ><br>
> > Ultimately, how a process is monitored is going to depend on the plugin, so shouldn't StartMonitoringChildProcess also be part of the plugin? In what situation would you ever want to monitor a child process that is not under the control of some process plugin?<br>
><br>
> Any process you launch that you aren't going to debug. Like launching a shell command or just say running "debugserver" in order for _it_ to be able to debug your application along with ProcessGDBRemote. ProcessGDBRemote is very interested if the "debugserver" process dies because it crashes, so it can kill the debug session and say "debugserver exited with status 12". Also when running a shell command you need to be able to run the shell command and find out when the shell command exits.<br>
><br>
> So the monitoring of the process definitely will stay in the host layer. The host layer can and should be used to launch any process (though some plug-ins might not be respecting that and they might be doing it themselves. The idea is we write the process launching code once in the host layer, then lldb-gdbserver, lldb-platform, and lldb can all use that one copy of the code to correctly launch processes and monitor (for signals) and reap them (get exit status and know that any stdout/stderr can now be forwarded onto whomever needs it.<br>
><br>
> Greg<br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>