Dla tych użyciu Qt Creator, można sprawdzić wartości z IDE przez extending GDB with Python Debugging Helpers (być może inne IDE obsługuje tej funkcji zbyt).
Umieść poniższy skrypt, na przykład, ~/debugHelpers.py
#!/usr/bin/python
import gdb # gdb.Value()
import dumper # dumper.Children()
def qdump__arma__Mat(d, value):
array = value["mem"]
cols = value["n_cols"]
rows = value["n_rows"]
maxDisplayItems = 50
innerType = d.templateArgument(value.type, 0)
p = gdb.Value(array.cast(innerType.pointer()))
d.putItemCount(cols)
d.putNumChild(cols)
if d.isExpanded():
numDisplayItems = min(maxDisplayItems, cols)
with dumper.Children(d, numChild=cols,
maxNumChild=numDisplayItems,
childType="<column>",
addrBase=p,
addrStep=p.dereference().__sizeof__):
for i in range(0, int(numDisplayItems)):
with dumper.Children(d):
d.putItemCount(rows)
d.putNumChild(rows)
if d.isExpanded():
numDisplayItems = min(maxDisplayItems, rows)
with dumper.Children(d, numChild=rows,
maxNumChild=numDisplayItems,
childType=innerType,
addrBase=p,
addrStep=p.dereference().__sizeof__):
for j in range(0, int(numDisplayItems)):
d.putSubItem(j, p.dereference())
p += 1
i nazywają to dodanie tej linii do ~/.gdbinit
:
python exec(open('/<full_path>/debugHelpers.py').read())
lub dodać go z IDE; w QtCreator użyj Narzędzia> Opcje> Debugger> GDB (tab)> Dodatkowe narzędzia do debugowania (u dołu).
Ten konkretny skrypt zwróci macierz umieszczoną na kolumnach (naturalny układ pamięci w moim architektury):

Źródła: Writing Debug Visualizers for GDB/QtCreator 2.8
Najnowsze gdb (najnowsze wydanie to GDB 7.4) może b e skryptowane w Pythonie. Czy myślałeś o tym? –