GDB printers: print as string instead of char array

Ralf Habacker ralf.habacker at freenet.de
Thu Aug 5 09:45:24 BST 2021


Am 04.08.21 um 16:02 schrieb Da Viper via Kde-finance-apps:
> Hello there i was able to narrow down the problem,
> 
> it is that gdb/MI does not print to_string values if it has children.

> i am not sure why and do not know any way to change that. If you do
> let me know

if there is nothing in the documentation (for example
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html#GDB_002fMI-Variable-Objects)
you may inspect the source.

I checked out the gdb sources from

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git, entered the
source dir and did

1. switch to the version of the used gdb
$ git reset --hard gdb-10.2-release

2. find requested string
$ find -name '*.c' -exec grep -Hn '"{\.\.\.}"' {} \;

which prints out several occurences

./gdb/ada-varobj.c:869:      return "{...}";
./gdb/varobj.c:1241:   always "{...}", so no comparison is necessary
here.  If the old
./gdb/varobj.c:2306:        return "{...}";
./gdb/language.c:801:  "{...}"                  /*
la_struct_too_deep_ellipsis */
./gdb/language.c:927:  "{...}"                  /*
la_struct_too_deep_ellipsis */
./gdb/c-varobj.c:479:     it will print out its children instead of
"{...}".  So we need to
./gdb/c-varobj.c:491:      return "{...}";
./gdb/opencl-lang.c:1024:  "{...}"                      /*
la_struct_too_deep_ellipsis */
./gdb/c-typeprint.c:1086:       fprintf_filtered (stream, "{...}");
./gdb/c-typeprint.c:1573:           fprintf_filtered (stream, "{...}");
./gdb/m2-lang.c:217:  "{...}"                   /*
la_struct_too_deep_ellipsis */
./gdb/m2-valprint.c:370:          fprintf_filtered (stream, "{...}");
./gdb/c-lang.c:898:  "{...}"                    /*
la_struct_too_deep_ellipsis */
./gdb/c-lang.c:999:  "{...}"                    /*
la_struct_too_deep_ellipsis */
./gdb/c-lang.c:1197:  "{...}"                   /*
la_struct_too_deep_ellipsis */
./gdb/c-lang.c:1253:  "{...}"                   /*
la_struct_too_deep_ellipsis */
./gdb/p-valprint.c:295:   fprintf_filtered (stream, "{...}");
./gdb/d-lang.c:151:  "{...}"                    /*
la_struct_too_deep_ellipsis */
./gdb/c-valprint.c:369:    fprintf_filtered (stream, "{...}");
./gdb/p-lang.c:275:  "{...}"                    /*
la_struct_too_deep_ellipsis */
./gdb/rust-lang.c:1929:  "{...}"                        /*
la_struct_too_deep_ellipsis */
./gdb/go-lang.c:526:  "{...}"                   /*
la_struct_too_deep_ellipsis */
./gdb/objc-lang.c:346:  "{...}"                 /*
la_struct_too_deep_ellipsis */
./gdb/p-typeprint.c:555:            fprintf_filtered (stream, "{...}");


According to the list above, this location looks promising

./gdb/c-varobj.c:479:     it will print out its children instead of
"{...}".  So we need to

Regards
Ralf


More information about the Kde-finance-apps mailing list