开发者

Is there an easy way to make `boost::ptr_vector` more debugger friendly in Visual Studio?

I'm considering using boost::ptr_container as a result of the responses from this question. My biggest problem with the library is that I cannot view the contents of the collection in the debugger, because the MSVC debugger doesn't recognize it, and therefore I cannot see the contents of the containers. (All the data gets stored as void * internally)

I've heard MSVC has a feature called "debugger visualizers" which would allow the user to make the debugger smarter about these kinds of things, but I've never written anything like this, and I'm not hugely firmiliar with such things.

For example, compare the behavior of boost::shared_ptr with MSVC's own std::tr1::shared_ptr. In the debugger (i.e. in the Watch window), the boost version shows up as a big mess of internal variables used for implementing the shared pointer, but the MSVC version shows up as a plain pointer to the object (and the share开发者_Go百科d_ptr's innards are hidden).

How can I get started either using or implementing such a thing?


See this link which provides every debugger visualizer (through autoexp.dat) you may want :

All visualizers are available in the svn. Currently, we support the following Boost types:

  • boost::array, ptr_array, ptr_deque, ptr_list, ptr_map, ptr_multimap, ptr_set, ptr_multiset, ptr_vector
  • boost::interprocess::offset_ptr
  • boost::optional
  • boost::multi_index_container
  • boost::shared_ptr
  • boost::posix_time::ptime,
  • boost::posix_time::time_duration (two variants are available)
  • boost::regex
  • boost::variant


Some possibly useful information on MSDN:

  • for VC++ 8
  • for VC++ 10

A codeproject sample or two:

  • http://www.codeproject.com/Articles/51610/Visualizing-MFC-Containers-in-autoexp-dat.aspx
  • http://code.msdn.microsoft.com/boostsharedptrvis

All of them involve autoexp.dat in some way, making that an effective search term.


You can use this extension for Visual Studio 2012+, check this link. They based on visualizers from boost svn for Visual Studio 2008/2010

Extension support the following Boost types:

  • boost::shared_ptr, boost::weak_ptr, boost::intrusive_ptr, boost::shared_array, boost::scoped_ptr, boost::scoped_array
  • boost::ptr_array, boost::ptr_vector, boost::ptr_list, boost::ptr_deque, boost::ptr_map, boost::ptr_set, boost::ptr_multimap, boost::ptr_multiset
  • boost::array, boost::dynamic_bitset, boost::circular_buffer boost::unordered_map, boost::unordered_set, boost::unordered_multimap, boost::unordered_multiset
  • boost::intrusive::list, boost::intrusive::slist
  • boost::container::basic_string, boost::container::deque, boost::container::vector
  • boost::optional, boost::any, boost::variant
  • boost::filesystem::path, boost::filesystem::directory_entry, boost::filesystem::file_status
  • boost::posix_time::ptime, boost::posix_time::time_duration
  • boost::regex
  • boost::interprocess::offset_ptr
  • boost::tribool
  • boost::unique_lock
  • boost::uuids::uuid


Debugger visualizers are only available for managed code, according to http://msdn.microsoft.com/en-us/library/zayyhzts.aspx which provides more information about them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