Recently I saw the test TestCases/Posix/print_cmdline.cc failing on
FreeBSD, with "expected string not found in input". This is because
asan could not retrieve the command line arguments properly.
In lib/sanitizer_common/sanitizer_linux.cc, this is taken care of by
the GetArgsAndEnv() function, but it uses __libc_stack_end to get at
the required data. This variable does not exist on BSDs; the regular
way to retrieve the arguments and environment information is via the
kern.ps_strings sysctl.
I added this functionality in sanitizer_linux.cc, as a separate #ifdef
block in GetArgsAndEnv(). Also, ReadNullSepFileToArray() becomes
unused due to this change. (It won't work on FreeBSD anyway, since
/proc is not mounted by default.)
Can you please add a comment explaining what this function is doing for first-readers who don't know sysctl&friends ?