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-03-01 16:18:05 +00:00
|
|
|
const version string = "0.5.0.beta"
|
2014-11-10 12:53:33 +00:00
|
|
|
|
2015-03-09 02:26:45 +00:00
|
|
|
var usage string = fmt.Sprintf(`Delve version %s
|
|
|
|
|
|
|
|
flags:
|
|
|
|
-v - Print version
|
|
|
|
|
|
|
|
Invoke with the path to a binary:
|
|
|
|
|
|
|
|
dlv ./path/to/prog
|
|
|
|
|
|
|
|
or use the following commands:
|
|
|
|
run - Build, run, and attach to program
|
|
|
|
attach - Attach to running process
|
|
|
|
`, version)
|
|
|
|
|
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() {
|
2015-03-09 02:26:45 +00:00
|
|
|
var printv bool
|
|
|
|
|
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 {
|
2015-03-09 02:26:45 +00:00
|
|
|
fmt.Println(usage)
|
2014-08-23 13:20:56 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2015-03-09 02:26:45 +00:00
|
|
|
cli.Run(os.Args[1:])
|
2014-05-20 21:29:01 +00:00
|
|
|
}
|