Search code examples
c++gdbstdvectorpretty-print

GDB crashes trying to display pretty-printed std::vector


how to avoid GDB crashing or hanging when entering a function step by step and GDB pretty printing for example STL vector which has not been stepped over to be initialized.

For example pretty printing a vector that is not initialized in function can show over millions of elements, but that due to uninitialized value inside a vector, which hasn't been stepped over. Immediately when i step over line the vector holds 0 elements.

Any way to avoid this?


Solution

  • Any way to avoid this?

    The best way to avoid this is by not displaying contents of a vector until it has been initialized.

    If you are doing it via display GDB command, don't.

    If this is happening because your GUI does it, don't use that GUI.