From: David Mosberger <davidm@hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] Unwind problem for __attribute__ noreturn
Date: Wed, 21 Mar 2001 17:54:47 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590693005317@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590693005303@msgid-missing>
Keith,
We are dealing with two problems here, both have a solution but the
solutions are conflicting:
Problem A: "noreturn" optimization confuses kernel unwinder because
return address is not inside the caller.
Solution A: Emit a dummy instruction after the last "br.call" in a
"no return" routine. Downside: requires generating extra
code with no purpose other than to make unwinding work
Problem B: "last-call" type optimizations confuse the gcc unwinder
because decrementing the return address does not yield
an address inside the caller.
Solution B: Don't decrement return pointer when determining the
caller. Downside: requires that the frame state
immediately before and after a br.call is identical.
I agree that manipulating the return pointer seems like a bad idea.
Especially on IA-64 where there is no way of reliably determining
which of the three instruction in a bundle was the one that called a
function. But generating dummy code just for the purpose of unwinding
doesn't seem 100% right either, as the unwind convention were
expressedly designed to work with fully optimized code.
Anyhow, I'll re-read the unwind conventions when I'm back at work.
Either the document answers this question unambigiously and one of the
existing unwinder implementation is wrong, or it doesn't answer the
question, in which case we need to pick one solution and work towards
clarifying this point in the manual.
--david
>>>>> On Wed, 21 Mar 2001 19:54:20 +1100, Keith Owens <kaos@ocs.com.au> said:
Keith> On Tue, 20 Mar 2001 23:54:44 -0800, David Mosberger
Keith> <davidm@hpl.hp.com> wrote:
>> I also doubt that adding "nop"s in the compiler is the right
>> solution.
Keith> After more thought, the problem of attribute ((noreturn))
Keith> affects all architectures, all debuggers and all programs.
Keith> It is not just ia64 + kdb + kernel that has this problem. An
Keith> unconditional call to function F which is declared noreturn
Keith> is converted by gcc into this
Keith> A: ... call F X: ...
Keith> which will cause problems for all debuggers on all
Keith> architectures. The return address is pointing at the start
Keith> of X but F was really called by A.
Keith> It is not valid to always subtract 1 from the return address
Keith> because programmers are allowed to do this in assembler.
Keith> A: ret = B goto F X: ... B: ...
Keith> F cannot assume that it was entered via call, it can be
Keith> entered by any hand coded construct that gives the same
Keith> environment as a call, even if the return is not to the code
Keith> that branched to F. Subtracting 1 from ret in this case
Keith> would give B-1 which appears to be in X and is wrong.
Keith> Given these two methods of entering a function there is no
Keith> way for a debugger to adjust the return address correctly in
Keith> all cases. Because the problem case only occurs in C when
Keith> function F is declared noreturn, a change to gcc to emit
Keith> A: ... call F nop X: ...
Keith> if and only if
Keith> (1) F is declared noreturn and (2) gcc is discarding the
Keith> rest of the function that calls F
Keith> will fix the problem. The extra nop is only required to
Keith> avoid a call as the very last instruction of a function so it
Keith> has very little impact on the size of most programs. It has
Keith> zero impact on the speed of the programs because the nop is
Keith> never executed, it is just a padding code.
next prev parent reply other threads:[~2001-03-21 17:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-20 2:10 [Linux-ia64] Unwind problem for __attribute__ noreturn Keith Owens
2001-03-21 0:24 ` Jim Wilson
2001-03-21 6:03 ` Keith Owens
2001-03-21 6:53 ` David Mosberger
2001-03-21 7:12 ` Jim Wilson
2001-03-21 7:54 ` David Mosberger
2001-03-21 8:54 ` Keith Owens
2001-03-21 17:54 ` David Mosberger [this message]
2001-03-21 18:48 ` Cary Coutant
2001-03-21 19:07 ` Jim Wilson
2001-03-21 19:13 ` David Mosberger
2001-03-21 19:13 ` Jim Wilson
2001-03-21 19:26 ` Cary Coutant
2001-03-21 19:40 ` Jim Wilson
2001-03-21 19:58 ` David Mosberger
2001-03-21 20:00 ` Jim Wilson
2001-03-21 20:38 ` Jim Wilson
2001-03-21 22:54 ` David Mosberger
2001-03-21 23:42 ` Cary Coutant
2001-03-22 17:00 ` Rich Altmaier
2001-03-23 20:28 ` Jim Wilson
2001-03-24 0:58 ` Cary Coutant
2001-03-24 1:27 ` Keith Owens
2001-03-24 1:37 ` Jim Wilson
2001-03-26 22:06 ` DE-DINECHIN,CHRISTOPHE (HP-Cupertino,ex1)
2001-03-26 22:58 ` Cary Coutant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-ia64-105590693005317@msgid-missing \
--to=davidm@hpl.hp.com \
--cc=linux-ia64@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox