Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Classes | |
struct | PrettyHelperBufs |
Functions | |
static void | types_ht_free (HtPPKv *kv) |
static void | formats_ht_free (HtPPKv *kv) |
static void | callables_ht_free (HtPPKv *kv) |
RZ_API RzTypeDB * | rz_type_db_new () |
Creates a new instance of the RzTypeDB. More... | |
RZ_API void | rz_type_db_free (RzTypeDB *typedb) |
Frees the instance of the RzTypeDB. More... | |
RZ_API void | rz_type_db_purge (RzTypeDB *typedb) |
Purges the instance of the RzTypeDB. More... | |
RZ_API void | rz_type_db_format_purge (RzTypeDB *typedb) |
Purges formats in the instance of the RzTypeDB. More... | |
static void | set_default_type (RzTypeTarget *target, int bits) |
RZ_API void | rz_type_db_set_bits (RzTypeDB *typedb, int bits) |
Set the RzType target architecture bits. More... | |
RZ_API void | rz_type_db_set_address_bits (RzTypeDB *typedb, int addr_bits) |
Set the RzType target adress size. More... | |
RZ_API void | rz_type_db_set_os (RzTypeDB *typedb, const char *os) |
Set the RzType target architecture operating system. More... | |
RZ_API void | rz_type_db_set_cpu (RzTypeDB *typedb, const char *cpu) |
Set the RzType target architecture CPU. More... | |
RZ_API void | rz_type_db_set_endian (RzTypeDB *typedb, bool big_endian) |
Set the RzType target architecture CPU. More... | |
RZ_API ut8 | rz_type_db_pointer_size (const RzTypeDB *typedb) |
Returns the pointer size for the current RzTypeDB target set. More... | |
RZ_API bool | rz_type_db_del (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Removes the type from the database. More... | |
RZ_API void | rz_type_db_init (RzTypeDB *typedb, const char *types_dir, const char *arch, int bits, const char *os) |
Initializes the types database for specified arch, bits, OS. More... | |
RZ_API void | rz_type_db_reload (RzTypeDB *typedb, const char *types_dir) |
Re-initializes the types database for current target. More... | |
RZ_API RZ_OWN RzList * | rz_type_db_enum_names (RzTypeDB *typedb) |
Returns the list of all enum names. More... | |
RZ_API RZ_OWN RzList * | rz_type_db_union_names (RzTypeDB *typedb) |
Returns the list of all union names. More... | |
RZ_API RZ_OWN RzList * | rz_type_db_struct_names (RzTypeDB *typedb) |
Returns the list of all struct names. More... | |
RZ_API RZ_OWN RzList * | rz_type_db_typedef_names (RzTypeDB *typedb) |
Returns the list of all typedef (type aliases) names. More... | |
RZ_API RZ_OWN RzList * | rz_type_db_all (RzTypeDB *typedb) |
Returns the list of all type names. More... | |
RZ_API bool | rz_type_exists (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Checks if the type exists in the Type database. More... | |
RZ_API int | rz_type_kind (RzTypeDB *typedb, RZ_NONNULL const char *name) |
Returns the kind (RzBaseTypeKind) of the type. More... | |
RZ_API RzBaseType * | rz_type_db_get_enum (const RzTypeDB *typedb, RZ_NONNULL const char *name) |
Returns the enum base type matching the specified name. More... | |
RZ_API RZ_BORROW const char * | rz_type_db_enum_member_by_val (const RzTypeDB *typedb, RZ_NONNULL const char *name, ut64 val) |
Returns the enum case name matching the cpecified value. More... | |
RZ_API int | rz_type_db_enum_member_by_name (const RzTypeDB *typedb, RZ_NONNULL const char *name, const char *member) |
Returns the enum case value matched by the enum case name. More... | |
RZ_API RZ_OWN RzList * | rz_type_db_find_enums_by_val (const RzTypeDB *typedb, ut64 val) |
Returns all enums and cases name matching the specified value. More... | |
RZ_API RZ_OWN char * | rz_type_db_enum_get_bitfield (const RzTypeDB *typedb, RZ_NONNULL const char *name, ut64 val) |
Returns all matching bitfields as an OR mask given the resulting value. More... | |
RZ_API RzBaseType * | rz_type_db_get_union (const RzTypeDB *typedb, RZ_NONNULL const char *name) |
Returns the union base type matching the specified name. More... | |
RZ_API RzBaseType * | rz_type_db_get_struct (const RzTypeDB *typedb, RZ_NONNULL const char *name) |
returns the struct base type matching the specified name More... | |
RZ_API RzBaseType * | rz_type_db_get_typedef (const RzTypeDB *typedb, RZ_NONNULL const char *name) |
Returns the typedef base type matching the specified name. More... | |
RZ_API ut64 | rz_type_db_atomic_bitsize (const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype) |
Returns the atomic type size in bits (target dependent) More... | |
RZ_API ut64 | rz_type_db_enum_bitsize (const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype) |
Returns the enum type size in bits (target dependent) More... | |
RZ_API ut64 | rz_type_db_struct_bitsize (const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype) |
Returns the struct type size in bits (target dependent) More... | |
RZ_API ut64 | rz_type_db_union_bitsize (const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype) |
Returns the union type size in bits (target dependent) More... | |
RZ_API ut64 | rz_type_db_typedef_bitsize (const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype) |
Returns the typedef type size in bits (target dependent) More... | |
RZ_API ut64 | rz_type_db_base_get_bitsize (const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype) |
Returns the base type size in bits (target dependent) More... | |
RZ_API ut64 | rz_type_db_get_bitsize (const RzTypeDB *typedb, RZ_NONNULL RzType *type) |
Returns the type size in bits (target dependent) More... | |
RZ_API RZ_OWN char * | rz_type_as_string (const RzTypeDB *typedb, RZ_NONNULL const RzType *type) |
Returns the type C representation. More... | |
RZ_API RZ_OWN char * | rz_type_declaration_as_string (const RzTypeDB *typedb, RZ_NONNULL const RzType *type) |
Returns the type C declaration representation. More... | |
RZ_API RZ_OWN char * | rz_type_identifier_declaration_as_string (const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RZ_NONNULL const char *identifier) |
Returns the type C representation with identifier. More... | |
static bool | type_decl_as_pretty_string (const RzTypeDB *typedb, const RzType *type, HtPP *used_types, struct PrettyHelperBufs phbuf, bool *self_ref, char **self_ref_typename, bool zero_vla, bool print_anon, bool show_typedefs) |
static char * | type_as_pretty_string (const RzTypeDB *typedb, const RzType *type, const char *identifier, HtPP *used_types, unsigned int opts, int unfold_level, int indent_level) |
RZ_API RZ_OWN char * | rz_type_as_pretty_string (const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RZ_NULLABLE const char *identifier, unsigned int opts, int unfold_level) |
Return a string contining the type pretty printed according to the options provided. More... | |
RZ_API RZ_BORROW const char * | rz_type_identifier (RZ_NONNULL const RzType *type) |
Returns the type C identifier. More... | |
RZ_API RZ_OWN RzType * | rz_type_clone (RZ_BORROW RZ_NONNULL const RzType *type) |
Creates an exact clone of the RzType. More... | |
RZ_API bool | rz_types_equal (RZ_NONNULL const RzType *type1, RZ_NONNULL const RzType *type2) |
Checks if two types are identical. More... | |
RZ_API RZ_BORROW RzBaseType * | rz_type_get_base_type (const RzTypeDB *typedb, RZ_NONNULL const RzType *type) |
Returns the RzBaseType for the chosen RzType. More... | |
RZ_API void | rz_type_free (RZ_NULLABLE RzType *type) |
Frees the RzType. More... | |
RZ_API bool | rz_type_db_edit_base_type (RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *typestr) |
Edits the existing base type given the new C code. More... | |
|
static |
Definition at line 22 of file type.c.
References free(), and rz_type_callable_free().
Referenced by rz_type_db_new(), and rz_type_db_purge().
|
static |
Definition at line 17 of file type.c.
References free().
Referenced by rz_type_db_format_purge(), and rz_type_db_new().
RZ_API RZ_OWN char* rz_type_as_pretty_string | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const RzType * | type, | ||
RZ_NULLABLE const char * | identifier, | ||
unsigned int | opts, | ||
int | unfold_level | ||
) |
Return a string contining the type pretty printed according to the options provided.
typedb | typedb for the current analysis |
type | type to be pretty printed |
identifier | name of the variable of the given type (RZ_NULLABLE) |
opts | options for pretty printing (see RzTypePrintOpts) |
unfold_level | level of unfolding to do in case of nested structures/unions (any negative number means maximum unfolding, i.e. INT32_MAX. 0 means no unfolding, just the typename and identifier, if any) |
Definition at line 1130 of file type.c.
References INT32_MAX, NULL, RZ_LOG_ERROR, rz_return_val_if_fail, type, and type_as_pretty_string().
Referenced by rz_type_as_string(), rz_type_db_base_type_as_pretty_string(), rz_type_db_base_type_as_string(), rz_type_declaration_as_string(), and rz_type_identifier_declaration_as_string().
Returns the type C representation.
typedb | Types Database instance |
type | RzType type |
Definition at line 817 of file type.c.
References NULL, rz_return_val_if_fail, rz_type_as_pretty_string(), RZ_TYPE_PRINT_ANONYMOUS, RZ_TYPE_PRINT_NO_END_SEMICOLON, RZ_TYPE_PRINT_ZERO_VLA, and type.
Referenced by callable_as_string(), core_analysis_var_list_show(), ds_print_calls_hints(), ds_print_esil_analysis(), ds_show_functions(), ds_show_functions_argvar(), pdb_types_print_json(), print_fcn_arg(), rz_analysis_fcn_format_sig(), rz_analysis_function_get_json(), rz_analysis_function_vars_stackframe_handler(), rz_analysis_var_global_list_show(), rz_core_analysis_function_signature(), rz_core_types_function_print(), rz_core_types_link_print(), rz_core_types_struct_print(), rz_core_types_typedef_print(), rz_core_types_union_print(), rz_serialize_analysis_global_var_save(), rz_serialize_analysis_var_save(), save_callable(), save_struct(), save_typedef(), save_typelink(), save_union(), set_offset_hint(), type_decl_as_pretty_string(), type_match(), types_xrefs_function(), types_xrefs_graph(), types_xrefs_summary(), and var_variables_show().
Creates an exact clone of the RzType.
type | RzType pointer |
Definition at line 1181 of file type.c.
References rz_type_t::array, rz_type_t::callable, rz_type_t::identifier, rz_type_t::kind, NULL, rz_type_t::pointer, RZ_NEW0, rz_return_val_if_fail, rz_type_callable_clone(), RZ_TYPE_KIND_ARRAY, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_IDENTIFIER, RZ_TYPE_KIND_POINTER, strdup(), and type.
Referenced by function_argument_type_derive(), parse_enum(), parse_structure(), parse_type_nest(), parse_type_string_cached(), parse_union(), rz_analysis_fcn_vars_add_types(), rz_analysis_function_derive_args(), rz_analysis_function_derive_return_type(), rz_analysis_function_set_type(), rz_type_callable_arg_clone(), rz_type_callable_clone(), var_type_clone_or_default_type(), and var_type_set().
Returns the list of all type names.
typedb | Types Database instance |
Definition at line 441 of file type.c.
References rz_base_type_t::name, NULL, rz_list_append(), rz_list_free(), rz_list_new(), rz_return_val_if_fail, rz_type_db_get_base_types(), and types.
Referenced by autocmplt_cmd_arg_any_type().
RZ_API ut64 rz_type_db_atomic_bitsize | ( | const RzTypeDB * | typedb, |
RZ_NONNULL RzBaseType * | btype | ||
) |
Returns the atomic type size in bits (target dependent)
typedb | Types Database instance |
btype | The base type |
Definition at line 684 of file type.c.
References RZ_BASE_TYPE_KIND_ATOMIC, and rz_return_val_if_fail.
Referenced by rz_type_db_base_get_bitsize(), and rz_type_db_get_bitsize().
RZ_API ut64 rz_type_db_base_get_bitsize | ( | const RzTypeDB * | typedb, |
RZ_NONNULL RzBaseType * | btype | ||
) |
Returns the base type size in bits (target dependent)
typedb | Types Database instance |
btype | The base type |
Definition at line 755 of file type.c.
References RZ_BASE_TYPE_KIND_ATOMIC, RZ_BASE_TYPE_KIND_ENUM, RZ_BASE_TYPE_KIND_STRUCT, RZ_BASE_TYPE_KIND_TYPEDEF, RZ_BASE_TYPE_KIND_UNION, rz_return_val_if_fail, rz_type_db_atomic_bitsize(), rz_type_db_enum_bitsize(), rz_type_db_struct_bitsize(), rz_type_db_typedef_bitsize(), rz_type_db_union_bitsize(), and rz_warn_if_reached.
Referenced by rz_type_integral_set_sign().
RZ_API bool rz_type_db_del | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Removes the type from the database.
Can remove either RzBaseType or RzCallable type
typedb | RzTypeDB instance |
name | RzBaseType or RzCallable type name |
Definition at line 223 of file type.c.
References eprintf, rz_return_val_if_fail, rz_type_db_delete_base_type(), rz_type_db_get_base_type(), rz_type_func_delete(), and rz_type_func_exist().
Referenced by rz_type_del_handler().
RZ_API bool rz_type_db_edit_base_type | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name, | ||
RZ_NONNULL const char * | typestr | ||
) |
Edits the existing base type given the new C code.
Searches the base type in the types database given the name
. If it exists - parses the typestr
as the new C type. If there is any error during the parsing it restores the original type in the database.
typedb | Type Database instance |
name | Name of the base type |
typestr | C string of the new definition of the type |
Definition at line 1305 of file type.c.
References free(), freefn(), rz_base_type_t::name, NULL, rz_type_db_t::parser, RZ_LOG_ERROR, rz_return_val_if_fail, rz_type_base_type_free(), rz_type_db_get_compound_type(), rz_type_parse_string_stateless(), and rz_type_db_t::types.
Referenced by rz_types_open_editor().
RZ_API ut64 rz_type_db_enum_bitsize | ( | const RzTypeDB * | typedb, |
RZ_NONNULL RzBaseType * | btype | ||
) |
Returns the enum type size in bits (target dependent)
typedb | Types Database instance |
btype | The base type |
Definition at line 695 of file type.c.
References RZ_BASE_TYPE_KIND_ENUM, and rz_return_val_if_fail.
Referenced by rz_type_db_base_get_bitsize(), and rz_type_db_get_bitsize().
RZ_API RZ_OWN char* rz_type_db_enum_get_bitfield | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const char * | name, | ||
ut64 | val | ||
) |
Returns all matching bitfields as an OR mask given the resulting value.
typedb | Types Database instance |
name | The name of the bitfield enum |
val | The value to search for |
Definition at line 584 of file type.c.
References rz_base_type_enum_t::cases, rz_base_type_t::enum_data, i, rz_base_type_t::kind, n, rz_type_enum_case_t::name, NULL, PFMT64x, RZ_BASE_TYPE_KIND_ENUM, rz_return_val_if_fail, rz_str_append(), rz_str_appendf(), rz_str_newf(), rz_type_db_get_base_type(), rz_vector_foreach, val, and rz_type_enum_case_t::val.
Referenced by rz_type_format_bitfield().
RZ_API int rz_type_db_enum_member_by_name | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const char * | name, | ||
const char * | member | ||
) |
Returns the enum case value matched by the enum case name.
typedb | Types Database instance |
name | The name of the enum to search in |
member | The enum case name to search for |
Definition at line 533 of file type.c.
References rz_base_type_enum_t::cases, rz_base_type_t::enum_data, rz_base_type_t::kind, rz_type_enum_case_t::name, RZ_BASE_TYPE_KIND_ENUM, rz_return_val_if_fail, rz_type_db_get_base_type(), rz_vector_foreach, and rz_type_enum_case_t::val.
Referenced by rz_type_enum_bitfield_handler().
RZ_API RZ_BORROW const char* rz_type_db_enum_member_by_val | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const char * | name, | ||
ut64 | val | ||
) |
Returns the enum case name matching the cpecified value.
typedb | Types Database instance |
name | The name of the enum to search in |
val | The value to search for |
Definition at line 508 of file type.c.
References rz_base_type_enum_t::cases, rz_base_type_t::enum_data, rz_base_type_t::kind, rz_type_enum_case_t::name, NULL, RZ_BASE_TYPE_KIND_ENUM, rz_return_val_if_fail, rz_type_db_get_base_type(), rz_vector_foreach, val, and rz_type_enum_case_t::val.
Referenced by ds_show_flags(), rz_type_format_enum(), and types_enum_member_find().
Returns the list of all enum names.
typedb | Types Database instance |
Definition at line 369 of file type.c.
References e, NULL, RZ_BASE_TYPE_KIND_ENUM, rz_list_append(), rz_list_free(), rz_list_new(), rz_return_val_if_fail, and rz_type_db_get_base_types_of_kind().
Referenced by autocmplt_cmd_arg_enum_type().
Returns all enums and cases name matching the specified value.
typedb | Types Database instance |
val | The value to search for |
Definition at line 559 of file type.c.
References e, free(), rz_type_enum_case_t::name, NULL, RZ_BASE_TYPE_KIND_ENUM, rz_list_append(), rz_list_free(), rz_list_newf(), rz_return_val_if_fail, rz_str_newf(), rz_type_db_get_base_types_of_kind(), rz_vector_foreach, val, and rz_type_enum_case_t::val.
Referenced by types_enum_member_find_all().
Purges formats in the instance of the RzTypeDB.
Definition at line 108 of file type.c.
References rz_type_db_t::formats, formats_ht_free(), and NULL.
Referenced by cmd_print_format().
Frees the instance of the RzTypeDB.
Destroys hashtables for RzBaseType, RzCallable, type formats.
Definition at line 79 of file type.c.
References rz_type_db_t::callables, rz_type_target_t::cpu, rz_type_target_t::default_type, rz_type_db_t::formats, free(), rz_type_target_t::os, rz_type_db_t::parser, rz_type_parser_free(), rz_type_db_t::target, and rz_type_db_t::types.
Referenced by rz_analysis_free().
Returns the type size in bits (target dependent)
typedb | Types Database instance |
type | The type |
Definition at line 779 of file type.c.
References rz_base_type_t::kind, RZ_BASE_TYPE_KIND_ATOMIC, RZ_BASE_TYPE_KIND_ENUM, RZ_BASE_TYPE_KIND_STRUCT, RZ_BASE_TYPE_KIND_TYPEDEF, RZ_BASE_TYPE_KIND_UNION, rz_return_val_if_fail, rz_type_db_atomic_bitsize(), rz_type_db_enum_bitsize(), rz_type_db_get_base_type(), rz_type_db_pointer_size(), rz_type_db_struct_bitsize(), rz_type_db_typedef_bitsize(), rz_type_db_union_bitsize(), RZ_TYPE_IDENTIFIER_KIND_ENUM, RZ_TYPE_IDENTIFIER_KIND_STRUCT, RZ_TYPE_IDENTIFIER_KIND_UNION, RZ_TYPE_KIND_ARRAY, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_POINTER, rz_warn_if_reached, and type.
Referenced by extract_arg(), parse_enum(), path_walker(), rz_analysis_function_set_type(), rz_analysis_var_global_add(), rz_analysis_var_global_get_byaddr_in(), rz_analysis_var_global_set_type(), rz_analysis_var_resolve_overlaps(), rz_core_print_disasm(), rz_core_types_struct_print(), rz_core_types_union_print(), rz_type_db_struct_bitsize(), rz_type_db_struct_member_packed_offset(), rz_type_db_typedef_bitsize(), rz_type_db_union_bitsize(), rz_type_path_by_offset(), set_fcn_args_info(), structured_member_walker(), and var_add_structure_fields_to_list().
RZ_API RzBaseType* rz_type_db_get_enum | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Returns the enum base type matching the specified name.
typedb | Types Database instance |
name | The name of the enum to match against |
Definition at line 489 of file type.c.
References rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_ENUM, rz_return_val_if_fail, and rz_type_db_get_base_type().
Referenced by rz_analysis_function_blocks_switch_type_handler(), rz_type_enum_c_handler(), rz_type_enum_c_nl_handler(), and rz_type_list_enum_handler().
RZ_API RzBaseType* rz_type_db_get_struct | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
returns the struct base type matching the specified name
typedb | types database instance |
name | the name of the struct to match against |
Definition at line 648 of file type.c.
References rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_STRUCT, rz_return_val_if_fail, and rz_type_db_get_base_type().
Referenced by rz_type_list_structure_handler(), rz_type_structure_c_handler(), and rz_type_structure_c_nl_handler().
RZ_API RzBaseType* rz_type_db_get_typedef | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Returns the typedef base type matching the specified name.
typedb | Types Database instance |
name | The name of the typedef to match against |
Definition at line 666 of file type.c.
References rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_TYPEDEF, rz_return_val_if_fail, and rz_type_db_get_base_type().
Referenced by rz_type_list_typedef_handler(), and rz_type_typedef_c_handler().
RZ_API RzBaseType* rz_type_db_get_union | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Returns the union base type matching the specified name.
typedb | Types Database instance |
name | The name of the union to match against |
Definition at line 630 of file type.c.
References rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_UNION, rz_return_val_if_fail, and rz_type_db_get_base_type().
Referenced by rz_type_list_union_handler(), rz_type_union_c_handler(), and rz_type_union_c_nl_handler().
RZ_API void rz_type_db_init | ( | RzTypeDB * | typedb, |
const char * | types_dir, | ||
const char * | arch, | ||
int | bits, | ||
const char * | os | ||
) |
Initializes the types database for specified arch, bits, OS.
Loads pre-shipped type libraries for base types and function types. Different architectures, operating systems, bitness affects on what exact types are loaded, also some atomic types sizes are different. In some cases the same type, for example, structure type could have a different layout, depending on the operating system or bitness.
typedb | Types Database instance |
types_dir | Directory where all type libraries are installed |
arch | Architecture of the analysis session |
bits | Bitness of the analysis session |
os | Operating system of the analysis session |
Definition at line 253 of file type.c.
References arch, bits(), rz_type_db_t::formats, free(), rz_file_path_join(), RZ_LOG_DEBUG, rz_return_if_fail, RZ_STR_ISNOTEMPTY, rz_strf, rz_type_db_load_callables_sdb(), rz_type_db_load_sdb(), autogen_x86imm::tmp, and rz_type_db_t::types.
Referenced by rz_core_analysis_type_init(), and rz_type_db_reload().
Creates a new instance of the RzTypeDB.
Creates the RzTypeDB instance, initializes hashtables for RzBaseType, RzCallable, type formats. Also initializes default "target" (arch, bits, platform) parameters.
Definition at line 34 of file type.c.
References rz_type_db_t::callables, callables_ht_free(), rz_type_target_t::default_type, rz_type_db_t::formats, formats_ht_free(), free(), rz_type_db_t::iob, NULL, rz_type_db_t::parser, rz_io_bind_init, RZ_NEW0, rz_type_parser_init(), strdup(), rz_type_db_t::target, rz_type_db_t::types, and types_ht_free().
Referenced by rz_analysis_new().
Returns the pointer size for the current RzTypeDB target set.
typedb | RzTypeDB instance |
Definition at line 211 of file type.c.
References rz_type_target_t::addr_bits, rz_type_target_t::bits, and rz_type_db_t::target.
Referenced by rz_type_db_get_bitsize().
Purges the instance of the RzTypeDB.
Destroys all loaded base types and callable types.
Definition at line 96 of file type.c.
References rz_type_db_t::callables, callables_ht_free(), NULL, rz_type_db_t::parser, rz_type_parser_free(), rz_type_parser_init(), rz_type_db_t::types, and types_ht_free().
Referenced by rz_analysis_purge(), rz_type_db_reload(), and rz_type_del_all_handler().
Re-initializes the types database for current target.
Similarly to rz_type_db_init loads pre-shipped type libraries for base types and function types.
typedb | Types Database instance |
types_dir | Directory where all type libraries are installed |
Definition at line 357 of file type.c.
References rz_type_target_t::bits, rz_type_target_t::cpu, rz_type_target_t::os, rz_type_db_init(), rz_type_db_purge(), and rz_type_db_t::target.
Referenced by analysis_set_os(), rz_analysis_set_bits(), and rz_analysis_set_cpu().
Set the RzType target adress size.
Important for calculating some types size, especially pointers's size.
typedb | RzTypeDB instance |
bits | size of an address in bits. If <= 0, then the value from rz_type_db_set_bits() is used. |
Definition at line 161 of file type.c.
References rz_type_target_t::addr_bits, rz_return_if_fail, and rz_type_db_t::target.
Referenced by rz_analysis_set_bits().
Set the RzType target architecture bits.
Important for calculating some types size, especially pointers's size.
typedb | RzTypeDB instance |
bits | Architecture bits to set |
Definition at line 145 of file type.c.
References rz_type_target_t::bits, bits(), set_default_type(), and rz_type_db_t::target.
Referenced by rz_analysis_set_bits().
Set the RzType target architecture CPU.
Important for calculating some types size, especially pointers's size.
typedb | RzTypeDB instance |
cpu | Architecture name to set |
Definition at line 189 of file type.c.
References cpu, rz_type_target_t::cpu, free(), NULL, strdup(), and rz_type_db_t::target.
Referenced by rz_analysis_set_cpu().
Set the RzType target architecture CPU.
Important for calculating complex types layout.
typedb | RzTypeDB instance |
big_endian | True if the big endian, false if the opposite |
Definition at line 202 of file type.c.
References rz_type_target_t::big_endian, and rz_type_db_t::target.
Referenced by cb_bigendian(), and rz_analysis_set_big_endian().
Set the RzType target architecture operating system.
Important for calculating some types size, especially pointers's size.
typedb | RzTypeDB instance |
os | Operating system name to set |
Definition at line 175 of file type.c.
References free(), NULL, rz_type_target_t::os, strdup(), and rz_type_db_t::target.
Referenced by analysis_set_os().
RZ_API ut64 rz_type_db_struct_bitsize | ( | const RzTypeDB * | typedb, |
RZ_NONNULL RzBaseType * | btype | ||
) |
Returns the struct type size in bits (target dependent)
typedb | Types Database instance |
btype | The base type |
Definition at line 707 of file type.c.
References RZ_BASE_TYPE_KIND_STRUCT, rz_return_val_if_fail, rz_type_db_get_bitsize(), rz_vector_foreach, rz_type_struct_member_t::type, and ut64().
Referenced by rz_type_db_base_get_bitsize(), and rz_type_db_get_bitsize().
Returns the list of all struct names.
typedb | Types Database instance |
Definition at line 405 of file type.c.
References NULL, RZ_BASE_TYPE_KIND_STRUCT, rz_list_append(), rz_list_free(), rz_list_new(), rz_return_val_if_fail, rz_type_db_get_base_types_of_kind(), and s.
Referenced by autocmplt_cmd_arg_struct_type().
RZ_API ut64 rz_type_db_typedef_bitsize | ( | const RzTypeDB * | typedb, |
RZ_NONNULL RzBaseType * | btype | ||
) |
Returns the typedef type size in bits (target dependent)
typedb | Types Database instance |
btype | The base type |
Definition at line 740 of file type.c.
References RZ_BASE_TYPE_KIND_TYPEDEF, rz_return_val_if_fail, rz_type_db_get_bitsize(), and RZ_TYPE_KIND_IDENTIFIER.
Referenced by rz_type_db_base_get_bitsize(), and rz_type_db_get_bitsize().
Returns the list of all typedef (type aliases) names.
typedb | Types Database instance |
Definition at line 423 of file type.c.
References rz_base_type_t::name, NULL, RZ_BASE_TYPE_KIND_TYPEDEF, rz_list_append(), rz_list_free(), rz_list_new(), rz_return_val_if_fail, and rz_type_db_get_base_types_of_kind().
Referenced by autocmplt_cmd_arg_alias_type().
RZ_API ut64 rz_type_db_union_bitsize | ( | const RzTypeDB * | typedb, |
RZ_NONNULL RzBaseType * | btype | ||
) |
Returns the union type size in bits (target dependent)
typedb | Types Database instance |
btype | The base type |
Definition at line 723 of file type.c.
References RZ_BASE_TYPE_KIND_UNION, RZ_MAX, rz_return_val_if_fail, rz_type_db_get_bitsize(), rz_vector_foreach, rz_type_union_member_t::type, and ut64().
Referenced by rz_type_db_base_get_bitsize(), and rz_type_db_get_bitsize().
Returns the list of all union names.
typedb | Types Database instance |
Definition at line 387 of file type.c.
References rz_base_type_t::name, NULL, RZ_BASE_TYPE_KIND_UNION, rz_list_append(), rz_list_free(), rz_list_new(), rz_return_val_if_fail, and rz_type_db_get_base_types_of_kind().
Referenced by autocmplt_cmd_arg_union_type().
RZ_API RZ_OWN char* rz_type_declaration_as_string | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const RzType * | type | ||
) |
Returns the type C declaration representation.
typedb | Types Database instance |
type | RzType type |
Definition at line 829 of file type.c.
References NULL, rz_return_val_if_fail, rz_type_as_pretty_string(), RZ_TYPE_PRINT_NO_END_SEMICOLON, RZ_TYPE_PRINT_ZERO_VLA, and type.
RZ_API bool rz_type_exists | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Checks if the type exists in the Type database.
typedb | Types Database instance |
name | Name of the type |
Definition at line 462 of file type.c.
References NULL, rz_return_val_if_fail, and rz_type_db_get_base_type().
RZ_API void rz_type_free | ( | RZ_NULLABLE RzType * | type | ) |
Frees the RzType.
Doesn't free the underlying RzBaseType, only the RzType wrapper. Same goes for the RzCallable. Both are stored in the corresponding hashtables and should not be touched until deleted explicitly.
type | RzType type |
Definition at line 1273 of file type.c.
References free(), RZ_TYPE_KIND_ARRAY, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_IDENTIFIER, RZ_TYPE_KIND_POINTER, and type.
Referenced by c_parser_get_primitive_type(), c_parser_get_typedef(), c_parser_new_enum_naked_type(), c_parser_new_enum_type(), c_parser_new_primitive_type(), c_parser_new_structure_naked_type(), c_parser_new_structure_type(), c_parser_new_typedef(), c_parser_new_typedef_naked_type(), c_parser_new_union_naked_type(), c_parser_new_union_type(), c_parser_new_unspecified_naked_type(), get_callable_type(), parse_sole_type_name(), parse_struct_member(), parse_type_mfunction(), parse_type_pointer(), parse_type_procedure(), parse_union_member(), rz_analysis_dwarf_integrate_functions(), rz_analysis_fcn_vars_add_types(), rz_analysis_function_blocks_switch_type_handler(), rz_analysis_function_set_type(), rz_analysis_function_set_var(), rz_analysis_function_vars_bp_handler(), rz_analysis_function_vars_regs_handler(), rz_analysis_function_vars_sp_handler(), rz_analysis_var_global_free(), rz_analysis_var_global_set_type(), rz_type_array_of_base_type(), rz_type_base_struct_member_free(), rz_type_base_type_free(), rz_type_base_union_member_free(), rz_type_callable_arg_free(), rz_type_callable_free(), rz_type_integral_set_sign(), rz_type_pointer_of_base_type(), type_match(), var_free(), and var_type_set_str().
RZ_API RZ_BORROW RzBaseType* rz_type_get_base_type | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const RzType * | type | ||
) |
Returns the RzBaseType for the chosen RzType.
typedb | Type Database instance |
type | RzType type pointer |
Definition at line 1251 of file type.c.
References NULL, rz_return_val_if_fail, rz_type_db_get_base_type(), rz_type_identifier(), and type.
Referenced by base_type_to_format_unfold().
Returns the type C identifier.
In case of the compound types it returns the name of identifier For example, for "char **ptr" it will return "char", for "const int **arr[56][76]" it will return "int"
type | RzType type |
Definition at line 1155 of file type.c.
References NULL, rz_return_val_if_fail, RZ_TYPE_KIND_ARRAY, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_IDENTIFIER, RZ_TYPE_KIND_POINTER, and type.
Referenced by ds_show_flags(), get_base_type_typeclass(), get_type_typeclass(), parse_typedef_node(), rz_core_print_disasm(), rz_type_get_base_type(), rz_type_integral_set_sign(), type_to_format_pair(), and types_xrefs_all().
RZ_API RZ_OWN char* rz_type_identifier_declaration_as_string | ( | const RzTypeDB * | typedb, |
RZ_NONNULL const RzType * | type, | ||
RZ_NONNULL const char * | identifier | ||
) |
Returns the type C representation with identifier.
typedb | Types Database instance |
type | RzType type |
Definition at line 841 of file type.c.
References NULL, rz_return_val_if_fail, rz_type_as_pretty_string(), RZ_TYPE_PRINT_NO_END_SEMICOLON, RZ_TYPE_PRINT_UNFOLD_ANON_ONLY_STRICT, RZ_TYPE_PRINT_ZERO_VLA, and type.
Referenced by callable_as_string().
RZ_API int rz_type_kind | ( | RzTypeDB * | typedb, |
RZ_NONNULL const char * | name | ||
) |
Returns the kind (RzBaseTypeKind) of the type.
typedb | Types Database instance |
name | Name of the type |
Definition at line 474 of file type.c.
References rz_base_type_t::kind, rz_return_val_if_fail, and rz_type_db_get_base_type().
RZ_API bool rz_types_equal | ( | RZ_NONNULL const RzType * | type1, |
RZ_NONNULL const RzType * | type2 | ||
) |
Checks if two types are identical.
type1 | RzType pointer |
type2 | RzType pointer |
Definition at line 1218 of file type.c.
References rz_return_val_if_fail, RZ_TYPE_KIND_ARRAY, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_IDENTIFIER, RZ_TYPE_KIND_POINTER, and rz_warn_if_reached.
Referenced by typecmp(), and types_xrefs().
|
static |
Definition at line 113 of file type.c.
References bits(), rz_type_target_t::default_type, free(), rz_warn_if_reached, and strdup().
Referenced by rz_type_db_set_bits().
|
static |
Definition at line 948 of file type.c.
References PrettyHelperBufs::arraybuf, rz_base_type_enum_t::cases, rz_base_type_t::enum_data, free(), i, rz_base_type_t::kind, rz_base_type_struct_t::members, rz_base_type_union_t::members, rz_type_enum_case_t::name, rz_type_struct_member_t::name, rz_type_union_member_t::name, rz_base_type_t::name, NULL, PFMT64x, PrettyHelperBufs::pointerbuf, RZ_BASE_TYPE_KIND_ATOMIC, RZ_BASE_TYPE_KIND_ENUM, RZ_BASE_TYPE_KIND_STRUCT, RZ_BASE_TYPE_KIND_TYPEDEF, RZ_BASE_TYPE_KIND_UNION, rz_return_val_if_fail, rz_str_nlen(), rz_strbuf_append(), rz_strbuf_appendf(), rz_strbuf_drain(), rz_strbuf_free(), rz_strbuf_length(), rz_strbuf_new(), rz_strbuf_slice(), rz_type_db_get_base_type(), rz_type_is_callable_ptr_nested(), RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_IDENTIFIER, RZ_TYPE_KIND_POINTER, RZ_TYPE_PRINT_ANONYMOUS, RZ_TYPE_PRINT_END_NEWLINE, RZ_TYPE_PRINT_MULTILINE, RZ_TYPE_PRINT_NO_END_SEMICOLON, RZ_TYPE_PRINT_SHOW_TYPEDEF, RZ_TYPE_PRINT_UNFOLD_ANON_ONLY, RZ_TYPE_PRINT_UNFOLD_ANON_ONLY_STRICT, RZ_TYPE_PRINT_ZERO_VLA, rz_vector_foreach, rz_vector_len(), rz_warn_if_reached, rz_base_type_t::struct_data, type, rz_type_struct_member_t::type, rz_type_union_member_t::type, rz_base_type_t::type, type_decl_as_pretty_string(), PrettyHelperBufs::typename, rz_base_type_t::union_data, and rz_type_enum_case_t::val.
Referenced by rz_type_as_pretty_string().
|
static |
Definition at line 853 of file type.c.
References PrettyHelperBufs::arraybuf, free(), rz_base_type_t::kind, rz_base_type_t::name, NULL, PFMT64d, PrettyHelperBufs::pointerbuf, RZ_BASE_TYPE_KIND_ATOMIC, RZ_BASE_TYPE_KIND_ENUM, RZ_BASE_TYPE_KIND_STRUCT, RZ_BASE_TYPE_KIND_TYPEDEF, RZ_BASE_TYPE_KIND_UNION, RZ_LOG_ERROR, rz_return_val_if_fail, rz_strbuf_append(), rz_strbuf_appendf(), rz_type_as_string(), rz_type_callable_as_string(), rz_type_callable_ptr_as_string(), rz_type_db_get_base_type(), rz_type_is_callable_ptr_nested(), RZ_TYPE_KIND_ARRAY, RZ_TYPE_KIND_CALLABLE, RZ_TYPE_KIND_IDENTIFIER, RZ_TYPE_KIND_POINTER, rz_warn_if_reached, strdup(), type, rz_base_type_t::type, and PrettyHelperBufs::typename.
Referenced by type_as_pretty_string().
|
static |
Definition at line 12 of file type.c.
References free(), and rz_type_base_type_free().
Referenced by rz_type_db_new(), and rz_type_db_purge().