Para aquellos que utilizan QtCreator, puede inspeccionar los valores de su IDE por extending GDB with Python Debugging Helpers (tal vez otros entornos de desarrollo compatibles con esta función también).
Coloque la siguiente secuencia de comandos, por ejemplo, ~/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
y lo llaman añadir esta línea a su ~/.gdbinit
:
python exec(open('/<full_path>/debugHelpers.py').read())
o añadirlo en su IDE; en QtCreator usa Herramientas> Opciones> Depurador> GDB (pestaña)> Ayudantes de depuración extra (cerca de la parte inferior).
Este script en particular devolverá la matriz organizada por columnas (disposición de memoria natural en mi arquitectura):

Fuentes: Writing Debug Visualizers for GDB/QtCreator 2.8
gdb reciente (la última versión es GDB 7.4) puede b e guionado en Python. ¿Lo consideraste? –