12 #include "../core_private.h"
18 if (strchr(cc,
'(')) {
29 pj_ks(pj,
"cc", result);
59 if (!matches || rz_list_empty(matches)) {
109 RZ_LOG_ERROR(
"Cannot find function at the current offset\n");
115 RZ_LOG_ERROR(
"Cannot find variable \"%s\" in the current function\n", varname);
150 char *error_msg =
NULL;
152 if (!
type || error_msg) {
164 rz_list_foreach (uniq, iter2, type2) {
178 rz_list_foreach (analysis->
fcns,
iter, fcn) {
183 rz_list_foreach (uniq, iter2,
type) {
203 rz_list_foreach (uniq,
iter,
type) {
221 rz_list_foreach (uniq, iter2,
type) {
250 rz_list_foreach (uniq_types,
iter, typestr) {
278 const char *cc = argc > 1 ?
argv[1] :
NULL;
288 const char *cc = argc > 1 ?
argv[1] :
NULL;
364 const char *enum_name = argc > 1 ?
argv[1] :
NULL;
365 const char *enum_member = argc > 2 ?
argv[2] :
NULL;
368 RZ_LOG_ERROR(
"Cannot find anything matching the specified bitfield");
426 const char *enum_value = argc > 1 ?
argv[1] :
NULL;
431 const char *
function = argc > 1 ?
argv[1] :
NULL;
516 for (
int i = 1;
i < argc;
i++) {
526 rz_list_foreach (noretl,
iter,
name) {
552 const char *addr_or_var = argc > 2 ?
argv[2] :
NULL;
612 RZ_LOG_ERROR(
"Cannot get C representation of \"%s\" struct type\n",
argv[1]);
637 RZ_LOG_ERROR(
"Cannot get C representation of \"%s\" struct type\n",
argv[1]);
683 RZ_LOG_ERROR(
"Cannot get C representation of \"%s\" typedef type\n",
argv[1]);
736 RZ_LOG_ERROR(
"Cannot get C representation of \"%s\" union type\n",
argv[1]);
761 RZ_LOG_ERROR(
"Cannot get C representation of \"%s\" union type\n",
argv[1]);
778 const char *
typename = argc > 1 ?
argv[1] :
NULL;
RZ_API RzAnalysisFunction * rz_analysis_get_function_at(RzAnalysis *analysis, ut64 addr)
RZ_API bool rz_analysis_noreturn_add(RzAnalysis *analysis, const char *name, ut64 addr)
RZ_API RZ_OWN RzType * rz_type_parse_string_single(RzTypeParser *parser, const char *code, char **error_msg)
Parses the single C type definition.
RZ_API void rz_type_parse_reset(RzTypeDB *typedb)
Reset the C parser state.
RZ_API void rz_analysis_cc_del(RzAnalysis *analysis, const char *name)
RZ_API char * rz_analysis_cc_get(RzAnalysis *analysis, const char *name)
RZ_API bool rz_analysis_cc_set(RzAnalysis *analysis, const char *expr)
RZ_API int rz_core_cmdf(RzCore *core, const char *fmt,...)
RZ_IPI RzCmdStatus rz_type_link_del_all_handler(RzCore *core, int argc, const char **argv)
static RzCmdStatus type_format_print_hexstring(RzCore *core, const char *type, const char *hexpairs)
RZ_IPI RzCmdStatus rz_type_function_del_handler(RzCore *core, int argc, const char **argv)
static RzCmdStatus type_format_print(RzCore *core, const char *type, ut64 address)
RZ_IPI RzCmdStatus rz_type_noreturn_del_all_handler(RzCore *core, int argc, const char **argv)
static void types_xrefs_all(RzCore *core)
RZ_IPI RzCmdStatus rz_type_union_c_nl_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_structure_c_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_xrefs_list_all_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_link_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_xrefs_function_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_function_del_all_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_del_handler(RzCore *core, int argc, const char **argv)
static void types_cc_print(RzCore *core, const char *cc, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_cc_list_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_list_structure_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_open_sdb_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_cc_del_all_handler(RzCore *core, int argc, const char **argv)
static RzCmdStatus types_enum_member_find_all(RzCore *core, const char *enum_value)
RZ_IPI RzCmdStatus rz_type_del_all_handler(RzCore *core, int argc, const char **argv)
static void types_xrefs(RzCore *core, const char *typestr)
static RzCmdStatus types_enum_member_find(RzCore *core, const char *enum_name, const char *enum_value)
static void type_list_c_all_nl(RzCore *core)
static RzCmdStatus type_format_print_value(RzCore *core, const char *type, ut64 val)
RZ_IPI RzCmdStatus rz_type_noreturn_del_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_open_file_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_function_cc_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_print_hexstring_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_cc_del_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_list_c_nl_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_xrefs_graph_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_list_enum_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_enum_bitfield_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_enum_c_nl_handler(RzCore *core, int argc, const char **argv)
static RzCmdStatus types_xrefs_function(RzCore *core, ut64 addr)
RZ_IPI RzCmdStatus rz_type_list_union_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_enum_find_handler(RzCore *core, int argc, const char **argv)
static void types_xrefs_graph(RzCore *core)
RZ_IPI RzCmdStatus rz_type_list_typedef_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_list_c_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_xrefs_list_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_list_noreturn_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_link_show_handler(RzCore *core, int argc, const char **argv)
static RzCmdStatus type_format_print_variable(RzCore *core, const char *type, const char *varname)
RZ_IPI RzCmdStatus rz_type_list_function_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode)
RZ_IPI RzCmdStatus rz_type_define_handler(RzCore *core, int argc, const char **argv)
static void types_xrefs_summary(RzCore *core)
RZ_IPI RzCmdStatus rz_type_open_editor_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_structure_c_nl_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_enum_c_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_typedef_c_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_print_handler(RzCore *core, int argc, const char **argv)
static void type_list_c_all(RzCore *core)
RZ_IPI RzCmdStatus rz_type_link_del_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_print_value_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_type_union_c_handler(RzCore *core, int argc, const char **argv)
RZ_API int rz_cons_printf(const char *format,...)
RZ_API void rz_cons_println(const char *str)
RZ_IPI void rz_core_types_link_print_all(RzCore *core, RzOutputMode mode)
RZ_IPI void rz_core_types_union_print_format_all(RzCore *core)
RZ_IPI bool rz_types_open_editor(RzCore *core, RZ_NONNULL const char *typename)
RZ_IPI void rz_core_types_function_noreturn_print(RzCore *core, RzOutputMode mode)
RZ_IPI void rz_core_types_typedef_print_all(RzCore *core, RzOutputMode mode)
RZ_IPI RZ_OWN char * rz_core_types_enum_as_c(RzTypeDB *typedb, const RzBaseType *btype, bool multiline)
RZ_IPI RZ_OWN char * rz_core_types_struct_as_c_all(RzTypeDB *typedb, bool multiline)
RZ_IPI void rz_core_types_link_show(RzCore *core, ut64 addr)
RZ_IPI void rz_core_types_function_print(RzTypeDB *typedb, const char *function, RzOutputMode mode, PJ *pj)
RZ_IPI void rz_core_types_function_print_all(RzCore *core, RzOutputMode mode)
RZ_IPI bool rz_types_open_file(RzCore *core, const char *path)
RZ_IPI void rz_core_types_union_print_all(RzCore *core, RzOutputMode mode)
RZ_IPI RZ_OWN char * rz_core_types_typedef_as_c_all(RzTypeDB *typedb)
RZ_IPI void rz_core_types_struct_print_all(RzCore *core, RzOutputMode mode)
RZ_IPI void rz_core_types_struct_print_format_all(RzCore *core)
RZ_IPI void rz_core_types_print_all(RzCore *core, RzOutputMode mode)
RZ_IPI void rz_core_types_enum_print(RzCore *core, const RzBaseType *btype, RzOutputMode mode, PJ *pj)
RZ_IPI RZ_OWN char * rz_core_types_enum_as_c_all(RzTypeDB *typedb, bool multiline)
RZ_IPI RZ_OWN char * rz_core_types_union_as_c_all(RzTypeDB *typedb, bool multiline)
RZ_IPI void rz_core_types_show_format(RzCore *core, const char *name, RzOutputMode mode)
RZ_IPI void rz_core_types_struct_print(RzCore *core, const RzBaseType *btype, RzOutputMode mode, PJ *pj)
RZ_IPI RZ_OWN char * rz_core_types_typedef_as_c(RzTypeDB *typedb, const RzBaseType *btype)
RZ_IPI RZ_OWN char * rz_core_types_struct_as_c(RzTypeDB *typedb, const RzBaseType *btype, bool multiline)
RZ_IPI void rz_types_define(RzCore *core, const char *type)
RZ_IPI void rz_core_types_enum_print_all(RzCore *core, RzOutputMode mode)
RZ_IPI RZ_OWN char * rz_core_types_union_as_c(RzTypeDB *typedb, const RzBaseType *btype, bool multiline)
RZ_IPI void rz_core_types_union_print(RzCore *core, const RzBaseType *btype, RzOutputMode mode, PJ *pj)
RZ_IPI void rz_core_types_typedef_print(RzCore *core, const RzBaseType *btype, RzOutputMode mode, PJ *pj)
RZ_IPI void rz_core_types_calling_conventions_print(RzCore *core, RzOutputMode mode)
RZ_API RZ_OWN char * rz_core_types_as_c(RZ_NONNULL RzCore *core, RZ_NONNULL const char *name, bool multiline)
Get a type string by name (.
RZ_API RZ_OWN char * rz_core_types_as_c_all(RZ_NONNULL RzCore *core, bool multiline)
Get all types with pretty printing.
RZ_API void rz_core_types_link(RzCore *core, const char *typestr, ut64 addr)
Link an address addr to the type referenced by typestr.
RZ_DEPRECATE RZ_API RzAnalysisFunction * rz_analysis_get_fcn_in(RzAnalysis *analysis, ut64 addr, int type)
RZ_API RZ_OWN RzList * rz_analysis_types_from_fcn(RzAnalysis *analysis, RzAnalysisFunction *fcn)
unsigned char match[65280+2]
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API RZ_OWN RzList * rz_list_uniq(RZ_NONNULL const RzList *list, RZ_NONNULL RzListComparator cmp)
Returns a new RzList which contains only unique values.
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp)
Sorts via merge sort or via insertion sort a list.
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
static static fork const void static count static fd const char const char static newpath char char argv
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
insn_type_descr_t types[]
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_OK
command handler exited in the right way
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
int(* RzListComparator)(const void *value, const void *list_data)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API PJ * pj_end(PJ *j)
RZ_API const char * pj_string(PJ *pj)
RZ_API void pj_free(PJ *j)
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
#define RZ_STR_ISEMPTY(x)
RZ_API const char * rz_str_trim_head_ro(const char *str)
RZ_API int rz_str_replace_ch(char *s, char a, char b, bool g)
RzOutputMode
Enum to describe the way data are printed.
@ RZ_OUTPUT_MODE_STANDARD
RZ_API void sdb_reset(Sdb *s)
RZ_API bool rz_type_db_load_sdb(RzTypeDB *typedb, RZ_NONNULL const char *path)
Loads the types from compiled SDB specified by path.
struct rz_list_iter_t * n
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.
RZ_API bool rz_type_func_noreturn_drop(RzTypeDB *typedb, RZ_NONNULL const char *name)
Drops the "noreturn" attribute from the RzCallable type.
RZ_API void rz_type_func_delete_all(RzTypeDB *typedb)
Removes all RzCallable types.
RZ_API RZ_OWN RzList * rz_type_noreturn_function_names(RzTypeDB *typedb)
Returns the list of all noreturn function type names.
RZ_API bool rz_type_func_delete(RzTypeDB *typedb, RZ_NONNULL const char *name)
Removes RzCallable type from the types database.
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.
RZ_API bool rz_type_func_noreturn_add(RzTypeDB *typedb, RZ_NONNULL const char *name)
Adds the "noreturn" attribute to the RzCallable type.
RZ_API RZ_BORROW const char * rz_type_identifier(RZ_NONNULL const RzType *type)
Returns the type C identifier.
RZ_API bool rz_types_equal(RZ_NONNULL const RzType *type1, RZ_NONNULL const RzType *type2)
Checks if two types are identical.
RZ_API void rz_type_db_purge(RzTypeDB *typedb)
Purges the instance of the RzTypeDB.
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.
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.
RZ_API bool rz_type_db_del(RzTypeDB *typedb, RZ_NONNULL const char *name)
Removes the type from the database.
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.
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.
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.
RZ_API RZ_OWN char * rz_type_as_string(const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
Returns the type C representation.
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
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.
RZ_API bool rz_analysis_type_unlink(RzAnalysis *analysis, ut64 addr)
Removes the type link given the address.
RZ_API bool rz_analysis_type_unlink_all(RzAnalysis *analysis)
Removes all type links.
RZ_API ut64 rz_analysis_var_addr(RzAnalysisVar *var)
RZ_API RZ_BORROW RzAnalysisVar * rz_analysis_function_get_var_byname(RzAnalysisFunction *fcn, const char *name)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()