|
From: Phillip B. <phi...@um...> - 2025-10-25 17:20:32
|
Can anyone try the short program below on older versions of Xcode and
MacOS? It would be interesting to see when the issue with lldb hiding the
setting of DYLD_IMAGE_SUFFIX started.
Also, does everyone see the same result that I see with MacOS 26 and the
latest Xcode?
To run the test, cut and paste the following into a file named runit.zsh:
### cut here ###
cat > hello.c <<!
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
char* var_value = getenv( "DYLD_IMAGE_SUFFIX" );
if ( var_value ) {
printf( "\nDYLD_IMAGE_SUFFIX is set to: %s\n", var_value );
} else {
printf( "\nDYLD_IMAGE_SUFFIX is not set\n\n" );
}
}
!
export DYLD_IMAGE_SUFFIX=_debug
cc -g hello.c
echo "\nRunning without lldb:"
./a.out
echo "\nRunning with lldb:"
lldb --batch -o run ./a.out
echo ""
### cut here ###
then run it with:
$ zsh runit.zsh
Of interest is whether it prints:
DYLD_IMAGE_SUFFIX is set to: _debug
for both executions of a.out, or just for the first one, printing:
DYLD_IMAGE_SUFFIX is not set
when run under lldb.
Phil
On Fri, Oct 24, 2025 at 9:01 PM Phillip Brooks <phi...@um...> wrote:
> More digging - this article seems to bear something of a partial
> explanation:
>
>
> https://stackoverflow.com/questions/33587130/why-doesnt-lldb-forward-my-environment-variable-anymore
>
> Though the article is about 10 years old. The article mentions that this
> restriction only occurs under certain circumstances, but I can't find any
> that it doesn't happen for. I finally got down to this short program. It
> is running as me, on my home directory (not a network share, not a mounted
> external volume, it's just my "Macintosh HD" home directory just as
> originally set up by Apple:
>
> % cat hello.c
>
> #include <stdio.h>
>
> #include <stdlib.h>
>
> #include <unistd.h>
>
>
> int main() {
>
> int mypid = getpid();
>
> printf( "PID=%d\n", mypid );
>
> char* var_value = getenv( "DYLD_IMAGE_SUFFIX" );
>
> if ( var_value ) {
>
> printf( "DYLD_IMAGE_SUFFIX is set to: %s\n", var_value );
>
> } else {
>
> printf( "DYLD_IMAGE_SUFFIX is not set\n" );
>
> }
>
> }
>
>
> pbrooks@Drakblar ~ % cc -g hello.c
>
> pbrooks@Drakblar ~ % ./a.out
>
> PID=37336
>
> DYLD_IMAGE_SUFFIX is set to: _debug
>
> pbrooks@Drakblar ~ % lldb ./a.out
>
> (lldb) target create "./a.out"
>
> Current executable set to '/Users/pbrooks/a.out' (arm64).
>
> (lldb) run
>
> Process 37339 launched: '/Users/pbrooks/a.out' (arm64)
>
> PID=37339
>
> DYLD_IMAGE_SUFFIX is not set
>
> Process 37339 exited with status = 0 (0x00000000)
>
> (lldb)
>
> So I can't find a case where lldb does not hide DYLD_IMAGE_SUFFIX. It
> seems like we should have a "debug" build of tclsh that links to Tcl_debug
> directly rather than relying on this environment variable.
>
>
>
>
>
>
>
|