This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Major debugging breakage


> cc: gcc@gcc.gnu.org, geoffk@redhat.com
> Reply-To: law@redhat.com
> From: law@redhat.com
> Date: Thu, 03 Jan 2002 14:03:11 -0700
> 
>   > Something has been hosed with line numbers for a long time; Geoff
>   > seemed to think he knew what it was. 
> Yea, it was broken before gcc-3.0, so it's been awhile.  I've cc'd Geoff
> directly in the hopes that he'll chime in.

I'm sure it's caused by functions-as-trees.

> 
>   > I do know that what CPP tells
>   > the front end is definitely correct; so something, from
>   > cb_file_change() in c-lex.c down to the guts of GCC, is not using
>   > "lineno" correctly or getting mucked up for some reason.  Sadly, my
>   > knowledge of such parts of GCC is not good enough to suggest anything
>   > constructive.
> Every time we parse a token we update LINENO to be equal to SRC_LINENO
> (c_lex.c).   LINENO is used to initialize the line numbers in NOTEs
> that are used by the debug symbol routines.  The comments in cb_line_change
> seem to indicate that SRC_LINENO is meant to be used for diagnostic
> line numbers.  Maybe that is the root of our problem -- mixing the two
> purposes.
> 
> SRC_LINENO is updated at the start of every non-empty line via cb_line_change.

Yes, this is most likely the problem.

What we should be doing, in the case of this example, is producing
line numbers for every line.  If the user writes (as I sometimes do)

if ((fd = open ("foo", O_RDONLY)) < 0
    || read (fd, &buf, 7) != 7
    || read (fd, &bar, 12) != 12)
  perror ("problem reading foo");

then it'd be really nice if the debugger could step one line at a
time, rather than just doing the whole if condition in one hit.

The problem is that we don't really have places to store the
information.  We should probably be using EXPR_WITH_FILE_LOCATION.  If
we were, we could generate the EXPR_WITH_FILE_LOCATION when we started
parsing the expression, and at that point LINENO would be correct.

-- 
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]