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


Golang api.DebuggerState類代碼示例

本文整理匯總了Golang中github.com/derekparker/delve/service/api.DebuggerState的典型用法代碼示例。如果您正苦於以下問題:Golang DebuggerState類的具體用法?Golang DebuggerState怎麽用?Golang DebuggerState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DebuggerState類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: State

// State returns the current state of the debugger.
func (d *Debugger) State() (*api.DebuggerState, error) {
	if d.process.Exited() {
		return nil, proc.ProcessExitedError{Pid: d.ProcessPid()}
	}

	var (
		state     *api.DebuggerState
		goroutine *api.Goroutine
	)

	if d.process.SelectedGoroutine != nil {
		goroutine = api.ConvertGoroutine(d.process.SelectedGoroutine)
	}

	state = &api.DebuggerState{
		SelectedGoroutine: goroutine,
		Exited:            d.process.Exited(),
	}

	for i := range d.process.Threads {
		th := api.ConvertThread(d.process.Threads[i])
		state.Threads = append(state.Threads, th)
		if i == d.process.CurrentThread.ID {
			state.CurrentThread = th
		}
	}

	return state, nil
}
開發者ID:vornet,項目名稱:delve,代碼行數:30,代碼來源:debugger.go

示例2: Continue

func (c *RPCClient) Continue() <-chan *api.DebuggerState {
	ch := make(chan *api.DebuggerState)
	c.haltMu.Lock()
	c.haltReq = false
	c.haltMu.Unlock()
	go func() {
		for {
			c.haltMu.Lock()
			if c.haltReq {
				c.haltMu.Unlock()
				close(ch)
				return
			}
			c.haltMu.Unlock()
			state := new(api.DebuggerState)
			err := c.call("Command", &api.DebuggerCommand{Name: api.Continue}, state)
			if err != nil {
				state.Err = err
			}
			if state.Exited {
				// Error types apparently cannot be marshalled by Go correctly. Must reset error here.
				state.Err = fmt.Errorf("Process %d has exited with status %d", c.ProcessPid(), state.ExitStatus)
			}
			ch <- state
			if err != nil || state.Exited {
				close(ch)
				return
			}

			isbreakpoint := false
			istracepoint := true
			for i := range state.Threads {
				if state.Threads[i].Breakpoint != nil {
					isbreakpoint = true
					istracepoint = istracepoint && state.Threads[i].Breakpoint.Tracepoint
				}
			}

			if !isbreakpoint || !istracepoint {
				close(ch)
				return
			}
		}
	}()
	return ch
}
開發者ID:alexbrainman,項目名稱:delve,代碼行數:46,代碼來源:client.go

示例3: Continue

func (c *RPCClient) Continue() <-chan *api.DebuggerState {
	ch := make(chan *api.DebuggerState)
	go func() {
		for {
			state := new(api.DebuggerState)
			err := c.call("Command", &api.DebuggerCommand{Name: api.Continue}, state)
			if err != nil {
				state.Err = err
			}
			if state.Exited {
				// Error types apparantly cannot be marshalled by Go correctly. Must reset error here.
				state.Err = fmt.Errorf("Process %d has exited with status %d", c.ProcessPid(), state.ExitStatus)
			}
			ch <- state
			if err != nil || state.Exited || state.Breakpoint == nil || !state.Breakpoint.Tracepoint {
				close(ch)
				return
			}
		}
	}()
	return ch
}
開發者ID:jeff235255,項目名稱:delve,代碼行數:22,代碼來源:client.go

示例4: collectBreakpointInformation

func (d *Debugger) collectBreakpointInformation(state *api.DebuggerState) error {
	if state == nil || state.Breakpoint == nil {
		return nil
	}

	bp := state.Breakpoint
	bpi := &api.BreakpointInfo{}
	state.BreakpointInfo = bpi

	if bp.Goroutine {
		g, err := d.process.CurrentThread.GetG()
		if err != nil {
			return err
		}
		bpi.Goroutine = api.ConvertGoroutine(g)
	}

	if bp.Stacktrace > 0 {
		rawlocs, err := d.process.CurrentThread.Stacktrace(bp.Stacktrace)
		if err != nil {
			return err
		}
		bpi.Stacktrace, err = d.convertStacktrace(rawlocs, false)
		if err != nil {
			return err
		}
	}

	s, err := d.process.CurrentThread.Scope()
	if err != nil {
		return err
	}

	if len(bp.Variables) > 0 {
		bpi.Variables = make([]api.Variable, len(bp.Variables))
	}
	for i := range bp.Variables {
		v, err := s.EvalVariable(bp.Variables[i])
		if err != nil {
			return err
		}
		bpi.Variables[i] = api.ConvertVar(v)
	}
	vars, err := functionArguments(s)
	if err == nil {
		bpi.Arguments = vars
	}
	return nil
}
開發者ID:rdterner,項目名稱:delve,代碼行數:49,代碼來源:debugger.go


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