proc.go 15.5 KB
Newer Older
D
Derek Parker 已提交
1
package proc
2 3

import (
D
Derek Parker 已提交
4
	"debug/dwarf"
5
	"debug/gosym"
6
	"encoding/binary"
7 8
	"fmt"
	"os"
9
	"path/filepath"
10
	"runtime"
11 12
	"strconv"
	"strings"
D
Derek Parker 已提交
13
	"sync"
14

15 16
	sys "golang.org/x/sys/unix"

17
	"github.com/derekparker/delve/dwarf/frame"
D
Derek Parker 已提交
18
	"github.com/derekparker/delve/dwarf/line"
19
	"github.com/derekparker/delve/dwarf/reader"
D
Derek Parker 已提交
20
	"github.com/derekparker/delve/source"
21 22
)

23 24
// DebuggedProcess represents all of the information the debugger
// is holding onto regarding the process we are debugging.
D
Derek Parker 已提交
25
type DebuggedProcess struct {
26 27 28
	Pid     int         // Process Pid
	Process *os.Process // Pointer to process struct for the actual process we are debugging

29
	// Breakpoint table. Hardware breakpoints are stored in proc/arch.go, as they are architecture dependant.
D
Derek Parker 已提交
30
	Breakpoints map[uint64]*Breakpoint
31

D
Derek Parker 已提交
32 33
	// List of threads mapped as such: pid -> *Thread
	Threads map[int]*Thread
34 35

	// Active thread. This is the default thread used for setting breakpoints, evaluating variables, etc..
D
Derek Parker 已提交
36
	CurrentThread *Thread
37

38 39 40 41 42 43 44
	dwarf                   *dwarf.Data
	goSymTable              *gosym.Table
	frameEntries            frame.FrameDescriptionEntries
	lineInfo                *line.DebugLineInfo
	firstStart              bool
	singleStepping          bool
	os                      *OSProcessDetails
45
	arch                    Arch
46 47 48 49 50 51
	ast                     *source.Searcher
	breakpointIDCounter     int
	tempBreakpointIDCounter int
	running                 bool
	halt                    bool
	exited                  bool
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
	ptraceChan              chan func()
	ptraceDoneChan          chan interface{}
}

func New(pid int) *DebuggedProcess {
	dbp := &DebuggedProcess{
		Pid:            pid,
		Threads:        make(map[int]*Thread),
		Breakpoints:    make(map[uint64]*Breakpoint),
		firstStart:     true,
		os:             new(OSProcessDetails),
		ast:            source.New(),
		ptraceChan:     make(chan func()),
		ptraceDoneChan: make(chan interface{}),
	}
	go dbp.handlePtraceFuncs()
	return dbp
D
Derek Parker 已提交
69 70
}

D
Derek Parker 已提交
71 72
// A ManualStopError happens when the user triggers a
// manual stop via SIGERM.
D
Derek Parker 已提交
73 74 75 76 77 78
type ManualStopError struct{}

func (mse ManualStopError) Error() string {
	return "Manual stop requested"
}

79 80 81 82 83 84 85 86 87 88 89
// ProcessExitedError indicates that the process has exited and contains both
// process id and exit status.
type ProcessExitedError struct {
	Pid    int
	Status int
}

func (pe ProcessExitedError) Error() string {
	return fmt.Sprintf("process %d has exited with status %d", pe.Pid, pe.Status)
}

D
Derek Parker 已提交
90
// Attach to an existing process with the given PID.
91
func Attach(pid int) (*DebuggedProcess, error) {
92
	dbp, err := initializeDebugProcess(New(pid), "", true)
93 94 95 96 97 98
	if err != nil {
		return nil, err
	}
	return dbp, nil
}

99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
func (dbp *DebuggedProcess) Detach(kill bool) (err error) {
	// Clean up any breakpoints we've set.
	for _, bp := range dbp.Breakpoints {
		if bp != nil {
			dbp.Clear(bp.Addr)
		}
	}
	dbp.execPtraceFunc(func() {
		var sig int
		if kill {
			sig = int(sys.SIGINT)
		}
		err = PtraceDetach(dbp.Pid, sig)
	})
	return
D
Derek Parker 已提交
114 115
}

