GDB printers: print as string instead of char array
Ralf Habacker
ralf.habacker at freenet.de
Wed Aug 4 11:35:41 BST 2021
Am 03.08.21 um 17:24 schrieb Da Viper via Kde-finance-apps:
> There is a current problem when i try to return a python string as
> part of a pretty printer children
>
> in an gdb cli it prints as a string but in any IDE it does not print
> as a string it only prints as a char array
>
> i checked the internet the only thing is could find is a question in
> stackoverflow
> https://stackoverflow.com/questions/26472066/gdb-pretty-printing-returning-string-from-a-childrens-iterator-but-displaye
>
> and a bug report in sourceware
> https://sourceware.org/bugzilla/show_bug.cgi?id=18282
>
> you could try what i mean with `QStringRef` and view the ref_str in
> kdevelop and IDE
>
I guess that kdevelop uses the GDB/MI interface to send commands, which
may have a different behavior compared with command line gdb.
With command line gdb you can enable this mode either by starting gdb
with the interpreter-exec command as shown in the following example:
$ gdb
(gdb) interpreter-exec mi "-data-list-register-names"
which returns
-data-list-register-names
^done,register-names=["eax","ecx","edx","ebx","esp","ebp","esi","edi","eip","eflags","cs","ss","ds","es","fs","gs","st0","st1","st2","st3","st4","st5","st6","st7","fctrl","fstat","ftag","fiseg","fioff","foseg","fooff","fop","xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7","mxcsr","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","orig_eax","al","cl","dl","bl","ah","ch","dh","bh","ax","cx","dx","bx","","bp","si","di","mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7"]
(gdb)
or by using the --interpreter command line option as shown below
$ gdb --quiet --interpreter mi
=thread-group-added,id="i1"
=cmd-param-changed,param="python print-stack",value="full"
~"-----------------------------\n"
(gdb)
Then you can enter mi related commands:
-data-list-register-names
^done,register-names=["eax","ecx","edx","ebx","esp","ebp","esi","edi","eip","eflags","cs","ss","ds","es","fs","gs","st0","st1","st2","st3","st4","st5","st6","st7","fctrl","fstat","ftag","fiseg","fioff","foseg","fooff","fop","xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7","mxcsr","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","orig_eax","al","cl","dl","bl","ah","ch","dh","bh","ax","cx","dx","bx","","bp","si","di","mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7"]
(gdb)
So see which commands the IDE sends to gdb, in qtcreator you can enable
the "Debugger-log" view
https://doc.qt.io/qtcreator/creator-troubleshooting-debugging.html,
which shows all sended and received data. You can also enter gdb
commands directly by the IDE.
For kdevelop I current do not know how to show them. Maybe Thomas can
point you to the right direction related to this topic.
Regards
Ralf
More information about the Kde-finance-apps
mailing list