forked from OSchip/llvm-project
[llvm-objdump] Prevent variable locations to overlap short comments
For now, the source variable locations are printed at about the same space as the comments for disassembled code, which can make some ranges for variables disappear if a line contains comments, for example: ┠─ bar = W1 0: add x0, x2, #2, lsl #12 // =8192┃ 4: add z31.d, z31.d, #65280 // =0xff00 8: nop ┻ The patch shifts the report a bit to allow printing comments up to approximately 16 characters without interferences. Differential Revision: https://reviews.llvm.org/D104700
This commit is contained in:
parent
abe0fa4352
commit
c2e6bcb494
|
@ -132,7 +132,7 @@ OPTIONS
|
|||
.. option:: --debug-vars-indent=<width>
|
||||
|
||||
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=<section1[,section2,...]>
|
||||
|
||||
|
|
|
@ -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 <foo>:
|
||||
# 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:
|
||||
|
|
|
@ -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 <foo>:
|
||||
# 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 <bar>:
|
||||
# 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 <foo>:
|
||||
|
@ -81,70 +81,70 @@
|
|||
# INDENT-NEXT: 10: 1e ff 2f e1 bx lr ┻
|
||||
|
||||
# NO-RAW: 00000000 <foo>:
|
||||
# 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 <bar>:
|
||||
# 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 <foo>:
|
||||
# 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 <bar>:
|
||||
# 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 <foo>:
|
||||
# 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 <bar>:
|
||||
# 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 <foo>:
|
||||
# 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 <bar>:
|
||||
# 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
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
## characters.
|
||||
|
||||
# CHECK: 00000000 <foo>:
|
||||
# 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
|
||||
|
|
|
@ -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 <foo>:
|
||||
# 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:
|
||||
|
|
|
@ -221,7 +221,7 @@ uint32_t objdump::PrefixStrip;
|
|||
|
||||
DebugVarsFormat objdump::DbgVariables = DVDisabled;
|
||||
|
||||
int objdump::DbgIndent = 40;
|
||||
int objdump::DbgIndent = 52;
|
||||
|
||||
static StringSet<> DisasmSymbolSet;
|
||||
StringSet<> objdump::FoundSectionSet;
|
||||
|
|
Loading…
Reference in New Issue