forked from qt-creator/qt-creator
clean up WatchData
Reviewed-by: hjk
This commit is contained in:
@@ -3613,7 +3613,6 @@ WatchData GdbEngine::localVariable(const GdbMi &item,
|
||||
data.iname = "local." + name;
|
||||
data.name = nam;
|
||||
data.exp = name;
|
||||
data.framekey = m_currentFrame + data.name;
|
||||
setWatchDataType(data, item.findChild("type"));
|
||||
if (uninitializedVariables.contains(data.name)) {
|
||||
data.setError(WatchData::msgNotInScope());
|
||||
|
||||
@@ -90,7 +90,7 @@ QDataStream& operator>>(QDataStream& s, WatchData &data)
|
||||
QString value;
|
||||
QString type;
|
||||
bool hasChildren;
|
||||
s >> data.exp >> data.name >> value >> type >> hasChildren >> data.objectId;
|
||||
s >> data.exp >> data.name >> value >> type >> hasChildren >> data.id;
|
||||
data.setType(type.toUtf8(), false);
|
||||
data.setValue(value);
|
||||
data.setHasChildren(hasChildren);
|
||||
@@ -535,7 +535,7 @@ void QmlEngine::updateWatchData(const Internal::WatchData &data, const Internal:
|
||||
|
||||
if (!data.name.isEmpty() && data.isChildrenNeeded()
|
||||
&& watchHandler()->isExpandedIName(data.iname))
|
||||
expandObject(data.iname, data.objectId);
|
||||
expandObject(data.iname, data.id);
|
||||
|
||||
{
|
||||
QByteArray reply;
|
||||
@@ -630,7 +630,7 @@ void QmlEngine::messageReceived(const QByteArray &message)
|
||||
|
||||
if (watchHandler()->expandedINames().contains(data.iname)) {
|
||||
needPing = true;
|
||||
expandObject(data.iname, data.objectId);
|
||||
expandObject(data.iname, data.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,7 +640,7 @@ void QmlEngine::messageReceived(const QByteArray &message)
|
||||
|
||||
if (watchHandler()->expandedINames().contains(data.iname)) {
|
||||
needPing = true;
|
||||
expandObject(data.iname, data.objectId);
|
||||
expandObject(data.iname, data.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -710,7 +710,7 @@ void QmlEngine::messageReceived(const QByteArray &message)
|
||||
|
||||
if (watchHandler()->expandedINames().contains(data.iname)) {
|
||||
needPing = true;
|
||||
expandObject(data.iname, data.objectId);
|
||||
expandObject(data.iname, data.id);
|
||||
}
|
||||
}
|
||||
if (needPing)
|
||||
@@ -726,7 +726,7 @@ void QmlEngine::messageReceived(const QByteArray &message)
|
||||
watchHandler()->insertData(data);
|
||||
if (watchHandler()->expandedINames().contains(data.iname)) {
|
||||
needPing = true;
|
||||
expandObject(data.iname, data.objectId);
|
||||
expandObject(data.iname, data.id);
|
||||
}
|
||||
}
|
||||
if (needPing)
|
||||
|
||||
@@ -702,9 +702,11 @@ void ScriptEngine::updateLocals()
|
||||
m_scriptEngine->setAgent(0);
|
||||
|
||||
WatchData data;
|
||||
data.id = m_watchIdCounter++;
|
||||
m_watchIdToScriptValue.insert(data.id, context->activationObject());
|
||||
data.iname = "local";
|
||||
data.name = _(data.iname);
|
||||
data.scriptValue = context->activationObject();
|
||||
|
||||
watchHandler()->beginCycle();
|
||||
updateSubItem(data);
|
||||
watchHandler()->endCycle();
|
||||
@@ -744,8 +746,8 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
|
||||
//SDEBUG("\nUPDATE SUBITEM: " << data.toString() << data.scriptValue.toString());
|
||||
QTC_ASSERT(data.isValid(), return);
|
||||
|
||||
const QScriptValue &ob = m_watchIdToScriptValue.value(data.id);
|
||||
if (data.isTypeNeeded() || data.isValueNeeded()) {
|
||||
const QScriptValue &ob = data.scriptValue;
|
||||
if (ob.isArray()) {
|
||||
data.setType("Array", false);
|
||||
data.setValue(QString(QLatin1Char(' ')));
|
||||
@@ -802,14 +804,15 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
|
||||
}
|
||||
|
||||
if (data.isChildrenNeeded()) {
|
||||
QScriptValueIterator it(data.scriptValue);
|
||||
QScriptValueIterator it(ob);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
WatchData data1;
|
||||
data1.iname = data.iname + '.' + it.name().toLatin1();
|
||||
data1.exp = it.name().toLatin1();
|
||||
data1.name = it.name();
|
||||
data1.scriptValue = it.value();
|
||||
data.id = m_watchIdCounter++;
|
||||
m_watchIdToScriptValue.insert(data.id, it.value());
|
||||
if (watchHandler()->isExpandedIName(data1.iname)) {
|
||||
data1.setChildrenNeeded();
|
||||
} else {
|
||||
@@ -822,7 +825,7 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
|
||||
}
|
||||
|
||||
if (data.isHasChildrenNeeded()) {
|
||||
QScriptValueIterator it(data.scriptValue);
|
||||
QScriptValueIterator it(ob);
|
||||
data.setHasChildren(it.hasNext());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QtCore/QHash>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QScriptEngine;
|
||||
@@ -114,6 +115,8 @@ private:
|
||||
QString m_scriptContents;
|
||||
QString m_scriptFileName;
|
||||
QScopedPointer<ScriptAgent> m_scriptAgent;
|
||||
QHash<quint64,QScriptValue> m_watchIdToScriptValue;
|
||||
quint64 m_watchIdCounter;
|
||||
|
||||
bool m_stopped;
|
||||
bool m_stopOnNextLine;
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
|
||||
#include "watchdata.h"
|
||||
#include "watchutils.h"
|
||||
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QTextDocument> // Qt::escape
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -17,19 +15,107 @@
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
enum GuessChildrenResult { HasChildren, HasNoChildren, HasPossiblyChildren };
|
||||
static QString qt_escape(const QString& plain)
|
||||
{
|
||||
QString rich;
|
||||
rich.reserve(int(plain.length() * 1.1));
|
||||
for (int i = 0; i < plain.length(); ++i) {
|
||||
if (plain.at(i) == QLatin1Char('<'))
|
||||
rich += QLatin1String("<");
|
||||
else if (plain.at(i) == QLatin1Char('>'))
|
||||
rich += QLatin1String(">");
|
||||
else if (plain.at(i) == QLatin1Char('&'))
|
||||
rich += QLatin1String("&");
|
||||
else if (plain.at(i) == QLatin1Char('"'))
|
||||
rich += QLatin1String(""");
|
||||
else
|
||||
rich += plain.at(i);
|
||||
}
|
||||
return rich;
|
||||
}
|
||||
|
||||
bool isPointerType(const QByteArray &type)
|
||||
{
|
||||
return type.endsWith('*') || type.endsWith("* const");
|
||||
}
|
||||
|
||||
bool isCharPointerType(const QByteArray &type)
|
||||
{
|
||||
return type == "char *" || type == "const char *" || type == "char const *";
|
||||
}
|
||||
|
||||
bool isIntType(const QByteArray &type)
|
||||
{
|
||||
if (type.isEmpty())
|
||||
return false;
|
||||
switch (type.at(0)) {
|
||||
case 'b':
|
||||
return type == "bool";
|
||||
case 'c':
|
||||
return type == "char";
|
||||
case 'i':
|
||||
return type == "int" || type == "int64";
|
||||
case 'l':
|
||||
return type == "long"
|
||||
|| type == "long long";
|
||||
case 'p':
|
||||
return type == "ptrdiff_t";
|
||||
case 'q':
|
||||
return type == "qint16" || type == "quint16"
|
||||
|| type == "qint32" || type == "quint32"
|
||||
|| type == "qint64" || type == "quint64";
|
||||
case 's':
|
||||
return type == "short"
|
||||
|| type == "signed"
|
||||
|| type == "size_t"
|
||||
|| type == "std::size_t"
|
||||
|| type == "std::ptrdiff_t"
|
||||
|| type.startsWith("signed ");
|
||||
case 'u':
|
||||
return type == "unsigned"
|
||||
|| type.startsWith("unsigned ");
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isFloatType(const QByteArray &type)
|
||||
{
|
||||
return type == "float" || type == "double" || type == "qreal";
|
||||
}
|
||||
|
||||
bool isIntOrFloatType(const QByteArray &type)
|
||||
{
|
||||
return isIntType(type) || isFloatType(type);
|
||||
}
|
||||
|
||||
GuessChildrenResult guessChildren(const QByteArray &type)
|
||||
{
|
||||
if (isIntOrFloatType(type))
|
||||
return HasNoChildren;
|
||||
if (isCharPointerType(type))
|
||||
return HasNoChildren;
|
||||
if (isPointerType(type))
|
||||
return HasChildren;
|
||||
if (type.endsWith("QString"))
|
||||
return HasNoChildren;
|
||||
return HasPossiblyChildren;
|
||||
}
|
||||
|
||||
WatchData::WatchData() :
|
||||
id(0),
|
||||
state(InitialState),
|
||||
editformat(0),
|
||||
address(0),
|
||||
hasChildren(false),
|
||||
generation(-1),
|
||||
hasChildren(false),
|
||||
valueEnabled(true),
|
||||
valueEditable(true),
|
||||
error(false),
|
||||
source(0),
|
||||
objectId(0),
|
||||
state(InitialState),
|
||||
changed(false),
|
||||
sortId(0)
|
||||
sortId(0),
|
||||
source(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,7 +131,6 @@ bool WatchData::isEqual(const WatchData &other) const
|
||||
&& displayedType == other.displayedType
|
||||
&& variable == other.variable
|
||||
&& address == other.address
|
||||
&& framekey == other.framekey
|
||||
&& hasChildren == other.hasChildren
|
||||
&& valueEnabled == other.valueEnabled
|
||||
&& valueEditable == other.valueEditable
|
||||
@@ -213,8 +298,6 @@ QString WatchData::toString() const
|
||||
|
||||
if (isChildrenNeeded())
|
||||
str << "children=<needed>,";
|
||||
if (source)
|
||||
str << "source=" << source;
|
||||
str.flush();
|
||||
if (res.endsWith(QLatin1Char(',')))
|
||||
res.truncate(res.size() - 1);
|
||||
@@ -226,7 +309,7 @@ static void formatToolTipRow(QTextStream &str,
|
||||
const QString &category, const QString &value)
|
||||
{
|
||||
str << "<tr><td>" << category << "</td><td> : </td><td>"
|
||||
<< Qt::escape(value) << "</td></tr>";
|
||||
<< qt_escape(value) << "</td></tr>";
|
||||
}
|
||||
|
||||
static QString typeToolTip(const WatchData &wd)
|
||||
@@ -247,19 +330,19 @@ QString WatchData::toToolTip() const
|
||||
QString res;
|
||||
QTextStream str(&res);
|
||||
str << "<html><body><table>";
|
||||
formatToolTipRow(str, QCoreApplication::translate("Debugger::Internal::WatchHandler", "Name"), name);
|
||||
formatToolTipRow(str, QCoreApplication::translate("Debugger::Internal::WatchHandler", "Expression"), exp);
|
||||
formatToolTipRow(str, QCoreApplication::translate("Debugger::Internal::WatchHandler", "Type"), typeToolTip(*this));
|
||||
formatToolTipRow(str, tr("Name"), name);
|
||||
formatToolTipRow(str, tr("Expression"), exp);
|
||||
formatToolTipRow(str, tr("Type"), typeToolTip(*this));
|
||||
QString val = value;
|
||||
if (value.size() > 1000) {
|
||||
val.truncate(1000);
|
||||
val += QCoreApplication::translate("Debugger::Internal::WatchHandler", " ... <cut off>");
|
||||
val += tr(" ... <cut off>");
|
||||
}
|
||||
formatToolTipRow(str, QCoreApplication::translate("Debugger::Internal::WatchHandler", "Value"), val);
|
||||
formatToolTipRow(str, QCoreApplication::translate("Debugger::Internal::WatchHandler", "Object Address"),
|
||||
formatToolTipRow(str, tr("Value"), val);
|
||||
formatToolTipRow(str, tr("Object Address"),
|
||||
QString::fromAscii(hexAddress()));
|
||||
formatToolTipRow(str, QCoreApplication::translate("Debugger::Internal::WatchHandler", "Internal ID"), iname);
|
||||
formatToolTipRow(str, QCoreApplication::translate("Debugger::Internal::WatchHandler", "Generation"),
|
||||
formatToolTipRow(str, tr("Internal ID"), iname);
|
||||
formatToolTipRow(str, tr("Generation"),
|
||||
QString::number(generation));
|
||||
str << "</table></body></html>";
|
||||
return res;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QtCore/QtGlobal>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtScript/QScriptValue>
|
||||
|
||||
namespace Debugger {
|
||||
@@ -62,13 +63,6 @@ public:
|
||||
| HasChildrenNeeded
|
||||
};
|
||||
|
||||
void setValue(const QString &);
|
||||
void setType(const QByteArray &, bool guessChildrenFromType = true);
|
||||
void setValueToolTip(const QString &);
|
||||
void setError(const QString &);
|
||||
void setAddress(const quint64 &);
|
||||
void setHexAddress(const QByteArray &a);
|
||||
|
||||
bool isSomethingNeeded() const { return state & NeededMask; }
|
||||
void setAllNeeded() { state = NeededMask; }
|
||||
void setAllUnneeded() { state = State(0); }
|
||||
@@ -95,48 +89,58 @@ public:
|
||||
void setHasChildren(bool c) { hasChildren = c; setHasChildrenUnneeded();
|
||||
if (!c) setChildrenUnneeded(); }
|
||||
|
||||
QString toString() const;
|
||||
QString toToolTip() const;
|
||||
bool isLocal() const { return iname.startsWith("local."); }
|
||||
bool isWatcher() const { return iname.startsWith("watch."); }
|
||||
bool isValid() const { return !iname.isEmpty(); }
|
||||
|
||||
bool isEqual(const WatchData &other) const;
|
||||
quint64 coreAddress() const;
|
||||
QByteArray hexAddress() const;
|
||||
|
||||
void setError(const QString &);
|
||||
void setValue(const QString &);
|
||||
void setValueToolTip(const QString &);
|
||||
void setType(const QByteArray &, bool guessChildrenFromType = true);
|
||||
void setAddress(const quint64 &);
|
||||
void setHexAddress(const QByteArray &a);
|
||||
|
||||
QString toString() const;
|
||||
QString toToolTip() const;
|
||||
|
||||
static QString msgNotInScope();
|
||||
static QString shadowedName(const QString &name, int seen);
|
||||
static const QString &shadowedNameFormat();
|
||||
|
||||
quint64 coreAddress() const;
|
||||
QByteArray hexAddress() const;
|
||||
|
||||
public:
|
||||
quint64 id; // Token for the engine for internal mapping
|
||||
qint32 state; // 'needed' flags;
|
||||
QByteArray iname; // Internal name sth like 'local.baz.public.a'
|
||||
QByteArray exp; // The expression
|
||||
QString name; // Displayed name
|
||||
QString value; // Displayed value
|
||||
QByteArray editvalue; // Displayed value
|
||||
int editformat; // Format of displayed value
|
||||
qint32 editformat; // Format of displayed value
|
||||
QString valuetooltip; // Tooltip in value column
|
||||
QString typeFormats; // Selection of formats of displayed value
|
||||
QByteArray type; // Type for further processing
|
||||
QString displayedType;// Displayed type (optional)
|
||||
QByteArray variable; // Name of internal Gdb variable if created
|
||||
quint64 address; // Displayed address
|
||||
QString framekey; // Key for type cache
|
||||
QScriptValue scriptValue; // If needed...
|
||||
qint32 generation; // When updated?
|
||||
bool hasChildren;
|
||||
int generation; // When updated?
|
||||
bool valueEnabled; // Value will be greyed out or not
|
||||
bool valueEditable; // Value will be editable
|
||||
bool error;
|
||||
bool changed;
|
||||
qint32 sortId;
|
||||
QByteArray dumperFlags;
|
||||
|
||||
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::WatchHandler)
|
||||
|
||||
public:
|
||||
int source; // Originated from dumper or symbol evaluation? (CDB only)
|
||||
quint64 objectId; // Object id used for the QMLEngine
|
||||
int state;
|
||||
bool changed;
|
||||
int sortId;
|
||||
// FIXME: this is engine specific data that should be mapped internally
|
||||
QByteArray variable; // Name of internal Gdb variable if created
|
||||
qint32 source; // Originated from dumper or symbol evaluation? (CDB only)
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -273,16 +273,6 @@ bool isKeyWord(const QString &exp)
|
||||
|| exp == QLatin1String("while");
|
||||
}
|
||||
|
||||
bool isPointerType(const QByteArray &type)
|
||||
{
|
||||
return type.endsWith('*') || type.endsWith("* const");
|
||||
}
|
||||
|
||||
bool isCharPointerType(const QByteArray &type)
|
||||
{
|
||||
return type == "char *" || type == "const char *" || type == "char const *";
|
||||
}
|
||||
|
||||
bool startsWithDigit(const QString &str)
|
||||
{
|
||||
return !str.isEmpty() && str.at(0).isDigit();
|
||||
@@ -540,69 +530,11 @@ QString extractTypeFromPTypeOutput(const QString &str)
|
||||
return res.simplified();
|
||||
}
|
||||
|
||||
bool isIntType(const QByteArray &type)
|
||||
{
|
||||
if (type.isEmpty())
|
||||
return false;
|
||||
switch (type.at(0)) {
|
||||
case 'b':
|
||||
return type == "bool";
|
||||
case 'c':
|
||||
return type == "char";
|
||||
case 'i':
|
||||
return type == "int" || type == "int64";
|
||||
case 'l':
|
||||
return type == "long"
|
||||
|| type == "long long";
|
||||
case 'p':
|
||||
return type == "ptrdiff_t";
|
||||
case 'q':
|
||||
return type == "qint16" || type == "quint16"
|
||||
|| type == "qint32" || type == "quint32"
|
||||
|| type == "qint64" || type == "quint64";
|
||||
case 's':
|
||||
return type == "short"
|
||||
|| type == "signed"
|
||||
|| type == "size_t"
|
||||
|| type == "std::size_t"
|
||||
|| type == "std::ptrdiff_t"
|
||||
|| type.startsWith("signed ");
|
||||
case 'u':
|
||||
return type == "unsigned"
|
||||
|| type.startsWith("unsigned ");
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isSymbianIntType(const QByteArray &type)
|
||||
{
|
||||
return type == "TInt" || type == "TBool";
|
||||
}
|
||||
|
||||
bool isFloatType(const QByteArray &type)
|
||||
{
|
||||
return type == "float" || type == "double" || type == "qreal";
|
||||
}
|
||||
|
||||
bool isIntOrFloatType(const QByteArray &type)
|
||||
{
|
||||
return isIntType(type) || isFloatType(type);
|
||||
}
|
||||
|
||||
GuessChildrenResult guessChildren(const QByteArray &type)
|
||||
{
|
||||
if (isIntOrFloatType(type))
|
||||
return HasNoChildren;
|
||||
if (isCharPointerType(type))
|
||||
return HasNoChildren;
|
||||
if (isPointerType(type))
|
||||
return HasChildren;
|
||||
if (type.endsWith("QString"))
|
||||
return HasNoChildren;
|
||||
return HasPossiblyChildren;
|
||||
}
|
||||
|
||||
QByteArray sizeofTypeExpression(const QByteArray &type, QtDumperHelper::Debugger debugger)
|
||||
{
|
||||
if (type.endsWith('*'))
|
||||
|
||||
Reference in New Issue
Block a user