X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=gdb-xds.go;h=54f2270f189eac4836520e41b2d4e7c1a7a623c6;hb=b14158a8c5c4fdd440bc19c5c72f25a15699d29a;hp=15f8b6d5846294c24d0fa4267a4a571b467b72fc;hpb=273743466fa39a14bf7abf73f30427406684f3d3;p=src%2Fxds%2Fxds-gdb.git diff --git a/gdb-xds.go b/gdb-xds.go index 15f8b6d..54f2270 100644 --- a/gdb-xds.go +++ b/gdb-xds.go @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 "IoT.bzh" + * Copyright (C) 2017-2018 "IoT.bzh" * Author Sebastien Douheret * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,14 +23,15 @@ import ( "fmt" "os" "regexp" + "runtime" "strconv" "strings" "syscall" "text/tabwriter" + "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/xaapiv1" + common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib" "github.com/Sirupsen/logrus" - "github.com/iotbzh/xds-agent/lib/xaapiv1" - common "github.com/iotbzh/xds-common/golib" sio_client "github.com/sebd71/go-socket.io-client" ) @@ -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: @@ -396,7 +401,8 @@ func (g *GdbXds) InferiorRead(f func(timestamp, stdout, stderr string)) { // Write writes message/string into gdb stdin func (g *GdbXds) Write(args ...interface{}) error { - return g.ioSock.Emit(xaapiv1.ExecInEvent, args...) + s := fmt.Sprint(args...) + return g.ioSock.Emit(xaapiv1.ExecInEvent, []byte(s)) } // SendSignal is used to send a signal to remote process/gdb @@ -435,14 +441,21 @@ func (g *GdbXds) printProjectsList() (int, error) { fmt.Fprintln(writer, "\nList of installed cross SDKs (use: export XDS_SDK_ID=<< ID >>):") fmt.Fprintln(writer, "ID \t Name") for _, s := range sdks { - fmt.Fprintf(writer, " %s \t %s\n", s.ID, s.Name) + if s.Status == xaapiv1.SdkStatusInstalled { + fmt.Fprintf(writer, " %s \t %s\n", s.ID, s.Name) + } } 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)")