Page MenuHomePhabricator

Implement argv0-less getMainExecutable for FreeBSD
AcceptedPublic

Authored by emaste on Oct 8 2014, 8:01 PM.

Details

Reviewers
samsonov
joerg
Summary

The llvm-symbolizer patch in D5610 needs to call getMainExecutable without argv0.

Today this works on Linux, which reads /proc/self/exe, but does not on FreeBSD and other operating systems, which determine the exe name from argv0.

On FreeBSD the exe name can be found from the kern.proc.pathname sysctl. This probably works on other BSDs as well; others can confirm and update the #ifdefs.

Diff Detail

Event Timeline

emaste updated this revision to Diff 14622.Oct 8 2014, 8:01 PM
emaste retitled this revision from to Implement argv0-less getMainExecutable for FreeBSD.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added a reviewer: samsonov.
emaste added a subscriber: Unknown Object (MLST).
emaste updated this revision to Diff 14664.Oct 9 2014, 11:16 AM
emaste added a reviewer: joerg.

Add NetBSD #ifdefs

joerg edited edge metadata.Oct 9 2014, 11:32 AM

I would prefer using dl_iterate_phdr for this, I think.

I would prefer using dl_iterate_phdr for this, I think.

Ahh, good point - for some reason I thought it did not include the executable itself, but a quick test confirms it behaves as expected on FreeBSD stable/10 at least. That said, I don't see a guarantee that the first result returned is the executable.

joerg added a comment.Oct 9 2014, 12:34 PM

Hm. Right, it's not required to be. OK, I guess the sysctl is the best answer, __ps_strings might have a relative path or so.

samsonov accepted this revision.Oct 10 2014, 2:39 PM
samsonov edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 10 2014, 2:39 PM

Looks like patch was not committed.