Rizin
unix-like reverse engineering framework and cli tools
rz_type.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 Anton Kochkov <anton.kochkov@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef RZ_TYPE_H
5 #define RZ_TYPE_H
6 
7 #include <rz_types.h>
8 #include <rz_util/rz_num.h>
9 #include <rz_util/rz_print.h>
10 #include <rz_bind.h>
11 #include <rz_io.h>
12 #include <rz_list.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
19 
20 typedef struct rz_type_target_t {
21  char *cpu;
22  int bits;
23  int addr_bits;
24  char *os;
25  bool big_endian;
26  const char *default_type;
28 
29 typedef struct rz_type_parser_t RzTypeParser;
30 
31 typedef struct rz_type_db_t {
32  void *user;
33  HtPP /* <char *, RzBaseType *> */ *types; //< name -> base type
34  HtPP /* <char *, char *> */ *formats; //< name -> `pf` format
35  HtPP /* <char *, RzCallable *> */ *callables; //< name -> RzCallable (function type)
39  RzIOBind iob; // for RzIO in formats
41 
42 // All types in RzTypeDB module are either concrete,
43 // "base" types that are types already having the
44 // concrete size and memory layout
45 // or the "AST" types that are returned from the parser
46 // and don't contain the size or memory laoyout
47 
48 typedef struct rz_type_t RzType;
49 
50 // Base types
51 
53 
54 typedef enum {
55  // A first group - typeclasses
56  RZ_TYPE_ATTRIBUTE_TYPECLASS_MASK = 0xF, //< to store typeclasses
57  // The rest are reserved
59 
60 // Typeclasses for atomic types
61 typedef enum {
62  RZ_TYPE_TYPECLASS_NONE, //< most generic types
63  RZ_TYPE_TYPECLASS_NUM, //< all numbers
64  RZ_TYPE_TYPECLASS_INTEGRAL, //< all integer numbers
65  RZ_TYPE_TYPECLASS_FLOATING, //< all floating point numbers
66  RZ_TYPE_TYPECLASS_ADDRESS, //< integer types to work with pointers
67  RZ_TYPE_TYPECLASS_INTEGRAL_SIGNED, //< all signed integral types (subclass of Integral)
68  RZ_TYPE_TYPECLASS_INTEGRAL_UNSIGNED, //< all unsigned integral types (subclass of Integral)
71 
72 typedef enum {
77  RZ_BASE_TYPE_KIND_ATOMIC, // For real atomic base types
79 
80 typedef struct rz_type_enum_case_t {
81  char *name;
84 
85 typedef struct rz_type_struct_member_t {
86  char *name;
88  size_t offset; // in bytes
89  size_t size; // in bits?
91 
92 typedef struct rz_type_union_member_t {
93  char *name;
95  size_t offset; // in bytes
96  size_t size; // in bits?
98 
99 typedef struct rz_base_type_struct_t {
100  RzVector /*<RzTypeStructMember>*/ members;
102 
103 typedef struct rz_base_type_union_t {
104  RzVector /*<RzTypeUnionMember>*/ members;
106 
107 typedef struct rz_base_type_enum_t {
108  RzVector /*<RzTypeEnumCase*/ cases; // list of all the enum cases
110 
111 typedef struct rz_base_type_t {
112  char *name;
113  RzType *type; // Used by typedef, atomic type, enum
114  ut64 size; // size of the whole type in bits
117  union {
121  };
123 
124 // AST-level types for C and C++
125 // Parses strings like "const char * [0x42] const * [23]" to RzType
126 
127 typedef enum {
133 
134 typedef enum {
140 
141 typedef struct rz_callable_arg_t {
142  RZ_NULLABLE char *name; // optional
145 
146 typedef struct rz_callable_at {
147  RZ_NULLABLE char *name; // optional
149  RzPVector /* RzCallableArg */ *args;
150  RZ_NULLABLE const char *cc; // optional
151  bool noret; // Does not return
153 
154 struct rz_type_t {
156  union {
157  struct {
159  char *name;
160  bool is_const; // const char *
162  struct {
164  bool is_const; // char * const
166  struct {
167  RzType *type;
169  } array;
171  };
172 };
173 
174 typedef struct rz_type_path_t {
176  char *path;
178 
182 typedef enum {
199  RZ_TYPE_COND_HEX_SCL_TRUE, // Hexagon only: Scalar instruction if(Pu)
200  RZ_TYPE_COND_HEX_SCL_FALSE, // Hexagon only: Scalar instruction if(!Pu)
201  RZ_TYPE_COND_HEX_VEC_TRUE, // Hexagon only: Vector instruction if(Pu)
202  RZ_TYPE_COND_HEX_VEC_FALSE, // Hexagon only: Vector instruction if(!Pu)
203  RZ_TYPE_COND_EXCEPTION, // when the jump is taken only during an exception
204 } RzTypeCond;
205 
209 typedef struct rz_type_constraint_t {
213 
214 typedef enum {
215  RZ_TYPE_PRINT_NO_OPTS = 0, // no options
216  RZ_TYPE_PRINT_MULTILINE = 1 << 0, // print multiline string (every single type on a single line)
217  RZ_TYPE_PRINT_UNFOLD_ANON_ONLY = 1 << 1, // only unfold anonymous structs/unions/enums (applies only to inner members, not the root member)
218  RZ_TYPE_PRINT_UNFOLD_ANON_ONLY_STRICT = 1 << 2, // only unfold anonymous structs/unions/enums
219  RZ_TYPE_PRINT_ZERO_VLA = 1 << 3, // use [0] to denote VLA instead of (default) []
220  RZ_TYPE_PRINT_NO_END_SEMICOLON = 1 << 4, // return a string without a semicolon at end
221  RZ_TYPE_PRINT_ANONYMOUS = 1 << 5, // use "[struct|union|enum] anonymous" as the typename for anonymous structs/unions/enums
222  RZ_TYPE_PRINT_END_NEWLINE = 1 << 6, // return a string with a newline at the end
223  RZ_TYPE_PRINT_SHOW_TYPEDEF = 1 << 7 // show typedefs wherever found
225 
226 #ifdef RZ_API
227 
229 RZ_API void rz_type_db_free(RzTypeDB *typedb);
230 RZ_API bool rz_type_db_load_sdb(RzTypeDB *typedb, RZ_NONNULL const char *path);
231 RZ_API bool rz_type_db_load_sdb_str(RzTypeDB *typedb, RZ_NONNULL const char *str);
232 RZ_API bool rz_type_db_load_callables_sdb(RzTypeDB *typedb, RZ_NONNULL const char *path);
234 RZ_API void rz_type_db_set_bits(RzTypeDB *typedb, int bits);
235 RZ_API void rz_type_db_set_address_bits(RzTypeDB *typedb, int addr_bits);
236 RZ_API void rz_type_db_set_os(RzTypeDB *typedb, const char *os);
237 RZ_API void rz_type_db_set_cpu(RzTypeDB *typedb, const char *cpu);
238 RZ_API void rz_type_db_set_endian(RzTypeDB *typedb, bool big_endian);
239 
241 
242 RZ_API bool rz_type_db_del(RzTypeDB *typedb, RZ_NONNULL const char *name);
243 
244 RZ_API void rz_type_db_init(RzTypeDB *typedb, const char *dir_prefix, const char *arch, int bits, const char *os);
245 RZ_API void rz_type_db_reload(RzTypeDB *typedb, const char *dir_prefix);
246 RZ_API void rz_type_db_purge(RzTypeDB *typedb);
247 
248 // Base types
249 
253 
254 RZ_API void rz_type_base_enum_case_free(void *e, void *user);
255 RZ_API void rz_type_base_struct_member_free(void *e, void *user);
256 RZ_API void rz_type_base_union_member_free(void *e, void *user);
257 
260 RZ_API void rz_type_db_save_base_type(const RzTypeDB *typedb, const RzBaseType *type);
262 
263 RZ_API RZ_OWN RzList /*<RzBaseType *>*/ *rz_type_db_get_base_types_of_kind(const RzTypeDB *typedb, RzBaseTypeKind kind);
264 RZ_API RZ_OWN RzList /*<RzBaseType *>*/ *rz_type_db_get_base_types(const RzTypeDB *typedb);
265 
266 RZ_API RZ_OWN char *rz_type_db_base_type_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype);
267 RZ_API RZ_OWN char *rz_type_db_base_type_as_pretty_string(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, unsigned int opts, int unfold_level);
268 RZ_API bool rz_type_db_edit_base_type(RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *typestr);
269 
270 // Compound types
271 
274 RZ_API bool rz_types_equal(RZ_NONNULL const RzType *type1, RZ_NONNULL const RzType *type2);
275 RZ_API RZ_OWN char *rz_type_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
277 RZ_API RZ_OWN char *rz_type_identifier_declaration_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RZ_NONNULL const char *identifier);
278 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);
280 RZ_API bool rz_type_exists(RzTypeDB *typedb, RZ_NONNULL const char *name);
281 RZ_API int rz_type_kind(RzTypeDB *typedb, RZ_NONNULL const char *name);
282 
283 // Type classes
288 RZ_API bool rz_base_type_is_num(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type);
289 RZ_API bool rz_type_is_num(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
291 RZ_API bool rz_type_is_integral(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
293 RZ_API bool rz_type_is_floating(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
295 RZ_API bool rz_type_is_integral_signed(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
298 RZ_API RZ_OWN RzList /*<RzBaseType *>*/ *rz_type_typeclass_get_all(const RzTypeDB *typedb, RzTypeTypeclass typeclass);
299 RZ_API RZ_OWN RzList /*<RzBaseType *>*/ *rz_type_typeclass_get_all_sized(const RzTypeDB *typedb, RzTypeTypeclass typeclass, size_t size);
301 
302 // Type paths
305 RZ_API st64 rz_type_offset_by_path(const RzTypeDB *typedb, RZ_NONNULL const char *path);
306 RZ_API RZ_OWN RzList /*<RzTypePath *>*/ *rz_type_path_by_offset(const RzTypeDB *typedb, RzBaseType *btype, ut64 offset);
307 RZ_API RZ_OWN RzList /*<RzTypePath *>*/ *rz_type_db_get_by_offset(const RzTypeDB *typedb, ut64 offset);
308 RZ_API ut64 rz_type_db_struct_member_packed_offset(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *member);
309 RZ_API ut64 rz_type_db_struct_member_offset(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *member);
310 
311 // Type parser low-level API
312 
314 RZ_API RZ_OWN RzTypeParser *rz_type_parser_init(HtPP *types, HtPP *callables);
317 
318 RZ_API int rz_type_parse_string_stateless(RzTypeParser *parser, const char *code, char **error_msg);
319 RZ_API int rz_type_parse_file_stateless(RzTypeParser *parser, const char *path, const char *dir, char **error_msg);
320 RZ_API RZ_OWN RzType *rz_type_parse_string_single(RzTypeParser *parser, const char *code, char **error_msg);
322 
323 // Type parser high-level API
324 
325 RZ_API int rz_type_parse_string(RzTypeDB *typedb, const char *code, char **error_msg);
326 RZ_API int rz_type_parse_file(RzTypeDB *typedb, const char *path, const char *dir, char **error_msg);
327 RZ_API void rz_type_parse_reset(RzTypeDB *typedb);
328 
329 // Type-specific APIs
330 
331 RZ_API RzBaseType *rz_type_db_get_enum(const RzTypeDB *typedb, RZ_NONNULL const char *name);
332 RZ_API RzBaseType *rz_type_db_get_union(const RzTypeDB *typedb, RZ_NONNULL const char *name);
333 RZ_API RzBaseType *rz_type_db_get_struct(const RzTypeDB *typedb, RZ_NONNULL const char *name);
334 RZ_API RzBaseType *rz_type_db_get_typedef(const RzTypeDB *typedb, RZ_NONNULL const char *name);
335 
336 RZ_API int rz_type_db_enum_member_by_name(const RzTypeDB *typedb, RZ_NONNULL const char *name, const char *member);
337 RZ_API RZ_BORROW const char *rz_type_db_enum_member_by_val(const RzTypeDB *typedb, RZ_NONNULL const char *name, ut64 val);
338 RZ_API RZ_OWN RzList /*<char *>*/ *rz_type_db_find_enums_by_val(const RzTypeDB *typedb, ut64 val);
339 RZ_API RZ_OWN char *rz_type_db_enum_get_bitfield(const RzTypeDB *typedb, RZ_NONNULL const char *name, ut64 val);
340 
341 // Type size calculation
349 
350 // Various type helpers
351 RZ_API bool rz_type_atomic_eq(const RzTypeDB *typedb, RZ_NONNULL const RzType *typ1, RZ_NONNULL const RzType *typ2);
352 RZ_API bool rz_type_atomic_str_eq(const RzTypeDB *typedb, RZ_NONNULL const RzType *typ1, RZ_NONNULL const char *name);
353 RZ_API bool rz_type_atomic_is_void(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
354 RZ_API bool rz_type_atomic_is_const(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
355 RZ_API bool rz_type_integral_set_sign(const RzTypeDB *typedb, RZ_NONNULL RzType **type, bool sign);
356 
362 RZ_API bool rz_type_is_strictly_atomic(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
363 RZ_API bool rz_type_is_atomic(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
364 RZ_API bool rz_type_is_default(const RzTypeDB *typedb, RZ_NONNULL const RzType *type);
366 
367 RZ_API RZ_OWN RzType *rz_type_identifier_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, bool is_const);
369 RZ_API RZ_OWN RzType *rz_type_pointer_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, bool is_const);
370 RZ_API RZ_OWN RzType *rz_type_pointer_of_base_type_str(const RzTypeDB *typedb, RZ_NONNULL const char *name, bool is_const);
371 RZ_API RZ_OWN RzType *rz_type_pointer_of_type(const RzTypeDB *typedb, RZ_NONNULL RzType *type, bool is_const);
372 RZ_API RZ_OWN RzType *rz_type_array_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, size_t count);
373 RZ_API RZ_OWN RzType *rz_type_array_of_base_type_str(const RzTypeDB *typedb, RZ_NONNULL const char *name, size_t count);
375 
377 
378 // Type formats (`tp` and `pf` commands)
379 RZ_API const char *rz_type_db_format_get(const RzTypeDB *typedb, const char *name);
380 RZ_API void rz_type_db_format_set(RzTypeDB *typedb, const char *name, const char *fmt);
381 RZ_API RZ_OWN RzList /*<char *>*/ *rz_type_db_format_all(RzTypeDB *typedb);
382 RZ_API void rz_type_db_format_delete(RzTypeDB *typedb, const char *name);
384 
386 RZ_API RZ_OWN char *rz_type_format(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *type);
387 RZ_API int rz_type_format_struct_size(const RzTypeDB *typedb, const char *f, int mode, int n);
388 RZ_API RZ_OWN char *rz_type_format_data(const RzTypeDB *t, RzPrint *p, ut64 seek, const ut8 *b, const int len,
389  const char *formatname, int mode, const char *setval, char *ofield);
392 
393 // Function prototypes api
397 
402 
404 RZ_API bool rz_type_func_save(RzTypeDB *typedb, RZ_NONNULL RzCallable *callable);
405 RZ_API RZ_BORROW RzCallable *rz_type_func_get(RzTypeDB *typedb, RZ_NONNULL const char *func_name);
406 RZ_API bool rz_type_func_delete(RzTypeDB *typedb, RZ_NONNULL const char *func_name);
408 RZ_API bool rz_type_func_exist(RzTypeDB *typedb, RZ_NONNULL const char *func_name);
409 
410 RZ_API RZ_BORROW RzType *rz_type_func_ret(RzTypeDB *typedb, RZ_NONNULL const char *func_name);
411 RZ_API bool rz_type_func_ret_set(RzTypeDB *typedb, const char *func_name, RZ_OWN RZ_NONNULL RzType *type);
412 
413 RZ_API RZ_BORROW const char *rz_type_func_cc(RzTypeDB *typedb, RZ_NONNULL const char *func_name);
414 RZ_API bool rz_type_func_cc_set(RzTypeDB *typedb, const char *name, const char *cc);
415 
416 RZ_API int rz_type_func_args_count(RzTypeDB *typedb, RZ_NONNULL const char *func_name);
417 RZ_API RZ_BORROW RzType *rz_type_func_args_type(RzTypeDB *typedb, RZ_NONNULL const char *func_name, int i);
418 RZ_API RZ_BORROW const char *rz_type_func_args_name(RzTypeDB *typedb, RZ_NONNULL const char *func_name, int i);
419 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);
420 
424 RZ_API RZ_OWN char *rz_type_callable_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzCallable *callable);
426 
427 RZ_API bool rz_type_func_is_noreturn(RzTypeDB *typedb, RZ_NONNULL const char *name);
428 RZ_API bool rz_type_func_noreturn_add(RzTypeDB *typedb, RZ_NONNULL const char *name);
429 RZ_API bool rz_type_func_noreturn_drop(RzTypeDB *typedb, RZ_NONNULL const char *name);
430 
431 RZ_API RZ_OWN RzList /*<char *>*/ *rz_type_function_names(RzTypeDB *typedb);
433 
434 // Listing API
435 RZ_API RZ_OWN RzList /*<char *>*/ *rz_type_db_enum_names(RzTypeDB *typedb);
436 RZ_API RZ_OWN RzList /*<char *>*/ *rz_type_db_struct_names(RzTypeDB *typedb);
437 RZ_API RZ_OWN RzList /*<char *>*/ *rz_type_db_union_names(RzTypeDB *typedb);
438 RZ_API RZ_OWN RzList /*<char *>*/ *rz_type_db_typedef_names(RzTypeDB *typedb);
439 RZ_API RZ_OWN RzList /*<char *>*/ *rz_type_db_all(RzTypeDB *typedb);
440 
441 // Serialization API
446 
447 // Constrained Type
450 RZ_API bool rz_type_cond_eval(RzTypeCond cond, st64 arg0, st64 arg1);
452 #endif
453 
454 #ifdef __cplusplus
455 }
456 #endif
457 
458 #endif
size_t len
Definition: 6502dis.c:15
#define e(frag)
static ut32 cpu[32]
Definition: analysis_or1k.c:21
lzma_index ** i
Definition: index.h:629
ut16 val
Definition: armass64_const.h:6
RZ_API void rz_type_base_type_free(RzBaseType *type)
Frees the RzBaseType instance and all of its members.
Definition: base.c:132
RZ_API void rz_type_base_enum_case_free(void *e, void *user)
Definition: base.c:8
RZ_API void rz_type_base_struct_member_free(void *e, void *user)
Definition: base.c:14
RZ_API RZ_OWN RzList * rz_type_db_get_base_types(const RzTypeDB *typedb)
Returns the list of all basic types.
Definition: base.c:120
RZ_API RZ_BORROW RzBaseType * rz_type_db_get_compound_type(const RzTypeDB *typedb, RZ_NONNULL const char *name)
Searches for the compound RzBaseType in the types database given the name.
Definition: base.c:234
RZ_API RZ_OWN RzBaseType * rz_type_base_type_new(RzBaseTypeKind kind)
Allocates a new instance of RzBaseType given the kind.
Definition: base.c:162
RZ_API RZ_OWN char * rz_type_db_base_type_as_pretty_string(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, unsigned int opts, int unfold_level)
Returns C representation as string of RzBaseType.
Definition: base.c:219
RZ_API void rz_type_db_save_base_type(const RzTypeDB *typedb, const RzBaseType *type)
Saves RzBaseType into the Types DB.
Definition: base.c:191
RZ_API RZ_BORROW const char * rz_type_base_type_kind_as_string(RzBaseTypeKind kind)
Returns string representing the kind of base type.
Definition: base.c:33
RZ_API void rz_type_base_union_member_free(void *e, void *user)
Definition: base.c:21
RZ_API RZ_OWN char * rz_type_db_base_type_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype)
Returns C representation as string of RzBaseType (see rz_type_db_base_type_as_pretty_string for cusom...
Definition: base.c:203
RZ_API RZ_BORROW RzBaseType * rz_type_db_get_base_type(const RzTypeDB *typedb, RZ_NONNULL const char *name)
Searches for the RzBaseType in the types database given the name.
Definition: base.c:57
RZ_API bool rz_type_db_delete_base_type(RzTypeDB *typedb, RZ_NONNULL RzBaseType *type)
Removes RzBaseType from the Types DB.
Definition: base.c:74
RZ_API RZ_OWN RzList * rz_type_db_get_base_types_of_kind(const RzTypeDB *typedb, RzBaseTypeKind kind)
Returns the list of all basic types of the chosen kind.
Definition: base.c:100
int bits(struct state *s, int need)
Definition: blast.c:72
RZ_API RZ_OWN RzTypeParser * rz_type_parser_init(HtPP *types, HtPP *callables)
Creates a new instance of the C type parser.
Definition: c_cpp_parser.c:115
RZ_API int rz_type_parse_file(RzTypeDB *typedb, const char *path, const char *dir, char **error_msg)
Parses the C types file creating the new parser state.
Definition: c_cpp_parser.c:260
RZ_API RZ_OWN RzType * rz_type_parse_string_declaration_single(RzTypeParser *parser, const char *code, char **error_msg)
Parses the single C type declaration.
Definition: c_cpp_parser.c:411
RZ_API RZ_OWN RzTypeParser * rz_type_parser_new()
Creates a new instance of the C type parser.
Definition: c_cpp_parser.c:96
RZ_API void rz_type_parser_free(RZ_NONNULL RzTypeParser *parser)
Frees the instance of the C type parser without destroying hashtables.
Definition: c_cpp_parser.c:127
RZ_API RZ_OWN RzType * rz_type_parse_string_single(RzTypeParser *parser, const char *code, char **error_msg)
Parses the single C type definition.
Definition: c_cpp_parser.c:309
RZ_API int rz_type_parse_string_stateless(RzTypeParser *parser, const char *code, char **error_msg)
Parses the C type string reusing the existing parser state.
Definition: c_cpp_parser.c:227
RZ_API int rz_type_parse_file_stateless(RzTypeParser *parser, const char *path, const char *dir, char **error_msg)
Parses the C types file reusing the existing parser state.
Definition: c_cpp_parser.c:239
RZ_API void rz_type_parse_reset(RzTypeDB *typedb)
Reset the C parser state.
Definition: c_cpp_parser.c:297
RZ_API int rz_type_parse_string(RzTypeDB *typedb, const char *code, char **error_msg)
Parses the C type string creating the new parser state.
Definition: c_cpp_parser.c:280
RZ_API void rz_type_parser_free_purge(RZ_NONNULL RzTypeParser *parser)
Frees the instance of the C type parser and destroy the hashtables.
Definition: c_cpp_parser.c:136
#define RZ_API
cs_arch arch
Definition: cstool.c:13
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
RZ_API RZ_OWN char * rz_base_type_as_format(const RzTypeDB *typedb, RZ_NONNULL RzBaseType *type)
Represents the RzBaseType as a pf format string.
Definition: format.c:2941
RZ_API RZ_OWN char * rz_type_as_format(const RzTypeDB *typedb, RZ_NONNULL RzType *type)
Represents the RzType as a pf format string.
Definition: format.c:3005
RZ_API void rz_type_db_format_set(RzTypeDB *typedb, const char *name, const char *fmt)
Definition: format.c:1912
RZ_API RZ_OWN char * rz_type_format(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *name)
Represents the RzBaseType as a pf format string.
Definition: format.c:2965
RZ_API void rz_type_db_format_delete(RzTypeDB *typedb, const char *name)
Definition: format.c:1932
RZ_API int rz_type_format_struct_size(const RzTypeDB *typedb, const char *f, int mode, int n)
Definition: format.c:1515
RZ_API const char * rz_type_db_format_get(const RzTypeDB *typedb, const char *name)
Definition: format.c:1901
RZ_API RZ_OWN char * rz_type_as_format_pair(const RzTypeDB *typedb, RZ_NONNULL RzType *type)
Represents the RzType as a pf format string pair.
Definition: format.c:3075
RZ_API RZ_OWN RzList * rz_type_db_format_all(RzTypeDB *typedb)
Definition: format.c:1925
RZ_API RZ_OWN char * rz_type_format_data(const RzTypeDB *typedb, RzPrint *p, ut64 seek, const ut8 *b, const int len, const char *formatname, int mode, const char *setval, char *ofield)
Definition: format.c:2749
RZ_API bool rz_type_is_identifier(RZ_NONNULL const RzType *type)
Checks if the RzType is identifier.
Definition: helpers.c:338
RZ_API bool rz_type_is_char_ptr_nested(RZ_NONNULL const RzType *type)
Checks if the pointer RzType is a nested pointer of string ("char **", "char ***",...
Definition: helpers.c:328
RZ_API RZ_OWN RzType * rz_type_pointer_of_base_type_str(const RzTypeDB *typedb, RZ_NONNULL const char *name, bool is_const)
Creates a new pointer RzType from the given RzBaseType name.
Definition: helpers.c:86
RZ_API bool rz_type_is_void_ptr_nested(RZ_NONNULL const RzType *type)
Checks if the pointer RzType is a nested abstract pointer ("void **", "vpod ***", etc)
Definition: helpers.c:308
RZ_API RzTypeCond rz_type_cond_invert(RzTypeCond cond)
return the inverted condition
Definition: helpers.c:504
RZ_API bool rz_type_atomic_str_eq(const RzTypeDB *typedb, RZ_NONNULL const RzType *typ1, RZ_NONNULL const char *name)
Checks if two atomic types (RzType and RzBaseType) are equivalent.
Definition: helpers.c:208
RZ_API bool rz_type_is_strictly_atomic(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is strictly atomic.
Definition: helpers.c:349
RZ_API RZ_OWN RzType * rz_type_identifier_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, bool is_const)
Creates a new RzType indentifier from the given RzBaseType.
Definition: helpers.c:15
RZ_API RZ_BORROW const char * rz_type_cond_tostring(RzTypeCond cc)
RzTypeCond enum to string.
Definition: helpers.c:471
RZ_API RZ_OWN RzType * rz_type_array_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, size_t count)
Creates a new array RzType from the given RzBaseType.
Definition: helpers.c:124
RZ_API bool rz_type_is_atomic(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is atomic or derivative of it.
Definition: helpers.c:371
RZ_API bool rz_type_is_void_ptr(RZ_NONNULL const RzType *type)
Checks if the pointer RzType is abstract pointer ("void *")
Definition: helpers.c:298
RZ_API RZ_OWN RzType * rz_type_pointer_of_base_type(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *btype, bool is_const)
Creates a new pointer RzType from the given RzBaseType.
Definition: helpers.c:63
RZ_API RZ_OWN RzType * rz_type_array_of_type(const RzTypeDB *typedb, RZ_NONNULL RzType *type, size_t count)
Creates a new array RzType from the given RzType.
Definition: helpers.c:163
RZ_API bool rz_type_atomic_is_const(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the atomic RzType is "const".
Definition: helpers.c:246
RZ_API RZ_OWN RzType * rz_type_array_of_base_type_str(const RzTypeDB *typedb, RZ_NONNULL const char *name, size_t count)
Creates a new array RzType from the given RzBaseType name.
Definition: helpers.c:147
RZ_API bool rz_type_is_default(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is default.
Definition: helpers.c:399
RZ_API RZ_OWN RzType * rz_type_new_default(const RzTypeDB *typedb)
Creates a new instance of the default RzType type.
Definition: helpers.c:415
RZ_API RZ_OWN RzType * rz_type_pointer_of_type(const RzTypeDB *typedb, RZ_NONNULL RzType *type, bool is_const)
Creates a new pointer RzType from the given RzType.
Definition: helpers.c:102
RZ_API bool rz_type_atomic_is_void(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is "void".
Definition: helpers.c:232
RZ_API bool rz_type_cond_eval_single(RzTypeCond cond, st64 arg0)
Same as rz_type_cond_eval, but it assumes arg1 to be 0.
Definition: helpers.c:554
RZ_API bool rz_type_is_char_ptr(RZ_NONNULL const RzType *type)
Checks if the pointer RzType is a string ("char *" or "const char *")
Definition: helpers.c:318
RZ_API bool rz_type_integral_set_sign(const RzTypeDB *typedb, RZ_NONNULL RzType **type, bool sign)
If the type is unsigned it sets the sign.
Definition: helpers.c:430
RZ_API bool rz_type_cond_eval(RzTypeCond cond, st64 arg0, st64 arg1)
evaluate the type condition on the arguments and return a bool accordingly.
Definition: helpers.c:534
RZ_API RZ_OWN RzType * rz_type_identifier_of_base_type_str(const RzTypeDB *typedb, RZ_NONNULL const char *name)
Creates a new RzType indentifier from the given RzBaseType name.
Definition: helpers.c:47
RZ_API bool rz_type_atomic_eq(const RzTypeDB *typedb, RZ_NONNULL const RzType *typ1, RZ_NONNULL const RzType *typ2)
Checks if two atomic RzTypes are equivalent.
Definition: helpers.c:183
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
const char int mode
Definition: ioapi.h:137
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
int n
Definition: mipsasm.c:19
int type
Definition: mipsasm.c:17
insn_type_descr_t types[]
Definition: or1k_disas.c:7
struct rz_type_union_member_t RzTypeUnionMember
RzBaseTypeKind
Definition: rz_type.h:72
@ RZ_BASE_TYPE_KIND_TYPEDEF
Definition: rz_type.h:76
@ RZ_BASE_TYPE_KIND_ATOMIC
Definition: rz_type.h:77
@ RZ_BASE_TYPE_KIND_UNION
Definition: rz_type.h:74
@ RZ_BASE_TYPE_KIND_STRUCT
Definition: rz_type.h:73
@ RZ_BASE_TYPE_KIND_ENUM
Definition: rz_type.h:75
struct rz_type_path_t RzTypePath
struct rz_type_constraint_t RzTypeConstraint
type constrained by the type conditions
RzTypeAttributeMask
Definition: rz_type.h:54
@ RZ_TYPE_ATTRIBUTE_TYPECLASS_MASK
Definition: rz_type.h:56
RzTypeIdentifierKind
Definition: rz_type.h:134
@ RZ_TYPE_IDENTIFIER_KIND_STRUCT
Definition: rz_type.h:136
@ RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED
Definition: rz_type.h:135
@ RZ_TYPE_IDENTIFIER_KIND_ENUM
Definition: rz_type.h:138
@ RZ_TYPE_IDENTIFIER_KIND_UNION
Definition: rz_type.h:137
struct rz_type_struct_member_t RzTypeStructMember
RzTypePrintOpts
Definition: rz_type.h:214
@ RZ_TYPE_PRINT_NO_END_SEMICOLON
Definition: rz_type.h:220
@ RZ_TYPE_PRINT_ZERO_VLA
Definition: rz_type.h:219
@ RZ_TYPE_PRINT_SHOW_TYPEDEF
Definition: rz_type.h:223
@ RZ_TYPE_PRINT_NO_OPTS
Definition: rz_type.h:215
@ RZ_TYPE_PRINT_UNFOLD_ANON_ONLY
Definition: rz_type.h:217
@ RZ_TYPE_PRINT_UNFOLD_ANON_ONLY_STRICT
Definition: rz_type.h:218
@ RZ_TYPE_PRINT_END_NEWLINE
Definition: rz_type.h:222
@ RZ_TYPE_PRINT_MULTILINE
Definition: rz_type.h:216
@ RZ_TYPE_PRINT_ANONYMOUS
Definition: rz_type.h:221
struct rz_type_target_t RzTypeTarget
struct rz_callable_at RzCallable
struct rz_base_type_union_t RzBaseTypeUnion
ut64 RzTypeAttribute
Definition: rz_type.h:52
struct rz_base_type_enum_t RzBaseTypeEnum
struct rz_base_type_t RzBaseType
struct rz_callable_arg_t RzCallableArg
RzTypeTypeclass
Definition: rz_type.h:61
@ RZ_TYPE_TYPECLASS_FLOATING
Definition: rz_type.h:65
@ RZ_TYPE_TYPECLASS_NONE
Definition: rz_type.h:62
@ RZ_TYPE_TYPECLASS_INVALID
Definition: rz_type.h:69
@ RZ_TYPE_TYPECLASS_ADDRESS
Definition: rz_type.h:66
@ RZ_TYPE_TYPECLASS_NUM
Definition: rz_type.h:63
@ RZ_TYPE_TYPECLASS_INTEGRAL
Definition: rz_type.h:64
@ RZ_TYPE_TYPECLASS_INTEGRAL_SIGNED
Definition: rz_type.h:67
@ RZ_TYPE_TYPECLASS_INTEGRAL_UNSIGNED
Definition: rz_type.h:68
RzTypeCond
Type Conditions.
Definition: rz_type.h:182
@ RZ_TYPE_COND_LO
Carry clear Less than.
Definition: rz_type.h:192
@ RZ_TYPE_COND_VS
Overflow Unordered.
Definition: rz_type.h:195
@ RZ_TYPE_COND_HEX_SCL_TRUE
Definition: rz_type.h:199
@ RZ_TYPE_COND_LE
Less or equal.
Definition: rz_type.h:188
@ RZ_TYPE_COND_GE
Greater or equal.
Definition: rz_type.h:186
@ RZ_TYPE_COND_HEX_VEC_TRUE
Definition: rz_type.h:201
@ RZ_TYPE_COND_VC
No overflow Not unordered.
Definition: rz_type.h:196
@ RZ_TYPE_COND_HEX_SCL_FALSE
Definition: rz_type.h:200
@ RZ_TYPE_COND_LS
Unsigned lower or same Less than or equal.
Definition: rz_type.h:198
@ RZ_TYPE_COND_NV
Never executed must be a nop? :D.
Definition: rz_type.h:190
@ RZ_TYPE_COND_EQ
Equal.
Definition: rz_type.h:184
@ RZ_TYPE_COND_HS
Carry set >, ==, or unordered.
Definition: rz_type.h:191
@ RZ_TYPE_COND_NE
Not equal.
Definition: rz_type.h:185
@ RZ_TYPE_COND_AL
Always executed (no condition)
Definition: rz_type.h:183
@ RZ_TYPE_COND_MI
Minus, negative Less than.
Definition: rz_type.h:193
@ RZ_TYPE_COND_HI
Unsigned higher Greater than, or unordered.
Definition: rz_type.h:197
@ RZ_TYPE_COND_GT
Greater than.
Definition: rz_type.h:187
@ RZ_TYPE_COND_HEX_VEC_FALSE
Definition: rz_type.h:202
@ RZ_TYPE_COND_PL
Plus, positive or zero >, ==, or unordered.
Definition: rz_type.h:194
@ RZ_TYPE_COND_LT
Less than.
Definition: rz_type.h:189
@ RZ_TYPE_COND_EXCEPTION
Definition: rz_type.h:203
struct rz_type_enum_case_t RzTypeEnumCase
struct rz_base_type_struct_t RzBaseTypeStruct
RzTypeKind
Definition: rz_type.h:127
@ RZ_TYPE_KIND_ARRAY
Definition: rz_type.h:130
@ RZ_TYPE_KIND_CALLABLE
Definition: rz_type.h:131
@ RZ_TYPE_KIND_IDENTIFIER
Definition: rz_type.h:128
@ RZ_TYPE_KIND_POINTER
Definition: rz_type.h:129
struct rz_type_db_t RzTypeDB
RZ_LIB_VERSION_HEADER(rz_type)
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_BORROW
Definition: rz_types.h:63
#define st64
Definition: rz_types_base.h:10
RZ_API bool rz_type_db_load_callables_sdb_str(RzTypeDB *typedb, RZ_NONNULL const char *str)
Loads the callable types from SDB KV string.
RZ_API bool rz_serialize_callables_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzTypeDB *typedb, RZ_NULLABLE RzSerializeResultInfo *res)
Loads the callable types from SDB.
RZ_API bool rz_type_db_load_callables_sdb(RzTypeDB *typedb, RZ_NONNULL const char *path)
Loads the callable types from compiled SDB specified by path.
RZ_API void rz_serialize_callables_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzTypeDB *typedb)
Saves the callable types into SDB.
RZ_API void rz_serialize_types_save(RZ_NONNULL Sdb *db, RZ_NONNULL const RzTypeDB *typedb)
Saves the types into SDB.
RZ_API bool rz_type_db_load_sdb_str(RzTypeDB *typedb, RZ_NONNULL const char *str)
Loads the types from SDB KV string.
RZ_API bool rz_serialize_types_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzTypeDB *typedb, RZ_NULLABLE RzSerializeResultInfo *res)
Loads the types from SDB.
RZ_API bool rz_type_db_load_sdb(RzTypeDB *typedb, RZ_NONNULL const char *path)
Loads the types from compiled SDB specified by path.
#define b(i)
Definition: sha256.c:42
#define f(i)
Definition: sha256.c:46
#define cond(bop, top, mask, flags)
Definition: inftree9.h:24
Definition: z80asm.h:102
RzVector cases
Definition: rz_type.h:108
RzBaseTypeStruct struct_data
Definition: rz_type.h:118
char * name
Definition: rz_type.h:112
RzType * type
Definition: rz_type.h:113
RzBaseTypeEnum enum_data
Definition: rz_type.h:119
RzBaseTypeUnion union_data
Definition: rz_type.h:120
RzBaseTypeKind kind
Definition: rz_type.h:115
RzTypeAttribute attrs
Definition: rz_type.h:116
RzVector members
Definition: rz_type.h:104
RzType * type
Definition: rz_type.h:143
RZ_NULLABLE char * name
Definition: rz_type.h:142
RzPVector * args
optional for the time being
Definition: rz_type.h:149
RZ_NULLABLE const char * cc
Definition: rz_type.h:150
RZ_NULLABLE char * name
Definition: rz_type.h:147
RZ_NULLABLE RzType * ret
Definition: rz_type.h:148
type constrained by the type conditions
Definition: rz_type.h:209
RzTypeCond cond
Definition: rz_type.h:210
RzTypeParser * parser
Definition: rz_type.h:37
HtPP * callables
Definition: rz_type.h:35
void * user
Definition: rz_type.h:32
RzNum * num
Definition: rz_type.h:38
HtPP * formats
Definition: rz_type.h:34
RzIOBind iob
Definition: rz_type.h:39
HtPP * types
Definition: rz_type.h:33
RzTypeTarget * target
Definition: rz_type.h:36
RzType * typ
Definition: rz_type.h:175
char * path
Definition: rz_type.h:176
char * name
Definition: rz_type.h:159
RzTypeIdentifierKind kind
Definition: rz_type.h:158
ut64 count
Definition: rz_type.h:168
RzTypeKind kind
Definition: rz_type.h:155
bool is_const
Definition: rz_type.h:160
struct rz_type_t::@292::@295 pointer
RzType * type
Definition: rz_type.h:163
struct rz_type_t::@292::@294 identifier
RzCallable * callable
Definition: rz_type.h:170
struct rz_type_t::@292::@296 array
int addr_bits
size of a pointer if > 0, otherwise bits is used.
Definition: rz_type.h:23
char * cpu
Definition: rz_type.h:21
const char * default_type
Definition: rz_type.h:26
bool big_endian
Definition: rz_type.h:25
Definition: sdb.h:63
RZ_API RZ_OWN RzCallable * rz_type_callable_clone(RZ_BORROW RZ_NONNULL const RzCallable *callable)
Creates an exact clone of the RzCallable type.
Definition: function.c:33
RZ_API RZ_BORROW RzCallable * rz_type_func_get(RzTypeDB *typedb, RZ_NONNULL const char *name)
Returns the RzCallable from the database by name.
Definition: function.c:162
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.
Definition: function.c:246
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.
Definition: function.c:116
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.
Definition: function.c:262
RZ_API bool rz_type_func_noreturn_drop(RzTypeDB *typedb, RZ_NONNULL const char *name)
Drops the "noreturn" attribute from the RzCallable type.
Definition: function.c:543
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.
Definition: function.c:302
RZ_API bool rz_type_func_is_noreturn(RzTypeDB *typedb, RZ_NONNULL const char *name)
Checks if the RzCallable type is defined as "noreturn".
Definition: function.c:503
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.
Definition: function.c:131
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.
Definition: function.c:215
RZ_API bool rz_type_is_callable_ptr(RZ_NONNULL const RzType *type)
Checks if the RzType is the pointer to the RzCallable.
Definition: function.c:375
RZ_API void rz_type_func_delete_all(RzTypeDB *typedb)
Removes all RzCallable types.
Definition: function.c:192
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.
Definition: function.c:203
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.
Definition: function.c:327
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.
Definition: function.c:278
RZ_API RZ_OWN RzCallableArg * rz_type_callable_arg_clone(RZ_BORROW RZ_NONNULL const RzCallableArg *arg)
Creates am exact clone of RzCallableArg.
Definition: function.c:85
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.
Definition: function.c:464
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.
Definition: function.c:69
RZ_API RZ_OWN RzList * rz_type_noreturn_function_names(RzTypeDB *typedb)
Returns the list of all noreturn function type names.
Definition: function.c:588
RZ_API RZ_OWN RzCallable * rz_type_callable_new(RZ_NULLABLE const char *name)
Creates a new RzCallable type.
Definition: function.c:17
RZ_API void rz_type_callable_free(RZ_NONNULL RzCallable *callable)
Frees the RzCallable.
Definition: function.c:55
RZ_API RZ_OWN RzList * rz_type_function_names(RzTypeDB *typedb)
Returns the list of all function type names.
Definition: function.c:567
RZ_API bool rz_type_func_delete(RzTypeDB *typedb, RZ_NONNULL const char *name)
Removes RzCallable type from the types database.
Definition: function.c:179
RZ_API bool rz_type_is_callable(RZ_NONNULL const RzType *type)
Checks if the RzType is the pointer to the RzCallable.
Definition: function.c:364
RZ_API RZ_OWN char * rz_type_callable_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzCallable *callable)
Returns the callable C representation.
Definition: function.c:487
RZ_API bool rz_type_func_save(RzTypeDB *typedb, RZ_NONNULL RzCallable *callable)
Stores RzCallable type in the types database.
Definition: function.c:147
RZ_API void rz_type_callable_arg_free(RzCallableArg *arg)
Frees the RzCallableArg.
Definition: function.c:101
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.
Definition: function.c:230
RZ_API bool rz_type_func_noreturn_add(RzTypeDB *typedb, RZ_NONNULL const char *name)
Adds the "noreturn" attribute to the RzCallable type.
Definition: function.c:518
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.
Definition: function.c:348
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.
Definition: function.c:399
RZ_API ut64 rz_type_db_struct_member_offset(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *member)
Returns the offset in bytes of the structure member if there is a match.
Definition: path.c:269
RZ_API st64 rz_type_offset_by_path(const RzTypeDB *typedb, RZ_NONNULL const char *path)
Returns the offset of the member given path.
Definition: path.c:120
RZ_API RZ_OWN RzTypePath * rz_type_path_new(RZ_BORROW RZ_NONNULL RzType *type, RZ_OWN RZ_NONNULL char *path)
Creates a new instance of RzTypePath.
Definition: path.c:13
RZ_API RZ_OWN RzList * rz_type_db_get_by_offset(const RzTypeDB *typedb, ut64 offset)
Returns the list of all structured types that have members matching the offset.
Definition: path.c:219
RZ_API ut64 rz_type_db_struct_member_packed_offset(RZ_NONNULL const RzTypeDB *typedb, RZ_NONNULL const char *name, RZ_NONNULL const char *member)
Returns the packed offset in bits of the structure member if there is a match.
Definition: path.c:244
RZ_API RZ_OWN RzList * rz_type_path_by_offset(const RzTypeDB *typedb, RzBaseType *btype, ut64 offset)
Returns the list of all type paths matching the offset.
Definition: path.c:176
RZ_API void rz_type_path_free(RZ_NULLABLE RzTypePath *tpath)
Frees the RzTypePath.
Definition: path.c:31
RZ_API void rz_type_db_set_address_bits(RzTypeDB *typedb, int addr_bits)
Set the RzType target adress size.
Definition: type.c:161
RZ_API ut64 rz_type_db_union_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype)
Returns the union type size in bits (target dependent)
Definition: type.c:723
RZ_API void rz_type_db_reload(RzTypeDB *typedb, const char *types_dir)
Re-initializes the types database for current target.
Definition: type.c:357
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)
Definition: type.c:755
RZ_API int rz_type_kind(RzTypeDB *typedb, RZ_NONNULL const char *name)
Returns the kind (RzBaseTypeKind) of the type.
Definition: type.c:474
RZ_API void rz_type_db_set_os(RzTypeDB *typedb, const char *os)
Set the RzType target architecture operating system.
Definition: type.c:175
RZ_API RZ_BORROW const char * rz_type_identifier(RZ_NONNULL const RzType *type)
Returns the type C identifier.
Definition: type.c:1155
RZ_API void rz_type_db_set_bits(RzTypeDB *typedb, int bits)
Set the RzType target architecture bits.
Definition: type.c:145
RZ_API ut64 rz_type_db_get_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzType *type)
Returns the type size in bits (target dependent)
Definition: type.c:779
RZ_API bool rz_types_equal(RZ_NONNULL const RzType *type1, RZ_NONNULL const RzType *type2)
Checks if two types are identical.
Definition: type.c:1218
RZ_API void rz_type_db_free(RzTypeDB *typedb)
Frees the instance of the RzTypeDB.
Definition: type.c:79
RZ_API RZ_OWN char * rz_type_declaration_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Returns the type C declaration representation.
Definition: type.c:829
RZ_API void rz_type_db_purge(RzTypeDB *typedb)
Purges the instance of the RzTypeDB.
Definition: type.c:96
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.
Definition: type.c:508
RZ_API bool rz_type_exists(RzTypeDB *typedb, RZ_NONNULL const char *name)
Checks if the type exists in the Type database.
Definition: type.c:462
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.
Definition: type.c:1305
RZ_API void rz_type_free(RZ_NULLABLE RzType *type)
Frees the RzType.
Definition: type.c:1273
RZ_API ut64 rz_type_db_typedef_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype)
Returns the typedef type size in bits (target dependent)
Definition: type.c:740
RZ_API RZ_OWN RzType * rz_type_clone(RZ_BORROW RZ_NONNULL const RzType *type)
Creates an exact clone of the RzType.
Definition: type.c:1181
RZ_API void rz_type_db_set_endian(RzTypeDB *typedb, bool big_endian)
Set the RzType target architecture CPU.
Definition: type.c:202
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.
Definition: type.c:1130
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.
Definition: type.c:489
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.
Definition: type.c:1251
RZ_API ut64 rz_type_db_enum_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype)
Returns the enum type size in bits (target dependent)
Definition: type.c:695
RZ_API ut8 rz_type_db_pointer_size(const RzTypeDB *typedb)
Returns the pointer size for the current RzTypeDB target set.
Definition: type.c:211
RZ_API ut64 rz_type_db_struct_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype)
Returns the struct type size in bits (target dependent)
Definition: type.c:707
RZ_API RZ_OWN RzList * rz_type_db_enum_names(RzTypeDB *typedb)
Returns the list of all enum names.
Definition: type.c:369
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.
Definition: type.c:584
RZ_API RzTypeDB * rz_type_db_new()
Creates a new instance of the RzTypeDB.
Definition: type.c:34
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.
Definition: type.c:253
RZ_API bool rz_type_db_del(RzTypeDB *typedb, RZ_NONNULL const char *name)
Removes the type from the database.
Definition: type.c:223
RZ_API RZ_OWN RzList * rz_type_db_union_names(RzTypeDB *typedb)
Returns the list of all union names.
Definition: type.c:387
RZ_API ut64 rz_type_db_atomic_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzBaseType *btype)
Returns the atomic type size in bits (target dependent)
Definition: type.c:684
RZ_API RZ_OWN RzList * rz_type_db_struct_names(RzTypeDB *typedb)
Returns the list of all struct names.
Definition: type.c:405
RZ_API RZ_OWN RzList * rz_type_db_all(RzTypeDB *typedb)
Returns the list of all type names.
Definition: type.c:441
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.
Definition: type.c:533
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.
Definition: type.c:841
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.
Definition: type.c:666
RZ_API RZ_OWN RzList * rz_type_db_typedef_names(RzTypeDB *typedb)
Returns the list of all typedef (type aliases) names.
Definition: type.c:423
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.
Definition: type.c:630
RZ_API RZ_OWN char * rz_type_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Returns the type C representation.
Definition: type.c:817
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
Definition: type.c:648
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.
Definition: type.c:559
RZ_API void rz_type_db_format_purge(RzTypeDB *typedb)
Purges formats in the instance of the RzTypeDB.
Definition: type.c:108
RZ_API void rz_type_db_set_cpu(RzTypeDB *typedb, const char *cpu)
Set the RzType target architecture CPU.
Definition: type.c:189
RZ_API bool rz_type_is_num(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is Num typeclass.
Definition: typeclass.c:188
RZ_API bool rz_base_type_is_integral(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
Checks if the RzBaseType is Integral typeclass.
Definition: typeclass.c:203
RZ_API bool rz_base_type_is_floating(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
Checks if the RzBaseType is Floating typeclass.
Definition: typeclass.c:233
RZ_API bool rz_base_type_is_integral_signed(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
Checks if the RzBaseType is Integral and Signed typeclass.
Definition: typeclass.c:255
RZ_API bool rz_type_is_integral_unsigned(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is Integral and Unsigned typeclass.
Definition: typeclass.c:288
RZ_API bool rz_type_is_integral(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is Integral typeclass.
Definition: typeclass.c:218
RZ_API bool rz_base_type_is_num(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
Checks if the RzBaseType is Num typeclass.
Definition: typeclass.c:173
RZ_API RZ_BORROW const char * rz_type_typeclass_as_string(RzTypeTypeclass typeclass)
Returns the string representation of a typeclass.
Definition: typeclass.c:39
RZ_API RzTypeTypeclass rz_type_typeclass(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Gets the type class.
Definition: typeclass.c:160
RZ_API RZ_OWN RzList * rz_type_typeclass_get_all_sized(const RzTypeDB *typedb, RzTypeTypeclass typeclass, size_t size)
Returns the list of all base types given the typeclass and size.
Definition: typeclass.c:354
RZ_API bool rz_base_type_is_integral_unsigned(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
Checks if the RzBaseType is Integral and Unsigned typeclass.
Definition: typeclass.c:277
RZ_API RzTypeTypeclass rz_type_typeclass_from_string(RZ_NONNULL const char *typeclass)
Returns the typeclass from the string name of it.
Definition: typeclass.c:66
RZ_API bool rz_type_is_integral_signed(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is Integral and Signed typeclass.
Definition: typeclass.c:266
RZ_API RZ_OWN RzBaseType * rz_type_typeclass_get_default_sized(const RzTypeDB *typedb, RzTypeTypeclass typeclass, size_t size)
Returns the default base type given the typeclass and size.
Definition: typeclass.c:370
RZ_API RZ_OWN RzList * rz_type_typeclass_get_all(const RzTypeDB *typedb, RzTypeTypeclass typeclass)
Returns the list of all base types given the typeclass.
Definition: typeclass.c:338
RZ_API bool rz_type_is_floating(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Checks if the RzType is Floating typeclass.
Definition: typeclass.c:244
RZ_API RzTypeTypeclass rz_base_type_typeclass(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
Gets the base type class.
Definition: typeclass.c:147
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int seek(char *argv[])