Let an analysis plugin provide the decompiler ##analysis - #26701
Closed
0verflowme wants to merge 1 commit into
Closed
0verflowme wants to merge 1 commit into
0verflowme wants to merge 1 commit into
Conversation
An analysis plugin can now carry a decompile callback. The best-scoring eligible plugin that has one is the decompiler provider; r_anal_decompile hands it a function and returns the RCodeMeta it renders, and pdd routes to it before the sdb fallback. The plugin receives the RAnalFunction itself rather than a capture format shaped for one consumer. Around that, the pieces such a provider needs from radare2 rather than reimplementing them: a dirty epoch on functions and on the type database so a provider can tell whether a cached result is stale; a read-only signature query that does not trigger type loading, and a way to ask whether a function has an address-linked prototype; r_anal_cc_location_uses exported so a convention's register roles can be matched against what a function touches; stackalloc, redzone and retmech keys in the calling convention tables; RBin bind entries for the relocation at an address and for the named binary symbols; and a post-analysis depth so aa, aaa and aaaa can tell plugins how much work is appropriate. Unit tests cover provider selection, the decompile wrapper and pdd routing.
0verflowme
force-pushed
the
pr/anal-decompiler-provider
branch
from
September 10, 2026 16:12
6d7be4f to
b5f7922
Compare
Collaborator
|
Providing decompilers from anal is a design topic that it shouldnt be discused in a pr also this pr ships many more changes than just this thing |
This was referenced Sep 11, 2026
Merged
Member
Author
|
Agreed on both counts, and withdrawn. r2sleigh does not register as a decompiler provider any more (it answers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets an analysis plugin act as the decompiler provider, and adds the small set of things such a provider needs from radare2 rather than reimplementing them.
Provider API
RAnalPlugin.decompile: a callback that renders oneRAnalFunctionto anRCodeMeta. The best-scoring eligible plugin that has one is the provider (r_anal_decompiler_provider), andr_anal_decompileinvokes it. Ties keep registration order.pdd [name|addr]routes to the provider before the existing sdb fallback command, sopdc?and the fallback keep working when no provider is registered.Facts the provider consumes
RAnalFunctionand on the type database, bumped on the mutations that change typed metadata (variables, signatures, calling convention, bits, maxstack, type links, type loads). A provider uses it to know whether a cached result is stale.r_anal_function_get_signature_currentandr_anal_function_has_address_linked_signature_current: read-only signature queries that do not trigger type loading, for use while analysis holds the lock.r_anal_cc_location_usesexported, case-insensitive on the register name, so a convention's roles can be matched against the registers a function touches.stackalloc,redzoneandretmechkeys in the calling convention tables, and they are cleared with the rest of the layout on redefinition.RBinBind.get_reloc_atandRBinBind.get_sym, so an analysis holding only the bind can ask what a relocated slot names.RAnalPluginAnalysisDepth:aa,aaaandaaaatell post-analysis hooks how much work is appropriate.Alongside
afsprints the stored signature when one exists before formatting from variables.afc <cc>goes throughr_anal_function_set_callconv, which validates and bumps the epoch.r_anal_function_deleterefuses a function it does not own and honoursR_ANAL_FUNCTION_DELETE_REFUSEfrom the delete callback.aaano longer re-imports DWARF when the bin layer declined for size; the size limit was being defeated on exactly the binaries it protects.Unit tests cover provider selection, the decompile wrapper and
pddrouting (test_anal_decompiler), the epoch bumps (test_anal_function), and the DWARF integration test is registered in meson again.Replaces #26646, which carried this together with the removal now in its own pull request.