What's New in Oracle® Solaris Studio 12.4

Exit Print View

Updated: December 2014
 
 

Pretty-Printing With Python

dbx now has a mechanism in which you can write pretty-printing filters in Python. The pretty-printing filters transform a Value to a more readable form in dbx.

On the dbx command line, you can enable pretty-printing by using the –p option for the print, display, and watch commands or by typing dbxenv output_pretty_print on. In the IDE and dbxtool, you can enable pretty-printing by setting your dbxenv variable output_pretty_print to on and you can use the Pretty Print checkbox in the context menu of the Watches and Variables windows.

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
N/A
pair
N/A
vector
yes
list
yes
set
yes
deque
yes
bitset
yes
map
yes
stack
yes
priority_queue
yes
multimap
yes
multiset
yes
tuple (C++ only)
N/A
unique_ptr (C++ only)
N/A
Example 5-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

For general information about pretty-printing and call-style pretty-printers see Using Pretty-Printing in Oracle Solaris Studio 12.4: Debugging a Program With dbx and the topic prettyprint in the dbx helpfile.