Files
reverse-engineering-anything/scripts
morluto 06fa8d0634 perf(ghidra): decompile upcoming export functions in parallel (#14847)
* fix(ghidra): reuse completed decompiles and decompile code outside functions

* perf(ghidra): decompile upcoming export functions in parallel

* fix(ghidra): say what the procedure inventory omits and how to reach it

* fix(ghidra): say when a file offset maps to code outside every function

A file-offset selector that mapped to disassembled code without a function
failed with advice to choose an inventory procedure, which cannot name that
code. The failure now states the fact and that procedure_pseudo_code can
decompile it by the mapped analysis address.

One predicate now decides that an address holds code outside every function
for the address, file-offset and procedure_not_found paths, and the bridge
imports UndefinedFunction and SoftReference like its other dependencies.

* fix(ghidra): scope decompile read-ahead to the operation it prepares

The bridge ran the read-ahead window in the generic serve loop, before the
ping, analysis-incomplete and read-only checks and for any method that
carried the field. It now runs only for procedure_pseudo_code, after those
checks. The pool state sits with the other decompiler fields and its Ghidra
types are imported.

The export tests now cover consecutive windows, a limit that ends inside a
window and a window whose first function sends no decompile request. The
provider guide states that a function failing or timing out inside a window
is attempted again by its own request, and how long the pool lives.

* fix(ghidra): decompile code outside functions selected by file offset

A file offset names the same location as its mapped analysis address, but
an offset that mapped to code Ghidra disassembled without a function was
refused while the address decompiled. The offset now resolves through the
same on-the-fly UndefinedFunction path and limitation, and its selection
reports the inferred entry as procedure_address. The refusal that sent the
caller back to the address form is removed.

* fix(ghidra): bound decompile read-ahead by the carrying request's deadline

A request that carried a read-ahead window waited for every function in it,
then decompiled its own function again when the window's attempt failed or
timed out, so one configured deadline could elapse twice. That request now
waits only within its own deadline, consumes the window's outcome for its
function whatever it is, and cancels siblings still running once it has its
result and the deadline has passed; they stay uncached for their own requests.

The hint is advisory, so selectors past one window are now ignored instead
of refusing the request. Pooled decompilers run on a private thread pool
rather than resizing Ghidra's shared "Parallel Decompiler" pool, and are
released after 30 seconds without a window.

* test(ghidra): cover read-ahead deadline and hint clamp on real Ghidra

The decompiler failure probe now injects a read-ahead window whose carrying
function times out beside a sibling that never finishes. It checks that the
request reports the timeout without decompiling again, waits only within its
deadline, leaves the cancelled sibling uncached, uses REA's own thread pool,
and that a longer hint is clamped to one window.

The probe no longer ran against the current bridge: it used a removed
three-argument Request constructor, expected the old timeout and failure
wording, and injected decompilers that completed-result reuse never called.
It now builds full requests, matches the current messages by prefix and
clears reused results before each injection.

* fix(ghidra): keep reused decompiles across reads without decompiler options

A request that omits decompile_max_payload_mib now leaves the session's
payload limit unchanged instead of resetting it to the Ghidra default,
so an instruction or metadata read no longer discards completed
decompiles. An explicit null still selects the installed default.

Boundary limitations for a reused decompile of code outside every
function now use the function the decompile widened, not a fresh
entry-only UndefinedFunction.

* docs(ghidra): state what an omitted decompiler payload option means

* fix(decompile-all): plan read-ahead from the decision the export loop makes

The read-ahead window decided which functions would be requested from
journal history alone. A journaled write whose file was later deleted
is requested again, and file problems spend the caller's limit, so a
resume could prepare functions outside its limit while the ones it
requested got no preparation.

Each function is now decided once by the same check the loop uses. The
window keeps those decisions for the loop, counts every attempt against
the limit, and names only functions that will be decompiled.

* test(ghidra): cover payload-option omission and reused undefined-function bodies

* fix(decompile-all): start each read-ahead hint at the function that sends it

A function the window named first could send no decompile request, for
example when procedure_info classifies it as external, so the next
request sent a hint headed by that function. A provider reads the head
as the carrying request's own function, so the bridge could not keep
that request's window result and might decompile it again.

The request now takes the planned window from its own function on.
2026-11-27 10:39:26 +00:00
..