我需要一些帮助,为Go使用GDB + Python扩展。
我想要研究的结构LogQuery的组成如下:
LogQuery (struct)
CommonCmd (struct)
Context (struct)
out
Globs
flagHelp
...
flagLog
...
Breakpoint 3, acme/subcmds.CmdObj (context=..., cmdName="log_query", noname=
void) at /nobackup/git/goacme/src/acme/subcmds/cmder.go:32
32 cmd = NewLogQuery(context) //debugger
(gdb) s
acme/subcmds.NewLogQuery (context=..., noname=void)
at /nobackup/git/goacme/src/acme/subcmds/log_query.go:29
29 func NewLogQuery(context context.Context) LogQuery {
(gdb) n
30 obj := LogQuery{NewCommonCmd(context), "", "", "", "", 0, "", ""}
(gdb)
31 return obj
1 - 在构造函数中打印对象(obj)。但我怎么看'obj.Globs'?
(gdb) p obj
$8 = {acme/subcmds.CommonCmd = {acme/context.Context = {out = 0, Globs =
0xf840050140}, FlagArgs = "", flagDebug = "", flagHelp = false,
flagOutput = "", flagVerbose = false, CmdName = "", debug = 0x0},
flagColl = "", flagData = "", flagDb = "", flagHost = "", flagLimit = 0,
flagLog = "", flagQuery = ""}
返回来电者
(gdb) n
acme/subcmds.CmdObj (context=..., cmdName="log_query", noname=void)
at /nobackup/git/goacme/src/acme/subcmds/cmder.go:40
40 if cmdName == "acme" {
在这里,我看到了对象的类型,但似乎无法在其中看到任何内容
(gdb) p cmd
$9 = "(subcmds.LogQuery)0xf840052b60"
(gdb) p $dtype(cmd)
$2 = (struct cmds.Add *) 0xf840034210
(gdb) p cmd->Globs
A syntax error in expression, near `>Globs'.
(gdb) p cmd.Globs
There is no member named Globs.