В GDB есть
возможность писать pretty-printers на python.
Python
import gdb
class MoneyPrinter:
def __init__(self, val):
self.val = val
def to_string(self):
return 'Money: ' + str(self.val['amount']*0.01)
def lookup_function (val):
if str(val.type) == 'Money':
return MoneyPrinter(val)
return None
gdb.pretty_printers.append(lookup_function)
>gdb money.exe
...
Reading symbols from C:\...\money.exe...done.
(gdb) l
1 struct Money {
2 int amount;
3 };
4
5 int main()
6 {
7 Money m = { 123 };
8 return 0;
9 }
(gdb) b 8
Breakpoint 1 at 0x401576: file money.cpp, line 8.
(gdb) r
Starting program: C:\...\money.exe
[New Thread 1672.0x176c]
Breakpoint 1, main () at money.cpp:8
8 return 0;
(gdb) p m
$1 = Money: 1.23