Rename package proctl -> proc

This commit is contained in:
Derek Parker 2015-06-12 14:49:23 -05:00
parent a71f218e35
commit bfca6114d4
36 changed files with 64 additions and 64 deletions

@ -26,20 +26,20 @@ ifeq "$(CERT)" ""
$(error You must provide a CERT env var) $(error You must provide a CERT env var)
endif endif
go test $(PREFIX)/terminal $(PREFIX)/dwarf/frame $(PREFIX)/dwarf/op $(PREFIX)/dwarf/util $(PREFIX)/source $(PREFIX)/dwarf/line go test $(PREFIX)/terminal $(PREFIX)/dwarf/frame $(PREFIX)/dwarf/op $(PREFIX)/dwarf/util $(PREFIX)/source $(PREFIX)/dwarf/line
cd proctl && go test -c $(PREFIX)/proctl && codesign -s $(CERT) ./proctl.test && ./proctl.test $(TESTFLAGS) && rm ./proctl.test cd proc && go test -c $(PREFIX)/proc && codesign -s $(CERT) ./proc.test && ./proc.test $(TESTFLAGS) && rm ./proc.test
cd service/rest && go test -c $(PREFIX)/service/rest && codesign -s $(CERT) ./rest.test && ./rest.test $(TESTFLAGS) && rm ./rest.test cd service/rest && go test -c $(PREFIX)/service/rest && codesign -s $(CERT) ./rest.test && ./rest.test $(TESTFLAGS) && rm ./rest.test
else else
go test -v ./... go test -v ./...
endif endif
test-proctl-run: test-proc-run:
ifeq "$(UNAME)" "Darwin" ifeq "$(UNAME)" "Darwin"
ifeq "$(CERT)" "" ifeq "$(CERT)" ""
$(error You must provide a CERT env var) $(error You must provide a CERT env var)
endif endif
cd proctl && go test -c $(PREFIX)/proctl && codesign -s $(CERT) ./proctl.test && ./proctl.test -test.run $(RUN) && rm ./proctl.test cd proc && go test -c $(PREFIX)/proc && codesign -s $(CERT) ./proc.test && ./proc.test -test.run $(RUN) && rm ./proc.test
else else
cd proctl && go test -run $(RUN) cd proc && go test -run $(RUN)
endif endif
test-integration-run: test-integration-run:

@ -1,4 +1,4 @@
package proctl package proc
import "runtime" import "runtime"

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"fmt" "fmt"

@ -1,4 +1,4 @@
package proctl package proc
import "fmt" import "fmt"

