This is the mail archive of the mailing list for the binutils 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: [PATCH] inconsistent DWARF2 sections generated by --gdwarf2

Replying to several messages at once here....

Nick Clifton wrote:
I do not think so - the DWARF standard does specify that there there
should be a correspondence between the compilation units in the .debug_info
section and the compilation units in the .debug_line section:

I agree with this. Before submitting the patch, I considered Alan's suggestion that this is a bug in readelf, and regardless of what GAS generates, it does seem that readelf should only look for .debug_line sections that are referenced from .debug_info sections. I'm not going to tackle that change now. After reading the DWARF spec, I think it would be best to fix GAS. I agree with Alan that the current situation is not explicitly prohibited by the DWARF spec, but keeping .debug_line sections tied to .debug_info sections would seem to better follow the spirit of the spec.

Alan Modra wrote:
On Thu, Nov 18, 2004 at 09:22:37AM +0000, Nick Clifton wrote:
Does that make sense though ? A .debug_line compilation unit which does not correspond to any .debug_info compilation unit ? What lines would it be describing ? Why would these lines exist without any debug info ?

.debug_line by itself gives you a mapping between addresses and source file line numbers. That might be all a tool needs.

That's irrelevant, though, because the situation in question occurs only when there is no debug line info. dwarf2_finish is currently writing an (empty) .debug_line section even when there is no line number data. The whole point of the patch is to fix that! (Sorry, I guess I didn't make that clear earlier.)

Nick Clifton wrote:
As for the patch itself - I am not so sure.  It looks to me like there might
be problems when -gdwarf2 is not specified on the command line. ie GAS might
still generate dwarf2 debug sections.  I would need to have a look at this
and I am really swamped at the moment. :-(   Bob - could you try a few more
tests of your patch please ?  Say with various different -gxxx command line
switches specified ?

I just tried --gstabs and --gstabs+ for several input files, and I don't see any problems.

I think your concern is misplaced, i.e., the patch might not be correct, but it shouldn't cause GAS to generate "extra" dwarf2 debugging output. Look at it this way: the patch removes one of the conditions required for dwarf2_finish to return without doing anything. It can only increase the number of situations where dwarf2_finish does nothing.

Daniel Jacobowitz wrote:
Bob's original mail said it was harmless for GDB - but that's not true.
GDB will only read line number data associated with some compilation

Well, I said it was *probably* harmless, and from what you say, I still think that. GDB will ignore the "orphan" .debug_line section, but that's fine -- there's nothing there for GDB to see anyway.

Is there any reason not to emit a compilation unit, if there isn't one already, and there is line number data?

No, there is no reason not to emit a comp unit in that case, and it will be emitted in that case, both with and without my patch. The patch is intended to address only the case where there is no line number data.

I hope that clears things up a bit. As far as I can tell, this shouldn't be a big deal -- it's just tidying up an unusual corner case.


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