Rizin
unix-like reverse engineering framework and cli tools
|
Validation/Type Checking of RzIL Code. More...
#include <rz_il/rz_il_vm.h>
Go to the source code of this file.
Typedefs | |
typedef char * | RzILValidateReport |
typedef struct rz_il_validate_global_context_t | RzILValidateGlobalContext |
Functions | |
RZ_API RzILValidateGlobalContext * | rz_il_validate_global_context_new_empty (ut32 pc_len) |
RZ_API void | rz_il_validate_global_context_add_var (RzILValidateGlobalContext *ctx, RZ_NONNULL const char *name, RzILSortPure sort) |
RZ_API void | rz_il_validate_global_context_add_mem (RzILValidateGlobalContext *ctx, RzILMemIndex idx, ut32 key_len, ut32 val_len) |
RZ_API RzILValidateGlobalContext * | rz_il_validate_global_context_new_from_vm (RZ_NONNULL RzILVM *vm) |
RZ_API void | rz_il_validate_global_context_free (RzILValidateGlobalContext *ctx) |
RZ_API bool | rz_il_validate_pure (RZ_NULLABLE RzILOpPure *op, RZ_NONNULL RzILValidateGlobalContext *ctx, RZ_NULLABLE RZ_OUT RzILSortPure *sort_out, RZ_NULLABLE RZ_OUT RzILValidateReport *report_out) |
RZ_API bool | rz_il_validate_effect (RZ_NULLABLE RzILOpEffect *op, RZ_NONNULL RzILValidateGlobalContext *ctx, RZ_NULLABLE RZ_OUT HtPP **local_var_sorts_out, RZ_NULLABLE RZ_OUT RzILTypeEffect *type_out, RZ_NULLABLE RZ_OUT RzILValidateReport *report_out) |
Validation/Type Checking of RzIL Code.
Definition in file rz_il_validate.h.
typedef struct rz_il_validate_global_context_t RzILValidateGlobalContext |
Global context for validation, defining:
Definition at line 18 of file rz_il_validate.h.
typedef char* RzILValidateReport |
Definition at line 18 of file rz_il_validate.h.
RZ_API bool rz_il_validate_effect | ( | RZ_NULLABLE RzILOpEffect * | op, |
RZ_NONNULL RzILValidateGlobalContext * | ctx, | ||
RZ_NULLABLE RZ_OUT HtPP ** | local_var_sorts_out, | ||
RZ_NULLABLE RZ_OUT RzILTypeEffect * | type_out, | ||
RZ_NULLABLE RZ_OUT RzILValidateReport * | report_out | ||
) |
Run validation (type-checking and other checks) on an effect. op
the op to be checked. May be null, which will always be reported as invalid. ctx
global context, defining available global vars and mems local_var_sorts_out
optionally returns a map of local variable names defined in the effect to their sorts type_put
optionally returns the type of effects that the ops perform, i.e. ctrl, data, both or none report_out
optionally returns a readable report containing details about why the validation failed
ctx
Definition at line 846 of file il_validate.c.
References local_context_fini(), local_context_init(), LocalContext::local_vars_known, NULL, RZ_IL_TYPE_EFFECT_NONE, rz_str_trim_tail(), rz_strbuf_drain_nofree(), rz_strbuf_fini(), rz_strbuf_init(), rz_strbuf_is_empty(), type, valid, and validate_effect().
Referenced by print_and_check_il().
RZ_API void rz_il_validate_global_context_add_mem | ( | RzILValidateGlobalContext * | ctx, |
RzILMemIndex | idx, | ||
ut32 | key_len, | ||
ut32 | val_len | ||
) |
Define a new memory in ctx
Definition at line 69 of file il_validate.c.
References setup::idx, rz_return_if_fail, and ut64().
Referenced by rz_il_validate_global_context_new_from_vm().
RZ_API void rz_il_validate_global_context_add_var | ( | RzILValidateGlobalContext * | ctx, |
RZ_NONNULL const char * | name, | ||
RzILSortPure | sort | ||
) |
Define a new global variable in ctx
Definition at line 56 of file il_validate.c.
References RZ_NEW, and rz_return_if_fail.
Referenced by rz_il_validate_global_context_new_from_vm().
RZ_API void rz_il_validate_global_context_free | ( | RzILValidateGlobalContext * | ctx | ) |
RZ_API RzILValidateGlobalContext* rz_il_validate_global_context_new_empty | ( | ut32 | pc_len | ) |
Create a new global context for validation Vars and mems can be added manually with rz_il_validate_global_context_add_* functions.
Definition at line 32 of file il_validate.c.
References free(), NULL, RZ_NEW0, rz_return_val_if_fail, and var_kv_free().
Referenced by rz_il_validate_global_context_new_from_vm().
RZ_API RzILValidateGlobalContext* rz_il_validate_global_context_new_from_vm | ( | RZ_NONNULL RzILVM * | vm | ) |
Create a new context for IL validation based on the global vars and mems in vm
Definition at line 77 of file il_validate.c.
References i, mem, rz_il_var_t::name, NULL, rz_il_mem_key_len(), rz_il_mem_value_len(), rz_il_validate_global_context_add_mem(), rz_il_validate_global_context_add_var(), rz_il_validate_global_context_new_empty(), RZ_IL_VAR_KIND_GLOBAL, rz_il_vm_get_all_vars(), rz_il_vm_get_pc_len(), rz_pvector_at(), rz_pvector_foreach, rz_pvector_free(), rz_pvector_len(), rz_return_val_if_fail, and rz_il_var_t::sort.
Referenced by print_and_check_il().
RZ_API bool rz_il_validate_pure | ( | RZ_NULLABLE RzILOpPure * | op, |
RZ_NONNULL RzILValidateGlobalContext * | ctx, | ||
RZ_NULLABLE RZ_OUT RzILSortPure * | sort_out, | ||
RZ_NULLABLE RZ_OUT RzILValidateReport * | report_out | ||
) |
Run validation (type-checking and other checks) on a pure expression and determine its sort. op
the op to be checked. May be null, which will always be reported as invalid. ctx
global context, defining available global vars and mems sort_out
optionally returns the sort of the expression, if it is valid report_out
optionally returns a readable report containing details about why the validation failed
ctx
Definition at line 584 of file il_validate.c.
References local_context_fini(), local_context_init(), NULL, rz_str_trim_tail(), rz_strbuf_drain_nofree(), rz_strbuf_fini(), rz_strbuf_init(), rz_strbuf_is_empty(), local_pure_var_t::sort, valid, and validate_pure().