Alexey Lapshin 4539b44148 [Reland][Debuginfo][llvm-dwarfutil] llvm-dwarfutil dsymutil-like tool for ELF.
This patch implements proposal https://lists.llvm.org/pipermail/llvm-dev/2020-August/144579.html
llvm-dwarfutil - is a tool that is used for processing debug info(DWARF) located in built binary files to improve debug info quality, reduce debug info size. The patch currently implements smaller set of command-line options(comparing to the proposal):

```
./llvm-dwarfutil [options] <input file> <output file>

  --garbage-collection    Do garbage collection for debug info(default)
  -j <value>              Alias for --num-threads
  --no-garbage-collection Don`t do garbage collection for debug info
  --no-odr-deduplication  Don`t do ODR deduplication for debug types
  --no-odr                Alias for --no-odr-deduplication
  --no-separate-debug-file
                          Create single output file, containing debug tables(default)
  --num-threads <threads> Number of available threads for multi-threaded execution. Defaults to the number of cores on the current machine
  --odr-deduplication     Do ODR deduplication for debug types(default)
  --odr                   Alias for --odr-deduplication
  --separate-debug-file   Create two output files: file w/o debug tables and file with debug tables
  --tombstone [bfd,maxpc,exec,universal]
                          Tombstone value used as a marker of invalid address(default: universal)
    =bfd - Zero for all addresses and [1,1] for DWARF v4 (or less) address ranges and exec
    =maxpc - Minus 1 for all addresses and minus 2 for DWARF v4 (or less) address ranges
    =exec - Match with address ranges of executable sections
    =universal - Both: bfd and maxpc
```

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D86539
2022-07-19 15:11:36 +03:00

35 lines
1.1 KiB
Plaintext

## This test checks that debug info contained in the source file
## is fully copied to the destination file in case --no-garbage-collection
## is specified.
# RUN: yaml2obj %p/Inputs/common.yaml -o %t.o
## Check that the resulting file contains debug info from source file.
# RUN: llvm-dwarfutil --no-garbage-collection %t.o %t1
# RUN: llvm-dwarfdump -a %t1 | FileCheck %s
## Check that the second copy matches with the first.
# RUN: llvm-dwarfutil --no-garbage-collection %t1 %t2
# RUN: cmp %t1 %t2
## Check that input file passed through <stdin> is correctly processesed.
# RUN: llvm-dwarfutil --no-garbage-collection - %t2 < %t1
# RUN: cmp %t1 %t2
# CHECK: .debug_abbrev
# CHECK: DW_TAG_compile_unit
# CHECK: .debug_info
# CHECK: DW_TAG_compile_unit
# CHECK: DW_AT_producer{{.*}}"by_hand"
# CHECK: DW_AT_language{{.*}}DW_LANG_C_plus_plus
# CHECK: DW_AT_name{{.*}}"CU1"
# CHECK: DW_TAG_class_type
# CHECK: DW_AT_name{{.*}}"class1"
# CHECK: DW_TAG_base_type
# CHECK: DW_AT_name{{.*}}"int"
# CHECK: DW_AT_name{{.*}}"char"
# CHECK: DW_AT_name{{.*}}"float"
# CHECK: DW_TAG_pointer_type
# CHECK: DW_TAG_variable
# CHECK: DW_AT_name{{.*}}"var1"