If you look at the output of your first command you see the result `(**runtime.g)(<addr>)`, however you're trying to cast to `(runtime.g*)(<addr>)`. The correct syntax you're looking for is ` *(*runtime.g)(<addr>)`. Hope that helps!
On Monday, November 11, 2019 at 11:29:42 PM UTC-8, Xiangdong JI wrote: > > Hi Derek, > > Say I have the pointer value of a specific G struct, how to convert it to > 'struct g' (or any other form) in delve so that I can check > the details of its fields? > > For example (simply utilized runtime.m0.curg to get a pointer value here) > > (dlv) p &runtime.m0.curg > (**runtime.g)(0x56a140) > > Just tried a few commands to convert the value back to 'struct g' or a > pointer to 'struct g' > > (dlv) p (runtime.g*)(0x56b140) > Command failed: 1:12: expected operand, found ')' > (dlv) p ('runtime.g'*)(0x56b140) > Command failed: 1:2: illegal rune literal > (dlv) p ("runtime.g"*)(0x56b140) > Command failed: 1:14: expected operand, found ')' > (dlv) p ("runtime".g*)(0x56b140) > Command failed: 1:14: expected operand, found ')' > > Thanks. > > On Tuesday, November 12, 2019 at 2:28:12 AM UTC+8, Derek Parker wrote: >> >> Can you reply with a gist showing the exact Delve commands you are >> attempting to use and what errors are being returned? >> >> There is some more information on the expression parser here >> <https://github.com/go-delve/delve/blob/master/Documentation/cli/expr.md>. >> You can also open an issue on the Delve Github repo and we can help you out >> over there as well. >> >> On Sunday, November 10, 2019 at 11:58:24 PM UTC-8, Xiangdong JI wrote: >>> >>> Given a valid goroutine structure's pointer, say retrieving from the >>> register 'g', how can I convert it to 'struct g' in delve or gdb? >>> >>> gdb usually reports "A syntax error in expression ...", and delve issues >>> various "Command failed" message (failed to figure the proper way of >>> converting a literal, I guess). >>> >>> Thanks. >>> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8a62a611-9e83-4a2b-9751-e943d99df128%40googlegroups.com.