This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: implement new dynamic varobj spec


 > With a dynamic varobj you can tell if it has children by examining the
 > has_more attribute.

The field has_more tells you if it _currently_ has children.  If you create a
variable object of a STL container immediately after declaring an empty
container, e.g. after

  map<string, int> m;

then has_more=0 yet the node for it would need to be expandable.  In Emacs
this means there is a plus sign on the icon in the toolbar.  Clicking on
it gives no immediate children but then as you proceed:

  l.push_back (1);
  l.push_back (2);

the additional children appear.  With a string there are never any children
so you would not want an expandable node.  AFAICS the only way the front end
can discriminate is through the displayhint field.

On that note, printers.py in libstdc++ doesn't have a displayhint function for
StdListPrinter.

Also there appears to be something wrong with the python class
StdVectorPrinter because if you create a variable object immediately after
declaring it, e.g. after

  vector<int> v(4);  // create vector of integers with 4 elts

then do -var-list-children, GDB hangs:

-var-create - * v
^done,name="var1",numchild="0",value="{...}",type="std::vector<int, std::allocator<int> >",thread-id="1",dynamic="1",has_more="1"
(gdb) 
-var-list-children var1

p v gives:

p v
&"p v\n"
~"$1 = std::vector of length -17178288109, capacity 35167192218076 = {"
&"Cannot access memory at address 0x1000000006\n"
^error,msg="Cannot access memory at address 0x1000000006"
(gdb) 

while a similar declaration for list just prints with uninitialised values.


-- 
Nick                                           http://www.inet.net.nz/~nickrob


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]