[Lldb-commits] [patch] implement process launch with a user-specified working directory on Linux

Greg Clayton gclayton at apple.com
Mon Jan 7 13:49:35 PST 2013


Gotcha. As long as the chdir is in the child process, the patch looks good.

Just curious: is there some anything that syncs with the child process from the parent while it has been forked but not exec'ed? This is a nice way to ensure you are connected to the process before it makes any progress since there is nothing on linux that says "start the process stopped for a debugger"...

Greg

On Jan 7, 2013, at 1:27 PM, "Malea, Daniel" <daniel.malea at intel.com> wrote:

> Hi Greg,
> 
> Thanks for looking into this. I agree, posix_spawn() would be really nice to use in lieu of the current approach, but since it is missing the ability to set working directories, I think it's a non-starter.
> 
> Currently on Linux, process starting works via a fork(), then in the child a call is made to chdir() and exec(). Since the chdir() happens after the fork() it shouldn't affect the parent host "lldb" instance cwd.
> 
> Dan
> 
> 
> 
> On 2013-01-07, at 12:51 PM, Greg Clayton wrote:
> 
> Calling "chdir" in process will change the working directory for the "lldb" binary. On MacOSX we use a thread specific version of chdir to minimize this affect, but that also only occurs in "debugserver" since all debugging on MacOSX is done remotely even on local machine.
> 
> It is really a shame that posix_spawn() doesn't have an attribute to set the working directory.
> 
> How does launching happen on Linux right now? The safest way to do this would be to fork, then chdir, then posix_spawn with exec only (if this is possible on linux/FreeBSD). This would eliminate the cwd from changing in the host "lldb".
> 
> Greg
> 
> On Jan 4, 2013, at 4:43 PM, "Malea, Daniel" <daniel.malea at intel.com<mailto:daniel.malea at intel.com>> wrote:
> 
> Hi all,
> 
> I noticed that on Linux (and FreeBSD) the working directory specified to the “process launch” command is ignored. Here’s a patch that implements the correct behaviour on Linux by propagating the working directory string down through ProcessPOSIX and ProcessMonitor, and eventually just calls ::chdir() before launching the inferior process.
> 
> It’s all pretty straight forward, but since there’s a common interface with FreeBSD (ProcessMonitor) that I had to modify the constructor of, I figured I’d ask here if someone could take a look when they have a spare moment.
> 
> This patch fixes the TestProcessLaunch test case.
> 
> Thanks in advance,
> Dan
> 
> 
> Daniel Malea daniel.malea at intel.com<mailto:daniel.malea at intel.com>
> Intel Embedded Computing, Debuggers & Libraries
> Intel Waterloo
> 
> <working_dir.patch>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu<mailto:lldb-commits at cs.uiuc.edu>
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
> 
> 
> Daniel Malea <daniel.malea at intel.com<mailto:daniel.malea at intel.com>>
> Intel Waterloo
> Phone: 519-772-2566
> 





More information about the lldb-commits mailing list