gperftools and pprof do not print my function names. Need advice on how to fix this

徘徊边缘 提交于 2021-01-28 07:20:27

问题


I'm currently writing a game in C++ using SDL on Ubuntu. I recently multithreaded my engine, so I switched from profiling with valgrind/callgrind to gperftools. I have gotten it to work, but it will not print my own function names. Oddly enough, it recognizes SDL function names (I've seen the reverse happening on a few threads online; shared library functions not having their names found).

kcachegrind Output

I run my program, and the execute the following two commands in order to get this:

pprof --callgrind /bin/ls ls.prof > ls.callgrind

kcachegrind ls.callgrind

I know there are several ways to use gperftools; I have done it by including "gperftools/profiler.h" and using the ProfilerStart("ls.prof") and ProfilerStop() functions.

For reference, here is part of my Makefile in case that is relevant:

OBJS = background.o gameObject.o uGrid.o main.o Timer.o sdlHandlers.o player.o handleEvents.o handleAllStateChanges.o enactAllStateChanges.o cleanLoop.o renderAll.o loadAllFiles.o loop.o inputHandler.o loopWrite.o loopDebug.o loopDebugSingleStep.o loopDebug_SDLDecoupled.o CC = g++ CFLAGS = -std=c++11 -Wall -O3 -c -g

Aegis: $(OBJS)
    $(CC) $(OBJS) -I/sdlLib -lSDL2  -I/sdlLib -lSDL2_image -I/sdlLib -lSDL2_mixer -lX11 -pthread -lprofiler -o Aegis

I removed all references to object files and the like; this is not the entire file. Upon request, I can post the entire Makefile.

Also, because people have gotten confused in the past, I AM using a copy of the SDl2 libraries in my project's folder. That is not a typo.

If anything is unclear, I am happy to answer or provide more source code if needed. Anything to get this problem fixed

Thanks!


回答1:


You seem to be linking your program without debug symbols. Add -g (or I tend to add -ggdb3) to flags.



来源:https://stackoverflow.com/questions/46007988/gperftools-and-pprof-do-not-print-my-function-names-need-advice-on-how-to-fix-t

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