forked from qt-creator/qt-creator
debugger: remember format settings also for individual variables
Task-number: QTCREATORBUG-6944 Change-Id: I98c803e64a6a1ac2c07a0d0b0f31c6d7756faffc Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -72,8 +72,11 @@ enum { debugModel = 0 };
|
|||||||
#define MODEL_DEBUG(s) do { if (debugModel) qDebug() << s; } while (0)
|
#define MODEL_DEBUG(s) do { if (debugModel) qDebug() << s; } while (0)
|
||||||
#define MODEL_DEBUGX(s) qDebug() << s
|
#define MODEL_DEBUGX(s) qDebug() << s
|
||||||
|
|
||||||
QHash<QByteArray, int> WatchHandler::m_watcherNames;
|
static QHash<QByteArray, int> theWatcherNames;
|
||||||
QHash<QByteArray, int> WatchHandler::m_typeFormats;
|
static QHash<QByteArray, int> theTypeFormats;
|
||||||
|
static QHash<QByteArray, int> theIndividualFormats;
|
||||||
|
static int theUnprintableBase = -1;
|
||||||
|
|
||||||
|
|
||||||
static QByteArray stripForFormat(const QByteArray &ba)
|
static QByteArray stripForFormat(const QByteArray &ba)
|
||||||
{
|
{
|
||||||
@@ -97,17 +100,15 @@ static QByteArray stripForFormat(const QByteArray &ba)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int m_unprintableBase = -1;
|
|
||||||
|
|
||||||
void WatchHandler::setUnprintableBase(int base)
|
void WatchHandler::setUnprintableBase(int base)
|
||||||
{
|
{
|
||||||
m_unprintableBase = base;
|
theUnprintableBase = base;
|
||||||
emitAllChanged();
|
emitAllChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int WatchHandler::unprintableBase()
|
int WatchHandler::unprintableBase()
|
||||||
{
|
{
|
||||||
return m_unprintableBase;
|
return theUnprintableBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@@ -706,10 +707,10 @@ static QString truncateValue(QString v)
|
|||||||
|
|
||||||
int WatchModel::itemFormat(const WatchData &data) const
|
int WatchModel::itemFormat(const WatchData &data) const
|
||||||
{
|
{
|
||||||
const int individualFormat = m_handler->m_individualFormats.value(data.iname, -1);
|
const int individualFormat = theIndividualFormats.value(data.iname, -1);
|
||||||
if (individualFormat != -1)
|
if (individualFormat != -1)
|
||||||
return individualFormat;
|
return individualFormat;
|
||||||
return m_handler->m_typeFormats.value(stripForFormat(data.type), -1);
|
return theTypeFormats.value(stripForFormat(data.type), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QString expression(const WatchItem *item)
|
static inline QString expression(const WatchItem *item)
|
||||||
@@ -837,10 +838,10 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
|||||||
return QString::fromLatin1(data.type);
|
return QString::fromLatin1(data.type);
|
||||||
|
|
||||||
case LocalsTypeFormatRole:
|
case LocalsTypeFormatRole:
|
||||||
return m_handler->m_typeFormats.value(stripForFormat(data.type), -1);
|
return theTypeFormats.value(stripForFormat(data.type), -1);
|
||||||
|
|
||||||
case LocalsIndividualFormatRole:
|
case LocalsIndividualFormatRole:
|
||||||
return m_handler->m_individualFormats.value(data.iname, -1);
|
return theIndividualFormats.value(data.iname, -1);
|
||||||
|
|
||||||
case LocalsRawValueRole:
|
case LocalsRawValueRole:
|
||||||
return data.value;
|
return data.value;
|
||||||
@@ -911,9 +912,9 @@ bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||||||
case LocalsIndividualFormatRole: {
|
case LocalsIndividualFormatRole: {
|
||||||
const int format = value.toInt();
|
const int format = value.toInt();
|
||||||
if (format == -1) {
|
if (format == -1) {
|
||||||
m_handler->m_individualFormats.remove(data.iname);
|
theIndividualFormats.remove(data.iname);
|
||||||
} else {
|
} else {
|
||||||
m_handler->m_individualFormats[data.iname] = format;
|
theIndividualFormats[data.iname] = format;
|
||||||
}
|
}
|
||||||
engine()->updateWatchData(data);
|
engine()->updateWatchData(data);
|
||||||
break;
|
break;
|
||||||
@@ -1249,9 +1250,9 @@ QDebug operator<<(QDebug d, const WatchModel &m)
|
|||||||
|
|
||||||
void WatchModel::formatRequests(QByteArray *out, const WatchItem *item) const
|
void WatchModel::formatRequests(QByteArray *out, const WatchItem *item) const
|
||||||
{
|
{
|
||||||
int format = m_handler->m_individualFormats.value(item->iname, -1);
|
int format = theIndividualFormats.value(item->iname, -1);
|
||||||
if (format == -1)
|
if (format == -1)
|
||||||
format = m_handler->m_typeFormats.value(stripForFormat(item->type), -1);
|
format = theTypeFormats.value(stripForFormat(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)
|
||||||
@@ -1311,7 +1312,7 @@ void WatchHandler::endCycle()
|
|||||||
void WatchHandler::cleanup()
|
void WatchHandler::cleanup()
|
||||||
{
|
{
|
||||||
m_expandedINames.clear();
|
m_expandedINames.clear();
|
||||||
m_watcherNames.remove(QByteArray());
|
theWatcherNames.remove(QByteArray());
|
||||||
m_return->reinitialize();
|
m_return->reinitialize();
|
||||||
m_locals->reinitialize();
|
m_locals->reinitialize();
|
||||||
m_tooltips->reinitialize();
|
m_tooltips->reinitialize();
|
||||||
@@ -1429,21 +1430,21 @@ void WatchHandler::removeData(const QByteArray &iname)
|
|||||||
|
|
||||||
QByteArray WatchHandler::watcherName(const QByteArray &exp)
|
QByteArray WatchHandler::watcherName(const QByteArray &exp)
|
||||||
{
|
{
|
||||||
return "watch." + QByteArray::number(m_watcherNames[exp]);
|
return "watch." + QByteArray::number(theWatcherNames[exp]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchHandler::watchExpression(const QString &exp)
|
void WatchHandler::watchExpression(const QString &exp)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_engine, return);
|
QTC_ASSERT(m_engine, return);
|
||||||
// Do not insert the same entry more then once.
|
// Do not insert the same entry more then once.
|
||||||
if (m_watcherNames.value(exp.toLatin1()))
|
if (theWatcherNames.value(exp.toLatin1()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: 'exp' can contain illegal characters
|
// FIXME: 'exp' can contain illegal characters
|
||||||
WatchData data;
|
WatchData data;
|
||||||
data.exp = exp.toLatin1();
|
data.exp = exp.toLatin1();
|
||||||
data.name = exp;
|
data.name = exp;
|
||||||
m_watcherNames[data.exp] = m_watcherCounter++;
|
theWatcherNames[data.exp] = m_watcherCounter++;
|
||||||
saveWatchers();
|
saveWatchers();
|
||||||
|
|
||||||
if (exp.isEmpty())
|
if (exp.isEmpty())
|
||||||
@@ -1560,12 +1561,12 @@ void WatchHandler::showEditValue(const WatchData &data)
|
|||||||
|
|
||||||
void WatchHandler::clearWatches()
|
void WatchHandler::clearWatches()
|
||||||
{
|
{
|
||||||
if (m_watcherNames.isEmpty())
|
if (theWatcherNames.isEmpty())
|
||||||
return;
|
return;
|
||||||
const QList<WatchItem *> watches = m_watchers->rootItem()->children;
|
const QList<WatchItem *> watches = m_watchers->rootItem()->children;
|
||||||
for (int i = watches.size() - 1; i >= 0; i--)
|
for (int i = watches.size() - 1; i >= 0; i--)
|
||||||
m_watchers->destroyItem(watches.at(i));
|
m_watchers->destroyItem(watches.at(i));
|
||||||
m_watcherNames.clear();
|
theWatcherNames.clear();
|
||||||
m_watcherCounter = 0;
|
m_watcherCounter = 0;
|
||||||
updateWatchersWindow();
|
updateWatchersWindow();
|
||||||
emitAllChanged();
|
emitAllChanged();
|
||||||
@@ -1576,7 +1577,7 @@ void WatchHandler::removeWatchExpression(const QString &exp0)
|
|||||||
{
|
{
|
||||||
QByteArray exp = exp0.toLatin1();
|
QByteArray exp = exp0.toLatin1();
|
||||||
MODEL_DEBUG("REMOVE WATCH: " << exp);
|
MODEL_DEBUG("REMOVE WATCH: " << exp);
|
||||||
m_watcherNames.remove(exp);
|
theWatcherNames.remove(exp);
|
||||||
foreach (WatchItem *item, m_watchers->rootItem()->children) {
|
foreach (WatchItem *item, m_watchers->rootItem()->children) {
|
||||||
if (item->exp == exp) {
|
if (item->exp == exp) {
|
||||||
m_watchers->destroyItem(item);
|
m_watchers->destroyItem(item);
|
||||||
@@ -1598,7 +1599,7 @@ QStringList WatchHandler::watchedExpressions()
|
|||||||
{
|
{
|
||||||
// Filter out invalid watchers.
|
// Filter out invalid watchers.
|
||||||
QStringList watcherNames;
|
QStringList watcherNames;
|
||||||
QHashIterator<QByteArray, int> it(m_watcherNames);
|
QHashIterator<QByteArray, int> it(theWatcherNames);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
const QByteArray &watcherName = it.key();
|
const QByteArray &watcherName = it.key();
|
||||||
@@ -1621,14 +1622,14 @@ void WatchHandler::loadTypeFormats()
|
|||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
if (!it.key().isEmpty())
|
if (!it.key().isEmpty())
|
||||||
m_typeFormats.insert(it.key().toUtf8(), it.value().toInt());
|
theTypeFormats.insert(it.key().toUtf8(), it.value().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchHandler::saveTypeFormats()
|
void WatchHandler::saveTypeFormats()
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant> typeFormats;
|
QMap<QString, QVariant> typeFormats;
|
||||||
QHashIterator<QByteArray, int> it(m_typeFormats);
|
QHashIterator<QByteArray, int> it(theTypeFormats);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
const int format = it.value();
|
const int format = it.value();
|
||||||
@@ -1651,7 +1652,7 @@ void WatchHandler::saveSessionData()
|
|||||||
void WatchHandler::loadSessionData()
|
void WatchHandler::loadSessionData()
|
||||||
{
|
{
|
||||||
loadTypeFormats();
|
loadTypeFormats();
|
||||||
m_watcherNames.clear();
|
theWatcherNames.clear();
|
||||||
m_watcherCounter = 0;
|
m_watcherCounter = 0;
|
||||||
QVariant value = debuggerCore()->sessionValue(QLatin1String("Watchers"));
|
QVariant value = debuggerCore()->sessionValue(QLatin1String("Watchers"));
|
||||||
foreach (WatchItem *item, m_watchers->rootItem()->children)
|
foreach (WatchItem *item, m_watchers->rootItem()->children)
|
||||||
@@ -1667,7 +1668,7 @@ void WatchHandler::updateWatchers()
|
|||||||
foreach (WatchItem *item, m_watchers->rootItem()->children)
|
foreach (WatchItem *item, m_watchers->rootItem()->children)
|
||||||
m_watchers->destroyItem(item);
|
m_watchers->destroyItem(item);
|
||||||
// Copy over all watchers and mark all watchers as incomplete.
|
// Copy over all watchers and mark all watchers as incomplete.
|
||||||
foreach (const QByteArray &exp, m_watcherNames.keys()) {
|
foreach (const QByteArray &exp, theWatcherNames.keys()) {
|
||||||
WatchData data;
|
WatchData data;
|
||||||
data.iname = watcherName(exp);
|
data.iname = watcherName(exp);
|
||||||
data.setAllNeeded();
|
data.setAllNeeded();
|
||||||
@@ -1737,9 +1738,9 @@ void WatchHandler::setFormat(const QByteArray &type0, int format)
|
|||||||
{
|
{
|
||||||
const QByteArray type = stripForFormat(type0);
|
const QByteArray type = stripForFormat(type0);
|
||||||
if (format == -1)
|
if (format == -1)
|
||||||
m_typeFormats.remove(type);
|
theTypeFormats.remove(type);
|
||||||
else
|
else
|
||||||
m_typeFormats[type] = format;
|
theTypeFormats[type] = format;
|
||||||
saveTypeFormats();
|
saveTypeFormats();
|
||||||
m_return->emitDataChanged(1);
|
m_return->emitDataChanged(1);
|
||||||
m_locals->emitDataChanged(1);
|
m_locals->emitDataChanged(1);
|
||||||
@@ -1751,9 +1752,9 @@ int WatchHandler::format(const QByteArray &iname) const
|
|||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
if (const WatchData *item = findItem(iname)) {
|
if (const WatchData *item = findItem(iname)) {
|
||||||
int result = m_individualFormats.value(item->iname, -1);
|
int result = theIndividualFormats.value(item->iname, -1);
|
||||||
if (result == -1)
|
if (result == -1)
|
||||||
result = m_typeFormats.value(stripForFormat(item->type), -1);
|
result = theTypeFormats.value(stripForFormat(item->type), -1);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1778,8 +1779,8 @@ QByteArray WatchHandler::expansionRequests() const
|
|||||||
QByteArray WatchHandler::typeFormatRequests() const
|
QByteArray WatchHandler::typeFormatRequests() const
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
if (!m_typeFormats.isEmpty()) {
|
if (!theTypeFormats.isEmpty()) {
|
||||||
QHashIterator<QByteArray, int> it(m_typeFormats);
|
QHashIterator<QByteArray, int> it(theTypeFormats);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
ba.append(it.key().toHex());
|
ba.append(it.key().toHex());
|
||||||
@@ -1795,8 +1796,8 @@ QByteArray WatchHandler::typeFormatRequests() const
|
|||||||
QByteArray WatchHandler::individualFormatRequests() const
|
QByteArray WatchHandler::individualFormatRequests() const
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
if (!m_individualFormats.isEmpty()) {
|
if (!theIndividualFormats.isEmpty()) {
|
||||||
QHashIterator<QByteArray, int> it(m_individualFormats);
|
QHashIterator<QByteArray, int> it(theIndividualFormats);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
ba.append(it.key());
|
ba.append(it.key());
|
||||||
@@ -1911,5 +1912,10 @@ bool WatchHandler::isValidToolTip(const QByteArray &iname) const
|
|||||||
return item && !item->type.trimmed().isEmpty();
|
return item && !item->type.trimmed().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHash<QByteArray, int> WatchHandler::watcherNames()
|
||||||
|
{
|
||||||
|
return theWatcherNames;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
@@ -179,8 +179,7 @@ public:
|
|||||||
QSet<QByteArray> expandedINames() const
|
QSet<QByteArray> expandedINames() const
|
||||||
{ return m_expandedINames; }
|
{ return m_expandedINames; }
|
||||||
static QStringList watchedExpressions();
|
static QStringList watchedExpressions();
|
||||||
static QHash<QByteArray, int> watcherNames()
|
static QHash<QByteArray, int> watcherNames();
|
||||||
{ return m_watcherNames; }
|
|
||||||
|
|
||||||
QByteArray expansionRequests() const;
|
QByteArray expansionRequests() const;
|
||||||
QByteArray typeFormatRequests() const;
|
QByteArray typeFormatRequests() const;
|
||||||
@@ -222,9 +221,6 @@ private:
|
|||||||
typedef QMap<QByteArray, QPointer<QObject> > EditHandlers;
|
typedef QMap<QByteArray, QPointer<QObject> > EditHandlers;
|
||||||
EditHandlers m_editHandlers;
|
EditHandlers m_editHandlers;
|
||||||
|
|
||||||
static QHash<QByteArray, int> m_watcherNames;
|
|
||||||
static QHash<QByteArray, int> m_typeFormats;
|
|
||||||
QHash<QByteArray, int> m_individualFormats; // Indexed by iname.
|
|
||||||
TypeFormats m_reportedTypeFormats;
|
TypeFormats m_reportedTypeFormats;
|
||||||
|
|
||||||
// Items expanded in the Locals & Watchers view.
|
// Items expanded in the Locals & Watchers view.
|
||||||
|
Reference in New Issue
Block a user