public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug varobj/13708] Erasing an element from std::vector isn't reported by -var-update, when pretty printing is enabled
  2012-02-18 13:30 [Bug varobj/13708] New: erasure of an element from std::vector isn't reported by -var-update, when pretty printing is enabled dodji at seketeli dot org
@ 2012-02-18 13:30 ` dodji at seketeli dot org
  2012-02-21 19:27 ` tromey at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dodji at seketeli dot org @ 2012-02-18 13:30 UTC (permalink / raw)
  To: gdb-prs

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

dodji at seketeli dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|erasure of an element from  |Erasing an element from
                   |std::vector isn't reported  |std::vector isn't reported
                   |by -var-update, when pretty |by -var-update, when pretty
                   |printing is enabled         |printing is enabled

-- 
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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug varobj/13708] New: erasure of an element from std::vector isn't reported by -var-update, when pretty printing is enabled
@ 2012-02-18 13:30 dodji at seketeli dot org
  2012-02-18 13:30 ` [Bug varobj/13708] Erasing " dodji at seketeli dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dodji at seketeli dot org @ 2012-02-18 13:30 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug varobj/13708] Erasing an element from std::vector isn't reported by -var-update, when pretty printing is enabled
  2012-02-18 13:30 [Bug varobj/13708] New: erasure of an element from std::vector isn't reported by -var-update, when pretty printing is enabled dodji at seketeli dot org
  2012-02-18 13:30 ` [Bug varobj/13708] Erasing " dodji at seketeli dot org
@ 2012-02-21 19:27 ` tromey at redhat dot com
  2014-09-12 23:08 ` sergiodj at redhat dot com
  2023-08-31 16:37 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2012-02-21 19:27 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
                 CC|                            |tromey at redhat dot com

--- Comment #1 from Tom Tromey <tromey at redhat dot com> 2012-02-21 19:25:56 UTC ---
I think gdb is correct here.  Here's my analysis.
I'm moving this to WAITING pending your agreement.

> 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.

Here are the last two -var-update calls:

-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"}]}]

-var-update --all-values var1
^done,changelist=[]


The first -var-update shown reports 2 elements.  Then the inferior
adds an element and removes it.  Then we do another -var-update.  At
this point, the vector is identical to the last time it was updated.

If I instead -var-update at line 14 in the inferior, I get:

^done,changelist=[{name="var1",value="{...}",in_scope="true",type_changed="false",new_num_children="2",displayhint="array",dynamic="1",has_more="0"}]


Here is the test input I am using, run like: gdb -i=mi2 ./pr < script:

set data-directory /usr/share/gdb
-enable-pretty-printing
b 10
run
-var-create - * v
-var-list-children --all-values var1
b 14
cont
-var-update --all-values var1
b 22
cont
p/r v
p v
-var-update --all-values var1

-- 
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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug varobj/13708] Erasing an element from std::vector isn't reported by -var-update, when pretty printing is enabled
  2012-02-18 13:30 [Bug varobj/13708] New: erasure of an element from std::vector isn't reported by -var-update, when pretty printing is enabled dodji at seketeli dot org
  2012-02-18 13:30 ` [Bug varobj/13708] Erasing " dodji at seketeli dot org
  2012-02-21 19:27 ` tromey at redhat dot com
@ 2014-09-12 23:08 ` sergiodj at redhat dot com
  2023-08-31 16:37 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: sergiodj at redhat dot com @ 2014-09-12 23:08 UTC (permalink / raw)
  To: gdb-prs

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

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sergiodj at redhat dot com

--- Comment #2 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
Hey Dodji, could you take a look at this bug and see if Tom's comments make
sense to you?  Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug varobj/13708] Erasing an element from std::vector isn't reported by -var-update, when pretty printing is enabled
  2012-02-18 13:30 [Bug varobj/13708] New: erasure of an element from std::vector isn't reported by -var-update, when pretty printing is enabled dodji at seketeli dot org
                   ` (2 preceding siblings ...)
  2014-09-12 23:08 ` sergiodj at redhat dot com
@ 2023-08-31 16:37 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2023-08-31 16:37 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org
         Resolution|---                         |INVALID
             Status|WAITING                     |RESOLVED

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
Closing now.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-31 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-18 13:30 [Bug varobj/13708] New: erasure of an element from std::vector isn't reported by -var-update, when pretty printing is enabled dodji at seketeli dot org
2012-02-18 13:30 ` [Bug varobj/13708] Erasing " dodji at seketeli dot org
2012-02-21 19:27 ` tromey at redhat dot com
2014-09-12 23:08 ` sergiodj at redhat dot com
2023-08-31 16:37 ` tromey at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).