Support local variables in watch expressions

This commit is contained in:
baldurk
2018-06-08 19:20:50 +01:00
parent 1761f5ab36
commit 2a6a0f0f95
2 changed files with 49 additions and 1 deletions
+48 -1
View File
@@ -1459,7 +1459,7 @@ void ShaderViewer::combineStructures(RDTreeWidgetItem *root)
});
// create a new parent with just the prefix
QVariantList values = {isArray ? name : name.mid(0, sepIndex)};
QVariantList values = {name.mid(0, sepIndex)};
for(int i = 1; i < child->dataCount(); i++)
values.push_back(QVariant());
RDTreeWidgetItem *parent = new RDTreeWidgetItem(values);
@@ -1493,6 +1493,21 @@ void ShaderViewer::combineStructures(RDTreeWidgetItem *root)
root->addChild(temp.takeChild(0));
}
RDTreeWidgetItem *ShaderViewer::findLocal(RDTreeWidgetItem *root, QString name)
{
if(root->tag().toString() == name)
return root;
for(int i = 0; i < root->childCount(); i++)
{
RDTreeWidgetItem *ret = findLocal(root->child(i), name);
if(ret)
return ret;
}
return NULL;
}
void ShaderViewer::updateDebugging()
{
if(!m_Trace || m_CurrentStep < 0 || m_CurrentStep >= m_Trace->states.count())
@@ -1857,6 +1872,8 @@ void ShaderViewer::updateDebugging()
RDTreeWidgetItem *node = new RDTreeWidgetItem({localName, regNames, typeName, value});
node->setTag(localName);
if(modified)
node->setForegroundColor(QColor(Qt::red));
@@ -2133,6 +2150,36 @@ void ShaderViewer::updateDebugging()
continue;
}
}
else
{
regexp = QRegularExpression(lit("^(.+)(\\.[xyzwrgba]+)?(,[xfiudb])?$"));
match = regexp.match(reg);
if(match.hasMatch())
{
QString variablename = match.captured(1);
RDTreeWidgetItem *local = findLocal(ui->locals->invisibleRootItem(), match.captured(1));
if(local)
{
// TODO apply swizzle/typecast ?
if(local->childCount() > 0)
{
// can't display structs
ui->watch->setItem(i, 2, new QTableWidgetItem(lit("{...}")));
}
else
{
ui->watch->setItem(i, 2, new QTableWidgetItem(local->text(3)));
}
continue;
}
}
}
ui->watch->setItem(i, 2, new QTableWidgetItem(tr("Error evaluating expression")));
}
+1
View File
@@ -252,4 +252,5 @@ private:
RDTreeWidgetItem *makeResourceRegister(const Bindpoint &bind, uint32_t idx,
const BoundResource &ro, const ShaderResource &resources);
void combineStructures(RDTreeWidgetItem *root);
RDTreeWidgetItem *findLocal(RDTreeWidgetItem *root, QString name);
};