Giter VIP home page Giter VIP logo

cppdebuggervisualizers's Introduction

C++ Debugger Visualizers Donate

C++ Debugger Visualizers for Boost, wxWidgets, TinyXML2.

Debugger Visualizers for Boost based on visualizers for VS2010 and Microsoft boost::shared_ptr visualizer

  • Boost library
    • 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::intrusive::set
    • 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::multiprecision
    • boost::rational
    • boost::regex
    • boost::interprocess::offset_ptr
    • boost::tribool
    • boost::unique_lock
    • boost::uuids::uuid
  • wxWidgets library: wxPoint, wxSize, wxRect, wxDateTime, wxLongLong, wxString, wxArrayString, wxDir, wxFileName
  • TinyXML library: TiXmlNode, TiXmlElement, TiXmlAttribute
  • TinyXML2 library: XMLNode, XMLElement, XMLAttribute
  • HRESULT for DirectX

You can install this extension from Visual Studio marketplace for VS2012, VS2013, VS2015 and VS2017

Please submit a request for support for new libraries and classes to this page https://github.com/KindDragon/CPPDebuggerVisualizers/issues

cppdebuggervisualizers's People

Contributors

aligature avatar apolukhin avatar biocomp avatar egorpugin avatar jzmaddock avatar kinddragon avatar lukaasm avatar r0nw avatar romankhv avatar sergeyvsb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cppdebuggervisualizers's Issues

Library request: Google Protocol Buffers (protobuf) repeated fields

It would be great to add support for repeated fields in Google Protocol Buffers.

Protocol buffers let you define "messages", which are basically like C structs, which have fields that are numeric, string or nested messages. From these definitions you generate code for any of several languages including C++, and this generated code includes methods for serialization to a language-neutral binary format. This library is used in Google projects like gRPC and TensorFlow, but also in lots of non-Google projects like Caffe and Mosh.

The fields can be single or repeated. Unfortunately, the C++ generated code for repeated fields uses their own custom containers. Depending of the type within, you either only see the first element in the debugger, or (usually) just a void* that points to the first element in the container. It would be great if debug visualizers for both types of classes were added to this plugin.

For intrinsic types, the template class google::protobuf::RepeatedField<T> is used. This stores the elements in a contiguous block, like a std::vector. This block is of type RepeatedField<T>::Rep, and the container includes a member of type Rep*. The static type of Rep finishes with a one-element array, which of course is really a multi-element array at runtime, so only the first element shows up in the debugger.

For string and nested messages types, the template class google::protobuf::RepeatedPtrField<T> is used. This also has a nested Rep type that includes an array (of static type length one), except that this is now an array of pointers rather than a direct array of objects. But wait - this is actually done in a non-templated base class called google::protobuf::RepeatedPtrFieldBase, so the static type of the final element of Rep is just void*.

Thanks for considering it!

Boost container changes

boost::container has (at least) two changes from 1.66 to 1.67:

  • The namespace boost::container::container_detail has been renamed to boost::container::dtl throughout (in boostorg/container@fa24946).
  • The class vector_alloc_holder has moved out of boost::container::container_detail altogether into boost::container (in boostorg/container@2802a1f).

The second change broke the visualiser for vector, and also flat_map and flat_set (which use vector internally). The first change probably broke all containers! Sorry this isn't a pull request :-( but I thought a hint would be better than nothing.

boost::intrusive::list visualizer doesn't work if list's size is not constant size

boost::intrusive::list can be set to omit the constant time size_ field in root_plus_size_ with boost::intrusive::constant_time_size<false> supplied as a template parameter.

The current visualizer implementation fails to load with "Natvis: [redacted]\boost\natvis\boost_IntrusiveContainers.natvis(47,2): Ignoring visualizer for type 'boost::intrusive::list_impl<boost::intrusive::bhtraits<[redacted],[redacted],unsigned __int64,0,[redacted]>' labeled as 'boost::intrusive::list_impl<boost::intrusive::bhtraits<*,*>,*>' because one or more sub-expressions was invalid."

The expressions containing data_.root_plus_size_.size_ were the cause of the problem, removing them made the visualizer work again.

boost::intrusive::constant_time_size<false> can be detected by taking into consideration the bool ConstantTimeSize parameter in the template parameters of boost::intrusive::list_impl.

The Boost version that was used is 1.72.0.

Contents of boost::optional<T> are not displayed properly if T is declared in anonymous namespace

Consider this code:

namespace
{
  enum class Side { Right, Left };
}

enum class Dir { Up, Down };

int main() 
{
  auto side = Side::Right;  // Displayed ok
  boost::optional<Dir> dirOpt = Dir::Up;  // Displayed ok
  boost::optional<Side> sideOpt = Side::Right;  // Displayed raw only
}

Variables side and dirOpt are displayed fine. But variable sideOpt is displayed as there was no natvis installed - raw content is shown only.

boost::uuid natvis not working in vs2019

Hi,
the vs extension isn't working anymore in vs2019 when trying to resolve a boost::uuid.
When comparing the extension directory I've recognized that the library referenced in the boost.natvis "CPPDebuggerVisualizersNatvisAddIn.dll" is missing when using the default installation over the Visual Studio Marketplace.

When enabling the verbose natvis logs I received the following message.

...\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\16.0_CA7B3D13\EXTENSIONS\CSSKHXNB.3TY\Visualizers\boost.natvis(390,2): Error: Legacy addin '...\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\16.0_CA7B3D13\EXTENSIONS\CSSKHXNB.3TY\Visualizers\CPPDebuggerVisualizersNatvisAddIn.dll' for type 'boost::uuids::uuid' cannot be used when out-of-process symbol loading is enabled. See https://aka.ms/VSCppEE-ExternalSymbolsCompat for more information.

At first, I've tried to get to the library by checking out and compile your source code. But the error message still occured.
The solution for me was to finally read the detail information provided by vs at
Visual C/C++ Custom Visualizer Compatibility.

It tells you as a user to disable "Load debug symbols in external process (native only)" and also steps to fix the change, which occured due to their externalization of the memory handling for components / plugins, as an extension owner.

Cheers,
karli

offset_ptr doesn't seem to visualize correctly

it looks like the internals of the class changed:
the m_offset field is not a direct member, but inside the union member 'internal'.

