This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 243272 - Variables window does not show smart pointers in user friendly manner
Summary: Variables window does not show smart pointers in user friendly manner
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 8.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: Maria Tishkova
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-26 00:08 UTC by jackua
Modified: 2016-07-06 14:39 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
C++ source (1.03 KB, text/x-c++src)
2014-03-26 00:08 UTC, jackua
Details
Two snapshots of NB 8 (256.57 KB, application/x-gzip)
2014-03-26 00:10 UTC, jackua
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jackua 2014-03-26 00:08:57 UTC
Created attachment 146318 [details]
C++ source

I am trying to convince my group to use smart pointers instead of regular C pointers.  The main objection from the developers is that it is harder to see values in the debugger. OK, I made a simple experiment, I created a tree using shared_ptr and using regular pointers (we need shared_ptr because nodes can have dup pointers).

Then I ran debugger and expanded the tree in Variables window.  The tree has three levels.  With plain pointers I need to expand three levels in the variable value tree to reach the NULL pointer.  With smart pointers I need to expand 11 levels.  First view takes 7 lines, second view requires 15 lines.

I am attaching two snapshots from the debugger.  I am also attaching source code for simplicity.

Value balloon is also much longer with a little reason.  BTW, many problems in C++ messages are related with inability to convert compiler expanded types back to user's types.  I wrote such back converters in C++ and Python and know that it is mostly doable.  It may require some heuristic but it really worth to do.

Refcount is so useless in this context.  It is a pointer to something containing a real counter.  Do I need to know implementation details?  I prefer to see two fields in shared_ptr: pointer and counter, plain, no wrappers.

We need to switch to smart pointers but I have a weak position in ease of debugging.
Please help.

Product Version: NetBeans IDE 8.0 Beta (Build 201401141042)
Java: 1.7.0_51; Java HotSpot(TM) Client VM 24.51-b03
Runtime: Java(TM) SE Runtime Environment 1.7.0_51-b13

A hint: why does every node waste a line with no text and then next line has one more hierarchy level with a type (std::__shared_ptr<...>)?  Why not combine them into one line?

P.S. Yes, I know, you can say that there is a nice script that I can source in GDB/NetBeans which can allow to make C++/STL human friendlier in debugging.  Is it right way?  These days nobody reads long manuals.  If every user needs to setup and then support some init scripts, the tool cannot be called user friendly out of the box.
Comment 1 jackua 2014-03-26 00:10:02 UTC
Created attachment 146319 [details]
Two snapshots of NB 8
Comment 2 Vladimir Voskresensky 2014-03-26 14:24:44 UTC
Eugene, if I understand correctly, such things are usually done through pretty printers. And IDE allows to specify gdb ini file where pretty printers are initialized. I.e. you can find pretty printers for STL in Internet.
Comment 3 jackua 2014-04-12 02:50:08 UTC
I had to learn how to use/create pretty printers but with one of STL printer implementation I see this in my gdb console:
   (gdb) p root
   std::shared_ptr (count 1, weak 0) 0x605028
without printer I see
   (gdb) p root
  $4 = {<std::__shared_ptr<Node, (__gnu_cxx::_Lock_policy)2>> = {_M_ptr = 0x605028, _M_refcount = {_M_pi = 0x605010}}, <No data fields>}

Looking at Python code I suspect that full type is stripped from typename argument of the printer and it is impossible to improve what we see above.

As the result, in Variables tab, NB shows a plain pointer value without an ability to expand the hierarchy.  So, without printers I need many clicks to see the tree.  With printers I cannot see the tree.
Where am I wrong?