* Problems with gprof (C++ name mangling)
@ 2009-08-17 9:18 Markus Muckhoff
2009-08-17 19:34 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Markus Muckhoff @ 2009-08-17 9:18 UTC (permalink / raw)
To: binutils
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;
}
---------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Problems with gprof (C++ name mangling)
2009-08-17 9:18 Problems with gprof (C++ name mangling) Markus Muckhoff
@ 2009-08-17 19:34 ` Andreas Schwab
2009-08-17 19:39 ` Markus Muckhoff
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2009-08-17 19:34 UTC (permalink / raw)
To: Markus Muckhoff; +Cc: binutils
Markus Muckhoff <markus@xpiriax.de> writes:
> Did I do something wrong or is there a workaround?
Use the mangled name, but don't include the extra leading underscore.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Problems with gprof (C++ name mangling)
2009-08-17 19:34 ` Andreas Schwab
@ 2009-08-17 19:39 ` Markus Muckhoff
0 siblings, 0 replies; 3+ messages in thread
From: Markus Muckhoff @ 2009-08-17 19:39 UTC (permalink / raw)
To: Andreas Schwab; +Cc: binutils
Hi Andreas,
thank you for the hint. It now works for me! Unfortunately I didn't
figure it out during my research ;-)
Markus
Andreas Schwab schrieb:
> Markus Muckhoff <markus@xpiriax.de> writes:
>
>
>> Did I do something wrong or is there a workaround?
>>
>
> Use the mangled name, but don't include the extra leading underscore.
>
> Andreas.
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-17 19:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-17 9:18 Problems with gprof (C++ name mangling) Markus Muckhoff
2009-08-17 19:34 ` Andreas Schwab
2009-08-17 19:39 ` Markus Muckhoff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).