116 117 118 119 120 121
// Returns whether or not Delve thinks the debugged
// process has exited.
func (dbp *DebuggedProcess) Exited() bool {
	return dbp.exited
}

D
Derek Parker 已提交
122 123
// Returns whether or not Delve thinks the debugged
// process is currently executing.
D
Derek Parker 已提交
124 125 126 127
func (dbp *DebuggedProcess) Running() bool {
	return dbp.running
}

D
Derek Parker 已提交
128 129 130 131 132
// Finds the executable and then uses it
// to parse the following information:
// * Dwarf .debug_frame section
// * Dwarf .debug_line section
// * Go symbol table.
133
func (dbp *DebuggedProcess) LoadInformation(path string) error {
D
Derek Parker 已提交
134 135
	var wg sync.WaitGroup

136
	exe, err := dbp.findExecutable(path)
D
Derek Parker 已提交
137 138 139 140 141 142 143 144 145 146 147 148 149
	if err != nil {
		return err
	}

	wg.Add(3)
	go dbp.parseDebugFrame(exe, &wg)
	go dbp.obtainGoSymbols(exe, &wg)
	go dbp.parseDebugLineInfo(exe, &wg)
	wg.Wait()

	return nil
}

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
// Find a location by string (file+line, function, breakpoint id, addr)
func (dbp *DebuggedProcess) FindLocation(str string) (uint64, error) {
	// File + Line
	if strings.ContainsRune(str, ':') {
		fl := strings.Split(str, ":")

		fileName, err := filepath.Abs(fl[0])
		if err != nil {
			return 0, err
		}

		line, err := strconv.Atoi(fl[1])
		if err != nil {
			return 0, err
		}

166
		pc, _, err := dbp.goSymTable.LineToPC(fileName, line)
167 168 169 170
		if err != nil {
			return 0, err
		}
		return pc, nil
D
Derek Parker 已提交
171
	}
172

D
Derek Parker 已提交
173
	// Try to lookup by function name
174
	fn := dbp.goSymTable.LookupFunc(str)
D
Derek Parker 已提交
175 176 177 178 179 180 181 182 183
	if fn != nil {
		return fn.Entry, nil
	}

	// Attempt to parse as number for breakpoint id or raw address
	id, err := strconv.ParseUint(str, 0, 64)
	if err != nil {
		return 0, fmt.Errorf("unable to find location for %s", str)
	}
184

D
Derek Parker 已提交
185
	for _, bp := range dbp.Breakpoints {
D
Derek Parker 已提交
186 187 188 189 190 191 192
		if uint64(bp.ID) == id {
			return bp.Addr, nil
		}
	}

	// Last resort, use as raw address
	return id, nil
193 194
}

D
Derek Parker 已提交
195 196
// Sends out a request that the debugged process halt
// execution. Sends SIGSTOP to all threads.
D
Derek Parker 已提交
197
func (dbp *DebuggedProcess) RequestManualStop() error {
D
Derek Parker 已提交
198
	dbp.halt = true
D
Derek Parker 已提交
199 200 201
	err := dbp.requestManualStop()
	if err != nil {
		return err
D
Derek Parker 已提交
202
	}
D
Derek Parker 已提交
203 204 205 206
	err = dbp.Halt()
	if err != nil {
		return err
	}
D
Derek Parker 已提交
207
	dbp.running = false
D
Derek Parker 已提交
208
	return nil
D
Derek Parker 已提交
209 210
}

D
Derek Parker 已提交
211 212 213 214 215 216 217 218 219
// Sets a breakpoint at addr, and stores it in the process wide
// break point table. Setting a break point must be thread specific due to
// ptrace actions needing the thread to be in a signal-delivery-stop.
//
// Depending on hardware support, Delve will choose to either
// set a hardware or software breakpoint. Essentially, if the
// hardware supports it, and there are free debug registers, Delve
// will set a hardware breakpoint. Otherwise we fall back to software
// breakpoints, which are a bit more work for us.
D
Derek Parker 已提交
220
func (dbp *DebuggedProcess) Break(addr uint64) (*Breakpoint, error) {
221 222 223
	return dbp.setBreakpoint(dbp.CurrentThread.Id, addr, false)
}

