[llvm-dev] [assembler + debuginfo] interaction with .file directive and debuginfo

Brian Cain via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 24 16:11:55 PDT 2018


Done.  PR38695.

 

I’ll give it a try and reach out if I need help.

 

-Brian

 

From: paul.robinson at sony.com <paul.robinson at sony.com> 
Sent: Friday, August 24, 2018 1:08 PM
To: bcain at codeaurora.org; dblaikie at gmail.com
Cc: llvm-dev at lists.llvm.org
Subject: RE: [llvm-dev] [assembler + debuginfo] interaction with .file directive and debuginfo

 

Awesome, couldn't have a clearer example.  Can you file a bug for this?  Product: libraries, component: MC.

Feel free to have a run at it yourself, if you don't want to wait a couple months.

Thanks!

--paulr

 

From: Brian Cain [mailto:bcain at codeaurora.org] 
Sent: Friday, August 24, 2018 10:45 AM
To: 'David Blaikie'; Robinson, Paul
Cc: llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> 
Subject: RE: [llvm-dev] [assembler + debuginfo] interaction with .file directive and debuginfo

 

gcc as of 8.1 still behaves the same as clang 6.

 

$ cat file_.S 

//.file 1 "file.S"

.file "file_other.S"

.text

 

f1:

              nop

.size f1, .-f1

 

$ /local/mnt/workspace/install/gcc-8.1/bin/gcc-8.1 -g -o out.o -c file_.S ; objdump -t out.o 

 

out.o:     file format elf64-x86-64

 

SYMBOL TABLE:

0000000000000000 l    df *ABS*              0000000000000000 file_other.S

0000000000000000 l    d  .text   0000000000000000 .text

0000000000000000 l    d  .data  0000000000000000 .data

0000000000000000 l    d  .bss    0000000000000000 .bss

0000000000000000 l       .text     0000000000000001 f1

0000000000000000 l    d  .debug_info    0000000000000000 .debug_info

0000000000000000 l    d  .debug_abbrev             0000000000000000 .debug_abbrev

0000000000000000 l    d  .debug_line    0000000000000000 .debug_line

0000000000000000 l    d  .debug_aranges           0000000000000000 .debug_aranges

 

 

$ /local/mnt/workspace/install/clang_nightly_2018_Jul27/bin/clang  -g -o out.o -c file_.S ; objdump -t out.o 

 

out.o:     file format elf64-x86-64

 

SYMBOL TABLE:

0000000000000000 l    df *ABS*              0000000000000000 file_other.S

0000000000000000 l       .text     0000000000000001 f1

 

 

 

From: Brian Cain <bcain at codeaurora.org <mailto:bcain at codeaurora.org> > 
Sent: Friday, August 24, 2018 11:27 AM
To: 'David Blaikie' <dblaikie at gmail.com <mailto:dblaikie at gmail.com> >; 'paul.robinson at sony.com' <paul.robinson at sony.com <mailto:paul.robinson at sony.com> >
Cc: 'llvm-dev at lists.llvm.org' <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> >
Subject: RE: [llvm-dev] [assembler + debuginfo] interaction with .file directive and debuginfo

 

gcc as of 4.2.4 generates the debuginfo even with “.file” (as did clang 6.0.0).  I’ll check a modern gcc.

 

From: David Blaikie <dblaikie at gmail.com <mailto:dblaikie at gmail.com> > 
Sent: Friday, August 24, 2018 11:10 AM
To: paul.robinson at sony.com <mailto:paul.robinson at sony.com> 
Cc: bcain at codeaurora.org <mailto:bcain at codeaurora.org> ; llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> 
Subject: Re: [llvm-dev] [assembler + debuginfo] interaction with .file directive and debuginfo

 

What does gcc do?

 

On Fri, Aug 24, 2018 at 9:05 AM via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > wrote:

There are two forms of the .file directive.  One is simply

               .file "path"

and the other is

               .file <file-number> [ "dir"] "path" [ …. other stuff ]

 

The latter is sometimes referred to as the "DWARF" form of the .file directive.  I don't know the history about the different forms. I have certainly messed with the latter form to accommodate the needs of DWARF v5.

 

I think it's pretty certain that the DWARF form of .file means that the .s file was generated with debug info, and therefore the correct behavior of "clang –g foo.s" in that case is to ignore the –g and assume the assembler source has all the right stuff.

 

If the older form of .file can mean nothing more than "emit a file symbol" and not imply that the assembler source file itself already contains debug info, then seeing that form should not cause the assembler to ignore –g.  But as I said, I don't know the history and I don't understand how the first form is generally used.

 

I'm quite willing to believe I did not understand the (largely unstated) specification for the non-DWARF form of .file, and if others agree that it should not imply that debug info already exists, then reporting that as a bug is appropriate.  I can't say I'd be able to find time to try to *fix* it before October, as I'm already over-committed, but I'd anticipate getting to it around that time.

--paulr

 

From: bcain at codeaurora.org <mailto:bcain at codeaurora.org>  [mailto:bcain at codeaurora.org <mailto:bcain at codeaurora.org> ] 
Sent: Thursday, August 23, 2018 3:18 PM
To: llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> 
Cc: Robinson, Paul
Subject: [assembler + debuginfo] interaction with .file directive and debuginfo 

 

[ I discussed this briefly with Paul off list and he suggested it would be better here. ]

 

Among the changes in 7.0.0 are some that were added to support DWARFv5’s .debug_line.   

 

The presence of “.file” mutes debug info generated by the assembler as of r328208 – logic in AsmParser::enabledGenDwarfForAssembly().

 

The comment there states: “If we haven't encountered any .file directives (which would imply that the assembler source was produced with debug info already) then emit one describing the assembler source file itself.”

 

Does .file imply that the assembly source was already produced with debug info?  Perhaps not in all cases.  If you wanted to emit an ELF::STT_FILE into your object, for example, you might add ```.file "foo.s"```.

 

I think we should change this behavior to the previous – check for “-g” but ignore “.file” directives.   Or maybe there’s a compromise to be found among the different versions of “.file” with various args?  Thoughts?

 

-Brian

_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> 
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180824/ff11ec1a/attachment.html>


More information about the llvm-dev mailing list