main: add support for QEMU in the gdb subcommand
This allows debugging QEMU-only targets with GDB, which can be super useful.
Этот коммит содержится в:
родитель
0105f815c6
коммит
7bdd4a1186
1 изменённых файлов: 24 добавлений и 3 удалений
27
main.go
27
main.go
|
@ -268,12 +268,13 @@ func FlashGDB(pkgName, port string, ocdOutput bool, options *compileopts.Options
|
||||||
gdbInterface, openocdInterface := config.Programmer()
|
gdbInterface, openocdInterface := config.Programmer()
|
||||||
switch gdbInterface {
|
switch gdbInterface {
|
||||||
case "msd", "command", "":
|
case "msd", "command", "":
|
||||||
if gdbInterface == "" {
|
|
||||||
gdbInterface = "command"
|
|
||||||
}
|
|
||||||
if openocdInterface != "" && config.Target.OpenOCDTarget != "" {
|
if openocdInterface != "" && config.Target.OpenOCDTarget != "" {
|
||||||
gdbInterface = "openocd"
|
gdbInterface = "openocd"
|
||||||
}
|
}
|
||||||
|
if len(config.Target.Emulator) != 0 {
|
||||||
|
// Assume QEMU as an emulator.
|
||||||
|
gdbInterface = "qemu"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the GDB server, if necessary.
|
// Run the GDB server, if necessary.
|
||||||
|
@ -303,6 +304,26 @@ func FlashGDB(pkgName, port string, ocdOutput bool, options *compileopts.Options
|
||||||
// Make sure the daemon doesn't receive Ctrl-C that is intended for
|
// Make sure the daemon doesn't receive Ctrl-C that is intended for
|
||||||
// GDB (to break the currently executing program).
|
// GDB (to break the currently executing program).
|
||||||
setCommandAsDaemon(daemon)
|
setCommandAsDaemon(daemon)
|
||||||
|
// Start now, and kill it on exit.
|
||||||
|
daemon.Start()
|
||||||
|
defer func() {
|
||||||
|
daemon.Process.Signal(os.Interrupt)
|
||||||
|
// Maybe we should send a .Kill() after x seconds?
|
||||||
|
daemon.Wait()
|
||||||
|
}()
|
||||||
|
case "qemu":
|
||||||
|
gdbCommands = append(gdbCommands, "target remote :1234")
|
||||||
|
|
||||||
|
// Run in an emulator.
|
||||||
|
args := append(config.Target.Emulator[1:], tmppath, "-s", "-S")
|
||||||
|
daemon := exec.Command(config.Target.Emulator[0], args...)
|
||||||
|
daemon.Stdout = os.Stdout
|
||||||
|
daemon.Stderr = os.Stderr
|
||||||
|
|
||||||
|
// Make sure the daemon doesn't receive Ctrl-C that is intended for
|
||||||
|
// GDB (to break the currently executing program).
|
||||||
|
setCommandAsDaemon(daemon)
|
||||||
|
|
||||||
// Start now, and kill it on exit.
|
// Start now, and kill it on exit.
|
||||||
daemon.Start()
|
daemon.Start()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче