[PATCH] D62462: [llvm-objdump] Add warning messages if disassembly + source for problematic inputs

Mike Pozulp via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 22:35:45 PDT 2019


mmpozulp marked an inline comment as done.
mmpozulp added inline comments.


================
Comment at: llvm/test/tools/llvm-objdump/X86/source-interleave-no-debug-info.test:12
 
+# WARN:        warning: failed to parse debug info from file <invalid>
 # CHECK:       0000000000000010 main:
----------------
jhenderson wrote:
> mmpozulp wrote:
> > jhenderson wrote:
> > > Hmm... Not sure about this one. I think we need a different message in that case, since '<invalid>' isn't actually a file.
> > I think `failed to parse debug info` is a bit better than `failed to parse debug info from file "<invalid>"`. Here's what the user sees
> > 
> > ```
> > [mike at gannon build]$ ./bin/llvm-objdump --source test/tools/llvm-objdump/X86/Output/source-interleave-no-debug-info.test.tmp2.o
> > 
> > test/tools/llvm-objdump/X86/Output/source-interleave-no-debug-info.test.tmp2.o:	file format ELF64-x86-64
> > 
> > 
> > Disassembly of section .text:
> > 
> > 0000000000000000 foo:
> > ./bin/llvm-objdump: warning: failed to parse debug info
> >        0: 55                           	pushq	%rbp
> >        1: 48 89 e5                     	movq	%rsp, %rbp
> >        4: 8b 05 00 00 00 00            	movl	(%rip), %eax
> >        a: 5d                           	popq	%rbp
> >        b: c3                           	retq
> >        c: 90                           	nop
> >        d: 90                           	nop
> >        e: 90                           	nop
> >        f: 90                           	nop
> > 
> > 0000000000000010 main:
> >       10: 55                           	pushq	%rbp
> >       11: 48 89 e5                     	movq	%rsp, %rbp
> >       14: 53                           	pushq	%rbx
> >       15: 48 83 ec 18                  	subq	$24, %rsp
> >       19: c7 45 f4 00 00 00 00         	movl	$0, -12(%rbp)
> >       20: 48 c7 45 e8 00 00 00 00      	movq	$0, -24(%rbp)
> >       28: 8b 1d 00 00 00 00            	movl	(%rip), %ebx
> >       2e: e8 cd ff ff ff               	callq	-51 <foo>
> >       33: 01 d8                        	addl	%ebx, %eax
> >       35: 48 83 c4 18                  	addq	$24, %rsp
> >       39: 5b                           	popq	%rbx
> >       3a: 5d                           	popq	%rbp
> >       3b: c3                           	retq
> > 
> > ```
> They'll only see this if standard output and standard error are printed to the same stream. I think you need something indicating the file in most cases, where possible.
> 
> Thinking about your previous version (reporting "invalid"), that sounds like something's wrong. Why isn't it able to print the object file name here? How could it be in an invalid state in that context? Sure, the debug info in the object file might be invalid, but that doesn't affect the file name of the object.
> Why isn't it able to print the object file name here?

In this test, we "failed to parse debug info" because it was stripped from the object file.
```
[mike at gannon build]$ ./bin/llvm-dwarfdump test/tools/llvm-objdump/X86/Output/source-interleave-no-debug-info.test.tmp2.o
test/tools/llvm-objdump/X86/Output/source-interleave-no-debug-info.test.tmp2.o:	file format ELF64-x86-64

.debug_info contents:
```
Thus, `LineInfo.FileName == "<invalid>"` for every instruction. Here is the output from dwarfdump on the unstripped file (that is, before running `llvm-objcopy --strip-debug`). The filename `/home/mike/ws/llvm/llvm-project/llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-x86_64.c` is present.

```[mike at gannon build]$ ./bin/llvm-dwarfdump test/tools/llvm-objdump/X86/Output/source-interleave-no-debug-info.test.tmp.o
test/tools/llvm-objdump/X86/Output/source-interleave-no-debug-info.test.tmp.o:	file format ELF64-x86-64

.debug_info contents:
0x00000000: Compile Unit: length = 0x00000089 version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x0000008d)

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer	("clang version 4.0.0")
              DW_AT_language	(DW_LANG_C99)
              DW_AT_name	("source-interleave-x86_64.c")
              DW_AT_stmt_list	(0x00000000)
              DW_AT_comp_dir	("/home/mike/ws/llvm/llvm-project/llvm/test/tools/llvm-objdump/X86/Inputs")
              DW_AT_GNU_pubnames	(true)
              DW_AT_low_pc	(0x0000000000000000)
              DW_AT_high_pc	(0x000000000000003c)

0x0000002a:   DW_TAG_variable
                DW_AT_name	("a")
                DW_AT_type	(0x0000003f "int")
                DW_AT_external	(true)
                DW_AT_decl_file	("/home/mike/ws/llvm/llvm-project/llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-x86_64.c")
                DW_AT_decl_line	(1)
                DW_AT_location	(DW_OP_addr 0x0)

0x0000003f:   DW_TAG_base_type
                DW_AT_name	("int")
                DW_AT_encoding	(DW_ATE_signed)
                DW_AT_byte_size	(0x04)

0x00000046:   DW_TAG_subprogram
                DW_AT_low_pc	(0x0000000000000000)
                DW_AT_high_pc	(0x000000000000000c)
                DW_AT_frame_base	(DW_OP_reg6 RBP)
                DW_AT_name	("foo")
                DW_AT_decl_file	("/home/mike/ws/llvm/llvm-project/llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-x86_64.c")
                DW_AT_decl_line	(2)
                DW_AT_type	(0x0000003f "int")
                DW_AT_external	(true)

0x0000005f:   DW_TAG_subprogram
                DW_AT_low_pc	(0x0000000000000010)
                DW_AT_high_pc	(0x000000000000003c)
                DW_AT_frame_base	(DW_OP_reg6 RBP)
                DW_AT_name	("main")
                DW_AT_decl_file	("/home/mike/ws/llvm/llvm-project/llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-x86_64.c")
                DW_AT_decl_line	(6)
                DW_AT_type	(0x0000003f "int")
                DW_AT_external	(true)

0x00000078:     DW_TAG_variable
                  DW_AT_location	(DW_OP_fbreg -24)
                  DW_AT_name	("b")
                  DW_AT_decl_file	("/home/mike/ws/llvm/llvm-project/llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave-x86_64.c")
                  DW_AT_decl_line	(7)
                  DW_AT_type	(0x00000087 "int*")

0x00000086:     NULL

0x00000087:   DW_TAG_pointer_type
                DW_AT_type	(0x0000003f "int")

0x0000008c:   NULL

```
How do we recover the filename after stripping?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62462/new/

https://reviews.llvm.org/D62462





More information about the llvm-commits mailing list