gprof2dot icon indicating copy to clipboard operation
gprof2dot copied to clipboard

valgrind: A lot of information is lost, graph has few disconnected components

Open Akuli opened this issue 2 years ago • 0 comments

asdf.c:

#include <stdio.h>
#include <SDL2/SDL.h>

void a(void) {
	long long sum = 0;
	for (long long i = 0; i <= 100000000LL; i++)
		sum += i;
	printf("%lld\n", sum);
}
void b(void) { a(); }
void c(void) { b(); }
int main(void) { SDL_CreateWindow("a", 5, 5, 100, 100, 0); c(); return 0; }

commands:

gcc asdf.c -lSDL2
valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./a.out
gprof2dot callgrind.out --format=callgrind --output=foo.dot
dot -Tpng foo.dot -o foo.png

resulting foo.png:

foo

I believe the problem is in gprof2dot, because kcachegrind callgrind.out correctly shows that most of the time is spent in a():

k

Content of callgrind.out (71191 lines): https://termbin.com/e2k8

If I comment out the call to SDL_CreateWindow(), valgrind's brk segment overflow in thread #1 warning disappears, and I also get much better results:

foo

Akuli avatar Dec 10 '21 15:12 Akuli