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 committed Sep 4, 2023
1 parent f3e35a1 commit 2730244
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 2730244

Please sign in to comment.