mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Use drrj to read values for RegistersWidget. (#2141)
* Avoids problem with 64bit value as number in json * Keeps registers in the order reported by r2
This commit is contained in:
parent
b69dff0fcd
commit
aa8ecee8e2
@ -1494,22 +1494,22 @@ QList<VariableDescription> CutterCore::getVariables(RVA at)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject CutterCore::getRegisterJson()
|
QVector<RegisterRefValueDescription> CutterCore::getRegisterRefValues()
|
||||||
{
|
{
|
||||||
QJsonArray registerRefArray = cmdj("drrj").array();
|
QJsonArray registerRefArray = cmdj("drrj").array();
|
||||||
QJsonObject registerJson;
|
QVector<RegisterRefValueDescription> result;
|
||||||
|
|
||||||
for (const QJsonValue &value : registerRefArray) {
|
for (const QJsonValue value : registerRefArray) {
|
||||||
QJsonObject regRefObject = value.toObject();
|
QJsonObject regRefObject = value.toObject();
|
||||||
|
|
||||||
QJsonObject registers;
|
RegisterRefValueDescription desc;
|
||||||
|
desc.name = regRefObject[RJsonKey::reg].toString();
|
||||||
|
desc.value = regRefObject[RJsonKey::value].toString();
|
||||||
|
desc.ref = regRefObject[RJsonKey::ref].toString();
|
||||||
|
|
||||||
registers.insert(RJsonKey::value, regRefObject[RJsonKey::value]);
|
result.push_back(desc);
|
||||||
registers.insert(RJsonKey::ref, regRefObject[RJsonKey::ref]);
|
|
||||||
|
|
||||||
registerJson.insert(regRefObject[RJsonKey::reg].toString(), registers);
|
|
||||||
}
|
}
|
||||||
return registerJson;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CutterCore::getRegisterName(QString registerRole)
|
QString CutterCore::getRegisterName(QString registerRole)
|
||||||
|
@ -560,7 +560,7 @@ public:
|
|||||||
* @param depth telescoping depth
|
* @param depth telescoping depth
|
||||||
*/
|
*/
|
||||||
QList<QJsonObject> getRegisterRefs(int depth = 6);
|
QList<QJsonObject> getRegisterRefs(int depth = 6);
|
||||||
QJsonObject getRegisterJson();
|
QVector<RegisterRefValueDescription> getRegisterRefValues();
|
||||||
QList<VariableDescription> getVariables(RVA at);
|
QList<VariableDescription> getVariables(RVA at);
|
||||||
|
|
||||||
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function,
|
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function,
|
||||||
|
@ -321,6 +321,12 @@ struct VariableDescription {
|
|||||||
QString type;
|
QString type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RegisterRefValueDescription {
|
||||||
|
QString name;
|
||||||
|
QString value;
|
||||||
|
QString ref;
|
||||||
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(FunctionDescription)
|
Q_DECLARE_METATYPE(FunctionDescription)
|
||||||
Q_DECLARE_METATYPE(ImportDescription)
|
Q_DECLARE_METATYPE(ImportDescription)
|
||||||
Q_DECLARE_METATYPE(ExportDescription)
|
Q_DECLARE_METATYPE(ExportDescription)
|
||||||
|
@ -51,17 +51,11 @@ void RegistersWidget::setRegisterGrid()
|
|||||||
QString regValue;
|
QString regValue;
|
||||||
QLabel *registerLabel;
|
QLabel *registerLabel;
|
||||||
QLineEdit *registerEditValue;
|
QLineEdit *registerEditValue;
|
||||||
QJsonObject registerValues = Core()->getRegisterValues().object();
|
const auto registerRefs = Core()->getRegisterRefValues();
|
||||||
QJsonObject registerRefs = Core()->getRegisterJson();
|
|
||||||
QStringList registerNames = registerValues.keys();
|
|
||||||
|
|
||||||
QCollator collator;
|
registerLen = registerRefs.size();
|
||||||
collator.setNumericMode(true);
|
for (auto ® : registerRefs) {
|
||||||
std::sort(registerNames.begin(), registerNames.end(), collator);
|
regValue = "0x" + reg.value;
|
||||||
|
|
||||||
registerLen = registerValues.size();
|
|
||||||
for (const QString &key : registerNames) {
|
|
||||||
regValue = RAddressString(registerValues[key].toVariant().toULongLong());
|
|
||||||
// check if we already filled this grid space with label/value
|
// check if we already filled this grid space with label/value
|
||||||
if (!registerLayout->itemAtPosition(i, col)) {
|
if (!registerLayout->itemAtPosition(i, col)) {
|
||||||
registerLabel = new QLabel;
|
registerLabel = new QLabel;
|
||||||
@ -87,8 +81,6 @@ void RegistersWidget::setRegisterGrid()
|
|||||||
QString regNameString = registerLabel->text();
|
QString regNameString = registerLabel->text();
|
||||||
QString regValueString = registerEditValue->text();
|
QString regValueString = registerEditValue->text();
|
||||||
Core()->setRegister(regNameString, regValueString);
|
Core()->setRegister(regNameString, regValueString);
|
||||||
printf("dr %s %s\n", regNameString.toLocal8Bit().constData(),
|
|
||||||
regValueString.toLocal8Bit().constData());
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
QWidget *regNameWidget = registerLayout->itemAtPosition(i, col)->widget();
|
QWidget *regNameWidget = registerLayout->itemAtPosition(i, col)->widget();
|
||||||
@ -104,13 +96,11 @@ void RegistersWidget::setRegisterGrid()
|
|||||||
registerEditValue->setStyleSheet("");
|
registerEditValue->setStyleSheet("");
|
||||||
}
|
}
|
||||||
// define register label and value
|
// define register label and value
|
||||||
registerLabel->setText(key);
|
registerLabel->setText(reg.name);
|
||||||
if (registerRefs.contains(key)) {
|
|
||||||
// add register references to tooltips
|
registerLabel->setToolTip(reg.ref);
|
||||||
QString reference = registerRefs[key].toObject()["ref"].toString();
|
registerEditValue->setToolTip(reg.ref);
|
||||||
registerLabel->setToolTip(reference);
|
|
||||||
registerEditValue->setToolTip(reference);
|
|
||||||
}
|
|
||||||
registerEditValue->setPlaceholderText(regValue);
|
registerEditValue->setPlaceholderText(regValue);
|
||||||
registerEditValue->setText(regValue);
|
registerEditValue->setText(regValue);
|
||||||
i++;
|
i++;
|
||||||
|
Loading…
Reference in New Issue
Block a user