[lldb-dev] Setting environment via SBLaunchInfo

Vadim Chugunov via lldb-dev lldb-dev at lists.llvm.org
Tue Nov 26 18:13:08 PST 2019


Hi,
I am trying to figure out the proper way of using LLDB's SBLaunchInfo class:
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`:

(lldb) file /usr/bin/env
Current executable set to '/usr/bin/env' (x86_64).
(lldb) set set target.env-vars 'FOO=BAR'
(lldb) run
Process 12733 launched: '/usr/bin/env' (x86_64)
FOO=BAR
GDM_LANG=en_US
CINNAMON_SOFTWARE_RENDERING=1
MUFFIN_NO_SHADOWS=1
<the rest of my environment variables>
Process 12733 exited with status = 0 (0x00000000)

But when I launch via SB API, it looks like only the values explicitly
added to launch_info are passed to the debuggee:

(lldb) script from lldb import *
(lldb) script t = lldb.debugger.CreateTarget('/usr/bin/env')
(lldb) script li = SBLaunchInfo([])
(lldb) script li.SetEnvironmentEntries(['FOO=BAR'], True)
(lldb) script t.Launch(li, SBError())
<lldb.SBProcess; proxy of <Swig Object of type 'lldb::SBProcess *' at
0x7fbc674ea0f0> >
FOO=BAR
Process 13331 exited with status = 0 (0x00000000)

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20191126/96857e05/attachment.html>


More information about the lldb-dev mailing list