-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DW_TAG_formal_parameter always has DW_AT_decl_line == 1 #45010
Comments
Historically, 1.11.0 looked more like I would expect, with the right line numbers on the formal parameters and no extra local variables. $ rustc +1.11.0 -g line.rs --emit=llvm-ir && sed -n '/DIComp/,$p' line.ll
!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "rustc version 1.11.0 (9b21dcd6a 2016-08-15)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
!1 = !DIFile(filename: "./line.rs", directory: "/tmp")
!2 = !{}
!3 = !{!4}
!4 = distinct !DISubprogram(name: "foo", linkageName: "_ZN4line3fooE", scope: !6, file: !5, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, templateParams: !2, variables: !2)
!5 = !DIFile(filename: "/tmp/line.rs", directory: "/tmp")
!6 = !DINamespace(name: "line", scope: null)
!7 = !DISubroutineType(types: !8)
!8 = !{!9, !9, !9}
!9 = !DIBasicType(name: "i32", size: 32, align: 32, encoding: DW_ATE_signed)
!10 = !{i32 2, !"Debug Info Version", i32 3}
!11 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 3, type: !9)
!12 = !DIExpression()
!13 = !DILocation(line: 3, scope: !4)
!14 = !DILocalVariable(name: "y", arg: 2, scope: !4, file: !5, line: 4, type: !9)
!15 = !DILocation(line: 4, scope: !4)
!16 = !DILocation(line: 6, scope: !17)
!17 = distinct !DILexicalBlock(scope: !4, file: !5, line: 6)
!18 = !DILocation(line: 6, scope: !4) In 1.12.0, it added the extra locals, and the formal parameters took on line 2 like the subprogram. $ rustc +1.12.0 -g line.rs --emit=llvm-ir && sed -n '/DIComp/,$p' line.ll
!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "rustc version 1.12.0 (3191fbae9 2016-09-23)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "./line.rs", directory: "/tmp")
!2 = !{}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = distinct !DISubprogram(name: "foo", linkageName: "_ZN4line3fooE", scope: !6, file: !5, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, templateParams: !2, variables: !2)
!5 = !DIFile(filename: "/tmp/line.rs", directory: "/tmp")
!6 = !DINamespace(name: "line", scope: null, file: !7)
!7 = !DIFile(filename: "<unknown>", directory: "")
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10, !10}
!10 = !DIBasicType(name: "i32", size: 32, align: 32, encoding: DW_ATE_signed)
!11 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 2, type: !10)
!12 = !DIExpression()
!13 = !DILocation(line: 2, scope: !4)
!14 = !DILocalVariable(name: "y", arg: 2, scope: !4, file: !5, line: 2, type: !10)
!15 = !DILocalVariable(name: "x", scope: !16, file: !5, line: 3, type: !10)
!16 = distinct !DILexicalBlock(scope: !4, file: !5, line: 6)
!17 = !DILocation(line: 3, scope: !16)
!18 = !DILocalVariable(name: "y", scope: !16, file: !5, line: 4, type: !10)
!19 = !DILocation(line: 4, scope: !16)
!20 = !DILocation(line: 3, scope: !4)
!21 = !DILocation(line: 4, scope: !4)
!22 = !DILocation(line: 6, scope: !16)
!23 = !DILocation(line: 2, scope: !16) Then 1.13.0 shows the line 1 behavior like the current nightly. $ rustc +1.13.0 -g line.rs --emit=llvm-ir && sed -n '/DIComp/,$p' line.ll
!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "rustc version 1.13.0 (2c6933acc 2016-11-07)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "./line.rs", directory: "/tmp")
!2 = !{}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = distinct !DISubprogram(name: "foo", linkageName: "_ZN4line3fooE", scope: !6, file: !5, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, templateParams: !2, variables: !2)
!5 = !DIFile(filename: "/tmp/line.rs", directory: "/tmp")
!6 = !DINamespace(name: "line", scope: null, file: !7)
!7 = !DIFile(filename: "<unknown>", directory: "")
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10, !10}
!10 = !DIBasicType(name: "i32", size: 32, align: 32, encoding: DW_ATE_signed)
!11 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 1, type: !10)
!12 = !DIExpression()
!13 = !DILocation(line: 1, scope: !4)
!14 = !DILocalVariable(name: "y", arg: 2, scope: !4, file: !5, line: 1, type: !10)
!15 = !DILocalVariable(name: "x", scope: !16, file: !5, line: 3, type: !10)
!16 = distinct !DILexicalBlock(scope: !4, file: !5, line: 6)
!17 = !DILocation(line: 3, scope: !16)
!18 = !DILocalVariable(name: "y", scope: !16, file: !5, line: 4, type: !10)
!19 = !DILocation(line: 4, scope: !16)
!20 = !DILocation(line: 3, scope: !4)
!21 = !DILocation(line: 4, scope: !4)
!22 = !DILocation(line: 6, scope: !16)
!23 = !DILocation(line: 2, scope: !16) |
With the latest nightly, it no longer has the extra local declarations (perhaps thanks to #44573), but the formal-parameter line numbers are still just 1.
$ rustc +nightly -g line.rs --emit=llvm-ir
$ sed -n '/DIComp/,$p' line.ll
!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "clang LLVM (rustc version 1.23.0-nightly (ee2286149 2017-11-07))", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "line.rs", directory: "/tmp")
!2 = !{}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = distinct !DISubprogram(name: "foo", linkageName: "_ZN4line3fooE", scope: !5, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, templateParams: !2, variables: !2)
!5 = !DINamespace(name: "line", scope: null, file: !6)
!6 = !DIFile(filename: "<unknown>", directory: "")
!7 = !DISubroutineType(types: !8)
!8 = !{!9, !9, !9}
!9 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed)
!10 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !1, line: 1, type: !9)
!11 = !DIExpression()
!12 = !DILocation(line: 1, scope: !4)
!13 = !DILocalVariable(name: "y", arg: 2, scope: !4, file: !1, line: 1, type: !9)
!14 = !DILocation(line: 6, scope: !4)
|
This was fixed in Rust 1.40 (godbolt). wg-debugging would like to see a codegen test added to prevent regressions and then this can be closed. |
It seems that Rust debuginfo always writes
decl_line
of 1 for formal parameters.With this
line.rs
:With:
I get this output:
So it describes the formal parameters of
x
andy
both with line 1, but also describes local variables with the correct lines 3 and 4.In LLVM IR it looks like this, with the wrong lines in
!10
and!13
:The text was updated successfully, but these errors were encountered: