{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/10318","labels_url":"https://api.github.com/repos/golang/go/issues/10318/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/10318/comments","events_url":"https://api.github.com/repos/golang/go/issues/10318/events","html_url":"https://github.com/golang/go/issues/10318","id":65970808,"number":10318,"title":"debug/dwarf: No method to lookup type by type signature","user":{"login":"aclements","id":2688315,"avatar_url":"https://avatars.githubusercontent.com/u/2688315?v=3","gravatar_id":"","url":"https://api.github.com/users/aclements","html_url":"https://github.com/aclements","followers_url":"https://api.github.com/users/aclements/followers","following_url":"https://api.github.com/users/aclements/following{/other_user}","gists_url":"https://api.github.com/users/aclements/gists{/gist_id}","starred_url":"https://api.github.com/users/aclements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aclements/subscriptions","organizations_url":"https://api.github.com/users/aclements/orgs","repos_url":"https://api.github.com/users/aclements/repos","events_url":"https://api.github.com/users/aclements/events{/privacy}","received_events_url":"https://api.github.com/users/aclements/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/2","html_url":"https://github.com/golang/go/milestones/Go1.5Maybe","labels_url":"https://api.github.com/repos/golang/go/milestones/2/labels","id":905114,"number":2,"title":"Go1.5Maybe","description":"Things that might make Go 1.5, but aren't critical.\r\n","creator":{"login":"bradfitz","id":2621,"avatar_url":"https://avatars.githubusercontent.com/u/2621?v=3","gravatar_id":"","url":"https://api.github.com/users/bradfitz","html_url":"https://github.com/bradfitz","followers_url":"https://api.github.com/users/bradfitz/followers","following_url":"https://api.github.com/users/bradfitz/following{/other_user}","gists_url":"https://api.github.com/users/bradfitz/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfitz/subscriptions","organizations_url":"https://api.github.com/users/bradfitz/orgs","repos_url":"https://api.github.com/users/bradfitz/repos","events_url":"https://api.github.com/users/bradfitz/events{/privacy}","received_events_url":"https://api.github.com/users/bradfitz/received_events","type":"User","site_admin":false},"open_issues":60,"closed_issues":1,"state":"open","created_at":"2014-12-16T02:39:13Z","updated_at":"2015-04-10T04:21:50Z","due_on":"2015-07-31T04:00:00Z","closed_at":null},"comments":1,"created_at":"2015-04-02T17:15:10Z","updated_at":"2015-04-10T04:21:50Z","closed_at":null,"body":"The dwarf package internally has support for finding type entries by type signature, but it does not expose this to users of the dwarf package. (*Data).Type takes an \"info\" offset of a type entry and understands internally how to follow AttrType fields within that type that reference other types by signature. But AttrType can also be used on program entities to reference the type of that entity (e.g., the type of a variable), and any occurrence of AttrType can be either an \"info\" offset, which can be resolved by the package user; or a type signature, which cannot currently be resolved by the package user.\r\n\r\nIn practice this often isn't an issue because compilers that emit type signatures typically do so for typedef'd types (since there's little value in doing this for a single instance type), so the AttrType of the program entity will be an \"info\" offset of the typedef and that, in turn, will reference the type signature. However, compilers are free to do what they want and may emit type signatures in program entities, making the current API fragile. There's also no way for a caller to do its own decoding of the type structure if it references types by signature.\r\n\r\nConsider adding an API to fetch a type by its signature. This could be accomplished by simply exposing (*Data).sigToType, but this puts the burden of distinguishing \"info\" offests and type signatures on the user. We could instead add a variant of (*Data).Type that takes a Val (really an interface{}) and does the appropriate kind of lookup.\r\n\r\nOrthogonally, this new method could return either a dwarf.Type or a dwarf.Entry. Returning dwarf.Type forces the user to accept the dwarf package's decoding of the type structure. On the other hand, a method to resolve a type offset or signature into an Entry and another method to decode an Entry into a Type would be more flexible and would expose the ability to read the types section without forcing the caller to use dwarf.Type.\r\n\r\nSee related discussion at https://go-review.googlesource.com/#/c/7280/"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/91424594","html_url":"https://github.com/golang/go/issues/10318#issuecomment-91424594","issue_url":"https://api.github.com/repos/golang/go/issues/10318","id":91424594,"user":{"login":"rsc","id":104030,"avatar_url":"https://avatars.githubusercontent.com/u/104030?v=3","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},"created_at":"2015-04-10T04:21:50Z","updated_at":"2015-04-10T04:21:50Z","body":"If you need this for a real program, sure."}}