D
Derek Parker 已提交
224
// Sets a temp breakpoint, for the 'next' command.
D
Derek Parker 已提交
225
func (dbp *DebuggedProcess) TempBreak(addr uint64) (*Breakpoint, error) {
226
	return dbp.setBreakpoint(dbp.CurrentThread.Id, addr, true)
227 228 229
}

// Sets a breakpoint by location string (function, file+line, address)
D
Derek Parker 已提交
230
func (dbp *DebuggedProcess) BreakByLocation(loc string) (*Breakpoint, error) {
231 232 233 234
	addr, err := dbp.FindLocation(loc)
	if err != nil {
		return nil, err
	}
D
Derek Parker 已提交
235
	return dbp.Break(addr)
236 237 238
}

// Clears a breakpoint in the current thread.
D
Derek Parker 已提交
239
func (dbp *DebuggedProcess) Clear(addr uint64) (*Breakpoint, error) {
240
	return dbp.clearBreakpoint(dbp.CurrentThread.Id, addr)
241 242 243
}

// Clears a breakpoint by location (function, file+line, address, breakpoint id)
D
Derek Parker 已提交
244
func (dbp *DebuggedProcess) ClearByLocation(loc string) (*Breakpoint, error) {
245 246 247 248
	addr, err := dbp.FindLocation(loc)
	if err != nil {
		return nil, err
	}
D
Derek Parker 已提交
249
	return dbp.Clear(addr)
250 251 252
}

// Returns the status of the current main thread context.
P
Paul Sbarra 已提交
253
func (dbp *DebuggedProcess) Status() *sys.WaitStatus {
254 255 256 257 258
	return dbp.CurrentThread.Status
}

// Step over function calls.
func (dbp *DebuggedProcess) Next() error {
D
Derek Parker 已提交
259 260
	return dbp.run(dbp.next)
}
261

D
Derek Parker 已提交
262
func (dbp *DebuggedProcess) next() error {
D
Derek Parker 已提交
263
	// Make sure we clean up the temp breakpoints created by thread.Next
264 265
	defer dbp.clearTempBreakpoints()

D
Derek Parker 已提交
266 267 268 269 270
	chanRecvCount, err := dbp.setChanRecvBreakpoints()
	if err != nil {
		return err
	}

271
	g, err := dbp.CurrentThread.getG()
D
Derek Parker 已提交
272 273 274
	if err != nil {
		return err
	}
275

276 277
	if g.DeferPC != 0 {
		_, err = dbp.TempBreak(g.DeferPC)
278 279 280 281 282
		if err != nil {
			return err
		}
	}

283
	var goroutineExiting bool
D
Derek Parker 已提交
284
	var waitCount int
D
Derek Parker 已提交
285
	for _, th := range dbp.Threads {
286 287
		if th.blocked() {
			// Ignore threads that aren't running go code.
D
Derek Parker 已提交
288 289
			continue
		}
D
Derek Parker 已提交
290
		waitCount++
291
		if err = th.SetNextBreakpoints(); err != nil {
292
			if err, ok := err.(GoroutineExitingError); ok {
D
Derek Parker 已提交
293
				waitCount = waitCount - 1 + chanRecvCount
294
				if err.goid == g.Id {
295 296 297 298
					goroutineExiting = true
				}
				continue
			}
D
Derek Parker 已提交
299 300 301
			return err
		}
	}
302 303 304 305 306
	for _, th := range dbp.Threads {
		if err = th.Continue(); err != nil {
			return err
		}
	}
307

D
Derek Parker 已提交
308
	for waitCount > 0 {
309
		thread, err := dbp.trapWait(-1)
D
Derek Parker 已提交
310 311
		if err != nil {
			return err
D
Derek Parker 已提交
312
		}
313
		tg, err := thread.getG()
D
Derek Parker 已提交
314 315 316
		if err != nil {
			return err
		}
D
Derek Parker 已提交
317
		// Make sure we're on the same goroutine, unless it has exited.
318
		if tg.Id == g.Id || goroutineExiting {
319 320
			if dbp.CurrentThread != thread {
				dbp.SwitchThread(thread.Id)
D
Derek Parker 已提交
321
			}
322
		}
D
Derek Parker 已提交
323
		waitCount--
324
	}
D
Derek Parker 已提交
325
	return dbp.Halt()
326 327
}

