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

Greg Clayton gclayton at apple.com
Mon Jan 7 09:51:17 PST 2013

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".


On Jan 4, 2013, at 4:43 PM, "Malea, Daniel" <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
>   Intel Embedded Computing, Debuggers & Libraries
>   Intel Waterloo
> <working_dir.patch>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

More information about the lldb-commits mailing list