This commit adds AVR support to lldb. With this change, it can load a binary and do basic things like dump a line table.
Not much else has been implemented, that should be done in later changes.
Things that work:
$ ./llvm-build.master/bin/lldb tmp/avr.elf (lldb) target create "tmp/avr.elf" Current executable set to '/home/ayke/src/github.com/tinygo-org/tinygo/tmp/avr.elf' (avr). (lldb) image lookup -F main 1 match found in /home/ayke/src/github.com/tinygo-org/tinygo/tmp/avr.elf: Address: avr.elf[0x0080] (avr.elf.PT_LOAD[0]..text + 128) Summary: avr.elf`main at avr.c:10 (lldb) image dump line-table avr.c Line table for /home/ayke/src/github.com/tinygo-org/tinygo/tmp/avr.c in `avr.elf 0x0080: /home/ayke/src/github.com/tinygo-org/tinygo/tmp/avr.c:10 0x0084: /home/ayke/src/github.com/tinygo-org/tinygo/tmp/avr.c:13 0x0088: /usr/lib/avr/include/util/delay.h:163 0x009a: /home/ayke/src/github.com/tinygo-org/tinygo/tmp/avr.c:15 0x009c: /usr/lib/avr/include/util/delay.h:163 0x00b0: /usr/lib/avr/include/util/delay.h:163
Source code (copied from the internet somewhere):
#ifndef F_CPU #define F_CPU 16000000UL // 16 MHz clock speed #endif #include <avr/io.h> #include <util/delay.h> int main(void) { DDRC = 0xFF; //Nakes PORTC as Output while(1) //infinite loop { PORTC = 0xFF; //Turns ON All LEDs _delay_ms(1000); //1 second delay PORTC= 0x00; //Turns OFF All LEDs _delay_ms(1000); //1 second delay } }
Compiled using avr-gcc (with -gdwarf-4 as it defaults to the stabs debug format in Debian):
avr-gcc -Og -gdwarf-4 -mmcu=atmega328p -o avr.elf avr.c
Things like disassembling a binary don't work yet, but I think that can be done independently by getting llvm-objdump to work with the AVR target (it currently results in an assertion failure).