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 mi/13149] New: Some pretty printers don't work in MI mode


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

             Bug #: 13149
           Summary: Some pretty printers don't work in MI mode
           Product: gdb
           Version: 7.3
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mi
        AssignedTo: unassigned@sourceware.org
        ReportedBy: dodji@seketeli.org
                CC: pmuldoon@redhat.com
    Classification: Unclassified


Consider this test case:

$ cat -n ~/test.cc
     1    #include <vector>
     2    #include <string>
     3    
     4    int
     5    main()
     6    {
     7        std::vector<std::string> v;
     8        std::string s;
     9        
    10        s = "ein";
    11        v.push_back (s);
    12        s = "zwei";
    13        v.push_back (s);
    14        s = "drei";
    15        v.push_back (s);
    16    }

If I debug it using gdb 7.3 and the mi interpreter, I can see that
the pretty printer for the 'v' variable is not "working" in MI, but is
working in CLI:

$ gdb --interpreter=mi2 ./test
=thread-group-added,id="i1"
~"GNU gdb (GDB) Fedora (7.3-41.fc15)\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"
~"\nwarning: "
~"Current output protocol does not support redirection\n"
~"\nwarning: "
~"Currently logging to gdb.txt.  Turn the logging off and on to make the new
setting effective.\n"
~"Reading symbols from /home/dodji/test..."
~"done.\n"
(gdb) 
-enable-pretty-printing
^done
(gdb) 
b main
~"b main\n"
~"Breakpoint 1 at 0x4009ed: file test.cc, line 7.\n"
^done
(gdb) 
run
~"run\n"
~"Starting program: /home/dodji/test \n"
=thread-group-started,id="i1",pid="30679"
=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"
~"\nBreakpoint "
~"1, main () at test.cc:7\n"
~"7\t    std::vector<std::string> v;\n"
*stopped,frame={addr="0x00000000004009ed",func="main",args=[],file="test.cc",fullname="/home/dodji/test.cc",line="7"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
n
~"n\n"
^running
*running,thread-id="1"
(gdb) 
~"8\t    std::string s;\n"
*stopped,frame={addr="0x00000000004009f9",func="main",args=[],file="test.cc",fullname="/home/dodji/test.cc",line="8"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
n
~"n\n"
^running
*running,thread-id="1"
(gdb) 
~"10\t    s = \"ein\";\n"
*stopped,frame={addr="0x0000000000400a05",func="main",args=[],file="test.cc",fullname="/home/dodji/test.cc",line="10"},thread-id="1",stopped-threads="all",core="1"
(gdb) 
n
~"n\n"
^running
*running,thread-id="1"
(gdb) 
~"11\t    v.push_back (s);\n"
*stopped,frame={addr="0x0000000000400a16",func="main",args=[],file="test.cc",fullname="/home/dodji/test.cc",line="11"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
n
~"n\n"
^running
*running,thread-id="1"
(gdb) 
~"12\t    s = \"zwei\";\n"
*stopped,frame={addr="0x0000000000400a29",func="main",args=[],file="test.cc",fullname="/home/dodji/test.cc",line="12"},thread-id="1",stopped-threads="all",core="2"
(gdb) 
-var-create - * s
^done,name="var1",numchild="0",value="
\"ein\"",type="std::string",thread-id="1",displayhint="string",dynamic="1",has_more="0"
(gdb) 
-var-create - * v
^done,name="var2",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="1"
(gdb) 
p v
~"p v\n"
~"$1 = std::vector of length 1, capacity 1 = {\"ein\""
~"}\n"
^done
(gdb) 

you Can see that the "-var-create - * v" yields a varobj which value
is "{...}".  If I tried to explore it I get:

-var-list-children var2
^done,numchild="1",displayhint="array",children=[child={name="var2.[0]",exp="[0]",numchild="0",type="std::basic_string<char,
std::char_traits<char>, std::allocator<char>
>",thread-id="1",displayhint="string",dynamic="1"}],has_more="0"
(gdb) 
-var-list-children var2.[0]
^done,numchild="0",displayhint="string",has_more="0"
(gdb) 


Not particularly well pretty printed.  Notice how the CLI command "p
v" yields a pretty printed value, instead.  Notice also how the varobj
created for the string "s" yields a pretty printed value.

This version of GDB is:

$ gdb --version
GNU gdb (GDB) Fedora (7.3-41.fc15)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

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