This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


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

Re: [rfa] Change line to long


On Feb 1,  5:00pm, Michael Elizabeth Chastain wrote:

> > In this case, the rule would mean that the type of
> > ``line'' should be at least as wide as an unsigned long (because
> > that's what is used in dwarf2read.c).
> 
> Right now dwarf2read.c silently shortens from the line numbers from
> unsigned long to unsigned int:
> 
>   /* read_file_scope */
>   unsigned int line_offset = 0;
>   ...
>   line_offset = DW_UNSND (attr);

Actually, I was referring to the declaration of ``line'' in
dwarf_decode_lines () in dwarf2.c.  But now that I look at it again, I
see it's declared as an unsigned int.  (Which is not what I thought I
saw the first time I looked at it.)  However, this variable also
suffers from a narrowing similar to the one you found above.

      unsigned int line = 1;
	    ...
	    case DW_LNS_advance_line:
	      line += read_signed_leb128 (abfd, line_ptr, &bytes_read);

where read_signed_leb128() is declared to return a long.

If you look at decode_line_numbers() in dwarfread.c, you will see
that ``line'' is declared to be an unsigned long and that it is
passed to record_line().

> IMHO we may as well make the native gdb width 'unsigned int' and then,
> when we find them, add errors or warnings in the case where gdb reads
> a line number and it exceeds the bounds of the representation.

I still think it'd be nice if we could somehow guarantee that line
numbers are represented with at least 31 bits.  I agree that it's
important to provide the user with an error/warning when a line number
(or anything else for that matter) can't be accurately represented in
the space that gdb allocates for it.

Kevin

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