From: Sebastien Douheret Date: Wed, 30 Aug 2017 16:33:10 +0000 (+0200) Subject: Add workaround to fix Stop action with Netbeans. X-Git-Tag: v0.1.0 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fxds%2Fxds-gdb.git;a=commitdiff_plain;h=68f893390feb6d4f442add4ac4152c9cb1112019 Add workaround to fix Stop action with Netbeans. Netbeans sends -gdb-exit command when user press stop button. But this command is not processed by remote gdb if debugged program is running. So send a SIGINT signal to interrupt program before sending/executing -gdb-exit command. --- 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) }