This is the mail archive of the
mailing list for the elfutils project.
Re: frame unwinding patches
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- Cc: <elfutils-devel at sourceware dot org>
- Date: Tue, 11 Apr 2017 12:16:06 +0200
- Subject: Re: frame unwinding patches
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=qt.io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nDvytjgIfL+v79jmDxjbpSU+whz6TI3MT1SHYnaqU8Y=; b=SQbQ/M6mVHxEGK/i4ged8zAcz0tpVQMQin/IsMq/DvhEHeeD+zGtBs+tMWoq8kOcB0nWcJPM/xkM4pdrOvM/AxlocfS1UNGY3mTudOXCOzGOFk85Q0Ygnd8L1Yo1PSfZ/jHhVXumwbdjQgQ6zLo5oR2xseJ0cUdQ5dKfOmj4Wmw=
- References: <firstname.lastname@example.org> <3915502.JGE1jdPxOT@milian-kdab2> <email@example.com> <20170403211516.GB9584@stream> <firstname.lastname@example.org>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
> I do agree with Jan that frame pointer unwinding is notoriously
> untrustworthy. Even with some sanity checks it is hard to know whether
> you are doing a correct unwind. gdb gets away with it through pretty
> advanced frame sniffers, which take a lot of low-level compiler
> generation knowledge to get correct (and even then...). You only restore
> the pc, stack and frame pointer registers (maybe incorrectly). So
> afterwards, even if you got valid CFI data you might be stuck.
Yes, especially with mixed stack traces, where part of the stack has CFI and part of it doesn't, we quickly run into guesswork. I've regenerated the binaries as suggested, with the result being that raise() from libc actually has CFI, but doesn't set a frame pointer. So, the frame pointer unwinder can find raise() in the link register, but it sets up the FP register with the wrong value. Then raise() is unwound using CFI, which mixes up the registers some more. At that point we're lost. I don't see an easy way out of this.
I will keep a version of the frame unwinding for perfparser as it's still better than not unwinding at all, but I do understand that it's not really suitable for mainline elfutils.