D
Derek Parker 已提交
328 329
func (dbp *DebuggedProcess) setChanRecvBreakpoints() (int, error) {
	var count int
D
Derek Parker 已提交
330 331
	allg, err := dbp.GoroutinesInfo()
	if err != nil {
D
Derek Parker 已提交
332
		return 0, err
D
Derek Parker 已提交
333 334 335 336 337
	}
	for _, g := range allg {
		if g.ChanRecvBlocked() {
			ret, err := g.chanRecvReturnAddr(dbp)
			if err != nil {
338 339 340
				if _, ok := err.(NullAddrError); ok {
					continue
				}
D
Derek Parker 已提交
341
				return 0, err
D
Derek Parker 已提交
342 343
			}
			if _, err = dbp.TempBreak(ret); err != nil {
D
Derek Parker 已提交
344
				return 0, err
D
Derek Parker 已提交
345
			}
D
Derek Parker 已提交
346
			count++
D
Derek Parker 已提交
347 348
		}
	}
D
Derek Parker 已提交
349
	return count, nil
D
Derek Parker 已提交
350 351
}

352 353 354 355 356 357 358 359
// Resume process.
func (dbp *DebuggedProcess) Continue() error {
	for _, thread := range dbp.Threads {
		err := thread.Continue()
		if err != nil {
			return err
		}
	}
360 361
	return dbp.run(dbp.resume)
}
362

363
func (dbp *DebuggedProcess) resume() error {
364
	thread, err := dbp.trapWait(-1)
365 366 367 368 369 370
	if err != nil {
		return err
	}
	if dbp.CurrentThread != thread {
		dbp.SwitchThread(thread.Id)
	}
D
Derek Parker 已提交
371
	pc, err := thread.PC()
372 373 374
	if err != nil {
		return err
	}
D
Derek Parker 已提交
375 376
	if dbp.CurrentBreakpoint != nil || dbp.halt {
		return dbp.Halt()
377 378
	}
	// Check to see if we hit a runtime.breakpoint
379
	fn := dbp.goSymTable.PCToFunc(pc)
380 381 382 383 384
	if fn != nil && fn.Name == "runtime.breakpoint" {
		// step twice to get back to user code
		for i := 0; i < 2; i++ {
			if err = thread.Step(); err != nil {
				return err
D
Derek Parker 已提交
385 386
			}
		}
387
		return dbp.Halt()
388
	}
389 390

	return fmt.Errorf("unrecognized breakpoint %#v", pc)
391 392
}

D
Derek Parker 已提交
393
// Single step, will execute a single instruction.
D
Derek Parker 已提交
394 395
func (dbp *DebuggedProcess) Step() (err error) {
	fn := func() error {
396 397
		dbp.singleStepping = true
		defer func() { dbp.singleStepping = false }()
D
Derek Parker 已提交
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
		for _, th := range dbp.Threads {
			if th.blocked() {
				continue
			}
			err := th.Step()
			if err != nil {
				return err
			}
		}
		return nil
	}

	return dbp.run(fn)
}

413 414 415
// Change from current thread to the thread specified by `tid`.
func (dbp *DebuggedProcess) SwitchThread(tid int) error {
	if th, ok := dbp.Threads[tid]; ok {
D
Derek Parker 已提交
416
		fmt.Printf("thread context changed from %d to %d\n", dbp.CurrentThread.Id, tid)
417
		dbp.CurrentThread = th
418 419 420 421 422
		return nil
	}
	return fmt.Errorf("thread %d does not exist", tid)
}

D
Derek Parker 已提交
423 424
// Returns an array of G structures representing the information
// Delve cares about from the internal runtime G structure.
425 426
func (dbp *DebuggedProcess) GoroutinesInfo() ([]*G, error) {
	var (
427 428
		allg []*G
		rdr  = dbp.DwarfReader()
429 430
	)

431
	addr, err := rdr.AddrFor("runtime.allglen")
432 433 434
	if err != nil {
		return nil, err
	}
435 436 437 438 439 440 441 442
	allglenBytes, err := dbp.CurrentThread.readMemory(uintptr(addr), 8)
	if err != nil {
		return nil, err
	}
	allglen := binary.LittleEndian.Uint64(allglenBytes)

	rdr.Seek(0)
	allgentryaddr, err := rdr.AddrFor("runtime.allg")
443 444 445
	if err != nil {
		return nil, err
	}
446
	faddr, err := dbp.CurrentThread.readMemory(uintptr(allgentryaddr), dbp.arch.PtrSize())
447 448 449
	allgptr := binary.LittleEndian.Uint64(faddr)

	for i := uint64(0); i < allglen; i++ {
450
		g, err := parseG(dbp.CurrentThread, allgptr+(i*uint64(dbp.arch.PtrSize())), true)
451 452 453 454 455 456 457 458
		if err != nil {
			return nil, err
		}
		allg = append(allg, g)
	}
	return allg, nil
}

