llvm / llvm/llvm-project

yaml2obj lacks dwarf5 .debug_line support

Open
#166,441 0 comments 0 reactions 0 assignees View on GitHub
llvm-tools
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

yaml2obj does not support DWARF5's structured directory and file table format in `.debug_line` sections. It appears to only support dwarf4 format with simple string arrays.

For example, in `llvm/include/llvm/ObjectYAML/DWARFYAML.h`

```cpp
struct LineTable {
dwarf::DwarfFormat Format;
std::optional Length;
uint16_t Version;
std::optional PrologueLength;
uint8_t MinInstLength;
uint8_t MaxOpsPerInst;
uint8_t DefaultIsStmt;
uint8_t LineBase;
uint8_t LineRange;
std::optional OpcodeBase;
std::optional> StandardOpcodeLengths;
std::vector IncludeDirs; // DWARF4: simple strings
std::vector Files; // DWARF4: simple file entries
std::vector Opcodes;
};
```

When attempting to write yaml for dwarf5 debug_line

```yaml
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_line:
- Version: 5
AddressSize: 8
SegSelectorSize: 0
MinInstLength: 1
MaxOpsPerInst: 1
DefaultIsStmt: 1
LineBase: 251
LineRange: 14
OpcodeBase: 13
StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
IncludeDirs:
- '/usr/include'
Files:
- Name: 'test.c'
DirIdx: 0
...
```

```
YAML:21:11: error: missing required key 'ModTime'
- Name: 'test.c'
^
yaml2obj: error: failed to parse YAML input: Invalid argument
```

It looks like all of the existing dwarf5 .debug_line tests work around this by doing `Sections:` with raw hex `Content:`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.