本文整理汇总了Golang中github.com/derekparker/delve/service.Client类的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: restart
func restart(client service.Client, args ...string) error {
if err := client.Restart(); err != nil {
return err
}
fmt.Println("Process restarted with PID", client.ProcessPid())
return nil
}
示例2: findLocationHelper
func findLocationHelper(t *testing.T, c service.Client, loc string, shouldErr bool, count int, checkAddr uint64) []uint64 {
locs, err := c.FindLocation(api.EvalScope{-1, 0}, loc)
t.Logf("FindLocation(\"%s\") → %v\n", loc, locs)
if shouldErr {
if err == nil {
t.Fatalf("Resolving location <%s> didn't return an error: %v", loc, locs)
}
} else {
if err != nil {
t.Fatalf("Error resolving location <%s>: %v", loc, err)
}
}
if (count >= 0) && (len(locs) != count) {
t.Fatalf("Wrong number of breakpoints returned for location <%s> (got %d, expected %d)", loc, len(locs), count)
}
if checkAddr != 0 && checkAddr != locs[0].PC {
t.Fatalf("Wrong address returned for location <%s> (got %v, epected %v)", loc, locs[0].PC, checkAddr)
}
addrs := make([]uint64, len(locs))
for i := range locs {
addrs[i] = locs[i].PC
}
return addrs
}
示例3: locals
func locals(client service.Client, scope api.EvalScope, filter string) ([]string, error) {
locals, err := client.ListLocalVariables(scope)
if err != nil {
return nil, err
}
return filterVariables(locals, filter), nil
}
示例4: goroutine
func goroutine(client service.Client, args ...string) error {
switch len(args) {
case 0:
return printscope(client)
case 1:
gid, err := strconv.Atoi(args[0])
if err != nil {
return err
}
oldState, err := client.GetState()
if err != nil {
return err
}
newState, err := client.SwitchGoroutine(gid)
if err != nil {
return err
}
fmt.Printf("Switched from %d to %d (thread %d)\n", oldState.SelectedGoroutine.ID, gid, newState.CurrentThread.ID)
return nil
default:
return scopePrefix(client, "goroutine", args...)
}
}
示例5: breakpoints
func breakpoints(client service.Client, args ...string) error {
breakPoints, err := client.ListBreakpoints()
if err != nil {
return err
}
sort.Sort(ById(breakPoints))
for _, bp := range breakPoints {
thing := "Breakpoint"
if bp.Tracepoint {
thing = "Tracepoint"
}
fmt.Printf("%s %d at %#v %s:%d\n", thing, bp.ID, bp.Addr, shortenFilePath(bp.File), bp.Line)
var attrs []string
if bp.Stacktrace > 0 {
attrs = append(attrs, "-stack")
attrs = append(attrs, strconv.Itoa(bp.Stacktrace))
}
if bp.Goroutine {
attrs = append(attrs, "-goroutine")
}
for i := range bp.Variables {
attrs = append(attrs, bp.Variables[i])
}
if len(attrs) > 0 {
fmt.Printf("\t%s\n", strings.Join(attrs, " "))
}
}
return nil
}
示例6: vars
func vars(client service.Client, filter string) ([]string, error) {
vars, err := client.ListPackageVariables(filter)
if err != nil {
return nil, err
}
return filterVariables(vars, filter), nil
}
示例7: setVar
func setVar(client service.Client, scope api.EvalScope, args ...string) error {
if len(args) != 2 {
return fmt.Errorf("wrong number of arguments")
}
return client.SetVariable(scope, args[0], args[1])
}
示例8: args
func args(client service.Client, scope api.EvalScope, filter string) ([]string, error) {
vars, err := client.ListFunctionArgs(scope)
if err != nil {
return nil, err
}
return filterVariables(vars, filter), nil
}
示例9: threads
func threads(client service.Client, args ...string) error {
threads, err := client.ListThreads()
if err != nil {
return err
}
state, err := client.GetState()
if err != nil {
return err
}
sort.Sort(byThreadID(threads))
for _, th := range threads {
prefix := " "
if state.CurrentThread != nil && state.CurrentThread.ID == th.ID {
prefix = "* "
}
if th.Function != nil {
fmt.Printf("%sThread %d at %#v %s:%d %s\n",
prefix, th.ID, th.PC, shortenFilePath(th.File),
th.Line, th.Function.Name)
} else {
fmt.Printf("%sThread %s\n", prefix, formatThread(th))
}
}
return nil
}
示例10: handleExit
func handleExit(client service.Client, t *Term) (error, int) {
fullHistoryFile, err := getConfigFilePath(historyFile)
if err != nil {
fmt.Println("Error saving history file:", err)
} else {
if f, err := os.OpenFile(fullHistoryFile, os.O_RDWR, 0666); err == nil {
_, err := t.line.WriteHistory(f)
if err != nil {
fmt.Println("readline history error: ", err)
}
f.Close()
}
}
kill := true
if client.AttachedToExistingProcess() {
answer, err := t.line.Prompt("Would you like to kill the process? [Y/n] ")
if err != nil {
return io.EOF, 2
}
answer = strings.ToLower(strings.TrimSpace(answer))
kill = (answer != "n" && answer != "no")
}
err = client.Detach(kill)
if err != nil {
return err, 1
}
return nil, 0
}
示例11: stackCommand
func stackCommand(client service.Client, args ...string) error {
var err error
goroutineid := -1
depth := 10
switch len(args) {
case 0:
// nothing to do
case 2:
goroutineid, err = strconv.Atoi(args[1])
if err != nil {
return fmt.Errorf("Wrong argument: expected integer")
}
fallthrough
case 1:
depth, err = strconv.Atoi(args[0])
if err != nil {
return fmt.Errorf("Wrong argument: expected integer")
}
default:
return fmt.Errorf("Wrong number of arguments to stack")
}
stack, err := client.Stacktrace(goroutineid, depth)
if err != nil {
return err
}
printStack(stack, "")
return nil
}
示例12: breakpoint
func breakpoint(client service.Client, args ...string) error {
if len(args) != 1 {
return fmt.Errorf("argument must be either a function name or <file:line>")
}
requestedBp := &api.Breakpoint{}
tokens := strings.Split(args[0], ":")
switch {
case len(tokens) == 1:
requestedBp.FunctionName = args[0]
case len(tokens) == 2:
file := tokens[0]
line, err := strconv.Atoi(tokens[1])
if err != nil {
return err
}
requestedBp.File = file
requestedBp.Line = line
default:
return fmt.Errorf("invalid line reference")
}
bp, err := client.CreateBreakpoint(requestedBp)
if err != nil {
return err
}
fmt.Printf("Breakpoint %d set at %#v for %s %s:%d\n", bp.ID, bp.Addr, bp.FunctionName, bp.File, bp.Line)
return nil
}
示例13: thread
func thread(client service.Client, args ...string) error {
if len(args) == 0 {
return fmt.Errorf("you must specify a thread")
}
tid, err := strconv.Atoi(args[0])
if err != nil {
return err
}
oldState, err := client.GetState()
if err != nil {
return err
}
newState, err := client.SwitchThread(tid)
if err != nil {
return err
}
oldThread := "<none>"
newThread := "<none>"
if oldState.CurrentThread != nil {
oldThread = strconv.Itoa(oldState.CurrentThread.ID)
}
if newState.CurrentThread != nil {
newThread = strconv.Itoa(newState.CurrentThread.ID)
}
fmt.Printf("Switched from %s to %s\n", oldThread, newThread)
return nil
}
示例14: regs
func regs(client service.Client, args ...string) error {
regs, err := client.ListRegisters()
if err != nil {
return err
}
fmt.Println(regs)
return nil
}
示例15: next
func next(client service.Client, args ...string) error {
state, err := client.Next()
if err != nil {
return err
}
printcontext(state)
return nil
}