X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=gdb-xds.go;h=927901be0b77d48ffc31c96a38b8da828eb3b58e;hb=refs%2Fheads%2Fguppy;hp=e9c74e328a92c3e57f698e5c44da7b22653e5786;hpb=029a61282512b633d8210de9101510a8284d4923;p=src%2Fxds%2Fxds-gdb.git diff --git a/gdb-xds.go b/gdb-xds.go index e9c74e3..927901b 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"); @@ -29,9 +29,9 @@ import ( "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" ) @@ -401,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 @@ -421,14 +422,18 @@ func (g *GdbXds) SendSignal(sig os.Signal) error { //***** Private functions ***** func (g *GdbXds) printProjectsList() (int, error) { + var prjExample *xaapiv1.ProjectConfig + var sdkExample *xaapiv1.SDK + writer := new(tabwriter.Writer) writer.Init(os.Stdout, 0, 8, 0, '\t', 0) msg := "" if len(g.projects) > 0 { fmt.Fprintln(writer, "List of existing projects (use: export XDS_PROJECT_ID=<< ID >>):") fmt.Fprintln(writer, "ID \t Label") - for _, f := range g.projects { + for ii, f := range g.projects { fmt.Fprintf(writer, " %s \t %s\n", f.ID, f.Label) + prjExample = &g.projects[ii] } } @@ -439,19 +444,22 @@ 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) + for ii, s := range sdks { + if s.Status == xaapiv1.SdkStatusInstalled { + fmt.Fprintf(writer, " %s \t %s\n", s.ID, s.Name) + sdkExample = &sdks[ii] + } } - if len(g.projects) > 0 && len(sdks) > 0 { + if prjExample != nil && sdkExample != nil { fmt.Fprintln(writer, "") fmt.Fprintln(writer, "For example: ") 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) + prjExample.ID[:8], sdkExample.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) + prjExample.ID[:8], sdkExample.ID[:8], AppName) } } fmt.Fprintln(writer, "")