[PATCH] D93304: Fix jumpy debug behavior issue
Chuanfeng Zhao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 15 08:20:25 PST 2020
yixi created this revision.
yixi added a reviewer: echristo.
Herald added a subscriber: hiraditya.
Herald added a reviewer: gkistanova.
yixi requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When debugging an executable program completed by Clang, if you set a break to a function, it is often no way to stop right at the line of the function, but jump to the end of the program. For example:
Reading symbols from ./a.out...done.
(gdb) b main
Breakpoint 1 at 0x4005ec
(gdb) r
Starting program: /tmp/a.out
Breakpoint 1, 0x00000000004005ec in main ()
(gdb) n
Single stepping until exit from function main,
which has no line number information.
0x0000ffffbf559ae0 in __libc_start_main () from /usr/lib64/libc.so.6
GDB version: GNU gdb (GDB) 8.2
This patch is trying to solve the issue.
Repository:
rZORG LLVM Github Zorg
https://reviews.llvm.org/D93304
Files:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/AArch64/prologue_end_line_0.ll
llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir
llvm/test/DebugInfo/X86/dbg-prolog-end.ll
Index: llvm/test/DebugInfo/X86/dbg-prolog-end.ll
===================================================================
--- llvm/test/DebugInfo/X86/dbg-prolog-end.ll
+++ llvm/test/DebugInfo/X86/dbg-prolog-end.ll
@@ -26,7 +26,7 @@
declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
;CHECK-LABEL: main:
-;CHECK: .loc 1 0 0 prologue_end
+;CHECK: .loc 1 8 2 prologue_end
define i32 @main() nounwind ssp !dbg !6 {
entry:
Index: llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir
===================================================================
--- llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir
+++ llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir
@@ -3,9 +3,8 @@
# RUN: llc -start-before=machine-cp -O2 -filetype=asm -mtriple=x86_64-apple-macosx10.9.0 -o - %s | FileCheck %s
# CHECK: Ltmp0:
-# CHECK: .loc 1 0 0 prologue_end
-# CHECK-NOT: .loc 1 0 0
-# CHECK: .loc 1 37 1
+# CHECK: .loc 1 0 0
+# CHECK: .loc 1 37 1 prologue_end
--- |
; ModuleID = '<stdin>'
Index: llvm/test/DebugInfo/AArch64/prologue_end_line_0.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/AArch64/prologue_end_line_0.ll
@@ -0,0 +1,43 @@
+; Check whether prologue_end was marked correctly. The IR in this test is
+; reduced form this C program:
+;
+; int var1;
+; int main() {
+; var1 = 2;
+; return 0;
+; }
+
+; RUN: llc -O0 %s -o - | FileCheck %s
+
+; CHECK: .loc 1 0 0
+; CHECK: .loc 1 3 8 prologue_end
+
+ at var1 = common dso_local global i32 0, align 4, !dbg !0
+
+; Function Attrs: noinline nounwind optnone
+define dso_local i32 @main() #0 !dbg !11 {
+entry:
+ %retval = alloca i32, align 4
+ store i32 0, i32* %retval, align 4
+ store i32 2, i32* @var1, align 4, !dbg !14
+ ret i32 0, !dbg !15
+}
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!7, !8, !9}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "var1", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "test.c", directory: "/tmp")
+!4 = !{}
+!5 = !{!0}
+!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!7 = !{i32 7, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{i32 1, !"wchar_size", i32 4}
+!11 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 2, type: !12, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!12 = !DISubroutineType(types: !13)
+!13 = !{!6}
+!14 = !DILocation(line: 3, column: 8, scope: !11)
+!15 = !DILocation(line: 4, column: 3, scope: !11)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1876,7 +1876,7 @@
for (const auto &MBB : *MF)
for (const auto &MI : MBB)
if (!MI.isMetaInstruction() && !MI.getFlag(MachineInstr::FrameSetup) &&
- MI.getDebugLoc())
+ MI.getDebugLoc() && (MI.getDebugLoc().getLine() != 0))
return MI.getDebugLoc();
return DebugLoc();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93304.311907.patch
Type: text/x-patch
Size: 3343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201215/e5d6d08b/attachment.bin>
More information about the llvm-commits
mailing list