Merging calls to `abort'
James E Wilson
wilson@specifixinc.com
Sun Mar 13 01:07:00 GMT 2005
Richard Stallman wrote:
> Currently, I believe, GCC combines various calls to abort in a single
> function, because it knows that none of them returns.
To give this request a little context, consider the attached example.
If I compile this with -O2 -g, and run it under the debugger, it tells
me that the program died at line 7 (j == 0) which is impossible. It is
easy to tell what went wrong in a trivial example like this, but in a
big program like gcc this can be very confusing. This reduces the
usefulness of using abort in combination with -g and optimization.
The optimization that causes the problem is crossjumping. If I compile
with -O2 -fno-crossjumping I get the desired result. So rms's request
is essentially to disable crossjumping of abort calls.
Incidentally, we have already pushed crossjumping back from -O to -O2.
If I use gcc-3.3, the example fails with -O -g. But with gcc-4, it
works at -O -g and fails only at -O2 (or -Os) -g. Since -O -g works
with current sources, perhaps this is a good enough solution. Or
perhaps just asking people to use -fno-crossjumping is a good enough
solution.
Otherwise, we need to consider the merits of disabling an optimization
to make debugging easier. This is a difficult choice to make, but at
-O2, I'd prefer that we optimize, and suggest other debugging techniques
intead of relying on the line numbers of abort calls. Such as using
assert instead.
I suppose there is yet another alternative, which is to extend the debug
info to indicate that the single abort call is both line 5 and line 7,
and then extend gdb to handle this gracefully, but this does not seem to
be a practical solution, at least not a practical short term one.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc
mailing list