Hex-Rays' blog

Igor’s tip of the week #100: Collapsing pseudocode parts – Hex Rays

Written by Igor Skochinsky | Jul 28, 2022

When working with big functions in the decompiler, it may be useful to temporarily hide some parts of the pseudocode to analyze the rest. While currently it’s not possible to hide arbitrary lines like in disassembly, you can hide specific sections of it.

 

Collapsing local variable declarations

While the local variable declarations are useful to see the overall layout of the stack frame and other interesting info, in big functions they may take up a lot of valuable screen estate. To get them out of the way, you can use “Collapse declarations…” from the context menu, or the - key on the numpad.

This replaces the declarations with a single comment line. To show them again, use “Uncollapse declarations..” or the numpad + key.

To always collapse the declarations by default, set COLLAPSE_LVARS option in cfg/hexrays.cfg.

Collapsing statements

Compound statements can be collapsed too: if and switch statements, as well as for, while, and do loops. This can be done using the “Collapse item” context menu command, or the same numpad - shortcut.

After collapsing, the whole statement is replaced by one line with the keyword and ellipsis:

And can be uncollapsed again from context menu or the numpad + key.

You can use this approach to progressively hide analyzed code and tackle long functions piece by piece.

 

See also

Hex-Rays interactive operation: Hide/unhide C statements (hex-rays.com)