本文整理汇总了Golang中github.com/derekparker/delve/service/rpc.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewClient函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: traceCmd
func traceCmd(cmd *cobra.Command, args []string) {
status := func() int {
const debugname = "debug"
var processArgs []string
if traceAttachPid == 0 {
if err := gobuild(debugname); err != nil {
return 1
}
fp, err := filepath.Abs("./" + debugname)
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
return 1
}
defer os.Remove(fp)
processArgs = append([]string{"./" + debugname}, args...)
}
// Make a TCP listener
listener, err := net.Listen("tcp", Addr)
if err != nil {
fmt.Printf("couldn't start listener: %s\n", err)
return 1
}
defer listener.Close()
// Create and start a debug server
server := rpc.NewServer(&service.Config{
Listener: listener,
ProcessArgs: processArgs,
AttachPid: traceAttachPid,
}, Log)
if err := server.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
client := rpc.NewClient(listener.Addr().String())
funcs, err := client.ListFunctions(args[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
for i := range funcs {
_, err := client.CreateBreakpoint(&api.Breakpoint{FunctionName: funcs[i], Tracepoint: true, Line: -1, Stacktrace: traceStackDepth})
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
}
cmds := terminal.DebugCommands(client)
cmd := cmds.Find("continue")
err = cmd(terminal.New(client, nil), "")
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
return 0
}()
os.Exit(status)
}
开发者ID:ethobis,项目名称:delve,代码行数:59,代码来源:main.go
示例2: connect
func connect(addr string, conf *config.Config) int {
// Create and start a terminal - attach to running instance
var client service.Client
client = rpc.NewClient(addr)
term := terminal.New(client, conf)
err, status := term.Run()
if err != nil {
fmt.Println(err)
}
return status
}
开发者ID:jeffallen,项目名称:delve,代码行数:11,代码来源:main.go
示例3: execute
func execute(attachPid int, processArgs []string, conf *config.Config) int {
// Make a TCP listener
listener, err := net.Listen("tcp", Addr)
if err != nil {
fmt.Printf("couldn't start listener: %s\n", err)
return 1
}
defer listener.Close()
if Headless && (InitFile != "") {
fmt.Fprintf(os.Stderr, "Warning: init file ignored\n")
}
// Create and start a debugger server
server := rpc.NewServer(&service.Config{
Listener: listener,
ProcessArgs: processArgs,
AttachPid: attachPid,
}, Log)
if err := server.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
var status int
if !Headless {
// Create and start a terminal
var client service.Client
client = rpc.NewClient(listener.Addr().String())
term := terminal.New(client, conf)
term.InitFile = InitFile
status, err = term.Run()
} else {
ch := make(chan os.Signal)
signal.Notify(ch, sys.SIGINT)
<-ch
err = server.Stop(true)
}
if err != nil {
fmt.Println(err)
}
return status
}
开发者ID:CedarLogic,项目名称:delve,代码行数:45,代码来源:main.go
示例4: withTestClient
func withTestClient(name string, t *testing.T, fn func(c service.Client)) {
listener, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatalf("couldn't start listener: %s\n", err)
}
defer listener.Close()
server := rpc.NewServer(&service.Config{
Listener: listener,
ProcessArgs: []string{protest.BuildFixture(name).Path},
}, false)
if err := server.Run(); err != nil {
t.Fatal(err)
}
client := rpc.NewClient(listener.Addr().String())
defer func() {
client.Detach(true)
}()
fn(client)
}
开发者ID:yigen520,项目名称:delve,代码行数:20,代码来源:integration_test.go
示例5: main
//.........这里部分代码省略.........
err := goBuild.Run()
if err != nil {
return 1
}
fp, err := filepath.Abs("./" + debugname)
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
return 1
}
defer os.Remove(fp)
processArgs = append([]string{"./" + debugname}, args...)
}
// Make a TCP listener
listener, err := net.Listen("tcp", Addr)
if err != nil {
fmt.Printf("couldn't start listener: %s\n", err)
return 1
}
defer listener.Close()
// Create and start a debugger server
server := rpc.NewServer(&service.Config{
Listener: listener,
ProcessArgs: processArgs,
AttachPid: traceAttachPid,
}, Log)
if err := server.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
sigChan := make(chan os.Signal)
signal.Notify(sigChan, sys.SIGINT)
client := rpc.NewClient(listener.Addr().String())
funcs, err := client.ListFunctions(args[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
for i := range funcs {
_, err := client.CreateBreakpoint(&api.Breakpoint{FunctionName: funcs[i], Tracepoint: true})
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
}
stateChan := client.Continue()
for {
select {
case state := <-stateChan:
if state.Err != nil {
fmt.Fprintln(os.Stderr, state.Err)
return 0
}
var args []string
var fname string
if state.CurrentThread != nil && state.CurrentThread.Function != nil {
fname = state.CurrentThread.Function.Name
}
if state.BreakpointInfo != nil {
for _, arg := range state.BreakpointInfo.Arguments {
args = append(args, arg.Value)
}
}
fmt.Printf("%s(%s) %s:%d\n", fname, strings.Join(args, ", "), state.CurrentThread.File, state.CurrentThread.Line)
case <-sigChan:
开发者ID:joeshaw,项目名称:delve,代码行数:67,代码来源:main.go
示例6: main
//.........这里部分代码省略.........
err := goBuild.Run()
if err != nil {
return 1
}
fp, err := filepath.Abs("./" + debugname)
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
return 1
}
defer os.Remove(fp)
processArgs = append([]string{"./" + debugname}, args...)
}
// Make a TCP listener
listener, err := net.Listen("tcp", Addr)
if err != nil {
fmt.Printf("couldn't start listener: %s\n", err)
return 1
}
defer listener.Close()
// Create and start a debugger server
server := rpc.NewServer(&service.Config{
Listener: listener,
ProcessArgs: processArgs,
AttachPid: traceAttachPid,
}, Log)
if err := server.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
sigChan := make(chan os.Signal)
signal.Notify(sigChan, sys.SIGINT)
client := rpc.NewClient(listener.Addr().String())
funcs, err := client.ListFunctions(args[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
for i := range funcs {
_, err := client.CreateBreakpoint(&api.Breakpoint{FunctionName: funcs[i], Tracepoint: true})
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
}
stateChan := client.Continue()
for {
select {
case state := <-stateChan:
if state == nil {
return 0
}
if state.Err != nil {
fmt.Fprintln(os.Stderr, state.Err)
return 0
}
for i := range state.Threads {
th := state.Threads[i]
if th.Breakpoint == nil {
continue
}
var args []string
var fname string
if th.Function != nil {
fname = th.Function.Name
开发者ID:CedarLogic,项目名称:delve,代码行数:67,代码来源:main.go
注:本文中的github.com/derekparker/delve/service/rpc.NewClient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论