mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-15 08:23:41 +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 {
|
switch gdbInterface {
|
||||||
case "msd", "command", "":
|
case "msd", "command", "":
|
||||||
if len(config.Target.Emulator) != 0 {
|
if len(config.Target.Emulator) != 0 {
|
||||||
// Assume QEMU as an emulator.
|
|
||||||
if config.Target.Emulator[0] == "mgba" {
|
if config.Target.Emulator[0] == "mgba" {
|
||||||
gdbInterface = "mgba"
|
gdbInterface = "mgba"
|
||||||
|
} else if config.Target.Emulator[0] == "simavr" {
|
||||||
|
gdbInterface = "simavr"
|
||||||
} else {
|
} else {
|
||||||
|
// Assume QEMU as an emulator.
|
||||||
gdbInterface = "qemu"
|
gdbInterface = "qemu"
|
||||||
}
|
}
|
||||||
} else if openocdInterface != "" && config.Target.OpenOCDTarget != "" {
|
} 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 = exec.Command(config.Target.Emulator[0], args...)
|
||||||
daemon.Stdout = os.Stdout
|
daemon.Stdout = os.Stdout
|
||||||
daemon.Stderr = os.Stderr
|
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":
|
case "msd":
|
||||||
return errors.New("gdb is not supported for drag-and-drop programmable devices")
|
return errors.New("gdb is not supported for drag-and-drop programmable devices")
|
||||||
default:
|
default:
|
||||||
|
|||||||
+5
-1
@@ -6,11 +6,15 @@
|
|||||||
"gc": "conservative",
|
"gc": "conservative",
|
||||||
"linker": "avr-gcc",
|
"linker": "avr-gcc",
|
||||||
"scheduler": "none",
|
"scheduler": "none",
|
||||||
|
"cflags": [
|
||||||
|
"-gdwarf-4"
|
||||||
|
],
|
||||||
"ldflags": [
|
"ldflags": [
|
||||||
"-T", "targets/avr.ld",
|
"-T", "targets/avr.ld",
|
||||||
"-Wl,--gc-sections"
|
"-Wl,--gc-sections"
|
||||||
],
|
],
|
||||||
"extra-files": [
|
"extra-files": [
|
||||||
"src/runtime/scheduler_avr.S"
|
"src/runtime/scheduler_avr.S"
|
||||||
]
|
],
|
||||||
|
"gdb": "avr-gdb"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user