سؤال

I am using ubuntu 12.04. I have used so far anjuta and codelite as IDE's for C++ school projects. However, with both of them I have encountered one problem: After starting the debugger, everything works fine till I try to add an array at watches' section. It does not display anything and when I try to continue debugging it freezes and I have to stop the debug session. I have to mention that watching variables works well.

Thank you,

LE: Actually, the debug function freezes only in case of large arrays...it may be a bug of codelite then. Any opinion?

هل كانت مفيدة؟

المحلول

I have to mention that watching variables works well.

When you set the watchpoint on a variable, GDB probably says Hardware watchpoint N (but your IDE may be hiding that message).

When you set a watchpoint on anything larger than 8 bytes on x86 processor, GDB can not set a hardware watchpoint (because x86 hardware doesn't support such watchpoints). GDB sets a software watchpoint instead. Software watchpoints are implemented as follows:

  1. single-step the program
  2. did values change? No -> go to step 1. Yes: stop.

Software watchpoints are really slow. If you watch your system with top, you'll likely discover that GDB is consuming 100% CPU.

If you really need to watch an entire array, this answer shows how that can be done with valgrind.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top