GDB Printers Use string instead of char array

Da Viper yerimyah1 at gmail.com
Thu Jul 29 13:22:04 BST 2021


would update it

Hello what os and architecture was it built on that it gets optimised out ?


How do you check that the position is in 1 instead of 2 in  i586
architecture




On Thu, 29 Jul 2021, 12:22 Ralf Habacker via Kde-finance-apps, <
kde-finance-apps at kde.org> wrote:

> Am 29.07.21 um 12:49 schrieb Ralf Habacker via Kde-finance-apps:
> > Am 28.07.21 um 15:48 schrieb Da Viper via Kde-finance-apps:
> >> i am trying to return a string as one of the children in the pretty
> printer
> >>
> Compiling a test case for QStringRef having
>
>
>    QString a("test)
>    QStringRef aRef(&a);
>
>
> with RelWidhDebInfo cmake build type on running gdb 10.1 with your qt
> printers enabled I get the following error:
>
> Traceback (most recent call last):
>   File "/usr/share/gdb/python/gdb/printing.py", line 218, in __call__
>     return printer.gen_printer(val)
>   File "/home/ralf.habacker/src/gdb_printers/printers/qtprinters.py",
> line 301, in __init__
>     self.index = int(val['m_position'])
> gdb.error: value has been optimized out
>
>
> According to
> https://github.com/qt/qtbase/blob/5.15/src/corelib/text/qstring.h#L1602
> QStringRef is defined as
>
> class Q_CORE_EXPORT QStringRef {
>     const QString *m_string;
>     int m_position;
>     int m_size;
>
>
> m_position is be accessable by using
>
> (gdb) p ((int*)&aRef)[2]
> $3 = 0
>
> when the target has been compiled for x86_64 architecture and by
>
> (gdb) p ((int*)&aRef)[1]
> $3 = 0
>
> with i586 architecture.
>
>
> Accessing the referenced string can be done with
>
> (gdb) p *(QString**)&aRef
> $3 = (QString *) 0x7fffffffd6e8
>
> and the content returned by
>
> (gdb) p **(QString**)&bRef
> $4 = "test"
>
> Regards
> Ralf
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-finance-apps/attachments/20210729/9be4655d/attachment.htm>


More information about the Kde-finance-apps mailing list