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


Golang proc.Launch函數代碼示例

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


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

示例1: Restart

// Restart will restart the target process, first killing
// and then exec'ing it again.
func (d *Debugger) Restart() error {
	d.processMutex.Lock()
	defer d.processMutex.Unlock()

	if !d.process.Exited() {
		if d.process.Running() {
			d.process.Halt()
		}
		// Ensure the process is in a PTRACE_STOP.
		if err := stopProcess(d.ProcessPid()); err != nil {
			return err
		}
		if err := d.detach(true); err != nil {
			return err
		}
	}
	p, err := proc.Launch(d.config.ProcessArgs)
	if err != nil {
		return fmt.Errorf("could not launch process: %s", err)
	}
	for _, oldBp := range d.breakpoints() {
		if oldBp.ID < 0 {
			continue
		}
		newBp, err := p.SetBreakpoint(oldBp.Addr)
		if err != nil {
			return err
		}
		if err := copyBreakpointInfo(newBp, oldBp); err != nil {
			return err
		}
	}
	d.process = p
	return nil
}
開發者ID:DuoSoftware,項目名稱:v6engine-deps,代碼行數:37,代碼來源:debugger.go

示例2: Restart

// Restart will restart the target process, first killing
// and then exec'ing it again.
func (d *Debugger) Restart() error {
	if !d.process.Exited() {
		if d.process.Running() {
			d.process.Halt()
		}
		// Ensure the process is in a PTRACE_STOP.
		if err := stopProcess(d.ProcessPid()); err != nil {
			return err
		}
		if err := d.Detach(true); err != nil {
			return err
		}
	}
	p, err := proc.Launch(d.config.ProcessArgs)
	if err != nil {
		return fmt.Errorf("could not launch process: %s", err)
	}
	for addr, bp := range d.process.Breakpoints {
		if bp.Temp {
			continue
		}
		if _, err := p.SetBreakpoint(addr); err != nil {
			return err
		}
	}
	d.process = p
	return nil
}
開發者ID:vornet,項目名稱:delve,代碼行數:30,代碼來源:debugger.go

示例3: New

// New creates a new Debugger.
func New(config *Config) (*Debugger, error) {
	d := &Debugger{
		config: config,
	}

	// Create the process by either attaching or launching.
	if d.config.AttachPid > 0 {
		log.Printf("attaching to pid %d", d.config.AttachPid)
		p, err := proc.Attach(d.config.AttachPid)
		if err != nil {
			return nil, attachErrorMessage(d.config.AttachPid, err)
		}
		d.process = p
	} else {
		log.Printf("launching process with args: %v", d.config.ProcessArgs)
		p, err := proc.Launch(d.config.ProcessArgs)
		if err != nil {
			if err != proc.NotExecutableErr && err != proc.UnsupportedArchErr {
				err = fmt.Errorf("could not launch process: %s", err)
			}
			return nil, err
		}
		d.process = p
	}
	return d, nil
}
開發者ID:RJAugust,項目名稱:delve,代碼行數:27,代碼來源:debugger.go

示例4: withTestProcess

func withTestProcess(name string, t *testing.T, fn func(p *proc.Process, fixture protest.Fixture)) {
	fixture := protest.BuildFixture(name)
	p, err := proc.Launch([]string{fixture.Path})
	if err != nil {
		t.Fatal("Launch():", err)
	}

	defer func() {
		p.Halt()
		p.Kill()
	}()

	fn(p, fixture)
}
開發者ID:dustinevan,項目名稱:delve,代碼行數:14,代碼來源:variables_test.go

示例5: Restart

func (d *Debugger) Restart() error {
	if !d.process.Exited() {
		if d.process.Running() {
			d.process.Halt()
		}
		// Ensure the process is in a PTRACE_STOP.
		if err := sys.Kill(d.ProcessPid(), sys.SIGSTOP); err != nil {
			return err
		}
		if err := d.Detach(true); err != nil {
			return err
		}
	}
	p, err := proc.Launch(d.config.ProcessArgs)
	if err != nil {
		return fmt.Errorf("could not launch process: %s", err)
	}
	d.process = p
	return nil
}
開發者ID:alaska,項目名稱:delve,代碼行數:20,代碼來源:debugger.go


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