forked from qt-creator/qt-creator
Debugger: Add a few dumpers for OpenCV related structures
Mainly as test ground to show of matrix display later. Change-Id: I49e6d06bf7203532e384cc3215483512089bfcf5 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -294,6 +294,7 @@ class DumperBase:
|
||||
"stdtypes",
|
||||
"misctypes",
|
||||
"boosttypes",
|
||||
"opencvtypes",
|
||||
"creatortypes",
|
||||
"personaltypes",
|
||||
]
|
||||
@@ -2714,6 +2715,8 @@ class DumperBase:
|
||||
field.name = index
|
||||
elif isinstance(index, self.dumper.Field):
|
||||
field = index
|
||||
elif self.dumper.isInt(index):
|
||||
return self.members()[index]
|
||||
else:
|
||||
error("BAD INDEX TYPE %s" % type(index))
|
||||
field.check()
|
||||
@@ -2790,6 +2793,13 @@ class DumperBase:
|
||||
val.lbitsize = field.bitsize()
|
||||
return val
|
||||
|
||||
def members(self):
|
||||
members = []
|
||||
for field in self.type.fields():
|
||||
if not field.isBaseClass:
|
||||
members.append(self.extractField(field))
|
||||
return members
|
||||
|
||||
def __add__(self, other):
|
||||
self.check()
|
||||
if self.dumper.isInt(other):
|
||||
@@ -3274,6 +3284,13 @@ class DumperBase:
|
||||
#warn("CREATE TYPE: %s" % typeobj)
|
||||
typeobj.check()
|
||||
return typeobj
|
||||
if self.isInt(typish):
|
||||
# Assume it is an typecode, create an "anonymous" Type
|
||||
typeobj = self.Type(self)
|
||||
typeobj.code = typish
|
||||
typeobj.lbitsize = 8 * size
|
||||
typeobj.name = ' '
|
||||
return typeobj
|
||||
error("NEED TYPE, NOT %s" % type(typish))
|
||||
|
||||
def createValue(self, datish, typish):
|
||||
|
62
share/qtcreator/debugger/opencvtypes.py
Normal file
62
share/qtcreator/debugger/opencvtypes.py
Normal file
@@ -0,0 +1,62 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (C) 2016 The Qt Company Ltd.
|
||||
# Contact: https://www.qt.io/licensing/
|
||||
#
|
||||
# This file is part of Qt Creator.
|
||||
#
|
||||
# Commercial License Usage
|
||||
# Licensees holding valid commercial Qt licenses may use this file in
|
||||
# accordance with the commercial license agreement provided with the
|
||||
# Software or, alternatively, in accordance with the terms contained in
|
||||
# a written agreement between you and The Qt Company. For licensing terms
|
||||
# and conditions see https://www.qt.io/terms-conditions. For further
|
||||
# information use the contact form at https://www.qt.io/contact-us.
|
||||
#
|
||||
# GNU General Public License Usage
|
||||
# Alternatively, this file may be used under the terms of the GNU
|
||||
# General Public License version 3 as published by the Free Software
|
||||
# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
# included in the packaging of this file. Please review the following
|
||||
# information to ensure the GNU General Public License requirements will
|
||||
# be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
from dumper import *
|
||||
|
||||
def qdump__cv__Size_(d, value):
|
||||
d.putValue("(%s, %s)" % (value[0].display(), value[1].display()))
|
||||
d.putPlainChildren(value)
|
||||
|
||||
def qform__cv__Mat():
|
||||
return [SeparateFormat]
|
||||
|
||||
def qdump__cv__Mat(d, value):
|
||||
(flag, dims, rows, cols, data, refcount, datastart, dataend,
|
||||
datalimit, allocator, size, stepp) \
|
||||
= value.split("iiiipppppppp")
|
||||
steps = d.split('p' * dims, stepp)
|
||||
innerSize = 0 if dims == 0 else steps[dims - 1]
|
||||
if dims != 2:
|
||||
d.putEmptyValue()
|
||||
d.putPlainChildren(value)
|
||||
return
|
||||
|
||||
if d.currentItemFormat() == SeparateFormat:
|
||||
rs = steps[0] * innerSize
|
||||
cs = cols * innerSize
|
||||
dform = "arraydata:separate:int:%d::2:%d:%d" % (innerSize, cols, rows)
|
||||
out = ''.join(d.readMemory(data + i * rs, cs) for i in range(rows))
|
||||
d.putDisplay(dform, out)
|
||||
|
||||
d.putValue("(%s x %s)" % (rows, cols))
|
||||
if d.isExpanded():
|
||||
with Children(d):
|
||||
innerType = d.createType(TypeCodeIntegral, innerSize)
|
||||
for i in range(rows):
|
||||
for j in range(cols):
|
||||
with SubItem(d, None):
|
||||
d.putName("[%d,%d]" % (i, j))
|
||||
addr = data + (i * steps[0] + j) * innerSize
|
||||
d.putItem(d.createValue(addr, innerType))
|
@@ -248,6 +248,7 @@ const char DisplayUcs4String[] = "ucs4:separate";
|
||||
const char DisplayImageData[] = "imagedata:separate";
|
||||
const char DisplayImageFile[] = "imagefile:separate";
|
||||
const char DisplayPlotData[] = "plotdata:separate";
|
||||
const char DisplayArrayData[] = "arraydata:separate";
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Debugger
|
||||
|
@@ -68,6 +68,7 @@
|
||||
#include <QProcess>
|
||||
#include <QTabWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QTableWidget>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -272,10 +273,10 @@ public:
|
||||
QVariant geometry = sessionValue("DebuggerSeparateWidgetGeometry");
|
||||
if (geometry.isValid()) {
|
||||
QRect rc = geometry.toRect();
|
||||
if (rc.width() < 200)
|
||||
rc.setWidth(200);
|
||||
if (rc.height() < 200)
|
||||
rc.setHeight(200);
|
||||
if (rc.width() < 400)
|
||||
rc.setWidth(400);
|
||||
if (rc.height() < 400)
|
||||
rc.setHeight(400);
|
||||
setGeometry(rc);
|
||||
}
|
||||
}
|
||||
@@ -2139,6 +2140,13 @@ static void swapEndian(char *d, int nchar)
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> void readOne(const char *p, QString *res, int size)
|
||||
{
|
||||
T r = 0;
|
||||
memcpy(&r, p, size);
|
||||
res->setNum(r);
|
||||
}
|
||||
|
||||
void WatchModel::showEditValue(const WatchItem *item)
|
||||
{
|
||||
const QString &format = item->editformat;
|
||||
@@ -2206,6 +2214,41 @@ void WatchModel::showEditValue(const WatchItem *item)
|
||||
std::vector<double> data;
|
||||
readNumericVector(&data, QByteArray::fromHex(item->editvalue.toUtf8()), item->editencoding);
|
||||
m_separatedView->prepareObject<PlotViewer>(item)->setData(data);
|
||||
} else if (format.startsWith(DisplayArrayData)) {
|
||||
QString innerType = format.section(':', 2, 2);
|
||||
int innerSize = format.section(':', 3, 3).toInt();
|
||||
QTC_ASSERT(0 <= innerSize && innerSize <= 8, return);
|
||||
// int hint = format.section(':', 4, 4).toInt();
|
||||
int ndims = format.section(':', 5, 5).toInt();
|
||||
int ncols = format.section(':', 6, 6).toInt();
|
||||
int nrows = format.section(':', 7, 7).toInt();
|
||||
QTC_ASSERT(ndims == 2, qDebug() << "Display format: " << format; return);
|
||||
QByteArray ba = QByteArray::fromHex(item->editvalue.toUtf8());
|
||||
|
||||
void (*reader)(const char *p, QString *res, int size) = 0;
|
||||
if (innerType == "int")
|
||||
reader = &readOne<qlonglong>;
|
||||
else if (innerType == "uint")
|
||||
reader = &readOne<qulonglong>;
|
||||
else if (innerType == "float") {
|
||||
if (innerSize == 4)
|
||||
reader = &readOne<float>;
|
||||
else if (innerSize == 4)
|
||||
reader = &readOne<double>;
|
||||
}
|
||||
QTC_ASSERT(reader, return);
|
||||
auto table = m_separatedView->prepareObject<QTableWidget>(item);
|
||||
table->setRowCount(nrows);
|
||||
table->setColumnCount(ncols);
|
||||
QString s;
|
||||
const char *p = ba.constBegin();
|
||||
for (int i = 0; i < nrows; ++i) {
|
||||
for (int j = 0; j < ncols; ++j) {
|
||||
reader(p, &s, innerSize);
|
||||
table->setItem(i, j, new QTableWidgetItem(s));
|
||||
p += innerSize;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QTC_ASSERT(false, qDebug() << "Display format: " << format);
|
||||
}
|
||||
|
Reference in New Issue
Block a user