diff --git a/llvm/docs/CommandGuide/llvm-objdump.rst b/llvm/docs/CommandGuide/llvm-objdump.rst --- a/llvm/docs/CommandGuide/llvm-objdump.rst +++ b/llvm/docs/CommandGuide/llvm-objdump.rst @@ -132,7 +132,7 @@ .. option:: --debug-vars-indent= Distance to indent the source-level variable display, relative to the start - of the disassembly. Defaults to 40 characters. + of the disassembly. Defaults to 52 characters. .. option:: -j, --section= diff --git a/llvm/test/tools/llvm-objdump/ELF/AArch64/disassemble-print-comments.s b/llvm/test/tools/llvm-objdump/ELF/AArch64/disassemble-print-comments.s --- a/llvm/test/tools/llvm-objdump/ELF/AArch64/disassemble-print-comments.s +++ b/llvm/test/tools/llvm-objdump/ELF/AArch64/disassemble-print-comments.s @@ -7,7 +7,63 @@ # CHECK-NEXT: 0: add x0, x2, #2, lsl #12 // =8192 # CHECK-NEXT: 4: add z31.d, z31.d, #65280 // =0xff00 +## Check that comments and locations of variables can be printed together. +# RUN: llvm-objdump -d --mattr=+sve --debug-vars --no-show-raw-insn %t | \ +# RUN: FileCheck %s --check-prefix=DBGVARS + +# DBGVARS: 0000000000000000 : +# DBGVARS-NEXT: ┠─ bar = W1 +# DBGVARS-NEXT: 0: add x0, x2, #2, lsl #12 // =8192 ┃ +# DBGVARS-NEXT: 4: add z31.d, z31.d, #65280 // =0xff00 ┻ + .text foo: add x0, x2, 8192 add z31.d, z31.d, #65280 +.LFooEnd: + + .section .debug_abbrev,"",@progbits + .uleb128 1 // Abbreviation Code + .uleb128 0x11 // DW_TAG_compile_unit + .byte 1 // DW_CHILDREN_yes + .byte 0 // EOM(1) + .byte 0 // EOM(2) + .uleb128 2 // Abbreviation Code + .uleb128 0x2e // DW_TAG_subprogram + .byte 1 // DW_CHILDREN_yes + .uleb128 0x11 // DW_AT_low_pc + .uleb128 0x01 // DW_FORM_addr + .uleb128 0x12 // DW_AT_high_pc + .uleb128 0x06 // DW_FORM_data4 + .byte 0 // EOM(1) + .byte 0 // EOM(2) + .uleb128 3 // Abbreviation Code + .uleb128 0x34 // DW_TAG_variable + .byte 0 // DW_CHILDREN_no + .uleb128 0x02 // DW_AT_location + .uleb128 0x18 // DW_FORM_exprloc + .uleb128 0x03 // DW_AT_name + .uleb128 0x08 // DW_FORM_string + .byte 0 // EOM(1) + .byte 0 // EOM(2) + .byte 0 // EOM(3) + + .section .debug_info,"",@progbits + .long .LCuEnd-.LCuBegin // Length of Unit +.LCuBegin: + .short 4 // DWARF version number + .long .debug_abbrev // Offset Into Abbrev. Section + .byte 8 // Address Size + .uleb128 1 // Abbrev [1] DW_TAG_compile_unit + .uleb128 2 // Abbrev [2] DW_TAG_subprogram + .quad foo // DW_AT_low_pc + .long .LFooEnd-foo // DW_AT_high_pc + .uleb128 3 // Abbrev [3] DW_TAG_variable + .byte .LLocEnd-.LLocBegin // DW_AT_location +.LLocBegin: + .byte 0x51 // DW_OP_reg1 +.LLocEnd: + .asciz "bar" // DW_FORM_string + .byte 0 // End Of Children Mark + .byte 0 // End Of Children Mark +.LCuEnd: diff --git a/llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-dwarf4.s b/llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-dwarf4.s --- a/llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-dwarf4.s +++ b/llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-dwarf4.s @@ -12,10 +12,10 @@ # RUN: llvm-objdump - -d --debug-vars | \ # RUN: FileCheck %s --check-prefix=RAW --strict-whitespace -## Check that passing the default value for --debug-vars-indent (40) makes no +## Check that passing the default value for --debug-vars-indent (52) makes no ## change to the output. # RUN: llvm-mc -triple armv8a--none-eabi < %s -filetype=obj | \ -# RUN: llvm-objdump - -d --debug-vars --debug-vars-indent=40 | \ +# RUN: llvm-objdump - -d --debug-vars --debug-vars-indent=52 | \ # RUN: FileCheck %s --check-prefix=RAW --strict-whitespace # RUN: llvm-mc -triple armv8a--none-eabi < %s -filetype=obj | \ @@ -50,19 +50,19 @@ ## 8-byte tab stop, so these might not look aligned in a text editor. # RAW: 00000000 : -# RAW-NEXT: ┠─ a = R0 -# RAW-NEXT: ┃ ┠─ b = R1 -# RAW-NEXT: ┃ ┃ ┠─ c = R2 -# RAW-NEXT: ┃ ┃ ┃ ┌─ x = R0 -# RAW-NEXT: 0: 00 00 81 e0 add r0, r1, r0 ┻ ┃ ┃ ╈ -# RAW-NEXT: ┌─ y = R0 -# RAW-NEXT: 4: 02 00 80 e0 add r0, r0, r2 ╈ ┃ ┃ ┻ -# RAW-NEXT: 8: 1e ff 2f e1 bx lr ┻ ┻ ┻ +# RAW-NEXT: ┠─ a = R0 +# RAW-NEXT: ┃ ┠─ b = R1 +# RAW-NEXT: ┃ ┃ ┠─ c = R2 +# RAW-NEXT: ┃ ┃ ┃ ┌─ x = R0 +# RAW-NEXT: 0: 00 00 81 e0 add r0, r1, r0 ┻ ┃ ┃ ╈ +# RAW-NEXT: ┌─ y = R0 +# RAW-NEXT: 4: 02 00 80 e0 add r0, r0, r2 ╈ ┃ ┃ ┻ +# RAW-NEXT: 8: 1e ff 2f e1 bx lr ┻ ┻ ┻ # RAW-EMPTY: # RAW-NEXT: 0000000c : -# RAW-NEXT: ┠─ a = R0 -# RAW-NEXT: c: 01 00 80 e2 add r0, r0, #1 ┃ -# RAW-NEXT: 10: 1e ff 2f e1 bx lr ┻ +# RAW-NEXT: ┠─ a = R0 +# RAW-NEXT: c: 01 00 80 e2 add r0, r0, #1 ┃ +# RAW-NEXT: 10: 1e ff 2f e1 bx lr ┻ # INDENT: 00000000 : @@ -81,70 +81,70 @@ # INDENT-NEXT: 10: 1e ff 2f e1 bx lr ┻ # NO-RAW: 00000000 : -# NO-RAW-NEXT: ┠─ a = R0 -# NO-RAW-NEXT: ┃ ┠─ b = R1 -# NO-RAW-NEXT: ┃ ┃ ┠─ c = R2 -# NO-RAW-NEXT: ┃ ┃ ┃ ┌─ x = R0 -# NO-RAW-NEXT: 0: add r0, r1, r0 ┻ ┃ ┃ ╈ -# NO-RAW-NEXT: ┌─ y = R0 -# NO-RAW-NEXT: 4: add r0, r0, r2 ╈ ┃ ┃ ┻ -# NO-RAW-NEXT: 8: bx lr ┻ ┻ ┻ +# NO-RAW-NEXT: ┠─ a = R0 +# NO-RAW-NEXT: ┃ ┠─ b = R1 +# NO-RAW-NEXT: ┃ ┃ ┠─ c = R2 +# NO-RAW-NEXT: ┃ ┃ ┃ ┌─ x = R0 +# NO-RAW-NEXT: 0: add r0, r1, r0 ┻ ┃ ┃ ╈ +# NO-RAW-NEXT: ┌─ y = R0 +# NO-RAW-NEXT: 4: add r0, r0, r2 ╈ ┃ ┃ ┻ +# NO-RAW-NEXT: 8: bx lr ┻ ┻ ┻ # NO-RAW-EMPTY: # NO-RAW-NEXT: 0000000c : -# NO-RAW-NEXT: ┠─ a = R0 -# NO-RAW-NEXT: c: add r0, r0, #1 ┃ -# NO-RAW-NEXT: 10: bx lr ┻ +# NO-RAW-NEXT: ┠─ a = R0 +# NO-RAW-NEXT: c: add r0, r0, #1 ┃ +# NO-RAW-NEXT: 10: bx lr ┻ # LINE-NUMS: 00000000 : # LINE-NUMS-NEXT: ; foo(): -# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:2 ┠─ a = R0 -# LINE-NUMS-NEXT: ┃ ┠─ b = R1 -# LINE-NUMS-NEXT: ┃ ┃ ┠─ c = R2 -# LINE-NUMS-NEXT: ┃ ┃ ┃ ┌─ x = R0 -# LINE-NUMS-NEXT: 0: add r0, r1, r0 ┻ ┃ ┃ ╈ -# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:3 ┌─ y = R0 -# LINE-NUMS-NEXT: 4: add r0, r0, r2 ╈ ┃ ┃ ┻ -# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:4 ┃ ┃ ┃ -# LINE-NUMS-NEXT: 8: bx lr ┻ ┻ ┻ +# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:2 ┠─ a = R0 +# LINE-NUMS-NEXT: ┃ ┠─ b = R1 +# LINE-NUMS-NEXT: ┃ ┃ ┠─ c = R2 +# LINE-NUMS-NEXT: ┃ ┃ ┃ ┌─ x = R0 +# LINE-NUMS-NEXT: 0: add r0, r1, r0 ┻ ┃ ┃ ╈ +# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:3 ┌─ y = R0 +# LINE-NUMS-NEXT: 4: add r0, r0, r2 ╈ ┃ ┃ ┻ +# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:4 ┃ ┃ ┃ +# LINE-NUMS-NEXT: 8: bx lr ┻ ┻ ┻ # LINE-NUMS-EMPTY: # LINE-NUMS-NEXT: 0000000c : # LINE-NUMS-NEXT: ; bar(): -# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:8 ┠─ a = R0 -# LINE-NUMS-NEXT: c: add r0, r0, #1 ┃ -# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:9 ┃ -# LINE-NUMS-NEXT: 10: bx lr ┻ +# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:8 ┠─ a = R0 +# LINE-NUMS-NEXT: c: add r0, r0, #1 ┃ +# LINE-NUMS-NEXT: ; SRC_COMPDIR{{[\\/]}}debug.c:9 ┃ +# LINE-NUMS-NEXT: 10: bx lr ┻ # SOURCE: 00000000 : -# SOURCE-NEXT: ; int x = a + b; ┠─ a = R0 -# SOURCE-NEXT: ┃ ┠─ b = R1 -# SOURCE-NEXT: ┃ ┃ ┠─ c = R2 -# SOURCE-NEXT: ┃ ┃ ┃ ┌─ x = R0 -# SOURCE-NEXT: 0: add r0, r1, r0 ┻ ┃ ┃ ╈ -# SOURCE-NEXT: ; int y = x + c; ┌─ y = R0 -# SOURCE-NEXT: 4: add r0, r0, r2 ╈ ┃ ┃ ┻ -# SOURCE-NEXT: ; return y; ┃ ┃ ┃ -# SOURCE-NEXT: 8: bx lr ┻ ┻ ┻ +# SOURCE-NEXT: ; int x = a + b; ┠─ a = R0 +# SOURCE-NEXT: ┃ ┠─ b = R1 +# SOURCE-NEXT: ┃ ┃ ┠─ c = R2 +# SOURCE-NEXT: ┃ ┃ ┃ ┌─ x = R0 +# SOURCE-NEXT: 0: add r0, r1, r0 ┻ ┃ ┃ ╈ +# SOURCE-NEXT: ; int y = x + c; ┌─ y = R0 +# SOURCE-NEXT: 4: add r0, r0, r2 ╈ ┃ ┃ ┻ +# SOURCE-NEXT: ; return y; ┃ ┃ ┃ +# SOURCE-NEXT: 8: bx lr ┻ ┻ ┻ # SOURCE-EMPTY: # SOURCE-NEXT: 0000000c : -# SOURCE-NEXT: ; a++; ┠─ a = R0 -# SOURCE-NEXT: c: add r0, r0, #1 ┃ -# SOURCE-NEXT: ; return a; ┃ -# SOURCE-NEXT: 10: bx lr ┻ +# SOURCE-NEXT: ; a++; ┠─ a = R0 +# SOURCE-NEXT: c: add r0, r0, #1 ┃ +# SOURCE-NEXT: ; return a; ┃ +# SOURCE-NEXT: 10: bx lr ┻ # ASCII: 00000000 : -# ASCII-NEXT: |- a = R0 -# ASCII-NEXT: | |- b = R1 -# ASCII-NEXT: | | |- c = R2 -# ASCII-NEXT: | | | /- x = R0 -# ASCII-NEXT: 0: 00 00 81 e0 add r0, r1, r0 v | | ^ -# ASCII-NEXT: /- y = R0 -# ASCII-NEXT: 4: 02 00 80 e0 add r0, r0, r2 ^ | | v -# ASCII-NEXT: 8: 1e ff 2f e1 bx lr v v v +# ASCII-NEXT: |- a = R0 +# ASCII-NEXT: | |- b = R1 +# ASCII-NEXT: | | |- c = R2 +# ASCII-NEXT: | | | /- x = R0 +# ASCII-NEXT: 0: 00 00 81 e0 add r0, r1, r0 v | | ^ +# ASCII-NEXT: /- y = R0 +# ASCII-NEXT: 4: 02 00 80 e0 add r0, r0, r2 ^ | | v +# ASCII-NEXT: 8: 1e ff 2f e1 bx lr v v v # ASCII-EMPTY: # ASCII-NEXT: 0000000c : -# ASCII-NEXT: |- a = R0 -# ASCII-NEXT: c: 01 00 80 e2 add r0, r0, #1 | -# ASCII-NEXT: 10: 1e ff 2f e1 bx lr v +# ASCII-NEXT: |- a = R0 +# ASCII-NEXT: c: 01 00 80 e2 add r0, r0, #1 | +# ASCII-NEXT: 10: 1e ff 2f e1 bx lr v .text .syntax unified diff --git a/llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-wide-chars.s b/llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-wide-chars.s --- a/llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-wide-chars.s +++ b/llvm/test/tools/llvm-objdump/ELF/ARM/debug-vars-wide-chars.s @@ -13,9 +13,9 @@ ## characters. # CHECK: 00000000 : -# CHECK-NEXT: ; return *喵; ┠─ 喵 = R0 -# CHECK-NEXT: 0: 00 00 90 e5 ldr r0, [r0] ┻ -# CHECK-NEXT: 4: 1e ff 2f e1 bx lr +# CHECK-NEXT: ; return *喵; ┠─ 喵 = R0 +# CHECK-NEXT: 0: 00 00 90 e5 ldr r0, [r0] ┻ +# CHECK-NEXT: 4: 1e ff 2f e1 bx lr .text .syntax unified diff --git a/llvm/test/tools/llvm-objdump/X86/disassemble-print-comments.s b/llvm/test/tools/llvm-objdump/X86/disassemble-print-comments.s --- a/llvm/test/tools/llvm-objdump/X86/disassemble-print-comments.s +++ b/llvm/test/tools/llvm-objdump/X86/disassemble-print-comments.s @@ -7,7 +7,63 @@ # CHECK-NEXT: 0: nop # CHECK-NEXT: 1: cmpl $305419896, %eax # imm = 0x12345678 +## Check that comments and locations of variables can be printed together. +# RUN: llvm-objdump -d --debug-vars --no-show-raw-insn %t | \ +# RUN: FileCheck %s --check-prefix=DBGVARS + +# DBGVARS: 0000000000000000 : +# DBGVARS-NEXT: ┠─ bar = RDX +# DBGVARS-NEXT: 0: nop ┃ +# DBGVARS-NEXT: 1: cmpl $305419896, %eax # imm = 0x12345678 ┻ + .text foo: nop cmpl $0x12345678, %eax +.LFooEnd: + + .section .debug_abbrev,"",@progbits + .uleb128 1 # Abbreviation Code + .uleb128 0x11 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .uleb128 2 # Abbreviation Code + .uleb128 0x2e # DW_TAG_subprogram + .byte 1 # DW_CHILDREN_yes + .uleb128 0x11 # DW_AT_low_pc + .uleb128 0x01 # DW_FORM_addr + .uleb128 0x12 # DW_AT_high_pc + .uleb128 0x06 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .uleb128 3 # Abbreviation Code + .uleb128 0x34 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .uleb128 0x02 # DW_AT_location + .uleb128 0x18 # DW_FORM_exprloc + .uleb128 0x03 # DW_AT_name + .uleb128 0x08 # DW_FORM_string + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits + .long .LCuEnd-.LCuBegin # Length of Unit +.LCuBegin: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size + .uleb128 1 # Abbrev [1] DW_TAG_compile_unit + .uleb128 2 # Abbrev [2] DW_TAG_subprogram + .quad foo # DW_AT_low_pc + .long .LFooEnd-foo # DW_AT_high_pc + .uleb128 3 # Abbrev [3] DW_TAG_variable + .byte .LLocEnd-.LLocBegin # DW_AT_location +.LLocBegin: + .byte 0x51 # DW_OP_reg1 +.LLocEnd: + .asciz "bar" # DW_FORM_string + .byte 0 # End Of Children Mark + .byte 0 # End Of Children Mark +.LCuEnd: diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -221,7 +221,7 @@ DebugVarsFormat objdump::DbgVariables = DVDisabled; -int objdump::DbgIndent = 40; +int objdump::DbgIndent = 52; static StringSet<> DisasmSymbolSet; StringSet<> objdump::FoundSectionSet;