delve/cmd/dlv/main.go

52 lines
880 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
)
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() {
// 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() {
2015-03-09 02:26:45 +00:00
var printv bool
flag.Parse()
2014-05-20 23:11:00 +00:00
if flag.NFlag() == 0 && len(flag.Args()) == 0 {
2015-03-09 02:26:45 +00:00
fmt.Println(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)
}
2015-03-09 02:26:45 +00:00
cli.Run(os.Args[1:])
2014-05-20 21:29:01 +00:00
}