Show sizes of structs and unions (#1203)

Show sizes of structs and unions and update radare2 submodule for r_core_save_parsed_type()
This commit is contained in:
Gaurav Kumar Ghildiyal 2019-02-19 19:41:01 +05:30 committed by Itay Cohen
parent cd96856959
commit a8fbe72bf7
3 changed files with 16 additions and 10 deletions

@ -1 +1 @@
Subproject commit b84e57ec4c509afeaf856471d70e9dd9d9fd0013 Subproject commit b1bf3fea9edf231ba99c27b147ec83664ac06638

View File

@ -2204,10 +2204,13 @@ QList<TypeDescription> CutterCore::getAllUnions()
QList<TypeDescription> ret; QList<TypeDescription> ret;
QJsonArray typesArray = cmdj("tuj").array(); QJsonArray typesArray = cmdj("tuj").array();
for (auto value: typesArray) { for (const QJsonValue value: typesArray) {
QJsonObject typeObject = value.toObject();
TypeDescription exp; TypeDescription exp;
exp.type = value.toString();
exp.size = 0; exp.type = typeObject[RJsonKey::type].toString();
exp.size = typeObject[RJsonKey::size].toVariant().toULongLong();
exp.category = "Union"; exp.category = "Union";
ret << exp; ret << exp;
} }
@ -2221,10 +2224,13 @@ QList<TypeDescription> CutterCore::getAllStructs()
QList<TypeDescription> ret; QList<TypeDescription> ret;
QJsonArray typesArray = cmdj("tsj").array(); QJsonArray typesArray = cmdj("tsj").array();
for (auto value: typesArray) { for (const QJsonValue value: typesArray) {
QJsonObject typeObject = value.toObject();
TypeDescription exp; TypeDescription exp;
exp.type = value.toString();
exp.size = 0; exp.type = typeObject[RJsonKey::type].toString();
exp.size = typeObject[RJsonKey::size].toVariant().toULongLong();
exp.category = "Struct"; exp.category = "Struct";
ret << exp; ret << exp;
} }
@ -2280,7 +2286,7 @@ QString CutterCore::addTypes(const char *str)
return ret; return ret;
} }
sdb_query_lines(core_->anal->sdb_types, parsed); r_core_save_parsed_type(core_, parsed);
r_mem_free(parsed); r_mem_free(parsed);
if (error_msg) { if (error_msg) {
@ -2631,4 +2637,4 @@ QString CutterCore::ansiEscapeToHtml(const QString &text)
QString r = QString::fromUtf8(html, len); QString r = QString::fromUtf8(html, len);
free(html); free(html);
return r; return r;
} }

View File

@ -37,7 +37,7 @@ QVariant TypesModel::data(const QModelIndex &index, int role) const
case TYPE: case TYPE:
return exp.type; return exp.type;
case SIZE: case SIZE:
return exp.category == tr("Primitive") ? exp.size : QVariant(); return exp.size ? exp.size : QVariant();
case FORMAT: case FORMAT:
return exp.format; return exp.format;
case CATEGORY: case CATEGORY: