[Lldb-commits] [patch] implement process launch with a user-specified working directory on Linux
daniel.malea at intel.com
Mon Jan 7 13:27:55 PST 2013
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.
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".
On Jan 4, 2013, at 4:43 PM, "Malea, Daniel" <daniel.malea at intel.com<mailto:daniel.malea at intel.com>> wrote:
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,
Daniel Malea daniel.malea at intel.com<mailto:daniel.malea at intel.com>
Intel Embedded Computing, Debuggers & Libraries
lldb-commits mailing list
lldb-commits at cs.uiuc.edu<mailto:lldb-commits at cs.uiuc.edu>
Daniel Malea <daniel.malea at intel.com<mailto:daniel.malea at intel.com>>
More information about the lldb-commits