main: hide OCD output by default in gdb subcommand
In most cases, it's useless. But in some cases it may be critical if the OCD server (like openocd) has a problem. It would be nice if openocd would differentiate between stdout and stderr, and only write errors to stderr. But sadly it doesn't.
Этот коммит содержится в:
родитель
5d2ffa79e5
коммит
9d408b7cbc
1 изменённых файлов: 12 добавлений и 7 удалений
11
main.go
11
main.go
|
@ -205,7 +205,7 @@ func Flash(pkgName, target, port string, printIR, dumpSSA, debug bool, printSize
|
||||||
//
|
//
|
||||||
// Note: this command is expected to execute just before exiting, as it
|
// Note: this command is expected to execute just before exiting, as it
|
||||||
// modifies global state.
|
// modifies global state.
|
||||||
func FlashGDB(pkgName, target, port string, printIR, dumpSSA bool, printSizes string) error {
|
func FlashGDB(pkgName, target, port string, printIR, dumpSSA, ocdOutput bool, printSizes string) error {
|
||||||
spec, err := LoadTarget(target)
|
spec, err := LoadTarget(target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -220,12 +220,16 @@ func FlashGDB(pkgName, target, port string, printIR, dumpSSA bool, printSizes st
|
||||||
if len(spec.OCDDaemon) != 0 {
|
if len(spec.OCDDaemon) != 0 {
|
||||||
// We need a separate debugging daemon for on-chip debugging.
|
// We need a separate debugging daemon for on-chip debugging.
|
||||||
daemon := exec.Command(spec.OCDDaemon[0], spec.OCDDaemon[1:]...)
|
daemon := exec.Command(spec.OCDDaemon[0], spec.OCDDaemon[1:]...)
|
||||||
|
if ocdOutput {
|
||||||
// Make it clear which output is from the daemon.
|
// Make it clear which output is from the daemon.
|
||||||
daemon.Stderr = &ColorWriter{
|
w := &ColorWriter{
|
||||||
Out: os.Stderr,
|
Out: os.Stderr,
|
||||||
Prefix: spec.OCDDaemon[0] + ": ",
|
Prefix: spec.OCDDaemon[0] + ": ",
|
||||||
Color: TermColorYellow,
|
Color: TermColorYellow,
|
||||||
}
|
}
|
||||||
|
daemon.Stdout = w
|
||||||
|
daemon.Stderr = w
|
||||||
|
}
|
||||||
// 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).
|
||||||
// https://stackoverflow.com/a/35435038/559350
|
// https://stackoverflow.com/a/35435038/559350
|
||||||
|
@ -320,6 +324,7 @@ func main() {
|
||||||
target := flag.String("target", llvm.DefaultTargetTriple(), "LLVM target")
|
target := flag.String("target", llvm.DefaultTargetTriple(), "LLVM target")
|
||||||
printSize := flag.String("size", "", "print sizes (none, short, full)")
|
printSize := flag.String("size", "", "print sizes (none, short, full)")
|
||||||
nodebug := flag.Bool("no-debug", false, "disable DWARF debug symbol generation")
|
nodebug := flag.Bool("no-debug", false, "disable DWARF debug symbol generation")
|
||||||
|
ocdOutput := flag.Bool("ocd-output", false, "print OCD daemon output during debug")
|
||||||
port := flag.String("port", "/dev/ttyACM0", "flash port")
|
port := flag.String("port", "/dev/ttyACM0", "flash port")
|
||||||
|
|
||||||
if len(os.Args) < 2 {
|
if len(os.Args) < 2 {
|
||||||
|
@ -360,7 +365,7 @@ func main() {
|
||||||
if command == "flash" {
|
if command == "flash" {
|
||||||
err = Flash(flag.Arg(0), *target, *port, *printIR, *dumpSSA, !*nodebug, *printSize)
|
err = Flash(flag.Arg(0), *target, *port, *printIR, *dumpSSA, !*nodebug, *printSize)
|
||||||
} else {
|
} else {
|
||||||
err = FlashGDB(flag.Arg(0), *target, *port, *printIR, *dumpSSA, *printSize)
|
err = FlashGDB(flag.Arg(0), *target, *port, *printIR, *dumpSSA, *ocdOutput, *printSize)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "error:", err)
|
fmt.Fprintln(os.Stderr, "error:", err)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче