Home > Mobile >  gdb: Is there a performance penalty?
gdb: Is there a performance penalty?

Time:03-20

Is there any performance penalty if I attach gdb to a process? I do not set any breakpoint and I'm only waiting for a segfault.

Thanks

CodePudding user response:

Is there any performance penalty if I attach gdb to a process?

Yes.

There are several aspects which slow down when a debugger is attached. One is thread creation / destruction -- GDB needs to keep track of threads, and the pthread library has hooks which GDB sets up.

Also GDB always sets a few internal breakpoints. One of them is on _dl_debug_state(), and so dlopen() and dlclose() become slower as well.

Finally, GDB gets notified by the kernel about any signals the program receives, so any application which handles a lot of signals will run slower.

  •  Tags:  
  • c gdb
  • Related