| Summary: | valgrind should have a mean to pass environment variable to target program | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | Yann Droneaud <yann> |
| Component: | general | Assignee: | Julian Seward <jseward> |
| Status: | REPORTED --- | ||
| Severity: | wishlist | CC: | fche, pjfloyd |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Yann Droneaud
2019-08-23 12:02:19 UTC
It shouldn't be difficult to implement, but it's a bit tricky as valgrind launcher already communicate with each tool through environment variables. So environment variable to be added/removed from tracee environment have to be encoded in environment variables passed to valgrind's tool. I've to find how (and where) to implement this. (In reply to Yann Droneaud from comment #0) > Unfortunately, AFAICT, valgrind doesn't have (yet) support for altering the > tracee environment variables. Why do you say that? AFAIK, V passes the env vars to the program it is running. (In reply to Julian Seward from comment #2) > (In reply to Yann Droneaud from comment #0) > > > Unfortunately, AFAICT, valgrind doesn't have (yet) support for altering the > > tracee environment variables. > > Why do you say that? AFAIK, V passes the env vars to the program it is > running. It's not possible to add/remove variables to the tracee's environment only. For example, if I want to enable LD_VERBOSE=1 (only) for test-program to be traced, doing "LD_PROFILE=1 valgrind test-program" will affect valgrind too. strace has the -E option that enable to set environment variables only for the program to be traced. See http://man7.org/linux/man-pages/man1/strace.1.html#OPTIONS Valgrind certainly can change the guest environment. For a start Valgrind is responsible for synthesizing the guest stack which includes argv, envp, and auxv. As necessary it will either add or modify LD_PRELOAD and GLIBC_TUNABLES (on Linux, LD_32_PRELOAD and DYLD_INSERT_LIBRARIES on other platforms). In addition the launcher will add or modify VALGRIND_LIB. Another case where this sort of feature would be useful relates to debuginfod. We may need a way of passing $DEBUGINFOD_URLS only to valgrind or only to the target process (depending on what it is we're trying to debug). Consider a command line option scheme kind of like docker's or /bin/env's: valgrind -e ENV1= -e ENV2=foo /bin/target which could mean "drop ENV1 from, and override ENV2=foo in, valgrind's environment" It would probably be easiest to do this in valgrind itself. It already does this to insert LD_PRELOADs for the core and tool vgpreaload libs. |