當前位置: 首頁>>代碼示例>>Golang>>正文


Golang service.Client類代碼示例

本文整理匯總了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
}
開發者ID:yigen520,項目名稱:delve,代碼行數:7,代碼來源:command.go

示例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
}
開發者ID:yigen520,項目名稱:delve,代碼行數:28,代碼來源:integration_test.go

示例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
}
開發者ID:yigen520,項目名稱:delve,代碼行數:7,代碼來源:command.go

示例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...)
	}
}
開發者ID:yigen520,項目名稱:delve,代碼行數:27,代碼來源:command.go

示例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
}
開發者ID:yigen520,項目名稱:delve,代碼行數:30,代碼來源:command.go

示例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
}
開發者ID:yigen520,項目名稱:delve,代碼行數:7,代碼來源:command.go

示例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])
}
開發者ID:abandy,項目名稱:delve,代碼行數:7,代碼來源:command.go

示例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
}
開發者ID:yigen520,項目名稱:delve,代碼行數:7,代碼來源:command.go

示例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
}
開發者ID:abandy,項目名稱:delve,代碼行數:25,代碼來源:command.go

示例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
}
開發者ID:alaska,項目名稱:delve,代碼行數:29,代碼來源:terminal.go

示例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
}
開發者ID:yigen520,項目名稱:delve,代碼行數:32,代碼來源:command.go

示例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
}
開發者ID:no2key,項目名稱:delve,代碼行數:29,代碼來源:command.go

示例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
}
開發者ID:yigen520,項目名稱:delve,代碼行數:28,代碼來源:command.go

示例14: regs

func regs(client service.Client, args ...string) error {
	regs, err := client.ListRegisters()
	if err != nil {
		return err
	}
	fmt.Println(regs)
	return nil
}
開發者ID:yigen520,項目名稱:delve,代碼行數:8,代碼來源:command.go

示例15: next

func next(client service.Client, args ...string) error {
	state, err := client.Next()
	if err != nil {
		return err
	}
	printcontext(state)
	return nil
}
開發者ID:yigen520,項目名稱:delve,代碼行數:8,代碼來源:command.go


注:本文中的github.com/derekparker/delve/service.Client類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。