<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=RobinWhittle</id>
	<title>Code::Blocks - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=RobinWhittle"/>
	<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php/Special:Contributions/RobinWhittle"/>
	<updated>2026-05-10T17:45:29Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Pretty_Printers&amp;diff=7718</id>
		<title>Pretty Printers</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Pretty_Printers&amp;diff=7718"/>
		<updated>2014-02-01T09:49:59Z</updated>

		<summary type="html">&lt;p&gt;RobinWhittle: Previous fix wasn't enough - replaced the entire Linux download URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: User Documentation]]&lt;br /&gt;
GDB Pretty Printers for STL display nicely formatted variables in the hover pop-up and watch window, for all STL containers (vectors, maps, etc).&lt;br /&gt;
----&lt;br /&gt;
[[File:Pprint1.png|border|Popup example]]&amp;lt;br&amp;gt;&lt;br /&gt;
==Test with GDB==&lt;br /&gt;
&lt;br /&gt;
*Ensure GDB is python-enabled. For Linux (tested with recent Ubuntu), it is enabled by default. For Windows, MinGW's GDB is not python enabled. One option is to install [http://sourceforge.net/projects/mingwbuilds/ MinGW-Builds] over MinGW (consider backing up MinGW first). This updates GCC to 4.7.2 and includes a Python enabled GDB.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
To test, launch GDB from console:&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
(gdb) python print sys.version&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
If python is enabled, the version will be printed (probably 2.7.x), otherwise, a message will indicate python scripting is not supported.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
*Download printers.py (if necessary)&lt;br /&gt;
:Windows users with MinGW should already have this file in /MinGW/share/gcc-4.7.2/python/libstdcxx/v6.&lt;br /&gt;
:Linux users can download printers.py [http://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python/libstdcxx/v6/printers.py here]. Save as &amp;lt;tt&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;/home/username/gdb_printers/printers.py&amp;lt;/span&amp;gt;&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*Create a GDB [http://sourceware.org/gdb/onlinedocs/gdb/Command-Files.html Command File] to enable the printer. Store in &amp;lt;tt&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;c:\mingw\bin\pp.gdb&amp;lt;/span&amp;gt;&amp;lt;/tt&amp;gt; (windows) or &amp;lt;tt&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;/home/username/gdb_printers/pp.gdb&amp;lt;/span&amp;gt;&amp;lt;/tt&amp;gt; (linux). Below is a sample command file. Replace the path c:/MinGW/share... with your path to printers.py.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
python&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.insert(0, 'c:/MinGW/share/gcc-4.7.2/python/libstdcxx/v6')&lt;br /&gt;
from printers import register_libstdcxx_printers&lt;br /&gt;
register_libstdcxx_printers (None)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
*Test&lt;br /&gt;
#Set a breakpoint in a program and debug&lt;br /&gt;
#Run the command file from GDB (can use Codeblocks-&amp;gt;debugger tab-&amp;gt;command, or in GDB from the console) (substitute your path if necessary)&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;(gdb) source c:\MinGW\bin\pp.gdb&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Test the printer - example:&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;(gdb) print words2&lt;br /&gt;
$1 = std::vector of length 3, capacity 4 = {&amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Add to Codeblocks==&lt;br /&gt;
Once the command file is working correctly, there are two steps to activate in Codeblocks:&lt;br /&gt;
#Set debugger initialization command (substitute your path as necessary):&amp;lt;br/&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;Codeblocks-&amp;gt;Settings-&amp;gt;Debugger-&amp;gt;Default-&amp;gt;Debugger initialization commands&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;source c:\MinGW\bin\pp.gdb&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
NOTE: A bug in the Linux version of Codeblocks may prevent entering anything in the Debugger Initialization Commands field. A work-around is to open a CBP project file via a file manager, which in turn launches Codeblocks and seems to resolve the issue.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Disable Codeblocks handling of watch values:&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;Codeblocks-&amp;gt;Settings-&amp;gt;Debugger-&amp;gt;Default-&amp;gt;Enable Watch Scripts = Unchecked&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
===Other Info===&lt;br /&gt;
Links:&lt;br /&gt;
&lt;br /&gt;
[http://sourceware.org/gdb/onlinedocs/gdb/Python-API.html GDB Python API]&lt;br /&gt;
&lt;br /&gt;
[http://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html GDB Pretty Printing]&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
The third column in the Codeblocks popup and watch window displays a long unformatted string. Codeblocks is calling the GDB whatis command. Can this command be Pretty-Printed?&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Debugging with Code::Blocks]]&lt;br /&gt;
* [[Debugger scripts]]&lt;/div&gt;</summary>
		<author><name>RobinWhittle</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Pretty_Printers&amp;diff=7717</id>
		<title>Pretty Printers</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Pretty_Printers&amp;diff=7717"/>
		<updated>2014-02-01T09:48:22Z</updated>

		<summary type="html">&lt;p&gt;RobinWhittle: /* Test with GDB */  Replaced &amp;quot;viewcvs&amp;quot; with &amp;quot;svn&amp;quot; in Linux download URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: User Documentation]]&lt;br /&gt;
