Designs for better debug info in GCC
Joe Buck
Joe.Buck@synopsys.COM
Tue Dec 18 02:02:00 GMT 2007
On Mon, Dec 17, 2007 at 11:11:46PM -0200, Alexandre Oliva wrote:
> Line number information has a well-defined meaning: it ought to
> represent the source code line that best represents the source-code
> construct that ended up implemented using that instruction.
You implicitly assume that souch a source code line exists.
Consider something like
int func(bool cond, int a, int b, int c)
{
int out;
if (cond)
out = a + b;
else
out = a + b + c;
return out;
}
The optimizer might produce something that structurally resembles
out = a + b;
if (!cond)
out += c;
return out;
If you set a breakpoint on the addition of a and b, it will trigger
regardless of the value of cond. Furthermore, there isn't a place
to put a breakpoint that will trigger only for the case where cond
is true, as you can on unoptimized code. So you need to choose
between natural debugging and optimization.
More information about the Gcc
mailing list