D
Derek Parker 已提交
459
// Stop all threads.
D
Derek Parker 已提交
460 461 462 463 464 465 466 467 468
func (dbp *DebuggedProcess) Halt() (err error) {
	for _, th := range dbp.Threads {
		if err := th.Halt(); err != nil {
			return err
		}
	}
	return nil
}

469 470
// Obtains register values from what Delve considers to be the current
// thread of the traced process.
471
func (dbp *DebuggedProcess) Registers() (Registers, error) {
472 473 474
	return dbp.CurrentThread.Registers()
}

475
// Returns the PC of the current thread.
D
Derek Parker 已提交
476 477
func (dbp *DebuggedProcess) PC() (uint64, error) {
	return dbp.CurrentThread.PC()
478 479
}

480
// Returns the PC of the current thread.
D
Derek Parker 已提交
481
func (dbp *DebuggedProcess) CurrentBreakpoint() *Breakpoint {
482 483 484
	return dbp.CurrentThread.CurrentBreakpoint
}

485
// Returns the value of the named symbol.
486 487
func (dbp *DebuggedProcess) EvalVariable(name string) (*Variable, error) {
	return dbp.CurrentThread.EvalVariable(name)
488 489
}

490 491
// Returns a reader for the dwarf data
func (dbp *DebuggedProcess) DwarfReader() *reader.Reader {
492 493 494
	return reader.New(dbp.dwarf)
}

D
Derek Parker 已提交
495
// Returns list of source files that comprise the debugged binary.
496 497 498 499
func (dbp *DebuggedProcess) Sources() map[string]*gosym.Obj {
	return dbp.goSymTable.Files
}

D
Derek Parker 已提交
500
// Returns list of functions present in the debugged program.
501 502 503 504
func (dbp *DebuggedProcess) Funcs() []gosym.Func {
	return dbp.goSymTable.Funcs
}

D
Derek Parker 已提交
505
// Converts an instruction address to a file/line/function.
506 507
func (dbp *DebuggedProcess) PCToLine(pc uint64) (string, int, *gosym.Func) {
	return dbp.goSymTable.PCToLine(pc)
508 509
}

510 511 512 513 514 515 516 517 518 519
// Finds the breakpoint for the given ID.
func (dbp *DebuggedProcess) FindBreakpointByID(id int) (*Breakpoint, bool) {
	for _, bp := range dbp.Breakpoints {
		if bp.ID == id {
			return bp, true
		}
	}
	return nil, false
}

D
Derek Parker 已提交
520
// Finds the breakpoint for the given pc.
D
Derek Parker 已提交
521
func (dbp *DebuggedProcess) FindBreakpoint(pc uint64) (*Breakpoint, bool) {
522 523 524 525
	// Check for software breakpoint. PC will be at
	// breakpoint instruction + size of breakpoint.
	if bp, ok := dbp.Breakpoints[pc-uint64(dbp.arch.BreakpointSize())]; ok {
		return bp, true
D
Derek Parker 已提交
526
	}
527 528 529 530
	// Check for hardware breakpoint. PC will equal
	// the breakpoint address since the CPU will stop
	// the process without executing the instruction at
	// this address.
D
Derek Parker 已提交
531
	if bp, ok := dbp.Breakpoints[pc]; ok {
D
Derek Parker 已提交
532 533 534 535 536
		return bp, true
	}
	return nil, false
}

