Bug 28201 - Unable to show children and to string pretty-printer values at the same time.
Summary: Unable to show children and to string pretty-printer values at the same time.
Status: RESOLVED DUPLICATE of bug 11335
Alias: None
Product: gdb
Classification: Unclassified
Component: mi (show other bugs)
Version: 10.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-06 14:38 UTC by Ezike Ebuka
Modified: 2022-05-25 18:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2021-08-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ezike Ebuka 2021-08-06 14:38:46 UTC
For example if i create a vector; 

```
std::vector<std::string> aVector { "this", "is", "a", "standard", "list"}

```

in the normal gdb command line i would get 


```
p aVector 
$1 = std::vector of length 5, capacity 5 = {"this", "is ", "a", "standard", "list"}

```
however in GDB/MI


``` 
-var-create - * "aVector"

--
result-class: done
name: var21
numchild: 0
value: {...}
type: std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >
thread-id: 1
displayhint: array
dynamic: 1
has_more: 1

```

the to_string value of the std::vector pretty printer is gone and replaced by "{...}"

the values is meant to show the size of the vector and very valuable when debugging.

with the help of my mentor i was able to get the relevant part that it is hardcoded to return `{...}` (there may be other parts) that may be relevant.

here

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/c-varobj.c;h=f6db3a5d1ba77ad86e7d36a2cd94ef5fdc26069b;hb=refs/heads/master#l478

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/varobj.c;h=d0c857a69060644b225f3072b96c90a44b6d1548;hb=refs/heads/master#l2162


thanks
Comment 1 Tom Tromey 2021-08-06 16:07:38 UTC
Yeah, back when we added Python pretty-printing, the MI maintainer
requested this behavior.  I don't know why, as it seems un-useful to me.
Perhaps we could lift this restriction and show the to_string output
correctly in MI.  (Maybe only under the newest MI version, to keep
compatibility.)
Comment 2 Ezike Ebuka 2021-08-15 19:56:20 UTC
(In reply to Tom Tromey from comment #1)
> Yeah, back when we added Python pretty-printing, the MI maintainer
> requested this behavior.  I don't know why, as it seems un-useful to me.
> Perhaps we could lift this restriction and show the to_string output
> correctly in MI.  (Maybe only under the newest MI version, to keep
> compatibility.)

yeah that would be nice to remove the restriction on either the last or the last two mi versions.
Comment 3 Tom Tromey 2022-05-25 18:24:52 UTC
Marking this one as a dup, as the other bug is older and has a patch.

*** This bug has been marked as a duplicate of bug 11335 ***