<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68073>68073</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Question: Can't generate right debug info using llvm
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mttbx
</td>
</tr>
</table>
<pre>
I can't debug the following codes using gdb. When I step to the calling instruction in the gdb, it will run to the end. The following code is generated by myself, so there's maybe some bugs in the codes. But I can't find it, even though I compare them with the code generated by clang. Can you help me? The code is very simple.
```
include "second.dd"
int main() {
return foo();
}
```
```
int foo() {
return 3;
}
```
```
; ModuleID = 'xxx/design.dd'
source_filename = "xxx/design.dd"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define dso_local i64 @main() !dbg !3 {
func.entry:
%"@ret" = alloca i64, align 8
br label %block.entry, !dbg !8
block.entry: ; preds = %func.entry
%call = call i64 @foo(), !dbg !9
store i64 %call, ptr %"@ret", align 8, !dbg !11
br label %func.return, !dbg !12
func.return: ; preds = %block.entry
%0 = load i64, ptr %"@ret", align 8, !dbg !13
ret i64 %0, !dbg !13
}
declare dso_local i64 @foo()
!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "mzc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
!2 = !DIFile(filename: "design.dd", directory: "xxx")
!3 = distinct !DISubprogram(name: "main", linkageName: "main", scope: !2, file: !2, line: 3, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !7)
!4 = !DISubroutineType(types: !5)
!5 = !{!6}
!6 = !DIBasicType(name: "i64", size: 64, encoding: DW_ATE_signed)
!7 = !{}
!8 = !DILocation(line: 3, column: 12, scope: !3)
!9 = !DILocation(line: 4, column: 13, scope: !10)
!10 = distinct !DILexicalBlock(scope: !3, file: !2, line: 3, column: 12)
!11 = !DILocation(line: 4, column: 10, scope: !10)
!12 = !DILocation(line: 4, column: 3, scope: !10)
!13 = !DILocation(line: 5, column: 1, scope: !10)
```
```
; ModuleID = xxx/second.dd'
source_filename = "xxx/second.dd"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define dso_local i64 @foo() !dbg !3 {
func.entry:
%"@ret" = alloca i64, align 8
br label %block.entry, !dbg !8
block.entry: ; preds = %func.entry
store i64 3, ptr %"@ret", align 8, !dbg !9
br label %func.return, !dbg !11
func.return: ; preds = %block.entry
%0 = load i64, ptr %"@ret", align 8, !dbg !12
ret i64 %0, !dbg !12
}
!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "mzc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
!2 = !DIFile(filename: "second.dd", directory: "xxx")
!3 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !2, file: !2, line: 1, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !7)
!4 = !DISubroutineType(types: !5)
!5 = !{!6}
!6 = !DIBasicType(name: "i64", size: 64, encoding: DW_ATE_signed)
!7 = !{}
!8 = !DILocation(line: 1, column: 11, scope: !3)
!9 = !DILocation(line: 2, column: 10, scope: !10)
!10 = distinct !DILexicalBlock(scope: !3, file: !2, line: 1, column: 11)
!11 = !DILocation(line: 2, column: 3, scope: !10)
!12 = !DILocation(line: 3, column: 1, scope: !10)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWF1v27wV_jX0DWFDImVJvv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