D
Derek Parker 已提交
537
// Returns a new DebuggedProcess struct.
538
func initializeDebugProcess(dbp *DebuggedProcess, path string, attach bool) (*DebuggedProcess, error) {
D
Derek Parker 已提交
539
	if attach {
540 541
		var err error
		dbp.execPtraceFunc(func() { err = sys.PtraceAttach(dbp.Pid) })
D
Derek Parker 已提交
542 543 544
		if err != nil {
			return nil, err
		}
545
		_, _, err = wait(dbp.Pid, 0)
D
Derek Parker 已提交
546 547 548 549 550
		if err != nil {
			return nil, err
		}
	}

551
	proc, err := os.FindProcess(dbp.Pid)
D
Derek Parker 已提交
552 553 554 555 556
	if err != nil {
		return nil, err
	}

	dbp.Process = proc
557
	err = dbp.LoadInformation(path)
D
Derek Parker 已提交
558 559 560 561 562 563 564 565
	if err != nil {
		return nil, err
	}

	if err := dbp.updateThreadList(); err != nil {
		return nil, err
	}

566 567 568 569 570
	switch runtime.GOARCH {
	case "amd64":
		dbp.arch = AMD64Arch()
	}

571
	return dbp, nil
D
Derek Parker 已提交
572
}
573

D
Derek Parker 已提交
574
func (dbp *DebuggedProcess) clearTempBreakpoints() error {
D
Derek Parker 已提交
575
	for _, bp := range dbp.Breakpoints {
D
Derek Parker 已提交
576 577 578 579 580 581 582 583 584
		if !bp.Temp {
			continue
		}
		if _, err := dbp.Clear(bp.Addr); err != nil {
			return err
		}
	}
	return nil
}
585

D
Derek Parker 已提交
586
func (dbp *DebuggedProcess) handleBreakpointOnThread(id int) (*Thread, error) {
D
Derek Parker 已提交
587 588
	thread, ok := dbp.Threads[id]
	if !ok {
589
		return nil, fmt.Errorf("could not find thread for %d", id)
D
Derek Parker 已提交
590
	}
D
Derek Parker 已提交
591
	pc, err := thread.PC()
D
Derek Parker 已提交
592
	if err != nil {
593
		return nil, err
D
Derek Parker 已提交
594
	}
595 596
	// Check to see if we have hit a breakpoint.
	if bp, ok := dbp.FindBreakpoint(pc); ok {
597
		thread.CurrentBreakpoint = bp
D
Derek Parker 已提交
598 599 600 601 602 603
		if err = thread.SetPC(bp.Addr); err != nil {
			return nil, err
		}
		return thread, nil
	}
	if dbp.halt {
604
		return thread, nil
D
Derek Parker 已提交
605
	}
D
Derek Parker 已提交
606 607
	fn := dbp.goSymTable.PCToFunc(pc)
	if fn != nil && fn.Name == "runtime.breakpoint" {
608 609
		thread.singleStepping = true
		defer func() { thread.singleStepping = false }()
D
Derek Parker 已提交
610 611 612 613 614 615 616
		for i := 0; i < 2; i++ {
			if err := thread.Step(); err != nil {
				return nil, err
			}
		}
		return thread, nil
	}
D
Derek Parker 已提交
617
	return nil, NoBreakpointError{addr: pc}
D
Derek Parker 已提交
618
}
D
Derek Parker 已提交
619

D
Derek Parker 已提交
620
func (dbp *DebuggedProcess) run(fn func() error) error {
621
	if dbp.exited {
D
Derek Parker 已提交
622
		return fmt.Errorf("process has already exited")
623
	}
D
Derek Parker 已提交
624 625
	dbp.running = true
	dbp.halt = false
626 627 628
	for _, th := range dbp.Threads {
		th.CurrentBreakpoint = nil
	}
D
Derek Parker 已提交
629 630 631 632 633 634 635 636
	defer func() { dbp.running = false }()
	if err := fn(); err != nil {
		if _, ok := err.(ManualStopError); !ok {
			return err
		}
	}
	return nil
}
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653

func (dbp *DebuggedProcess) handlePtraceFuncs() {
	// We must ensure here that we are running on the same thread during
	// the execution of dbg. This is due to the fact that ptrace(2) expects
	// all commands after PTRACE_ATTACH to come from the same thread.
	runtime.LockOSThread()

	for fn := range dbp.ptraceChan {
		fn()
		dbp.ptraceDoneChan <- nil
	}
}

func (dbp *DebuggedProcess) execPtraceFunc(fn func()) {
	dbp.ptraceChan <- fn
	<-dbp.ptraceDoneChan
}