This is an archive of the discontinued LLVM Phabricator instance.

[llvm-dwarfdump] - Teach tool to parse DW_CFA_GNU_args_size.
ClosedPublic

Authored by grimar on Oct 13 2017, 3:13 AM.

Details

Summary

Currently llvm-dwarfdump runs into llvm_unreachable when faces DW_CFA_GNU_args_size.

I found it when inspected the object produced by "GCC 7.0.1 20170211 (experimental)" and:
g++ -std=c++11 -w -m32 -fPIC -O3 -g -c 1.ii,
where 1.ii is file from PR34852.

DW_CFA_GNU_args_size is a DWARF CFI described here:
https://refspecs.linuxfoundation.org/LSB_3.0.0/LSB-PDA/LSB-PDA/dwarfext.html
(The DW_CFA_GNU_args_size instruction takes an unsigned LEB128 operand representing an argument size.
This instruction specifies the total of the size of the arguments which have been pushed onto the stack.)

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Oct 13 2017, 3:13 AM
aprantl accepted this revision.Oct 13 2017, 7:28 AM

Do you need to update the Verifier, too? Does llvm-dwarfdump -verify work on this input?

This revision is now accepted and ready to land.Oct 13 2017, 7:28 AM

Currently llvm-dwarfdump runs into llvm_unreachable when faces DW_CFA_GNU_args_size.

+Jonas: That seems like a serious bug, by the way. The DWARF parser should never assert on invalid input, it should only assert when internal consistency checks fail. The end goal is to integrate libDebugInfo into LLDB.

JDevlieghere edited edge metadata.Oct 13 2017, 7:58 AM

Currently llvm-dwarfdump runs into llvm_unreachable when faces DW_CFA_GNU_args_size.

+Jonas: That seems like a serious bug, by the way. The DWARF parser should never assert on invalid input, it should only assert when internal consistency checks fail. The end goal is to integrate libDebugInfo into LLDB.

Refactoring the DWARF parsers to return an Optional is pretty high on my todo-list, but unfortunately I haven't gotten around to it yet. That would also solve some of the outstanding OSS-fuzz issues. I hope to be doing this soon!

JDevlieghere accepted this revision.Oct 13 2017, 9:32 AM

Do you need to update the Verifier, too? Does llvm-dwarfdump -verify work on this input?

There is no errors for me when using llvm-dwarfdump -verify:

Verifying debug_frame_GNU_args_size.s.tmp: file format ELF32-i386
Verifying .debug_abbrev...
Verifying .debug_info Unit Header Chain...
warning: .debug_info is empty.
Verifying .debug_info references...
No errors.

I am not really familar with -verify option, but seems it verifies only few debug sections and
this object does not have any:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .strtab           STRTAB          00000000 000098 000029 00      0   0  1
  [ 2] .text             PROGBITS        00000000 000034 000000 00  AX  0   0  4
  [ 3] .eh_frame         PROGBITS        00000000 000034 00002c 00   A  0   0  4
  [ 4] .rel.eh_frame     REL             00000000 000090 000008 08      5   3  4
  [ 5] .symtab           SYMTAB          00000000 000060 000030 10      1   2  4
This revision was automatically updated to reflect the committed changes.