QtCreator का उपयोग करने वालों के लिए, आप extending GDB with Python Debugging Helpers करके अपने आईडीई से मूल्यों का निरीक्षण कर सकते (शायद अन्य IDEs भी इस सुविधा का समर्थन)।
प्लेस में निम्न स्क्रिप्ट, उदाहरण के लिए, ~/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
और यह आपके ~/.gdbinit
को यह पंक्ति जोड़कर फोन:
python exec(open('/<full_path>/debugHelpers.py').read())
या अपने आईडीई से इसे जोड़ने; QtCreator में टूल्स> विकल्प> डीबगर> जीडीबी (टैब)> अतिरिक्त डिबगिंग हेल्पर्स (नीचे के पास) का उपयोग करें।
यह विशेष रूप से स्क्रिप्ट (मेरी वास्तुकला में प्राकृतिक स्मृति व्यवस्था) मैट्रिक्स स्तंभों के आधार पर व्यवस्थित वापस आ जाएगी:
सूत्रों का कहना है: Writing Debug Visualizers for GDB/QtCreator 2.8
हालिया जीडीबी (नवीनतम रिलीज जीडीबी 7.4 है) बी ई पायथन में लिखित। क्या आपने इसे माना ?? –