mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 11:26:11 +00:00
Add double click to seek to global var in decompiler (#2871)
This commit is contained in:
parent
138078a6f4
commit
5c4ba4891d
@ -115,6 +115,28 @@ Decompiler *DecompilerWidget::getCurrentDecompiler()
|
|||||||
return Core()->getDecompilerById(ui->decompilerComboBox->currentData().toString());
|
return Core()->getDecompilerById(ui->decompilerComboBox->currentData().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ut64 DecompilerWidget::findReference(size_t pos)
|
||||||
|
{
|
||||||
|
size_t closestPos = SIZE_MAX;
|
||||||
|
ut64 closestOffset = RVA_INVALID;
|
||||||
|
void *iter;
|
||||||
|
rz_vector_foreach(&code->annotations, iter)
|
||||||
|
{
|
||||||
|
RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter;
|
||||||
|
|
||||||
|
if (!(annotation->type == RZ_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE)
|
||||||
|
|| annotation->start > pos || annotation->end <= pos) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (closestPos != SIZE_MAX && closestPos >= annotation->start) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
closestPos = annotation->start;
|
||||||
|
closestOffset = annotation->reference.offset;
|
||||||
|
}
|
||||||
|
return closestOffset;
|
||||||
|
}
|
||||||
|
|
||||||
ut64 DecompilerWidget::offsetForPosition(size_t pos)
|
ut64 DecompilerWidget::offsetForPosition(size_t pos)
|
||||||
{
|
{
|
||||||
size_t closestPos = SIZE_MAX;
|
size_t closestPos = SIZE_MAX;
|
||||||
@ -123,7 +145,8 @@ ut64 DecompilerWidget::offsetForPosition(size_t pos)
|
|||||||
rz_vector_foreach(&code->annotations, iter)
|
rz_vector_foreach(&code->annotations, iter)
|
||||||
{
|
{
|
||||||
RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter;
|
RzCodeAnnotation *annotation = (RzCodeAnnotation *)iter;
|
||||||
if (annotation->type != RZ_CODE_ANNOTATION_TYPE_OFFSET || annotation->start > pos
|
|
||||||
|
if (!(annotation->type == RZ_CODE_ANNOTATION_TYPE_OFFSET) || annotation->start > pos
|
||||||
|| annotation->end <= pos) {
|
|| annotation->end <= pos) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -479,8 +502,11 @@ void DecompilerWidget::showDecompilerContextMenu(const QPoint &pt)
|
|||||||
void DecompilerWidget::seekToReference()
|
void DecompilerWidget::seekToReference()
|
||||||
{
|
{
|
||||||
size_t pos = ui->textEdit->textCursor().position();
|
size_t pos = ui->textEdit->textCursor().position();
|
||||||
RVA offset = offsetForPosition(pos);
|
RVA offset = findReference(pos);
|
||||||
seekable->seekToReference(offset);
|
if (offset != RVA_INVALID) {
|
||||||
|
seekable->seek(offset);
|
||||||
|
}
|
||||||
|
seekable->seekToReference(offsetForPosition(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecompilerWidget::eventFilter(QObject *obj, QEvent *event)
|
bool DecompilerWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
@ -198,6 +198,18 @@ private:
|
|||||||
* @param endPos - Position of the end of the range(inclusive).
|
* @param endPos - Position of the end of the range(inclusive).
|
||||||
*/
|
*/
|
||||||
void gatherBreakpointInfo(RzAnnotatedCode &codeDecompiled, size_t startPos, size_t endPos);
|
void gatherBreakpointInfo(RzAnnotatedCode &codeDecompiled, size_t startPos, size_t endPos);
|
||||||
|
/**
|
||||||
|
* @brief Finds the global variable reference that's closes to the specified position in the
|
||||||
|
* decompiled code. Same as offsetForPosition but for global references only
|
||||||
|
*
|
||||||
|
* @note If no global reference annotations are found at the given position, an RVA_INVALID is
|
||||||
|
* returned
|
||||||
|
*
|
||||||
|
* @param pos - Position in the decompiled code
|
||||||
|
* @return Address of the referenced global for the specified position, or RVA_INVALID if none
|
||||||
|
* is found
|
||||||
|
*/
|
||||||
|
ut64 findReference(size_t pos);
|
||||||
/**
|
/**
|
||||||
* @brief Finds the offset that's closest to the specified position in the decompiled code.
|
* @brief Finds the offset that's closest to the specified position in the decompiled code.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user