mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
main: support gdb debugging with AVR
Be able to run `tinygo gdb -target=arduino examples/serial` and debug a program with the power of a real debugger. Note that this only works on LLVM 11 because older versions have a bug in the AVR backend that cause it to produce invalid debug information: https://reviews.llvm.org/D74213.
This commit is contained in:
@@ -310,10 +310,12 @@ func FlashGDB(pkgName string, ocdOutput bool, options *compileopts.Options) erro
|
||||
switch gdbInterface {
|
||||
case "msd", "command", "":
|
||||
if len(config.Target.Emulator) != 0 {
|
||||
// Assume QEMU as an emulator.
|
||||
if config.Target.Emulator[0] == "mgba" {
|
||||
gdbInterface = "mgba"
|
||||
} else if config.Target.Emulator[0] == "simavr" {
|
||||
gdbInterface = "simavr"
|
||||
} else {
|
||||
// Assume QEMU as an emulator.
|
||||
gdbInterface = "qemu"
|
||||
}
|
||||
} else if openocdInterface != "" && config.Target.OpenOCDTarget != "" {
|
||||
@@ -379,6 +381,14 @@ func FlashGDB(pkgName string, ocdOutput bool, options *compileopts.Options) erro
|
||||
daemon = exec.Command(config.Target.Emulator[0], args...)
|
||||
daemon.Stdout = os.Stdout
|
||||
daemon.Stderr = os.Stderr
|
||||
case "simavr":
|
||||
gdbCommands = append(gdbCommands, "target remote :1234")
|
||||
|
||||
// Run in an emulator.
|
||||
args := append(config.Target.Emulator[1:], "-g", tmppath)
|
||||
daemon = exec.Command(config.Target.Emulator[0], args...)
|
||||
daemon.Stdout = os.Stdout
|
||||
daemon.Stderr = os.Stderr
|
||||
case "msd":
|
||||
return errors.New("gdb is not supported for drag-and-drop programmable devices")
|
||||
default:
|
||||
|
||||
+5
-1
@@ -6,11 +6,15 @@
|
||||
"gc": "conservative",
|
||||
"linker": "avr-gcc",
|
||||
"scheduler": "none",
|
||||
"cflags": [
|
||||
"-gdwarf-4"
|
||||
],
|
||||
"ldflags": [
|
||||
"-T", "targets/avr.ld",
|
||||
"-Wl,--gc-sections"
|
||||
],
|
||||
"extra-files": [
|
||||
"src/runtime/scheduler_avr.S"
|
||||
]
|
||||
],
|
||||
"gdb": "avr-gdb"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user