diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 5c551e1775b..e0248862bf0 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -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): diff --git a/share/qtcreator/debugger/opencvtypes.py b/share/qtcreator/debugger/opencvtypes.py new file mode 100644 index 00000000000..299a5e900ef --- /dev/null +++ b/share/qtcreator/debugger/opencvtypes.py @@ -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)) diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index f24d3b951a6..ceb3c9206d5 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -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 diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index ff50016f3a6..97970782666 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -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 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 data; readNumericVector(&data, QByteArray::fromHex(item->editvalue.toUtf8()), item->editencoding); m_separatedView->prepareObject(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; + else if (innerType == "uint") + reader = &readOne; + else if (innerType == "float") { + if (innerSize == 4) + reader = &readOne; + else if (innerSize == 4) + reader = &readOne; + } + QTC_ASSERT(reader, return); + auto table = m_separatedView->prepareObject(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); }