forked from qt-creator/qt-creator
debuggger: allow change of display for templated types
This commit is contained in:
@@ -2301,6 +2301,9 @@ def qdump__QScriptValue(d, item):
|
|||||||
#
|
#
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
|
#def qform__Eigen__Matrix():
|
||||||
|
# return "Transposed"
|
||||||
|
|
||||||
def qdump__Eigen__Matrix(d, item):
|
def qdump__Eigen__Matrix(d, item):
|
||||||
innerType = templateArgument(item.value.type, 0)
|
innerType = templateArgument(item.value.type, 0)
|
||||||
storage = item.value["m_storage"]
|
storage = item.value["m_storage"]
|
||||||
@@ -2318,18 +2321,15 @@ def qdump__Eigen__Matrix(d, item):
|
|||||||
d.putField("keeporder", "1")
|
d.putField("keeporder", "1")
|
||||||
d.putNumChild(nrows * ncols)
|
d.putNumChild(nrows * ncols)
|
||||||
|
|
||||||
limit = 100
|
limit = 10000
|
||||||
nncols = min(ncols, limit)
|
nncols = min(ncols, limit)
|
||||||
nnrows = min(nrows, limit * limit / nncols)
|
nnrows = min(nrows, limit * limit / nncols)
|
||||||
if d.isExpanded(item):
|
if d.isExpanded(item):
|
||||||
|
#format = d.itemFormat(item) # format == 1 is "Transposed"
|
||||||
iname = item.iname
|
iname = item.iname
|
||||||
with Children(d, nrows * ncols, innerType):
|
with Children(d, nrows * ncols, innerType):
|
||||||
if ncols == 1:
|
if ncols == 1 or nrows == 1:
|
||||||
for i in range(0, nnrows):
|
for i in range(0, min(nrows * ncols, 10000)):
|
||||||
v = (p + i).dereference()
|
|
||||||
d.putSubItem(Item(v, item.iname))
|
|
||||||
elif nrows == 1:
|
|
||||||
for i in range(0, nncols):
|
|
||||||
v = (p + i).dereference()
|
v = (p + i).dereference()
|
||||||
d.putSubItem(Item(v, item.iname))
|
d.putSubItem(Item(v, item.iname))
|
||||||
elif rowMajor == 1:
|
elif rowMajor == 1:
|
||||||
@@ -2342,7 +2342,7 @@ def qdump__Eigen__Matrix(d, item):
|
|||||||
for j in range(0, nncols):
|
for j in range(0, nncols):
|
||||||
for i in range(0, nnrows):
|
for i in range(0, nnrows):
|
||||||
name = "[%d,%d]" % (i, j)
|
name = "[%d,%d]" % (i, j)
|
||||||
v = (p + i * ncols + j).dereference()
|
v = (p + i + j * nrows).dereference()
|
||||||
d.putSubItem(Item(v, item.iname, None, name))
|
d.putSubItem(Item(v, item.iname, None, name))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3913,7 +3913,7 @@ void GdbEngine::insertData(const WatchData &data0)
|
|||||||
void GdbEngine::assignValueInDebugger(const WatchData *data,
|
void GdbEngine::assignValueInDebugger(const WatchData *data,
|
||||||
const QString &expression, const QVariant &value)
|
const QString &expression, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (hasPython()) {
|
if (hasPython() && !isIntOrFloatType(data->type)) {
|
||||||
QByteArray cmd = "bbedit "
|
QByteArray cmd = "bbedit "
|
||||||
+ data->type.toHex() + ','
|
+ data->type.toHex() + ','
|
||||||
+ expression.toUtf8().toHex() + ','
|
+ expression.toUtf8().toHex() + ','
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ QHash<QByteArray, int> WatchHandler::m_watcherNames;
|
|||||||
QHash<QByteArray, int> WatchHandler::m_typeFormats;
|
QHash<QByteArray, int> WatchHandler::m_typeFormats;
|
||||||
int WatchHandler::m_unprintableBase = 0;
|
int WatchHandler::m_unprintableBase = 0;
|
||||||
|
|
||||||
|
static QByteArray stripTemplate(const QByteArray &ba)
|
||||||
|
{
|
||||||
|
int pos = ba.indexOf('<');
|
||||||
|
return pos == -1 ? ba : ba.left(pos);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// WatchItem
|
// WatchItem
|
||||||
@@ -577,7 +583,7 @@ int WatchModel::itemFormat(const WatchData &data) const
|
|||||||
const int individualFormat = m_handler->m_individualFormats.value(data.iname, -1);
|
const int individualFormat = m_handler->m_individualFormats.value(data.iname, -1);
|
||||||
if (individualFormat != -1)
|
if (individualFormat != -1)
|
||||||
return individualFormat;
|
return individualFormat;
|
||||||
return m_handler->m_typeFormats.value(data.type, -1);
|
return m_handler->m_typeFormats.value(stripTemplate(data.type), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QString expression(const WatchItem *item)
|
static inline QString expression(const WatchItem *item)
|
||||||
@@ -717,13 +723,14 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
|||||||
<< tr("binary")
|
<< tr("binary")
|
||||||
<< tr("octal");
|
<< tr("octal");
|
||||||
// Hack: Compensate for namespaces.
|
// Hack: Compensate for namespaces.
|
||||||
QString type = data.type;
|
QString type = stripTemplate(data.type);
|
||||||
int pos = type.indexOf("::Q");
|
int pos = type.indexOf("::Q");
|
||||||
if (pos >= 0 && type.count(':') == 2)
|
if (pos >= 0 && type.count(':') == 2)
|
||||||
type = type.mid(pos + 2);
|
type = type.mid(pos + 2);
|
||||||
pos = type.indexOf('<');
|
pos = type.indexOf('<');
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
type = type.left(pos);
|
type = type.left(pos);
|
||||||
|
type.replace(':', '_');
|
||||||
return m_handler->m_reportedTypeFormats.value(type);
|
return m_handler->m_reportedTypeFormats.value(type);
|
||||||
}
|
}
|
||||||
case LocalsTypeRole:
|
case LocalsTypeRole:
|
||||||
@@ -731,7 +738,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
|||||||
case LocalsRawTypeRole:
|
case LocalsRawTypeRole:
|
||||||
return QString::fromLatin1(data.type);
|
return QString::fromLatin1(data.type);
|
||||||
case LocalsTypeFormatRole:
|
case LocalsTypeFormatRole:
|
||||||
return m_handler->m_typeFormats.value(data.type, -1);
|
return m_handler->m_typeFormats.value(stripTemplate(data.type), -1);
|
||||||
|
|
||||||
case LocalsIndividualFormatRole:
|
case LocalsIndividualFormatRole:
|
||||||
return m_handler->m_individualFormats.value(data.iname, -1);
|
return m_handler->m_individualFormats.value(data.iname, -1);
|
||||||
@@ -875,7 +882,8 @@ QVariant WatchModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||||||
// Set this before using any of the below according to action
|
// Set this before using any of the below according to action
|
||||||
static bool sortWatchDataAlphabetically = true;
|
static bool sortWatchDataAlphabetically = true;
|
||||||
|
|
||||||
static bool watchDataLessThan(const QByteArray &iname1, int sortId1, const QByteArray &iname2, int sortId2)
|
static bool watchDataLessThan(const QByteArray &iname1, int sortId1,
|
||||||
|
const QByteArray &iname2, int sortId2)
|
||||||
{
|
{
|
||||||
if (!sortWatchDataAlphabetically)
|
if (!sortWatchDataAlphabetically)
|
||||||
return sortId1 < sortId2;
|
return sortId1 < sortId2;
|
||||||
@@ -902,9 +910,10 @@ static bool watchDataLessThan(const QByteArray &iname1, int sortId1, const QByte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort key for watch data consisting of iname and numerical sort id.
|
// Sort key for watch data consisting of iname and numerical sort id.
|
||||||
struct WatchDataSortKey {
|
struct WatchDataSortKey
|
||||||
explicit WatchDataSortKey(const WatchData &wd) :
|
{
|
||||||
iname(wd.iname), sortId(wd.sortId) {}
|
explicit WatchDataSortKey(const WatchData &wd)
|
||||||
|
: iname(wd.iname), sortId(wd.sortId) {}
|
||||||
QByteArray iname;
|
QByteArray iname;
|
||||||
int sortId;
|
int sortId;
|
||||||
};
|
};
|
||||||
@@ -1117,7 +1126,7 @@ void WatchModel::formatRequests(QByteArray *out, const WatchItem *item) const
|
|||||||
{
|
{
|
||||||
int format = m_handler->m_individualFormats.value(item->iname, -1);
|
int format = m_handler->m_individualFormats.value(item->iname, -1);
|
||||||
if (format == -1)
|
if (format == -1)
|
||||||
format = m_handler->m_typeFormats.value(item->type, -1);
|
format = m_handler->m_typeFormats.value(stripTemplate(item->type), -1);
|
||||||
if (format != -1)
|
if (format != -1)
|
||||||
*out += item->iname + ":format=" + QByteArray::number(format) + ',';
|
*out += item->iname + ":format=" + QByteArray::number(format) + ',';
|
||||||
foreach (const WatchItem *child, item->children)
|
foreach (const WatchItem *child, item->children)
|
||||||
@@ -1574,8 +1583,9 @@ QModelIndex WatchHandler::itemIndex(const QByteArray &iname) const
|
|||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchHandler::setFormat(const QByteArray &type, int format)
|
void WatchHandler::setFormat(const QByteArray &type0, int format)
|
||||||
{
|
{
|
||||||
|
const QByteArray type = stripTemplate(type0);
|
||||||
if (format == -1)
|
if (format == -1)
|
||||||
m_typeFormats.remove(type);
|
m_typeFormats.remove(type);
|
||||||
else
|
else
|
||||||
@@ -1593,7 +1603,7 @@ int WatchHandler::format(const QByteArray &iname) const
|
|||||||
if (const WatchData *item = findItem(iname)) {
|
if (const WatchData *item = findItem(iname)) {
|
||||||
int result = m_individualFormats.value(item->iname, -1);
|
int result = m_individualFormats.value(item->iname, -1);
|
||||||
if (result == -1)
|
if (result == -1)
|
||||||
result = m_typeFormats.value(item->type, -1);
|
result = m_typeFormats.value(stripTemplate(item->type), -1);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1651,7 +1661,7 @@ QByteArray WatchHandler::individualFormatRequests() const
|
|||||||
|
|
||||||
void WatchHandler::addTypeFormats(const QByteArray &type, const QStringList &formats)
|
void WatchHandler::addTypeFormats(const QByteArray &type, const QStringList &formats)
|
||||||
{
|
{
|
||||||
m_reportedTypeFormats.insert(type, formats);
|
m_reportedTypeFormats.insert(stripTemplate(type), formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WatchHandler::editorContents()
|
QString WatchHandler::editorContents()
|
||||||
|
|||||||
@@ -146,15 +146,29 @@ private:
|
|||||||
|
|
||||||
// Watch model query helpers.
|
// Watch model query helpers.
|
||||||
static inline quint64 addressOf(const QModelIndex &m)
|
static inline quint64 addressOf(const QModelIndex &m)
|
||||||
{ return m.data(LocalsAddressRole).toULongLong(); }
|
{
|
||||||
|
return m.data(LocalsAddressRole).toULongLong();
|
||||||
|
}
|
||||||
|
|
||||||
static inline quint64 pointerValueOf(const QModelIndex &m)
|
static inline quint64 pointerValueOf(const QModelIndex &m)
|
||||||
{ return m.data(LocalsPointerValueRole).toULongLong(); }
|
{
|
||||||
|
return m.data(LocalsPointerValueRole).toULongLong();
|
||||||
|
}
|
||||||
|
|
||||||
static inline QString nameOf(const QModelIndex &m)
|
static inline QString nameOf(const QModelIndex &m)
|
||||||
{ return m.data().toString(); }
|
{
|
||||||
|
return m.data().toString();
|
||||||
|
}
|
||||||
|
|
||||||
static inline QString typeOf(const QModelIndex &m)
|
static inline QString typeOf(const QModelIndex &m)
|
||||||
{ return m.data(LocalsTypeRole).toString(); }
|
{
|
||||||
|
return m.data(LocalsTypeRole).toString();
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint sizeOf(const QModelIndex &m)
|
static inline uint sizeOf(const QModelIndex &m)
|
||||||
{ return m.data(LocalsSizeRole).toUInt(); }
|
{
|
||||||
|
return m.data(LocalsSizeRole).toUInt();
|
||||||
|
}
|
||||||
|
|
||||||
// Create a map of value->name for register markup
|
// Create a map of value->name for register markup
|
||||||
typedef QMap<quint64, QString> RegisterMap;
|
typedef QMap<quint64, QString> RegisterMap;
|
||||||
|
|||||||
@@ -2590,6 +2590,8 @@ void testEigen()
|
|||||||
#if USE_EIGEN
|
#if USE_EIGEN
|
||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
|
|
||||||
|
Vector3d test = Vector3d::Zero();
|
||||||
|
|
||||||
Matrix3d myMatrix = Matrix3d::Constant(5);
|
Matrix3d myMatrix = Matrix3d::Constant(5);
|
||||||
MatrixXd myDynamicMatrix(30, 10);
|
MatrixXd myDynamicMatrix(30, 10);
|
||||||
|
|
||||||
@@ -2597,11 +2599,11 @@ void testEigen()
|
|||||||
myDynamicMatrix(1, 0) = 1;
|
myDynamicMatrix(1, 0) = 1;
|
||||||
myDynamicMatrix(2, 0) = 2;
|
myDynamicMatrix(2, 0) = 2;
|
||||||
|
|
||||||
Matrix<double, 2, 1, RowMajor> rowMajorMatrix1;
|
Matrix<double, 2, 3, ColMajor> colMajorMatrix;
|
||||||
rowMajorMatrix1 << 34, 44;
|
colMajorMatrix << 0, 1, 2, 3, 4, 5;
|
||||||
|
|
||||||
Matrix<double, 2, 2, RowMajor> rowMajorMatrix;
|
Matrix<double, 2, 3, RowMajor> rowMajorMatrix;
|
||||||
rowMajorMatrix << 0, 1, 2, 3;
|
rowMajorMatrix << 0, 1, 2, 3, 4, 5;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
++i;
|
++i;
|
||||||
|
|||||||
Reference in New Issue
Block a user