This definition seems to work (but I'm no visualizer expert):

<Type Name="boost::interprocess::offset_ptr&lt;*,*,*,*&gt;">
    <DisplayString Condition="internal.m_offset == 1">nullptr</DisplayString>
    <DisplayString Condition="internal.m_offset != 1">non-nullptr {($T1*)(((char*)(void*)this)+internal.m_offset)}</DisplayString>
    <Expand>
        <Item Name="[ptr]" Condition="internal.m_offset != 1">($T1*)(((char*)(void*)this)+internal.m_offset)</Item>
    </Expand>
</Type>

No preview for boost::none

I'm seeing the following error when trying to preview a boost::optional<> that is initialized to boost::none.

Natvis: C:\USERS\AHAFERBU\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_854067BE\EXTENSIONS\0O1HEMU5.ZR2\Visualizers\boost.natvis(106,2): Warning: Unable to load a visualized preview for type 'boost::optional<std::pair<bool,bool> >' because the conditions of all <DisplayString> elements were false.

My suggestion would be to change it to

<Type Name="boost::optional&lt;*&gt;" Priority="Medium">
    <AlternativeType Name="boost::optional_detail::optional_base&lt;*&gt;" />
    <DisplayString Condition="m_initialized">{m_storage}</DisplayString>
    <DisplayString Condition="!m_initialized">boost::none</DisplayString>
    <Expand>
        <Item Condition="m_initialized" Name="value">m_storage</Item>
    </Expand>
</Type>

The visualizer multi_index_container<*,indexed_by<hashed_unique<...>>> is not working correctly.

Small example:
`
//------------

  struct employee
    {
        int         id;
        std::string name;
        int         age;
        employee(int id_, std::string name_, int age_) :id(id_), name(name_), age(age_) {}
    };

   /* tags for accessing the corresponding indices of employee_set */

    struct id {};
    struct name {};
    struct age {};
    struct member {};

    /* see Compiler specifics: Use of member_offset for info on
    * BOOST_MULTI_INDEX_MEMBER
    */

    /* Define a multi_index_container of employees with following indices:
    *   - a unique index sorted by employee::int,
    *   - a non-unique index sorted by employee::name,
    *   - a non-unique index sorted by employee::age.
    */

    typedef multi_index_container<
        employee,
        indexed_by<
        hashed_unique<
        tag<id>, BOOST_MULTI_INDEX_MEMBER(employee, int, id)>,
        ordered_non_unique<
        tag<name>, BOOST_MULTI_INDEX_MEMBER(employee, std::string, name)>,
        ordered_non_unique<
        tag<age>, BOOST_MULTI_INDEX_MEMBER(employee, int, age)>
        >
    > employee_set;

    employee_set es;

    es.insert(employee(0, "Joe", 31));
    es.insert(employee(1, "Robert", 27));
    es.insert(employee(2, "John", 40));
    es.insert(employee(2, "Aristotle", 2387));
    es.insert(employee(3, "Albert", 20));
    es.insert(employee(4, "John", 57));

   employee_set es;

'

The items of the instance "es" are not shown in the Watch View of the Visual Studio debugger. Tested in version 2017, 2019 and 2022.

Request for Armadillo C++ Lib support

Armadillo is now a popular lib for scienfic purpose. There are some natvis files out there that can deal with vector and matrix. But none of them can deal with cube, would you please look into this issue? Thanks!

VS2019 support

Hi.

It would be nice to have an extension with visualizers for VS2019.

Thanks.

boost::datetime::ptime shows wrong time of day

I'm using:

It calculates hours as a negative value. For example, this time

auto time = boost::posix_time::from_iso_string("20230613T130922");

is shown as:

2023-6-13 -6-8:01:44 0ms 0us

The hour variable gets -68. The source of miscalculation is this division:

<Intrinsic Name="hour"        Expression="_t_hours()/3600000000"/>

Debugger seems to be treating the literal as uint32 and extends it to int64 this way:

auto hour = t_hours/static_cast<int>(3600000000);

I.e. it first converts it to int32, making it negative, and then extends the negative value to 64 bits.
This change fixes this:

<Intrinsic Name="hour"        Expression="_t_hours()/3600000000LL"/>
<Intrinsic Name="_t_minutes"  Expression="_t_hours()-3600000000LL*hour()"/>

(Note, boost::local_time::posix_time_zone_base also uses the constant).

This is probably a debugger bug, because it must be following C++ expression rules, and this calculations written in C++ give the right value. But I'm not sure.

auto time = boost::posix_time::from_iso_string("20230613T130922");  // To check it in "Locals" window
__int64 value = 212553464962000000ll;
auto x = value/86400000000;
auto t_hours = value-86400000000*x;
auto hour = t_hours/3600000000;

hour is 13.

Recommendation for boost::ptree modification

Hey @KindDragon ! Thanks for maintaining this project, it was a big help for me in root causing an issue I was having. The ptree visualizations didn't work for me though (I was trying on vs 2019, and it doesn't allow function calls -- I'm not sure if the ptree natvis that's in the repo is a placeholder or it somehow works for you) so I made some modifications which I figured I'd post in case you find them useful:

    <!--Common ptree view-->
    <Type Name="boost::property_tree::basic_ptree&lt;*&gt;">
        <DisplayString> {m_data} : {static_cast&lt;subs::base_container*&gt;(m_children),na} </DisplayString>
        <Expand HideRawView="true">
            <Item Name="m_data">m_data</Item>
            <Item Name="m_children">static_cast&lt;subs::base_container*&gt;(m_children),na</Item>
        </Expand>
    </Type>

    <!-- ptree with boost::any as the value type (doesn't show the node value if it's empty) -->
    <Type Name="boost::property_tree::basic_ptree&lt;*,boost::any,*&gt;">
        <DisplayString Condition="m_data.content != 0"> {m_data} : {static_cast&lt;subs::base_container*&gt;(m_children),na} </DisplayString>
        <DisplayString Condition="m_data.content == 0"> {*static_cast&lt;subs::base_container*&gt;(m_children)} </DisplayString>
        <Expand HideRawView="true">
            <Item Condition="m_data.content != 0" Name="m_data">m_data</Item>
            <ExpandedItem>static_cast&lt;subs::base_container*&gt;(m_children)</ExpandedItem>
        </Expand>
    </Type>

    <!-- std::pair representation. Makes it easier to drill down the nodes in the tree -->
    <Type Name="std::pair&lt;*,boost::property_tree::basic_ptree&lt;*&gt;&gt;">
        <DisplayString> {{ {first} : {second} }} </DisplayString>
        <Expand HideRawView="true">
            <ExpandedItem>second</ExpandedItem>
        </Expand>
    </Type>

I didn't want to make a PR because I wrote this kind of specifically for the type of ptree I was looking at, so I'm not sure how exactly it behaves with other trees, but just in case it's useful to you.

Feel free to close this once you've seen it.

time duration calculation overflows and shows wrong value

If you construct a time duration of 24 hours, it shows "172d 00:04:47 0ms 0us" as the value in the debugger. This is consistent with the "86400*$T2" portion of the day intrinsic overflowing 32-bits when $T2 evaluates to 1000000. I'm in a Win32 project with Visual Studio 2017 (15.6.4).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.