delve/cmd/dlv/main.go

45 lines
877 B
Go
Raw Normal View History

2014-05-20 21:29:01 +00:00
package main
import (
"flag"
2014-05-20 21:29:01 +00:00
"fmt"
"os"
"runtime"
2014-05-20 21:29:01 +00:00
"github.com/derekparker/delve/client/cli"
2014-05-20 21:29:01 +00:00
)
2015-02-05 01:23:40 +00:00
const version string = "0.4.0.beta"
2014-11-10 12:53:33 +00:00
2014-11-23 16:22:04 +00:00
func init() {
// 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
2014-05-24 00:01:56 +00:00
// all commands after PTRACE_ATTACH to come from the same thread.
runtime.LockOSThread()
2014-11-23 16:22:04 +00:00
}
2014-11-23 16:22:04 +00:00
func main() {
var (
2014-12-09 18:11:47 +00:00
pid int
run bool
printv bool
)
2014-05-20 23:11:00 +00:00
flag.IntVar(&pid, "pid", 0, "Pid of running process to attach to.")
flag.BoolVar(&run, "run", false, "Compile program and begin debug session.")
2014-11-10 12:53:33 +00:00
flag.BoolVar(&printv, "v", false, "Print version number and exit.")
flag.Parse()
2014-05-20 23:11:00 +00:00
if flag.NFlag() == 0 && len(flag.Args()) == 0 {
flag.Usage()
os.Exit(0)
2014-05-20 23:11:00 +00:00
}
2014-11-10 12:53:33 +00:00
if printv {
fmt.Printf("Delve version: %s\n", version)
os.Exit(0)
}
cli.Run(run, pid, flag.Args())
2014-05-20 21:29:01 +00:00
}