mirror of
				https://github.com/go-delve/delve.git
				synced 2025-10-31 02:36:18 +08:00 
			
		
		
		
	| @ -39,6 +39,7 @@ Command | Description | ||||
| [trace](#trace) | Set tracepoint. | ||||
| [types](#types) | Print list of types | ||||
| [vars](#vars) | Print package variables. | ||||
| [whatis](#whatis) | Prints type of an expression. | ||||
|  | ||||
| ## args | ||||
| 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. | ||||
|  | ||||
|  | ||||
| ## whatis | ||||
| Prints type of an expression. | ||||
| 		 | ||||
| 		whatis <expression>. | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -11,6 +11,7 @@ import ( | ||||
| 	"io" | ||||
| 	"math" | ||||
| 	"os" | ||||
| 	"reflect" | ||||
| 	"regexp" | ||||
| 	"sort" | ||||
| 	"strconv" | ||||
| @ -141,6 +142,9 @@ Called with more arguments it will execute a command on the specified goroutine. | ||||
| 	[goroutine <n>] [frame <m>] print <expression> | ||||
|  | ||||
| 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. | ||||
|  | ||||
| 	[goroutine <n>] [frame <m>] set <variable> = <value> | ||||
| @ -911,6 +915,26 @@ func printVar(t *Term, ctx callContext, args string) error { | ||||
| 	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 { | ||||
| 	// 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) | ||||
| @ -1194,7 +1218,6 @@ func disassCommand(t *Term, ctx callContext, args string) error { | ||||
| 		return disasmErr | ||||
| 	} | ||||
|  | ||||
| 	fmt.Printf("printing\n") | ||||
| 	DisasmPrint(disasm, os.Stdout) | ||||
|  | ||||
| 	return nil | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 aarzilli
					aarzilli