[MSP430] Enable some basic support for debug information
authorAnatoly Trosinenko <atrosinenko@accesssoftek.com>
Mon, 22 Jun 2020 10:14:02 +0000 (13:14 +0300)
committerAnton Korobeynikov <anton@korobeynikov.info>
Mon, 22 Jun 2020 10:14:07 +0000 (13:14 +0300)
commita5bd75aab861df8cea8d1c6b88e764ad4a2c09ea
tree6ff5f5b909dde803441da810c1d7ad10df032736
parent359fae6eb094e8eacc466b9ce5802563771a3cb9
[MSP430] Enable some basic support for debug information

This commit technically permits LLVM to emit the debug information for ELF files for MSP430 architecture. Aside from this, it only defines the register numbers as defined by part 10.1 of MSP430 EABI specification (assuming the 1-byte subregisters share the register numbers with corresponding full-size registers).

This commit was basically tested by me with TI-provided GCC 8.3.1 toolchain by compiling an example program with `clang` (please note manual linking may be required due to upstream `clang` not yet handling the `-msim` option necessary to run binaries on the GDB-provided simulator) and then running it and single-stepping with `msp430-elf-gdb` like this:

```
$sysroot/bin/msp430-elf-gdb ./test -ex "target sim" -ex "load ./test"
(gdb) ... traditional GDB commands follow ...
```

While this implementation is most probably far from completeness and is considered experimental, it can already help with debugging MSP430 programs as well as finding issues in LLVM debug info support for MSP430 itself.

One of the use cases includes trying to find a point where UBSan check in a trap-on-error mode was triggered.

The expected debug information format is described in the [MSP430 Embedded Application Binary Interface](http://www.ti.com/lit/an/slaa534/slaa534.pdf) specification, part 10.

Differential Revision: https://reviews.llvm.org/D81488
llvm/lib/Object/RelocationResolver.cpp
llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCAsmInfo.cpp
llvm/lib/Target/MSP430/MSP430RegisterInfo.td
llvm/test/DebugInfo/MSP430/dwarf-basics.ll [new file with mode: 0644]