Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Functions | |
RZ_API RZ_OWN RzCallable * | rz_type_callable_new (RZ_NULLABLE const char *name) |
Creates a new RzCallable type. More... | |
RZ_API RZ_OWN RzCallable * | rz_type_callable_clone (RZ_BORROW RZ_NONNULL const RzCallable *callable) |
Creates an exact clone of the RzCallable type. More... | |
RZ_API void | rz_type_callable_free (RZ_NONNULL RzCallable *callable) |
Frees the RzCallable. More... | |
RZ_API RZ_OWN RzCallableArg * | rz_type_callable_arg_new (RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_OWN RZ_NONNULL RzType *type) |
Creates a new RzCallableArg given the name and type. More... | |
RZ_API RZ_OWN RzCallableArg * | rz_type_callable_arg_clone (RZ_BORROW RZ_NONNULL const RzCallableArg *arg) |
Creates am exact clone of RzCallableArg. More... | |
RZ_API void | rz_type_callable_arg_free (RzCallableArg *arg) |
Frees the RzCallableArg. More... | |
RZ_API bool | rz_type_callable_arg_add (RZ_NONNULL RzCallable *callable, RZ_OWN RZ_NONNULL RzCallableArg *arg) |
Adds a new argument to the RzCallable. More... | |
RZ_API RZ_OWN RzCallable * | rz_type_func_new (RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_OWN RZ_NULLABLE RzType *type) |
Creates a new RzCallable type. More... | |
RZ_API bool | rz_type_func_save (RzTypeDB *typedb, RZ_NONNULL RzCallable *callable) |
Stores RzCallable type in the types database. More... | |
RZ_API RZ_BORROW RzCallable * | rz_type_func_get (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Returns the RzCallable from the database by name. More... | |
RZ_API bool | rz_type_func_delete (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Removes RzCallable type from the types database. More... | |
static void | callables_ht_free (HtPPKv *kv) |
RZ_API void | rz_type_func_delete_all (RzTypeDB *typedb) |
Removes all RzCallable types. More... | |
RZ_API bool | rz_type_func_exist (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Checks if the RzCallable type exists in the database given the name. More... | |
RZ_API RZ_BORROW RzType * | rz_type_func_ret (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Searches for the RzCallable type in types database and returns return type. More... | |
RZ_API RZ_BORROW const char * | rz_type_func_cc (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Searches for the RzCallable type in types database and returns calling convention. More... | |
RZ_API bool | rz_type_func_cc_set (RzTypeDB *typedb, const char *name, const char *cc) |
Searches for the RzCallable type in types database and set the calling convention. More... | |
RZ_API int | rz_type_func_args_count (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Searches for the RzCallable type in types database and returns arguments' count. More... | |
RZ_API RZ_BORROW RzType * | rz_type_func_args_type (RzTypeDB *typedb, RZ_NONNULL const char *name, int i) |
Searches for the RzCallable type in types database and returns argument type. More... | |
RZ_API RZ_BORROW const char * | rz_type_func_args_name (RzTypeDB *typedb, RZ_NONNULL const char *name, int i) |
Searches for the RzCallable type in types database and returns argument name. More... | |
RZ_API bool | rz_type_func_arg_add (RzTypeDB *typedb, RZ_NONNULL const char *func_name, RZ_NONNULL const char *arg_name, RZ_OWN RZ_NONNULL RzType *arg_type) |
Adds a new argument to the RzCallable type at the end of the arguments vector. More... | |
RZ_API bool | rz_type_func_ret_set (RzTypeDB *typedb, const char *name, RZ_OWN RZ_NONNULL RzType *type) |
Sets the new return type for the RzCallable. More... | |
RZ_API bool | rz_type_is_callable (RZ_NONNULL const RzType *type) |
Checks if the RzType is the pointer to the RzCallable. More... | |
RZ_API bool | rz_type_is_callable_ptr (RZ_NONNULL const RzType *type) |
Checks if the RzType is the pointer to the RzCallable. More... | |
RZ_API bool | rz_type_is_callable_ptr_nested (RZ_NONNULL const RzType *type) |
Checks if the RzType is the nested pointer to the RzCallable. More... | |
static const RzCallable * | callable_ptr_unwrap (RZ_NONNULL const RzType *type, size_t *acc) |
static char * | callable_name_or_ptr (RZ_NONNULL const RzCallable *callable, size_t ptr_depth) |
static bool | callable_as_string (RzStrBuf *buf, const RzTypeDB *typedb, RZ_NONNULL const RzCallable *callable, size_t ptr_depth) |
RZ_API RZ_OWN char * | rz_type_callable_ptr_as_string (const RzTypeDB *typedb, RZ_NONNULL const RzType *type) |
Returns the callable pointer C representation. More... | |
RZ_API RZ_OWN char * | rz_type_callable_as_string (const RzTypeDB *typedb, RZ_NONNULL const RzCallable *callable) |
Returns the callable C representation. More... | |
RZ_API bool | rz_type_func_is_noreturn (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Checks if the RzCallable type is defined as "noreturn". More... | |
RZ_API bool | rz_type_func_noreturn_add (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Adds the "noreturn" attribute to the RzCallable type. More... | |
RZ_API bool | rz_type_func_noreturn_drop (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Drops the "noreturn" attribute from the RzCallable type. More... | |
static bool | function_names_collect_cb (void *user, const void *k, const void *v) |
RZ_API RZ_OWN RzList * | rz_type_function_names (RzTypeDB *typedb) |
Returns the list of all function type names. More... | |
static bool | noreturn_function_names_collect_cb (void *user, const void *k, const void *v) |
RZ_API RZ_OWN RzList * | rz_type_noreturn_function_names (RzTypeDB *typedb) |
Returns the list of all noreturn function type names. More... | |
|
static |
Definition at line 431 of file function.c.
References callable_name_or_ptr(), comma, free(), arg::name, NULL, rz_pvector_foreach, rz_return_val_if_fail, rz_str_get(), rz_strbuf_append(), rz_strbuf_appendf(), rz_type_as_string(), and rz_type_identifier_declaration_as_string().
Referenced by rz_type_callable_as_string(), and rz_type_callable_ptr_as_string().
|
inlinestatic |
Definition at line 422 of file function.c.
References rz_str_get(), rz_str_newf(), and strdup().
Referenced by callable_as_string().
|
static |
Definition at line 413 of file function.c.
References NULL, rz_return_val_if_fail, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_POINTER, and type.
Referenced by rz_type_callable_ptr_as_string().
|
static |
Definition at line 185 of file function.c.
References rz_type_callable_free().
Referenced by rz_type_func_delete_all().
Definition at line 555 of file function.c.
References rz_callable_at::name, rz_list_append(), strdup(), and v.
Referenced by rz_type_function_names().
|
static |
Definition at line 574 of file function.c.
References rz_callable_at::name, rz_callable_at::noret, rz_list_append(), strdup(), and v.
Referenced by rz_type_noreturn_function_names().
RZ_API bool rz_type_callable_arg_add | ( | RZ_NONNULL RzCallable * | callable, |
RZ_OWN RZ_NONNULL RzCallableArg * | arg | ||
) |
Adds a new argument to the RzCallable.
callable | RzCallable instance |
arg | Argument to add |
Definition at line 116 of file function.c.
References rz_pvector_push(), and rz_return_val_if_fail.
Referenced by rz_analysis_fcn_vars_add_types(), and rz_analysis_function_derive_args().
RZ_API RZ_OWN RzCallableArg* rz_type_callable_arg_clone | ( | RZ_BORROW RZ_NONNULL const RzCallableArg * | arg | ) |
Creates am exact clone of RzCallableArg.
arg | RzCallable argument pointer |
Definition at line 85 of file function.c.
References arg::name, rz_callable_arg_t::name, NULL, RZ_NEW0, rz_return_val_if_fail, rz_type_clone(), strdup(), and rz_callable_arg_t::type.
Referenced by rz_type_callable_clone().
RZ_API void rz_type_callable_arg_free | ( | RzCallableArg * | arg | ) |
Frees the RzCallableArg.
arg | RzCallableArg instance |
Definition at line 101 of file function.c.
References free(), arg::name, and rz_type_free().
Referenced by c_parser_new_callable(), c_parser_new_naked_callable(), get_callable_type(), parse_type_mfunction(), parse_type_procedure(), rz_type_callable_clone(), and rz_type_callable_new().
RZ_API RZ_OWN RzCallableArg* rz_type_callable_arg_new | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name, | ||
RZ_OWN RZ_NONNULL RzType * | type | ||
) |
Creates a new RzCallableArg given the name and type.
typedb | RzTypeDB instance |
name | Name of the argument |
type | RzType type of the argument |
Definition at line 69 of file function.c.
References arg(), arg::name, NULL, RZ_NEW0, rz_return_val_if_fail, strdup(), and type.
Referenced by rz_analysis_fcn_vars_add_types(), rz_analysis_function_derive_args(), and rz_type_func_arg_add().
RZ_API RZ_OWN char* rz_type_callable_as_string | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const RzCallable * | callable | ||
) |
Returns the callable C representation.
typedb | Types Database instance |
callable | RzCallable instance |
Definition at line 487 of file function.c.
References callable_as_string(), NULL, rz_return_val_if_fail, rz_strbuf_drain(), rz_strbuf_free(), and rz_strbuf_new().
Referenced by rz_analysis_function_get_signature(), rz_core_types_function_print(), and type_decl_as_pretty_string().
RZ_API RZ_OWN RzCallable* rz_type_callable_clone | ( | RZ_BORROW RZ_NONNULL const RzCallable * | callable | ) |
Creates an exact clone of the RzCallable type.
callable | RzCallable instance to clone |
Definition at line 33 of file function.c.
References rz_callable_at::args, rz_callable_at::name, NULL, rz_callable_at::ret, RZ_NEW0, rz_pvector_foreach, rz_pvector_new(), rz_pvector_push(), rz_return_val_if_fail, rz_type_callable_arg_clone(), rz_type_callable_arg_free(), rz_type_clone(), and strdup().
Referenced by rz_analysis_function_clone_type(), and rz_type_clone().
RZ_API void rz_type_callable_free | ( | RZ_NONNULL RzCallable * | callable | ) |
Frees the RzCallable.
callable | RzCallable type |
Definition at line 55 of file function.c.
References free(), rz_pvector_free(), and rz_type_free().
Referenced by callables_ht_free(), get_callable_type(), rz_analysis_function_derive_args(), rz_analysis_function_get_signature(), and type_match().
RZ_API RZ_OWN RzCallable* rz_type_callable_new | ( | RZ_NULLABLE const char * | name | ) |
Creates a new RzCallable type.
name | Name of the callable type |
type | A return type of the callable type |
Definition at line 17 of file function.c.
References rz_callable_at::args, rz_callable_at::name, NULL, rz_callable_at::ret, RZ_NEW0, rz_pvector_new(), rz_type_callable_arg_free(), and strdup().
Referenced by rz_type_func_new().
RZ_API RZ_OWN char* rz_type_callable_ptr_as_string | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const RzType * | type | ||
) |
Returns the callable pointer C representation.
typedb | Types Database instance |
callable | RzCallable instance |
Definition at line 464 of file function.c.
References callable_as_string(), callable_ptr_unwrap(), NULL, rz_return_val_if_fail, rz_strbuf_drain(), rz_strbuf_free(), rz_strbuf_new(), RZ_TYPE_KIND_POINTER, and type.
Referenced by type_decl_as_pretty_string().
RZ_API bool rz_type_func_arg_add | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | func_name, | ||
RZ_NONNULL const char * | arg_name, | ||
RZ_OWN RZ_NONNULL RzType * | arg_type | ||
) |
Adds a new argument to the RzCallable type at the end of the arguments vector.
typedb | Type Database instance |
func_name | Name of the callable to search |
arg_name | Name of the new argument |
arg_type | RzType type of the new argument |
Definition at line 327 of file function.c.
References rz_callable_at::args, rz_pvector_push(), rz_return_val_if_fail, rz_type_callable_arg_new(), and rz_type_func_get().
RZ_API int rz_type_func_args_count | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Searches for the RzCallable type in types database and returns arguments' count.
typedb | Type Database instance |
name | Name of the callable to search |
Definition at line 262 of file function.c.
References rz_callable_at::args, rz_pvector_len(), rz_return_val_if_fail, and rz_type_func_get().
Referenced by ds_print_calls_hints(), ds_print_esil_analysis(), extract_arg(), rz_analysis_extract_rarg(), rz_analysis_fcn_format_sig(), rz_core_analysis_function_signature(), rz_core_get_func_args(), and type_match().
RZ_API RZ_BORROW const char* rz_type_func_args_name | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name, | ||
int | i | ||
) |
Searches for the RzCallable type in types database and returns argument name.
typedb | Type Database instance |
name | Name of the callable to search |
i | Index of the argument go get type of |
Definition at line 302 of file function.c.
References rz_callable_at::args, i, arg::name, NULL, rz_pvector_index_ptr(), rz_pvector_len(), rz_return_val_if_fail, rz_type_func_get(), and rz_warn_if_reached.
Referenced by ds_print_calls_hints(), extract_arg(), rz_analysis_extract_rarg(), rz_analysis_fcn_format_sig(), rz_analysis_function_get_json(), and set_fcn_args_info().
RZ_API RZ_BORROW RzType* rz_type_func_args_type | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name, | ||
int | i | ||
) |
Searches for the RzCallable type in types database and returns argument type.
typedb | Type Database instance |
name | Name of the callable to search |
i | Index of the argument go get type of |
Definition at line 278 of file function.c.
References rz_callable_at::args, i, NULL, rz_pvector_index_ptr(), rz_pvector_len(), rz_return_val_if_fail, rz_type_func_get(), and rz_warn_if_reached.
Referenced by ds_print_calls_hints(), extract_arg(), rz_analysis_extract_rarg(), rz_analysis_fcn_format_sig(), rz_analysis_function_get_json(), and set_fcn_args_info().
Searches for the RzCallable type in types database and returns calling convention.
typedb | Type Database instance |
name | Name of the callable to search |
Definition at line 230 of file function.c.
References rz_callable_at::cc, NULL, rz_return_val_if_fail, and rz_type_func_get().
Referenced by rz_analysis_cc_func(), and rz_type_function_cc_handler().
Searches for the RzCallable type in types database and set the calling convention.
typedb | Type Database instance |
name | Name of the callable to search |
name | Name of the calling convention to set |
Definition at line 246 of file function.c.
References rz_callable_at::cc, rz_return_val_if_fail, rz_type_func_get(), and strdup().
Referenced by rz_type_function_cc_handler().
RZ_API bool rz_type_func_delete | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Removes RzCallable type from the types database.
typedb | Type Database instance |
name | Name of the callable to search |
Definition at line 179 of file function.c.
References rz_type_db_t::callables, and rz_return_val_if_fail.
Referenced by rz_analysis_function_set_type_str(), rz_type_db_del(), and rz_type_function_del_handler().
Removes all RzCallable types.
Definition at line 192 of file function.c.
References rz_type_db_t::callables, callables_ht_free(), and NULL.
Referenced by rz_type_function_del_all_handler().
RZ_API bool rz_type_func_exist | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Checks if the RzCallable type exists in the database given the name.
typedb | Type Database instance |
name | Name of the callable to search |
Definition at line 203 of file function.c.
References rz_type_db_t::callables, found, and rz_return_val_if_fail.
Referenced by ds_print_calls_hints(), function_name_try_guess(), propagate_types_among_used_variables(), resolve_fcn_name(), rz_analysis_fcn_format_sig(), rz_analysis_fcn_vars_add_types(), rz_analysis_function_set_type_str(), rz_analysis_noreturn_add(), rz_type_db_del(), and rz_type_func_save().
RZ_API RZ_BORROW RzCallable* rz_type_func_get | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Returns the RzCallable from the database by name.
typedb | Type Database instance |
name | RzCallable (function) name to search |
Definition at line 162 of file function.c.
References rz_type_db_t::callables, found, NULL, RZ_LOG_DEBUG, and rz_return_val_if_fail.
Referenced by function_type_derive(), rz_analysis_function_clone_type(), rz_core_types_function_print(), rz_type_func_arg_add(), rz_type_func_args_count(), rz_type_func_args_name(), rz_type_func_args_type(), rz_type_func_cc(), rz_type_func_cc_set(), rz_type_func_is_noreturn(), rz_type_func_noreturn_add(), rz_type_func_noreturn_drop(), rz_type_func_ret(), and rz_type_func_ret_set().
RZ_API bool rz_type_func_is_noreturn | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Checks if the RzCallable type is defined as "noreturn".
typedb | Types Database instance |
name | Name of the RzCallable type |
Definition at line 503 of file function.c.
References rz_callable_at::noret, rz_return_val_if_fail, and rz_type_func_get().
Referenced by rz_analysis_is_noreturn().
RZ_API RZ_OWN RzCallable* rz_type_func_new | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name, | ||
RZ_OWN RZ_NULLABLE RzType * | type | ||
) |
Creates a new RzCallable type.
typedb | RzTypeDB instance |
name | Name of the callable type |
type | A return type of the callable type |
Definition at line 131 of file function.c.
References NULL, rz_callable_at::ret, rz_return_val_if_fail, rz_type_callable_new(), and type.
Referenced by get_callable_type(), rz_analysis_fcn_vars_add_types(), rz_analysis_function_create_type(), and rz_type_func_noreturn_add().
RZ_API bool rz_type_func_noreturn_add | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Adds the "noreturn" attribute to the RzCallable type.
typedb | Types Database instance |
name | Name of the RzCallable type |
Definition at line 518 of file function.c.
References rz_callable_at::noret, NULL, rz_return_val_if_fail, rz_type_func_get(), rz_type_func_new(), and rz_type_func_save().
Referenced by rz_type_list_noreturn_handler().
RZ_API bool rz_type_func_noreturn_drop | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Drops the "noreturn" attribute from the RzCallable type.
typedb | Types Database instance |
name | Name of the RzCallable type |
Definition at line 543 of file function.c.
References rz_callable_at::noret, rz_return_val_if_fail, and rz_type_func_get().
Referenced by rz_type_noreturn_del_all_handler(), and rz_type_noreturn_del_handler().
Searches for the RzCallable type in types database and returns return type.
typedb | Type Database instance |
name | Name of the callable to search |
Definition at line 215 of file function.c.
References NULL, rz_callable_at::ret, rz_return_val_if_fail, and rz_type_func_get().
Referenced by ds_print_calls_hints(), ds_print_esil_analysis(), propagate_types_among_used_variables(), rz_analysis_fcn_format_sig(), rz_analysis_function_get_json(), and rz_core_analysis_function_signature().
RZ_API bool rz_type_func_ret_set | ( | RzTypeDB * | typedb, |
const char * | name, | ||
RZ_OWN RZ_NONNULL RzType * | type | ||
) |
Sets the new return type for the RzCallable.
typedb | Type Database instance |
name | Name of the callable to search |
type | RzType return type |
Definition at line 348 of file function.c.
References rz_callable_at::ret, rz_return_val_if_fail, rz_type_func_get(), and type.
Referenced by rz_analysis_function_signature_type_handler().
RZ_API bool rz_type_func_save | ( | RzTypeDB * | typedb, |
RZ_NONNULL RzCallable * | callable | ||
) |
Stores RzCallable type in the types database.
typedb | Type Database instance |
callable | RzCallable type to save |
Definition at line 147 of file function.c.
References rz_type_db_t::callables, rz_return_val_if_fail, and rz_type_func_exist().
Referenced by parse_type_mfunction(), parse_type_procedure(), rz_analysis_fcn_vars_add_types(), rz_analysis_function_get_arg_count(), and rz_type_func_noreturn_add().
Returns the list of all function type names.
typedb | Types Database instance |
Definition at line 567 of file function.c.
References rz_type_db_t::callables, free(), function_names_collect_cb(), NULL, rz_list_newf(), and rz_return_val_if_fail.
Referenced by rz_core_types_function_print_all().
RZ_API bool rz_type_is_callable | ( | RZ_NONNULL const RzType * | type | ) |
Checks if the RzType is the pointer to the RzCallable.
typedb | Types Database instance |
type | RzType |
Definition at line 364 of file function.c.
References rz_return_val_if_fail, RZ_TYPE_KIND_CALLABLE, and type.
RZ_API bool rz_type_is_callable_ptr | ( | RZ_NONNULL const RzType * | type | ) |
Checks if the RzType is the pointer to the RzCallable.
typedb | Types Database instance |
type | RzType |
Definition at line 375 of file function.c.
References rz_return_val_if_fail, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_POINTER, and type.
Referenced by rz_type_as_format().
RZ_API bool rz_type_is_callable_ptr_nested | ( | RZ_NONNULL const RzType * | type | ) |
Checks if the RzType is the nested pointer to the RzCallable.
For example it could be one of those:
typedb | Types Database instance |
type | RzType |
Definition at line 399 of file function.c.
References rz_type_t::kind, rz_return_val_if_fail, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_POINTER, and type.
Referenced by type_as_pretty_string(), type_decl_as_pretty_string(), and type_to_format_pair().
Returns the list of all noreturn function type names.
typedb | Types Database instance |
Definition at line 588 of file function.c.
References rz_type_db_t::callables, free(), noreturn_function_names_collect_cb(), NULL, rz_list_newf(), and rz_return_val_if_fail.
Referenced by rz_analysis_noreturn_functions(), rz_core_types_function_noreturn_print(), and rz_type_noreturn_del_all_handler().