Commit 6b0d5d60 authored by hjk's avatar hjk

Debugger: Clearly mark unavailable register contents

The previous display as 0, or 0x0...0e (LLDB on Linux) was
less useful.

Change-Id: I820ea5ef427b65633471c7c62e44851fcfd637cd
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent fe2addf5
......@@ -1218,7 +1218,11 @@ class Dumper(DumperBase):
for group in frame.GetRegisters():
for reg in group:
result += '{name="%s"' % reg.GetName()
result += ',value="%s"' % reg.GetValue()
value = reg.GetValue()
if value is None:
result += ',value=""'
else:
result += ',value="%s"' % value
result += ',size="%s"' % reg.GetByteSize()
result += ',type="%s"},' % reg.GetType()
result += ']'
......
......@@ -31,10 +31,6 @@
#include "registerhandler.h"
#include "watchdelegatewidgets.h"
#if USE_REGISTER_MODEL_TEST
#include <modeltest.h>
#endif
#include <utils/qtcassert.h>
namespace Debugger {
......@@ -282,6 +278,7 @@ static uint decodeHexChar(unsigned char c)
void RegisterValue::operator=(const QByteArray &ba)
{
known = !ba.isEmpty();
uint shift = 0;
int j = 0;
v.u64[1] = v.u64[0] = 0;
......@@ -318,6 +315,8 @@ static QByteArray format(quint64 v, int base, int size)
QByteArray RegisterValue::toByteArray(int base, RegisterKind kind, int size) const
{
if (!known)
return "[inaccessible]";
if (kind == FloatRegister) {
if (size == 4)
return QByteArray::number(v.f[0]);
......@@ -452,13 +451,13 @@ QVariant RegisterItem::data(int column, int role) const
case Qt::DisplayRole:
switch (column) {
case 0: {
case RegisterNameColumn: {
QByteArray res = m_reg.name;
if (!m_reg.description.isEmpty())
res += " (" + m_reg.description + ')';
return res;
}
case 1: {
case RegisterValueColumn: {
return m_reg.value.toByteArray(m_base, m_reg.kind, m_reg.size);
}
}
......@@ -472,7 +471,7 @@ QVariant RegisterItem::data(int column, int role) const
return m_reg.value.toByteArray(m_base, m_reg.kind, m_reg.size);
case Qt::TextAlignmentRole:
return column == 1 ? QVariant(Qt::AlignRight) : QVariant();
return column == RegisterValueColumn ? QVariant(Qt::AlignRight) : QVariant();
default:
break;
......@@ -494,9 +493,9 @@ QVariant RegisterSubItem::data(int column, int role) const
case Qt::DisplayRole:
switch (column) {
case 0:
case RegisterNameColumn:
return subTypeName(m_subKind, m_subSize);
case 1: {
case RegisterValueColumn: {
QTC_ASSERT(parent(), return QVariant());
RegisterItem *registerItem = static_cast<RegisterItem *>(parent());
RegisterValue value = registerItem->m_reg.value;
......@@ -526,10 +525,6 @@ RegisterHandler::RegisterHandler()
{
setObjectName(QLatin1String("RegisterModel"));
setHeader(QStringList() << tr("Name") << tr("Value"));
#if USE_REGISTER_MODEL_TEST
new ModelTest(this, 0);
#endif
}
void RegisterHandler::updateRegister(const Register &r)
......
......@@ -40,6 +40,13 @@
namespace Debugger {
namespace Internal {
enum RegisterColumns
{
RegisterNameColumn,
RegisterValueColumn,
RegisterColumnCount
};
enum RegisterDataRole
{
RegisterNameRole = Qt::UserRole,
......@@ -62,7 +69,7 @@ enum RegisterKind
class RegisterValue
{
public:
RegisterValue() { v.u64[1] = v.u64[0] = 0; }
RegisterValue() { known = false; v.u64[1] = v.u64[0] = 0; }
void operator=(const QByteArray &ba);
bool operator==(const RegisterValue &other);
bool operator!=(const RegisterValue &other) { return !operator==(other); }
......@@ -77,6 +84,7 @@ public:
float f[4];
double d[2];
} v;
bool known;
};
class Register
......
......@@ -108,7 +108,7 @@ public:
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == 1) {
if (index.column() == RegisterValueColumn) {
const bool paintRed = index.data(RegisterChangedRole).toBool();
QPen oldPen = painter->pen();
const QColor lightColor(140, 140, 140);
......
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