Commit 40052046 authored by hjk's avatar hjk

Debugger: Rework display length limitation systems

There are two values now, one to limit an entry in the L&E view
(default 100) and a hard upper limit (at 1 mio).

If displayed values are elided, the true length is shown in addition.

Change-Id: I180b70446c18e258c164e5af75b88d4c8b6c53f2
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 382730b1
This diff is collapsed.
......@@ -367,11 +367,8 @@ class Dumper(DumperBase):
self.currentChildNumChild = -1
self.currentMaxNumChild = -1
self.currentNumChild = -1
self.currentValue = None
self.currentValuePriority = -100
self.currentValueEncoding = None
self.currentType = None
self.currentTypePriority = -100
self.currentValue = ReportItem()
self.currentType = ReportItem()
self.currentAddress = None
self.typeformats = {}
self.formats = {}
......@@ -402,6 +399,8 @@ class Dumper(DumperBase):
self.expandedINames = set(arg[pos:].split(","))
elif arg.startswith("stringcutoff:"):
self.stringCutOff = int(arg[pos:])
elif arg.startswith("displaystringlimit:"):
self.displayStringLimit = int(arg[pos:])
elif arg.startswith("typeformats:"):
for f in arg[pos:].split(","):
pos = f.find("=")
......@@ -525,39 +524,39 @@ class Dumper(DumperBase):
self.put('name="%s",' % item.name)
item.savedIName = self.currentIName
item.savedValue = self.currentValue
item.savedValuePriority = self.currentValuePriority
item.savedValueEncoding = self.currentValueEncoding
item.savedType = self.currentType
item.savedTypePriority = self.currentTypePriority
item.savedCurrentAddress = self.currentAddress
self.currentIName = item.iname
self.currentValuePriority = -100
self.currentValueEncoding = None
self.currentType = ""
self.currentTypePriority = -100
self.currentValue = ReportItem();
self.currentType = ReportItem();
self.currentAddress = None
def exitSubItem(self, item, exType, exValue, exTraceBack):
#warn(" CURRENT VALUE: %s %s %s" % (self.currentValue,
# self.currentValueEncoding, self.currentValuePriority))
#warn("CURRENT VALUE: %s: %s %s %s %s" % (
# self.currentIName,
# self.currentValue.value,
# self.currentValue.elided,
# self.currentValue.encoding,
# self.currentValue.priority))
if not exType is None:
if self.passExceptions:
showException("SUBITEM", exType, exValue, exTraceBack)
self.putNumChild(0)
self.putValue("<not accessible>")
try:
#warn("TYPE VALUE: %s" % self.currentValue)
typeName = stripClassTag(self.currentType)
#warn("TYPE: '%s' DEFAULT: '%s' % (typeName, self.currentChildType))
#warn("CURRENT TYPE: %s" % self.currentType.value)
typeName = stripClassTag(self.currentType.value)
if len(typeName) > 0 and typeName != self.currentChildType:
self.put('type="%s",' % typeName) # str(type.unqualified()) ?
if self.currentValue is None:
if self.currentValue.value is None:
self.put('value="<not accessible>",numchild="0",')
else:
if not self.currentValueEncoding is None:
self.put('valueencoded="%d",' % self.currentValueEncoding)
self.put('value="%s",' % self.currentValue)
if not self.currentValue.encoding is None:
self.put('valueencoded="%d",' % self.currentValue.encoding)
if self.currentValue.elided:
self.put('valueelided="%d",' % self.currentValue.elided)
self.put('value="%s",' % self.currentValue.value)
except:
pass
if not self.currentAddress is None:
......@@ -565,10 +564,7 @@ class Dumper(DumperBase):
self.put('},')
self.currentIName = item.savedIName
self.currentValue = item.savedValue
self.currentValuePriority = item.savedValuePriority
self.currentValueEncoding = item.savedValueEncoding
self.currentType = item.savedType
self.currentTypePriority = item.savedTypePriority
self.currentAddress = item.savedCurrentAddress
return True
......@@ -888,10 +884,6 @@ class Dumper(DumperBase):
self.isQt3Support = lambda: self.cachedIsQt3Suport
return self.cachedIsQt3Suport
def putBetterType(self, type):
self.currentType = str(type)
self.currentTypePriority = self.currentTypePriority + 1
def putAddress(self, addr):
if self.currentPrintsAddress:
try:
......
......@@ -261,11 +261,8 @@ class Dumper(DumperBase):
self.typeformats = {}
self.currentIName = None
self.currentValuePriority = -100
self.currentValueEncoding = None
self.currentType = ""
self.currentTypePriority = -100
self.currentValue = None
self.currentValue = ReportItem()
self.currentType = ReportItem()
self.currentNumChild = None
self.currentMaxNumChild = None
self.currentPrintsAddress = None
......@@ -310,15 +307,10 @@ class Dumper(DumperBase):
self.put('name="%s",' % item.name)
item.savedIName = self.currentIName
item.savedValue = self.currentValue
item.savedValuePriority = self.currentValuePriority
item.savedValueEncoding = self.currentValueEncoding
item.savedType = self.currentType
item.savedTypePriority = self.currentTypePriority
self.currentIName = item.iname
self.currentValuePriority = -100
self.currentValueEncoding = None
self.currentType = ""
self.currentTypePriority = -100
self.currentValue = ReportItem()
self.currentType = ReportItem()
def exitSubItem(self, item, exType, exValue, exTraceBack):
if not exType is None:
......@@ -327,24 +319,23 @@ class Dumper(DumperBase):
self.putNumChild(0)
self.putValue("<not accessible>")
try:
typeName = self.currentType
typeName = self.currentType.value
if len(typeName) > 0 and typeName != self.currentChildType:
self.put('type="%s",' % typeName) # str(type.unqualified()) ?
if self.currentValue is None:
if self.currentValue.value is None:
self.put('value="<not accessible>",numchild="0",')
else:
if not self.currentValueEncoding is None:
self.put('valueencoded="%s",' % self.currentValueEncoding)
self.put('value="%s",' % self.currentValue)
if not self.currentValue.encoding is None:
self.put('valueencoded="%s",' % self.currentValue.encoding)
if self.currentValue.elided:
self.put('valueelided="%s",' % self.currentValue.elided)
self.put('value="%s",' % self.currentValue.value)
except:
pass
self.put('},')
self.currentIName = item.savedIName
self.currentValue = item.savedValue
self.currentValuePriority = item.savedValuePriority
self.currentValueEncoding = item.savedValueEncoding
self.currentType = item.savedType
self.currentTypePriority = item.savedTypePriority
return True
def isSimpleType(self, typeobj):
......@@ -856,14 +847,6 @@ class Dumper(DumperBase):
def reportStackTop(self):
self.report('stack-top={}')
def putBetterType(self, type):
try:
self.currentType = type.GetName()
except:
self.currentType = str(type)
self.currentTypePriority = self.currentTypePriority + 1
#warn("BETTER TYPE: %s PRIORITY: %s" % (type, self.currentTypePriority))
def extractBlob(self, base, size):
if size == 0:
return Blob("")
......
......@@ -274,7 +274,7 @@ def qdump__QDateTime(d, value):
tz = ""
else:
idBase = tzp + 2 * d.ptrSize() # [QSharedData] + [vptr]
tz = d.encodeByteArrayHelper(d.extractPointer(idBase))
tz = d.encodeByteArrayHelper(d.extractPointer(idBase), limit=100)
d.putValue("%s/%s/%s/%s/%s" % (msecs, spec, offset, tz, status),
DateTimeInternal)
else:
......@@ -705,7 +705,7 @@ def qdump__QHostAddress(d, value):
ipStringAddress = privAddress + (0 if isQt5 else 24)
isParsedAddress = privAddress + 24 + 2 * sizeofQString
# value.d.d->ipString
ipString = d.encodeStringHelper(d.extractPointer(ipStringAddress))
ipString = d.encodeStringHelper(d.extractPointer(ipStringAddress), limit=100)
if d.extractByte(isParsedAddress) and len(ipString) > 0:
d.putValue(ipString, Hex4EncodedLittleEndian)
else:
......@@ -720,7 +720,7 @@ def qdump__QHostAddress(d, value):
data = d.readMemory(privAddress + a6Offset, 16)
address = ':'.join("%x" % int(data[i:i+4], 16) for i in xrange(0, 32, 4))
scopeId = privAddress + sizeofQString + (0 if isQt5 else 24)
scopeId = d.encodeStringHelper(d.extractPointer(scopeId))
scopeId = d.encodeStringHelper(d.extractPointer(scopeId), limit=100)
d.putValue("%s%%%s" % (address, scopeId), IPv6AddressAndHexScopeId)
elif proto == 0:
# value.d.d->a
......@@ -1730,7 +1730,7 @@ def qdump__QString(d, value):
d.putDisplay(StopDisplay)
elif format == 2:
d.putField("editformat", DisplayUtf16String)
d.putField("editvalue", d.encodeString(value))
d.putField("editvalue", d.encodeString(value, limit=None))
def qdump__QStringRef(d, value):
......@@ -1759,7 +1759,7 @@ def qdump__QTemporaryFile(d, value):
def qdump__QTextCodec(d, value):
name = d.call(value, "name")
d.putValue(d.encodeByteArray(d, name), 6)
d.putValue(d.encodeByteArray(name, limit=100), 6)
d.putNumChild(2)
if d.isExpanded():
with Children(d):
......@@ -1843,13 +1843,13 @@ def qdump__QUrl(d, value):
d.putValue("<invalid>")
return
schemeAddr = privAddress + 2 * d.intSize()
scheme = d.encodeStringHelper(d.extractPointer(schemeAddr))
userName = d.encodeStringHelper(d.extractPointer(schemeAddr + 1 * d.ptrSize()))
password = d.encodeStringHelper(d.extractPointer(schemeAddr + 2 * d.ptrSize()))
host = d.encodeStringHelper(d.extractPointer(schemeAddr + 3 * d.ptrSize()))
path = d.encodeStringHelper(d.extractPointer(schemeAddr + 4 * d.ptrSize()))
query = d.encodeStringHelper(d.extractPointer(schemeAddr + 5 * d.ptrSize()))
fragment = d.encodeStringHelper(d.extractPointer(schemeAddr + 6 * d.ptrSize()))
scheme = d.encodeStringHelper(d.extractPointer(schemeAddr), limit=1000)
userName = d.encodeStringHelper(d.extractPointer(schemeAddr + 1 * d.ptrSize()), limit=100)
password = d.encodeStringHelper(d.extractPointer(schemeAddr + 2 * d.ptrSize()), limit=100)
host = d.encodeStringHelper(d.extractPointer(schemeAddr + 3 * d.ptrSize()), limit=100)
path = d.encodeStringHelper(d.extractPointer(schemeAddr + 4 * d.ptrSize()), limit=1000)
query = d.encodeStringHelper(d.extractPointer(schemeAddr + 5 * d.ptrSize()), limit=10000)
fragment = d.encodeStringHelper(d.extractPointer(schemeAddr + 6 * d.ptrSize()), limit=10000)
port = d.extractInt(d.extractPointer(value) + d.intSize())
url = scheme
......
......@@ -418,10 +418,8 @@ def qdump__std__stringHelper1__QNX(d, value, charSize):
qdump_stringHelper(d, sizePtr, size * charSize, charSize)
def qdump_stringHelper(d, data, size, charSize):
cutoff = min(size, d.stringCutOff)
mem = d.readMemory(data, cutoff)
if size > d.stringCutOff:
mem += "2e2e2e"
elided, shown = d.computeLimit(size, d.displayStringLimit)
mem = d.readMemory(data, shown)
if charSize == 1:
encodingType = Hex2EncodedLatin1
displayType = DisplayLatin1String
......@@ -433,7 +431,7 @@ def qdump_stringHelper(d, data, size, charSize):
displayType = DisplayUtf16String
d.putNumChild(0)
d.putValue(mem, encodingType)
d.putValue(mem, encodingType, elided=elided)
format = d.currentItemFormat()
if format == 1:
......
......@@ -121,6 +121,14 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
spinBoxMaximalStringLength->setSingleStep(1000);
spinBoxMaximalStringLength->setValue(10000);
labelDisplayStringLimit = new QLabel(tr("Display string limit:"), behaviorBox);
spinBoxDisplayStringLimit = new QSpinBox(behaviorBox);
spinBoxDisplayStringLimit->setSpecialValueText(tr("<unlimited>"));
spinBoxDisplayStringLimit->setMaximum(10000);
spinBoxDisplayStringLimit->setSingleStep(10);
spinBoxDisplayStringLimit->setValue(100);
sourcesMappingWidget = new DebuggerSourcePathMappingWidget(this);
QHBoxLayout *horizontalLayout = new QHBoxLayout();
......@@ -128,6 +136,11 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
horizontalLayout->addWidget(spinBoxMaximalStackDepth);
horizontalLayout->addStretch();
QHBoxLayout *horizontalLayout1 = new QHBoxLayout();
horizontalLayout1->addWidget(labelDisplayStringLimit);
horizontalLayout1->addWidget(spinBoxDisplayStringLimit);
horizontalLayout1->addStretch();
QHBoxLayout *horizontalLayout2 = new QHBoxLayout();
horizontalLayout2->addWidget(labelMaximalStringLength);
horizontalLayout2->addWidget(spinBoxMaximalStringLength);
......@@ -148,7 +161,8 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
gridLayout->addWidget(checkBoxShowQmlObjectTree, 3, 1, 1, 1);
gridLayout->addWidget(checkBoxKeepEditorStationaryWhileStepping, 4, 1, 1, 1);
gridLayout->addWidget(checkBoxRegisterForPostMortem, 5, 1, 1, 1);
gridLayout->addLayout(horizontalLayout2, 6, 1, 1, 2);
gridLayout->addLayout(horizontalLayout1, 6, 1, 1, 2);
gridLayout->addLayout(horizontalLayout2, 7, 1, 1, 2);
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
verticalLayout->addWidget(behaviorBox);
......@@ -193,6 +207,7 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
m_group->insert(dc->action(UseAddressInStackView), 0);
m_group->insert(dc->action(AlwaysAdjustStackColumnWidths), 0);
m_group->insert(dc->action(MaximalStackDepth), spinBoxMaximalStackDepth);
m_group->insert(dc->action(DisplayStringLimit), spinBoxDisplayStringLimit);
m_group->insert(dc->action(MaximalStringLength), spinBoxMaximalStringLength);
m_group->insert(dc->action(ShowStdNamespace), 0);
m_group->insert(dc->action(ShowQtNamespace), 0);
......
......@@ -77,9 +77,11 @@ private:
QCheckBox *checkBoxWarnOnReleaseBuilds;
QCheckBox *checkBoxKeepEditorStationaryWhileStepping;
QLabel *labelMaximalStackDepth;
QLabel *labelDisplayStringLimit;
QLabel *labelMaximalStringLength;
QSpinBox *spinBoxMaximalStackDepth;
QSpinBox *spinBoxMaximalStringLength;
QSpinBox *spinBoxDisplayStringLimit;
DebuggerSourcePathMappingWidget *sourcesMappingWidget;
const QSharedPointer<Utils::SavedActionSet> m_group;
......
......@@ -631,8 +631,18 @@ DebuggerSettings::DebuggerSettings()
item->setDefaultValue(20);
insertItem(MaximalStackDepth, item);
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("DisplayStringLimit"));
item->setToolTip(tr("The maximal length of string entries in the "
"Locals and Expressions pane. Longer than that are cut off "
"and displayed with an ellipsis attached."));
item->setDefaultValue(100);
insertItem(DisplayStringLimit, item);
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("MaximalStringLength"));
item->setToolTip(tr("The maximal length for strings in separated windows. "
"Longer strings are cut off and displayed with an ellipsis attached."));
item->setDefaultValue(10000);
insertItem(MaximalStringLength, item);
......
......@@ -148,6 +148,7 @@ enum DebuggerActionCode
AutoDerefPointers,
AlwaysAdjustLocalsColumnWidths,
MaximalStringLength,
DisplayStringLimit,
// Source List
ListSourceFiles,
......
......@@ -219,7 +219,6 @@ QDataStream &operator<<(QDataStream &stream, const WatchData &wd)
stream << wd.value;
stream << wd.editvalue;
stream << wd.editformat;
stream << wd.valuetooltip;
stream << wd.typeFormats;
stream << wd.type;
stream << wd.displayedType;
......@@ -243,7 +242,6 @@ QDataStream &operator>>(QDataStream &stream, WatchData &wd)
stream >> wd.value;
stream >> wd.editvalue;
stream >> wd.editformat;
stream >> wd.valuetooltip;
stream >> wd.typeFormats;
stream >> wd.type;
stream >> wd.displayedType;
......
......@@ -4841,7 +4841,10 @@ void GdbEngine::updateLocalsPython(const UpdateParameters &params)
expanded += "formats:" + handler->individualFormatRequests();
QByteArray cutOff = " stringcutoff:"
+ debuggerCore()->action(MaximalStringLength)->value().toByteArray();
+ debuggerCore()->action(MaximalStringLength)->value().toByteArray()
+ " displaystringlimit:"
+ debuggerCore()->action(DisplayStringLimit)->value().toByteArray();
QByteArray watchers;
const QString fileName = stackHandler()->currentFrame().file;
......
......@@ -126,6 +126,7 @@ WatchData::WatchData() :
size(0),
bitpos(0),
bitsize(0),
elided(0),
hasChildren(false),
valueEnabled(true),
valueEditable(true),
......@@ -142,12 +143,12 @@ bool WatchData::isEqual(const WatchData &other) const
&& name == other.name
&& value == other.value
&& editvalue == other.editvalue
&& valuetooltip == other.valuetooltip
&& type == other.type
&& displayedType == other.displayedType
&& variable == other.variable
&& address == other.address
&& size == other.size
&& elided == other.elided
&& hasChildren == other.hasChildren
&& valueEnabled == other.valueEnabled
&& valueEditable == other.valueEditable
......@@ -312,6 +313,9 @@ QString WatchData::toString() const
if (isValueKnown() && !value.isEmpty())
str << "value=\"" << value << doubleQuoteComma;
if (elided)
str << "valueelided=\"" << elided << doubleQuoteComma;
if (!editvalue.isEmpty())
str << "editvalue=\"<...>\",";
// str << "editvalue=\"" << editvalue << doubleQuoteComma;
......@@ -382,7 +386,7 @@ QString WatchData::toToolTip() const
formatToolTipRow(str, tr("Internal Type"), QLatin1String(type));
if (!displayedType.isEmpty())
formatToolTipRow(str, tr("Displayed Type"), displayedType);
QString val = valuetooltip.isEmpty() ? value : valuetooltip;
QString val = value;
// Automatically display hex value for unsigned integers.
if (!val.isEmpty() && val.at(0).isDigit() && isIntType(type)) {
bool ok;
......@@ -458,13 +462,6 @@ void WatchData::updateValue(const GdbMi &item)
}
}
void setWatchDataValueToolTip(WatchData &data, const GdbMi &mi,
int encoding)
{
if (mi.isValid())
data.valuetooltip = decodeData(mi.data(), encoding);
}
void WatchData::updateChildCount(const GdbMi &mi)
{
if (mi.isValid())
......@@ -629,6 +626,10 @@ void parseWatchData(const QSet<QByteArray> &expandedINames,
if (mi.isValid())
data.typeFormats = QString::fromUtf8(mi.data());
mi = item["valueelided"];
if (mi.isValid())
data.elided = mi.toInt();
mi = item["bitpos"];
if (mi.isValid())
data.bitpos = mi.toInt();
......
......@@ -126,7 +126,6 @@ public:
QString value; // Displayed value
QByteArray editvalue; // 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)
......@@ -135,6 +134,7 @@ public:
uint size; // Size
uint bitpos; // Position within bit fields
uint bitsize; // Size in case of bit fields
int elided; // Full size if value was cut off, -1 if cut on unknown size, 0 otherwise
bool hasChildren;
bool valueEnabled; // Value will be enabled or not
bool valueEditable; // Value will be editable
......
......@@ -695,6 +695,14 @@ QString WatchModel::formattedValue(const WatchData &data) const
}
}
if (data.elided) {
QString v = value;
v.chop(1);
QString len = data.elided > 0 ? QString::number(data.elided)
: QLatin1String("unknown length");
return v + QLatin1String("\"... (") + len + QLatin1Char(')');
}
return translate(value);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment