mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Added extra function information to function widget (#788)
* Added Extra Information to Functions Widget * Sorting enabled through recently added columns in Functions Widget
This commit is contained in:
parent
e97ddfa3b1
commit
b298ce8325
@ -1663,6 +1663,10 @@ QList<FunctionDescription> CutterCore::parseFunctionsJson(const QJsonDocument &d
|
|||||||
function.cc = (RVA)jsonObject["cc"].toVariant().toULongLong();
|
function.cc = (RVA)jsonObject["cc"].toVariant().toULongLong();
|
||||||
function.calltype = jsonObject["calltype"].toString();
|
function.calltype = jsonObject["calltype"].toString();
|
||||||
function.name = jsonObject["name"].toString();
|
function.name = jsonObject["name"].toString();
|
||||||
|
function.edges = (RVA)jsonObject["edges"].toVariant().toULongLong();
|
||||||
|
function.cost = (RVA)jsonObject["cost"].toVariant().toULongLong();
|
||||||
|
function.calls = (RVA)jsonObject["outdegree"].toVariant().toULongLong();
|
||||||
|
function.stackframe = (RVA)jsonObject["stackframe"].toVariant().toULongLong();
|
||||||
|
|
||||||
ret << function;
|
ret << function;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,10 @@ struct FunctionDescription {
|
|||||||
RVA cc;
|
RVA cc;
|
||||||
QString calltype;
|
QString calltype;
|
||||||
QString name;
|
QString name;
|
||||||
|
RVA edges;
|
||||||
|
RVA cost;
|
||||||
|
RVA calls;
|
||||||
|
RVA stackframe;
|
||||||
|
|
||||||
bool contains(RVA addr) const
|
bool contains(RVA addr) const
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ int FunctionModel::rowCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
if (nested) {
|
if (nested) {
|
||||||
if (parent.internalId() == 0)
|
if (parent.internalId() == 0)
|
||||||
return 8; // sub-nodes for nested functions
|
return ColumnCount; // sub-nodes for nested functions
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
@ -125,6 +125,14 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||||||
return tr("Cyclomatic complexity: %1").arg(RSizeString(function.cc));
|
return tr("Cyclomatic complexity: %1").arg(RSizeString(function.cc));
|
||||||
case 7:
|
case 7:
|
||||||
return tr("Call type: %1").arg(function.calltype);
|
return tr("Call type: %1").arg(function.calltype);
|
||||||
|
case 8:
|
||||||
|
return tr("Edges: %1").arg(function.edges);
|
||||||
|
case 9:
|
||||||
|
return tr("Cost: %1").arg(function.cost);
|
||||||
|
case 10:
|
||||||
|
return tr("Calls/OutDeg.: %1").arg(function.calls);
|
||||||
|
case 11:
|
||||||
|
return tr("StackFrame: %1").arg(function.stackframe);
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -148,6 +156,14 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||||||
return function.cc;
|
return function.cc;
|
||||||
case CalltypeColumn:
|
case CalltypeColumn:
|
||||||
return function.calltype;
|
return function.calltype;
|
||||||
|
case EdgesColumn:
|
||||||
|
return function.edges;
|
||||||
|
case CostColumn:
|
||||||
|
return function.cost;
|
||||||
|
case CallsColumn:
|
||||||
|
return function.calls;
|
||||||
|
case FrameColumn:
|
||||||
|
return function.stackframe;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -227,6 +243,14 @@ QVariant FunctionModel::headerData(int section, Qt::Orientation orientation, int
|
|||||||
return tr("Cyclo. Comp.");
|
return tr("Cyclo. Comp.");
|
||||||
case CalltypeColumn:
|
case CalltypeColumn:
|
||||||
return tr("Call type");
|
return tr("Call type");
|
||||||
|
case EdgesColumn:
|
||||||
|
return tr("Edges");
|
||||||
|
case CostColumn:
|
||||||
|
return tr("Cost");
|
||||||
|
case CallsColumn:
|
||||||
|
return tr("Calls/OutDeg.");
|
||||||
|
case FrameColumn:
|
||||||
|
return tr("StackFrame");
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -372,6 +396,22 @@ bool FunctionSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
|
|||||||
case FunctionModel::CalltypeColumn:
|
case FunctionModel::CalltypeColumn:
|
||||||
return left_function.calltype < right_function.calltype;
|
return left_function.calltype < right_function.calltype;
|
||||||
break;
|
break;
|
||||||
|
case FunctionModel::EdgesColumn:
|
||||||
|
if (left_function.edges != right_function.edges)
|
||||||
|
return left_function.edges < right_function.edges;
|
||||||
|
break;
|
||||||
|
case FunctionModel::CostColumn:
|
||||||
|
if (left_function.cost != right_function.cost)
|
||||||
|
return left_function.cost < right_function.cost;
|
||||||
|
break;
|
||||||
|
case FunctionModel::CallsColumn:
|
||||||
|
if (left_function.calls != right_function.calls)
|
||||||
|
return left_function.calls < right_function.calls;
|
||||||
|
break;
|
||||||
|
case FunctionModel::FrameColumn:
|
||||||
|
if (left_function.stackframe != right_function.stackframe)
|
||||||
|
return left_function.stackframe < right_function.stackframe;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,8 @@ public:
|
|||||||
static const int IsImportRole = Qt::UserRole + 1;
|
static const int IsImportRole = Qt::UserRole + 1;
|
||||||
|
|
||||||
enum Column { NameColumn = 0, SizeColumn, ImportColumn, OffsetColumn, NargsColumn, NbbsColumn,
|
enum Column { NameColumn = 0, SizeColumn, ImportColumn, OffsetColumn, NargsColumn, NbbsColumn,
|
||||||
NlocalsColumn, CcColumn, CalltypeColumn, ColumnCount
|
NlocalsColumn, CcColumn, CalltypeColumn, EdgesColumn, CostColumn, CallsColumn,
|
||||||
|
FrameColumn, ColumnCount
|
||||||
};
|
};
|
||||||
|
|
||||||
FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *importAddresses, ut64 *mainAdress,
|
FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *importAddresses, ut64 *mainAdress,
|
||||||
|
Loading…
Reference in New Issue
Block a user