gprof shows every function as 100%

白昼怎懂夜的黑 提交于 2019-12-25 02:39:17

问题


I'm using a modified auditd package, and linked gprof with it.

But from the output of gprof XX | gprof2dot | dot -Tpng output.png, all functions are 100% usage, so I cannot tell who's consuming most of the CPU resources.

(Right click on the image to have a full view)

Any ideas? Is that normal, and most importantly, how should I know which function consumes most CPU?

P.S: original gprof output http://pastie.org/8546568


回答1:


At the top of the flat profile (in the pastie.org link) is the immediate answer:

Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

Since everything took exactly no time at all, everything took the same amount of time as everything else.

The more interesting question is, why did everything take no time at all? The problem here is that auditd is setuid, and (at least in general) you cannot profile setuid programs.

(To get a profile of a program that would be setuid, make a non-suid version of it, and profile that. Sometimes you need to tweak the internals a bit to make it behave well now that it's not setuid.)

After poking around some more, I don't know why it fails. Linux uses a libc compatibility routine to fake the profil() system call for gprof. This needs the SIGPROF-based ITIMER_PROF interval timer but should generally work.

An alternative is to use OProfile, which is more general-purpose (it can profile system calls) and probably better-supported these days.



来源:https://stackoverflow.com/questions/20536873/gprof-shows-every-function-as-100

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!