GDB Pretty Printers for STL display nicely formatted variables in the hover pop-up and watch window, for all STL containers (vectors, maps, etc).&lt;br /&gt;
----&lt;br /&gt;
[[File:Pprint1.png|border|Popup example]]&amp;lt;br&amp;gt;&lt;br /&gt;
==Test with GDB==&lt;br /&gt;
&lt;br /&gt;
*Ensure GDB is python-enabled. For Linux (tested with recent Ubuntu), it is enabled by default. For Windows, MinGW's GDB is not python enabled. One option is to install [http://sourceforge.net/projects/mingwbuilds/ MinGW-Builds] over MinGW (consider backing up MinGW first). This updates GCC to 4.7.2 and includes a Python enabled GDB.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
To test, launch GDB from console:&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
(gdb) python print sys.version&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
If python is enabled, the version will be printed (probably 2.7.x), otherwise, a message will indicate python scripting is not supported.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
*Download printers.py (if necessary)&lt;br /&gt;
:Windows users with MinGW should already have this file in /MinGW/share/gcc-4.7.2/python/libstdcxx/v6.&lt;br /&gt;
:Linux users can download printers.py [http://gcc.gnu.org/svn/trunk/libstdc%2B%2B-v3/python/libstdcxx/v6/ here]. Save as &amp;lt;tt&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;/home/username/gdb_printers/printers.py&amp;lt;/span&amp;gt;&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*Create a GDB [http://sourceware.org/gdb/onlinedocs/gdb/Command-Files.html Command File] to enable the printer. Store in &amp;lt;tt&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;c:\mingw\bin\pp.gdb&amp;lt;/span&amp;gt;&amp;lt;/tt&amp;gt; (windows) or &amp;lt;tt&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;/home/username/gdb_printers/pp.gdb&amp;lt;/span&amp;gt;&amp;lt;/tt&amp;gt; (linux). Below is a sample command file. Replace the path c:/MinGW/share... with your path to printers.py.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
python&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.insert(0, 'c:/MinGW/share/gcc-4.7.2/python/libstdcxx/v6')&lt;br /&gt;
from printers import register_libstdcxx_printers&lt;br /&gt;
register_libstdcxx_printers (None)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
*Test&lt;br /&gt;
#Set a breakpoint in a program and debug&lt;br /&gt;
#Run the command file from GDB (can use Codeblocks-&amp;gt;debugger tab-&amp;gt;command, or in GDB from the console) (substitute your path if necessary)&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;(gdb) source c:\MinGW\bin\pp.gdb&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Test the printer - example:&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;(gdb) print words2&lt;br /&gt;
$1 = std::vector of length 3, capacity 4 = {&amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Add to Codeblocks==&lt;br /&gt;
Once the command file is working correctly, there are two steps to activate in Codeblocks:&lt;br /&gt;
#Set debugger initialization command (substitute your path as necessary):&amp;lt;br/&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;Codeblocks-&amp;gt;Settings-&amp;gt;Debugger-&amp;gt;Default-&amp;gt;Debugger initialization commands&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;source c:\MinGW\bin\pp.gdb&amp;lt;/pre&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
NOTE: A bug in the Linux version of Codeblocks may prevent entering anything in the Debugger Initialization Commands field. A work-around is to open a CBP project file via a file manager, which in turn launches Codeblocks and seems to resolve the issue.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;ol start=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Disable Codeblocks handling of watch values:&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10pt&amp;quot;&amp;gt;&amp;lt;tt&amp;gt;Codeblocks-&amp;gt;Settings-&amp;gt;Debugger-&amp;gt;Default-&amp;gt;Enable Watch Scripts = Unchecked&amp;lt;/tt&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
===Other Info===&lt;br /&gt;
Links:&lt;br /&gt;
&lt;br /&gt;
[http://sourceware.org/gdb/onlinedocs/gdb/Python-API.html GDB Python API]&lt;br /&gt;
&lt;br /&gt;
[http://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html GDB Pretty Printing]&lt;br /&gt;
&lt;br /&gt;
===To Do===&lt;br /&gt;
The third column in the Codeblocks popup and watch window displays a long unformatted string. Codeblocks is calling the GDB whatis command. Can this command be Pretty-Printed?&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Debugging with Code::Blocks]]&lt;br /&gt;
* [[Debugger scripts]]&lt;/div&gt;</summary>
		<author><name>RobinWhittle</name></author>
	</entry>
</feed>