Hide duplicate and cross-function edges. (#1582)

This commit is contained in:
karliss 2019-05-23 13:52:56 +03:00 committed by Florian Märkl
parent 75146d63f9
commit 214e6f4264
2 changed files with 21 additions and 0 deletions

View File

@ -310,6 +310,7 @@ void DisassemblerGraphView::loadCurrentGraph()
addBlock(gb);
}
cleanupEdges();
if (!func["blocks"].toArray().isEmpty()) {
computeGraph(entry);
@ -355,6 +356,25 @@ void DisassemblerGraphView::prepareGraphNode(GraphBlock &block)
block.height = (height * charHeight) + extra;
}
void DisassemblerGraphView::cleanupEdges()
{
for (auto &blockIt : blocks) {
auto &block = blockIt.second;
auto outIt = block.edges.begin();
std::unordered_set<ut64> seenEdges;
for (auto it = block.edges.begin(), end = block.edges.end(); it != end; ++it) {
// remove edges going to different functions
// and remove duplicate edges, common in switch statements
if (blocks.find(it->target) != blocks.end() &&
seenEdges.find(it->target) == seenEdges.end()) {
*outIt++ = *it;
seenEdges.insert(it->target);
}
}
block.edges.erase(outIt, block.edges.end());
}
}
void DisassemblerGraphView::prepareHeader()
{
QString afcf = Core()->cmd("afcf").trimmed();

View File

@ -158,6 +158,7 @@ private:
void initFont();
void prepareGraphNode(GraphBlock &block);
void cleanupEdges();
void prepareHeader();
Token *getToken(Instr *instr, int x);
QPoint getTextOffset(int line) const;