2014-05-20 21:29:01 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-08-23 13:20:56 +00:00
|
|
|
"flag"
|
2014-05-20 21:29:01 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2014-05-23 20:27:08 +00:00
|
|
|
"runtime"
|
2014-05-20 21:29:01 +00:00
|
|
|
|
2014-12-18 00:22:57 +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() {
|
2014-05-23 20:27:08 +00:00
|
|
|
// 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.
|
2014-05-23 20:27:08 +00:00
|
|
|
runtime.LockOSThread()
|
2014-11-23 16:22:04 +00:00
|
|
|
}
|
2014-05-23 20:27:08 +00:00
|
|
|
|
2014-11-23 16:22:04 +00:00
|
|
|
func main() {
|
2014-06-25 19:58:45 +00:00
|
|
|
var (
|
2014-12-09 18:11:47 +00:00
|
|
|
pid int
|
|
|
|
run bool
|
|
|
|
printv bool
|
2014-06-25 19:58:45 +00:00
|
|
|
)
|
2014-05-20 23:11:00 +00:00
|
|
|
|
2014-08-23 13:20:56 +00:00
|
|
|
flag.IntVar(&pid, "pid", 0, "Pid of running process to attach to.")
|
2014-10-13 23:30:37 +00:00
|
|
|
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.")
|
2014-08-23 13:20:56 +00:00
|
|
|
flag.Parse()
|
2014-05-20 23:11:00 +00:00
|
|
|
|
2014-11-14 07:41:12 +00:00
|
|
|
if flag.NFlag() == 0 && len(flag.Args()) == 0 {
|
2014-08-23 13:20:56 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2014-12-18 00:22:57 +00:00
|
|
|
cli.Run(run, pid, flag.Args())
|
2014-05-20 21:29:01 +00:00
|
|
|
}
|