David Blaikie via llvm-dev
2018-Aug-24 16:10 UTC
[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> 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] > *Sent:* Thursday, August 23, 2018 3:18 PM > *To:* 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 > 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/7ed05030/attachment.html>
Brian Cain via llvm-dev
2018-Aug-24 16:26 UTC
[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> Sent: Friday, August 24, 2018 11:10 AM To: paul.robinson at sony.com Cc: bcain at codeaurora.org; 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/352fb11d/attachment.html>
Brian Cain via llvm-dev
2018-Aug-24 17:45 UTC
[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> Sent: Friday, August 24, 2018 11:27 AM To: 'David Blaikie' <dblaikie at gmail.com>; 'paul.robinson at sony.com' <paul.robinson at sony.com> Cc: 'llvm-dev at lists.llvm.org' <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/df3486ca/attachment-0001.html>
via llvm-dev
2018-Aug-24 18:07 UTC
[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 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> Sent: Friday, August 24, 2018 11:27 AM To: 'David Blaikie' <dblaikie at gmail.com>; 'paul.robinson at sony.com' <paul.robinson at sony.com> Cc: 'llvm-dev at lists.llvm.org' <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/0d137381/attachment.html>