summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--gdb-xds.go24
-rw-r--r--main.go21
3 files changed, 33 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 0088519..118a80b 100644
--- a/Makefile
+++ b/Makefile
@@ -125,7 +125,9 @@ release:
package: clean vendor build
@mkdir -p $(PACKAGE_DIR)/$(TARGET)
@cp -a $(LOCAL_BINDIR)/*gdb$(EXT) $(PACKAGE_DIR)/$(TARGET)
+ifneq ($(GOOS), windows)
@cp -r $(ROOT_SRCDIR)/conf.d $(ROOT_SRCDIR)/scripts $(PACKAGE_DIR)/$(TARGET)
+endif
cd $(PACKAGE_DIR) && zip -r $(ROOT_SRCDIR)/$(PACKAGE_ZIPFILE) ./$(TARGET)
.PHONY: package-all
diff --git a/gdb-xds.go b/gdb-xds.go
index 15f8b6d..e9c74e3 100644
--- a/gdb-xds.go
+++ b/gdb-xds.go
@@ -23,6 +23,7 @@ import (
"fmt"
"os"
"regexp"
+ "runtime"
"strconv"
"strings"
"syscall"
@@ -77,17 +78,21 @@ func NewGdbXds(log *logrus.Logger, args []string, env []string) *GdbXds {
// SetConfig set additional config fields
func (g *GdbXds) SetConfig(name string, value interface{}) error {
+ var val string
+ if name != "listProject" {
+ val = strings.TrimSpace(value.(string))
+ }
switch name {
case "agentURL":
- g.agentURL = value.(string)
+ g.agentURL = val
case "serverURL":
- g.serverURL = value.(string)
+ g.serverURL = val
case "prjID":
- g.prjID = value.(string)
+ g.prjID = val
case "sdkID":
- g.sdkID = value.(string)
+ g.sdkID = val
case "rPath":
- g.rPath = value.(string)
+ g.rPath = val
case "listProject":
g.listPrj = value.(bool)
default:
@@ -441,8 +446,13 @@ func (g *GdbXds) printProjectsList() (int, error) {
if len(g.projects) > 0 && len(sdks) > 0 {
fmt.Fprintln(writer, "")
fmt.Fprintln(writer, "For example: ")
- fmt.Fprintf(writer, " XDS_PROJECT_ID=%s XDS_SDK_ID=%s %s -x myGdbConf.ini\n",
- g.projects[0].ID[:8], sdks[0].ID[:8], AppName)
+ if runtime.GOOS == "windows" {
+ fmt.Fprintf(writer, " SET XDS_PROJECT_ID=%s && SET XDS_SDK_ID=%s && %s -x myGdbConf.ini\n",
+ g.projects[0].ID[:8], sdks[0].ID[:8], AppName)
+ } else {
+ fmt.Fprintf(writer, " XDS_PROJECT_ID=%s XDS_SDK_ID=%s %s -x myGdbConf.ini\n",
+ g.projects[0].ID[:8], sdks[0].ID[:8], AppName)
+ }
}
fmt.Fprintln(writer, "")
fmt.Fprintln(writer, "Or define settings within gdb configuration file (see help and :XDS-ENV: tag)")
diff --git a/main.go b/main.go
index f7db365..8d9865b 100644
--- a/main.go
+++ b/main.go
@@ -58,7 +58,7 @@ var AppSubVersion = "unknown-dev"
// Create logger
var log = logrus.New()
-var logFileInitial = "/tmp/xds-gdb.log"
+var logFileInitial = path.Join(os.TempDir(), "xds-gdb.log")
// Application details
const (
@@ -100,12 +100,13 @@ func main() {
logFile = logFileInitial
fdL, err := os.OpenFile(logFileInitial, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
- msgErr := fmt.Sprintf("Cannot create log file %s", logFileInitial)
- exitError(syscall.EPERM, msgErr)
+ fmt.Printf("WARNING: Cannot create initial log file %s\n", logFileInitial)
+ log.Level = logrus.WarnLevel
+ } else {
+ log.Out = fdL
+ log.Level = logrus.DebugLevel
}
log.Formatter = &logrus.TextFormatter{}
- log.Out = fdL
- log.Level = logrus.DebugLevel
agentURL = "localhost:8800"
logLevel = defaultLogLevel
@@ -356,8 +357,14 @@ endloop:
log.Debugf("Recv OUT: <%s>", stdout)
}
if stderr != "" {
- fmt.Fprintf(os.Stderr, "%s", stderr)
- log.Debugf("Recv ERR: <%s>", stderr)
+ // Filter-out ugly message (python error when cross gdb exited)
+ if !strings.Contains(stderr, "readline.write_history_file") &&
+ !(strings.Contains(stderr, "Traceback") && strings.Contains(stderr, "__exithandler")) {
+ fmt.Fprintf(os.Stderr, "%s", stderr)
+ log.Debugf("Recv ERR: <%s>", stderr)
+ } else {
+ log.Debugf("Recv ERR (FILTERED OUT): <%s>", stderr)
+ }
}
// Correctly report error about init file