forked from qt-creator/qt-creator
debugger: use symbolic constants for "Display in Seperate Window" modes
Change-Id: Iab2b918e94abddb1fb4132c27e0b5f29810d4598 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -49,7 +49,7 @@ verbosity = 1
|
||||
|
||||
# Some "Enums"
|
||||
|
||||
# Encodings
|
||||
# Encodings. Keep that synchronized with DebuggerEncoding in watchutils.h
|
||||
Unencoded8Bit, \
|
||||
Base64Encoded8BitWithQuotes, \
|
||||
Base64Encoded16BitWithQuotes, \
|
||||
@@ -79,13 +79,15 @@ Hex2EncodedFloat4, \
|
||||
Hex2EncodedFloat8 \
|
||||
= range(27)
|
||||
|
||||
# Display modes
|
||||
# Display modes. Keep that synchronized with DebuggerDisplay in watchutils.h
|
||||
StopDisplay, \
|
||||
DisplayImage1, \
|
||||
DisplayString, \
|
||||
DisplayImage, \
|
||||
DisplayProcess \
|
||||
= range(5)
|
||||
DisplayImageData, \
|
||||
DisplayUtf16String, \
|
||||
DisplayImageFile, \
|
||||
DisplayProcess, \
|
||||
DisplayLatin1String, \
|
||||
DisplayUtf8String \
|
||||
= range(7)
|
||||
|
||||
|
||||
qqStringCutOff = 1000
|
||||
|
||||
@@ -54,10 +54,10 @@ def qdump__QByteArray(d, value):
|
||||
if format == 1:
|
||||
d.putDisplay(StopDisplay)
|
||||
elif format == 2:
|
||||
d.putField("editformat", 5)
|
||||
d.putField("editformat", DisplayLatin1String)
|
||||
d.putField("editvalue", encodeByteArray(value))
|
||||
elif format == 3:
|
||||
d.putField("editformat", 6)
|
||||
d.putField("editformat", DisplayUtf8String)
|
||||
d.putField("editvalue", encodeByteArray(value))
|
||||
if d.isExpanded():
|
||||
d.putArrayData(lookupType("char"), data, size)
|
||||
@@ -576,7 +576,7 @@ def qdump__QImage(d, value):
|
||||
if False:
|
||||
# Take four bytes at a time, this is critical for performance.
|
||||
# In fact, even four at a time is too slow beyond 100x100 or so.
|
||||
d.putField("editformat", 1) # Magic marker for direct "QImage" data.
|
||||
d.putField("editformat", DisplayImageData)
|
||||
d.put('%s="' % name)
|
||||
d.put("%08x" % int(d_ptr["width"]))
|
||||
d.put("%08x" % int(d_ptr["height"]))
|
||||
@@ -593,7 +593,7 @@ def qdump__QImage(d, value):
|
||||
p = bits.cast(lookupType("unsigned char").pointer())
|
||||
gdb.execute("dump binary memory %s %s %s" %
|
||||
(filename, cleanAddress(p), cleanAddress(p + nbytes)))
|
||||
d.putDisplay(DisplayImage, " %d %d %d %s"
|
||||
d.putDisplay(DisplayImageFile, " %d %d %d %s"
|
||||
% (d_ptr["width"], d_ptr["height"], d_ptr["format"], filename))
|
||||
|
||||
|
||||
@@ -1398,7 +1398,7 @@ def qdump__QString(d, value):
|
||||
if format == 1:
|
||||
d.putDisplay(StopDisplay)
|
||||
elif format == 2:
|
||||
d.putField("editformat", 2)
|
||||
d.putField("editformat", DisplayUtf16String)
|
||||
d.putField("editvalue", encodeString(value))
|
||||
|
||||
|
||||
|
||||
@@ -1605,7 +1605,8 @@ void WatchHandler::showEditValue(const WatchData &data)
|
||||
if (data.editformat == 0x0) {
|
||||
m_model->m_editHandlers.remove(data.iname);
|
||||
delete w;
|
||||
} else if (data.editformat == 1 || data.editformat == 3) {
|
||||
} else if (data.editformat == DisplayImageData
|
||||
|| data.editformat == DisplayImageFile) {
|
||||
// QImage
|
||||
QLabel *l = qobject_cast<QLabel *>(w);
|
||||
if (!l) {
|
||||
@@ -1621,7 +1622,7 @@ void WatchHandler::showEditValue(const WatchData &data)
|
||||
int width, height, format;
|
||||
QByteArray ba;
|
||||
uchar *bits;
|
||||
if (data.editformat == 1) {
|
||||
if (data.editformat == DisplayImageData) {
|
||||
ba = QByteArray::fromHex(data.editvalue);
|
||||
const int *header = (int *)(ba.data());
|
||||
swapEndian(ba.data(), ba.size());
|
||||
@@ -1629,7 +1630,7 @@ void WatchHandler::showEditValue(const WatchData &data)
|
||||
width = header[0];
|
||||
height = header[1];
|
||||
format = header[2];
|
||||
} else { // data.editformat == 3
|
||||
} else if (data.editformat == DisplayImageFile) {
|
||||
QTextStream ts(data.editvalue);
|
||||
QString fileName;
|
||||
ts >> width >> height >> format >> fileName;
|
||||
@@ -1639,20 +1640,13 @@ void WatchHandler::showEditValue(const WatchData &data)
|
||||
bits = (uchar*)ba.data();
|
||||
}
|
||||
QImage im(bits, width, height, QImage::Format(format));
|
||||
|
||||
#if 1
|
||||
// Qt bug. Enforce copy of image data.
|
||||
QImage im2(im);
|
||||
im.detach();
|
||||
#endif
|
||||
|
||||
l->setPixmap(QPixmap::fromImage(im));
|
||||
l->resize(width, height);
|
||||
l->show();
|
||||
} else if (data.editformat == 2
|
||||
|| data.editformat == 5
|
||||
|| data.editformat == 6) {
|
||||
// Display QString in a separate widget.
|
||||
} else if (data.editformat == DisplayUtf16String
|
||||
|| data.editformat == DisplayLatin1String
|
||||
|| data.editformat == DisplayUtf16String) {
|
||||
// String data.
|
||||
QTextEdit *t = qobject_cast<QTextEdit *>(w);
|
||||
if (!t) {
|
||||
delete w;
|
||||
@@ -1661,11 +1655,11 @@ void WatchHandler::showEditValue(const WatchData &data)
|
||||
}
|
||||
QByteArray ba = QByteArray::fromHex(data.editvalue);
|
||||
QString str;
|
||||
if (data.editformat == 2) // UTF-16
|
||||
if (data.editformat == DisplayUtf16String)
|
||||
str = QString::fromUtf16((ushort *)ba.constData(), ba.size()/2);
|
||||
else if (data.editformat == 5) // Latin1
|
||||
else if (data.editformat == DisplayLatin1String)
|
||||
str = QString::fromLatin1(ba.constData(), ba.size());
|
||||
else if (data.editformat == 6) // UTF-8
|
||||
else if (data.editformat == DisplayUtf8String)
|
||||
str = QString::fromUtf8(ba.constData(), ba.size());
|
||||
t->setText(str);
|
||||
t->resize(400, 200);
|
||||
|
||||
@@ -83,6 +83,17 @@ enum DebuggerEncoding
|
||||
Hex2EncodedFloat8 = 26
|
||||
};
|
||||
|
||||
// Keep in sync with dumper.py
|
||||
enum DebuggerDisplay {
|
||||
StopDisplay = 0,
|
||||
DisplayImageData = 1,
|
||||
DisplayUtf16String = 2,
|
||||
DisplayImageFile = 3,
|
||||
DisplayProcess = 4,
|
||||
DisplayLatin1String = 5,
|
||||
DisplayUtf8String = 6
|
||||
};
|
||||
|
||||
bool isEditorDebuggable(Core::IEditor *editor);
|
||||
QByteArray dotEscape(QByteArray str);
|
||||
QString currentTime();
|
||||
|
||||
Reference in New Issue
Block a user