|
From: Paul F. <pa...@so...> - 2026-03-10 08:44:30
|
https://sourceware.org/cgit/valgrind/commit/?id=f2e586bef842ab8d6c7402ef95b417886d9bc39a commit f2e586bef842ab8d6c7402ef95b417886d9bc39a Author: Paul Floyd <pj...@wa...> Date: Tue Mar 10 09:41:01 2026 +0100 Darwin: add printing function for env and apple pointer area Change DEBUG_ENV_APPLE to use it. It will print env and the apple pointer area at the start of setup_client_stack (what we get from 'valgrind' and the OS) and at the end of the same function (what we give tot he client). Diff: --- coregrind/m_initimg/initimg-darwin.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/coregrind/m_initimg/initimg-darwin.c b/coregrind/m_initimg/initimg-darwin.c index d0c6c464ac..e09cdf7bc0 100644 --- a/coregrind/m_initimg/initimg-darwin.c +++ b/coregrind/m_initimg/initimg-darwin.c @@ -50,6 +50,35 @@ #include "pub_core_pathscan.h" /* find_executable */ #include "pub_core_initimg.h" /* self */ +// change this to one to see the env/apple pointer area that Darwin gives us +// and also the env and apple pointer area that we pass on to the guest +#define DEBUG_ENV_APPLE 0 + +#if (DEBUG_ENV_APPLE) +static void print_env_apple(HChar** envp, const HChar* where) +{ + int i; + int j; + HChar** apple; + VG_(printf)("Start env and apple pointer strings at %s\n", where); + + for (i = 0; envp[i]; ++i) { + VG_(printf)("i %d &envp[i] %p envp[i] %s\n", i, &envp[i], envp[i]); + } + // should be NULL + VG_(printf)("i %d &envp[i] %p envp[i] %s\n", i, &envp[i], envp[i]); + + apple = &envp[i]; + ++apple; + + for (j = 0; apple[j]; ++j) { + VG_(printf)("j %d &apple[j] %p apple[j] %s\n", j, &apple[j], apple[j]); + } + VG_(printf)("j %d &apple[j] %p apple[j] %s\n", j, &apple[j], apple[j]); + VG_(printf)("End env and apple pointer strings at %s\n", where); +} +#endif + /*====================================================================*/ /*=== Loading the client ===*/ @@ -514,6 +543,10 @@ Addr setup_client_stack( void* init_sp, } } +#if (DEBUG_ENV_APPLE) + print_env_apple(VG_(client_envp), "final envp"); +#endif + /* client_SP is pointing at client's argc/argv */ if (0) VG_(printf)("startup SP = %#lx\n", client_SP); @@ -615,6 +648,10 @@ IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo iicii, load_client(&info, &iifii.initial_client_IP); +#if (DEBUG_ENV_APPLE) + print_env_apple(iicii.envp, "original envp"); +#endif + //-------------------------------------------------------------- // Set up client's environment // p: set-libdir [for VG_(libdir)] |