parent
317ebe1c58
commit
c2092d1669
@ -39,6 +39,7 @@ Command | Description
|
|||||||
[trace](#trace) | Set tracepoint.
|
[trace](#trace) | Set tracepoint.
|
||||||
[types](#types) | Print list of types
|
[types](#types) | Print list of types
|
||||||
[vars](#vars) | Print package variables.
|
[vars](#vars) | Print package variables.
|
||||||
|
[whatis](#whatis) | Prints type of an expression.
|
||||||
|
|
||||||
## args
|
## args
|
||||||
Print function arguments.
|
Print function arguments.
|
||||||
@ -320,3 +321,9 @@ Print package variables.
|
|||||||
If regex is specified only package variables with a name matching it will be returned. If -v is specified more information about each package variable will be shown.
|
If regex is specified only package variables with a name matching it will be returned. If -v is specified more information about each package variable will be shown.
|
||||||
|
|
||||||
|
|
||||||
|
## whatis
|
||||||
|
Prints type of an expression.
|
||||||
|
|
||||||
|
whatis <expression>.
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -141,6 +142,9 @@ Called with more arguments it will execute a command on the specified goroutine.
|
|||||||
[goroutine <n>] [frame <m>] print <expression>
|
[goroutine <n>] [frame <m>] print <expression>
|
||||||
|
|
||||||
See $GOPATH/src/github.com/derekparker/delve/Documentation/cli/expr.md for a description of supported expressions.`},
|
See $GOPATH/src/github.com/derekparker/delve/Documentation/cli/expr.md for a description of supported expressions.`},
|
||||||
|
{aliases: []string{"whatis"}, allowedPrefixes: scopePrefix, cmdFn: whatisCommand, helpMsg: `Prints type of an expression.
|
||||||
|
|
||||||
|
whatis <expression>.`},
|
||||||
{aliases: []string{"set"}, allowedPrefixes: scopePrefix, cmdFn: setVar, helpMsg: `Changes the value of a variable.
|
{aliases: []string{"set"}, allowedPrefixes: scopePrefix, cmdFn: setVar, helpMsg: `Changes the value of a variable.
|
||||||
|
|
||||||
[goroutine <n>] [frame <m>] set <variable> = <value>
|
[goroutine <n>] [frame <m>] set <variable> = <value>
|
||||||
@ -911,6 +915,26 @@ func printVar(t *Term, ctx callContext, args string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func whatisCommand(t *Term, ctx callContext, args string) error {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return fmt.Errorf("not enough arguments")
|
||||||
|
}
|
||||||
|
val, err := t.client.EvalVariable(ctx.Scope, args, ShortLoadConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if val.Type != "" {
|
||||||
|
fmt.Println(val.Type)
|
||||||
|
}
|
||||||
|
if val.RealType != val.Type {
|
||||||
|
fmt.Printf("Real type: %s\n", val.RealType)
|
||||||
|
}
|
||||||
|
if val.Kind == reflect.Interface && len(val.Children) > 0 {
|
||||||
|
fmt.Printf("Concrete type: %s\n", val.Children[0].Type)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func setVar(t *Term, ctx callContext, args string) error {
|
func setVar(t *Term, ctx callContext, args string) error {
|
||||||
// HACK: in go '=' is not an operator, we detect the error and try to recover from it by splitting the input string
|
// HACK: in go '=' is not an operator, we detect the error and try to recover from it by splitting the input string
|
||||||
_, err := parser.ParseExpr(args)
|
_, err := parser.ParseExpr(args)
|
||||||
@ -1194,7 +1218,6 @@ func disassCommand(t *Term, ctx callContext, args string) error {
|
|||||||
return disasmErr
|
return disasmErr
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("printing\n")
|
|
||||||
DisasmPrint(disasm, os.Stdout)
|
DisasmPrint(disasm, os.Stdout)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user