I've been playing with uprobes. In order to probe a specific object in runtime, I need to know the size of internal go struct. In my case, the poll.FD
. I could count each nested struct manually, but this could increase the complexity if we are working with a lot nested struct.
My first attempt was to use dlv expression , len <variable>
. Didn't work Command failed: command not available
My second attempt was to create a program to extract this information:
package main
import (
"fmt"
"internal/poll"
"unsafe"
)
func main() {
fmt.Println("size of internal/poll FD struct:", unsafe.Sizeof(poll.FD{}))
}
When I compile the code above, the following message is shown:
main.go:7:2: use of internal package internal/poll not allowed
Am I missing something? Is there a better way get that information?
You can try do it by Testing in same package, in order to pass this limitation.