提交 8ce88095 编写于 作者: A aarzilli 提交者: Derek Parker

cmd/dlv: Revert 4e177b, use new flag name for debug logging options

Previously to 4e177bb9 it was possible
to use --log without arguments to enable logging, this commit reenables
that use case.

The new functionality of the --log flag moved to a new flag name
--logx.

Fixes #1188
上级 7fd47749
......@@ -31,11 +31,12 @@ Pass flags to the program you are debugging using `--`, for example:
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -31,11 +31,12 @@ dlv attach pid [executable]
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -26,11 +26,12 @@ dlv connect addr
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -30,11 +30,12 @@ dlv core <executable> <core>
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -37,11 +37,12 @@ dlv debug [package]
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -31,11 +31,12 @@ dlv exec <path/to/binary>
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -30,11 +30,12 @@ dlv replay [trace directory]
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -26,11 +26,12 @@ dlv run
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -37,11 +37,12 @@ dlv test [package]
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -39,11 +39,12 @@ dlv trace [package] regexp
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -26,11 +26,12 @@ dlv version
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "localhost:0")
--log string Comma separated list of components that should produce debug output, possible values:
--log Enable debugging server logging.
--log-output string Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
(default "false")
Defaults to "debugger" when logging is enabled with --log.
--wd string Working directory for running the program. (default ".")
```
......
......@@ -26,7 +26,9 @@ import (
var (
// Log is whether to log debug statements.
Log string
Log bool
// LogOutput is a comma separated list of components that should produce debug output.
LogOutput string
// Headless is whether to run without terminal.
Headless bool
// APIVersion is the requested API version while running headless
......@@ -86,11 +88,12 @@ func New(docCall bool) *cobra.Command {
}
RootCommand.PersistentFlags().StringVarP(&Addr, "listen", "l", "localhost:0", "Debugging server listen address.")
RootCommand.PersistentFlags().StringVarP(&Log, "log", "", "false", `Comma separated list of components that should produce debug output, possible values:
RootCommand.PersistentFlags().BoolVarP(&Log, "log", "", false, "Enable debugging server logging.")
RootCommand.PersistentFlags().StringVarP(&LogOutput, "log-output", "", "", `Comma separated list of components that should produce debug output, possible values:
debugger Log debugger commands
gdbwire Log connection to gdbserial backend
lldbout Copy output from debugserver/lldb to standard output
`)
Defaults to "debugger" when logging is enabled with --log.`)
RootCommand.PersistentFlags().BoolVarP(&Headless, "headless", "", false, "Run debug server only, in headless mode.")
RootCommand.PersistentFlags().BoolVarP(&AcceptMulti, "accept-multiclient", "", false, "Allows a headless server to accept multiple client connections. Note that the server API is not reentrant and clients will have to coordinate.")
RootCommand.PersistentFlags().IntVar(&APIVersion, "api-version", 1, "Selects API version when headless.")
......@@ -311,7 +314,10 @@ func debugCmd(cmd *cobra.Command, args []string) {
func traceCmd(cmd *cobra.Command, args []string) {
status := func() int {
logflags.Setup(Log)
if err := logflags.Setup(Log, LogOutput); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return 1
}
debugname, err := filepath.Abs(cmd.Flag("output").Value.String())
if err != nil {
......@@ -463,7 +469,10 @@ const (
)
func execute(attachPid int, processArgs []string, conf *config.Config, coreFile string, kind executeKind) int {
logflags.Setup(Log)
if err := logflags.Setup(Log, LogOutput); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return 1
}
// Make a TCP listener
listener, err := net.Listen("tcp", Addr)
......
......@@ -210,7 +210,7 @@ func checkAutogenDoc(t *testing.T, filename, gencommand string, generated []byte
saved := slurpFile(t, os.ExpandEnv(fmt.Sprintf("$GOPATH/src/github.com/derekparker/delve/%s", filename)))
if len(saved) != len(generated) {
t.Fatalf("%s: needs to be regenerated run scripts/gen-cli-docs.go", filename)
t.Fatalf("%s: needs to be regenerated; run %s", filename, gencommand)
}
for i := range saved {
......
package logflags
import "strings"
import (
"errors"
"strings"
)
var debugger = false
var gdbWire = false
......@@ -23,11 +26,18 @@ func LLDBServerOutput() bool {
return lldbServerOutput
}
var errLogstrWithoutLog = errors.New("--log-output specified without --log")
// Setup sets debugger flags based on the contents of logstr.
func Setup(logstr string) {
if logstr == "true" || logstr == "" {
debugger = true
return
func Setup(log bool, logstr string) error {
if !log {
if logstr != "" {
return errLogstrWithoutLog
}
return nil
}
if logstr == "" {
logstr = "debugger"
}
v := strings.Split(logstr, ",")
for _, logcmd := range v {
......@@ -40,4 +50,5 @@ func Setup(logstr string) {
lldbServerOutput = true
}
}
return nil
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册