Per coloro che utilizzano QtCreator, è possibile controllare i valori dal vostro IDE da extending GDB with Python Debugging Helpers (forse altri IDE supportano questa caratteristica troppo).
Inserire il seguente script, per esempio, ~/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
e lo chiamano aggiungendo questa linea al vostro ~/.gdbinit
:
python exec(open('/<full_path>/debugHelpers.py').read())
o aggiungerlo dal vostro IDE; in QtCreator utilizzare Strumenti> Opzioni> Debugger> GDB (scheda)> Ulteriori helper di debug (nella parte inferiore).
Questo script particolare tornerà la matrice organizzato da colonne (arrangiamento di memoria naturale nella mia architettura):
Fonti: Writing Debug Visualizers for GDB/QtCreator 2.8
Recenti gdb (ultima versione è GDB 7.4) può b e script in Python. Lo hai preso in considerazione ?? –