@ -1,4 +1,4 @@
package proctl package proc
/* /*
#include <stddef.h> #include <stddef.h>

@ -1,10 +1,10 @@
// proctl is a low-level package that provides methods to manipulate // proc is a low-level package that provides methods to manipulate
// the process we are debugging, and methods to read and write from // the process we are debugging, and methods to read and write from
// the virtual memory of the process. // the virtual memory of the process.
// //
// proctl implements the core features of this debugger, including all // proc implements the core features of this debugger, including all
// process manipulation (step, next, continue, halt) as well as providing // process manipulation (step, next, continue, halt) as well as providing
// methods to evaluate variables and read them from the virtual memory of // methods to evaluate variables and read them from the virtual memory of
// the process we are debugging. // the process we are debugging.
// //
package proctl package proc

@ -1,4 +1,4 @@
#include "proctl_darwin.h" #include "proc_darwin.h"
#include <unistd.h> #include <unistd.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"debug/dwarf" "debug/dwarf"
@ -26,7 +26,7 @@ type DebuggedProcess struct {
Pid int // Process Pid Pid int // Process Pid
Process *os.Process // Pointer to process struct for the actual process we are debugging Process *os.Process // Pointer to process struct for the actual process we are debugging
// Software breakpoint table. Hardware breakpoints are stored in proctl/arch.go, as they are architecture dependant. // Software breakpoint table. Hardware breakpoints are stored in proc/arch.go, as they are architecture dependant.
Breakpoints map[uint64]*Breakpoint Breakpoints map[uint64]*Breakpoint
// List of threads mapped as such: pid -> *ThreadContext // List of threads mapped as such: pid -> *ThreadContext

@ -1,4 +1,4 @@
#include "proctl_darwin.h" #include "proc_darwin.h"
static const unsigned char info_plist[] static const unsigned char info_plist[]
__attribute__ ((section ("__TEXT,__info_plist"),used)) = __attribute__ ((section ("__TEXT,__info_plist"),used)) =

@ -1,6 +1,6 @@
package proctl package proc
// #include "proctl_darwin.h" // #include "proc_darwin.h"
// #include "exec_darwin.h" // #include "exec_darwin.h"
// #include <stdlib.h> // #include <stdlib.h>
import "C" import "C"

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"debug/elf" "debug/elf"

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"bytes" "bytes"
@ -7,7 +7,7 @@ import (
"runtime" "runtime"
"testing" "testing"
protest "github.com/derekparker/delve/proctl/test" protest "github.com/derekparker/delve/proc/test"
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"syscall" "syscall"

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"syscall" "syscall"

@ -1,4 +1,4 @@
package proctl package proc
import "fmt" import "fmt"

@ -1,4 +1,4 @@
package proctl package proc
// #include "threads_darwin.h" // #include "threads_darwin.h"
import "C" import "C"

@ -1,4 +1,4 @@
package proctl package proc
import sys "golang.org/x/sys/unix" import sys "golang.org/x/sys/unix"

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"debug/gosym" "debug/gosym"

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"debug/gosym" "debug/gosym"

@ -1,4 +1,4 @@
package proctl package proc
// #include "threads_darwin.h" // #include "threads_darwin.h"
import "C" import "C"

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"fmt" "fmt"

@ -1,4 +1,4 @@
package proctl package proc
import ( import (
"bytes" "bytes"

@ -1,11 +1,11 @@
package proctl package proc
import ( import (
"fmt" "fmt"
"sort" "sort"
"testing" "testing"
protest "github.com/derekparker/delve/proctl/test" protest "github.com/derekparker/delve/proc/test"
) )
type varTest struct { type varTest struct {

@ -6,7 +6,7 @@ import (
"regexp" "regexp"
"runtime" "runtime"
"github.com/derekparker/delve/proctl" "github.com/derekparker/delve/proc"
"github.com/derekparker/delve/service/api" "github.com/derekparker/delve/service/api"
) )
@ -14,8 +14,8 @@ import (
// Debugger can be exposed by other services. // Debugger can be exposed by other services.
type Debugger struct { type Debugger struct {
config *Config config *Config
process *proctl.DebuggedProcess process *proc.DebuggedProcess
processOps chan func(*proctl.DebuggedProcess) processOps chan func(*proc.DebuggedProcess)
stop chan stopSignal stop chan stopSignal
running bool running bool
} }
@ -42,7 +42,7 @@ type stopSignal struct {
// New creates a new Debugger. // New creates a new Debugger.
func New(config *Config) *Debugger { func New(config *Config) *Debugger {
debugger := &Debugger{ debugger := &Debugger{
processOps: make(chan func(*proctl.DebuggedProcess)), processOps: make(chan func(*proc.DebuggedProcess)),
config: config, config: config,
stop: make(chan stopSignal), stop: make(chan stopSignal),
} }
@ -61,13 +61,13 @@ func New(config *Config) *Debugger {
// instance, when performing an operation like halt which merely sends a // instance, when performing an operation like halt which merely sends a
// signal to the process rather than performing something like a ptrace // signal to the process rather than performing something like a ptrace
// operation. // operation.
func (d *Debugger) withProcess(f func(*proctl.DebuggedProcess) error) error { func (d *Debugger) withProcess(f func(*proc.DebuggedProcess) error) error {
if !d.running { if !d.running {
return fmt.Errorf("debugger isn't running") return fmt.Errorf("debugger isn't running")
} }
result := make(chan error) result := make(chan error)
d.processOps <- func(proc *proctl.DebuggedProcess) { d.processOps <- func(proc *proc.DebuggedProcess) {
result <- f(proc) result <- f(proc)
} }
return <-result return <-result
@ -87,14 +87,14 @@ func (d *Debugger) Run() error {
// Create the process by either attaching or launching. // Create the process by either attaching or launching.
if d.config.AttachPid > 0 { if d.config.AttachPid > 0 {
log.Printf("attaching to pid %d", d.config.AttachPid) log.Printf("attaching to pid %d", d.config.AttachPid)
p, err := proctl.Attach(d.config.AttachPid) p, err := proc.Attach(d.config.AttachPid)
if err != nil { if err != nil {
return fmt.Errorf("couldn't attach to pid %d: %s", d.config.AttachPid, err) return fmt.Errorf("couldn't attach to pid %d: %s", d.config.AttachPid, err)
} }
d.process = p d.process = p
} else { } else {
log.Printf("launching process with args: %v", d.config.ProcessArgs) log.Printf("launching process with args: %v", d.config.ProcessArgs)
p, err := proctl.Launch(d.config.ProcessArgs) p, err := proc.Launch(d.config.ProcessArgs)
if err != nil { if err != nil {
return fmt.Errorf("couldn't launch process: %s", err) return fmt.Errorf("couldn't launch process: %s", err)
} }
@ -143,7 +143,7 @@ func (d *Debugger) Run() error {
} else { } else {
// Detach // Detach
if !d.process.Exited() { if !d.process.Exited() {
if err := proctl.PtraceDetach(d.process.Pid, 0); err == nil { if err := proc.PtraceDetach(d.process.Pid, 0); err == nil {
log.Print("detached from process") log.Print("detached from process")
} else { } else {
log.Printf("couldn't detach from process: %s", err) log.Printf("couldn't detach from process: %s", err)
@ -169,7 +169,7 @@ func (d *Debugger) Detach(kill bool) error {
func (d *Debugger) State() (*api.DebuggerState, error) { func (d *Debugger) State() (*api.DebuggerState, error) {
var state *api.DebuggerState var state *api.DebuggerState
err := d.withProcess(func(p *proctl.DebuggedProcess) error { err := d.withProcess(func(p *proc.DebuggedProcess) error {
var thread *api.Thread var thread *api.Thread
th := p.CurrentThread th := p.CurrentThread
if th != nil { if th != nil {
@ -193,9 +193,9 @@ func (d *Debugger) State() (*api.DebuggerState, error) {
return state, err return state, err
} }
err := d.withProcess(func(p *proctl.DebuggedProcess) error {
func (d *Debugger) CreateBreakpoint(requestedBp *api.Breakpoint) (*api.Breakpoint, error) { func (d *Debugger) CreateBreakpoint(requestedBp *api.Breakpoint) (*api.Breakpoint, error) {
var createdBp *api.Breakpoint var createdBp *api.Breakpoint
err := d.withProcess(func(p *proc.DebuggedProcess) error {
var loc string var loc string
switch { switch {
case len(requestedBp.File) > 0: case len(requestedBp.File) > 0:
@ -263,7 +263,7 @@ func (d *Debugger) FindBreakpoint(id int) *api.Breakpoint {
func (d *Debugger) Threads() []*api.Thread { func (d *Debugger) Threads() []*api.Thread {
threads := []*api.Thread{} threads := []*api.Thread{}
d.withProcess(func(p *proctl.DebuggedProcess) error { d.withProcess(func(p *proc.DebuggedProcess) error {
for _, th := range p.Threads { for _, th := range p.Threads {
threads = append(threads, convertThread(th)) threads = append(threads, convertThread(th))
} }
@ -291,23 +291,23 @@ func (d *Debugger) Command(command *api.DebuggerCommand) (*api.DebuggerState, er
var err error var err error
switch command.Name { switch command.Name {
case api.Continue: case api.Continue:
err = d.withProcess(func(p *proctl.DebuggedProcess) error { err = d.withProcess(func(p *proc.DebuggedProcess) error {
log.Print("continuing") log.Print("continuing")
e := p.Continue() e := p.Continue()
return e return e
}) })
case api.Next: case api.Next:
err = d.withProcess(func(p *proctl.DebuggedProcess) error { err = d.withProcess(func(p *proc.DebuggedProcess) error {
log.Print("nexting") log.Print("nexting")
return p.Next() return p.Next()
}) })
case api.Step: case api.Step:
err = d.withProcess(func(p *proctl.DebuggedProcess) error { err = d.withProcess(func(p *proc.DebuggedProcess) error {
log.Print("stepping") log.Print("stepping")
return p.Step() return p.Step()
}) })
case api.SwitchThread: case api.SwitchThread:
err = d.withProcess(func(p *proctl.DebuggedProcess) error { err = d.withProcess(func(p *proc.DebuggedProcess) error {
log.Printf("switching to thread %d", command.ThreadID) log.Printf("switching to thread %d", command.ThreadID)
return p.SwitchThread(command.ThreadID) return p.SwitchThread(command.ThreadID)
}) })
@ -319,7 +319,7 @@ func (d *Debugger) Command(command *api.DebuggerCommand) (*api.DebuggerState, er
} }
if err != nil { if err != nil {
// Only report the error if it's not a process exit. // Only report the error if it's not a process exit.
if _, exited := err.(proctl.ProcessExitedError); !exited { if _, exited := err.(proc.ProcessExitedError); !exited {
return nil, err return nil, err
} }
} }
@ -333,7 +333,7 @@ func (d *Debugger) Sources(filter string) ([]string, error) {
} }
files := []string{} files := []string{}
d.withProcess(func(p *proctl.DebuggedProcess) error { d.withProcess(func(p *proc.DebuggedProcess) error {
for f := range p.Sources() { for f := range p.Sources() {
if regex.Match([]byte(f)) { if regex.Match([]byte(f)) {
files = append(files, f) files = append(files, f)
@ -351,7 +351,7 @@ func (d *Debugger) Functions(filter string) ([]string, error) {
} }
funcs := []string{} funcs := []string{}
d.withProcess(func(p *proctl.DebuggedProcess) error { d.withProcess(func(p *proc.DebuggedProcess) error {
for _, f := range p.Funcs() { for _, f := range p.Funcs() {
if f.Sym != nil && regex.Match([]byte(f.Name)) { if f.Sym != nil && regex.Match([]byte(f.Name)) {
funcs = append(funcs, f.Name) funcs = append(funcs, f.Name)
@ -369,7 +369,7 @@ func (d *Debugger) PackageVariables(threadID int, filter string) ([]api.Variable
} }
vars := []api.Variable{} vars := []api.Variable{}
err = d.withProcess(func(p *proctl.DebuggedProcess) error { err = d.withProcess(func(p *proc.DebuggedProcess) error {
thread, found := p.Threads[threadID] thread, found := p.Threads[threadID]
if !found { if !found {
return fmt.Errorf("couldn't find thread %d", threadID) return fmt.Errorf("couldn't find thread %d", threadID)
@ -390,7 +390,7 @@ func (d *Debugger) PackageVariables(threadID int, filter string) ([]api.Variable
func (d *Debugger) LocalVariables(threadID int) ([]api.Variable, error) { func (d *Debugger) LocalVariables(threadID int) ([]api.Variable, error) {
vars := []api.Variable{} vars := []api.Variable{}
err := d.withProcess(func(p *proctl.DebuggedProcess) error { err := d.withProcess(func(p *proc.DebuggedProcess) error {
thread, found := p.Threads[threadID] thread, found := p.Threads[threadID]
if !found { if !found {
return fmt.Errorf("couldn't find thread %d", threadID) return fmt.Errorf("couldn't find thread %d", threadID)
@ -409,7 +409,7 @@ func (d *Debugger) LocalVariables(threadID int) ([]api.Variable, error) {
func (d *Debugger) FunctionArguments(threadID int) ([]api.Variable, error) { func (d *Debugger) FunctionArguments(threadID int) ([]api.Variable, error) {
vars := []api.Variable{} vars := []api.Variable{}
err := d.withProcess(func(p *proctl.DebuggedProcess) error { err := d.withProcess(func(p *proc.DebuggedProcess) error {
thread, found := p.Threads[threadID] thread, found := p.Threads[threadID]
if !found { if !found {
return fmt.Errorf("couldn't find thread %d", threadID) return fmt.Errorf("couldn't find thread %d", threadID)
@ -428,7 +428,7 @@ func (d *Debugger) FunctionArguments(threadID int) ([]api.Variable, error) {
func (d *Debugger) EvalVariableInThread(threadID int, symbol string) (*api.Variable, error) { func (d *Debugger) EvalVariableInThread(threadID int, symbol string) (*api.Variable, error) {
var variable *api.Variable var variable *api.Variable
err := d.withProcess(func(p *proctl.DebuggedProcess) error { err := d.withProcess(func(p *proc.DebuggedProcess) error {
thread, found := p.Threads[threadID] thread, found := p.Threads[threadID]
if !found { if !found {
return fmt.Errorf("couldn't find thread %d", threadID) return fmt.Errorf("couldn't find thread %d", threadID)
@ -446,7 +446,7 @@ func (d *Debugger) EvalVariableInThread(threadID int, symbol string) (*api.Varia
func (d *Debugger) Goroutines() ([]*api.Goroutine, error) { func (d *Debugger) Goroutines() ([]*api.Goroutine, error) {
goroutines := []*api.Goroutine{} goroutines := []*api.Goroutine{}
err := d.withProcess(func(p *proctl.DebuggedProcess) error { err := d.withProcess(func(p *proc.DebuggedProcess) error {
gs, err := p.GoroutinesInfo() gs, err := p.GoroutinesInfo()
if err != nil { if err != nil {
return err return err
@ -460,7 +460,7 @@ func (d *Debugger) Goroutines() ([]*api.Goroutine, error) {
} }
// convertBreakpoint converts an internal breakpoint to an API Breakpoint. // convertBreakpoint converts an internal breakpoint to an API Breakpoint.
func convertBreakpoint(bp *proctl.Breakpoint) *api.Breakpoint { func convertBreakpoint(bp *proc.Breakpoint) *api.Breakpoint {
return &api.Breakpoint{ return &api.Breakpoint{
ID: bp.ID, ID: bp.ID,
FunctionName: bp.FunctionName, FunctionName: bp.FunctionName,
@ -471,7 +471,7 @@ func convertBreakpoint(bp *proctl.Breakpoint) *api.Breakpoint {
} }
// convertThread converts an internal thread to an API Thread. // convertThread converts an internal thread to an API Thread.
func convertThread(th *proctl.ThreadContext) *api.Thread { func convertThread(th *proc.ThreadContext) *api.Thread {
var ( var (
function *api.Function function *api.Function
file string file string
@ -504,7 +504,7 @@ func convertThread(th *proctl.ThreadContext) *api.Thread {
} }
// convertVar converts an internal variable to an API Variable. // convertVar converts an internal variable to an API Variable.
func convertVar(v *proctl.Variable) api.Variable { func convertVar(v *proc.Variable) api.Variable {
return api.Variable{ return api.Variable{
Name: v.Name, Name: v.Name,
Value: v.Value, Value: v.Value,
@ -513,7 +513,7 @@ func convertVar(v *proctl.Variable) api.Variable {
} }
// convertGoroutine converts an internal Goroutine to an API Goroutine. // convertGoroutine converts an internal Goroutine to an API Goroutine.
func convertGoroutine(g *proctl.G) *api.Goroutine { func convertGoroutine(g *proc.G) *api.Goroutine {
var function *api.Function var function *api.Function
if g.Func != nil { if g.Func != nil {
function = &api.Function{ function = &api.Function{

@ -5,7 +5,7 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
protest "github.com/derekparker/delve/proctl/test" protest "github.com/derekparker/delve/proc/test"
"github.com/derekparker/delve/service" "github.com/derekparker/delve/service"
"github.com/derekparker/delve/service/api" "github.com/derekparker/delve/service/api"
) )

@ -12,7 +12,7 @@ import (
"github.com/peterh/liner" "github.com/peterh/liner"
sys "golang.org/x/sys/unix" sys "golang.org/x/sys/unix"
"github.com/derekparker/delve/proctl" "github.com/derekparker/delve/proc"
"github.com/derekparker/delve/service" "github.com/derekparker/delve/service"
) )
@ -92,8 +92,8 @@ func (t *Term) Run() (error, int) {
cmd := cmds.Find(cmdstr) cmd := cmds.Find(cmdstr)
if err := cmd(t.client, args...); err != nil { if err := cmd(t.client, args...); err != nil {
switch err.(type) { switch err.(type) {
case proctl.ProcessExitedError: case proc.ProcessExitedError:
pe := err.(proctl.ProcessExitedError) pe := err.(proc.ProcessExitedError)
fmt.Fprintf(os.Stderr, "Process exited with status %d\n", pe.Status) fmt.Fprintf(os.Stderr, "Process exited with status %d\n", pe.Status)
default: default:
fmt.Fprintf(os.Stderr, "Command failed: %s\n", err) fmt.Fprintf(os.Stderr, "Command failed: %s\n", err)