From: Anton Blanchard <anton@samba.org>
To: "David Laight" <David.Laight@ACULAB.COM>
Cc: paulus@samba.org, linuxppc-dev@lists.ozlabs.org,
wschmidt@us.ibm.com, Alan Modra <amodra@gmail.com>
Subject: Re: BUG_ON and gcc don't mix
Date: Tue, 20 Aug 2013 20:55:48 +1000 [thread overview]
Message-ID: <20130820205548.1aea966b@kryten> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B72FF@saturn3.aculab.com>
Hi David,
> I was thinking that you could add the label after the trap and
> then use '.long 1b-4'. But you'd have to put the asm outside the
> conditional - so that wouldn't work if the condition was more
> complicated and the trap had to be out of line.
>
> If the trap is out of line, then it could be a long way from
> the surrounding code block - so a label 'nearby' in the C isn't
> any use.
>
> With fix sized instructions the .text segment of the object files
> could be scanned for trap instructions.
I tried something similar a while ago and the 1b-4 trick worked for
95%+ of cases but we did end up with out of line traps. I hacked
something up to look for an example, tagging the start and the end of a
BUG_ON, and seeing if the trap was in fact out of line:
asm volatile("1:\n");
if (x)
__builtin_trap();
asm volatile("2:\n");
And this one popped in arch/powerpc/platforms/powernv/pci-ioda.c:
1:
ld 9,0(29)
rlwinm. 8,9,0,29,30
beq- 0,.L287
2:
...
.L287:
trap
You could follow branches and look for the trap, but I'm sure you could
construct things that would be very hard to automatically parse, eg
multiple back to back BUG_ON()'s. At that point I figured some gcc help
would be nice :)
Anton
prev parent reply other threads:[~2013-08-20 10:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 2:37 BUG_ON and gcc don't mix Anton Blanchard
2013-08-20 4:24 ` Benjamin Herrenschmidt
2013-08-20 4:32 ` Alan Modra
2013-08-20 4:45 ` Alan Modra
2013-08-20 8:36 ` David Laight
2013-08-20 10:55 ` Anton Blanchard [this message]
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=20130820205548.1aea966b@kryten \
--to=anton@samba.org \
--cc=David.Laight@ACULAB.COM \
--cc=amodra@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
--cc=wschmidt@us.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).