GDB doesn't show the correct line
Daniel Jacobowitz
drow@false.org
Sat Nov 13 20:50:00 GMT 2004
On Mon, Jun 21, 2004 at 08:15:10PM +0200, Otto Wyss wrote:
> Daniel Jacobowitz wrote:
> >
> > > I can only speculate that it's because of one of the standard headers
> > > which are unique to this program. But they are from an ordinary
> > > Debian/sarge system. How can I detect further where the offset is introduced?
> >
> > The only things that I can recommend:
> > - Look at the preprocessor output (gcc -E). See if there are missing
> > #line directives (usually just "# <num>" in preprocessor output).
> > The syntax of these things is really hard to read.
> > - Look at the debug info with readelf -wl and compare it to the
> > object code.
> >
> Not a very nice prospect, I guess I won't be able to detect anything
> useful within resonable time :-(
>
> > It sounds like it is more likely to be a problem with GCC's output than
> > GDB's parsing.
> >
> I just inserted a syntax error in my source, at least GCC reports the
> correct line number.
>
> Can't this line number problem somehow detected within GDB? Sorry if I
> ask this as someone without knowing any internals but IMO this would be
> the best solution. My app is now working so I'm not in a hurry but a
> good debugger is _essential_ for any development.
It's no one's fault, I think. I tracked down the problem. You have
mixed newline conventions in the file: mostly "\n" as a line separator,
but in some places just "\r". GCC treats this as a line break for
legacy reasons (MacOS). 'less' doesn't, which really confused me while
trying to debug the problem. GDB doesn't, either.
Should GDB? I have no idea. But it's easiest to just fix the source
file to be consistent.
--
Daniel Jacobowitz
More information about the Gdb
mailing list