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