xhprof: backport section profiler fixes

Backport the fixes from Ibb3d0ce836d30663c511809b6e1dece4baa4da92 and
I06e5b3d82cfddd1a407c56819c9bdd91f160e928

Change-Id: I5935ee2965a338957a66a771b2cd2b290a61a924
(cherry picked from commit a6f973e669ee99029ca301ef14ef55933bcc6f42)