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

1.4k views Asked by At

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

There are 1 answers

0
Aliaksei Kandratsenka On

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