This is the mail archive of the gdb-prs@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]

[Bug varobj/13708] New: erasure of an element from std::vector isn'treported by -var-update, when pretty printing is enabled


http://sourceware.org/bugzilla/show_bug.cgi?id=13708

             Bug #: 13708
           Summary: erasure of an element from std::vector isn't reported
                    by -var-update, when pretty printing is enabled
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: varobj
        AssignedTo: unassigned@sourceware.org
        ReportedBy: dodji@seketeli.org
    Classification: Unclassified


Consider this short code snippet:

     1  #include <vector>
     2  #include <string>
     3  #include <iostream>
     4
     5  int
     6  main()
     7  {
     8      std::string s1 = "kÃlÃ", s2 = "fila", s3 = "saba";
     9      std::vector<std::string> v;
    10      v.push_back(s1);
    11      v.push_back(s2);
    12      v.push_back(s3);
    13
    14      std::vector<std::string>::iterator i = v.begin ();
    15      i += 2;
    16
    17      v.erase (i);
    18
    19      unsigned s = v.size ();
    20      std::cout << "v.size (): " << s;
    21
    22      return 0;
    23  }


Here are the actions I perform:

First, I enable pretty printing in MI2 mode.  

Then I create a variable object for vector 'v' right after executing line 9 and
I -var-list-children it there.

Then after each step, I -var-update the varobj.  Everything goes fine. 
-var-update correctly reports the new string being appended to the vector 'v'
at each step.

But then after line 17, (that erases the last element of the vector),
-var-update on the varobj does not report the fact that the variable got
deleted.

This is annoying as the front end can not update their graphical representation
of the variable 'v' accordingly.

Below is the detail of the GDB session.


$ libtool e gdb --interpreter=mi2 ./prettyprint 
=thread-group-added,id="i1"
~"GNU gdb (GDB) Fedora (7.3.50.20110722-10.fc16)\n"
~"Copyright (C) 2011 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to
change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by
law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-redhat-linux-gnu\".\nFor bug reporting
instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>...\n"
~"Reading symbols from
/devel/dodji/git/nemiver/better-variable-update/build/tests/prettyprint..."
~"done.\n"
(gdb) 
-enable-pretty-printing
^done
(gdb) 
b main
&"b main\n"
~"Breakpoint 1 at 0x400c4d: file
/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc,
line 8.\n"
=breakpoint-created,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400c4d",func="main()",file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="8",times="0",original-location="main"}
^done
(gdb) 
run
&"run\n"
~"Starting program:
/devel/dodji/git/nemiver/better-variable-update/build/tests/prettyprint \n"
=thread-group-started,id="i1",pid="13812"
=thread-created,id="1",group-id="i1"
^running
*running,thread-id="all"
(gdb) 
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/usr/lib64/libstdc++.so.6",target-name="/usr/lib64/libstdc++.so.6",host-name="/usr/lib64/libstdc++.so.6",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/lib64/libm.so.6",target-name="/lib64/libm.so.6",host-name="/lib64/libm.so.6",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/lib64/libgcc_s.so.1",target-name="/lib64/libgcc_s.so.1",host-name="/lib64/libgcc_s.so.1",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/lib64/libc.so.6",target-name="/lib64/libc.so.6",host-name="/lib64/libc.so.6",symbols-loaded="0",thread-group="i1"
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400c4d",func="main()",file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="8",times="1",original-location="main"}
~"\nBreakpoint "
~"1, main () at
/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc:8\n"
~"8\t    std::string s1 = \"k\303\251l\303\251\", s2 = \"fila\", s3 =
\"saba\";\n"
*stopped,frame={addr="0x0000000000400c4d",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="8"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
-enable-pretty-printing
^done
(gdb) 
n
&"n\n"
^running
*running,thread-id="1"
(gdb) 
~"9\t    std::vector<std::string> v;\n"
*stopped,frame={addr="0x0000000000400cd4",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="9"},thread-id="1",stopped-threads="all",core="3"
(gdb) 
n
&"n\n"
^running
*running,thread-id="1"
(gdb) 
~"10\t    v.push_back(s1);\n"
*stopped,frame={addr="0x0000000000400ce0",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="10"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
-var-create - * v
^done,name="var1",numchild="0",value="{...}",type="std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >
>",thread-id="1",displayhint="array",dynamic="1",has_more="0"
(gdb) 
-var-list-children --all-values var1
^done,numchild="0",displayhint="array",has_more="0"
(gdb) 
n
&"n\n"
^running
*running,thread-id="1"
(gdb) 
~"11\t    v.push_back(s2);\n"
*stopped,frame={addr="0x0000000000400cf3",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="11"},thread-id="1",stopped-threads="all",core="0"
(gdb) 
-var-update --all-values var1
^done,changelist=[{name="var1",value="{...}",in_scope="true",type_changed="false",new_num_children="1",displayhint="array",dynamic="1",has_more="0",new_children=[{name="var1.[0]",exp="[0]",numchild="0",value="
\"k\303\251l\303\251\"",type="std::basic_string<char, std::char_traits<char>,
std::allocator<char> >",thread-id="1",displayhint="string",dynamic="1"}]}]
(gdb) 
n
&"n\n"
^running
*running,thread-id="1"
(gdb) 
~"12\t    v.push_back(s3);\n"
*stopped,frame={addr="0x0000000000400d06",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="12"},thread-id="1",stopped-threads="all",core="1"
(gdb) 
-var-update --all-values var1
^done,changelist=[{name="var1",value="{...}",in_scope="true",type_changed="false",new_num_children="2",displayhint="array",dynamic="1",has_more="0",new_children=[{name="var1.[1]",exp="[1]",numchild="0",value="
\"fila\"",type="std::basic_string<char, std::char_traits<char>,
std::allocator<char> >",thread-id="1",displayhint="string",dynamic="1"}]}]
(gdb) 
n
&"n\n"
^running
*running,thread-id="1"
(gdb) 
~"14\t    std::vector<std::string>::iterator i = v.begin ();\n"
*stopped,frame={addr="0x0000000000400d19",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="14"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
n
&"n\n"
^running
*running,thread-id="1"
(gdb) 
~"15\t    i += 2;\n"
*stopped,frame={addr="0x0000000000400d29",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="15"},thread-id="1",stopped-threads="all",core="0"
(gdb) 
n
&"n\n"
^running
*running,thread-id="1"
(gdb) 
~"17\t    v.erase (i);\n"
*stopped,frame={addr="0x0000000000400d44",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="17"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
n
&"n\n"
^running
*running,thread-id="1"
(gdb) 
~"19\t    unsigned s = v.size ();\n"
*stopped,frame={addr="0x0000000000400d57",func="main",args=[],file="/home/dodji/devel/git/nemiver/better-variable-update/tests/pretty-print.cc",fullname="/devel/dodji/git/nemiver/better-variable-update/tests/pretty-print.cc",line="19"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
-var-update --all-values var1
^done,changelist=[]
(gdb) 


Note here, how, after erasing the last element of the vector,
-var-update --all-values var1 says that nothing has changed in the
variable.

I think it should report the change, somehow.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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