<pre class="notranslate">I'm trying to profile a cgo package. See the attached test case.

When running with clang "top" looks like this:

Total: 526 samples
      66  12.5%  12.5%       66  12.5% 000000000402483b
      57  10.8%  23.4%       57  10.8% 0000000004024761
      25   4.8%  28.1%       25   4.8% 0000000004018c22
      18   3.4%  31.6%       18   3.4% 0000000004017bf7
      11   2.1%  33.7%       11   2.1% 0000000004018c55
       8   1.5%  35.2%        8   1.5% 0000000004017b64
       8   1.5%  36.7%        8   1.5% 0000000004017c88
       8   1.5%  38.2%        8   1.5% 0000000004018c60
       7   1.3%  39.5%        7   1.3% 0000000004017b86
       7   1.3%  40.9%        7   1.3% 0000000004018c45

When running with gcc 4.8 "top" looks like this:

Total: 531 samples
     531 100.0% 100.0%      531 100.0% 000000000402567b
       0   0.0% 100.0%      531 100.0% 0000000004018e60

In both cases I'm getting addresses instead of names. With gcc all the samples are
appearing as a single address. This happens with C or C++ code. C++ is attached. Rename
.cc to .c and comment out #ifdef in .h file to make C.

I'm running:

CX=g++-4.8 gotip test -c
./cgotest.test -test.cpuprofile=prof.out -test.bench=. -test.benchtime=3s -test.v
gotip tool pprof cgotest.test prof.out

Which compiler are you using (5g, 6g, 8g, gccgo)?

default w/ clang++
default w/ GNU g++ 4.8
default w/ clang
default w/ GNU gcc 4.8

Which operating system are you using?

Max OS X 10.8.5

Which version are you using?  (run 'go version')

go version devel +d744da8c8cbf Wed Sep 25 16:18:33 2013 -0400 darwin/amd64

Please provide any additional information below.

gcc 4.8 is installed with `brew install gcc48`</pre>
<p dir="auto">Attachments:</p>
<ol dir="auto">
<li><a href="https://storage.googleapis.com/go-attachment/6481/0/cgotest.zip" rel="nofollow">cgotest.zip</a> (695505 bytes)</li>
</ol>
<pre class="notranslate">from src/cmd/cgo/gcc.go:
  1286              if isStructUnionClass(sub.Go) {
  1287                  // Use the typedef name for C code.
  1288                  typedef[sub.Go.(*ast.Ident).Name].C = t.C
  1289              }

When handling one of Objective-C's internal types, go get github.com/andlabs/ui fails
with a nil pointer dereference panic at line 1288 above. Upon further investigation:

### sub.Go:&amp;ast.Ident{NamePos:0, Name:"_Ctype_struct_objc_object",
Obj:(*ast.Object)(nil)} sub.Go.(*ast.Ident):&amp;ast.Ident{NamePos:0,
Name:"_Ctype_struct_objc_object", Obj:(*ast.Object)(nil)}
....Name:"_Ctype_struct_objc_object"
typedef:map[string]*main.Type{"_Ctype_struct_objc_cache":(*main.Type)(0x2083eacc0),
"_Ctype_int":(*main.Type)(0x2084d7480),
"_Ctype_struct_objc_method_list":(*main.Type)(0x2084d7e00),
"_Ctype_SEL":(*main.Type)(0x2084d7b00),
"_Ctype_Class":(*main.Type)(0x2084d7040),
"_Ctype_long":(*main.Type)(0x2084d7280),
"_Ctype_struct_objc_ivar":(*main.Type)(0x2084d7700),
"_Ctype_Method":(*main.Type)(0x2083eac00),
"_Ctype_struct_objc_selector":(*main.Type)(0x2084d7a80),
"_Ctype_IMP":(*main.Type)(0x2084d7cc0),
"_Ctype_struct_objc_method":(*main.Type)(0x2084d7d80),
"_Ctype_uint":(*main.Type)(0x2084d7f80),
"_Ctype_Protocol":(*main.Type)(0x2083eb000),
"_Ctype_char":(*main.Type)(0x2084d71c0),
"_Ctype_struct_objc_ivar_list":(*main.Type)(0x2084d7780)}
t:&amp;main.Type{Size:8, Align:-1, C:(*main.TypeRepr)(0x2084f66f0),
Go:(*ast.Ident)(0x2084e53c0), EnumValues:map[string]int64(nil), Typedef:""}
t.C:&amp;main.TypeRepr{Repr:"Protocol", FormatArgs:[]interface {}(nil)}
### expr:(*main.Type)(nil)

so while all the parts of the typedef[...] line are valid, the typedef[...] expression
itself is not. I'm not sure what's going on here.

I'm running Mac OS X 10.8 with go version
    go version devel +f39dff1bf0d4 Thu Jun 19 22:18:24 2014 +1000 darwin/amd64
and clang version
    Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
    Target: x86_64-apple-darwin12.5.0
    Thread model: posix
but people at <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="35140716" data-permission-text="Title is private" data-url="https://github.com/andlabs/ui/issues/9" data-hovercard-type="issue" data-hovercard-url="/andlabs/ui/issues/9/hovercard" href="https://github.com/andlabs/ui/issues/9">andlabs/ui#9</a> have different setups.

Thanks!</pre>