This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Problems with gprof (C++ name mangling)
- From: Markus Muckhoff <markus at xpiriax dot de>
- To: binutils at sourceware dot org
- Date: Mon, 17 Aug 2009 11:01:55 +0200
- Subject: Problems with gprof (C++ name mangling)
Hi everybody,
I'm currently trying to profile some of my windows / linux projects with
gprof. Until I used gprof with pure C code, everything works fine! But
when I started to use C++ I got some name mangling problems ... In detail:
* I want to profile code using namespaces (example follows)
* I want create a call graph starting at a given function (susspressing
the other parts of the code / call graph)
I did the following (under mingw with g++ 4.4.0 dw2):
1.) g++ -g -pg -o testprofiler.exe testprofiler.cpp
2.) testprofiler.exe
3.) gprof -q"TestProfiler::specialMadd(TestProfiler::VERTEX,
TestProfiler::VERTEX, TestProfiler::VERTEX)" testprofiler.exe >result.txt
But the output looks exactly the same as I use "gprof -q
testprofiler.exe >result.txt".
I tried different names and name manglings with -q (specialMadd /
TestProfiler::specialMadd /
__ZN12TestProfiler11specialMaddENS_6VERTEXES0_S0_ / ...) but nothing works!
I activated the debugging option of gprof (gprof -d
-q"TestProfiler::specialMadd(TestProfiler::VERTEX, ... ) and found this
line:
...
[parse_id] TestProfiler::specialMadd(TestProfiler::VERTEX,
TestProfiler::VERTEX, TestProfiler::VERTEX) -> <non-existent-file>:VERTEX)
...
It seems to me, that gprof interprets the whole string preceding the
last : as filename.
Did I do something wrong or is there a workaround?
Thanks in advance
Markus
Xpiriax Software
www.xpiriax.de
---------------------------------------------------------------
testprofiler.cpp
---------------------------------------------------------------
#include <stdio.h>
namespace TestProfiler {
struct VERTEX {
float x,y,z;
};
struct VERTEX add(struct VERTEX a, struct VERTEX b) {
struct VERTEX ret;
ret.x = a.x + b.x;
ret.y = a.y + b.y;
ret.z = a.z + b.z;
return ret;
}
struct VERTEX sub(struct VERTEX a, struct VERTEX b) {
struct VERTEX ret;
ret.x = a.x + b.x;
ret.y = a.y + b.y;
ret.z = a.z + b.z;
return ret;
}
float mul(struct VERTEX a, struct VERTEX b) {
return(a.x * b.x + a.y * b.y + a.z * b.z);
}
float specialMadd(struct VERTEX a, struct VERTEX b, struct VERTEX c) {
return mul(add(a,b), add(a,c));
}
float specialMdiff(struct VERTEX a, struct VERTEX b, struct VERTEX c) {
return mul(sub(b,a), add(c,a));
}
}//end namespace TestProfiler
int main(void) {
struct TestProfiler::VERTEX v1 = {1.0f, 2.0f, 3.0f}, v2 = {1.5f,
1.3f, 5.1f}, v3 = {1.223f, 2.01f, 3.6f};
float ferg1, ferg2;
ferg1 = TestProfiler::specialMadd(v1, v2, v3);
ferg1 = TestProfiler::specialMdiff(v1, v2, v3);
printf("%f, %f\n", ferg1, ferg2);
return 0;
}
---------------------------------------------------------------