Home  >  Article  >  Backend Development  >  How to Enable Pretty Printing for STL Objects in Eclipse CDT?

How to Enable Pretty Printing for STL Objects in Eclipse CDT?

Linda Hamilton
Linda HamiltonOriginal
2024-10-30 16:48:02275browse

 How to Enable Pretty Printing for STL Objects in Eclipse CDT?

Enable Pretty Printing for STL Objects in Eclipse CDT

Pretty printing is a feature that allows for improved visual representation of data when debugging C applications. To enable this functionality for STL objects in Eclipse CDT, follow these steps:

1. Python Module Installation

  • Install the latest version of GDB that supports Python scripting.
  • Download and checkout the Python pretty printers for STL objects into a directory of your choice.

2. Configuring GDB

  • Create a .gdbinit file in your home directory.
  • Add the following code to the file:
python
import sys 
sys.path.insert(0, '/PATH/TO/PRETTY_PRINTERS_DIRECTORY')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

3. Eclipse Configuration

  • Download and install Eclipse CDT.
  • Configure Eclipse to use the updated GDB and specify the path to the .gdbinit file.
  • Enable the "Pretty Printing" option in the C/C Debug preferences.

4. Usage

  • Start debugging your C application.
  • STL containers will now be displayed in a more visually appealing manner in the "Variables" view.

5. Additional Commands

  • To further enhance the output, consider using the following GDB commands:
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

The above is the detailed content of How to Enable Pretty Printing for STL Objects in Eclipse CDT?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn