{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/21093","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/21093/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/21093/comments","events_url":"https://api.github.com/repos/golang/go/issues/21093/events","html_url":"https://github.com/golang/go/issues/21093","id":244203216,"number":21093,"title":"debug/dwarf: StructField.ByteSize not set","user":{"login":"randall77","id":6889504,"avatar_url":"https://avatars0.githubusercontent.com/u/6889504?v=4","gravatar_id":"","url":"https://api.github.com/users/randall77","html_url":"https://github.com/randall77","followers_url":"https://api.github.com/users/randall77/followers","following_url":"https://api.github.com/users/randall77/following{/other_user}","gists_url":"https://api.github.com/users/randall77/gists{/gist_id}","starred_url":"https://api.github.com/users/randall77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randall77/subscriptions","organizations_url":"https://api.github.com/users/randall77/orgs","repos_url":"https://api.github.com/users/randall77/repos","events_url":"https://api.github.com/users/randall77/events{/privacy}","received_events_url":"https://api.github.com/users/randall77/received_events","type":"User","site_admin":false},"labels":[{"id":578237966,"url":"https://api.github.com/repos/golang/go/labels/Debugging","name":"Debugging","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/56","html_url":"https://github.com/golang/go/milestone/56","labels_url":"https://api.github.com/repos/golang/go/milestones/56/labels","id":2473074,"number":56,"title":"Go1.10","description":"","creator":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":853,"closed_issues":356,"state":"open","created_at":"2017-04-21T19:22:29Z","updated_at":"2017-10-18T18:07:56Z","due_on":"2018-01-31T08:00:00Z","closed_at":null},"comments":4,"created_at":"2017-07-19T23:25:12Z","updated_at":"2017-10-18T18:39:04Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"The fields StructField.ByteSize is not set.  (ByteOffset is set.)\r\nDemonstration:\r\n```\r\npackage main\r\n\r\nimport (\r\n\t\"debug/dwarf\"\r\n\t\"debug/elf\"\r\n\t\"fmt\"\r\n\t\"os\"\r\n)\r\n\r\nfunc main() {\r\n\tbinary := os.Args[0]\r\n\tf, err := os.Open(binary)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\te, err := elf.NewFile(f)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\td, err := e.DWARF()\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tr := d.Reader()\r\n\tfor e, err := r.Next(); e != nil && err == nil; e, err = r.Next() {\r\n\t\tif e.Tag != dwarf.TagStructType {\r\n\t\t\tcontinue\r\n\t\t}\r\n\t\tt, err := d.Type(e.Offset)\r\n\t\tif err != nil {\r\n\t\t\tpanic(err)\r\n\t\t}\r\n\t\tfmt.Printf(\"%s\\n\", t)\r\n\t\ts := t.(*dwarf.StructType)\r\n\t\tfor _, f := range s.Field {\r\n\t\t\tfmt.Printf(\"  %d %d %s\\n\", f.ByteOffset, f.ByteSize, f.Name)\r\n\t\t}\r\n\t}\r\n}\r\n```\r\nBuild with `go build` and run it with no args.  It reads its own DWARF info and prints out the info for all the struct fields.\r\nStart of output:\r\n```\r\nstruct runtime._type\r\n  0 0 size\r\n  8 0 ptrdata\r\n  16 0 hash\r\n  20 0 tflag\r\n  21 0 align\r\n  22 0 fieldalign\r\n  23 0 kind\r\n  24 0 alg\r\n  32 0 gcdata\r\n  40 0 str\r\n  44 0 ptrToThis\r\nstruct runtime.typeAlg\r\n  0 0 hash\r\n  8 0 equal\r\nstruct runtime.interfacetype\r\n  0 0 typ\r\n  48 0 pkgpath\r\n  56 0 mhdr\r\n```\r\n\r\nI think this is a bug with debug/dwarf, not the DWARF writer in the toolchain.  I get the same behavior when reading DWARF from a C binary. (Or perhaps the C writer has the same issue?)\r\n\r\nByteSize might be kind of useful (or is .Type.Size() the recommended fallback instead?). At the very least, we should document that it isn't provided.\r\n\r\n@heschik @derekparker "},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/337688220","html_url":"https://github.com/golang/go/issues/21093#issuecomment-337688220","issue_url":"https://api.github.com/repos/golang/go/issues/21093","id":337688220,"user":{"login":"gopherbot","id":8566911,"avatar_url":"https://avatars1.githubusercontent.com/u/8566911?v=4","gravatar_id":"","url":"https://api.github.com/users/gopherbot","html_url":"https://github.com/gopherbot","followers_url":"https://api.github.com/users/gopherbot/followers","following_url":"https://api.github.com/users/gopherbot/following{/other_user}","gists_url":"https://api.github.com/users/gopherbot/gists{/gist_id}","starred_url":"https://api.github.com/users/gopherbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gopherbot/subscriptions","organizations_url":"https://api.github.com/users/gopherbot/orgs","repos_url":"https://api.github.com/users/gopherbot/repos","events_url":"https://api.github.com/users/gopherbot/events{/privacy}","received_events_url":"https://api.github.com/users/gopherbot/received_events","type":"User","site_admin":false},"created_at":"2017-10-18T18:39:04Z","updated_at":"2017-10-18T18:39:04Z","author_association":"NONE","body":"Change https://golang.org/cl/71671 mentions this issue: `debug/dwarf: clarify StructField.ByteSize doc`"}}
{"actor":{"display_login":"gopherbot"}}