Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Python Pretty-Print Filters (Oracle Solaris)

The pretty-printing filter feature enables you to write filters in python which can transform a Value from one form to another. Python-based pretty-printers are only available on Oracle Solaris.


Note -  Python pretty-print filters can only be used in C and C++ code, not Fortran.

Filters are built in for select classes in 4 implementations of the C++ Standard Template Library. The following table specifies the library name and the compiler option for that library:

Compiler option for Library
Library Name
–library=Cstd (default)
libCstd.so.1
–library=stlport4
libstlport.so.1
–library=stdcxx4
libstdcxx4.so.4.**
–library=stdcpp (default when using the –std=c++11 option)
libstdc++.so.6.*

The following table specifies which classes filters can be used for in the C++ Standard Template Library and if index and slice can be printed:

Classes
Index and Slice Available
string
no
vector
yes
list
yes
set
no
Example 8-1  Pretty-Printing with Filters

The following output is an example of printing a list using the print command in dbx:

(dbx) print list10
list10 = {
   __buffer_size = 32U       
   __buffer_list = {
     __data_ = 0x654a8
   }
   __free_list   = (nil)
   __next_avail  = 0x67334
   __last     = 0x67448
   __node     = 0x48830
   __length   = 10U
   }

The following is the same list printed in dbx, but using pretty-printing filters:

(dbx) print -p list10
list10 = (200, 201, 202, 203, 204, 205, 206, 207, 208, 209)

(dbx) print -p list10[5]
list10[5] = 205

(dbx) print -p list10[1..100:2]
list10[1..100:2] =
[1] = 202
[3] = 204
[5] = 206
[7] = 208

Using Python on Oracle Solaris

Python pretty-print filters and the python command is available only on Oracle Solaris. To start the built-in Python interpreter, type python. To evaluate your Python code, type python python-code. A nascent Python plugin API is available. However, its primary purpose is for the writing of pretty-printer filters which that get invoked as callbacks. Therefore the python command mainly serves testing and diagnostic purposes.

Python Pretty-Print API Documentation

To generate the python pretty-print API documentation, use the python-docs command. This command is only available on Oracle Solaris.