3

I am trying to profile a program using gprof. The point is that for some cases the program does not finish by itself but by using the Linux execution time limit. In this case the file 'gmon.out' is not generated.

I was wondering if there exists a way to get some kind of profiling information even in the case that the program finishes by timeout. As far as I read here it is not possible, so I would be thankfully for any comments or suggestions upon my problem.

Thanks in advance!

Permita
  • 5,503
  • 1
  • 16
  • 21
pafede2
  • 1,626
  • 4
  • 23
  • 40

2 Answers2

7

If you know for sure, that you don't have a sginal handling for a certain signal, let's say SIGTERM, you could add a signal handler that calls exit().

Then you could terminate your program with kill -SIGTERM pid and gmon.out should be created.

Ingo Leonhardt
  • 9,435
  • 2
  • 24
  • 33
  • Hi, thanks for the hint! I added the signal managing as you suggested, but still the gmon.out was not created because I used _exit, then I replaced _exit by exit and the file was successfully created. – pafede2 Sep 09 '14 at 12:26
2

If you are running the program in gdb or can attach gdb to the program you can use "p exit(0)" to close the program and dump profile data.

Venkat
  • 161
  • 2
  • 10