Skip to content

Commit

Permalink
Seek to first call if multiple references (#3240)
Browse files Browse the repository at this point in the history
  • Loading branch information
frmdstryr authored and XVilka committed Sep 14, 2023
1 parent 2066a4b commit 359bd91
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/common/CutterSeekable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,26 @@ void CutterSeekable::seekToReference(RVA offset)
return;
}

RVA target;
QList<XrefDescription> refs = Core()->getXRefs(offset, false, false);

if (refs.length()) {
if (refs.length() > 1) {
qWarning() << tr("More than one (%1) references here. Weird behaviour expected.")
.arg(refs.length());
}

target = refs.at(0).to;
if (target != RVA_INVALID) {
seek(target);
// Try first call
for (auto &ref : refs) {
if (ref.to != RVA_INVALID && ref.type == "CALL") {
seek(ref.to);
return;
}
}
// Fallback to first valid, if any
for (auto &ref : refs) {
if (ref.to != RVA_INVALID) {
seek(ref.to);
return;
}
}
}
}

0 comments on commit 359bd91

Please sign in to comment.