[Dwarf-discuss] Referring to the stdin 'file' in .debug_macinfo sections

Matthew Gretton-Dann Matthew.Gretton-Dann
Mon Apr 25 04:51:58 GMT 2005


On Fri, 2005-04-22 at 20:05, Michael Eager wrote:
> Ron 603-884-2088 wrote:
> > Matthew.Gretton-Dann at arm.com wrote:
> >>What does the DWARF standard mean by the phrase 'a null string'?
> >>
> >>My initial interpretation is that this means a string of length zero. 
> >>However, section 6.2.4 item 11 (file_names) indicates that
> >>for the table of files:
> >>       
> >>       ...The last entry is followed by a single byte.
> >>
> >>This means that my interpretation of 'a null string' means that the
> >>file_names entry will get misinterpreted as the end of the file_names
> >>array and confuse the .debug_line state machine.
> >>
> >>If my understanding is correct above then there are three options open
> >>to us:
> >>
> >>    1. Use File ID 0 as a 'special' ID representing stdin
> >>    2. Use File ID (last + 1) as a 'special' ID representing stdin
> >>    3. Use DW_LNE_define_file to define a file with a zero-length null
> >>       name.
> >>
> >>Of these the third option is (the only?) one which meets with the
> >>current specification's requirements.
> >>
> >>Have I interpreted the standard correctly?  If so should option 1 or 2
> >>be made legal (I would suggest not)?  In any event does the standard
> >>need some clarification?
> > 
> > 
> > I believe you have interpreted the standard correctly.
> > 
> > I have confirmed that GEM-based compilers on Alpha Linux do fall into
> > the trap of generating a null file name that gets misinterpreted as the
> > end of list marker.
> > 
> > It would be interesting to hear how other implementations handle this.

The ARM RealView compiler uses the filename '<stdin>'.  And it was in an
attempt to correct this that I came across the issue.

> > > Recommending use of DW_LNE_define_file feels like a very heavyweight
> > solution. But I don't have a good alternative to suggest at the moment.
> > A not so good alternative is
> > 
> >       4. Specify that a null byte that is not the last byte of the
> >          prologue according to the length field at the beginning of
> > 	 the prologue is a null file name rather than an end-of-list
> > 	 marker. [Probably makes it very hard to ever extend the
> > 	 contents of the prologue...]
> > 
> > Hmmm, mumble, grumble...
> 
> Yucka.  How about a dummy file name to represent stdin?  Like "-"?
> Requires changes to both compilers and debuggers to recognize this,
> but they were likely not handling it correctly before. :-)

This looks good, as most compilers I have ever come across take "-" on
its own to represent stdin. My only concern is whether "-" can be
specified as a real filename, and so cause a conflict.  Some
experimentation with ARM's compiler suggests that there is noway to do
so in that implementation.  This also seems true for the version of gcc
I'm using [1].

Thanks,

Matt

[1] I am not a gcc expert so there might be a way that I haven't come
across.

-- 
Matthew Gretton-Dann - Software Engineer
Compiler Tools Group - Development Systems
ARM Ltd
110 Fulbourn Rd
Cambridge
CB1 9NJ
UK
Phone: +44 1223 406103

This e-mail message is intended for the addressee(s) only and may
contain information that is the property of, and/or subject to a
confidentiality agreement between the intended recipient(s), their
organisation and/or the ARM Group of Companies. If you are not an
intended recipient of this e-mail message, you should not read, copy,
forward or otherwise distribute or further disclose the information in
it; misuse of the contents of this e-mail message may violate various
laws in your state, country or jurisdiction. If you have received this
e-mail message in error, please contact the originator of this e-mail
message via e-mail and delete all copies of this message from your
computer or network. Thank you




More information about the Dwarf-discuss mailing list