X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=main.go;h=d907a449f90667e6885944012d632bbf08725124;hb=refs%2Ftags%2Fv0.1.0;hp=dc1d25bcb4534b41a8fadf33bc163cb1182145c2;hpb=3c4defb289a37002a924f12632426c5aab6a4f81;p=src%2Fxds%2Fxds-gdb.git diff --git a/main.go b/main.go index dc1d25b..d907a44 100644 --- a/main.go +++ b/main.go @@ -409,6 +409,10 @@ endloop: paranoia := 600 reader := bufio.NewReader(os.Stdin) + // Enable workaround to correctly close connection + // except if XDS_GDBSERVER_EXIT_NOFIX is defined + _, gdbExitNoFix := os.LookupEnv("XDS_GDBSERVER_EXIT_NOFIX") + for { sc := bufio.NewScanner(reader) for sc.Scan() { @@ -421,6 +425,16 @@ endloop: log.Debugf("OVERWRITE %s -> %s", key, value) } } + + // Send SIGINT to stop debugged process execution before sending -gdb-exit command + if !gdbExitNoFix && strings.Contains(command, "-gdb-exit") { + log.Infof("Detection of -gdb-exit, exiting...") + if err := gdb.SendSignal(syscall.SIGINT); err != nil { + log.Errorf("Error while sending signal SIGINT : %s", err.Error()) + } + time.Sleep(time.Millisecond * 200) + } + gdb.Write(command + "\n") log.Debugf("Send: <%v>", command) }