Opened 8 years ago

Last modified 8 years ago

#10112 new Feature Requests

improved shared_ptr visualizer and weak_ptr

Reported by: murray read at ccdc Owned by: fkonvick
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.54.0 Severity: Optimization
Keywords: Cc:

Description

I was trying out the boost::shared_ptr visualizer for Visual Studio 2010, here https://svn.boost.org/svn/boost/sandbox/boost_docs/subprojects/DebuggerVisualizers/shared_ptr.vis.txt

It's ok, but it doesn't show very much. The typical display is:

shared_ptr {...} count = ...

While experimenting with the visualizer, I made several observations:

1) If you view a pointer rather than a dereferenced pointer, you see both the address (which is useful) and more content in the referenced object (which is very useful)

2) Our normal use of shared_ptr is as a pointer. The usage count is not normally something we want to know about. By removing the text formatting, and only showing the pointer in the preview, we see far more content in the referenced object (even more useful)

3) The children are displayed in alphabetic order. It's most useful to be able to see and expand "ptr" in the children. Renaming "count" to "use_count" puts "ptr" at the top, where it belongs.

4) weak_ptr can be visualized the same way.

An example boost::shared_ptr is now previewed as:

0x18467058 {parent_bond_=0x184546e0 {type_={...} polymeric_=false annotations_={...} ...} mol_=0x18448768 {m_=0x1246c5ac {impl_={...} annotations_={...} } impl_={...} proxy_atom_creator_={...} ...} graphic_properties_=0x00000000 }

;------------------------------------------------------------------------------
;  boost::shared_ptr
;------------------------------------------------------------------------------

boost::shared_ptr<*>{
	preview
	( 
		($T1 *)$c.px
	)
	children
	( 
		#( 
			ptr: (($T1 *)$c.px) ,
			use_count: $c.pn.pi_->use_count_ ,
			weak_count: $c.pn.pi_->weak_count_
		)
	)
}

;------------------------------------------------------------------------------
;  boost::weak_ptr
;------------------------------------------------------------------------------

boost::weak_ptr<*>{
	preview
	( 
		($T1 *)$c.px
	)
	children
	( 
		#( 
			ptr: (($T1 *)$c.px) ,
			use_count: $c.pn.pi_->use_count_ ,
			weak_count: $c.pn.pi_->weak_count_
		)
	)
}

Change History (3)

comment:1 by anonymous, 8 years ago

Seems to be better still if you use $e rather than $c - iterators and function returns are now expanded.

;------------------------------------------------------------------------------
;  boost::shared_ptr
;------------------------------------------------------------------------------

boost::shared_ptr<*>{
	preview
	( 
		($T1 *)$e.px
	)
	children
	( 
		#( 
			ptr: (($T1 *)$e.px) ,
			use_count: $e.pn.pi_->use_count_ ,
			weak_count: $e.pn.pi_->weak_count_
		)
	)
}

;------------------------------------------------------------------------------
;  boost::weak_ptr
;------------------------------------------------------------------------------

boost::weak_ptr<*>{
	preview
	( 
		($T1 *)$e.px
	)
	children
	( 
		#( 
			ptr: (($T1 *)$e.px) ,
			use_count: $e.pn.pi_->use_count_ ,
			weak_count: $e.pn.pi_->weak_count_
		)
	)
}

comment:2 by Matias Capeletto, 8 years ago

Owner: changed from Matias Capeletto to fkonvick

comment:3 by viboes, 8 years ago

Component: Documentationsmart_ptr
Note: See TracTickets for help on using tickets.