本文整理匯總了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
}
示例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
}
示例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
}
示例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)
}
示例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
}