Home > Article > Backend Development > How to Enable GDB Pretty Printing for C STL Objects in Eclipse CDT?
Enabling GDB Pretty Printing for C STL Objects in Eclipse CDT
Debugging C programs with STL objects can be challenging when the default GDB output is not readily interpretable. Enabling pretty printing addresses this issue by providing a more user-friendly representation of STL data structures.
Prerequisites
Setting Up Pretty Printing
Configure GDBinit File: Create a .gdbinit file in your project directory and add the following content:
<code class="python">import sys sys.path.insert(0, '/home/<path_to_pretty_printers>') from libstdcxx.v6.printers import register_libstdcxx_printers register_libstdcxx_printers(None)</code>
Enable Pretty Printing in Eclipse CDT: In Eclipse, navigate to Window -> Preferences -> C/C -> Debug -> GDB.
Additional GDB Commands: For further customization, execute these commands in GDB:
set print pretty on set print object on set print static-members on set print vtbl on set print demangle on set demangle-style gnu-v3 set print sevenbit-strings off
Additional Tips
The above is the detailed content of How to Enable GDB Pretty Printing for C STL Objects in Eclipse CDT?. For more information, please follow other related articles on the PHP Chinese website!