Bug 499752 - The debugger (gdb) cannot display values of instances of the MyMoneyMoney class
Summary: The debugger (gdb) cannot display values of instances of the MyMoneyMoney class
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: buildsystem (show other bugs)
Version: 5.1.92
Platform: Other All
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-10 11:13 UTC by Ralf Habacker
Modified: 2025-02-15 09:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.2
Sentry Crash Report:


Attachments
Patch fixing the issue (1.50 KB, patch)
2025-02-13 21:05 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2025-02-10 11:13:49 UTC
SUMMARY
The class MyMoneyMoney is an elementary class and is used very often in the source code. Since the contained value is hidden inside, it cannot be displayed directly in debuggers such as gdb, kdevelop or QtCreator, which makes debugging more difficult. Outputs must therefore be generated manually by adding debug outputs, e.g. with `qDebug() << instance.toDouble()` or in the gdb window with `p instance.toDouble()`. It would speed up debugging if there is corresponding support for debuggers. 

STEPS TO REPRODUCE
1. build kmymoney from source (git master branch) with debug information included
2. run 
```
gdb <builddir>/bin/kmymoney
(gdb) b main
(gdb) r
(gdb) b MyMoneyMoney::One
```
3.  inspect debugger output

OBSERVED RESULT
The debugger displays a lot of data, but not the relevant value:
```
(gdb) p MyMoneyMoney::ONE
$1 = {<AlkValue> = {d = {d = 0x87f300}}, _vptr.MyMoneyMoney = 0x7ffff78b18c0 <vtable for MyMoneyMoney+16>, static maxValue = {<AlkValue> = {d = {d = 0x8807e0}}, 
    _vptr.MyMoneyMoney = 0x7ffff78b18c0 <vtable for MyMoneyMoney+16>, static maxValue = <same as static member of an already seen type>, static minValue = {<AlkValue> = {d = {d = 0x880810}}, 
      _vptr.MyMoneyMoney = 0x7ffff78b18c0 <vtable for MyMoneyMoney+16>, static maxValue = <same as static member of an already seen type>, 
      static minValue = <same as static member of an already seen type>, static autoCalc = {<AlkValue> = {d = {d = 0x8807b0}}, _vptr.MyMoneyMoney = 0x7ffff78b18c0 <vtable for MyMoneyMoney+16>, 
        static maxValue = <same as static member of an already seen type>, static minValue = <same as static member of an already seen type>, 
        static autoCalc = <same as static member of an already seen type>, static ONE = {<AlkValue> = {d = {d = 0x87f300}}, _vptr.MyMoneyMoney = 0x7ffff78b18c0 <vtable for MyMoneyMoney+16>, 
          static maxValue = <same as static member of an already seen type>, static minValue = <same as static member of an already seen type>, 
          static autoCalc = <same as static member of an already seen type>, static ONE = <same as static member of an already seen type>, static MINUS_ONE = {<AlkValue> = {d = {d = 0x87f3f0}}, 
            _vptr.MyMoneyMoney = 0x7ffff78b18c0 <vtable for MyMoneyMoney+16>, static maxValue = <same as static member of an already seen type>, 
            static minValue = <same as static member of an already seen type>, static autoCalc = <same as static member of an already seen type>, 
            static ONE = <same as static member of an already seen type>, static MINUS_ONE = <same as static member of an already seen type>}}, 
        static MINUS_ONE = <same as static member of an already seen type>}, static ONE = <same as static member of an already seen type>, 
      static MINUS_ONE = <same as static member of an already seen type>}, static autoCalc = <same as static member of an already seen type>, 
    static ONE = <same as static member of an already seen type>, static MINUS_ONE = <same as static member of an already seen type>}, 
  static minValue = <same as static member of an already seen type>, static autoCalc = <same as static member of an already seen type>, static ONE = <same as static member of an already seen type>, 
  static MINUS_ONE = <same as static member of an already seen type>}
```

EXPECTED RESULT
Instead, the debugger should display the value contained in the named instance
```
(gdb) p MyMoneyMoney::ONE
$1 = 1
```
SOFTWARE/OS VERSIONS
Operating System: openSUSE Leap 15.6
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.12
Comment 1 Ralf Habacker 2025-02-10 11:16:01 UTC
Git commit cac6330c8062930452b06b552474c8c76b31caef by Ralf Habacker.
Committed on 10/02/2025 at 11:15.
Pushed by habacker into branch 'master'.

Add gdb pretty printer for MyMoneyMoney class

With Windows/gdb, 'set auto-load safe-path /' must be used
before starting an executable file to activate the loading
of a pretty printer.

Gdb pretty printers work in kdevelop and the gdb window in
QtCreator with the 'p' command, but currently not in the
symbol display due to a bug in the QtCreator gdb bridge
(https://bugreports.qt.io/browse/QTCREATORBUG-32480).
FIXED-IN:5.2

M  +6    -0    kmymoney/mymoney/CMakeLists.txt
A  +28   -0    kmymoney/mymoney/kmm_mymoney-gdb.py

https://invent.kde.org/office/kmymoney/-/commit/cac6330c8062930452b06b552474c8c76b31caef
Comment 2 Ralf Habacker 2025-02-12 22:18:39 UTC
(In reply to Ralf Habacker from comment #1)
...
> Gdb pretty printers work in kdevelop and the gdb window in
> QtCreator with the 'p' command, but currently not in the
> symbol display due to a bug in the QtCreator gdb bridge
> (https://bugreports.qt.io/browse/QTCREATORBUG-32480).

A merge request has been opened at https://codereview.qt-project.org/c/qt-creator/qt-creator/+/624064 with a corresponding correction for QtCreator.
Comment 3 Ralf Habacker 2025-02-13 21:05:21 UTC
Created attachment 178319 [details]
Patch fixing the issue

(In reply to Ralf Habacker from comment #2)
> A merge request has been opened at
> https://codereview.qt-project.org/c/qt-creator/qt-creator/+/624064 with a
> corresponding correction for QtCreator.

A corresponding correction will be included in Qt Creator 16.0.0-rc1. For older versions, the patch has been appended to this ticket and can be applied to /usr/share/qtcreator/debugger/gdbbridge.py.
Comment 4 Ralf Habacker 2025-02-15 09:02:06 UTC
Git commit ef21565070fa0325693ab579f9318eea341610e3 by Ralf Habacker.
Committed on 15/02/2025 at 08:57.
Pushed by habacker into branch 'master'.

Add gdb pretty printer for MyMoneyPrice, MyMoneySecurity and MyMoneySplit classes

These pretty printers significantly improve the debugging capabilities of KMyMoney.

M  +118  -6    kmymoney/mymoney/kmm_mymoney-gdb.py

https://invent.kde.org/office/kmymoney/-/commit/ef21565070fa0325693ab579f9318eea341610e3