[lldb-dev] lldb-mi doesn't propagate host environment variables

Jim Ingham via lldb-dev lldb-dev at lists.llvm.org
Mon Jul 2 08:32:20 PDT 2018


In lldb, this behavior is controlled by the setting:

target.inherit-env

Passing debugger environment is equal parts handy (getting a DISPLAY variable right for instance) and a cause for confusion.  Not sure which is the most useful default.  lldb defaults to true.  But I can see an argument that for a server type program like lldb-mi it is better to be explicit about it.

Jim


> On Jun 29, 2018, at 5:03 AM, k.baladurin via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Hello!
> 
> lldb-mi doesn't propagate host environment variables while lldb does it:
> 
> $ cat env.c
> #include <stdio.h>
> #include <stdlib.h>
> 
> int main()
> {
>     printf("VAR = %s\n", getenv("VAR"));
>     return 0;
> }
> $ gcc env.c -o env
> $ /home/kbaladurin/Downloads/llvm-x64-7.0/bin/lldb -v
> lldb version 7.0.0
> $ VAR=1 /home/kbaladurin/Downloads/llvm-x64-7.0/bin/lldb env
> (lldb) target create "env"
> Current executable set to 'env' (x86_64).
> (lldb) r
> Process 13139 launched: '/home/kbaladurin/Desktop/tests/env' (x86_64)
> VAR = 1
> Process 13139 exited with status = 0 (0x00000000)
> (lldb) ^D
> $ VAR=1 /home/kbaladurin/Downloads/llvm-x64-7.0/bin/lldb-mi
> (gdb)
> -file-exec-and-symbols env
> ^done
> (gdb)
> =library-loaded,id="/home/kbaladurin/Desktop/tests/env",target-name="/home/kbaladurin/Desktop/tests/env",host-name="/home/kbaladurin/Desktop/tests/env",symbols-loaded="0",loaded_addr="-",size="0"
> -exec-run
> ^running
> =thread-group-started,id="i1",pid="13176"
> (gdb)
> =thread-created,id="1",group-id="i1"
> =thread-selected,id="1"
> (gdb)
> =library-loaded,id="/lib/x86_64-linux-gnu/ld-2.23.so",target-name="/lib/x86_64-linux-gnu/ld-2.23.so",host-name="/lib/x86_64-linux-gnu/ld-2.23.so",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",loaded_addr="-",size="0"
> (gdb)
> =library-loaded,id="[vdso]",target-name="[vdso]",host-name="[vdso]",symbols-loaded="1",symbols-path="",loaded_addr="0x00007ffff7ffa000",size="0"
> (gdb)
> =library-loaded,id="/home/kbaladurin/Desktop/tests/env",target-name="/home/kbaladurin/Desktop/tests/env",host-name="/home/kbaladurin/Desktop/tests/env",symbols-loaded="0",loaded_addr="-",size="0"
> (gdb)
> *running,thread-id="all"
> (gdb)
> (gdb)
> =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",loaded_addr="-",size="0"
> (gdb)
> =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",loaded_addr="-",size="0"
> @"VAR = (null)\r\n"
> (gdb)
> =thread-exited,id="1",group-id="i1"
> =thread-group-exited,id="i1",exit-code="0"
> *stopped,reason="exited-normally"
> (gdb)
> 
> Is it expected behavior?
> 
> Thank you!
> 
> BR,
> Konstantin Baladurin
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev



More information about the lldb-dev mailing list