Skip to content

decompiler: Implement variable values tooltip in debugging#3572

Open
i-m00n wants to merge 5 commits intorizinorg:devfrom
i-m00n:decompiler-tooltip-dereference
Open

decompiler: Implement variable values tooltip in debugging#3572
i-m00n wants to merge 5 commits intorizinorg:devfrom
i-m00n:decompiler-tooltip-dereference

Conversation

@i-m00n
Copy link
Copy Markdown

@i-m00n i-m00n commented Mar 10, 2026

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've updated the documentation with the relevant information (if needed)
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

This PR enhances the decompiler's variable tooltips by implementing live string dereferencing as mentioned in #3344.

cutter.-.decompiler.tooltips.webm

Test plan (required)

Start a debug session and try moving to different break points and hover over various variables and check the tooltip.

Closing issues

it doesn't fully close #3344 or #2532 as it currently handles only explicitly tracked analysis variables.

Limitations

Synthetic/Untracked Variables: Does not currently handle variables that Rizin hasn't fully analyzed or "Synthetic" variables generated by the decompiler.


Configuration Toggle: Would you like me to add a checkbox in the Preferences settings to enable/disable this feature? Currently, it is always active

@i-m00n i-m00n changed the title Implement variable values tooltip in debugging decompiler: Implement variable values tooltip in debugging Mar 10, 2026
Comment thread src/widgets/DecompilerWidget.cpp Outdated
Comment thread src/widgets/DecompilerWidget.cpp Outdated
Comment thread src/widgets/DecompilerWidget.cpp Outdated
@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch from 2b97c60 to b5a8fc9 Compare March 12, 2026 00:53
@i-m00n
Copy link
Copy Markdown
Author

i-m00n commented Mar 12, 2026

  • Replaced the eq logic with rz_core_analysis_var_addr() to resolve variable addresses directly from the analysis core.

  • The tooltip now correctly handles both Stack and Register variables by checking var->storage.type (as we no longer count on rz_core_analysis_var_display to handle that logic).

  • Switched to rz_str_is_printable() instead of isprint() and strnlen() instead of assigning the null character manually.

  • removed hard-coded Synthetic variables tooltip

@i-m00n i-m00n requested a review from wargio March 12, 2026 01:03
@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch 2 times, most recently from 5e7c040 to cde2485 Compare March 16, 2026 22:02
@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch from cde2485 to 1ae564d Compare March 23, 2026 18:16
@Rot127
Copy link
Copy Markdown
Member

Rot127 commented Mar 24, 2026

@i-m00n Please add a video where you show off the changes.

@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch 2 times, most recently from 573f7a6 to d067e2d Compare March 28, 2026 21:53
@i-m00n
Copy link
Copy Markdown
Author

i-m00n commented Mar 28, 2026

Hi @wargio, just a quick follow-up on this when you have a moment. I've addressed the previous feedback and rebased the PR. Let me know if it's ready for another look!

also, I've updated the PR body with the required video.

Comment thread src/widgets/DecompilerWidget.cpp Outdated
Comment on lines +564 to +565
pointedAddr_state =
rz_io_read_at_mapped(core->io, stackAddr, (ut8 *)&pointedAddr, ptrSize);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you cannot do this. you should read to a buffer and then use rz_read_ble to get the correct pointerAddr value.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, thanks for this note, I’ve updated the logic to read the pointer into a ut8 ptrBuf[8] and then used rz_read_ble() with core->rasm->big_endian to ensure the address is correctly reconstructed regardless of the target architecture.

Comment thread src/widgets/DecompilerWidget.cpp Outdated
if (str_state) {
size_t len = strnlen((const char *)buf, sizeof(buf));
if (len > 0 && rz_str_is_printable((const char *)buf)) {
QString str = QString::fromUtf8((const char *)buf, len);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QString str = QString::fromUtf8((const char *)buf, len);
QString str = QString::fromUtf8((const char *)buf, len).toHtmlEscaped();;

Comment thread src/widgets/DecompilerWidget.cpp Outdated
}
}
}
return QString("%1 (%2)\nValue: %3").arg(QString::fromUtf8(var->name), typeStr, displayValue);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return QString("%1 (%2)\nValue: %3").arg(QString::fromUtf8(var->name), typeStr, displayValue);
return QString("%1 (%2)\nValue: %3").arg(QString::fromUtf8(var->name).toHtmlEscaped(), typeStr, displayValue);

Comment thread src/widgets/DecompilerWidget.cpp Outdated
rz_mem_free(rawVal);
if (typeStr.contains("*")) {
ut64 pointedAddr = 0;
int ptrSize = core->analysis->bits / 8;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get the bitness from rz_asm

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. I’m now pulling the bitness from core->rasm->bits.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update dev and use the method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify what method you'd like me to use for getting the bitness? I checked for rz_asm_get_bits but it's marked as RZ_DEPRECATE in rizin, and I don't see a corresponding wrapper in Cutter's API.

Also I’ve updated to the latest dev and refactored the register access to use the new Core()->getRegisterRefValue() helper introduced in #3570 .

@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch from d067e2d to 490fa01 Compare March 29, 2026 18:47
@i-m00n
Copy link
Copy Markdown
Author

i-m00n commented Mar 29, 2026

@wargio
I've updated this PR to use .toHtmlEscaped() for the decompiler tooltips as requested. While working on this, I noticed that the Disassembler widget tooltips exactly in src/common/DisassemblyPreview.cpp also seem to lack HTML escaping for certain variable outputs.

I'd be happy to open a separate PR to standardize this across the project if needed.

@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch 3 times, most recently from 0c9dc37 to 49761c5 Compare March 29, 2026 19:11
@i-m00n i-m00n requested a review from wargio March 29, 2026 22:22
@wargio
Copy link
Copy Markdown
Member

wargio commented Mar 30, 2026

I'd be happy to open a separate PR to standardize this across the project if needed.

later. finish this first.

Comment thread bits Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for that, it happened when I mistakenly ran rg rasm->bits, I should've put it in double quotes as the symbol > created a new bits file searching for the text rasm-.
now it's removed.

@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch 3 times, most recently from 0a8cae4 to 4dadd4b Compare March 30, 2026 15:43
@i-m00n i-m00n requested a review from wargio March 31, 2026 11:37
@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch from 4dadd4b to 15f8e32 Compare April 1, 2026 19:31
@i-m00n i-m00n force-pushed the decompiler-tooltip-dereference branch from 15f8e32 to c1cc178 Compare April 10, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show current values in debugger

3 participants