Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(33)

Issue 4244052: code review 4244052: cgo: fix dwarf type parsing (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 7 months ago by niemeyer
Modified:
13 years, 6 months ago
Reviewers:
CC:
rsc, golang-dev
Visibility:
Public.

Description

cgo: fix dwarf type parsing The recursive algorithm used to parse types in cgo has a bug related to building the C type representation. As an example, when the recursion starts at a type *T, the C type representation won't be known until type T itself is parsed. But then, it is possible that type T references the type **T internally. The latter representation is built based on the one of *T, which started the recursion, so it won't attempt to parse it again, and will instead use the current representation value for *T, which is still empty at this point. This problem was fixed by introducing a simple TypeRepr type which builds the string representation lazily, analogous to how the Go type information is built within the same algorithm. This way, even if a type representation is still unknown at some level in the recursion, representations dependant on it can still be created correctly.

Patch Set 1 #

Patch Set 2 : diff -r 03da6860bb39 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 03da6860bb39 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 03da6860bb39 https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 5 : diff -r 6e0c3b77928a https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+85 lines, -48 lines) Patch
M src/cmd/cgo/gcc.go View 1 2 11 chunks +45 lines, -18 lines 0 comments Download
M src/cmd/cgo/main.go View 1 2 1 chunk +7 lines, -1 line 0 comments Download
M src/cmd/cgo/out.go View 1 2 3 4 7 chunks +33 lines, -29 lines 0 comments Download

Messages

Total messages: 3
niemeyer
Hello rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 7 months ago (2011-03-06 13:45:19 UTC) #1
rsc
LGTM http://codereview.appspot.com/4244052/diff/6001/src/cmd/cgo/gcc.go File src/cmd/cgo/gcc.go (right): http://codereview.appspot.com/4244052/diff/6001/src/cmd/cgo/gcc.go#newcode789 src/cmd/cgo/gcc.go:789: return fmt.Sprintf(tr.Repr, tr.FormatArgs...) Very cool.
13 years, 7 months ago (2011-03-06 22:37:32 UTC) #2
rsc
13 years, 7 months ago (2011-03-06 23:06:02 UTC) #3
*** Submitted as http://code.google.com/p/go/source/detail?r=7c7d23f8ddbc ***

cgo: fix dwarf type parsing

The recursive algorithm used to parse types in cgo
has a bug related to building the C type representation.

As an example, when the recursion starts at a type *T,
the C type representation won't be known until type T
itself is parsed.  But then, it is possible that type T
references the type **T internally.  The latter
representation is built based on the one of *T, which
started the recursion, so it won't attempt to parse it
again, and will instead use the current representation
value for *T, which is still empty at this point.

This problem was fixed by introducing a simple TypeRepr
type which builds the string representation lazily,
analogous to how the Go type information is built within
the same algorithm.  This way, even if a type
representation is still unknown at some level in the
recursion, representations dependant on it can still
be created correctly.

R=rsc
CC=golang-dev
http://codereview.appspot.com/4244052

Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b