<div dir="ltr"><div></div><div>> But I don't think passing lldb's environment variables automatically 
when running a remote process is a sensible thing to do - certainly not 
as the default anyway.  If the host and target are different OS'es and 
maybe different users, etc. lldb's environment may very well not be 
appropriate for the target process.</div><div><br></div><div>That's what I'm saying - I could not figure out how to correctly launch a remote application via SB API (other than executing "process launch" via command interpreter, I suppose).  <br></div><div><br></div><div>> Sounds like there should also be an  lldb.eLaunchFlagInheritEnv that triggers the same behavior from the SB API.</div><div><br></div><div>So it's a bug then?<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 2, 2019 at 2:59 PM Jim Ingham <<a href="mailto:jingham@apple.com">jingham@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">There's a setting (target.inherit-env) that controls whether "process launch" passes its environment variables along with any newly set to the process in question.  Sounds like there should also be an  lldb.eLaunchFlagInheritEnv that triggers the same behavior from the SB API.<br>
<br>
But I don't think passing lldb's environment variables automatically when running a remote process is a sensible thing to do - certainly not as the default anyway.  If the host and target are different OS'es and maybe different users, etc. lldb's environment may very well not be appropriate for the target process.<br>
<br>
JIm<br>
<br>
<br>
> On Nov 26, 2019, at 6:13 PM, Vadim Chugunov via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> Hi,<br>
> I am trying to figure out the proper way of using LLDB's SBLaunchInfo class:<br>
> When I launch a process via CLI interpreter, it seems to receive all of the environment variables inherited from shell, plus the ones I set via `target.env-vars`:<br>
> <br>
> (lldb) file /usr/bin/env<br>
> Current executable set to '/usr/bin/env' (x86_64).<br>
> (lldb) set set target.env-vars 'FOO=BAR'<br>
> (lldb) run<br>
> Process 12733 launched: '/usr/bin/env' (x86_64)<br>
> FOO=BAR<br>
> GDM_LANG=en_US<br>
> CINNAMON_SOFTWARE_RENDERING=1<br>
> MUFFIN_NO_SHADOWS=1<br>
> <the rest of my environment variables><br>
> Process 12733 exited with status = 0 (0x00000000) <br>
> <br>
> But when I launch via SB API, it looks like only the values explicitly added to launch_info are passed to the debuggee:<br>
> <br>
> (lldb) script from lldb import *<br>
> (lldb) script t = lldb.debugger.CreateTarget('/usr/bin/env')<br>
> (lldb) script li = SBLaunchInfo([])<br>
> (lldb) script li.SetEnvironmentEntries(['FOO=BAR'], True)<br>
> (lldb) script t.Launch(li, SBError())<br>
> <lldb.SBProcess; proxy of <Swig Object of type 'lldb::SBProcess *' at 0x7fbc674ea0f0> ><br>
> FOO=BAR<br>
> Process 13331 exited with status = 0 (0x00000000) <br>
> <br>
> Is this how it's supposed to work?   If so, I can certainly add all inherited env vars to launch_info myself, but it isn't clear what to do in the case of remote debugging, because I couldn't find any way of retrieving environment from the remote machine.<br>
> <br>
> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br>
<br>
</blockquote></div>