当前位置: 首页>>代码示例>>Golang>>正文


Golang Client.CreateBreakpoint方法代码示例

本文整理汇总了Golang中github.com/derekparker/delve/service.Client.CreateBreakpoint方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.CreateBreakpoint方法的具体用法?Golang Client.CreateBreakpoint怎么用?Golang Client.CreateBreakpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/derekparker/delve/service.Client的用法示例。


在下文中一共展示了Client.CreateBreakpoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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

示例2: setBreakpoint

func setBreakpoint(client service.Client, tracepoint bool, args ...string) error {
	if len(args) < 1 {
		return fmt.Errorf("address required, specify 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")
	}

	for i := 1; i < len(args); i++ {
		switch args[i] {
		case "-stack":
			i++
			n, err := strconv.Atoi(args[i])
			if err != nil {
				return fmt.Errorf("argument of -stack must be a number")
			}
			requestedBp.Stacktrace = n
		case "-goroutine":
			requestedBp.Goroutine = true
		default:
			requestedBp.Variables = append(requestedBp.Variables, args[i])
		}
	}

	requestedBp.Tracepoint = tracepoint

	bp, err := client.CreateBreakpoint(requestedBp)
	if err != nil {
		return err
	}

	thing := "Breakpoint"
	if tracepoint {
		thing = "Tracepoint"
	}

	fmt.Printf("%s %d set at %#v for %s %s:%d\n", thing, bp.ID, bp.Addr, bp.FunctionName, bp.File, bp.Line)
	return nil
}
开发者ID:benma,项目名称:delve,代码行数:53,代码来源:command.go

示例3: setBreakpoint

func setBreakpoint(client service.Client, tracepoint bool, args ...string) error {
	if len(args) < 1 {
		return fmt.Errorf("address required, specify either a function name or <file:line>")
	}

	requestedBp := &api.Breakpoint{}

	for i := 1; i < len(args); i++ {
		switch args[i] {
		case "-stack":
			i++
			n, err := strconv.Atoi(args[i])
			if err != nil {
				return fmt.Errorf("argument of -stack must be a number")
			}
			requestedBp.Stacktrace = n
		case "-goroutine":
			requestedBp.Goroutine = true
		default:
			requestedBp.Variables = append(requestedBp.Variables, args[i])
		}
	}

	requestedBp.Tracepoint = tracepoint

	locs, err := client.FindLocation(args[0])
	if err != nil {
		return err
	}

	thing := "Breakpoint"
	if tracepoint {
		thing = "Tracepoint"
	}

	for _, loc := range locs {
		requestedBp.Addr = loc.PC

		bp, err := client.CreateBreakpoint(requestedBp)
		if err != nil {
			return err
		}

		fmt.Printf("%s %d set at %#v for %s %s:%d\n", thing, bp.ID, bp.Addr, bp.FunctionName, bp.File, bp.Line)
	}

	return nil
}
开发者ID:aperera,项目名称:delve,代码行数:48,代码来源:command.go


注:本文中的github.com/derekparker/delve/service.Client.CreateBreakpoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。