Wrap getenv and append euid to GCOV_PREFIX

The coverage runtime creates coverage files with permissions 0644 and
intermediate directories with 0755.  This causes conflicts and
permissions issues when multiple processes create/access the same file
or directory under $GCOV_PREFIX.  Some processes also call umask, which
further complicates things.

It is possible to handle all of these in the coverage runtime library
but a foolproof alternative is to have a separate coverage directory per
effective userid (euid) by customizing GCOV_PREFIX.

This change adds a wrapper to getenv which appends the euid of the
current process for the "GCOV_PREFIX" environment variable.

Bug: 148178774
Test: Verify that coverage files are written to
/data/misc/trace/<euid>/proc/... instead of /data/misc/trace/proc/...

Change-Id: I6be1e748618d84697c354516ab1c734fb33ab5f4
Merged-In: I6be1e748618d84697c354516ab1c734fb33ab5f4
(cherry picked from commit a277ce976288ac0a35a9016970f6e49037eaeadb)
2 files changed