Rizin
unix-like reverse engineering framework and cli tools
cmd_type.c File Reference
#include <string.h>
#include <rz_analysis.h>
#include <rz_cons.h>
#include <rz_core.h>
#include <sdb.h>
#include "../core_private.h"

Go to the source code of this file.

Functions

static void types_cc_print (RzCore *core, const char *cc, RzOutputMode mode)
 
static RzCmdStatus types_enum_member_find (RzCore *core, const char *enum_name, const char *enum_value)
 
static RzCmdStatus types_enum_member_find_all (RzCore *core, const char *enum_value)
 
static void type_list_c_all (RzCore *core)
 
static void type_list_c_all_nl (RzCore *core)
 
static RzCmdStatus type_format_print (RzCore *core, const char *type, ut64 address)
 
static RzCmdStatus type_format_print_variable (RzCore *core, const char *type, const char *varname)
 
static RzCmdStatus type_format_print_value (RzCore *core, const char *type, ut64 val)
 
static RzCmdStatus type_format_print_hexstring (RzCore *core, const char *type, const char *hexpairs)
 
static void types_xrefs (RzCore *core, const char *typestr)
 
static void types_xrefs_summary (RzCore *core)
 
static RzCmdStatus types_xrefs_function (RzCore *core, ut64 addr)
 
static void types_xrefs_graph (RzCore *core)
 
static void types_xrefs_all (RzCore *core)
 
RZ_IPI RzCmdStatus rz_type_handler (RzCore *core, int argc, const char **argv, RzOutputMode mode)
 
RZ_IPI RzCmdStatus rz_type_del_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_del_all_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_cc_list_handler (RzCore *core, int argc, const char **argv, RzOutputMode mode)
 
RZ_IPI RzCmdStatus rz_type_cc_del_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_cc_del_all_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_list_c_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_define_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_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_enum_c_nl_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_enum_find_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_list_function_handler (RzCore *core, int argc, const char **argv, RzOutputMode mode)
 
RZ_IPI RzCmdStatus rz_type_function_del_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_function_cc_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_link_show_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_link_del_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_link_del_all_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_noreturn_del_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_noreturn_del_all_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_open_editor_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_open_sdb_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_print_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_print_hexstring_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_list_structure_handler (RzCore *core, int argc, const char **argv, RzOutputMode mode)
 
RZ_IPI RzCmdStatus rz_type_structure_c_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_list_typedef_handler (RzCore *core, int argc, const char **argv, RzOutputMode mode)
 
RZ_IPI RzCmdStatus rz_type_typedef_c_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_list_union_handler (RzCore *core, int argc, const char **argv, RzOutputMode mode)
 
RZ_IPI RzCmdStatus rz_type_union_c_handler (RzCore *core, int argc, const char **argv)
 
RZ_IPI RzCmdStatus rz_type_union_c_nl_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_xrefs_function_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_xrefs_list_all_handler (RzCore *core, int argc, const char **argv)
 

Function Documentation

◆ rz_type_cc_del_all_handler()

RZ_IPI RzCmdStatus rz_type_cc_del_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 293 of file cmd_type.c.

293  {
294  sdb_reset(core->analysis->sdb_cc);
295  return RZ_CMD_STATUS_OK;
296 }
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24
RZ_API void sdb_reset(Sdb *s)
Definition: sdb.c:433
RzAnalysis * analysis
Definition: rz_core.h:322

References rz_core_t::analysis, RZ_CMD_STATUS_OK, rz_analysis_t::sdb_cc, and sdb_reset().

Referenced by rzshell_cmddescs_init().

◆ rz_type_cc_del_handler()

RZ_IPI RzCmdStatus rz_type_cc_del_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 287 of file cmd_type.c.

287  {
288  const char *cc = argc > 1 ? argv[1] : NULL;
289  rz_analysis_cc_del(core->analysis, cc);
290  return RZ_CMD_STATUS_OK;
291 }
RZ_API void rz_analysis_cc_del(RzAnalysis *analysis, const char *name)
Definition: cc.c:10
#define NULL
Definition: cris-opc.c:27
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40

References rz_core_t::analysis, argv, NULL, rz_analysis_cc_del(), and RZ_CMD_STATUS_OK.

Referenced by rzshell_cmddescs_init().

◆ rz_type_cc_list_handler()

RZ_IPI RzCmdStatus rz_type_cc_list_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 277 of file cmd_type.c.

277  {
278  const char *cc = argc > 1 ? argv[1] : NULL;
279  if (cc) {
280  types_cc_print(core, cc, mode);
281  } else {
283  }
284  return RZ_CMD_STATUS_OK;
285 }
static void types_cc_print(RzCore *core, const char *cc, RzOutputMode mode)
Definition: cmd_type.c:16
RZ_IPI void rz_core_types_calling_conventions_print(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:19
const char int mode
Definition: ioapi.h:137

References argv, NULL, RZ_CMD_STATUS_OK, rz_core_types_calling_conventions_print(), and types_cc_print().

Referenced by rzshell_cmddescs_init().

◆ rz_type_define_handler()

RZ_IPI RzCmdStatus rz_type_define_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 328 of file cmd_type.c.

328  {
329  const char *type = argc > 1 ? argv[1] : NULL;
330  rz_types_define(core, type);
331  return RZ_CMD_STATUS_OK;
332 }
RZ_IPI void rz_types_define(RzCore *core, const char *type)
Definition: ctypes.c:1029
int type
Definition: mipsasm.c:17

References argv, NULL, RZ_CMD_STATUS_OK, rz_types_define(), and type.

Referenced by rzshell_cmddescs_init().

◆ rz_type_del_all_handler()

RZ_IPI RzCmdStatus rz_type_del_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 271 of file cmd_type.c.

271  {
274  return RZ_CMD_STATUS_OK;
275 }
RZ_API void rz_type_parse_reset(RzTypeDB *typedb)
Reset the C parser state.
Definition: c_cpp_parser.c:297
RzTypeDB * typedb
Definition: rz_analysis.h:602
RZ_API void rz_type_db_purge(RzTypeDB *typedb)
Purges the instance of the RzTypeDB.
Definition: type.c:96

References rz_core_t::analysis, RZ_CMD_STATUS_OK, rz_type_db_purge(), rz_type_parse_reset(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_del_handler()

RZ_IPI RzCmdStatus rz_type_del_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 266 of file cmd_type.c.

266  {
267  rz_type_db_del(core->analysis->typedb, argv[1]);
268  return RZ_CMD_STATUS_OK;
269 }
RZ_API bool rz_type_db_del(RzTypeDB *typedb, RZ_NONNULL const char *name)
Removes the type from the database.
Definition: type.c:223

References rz_core_t::analysis, argv, RZ_CMD_STATUS_OK, rz_type_db_del(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_enum_bitfield_handler()

RZ_IPI RzCmdStatus rz_type_enum_bitfield_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 363 of file cmd_type.c.

363  {
364  const char *enum_name = argc > 1 ? argv[1] : NULL;
365  const char *enum_member = argc > 2 ? argv[2] : NULL;
366  int value = rz_type_db_enum_member_by_name(core->analysis->typedb, enum_name, enum_member);
367  if (value == -1) {
368  RZ_LOG_ERROR("Cannot find anything matching the specified bitfield");
369  return RZ_CMD_STATUS_ERROR;
370  }
371  rz_cons_printf("0x%x\n", value);
372  return RZ_CMD_STATUS_OK;
373 }
static int value
Definition: cmd_api.c:93
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
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

References rz_core_t::analysis, argv, NULL, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_printf(), RZ_LOG_ERROR, rz_type_db_enum_member_by_name(), rz_analysis_t::typedb, and value.

Referenced by rzshell_cmddescs_init().

◆ rz_type_enum_c_handler()

RZ_IPI RzCmdStatus rz_type_enum_c_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 375 of file cmd_type.c.

375  {
376  if (argc > 1) {
377  RzBaseType *btype = rz_type_db_get_enum(core->analysis->typedb, argv[1]);
378  if (!btype) {
379  RZ_LOG_ERROR("Cannot find \"%s\" enum type\n", argv[1]);
380  return RZ_CMD_STATUS_ERROR;
381  }
382  char *str = rz_core_types_enum_as_c(core->analysis->typedb, btype, true);
383  if (!str) {
384  RZ_LOG_ERROR("Cannot get C representation of \"%s\" enum type\n", argv[1]);
385  return RZ_CMD_STATUS_ERROR;
386  }
387  rz_cons_print(str);
388  free(str);
389  } else {
390  char *str = rz_core_types_enum_as_c_all(core->analysis->typedb, true);
391  if (!str) {
392  return RZ_CMD_STATUS_ERROR;
393  }
394  rz_cons_print(str);
395  free(str);
396  }
397  return RZ_CMD_STATUS_OK;
398 }
RZ_IPI RZ_OWN char * rz_core_types_enum_as_c(RzTypeDB *typedb, const RzBaseType *btype, bool multiline)
Definition: ctypes.c:123
RZ_IPI RZ_OWN char * rz_core_types_enum_as_c_all(RzTypeDB *typedb, bool multiline)
Definition: ctypes.c:134
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
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

References rz_core_t::analysis, argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_enum_as_c(), rz_core_types_enum_as_c_all(), RZ_LOG_ERROR, rz_type_db_get_enum(), cmd_descs_generate::str, and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_enum_c_nl_handler()

RZ_IPI RzCmdStatus rz_type_enum_c_nl_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 400 of file cmd_type.c.

400  {
401  if (argc > 1) {
402  RzBaseType *btype = rz_type_db_get_enum(core->analysis->typedb, argv[1]);
403  if (!btype) {
404  RZ_LOG_ERROR("Cannot find \"%s\" enum type\n", argv[1]);
405  return RZ_CMD_STATUS_ERROR;
406  }
407  char *str = rz_core_types_enum_as_c(core->analysis->typedb, btype, false);
408  if (!str) {
409  RZ_LOG_ERROR("Cannot get C representation of \"%s\" enum type\n", argv[1]);
410  return RZ_CMD_STATUS_ERROR;
411  }
412  rz_cons_print(str);
413  free(str);
414  } else {
415  char *str = rz_core_types_enum_as_c_all(core->analysis->typedb, false);
416  if (!str) {
417  return RZ_CMD_STATUS_ERROR;
418  }
419  rz_cons_print(str);
420  free(str);
421  }
422  return RZ_CMD_STATUS_OK;
423 }

References rz_core_t::analysis, argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_enum_as_c(), rz_core_types_enum_as_c_all(), RZ_LOG_ERROR, rz_type_db_get_enum(), cmd_descs_generate::str, and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_enum_find_handler()

RZ_IPI RzCmdStatus rz_type_enum_find_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 425 of file cmd_type.c.

425  {
426  const char *enum_value = argc > 1 ? argv[1] : NULL;
427  return types_enum_member_find_all(core, enum_value);
428 }
static RzCmdStatus types_enum_member_find_all(RzCore *core, const char *enum_value)
Definition: cmd_type.c:55

References argv, NULL, and types_enum_member_find_all().

Referenced by rzshell_cmddescs_init().

◆ rz_type_function_cc_handler()

RZ_IPI RzCmdStatus rz_type_function_cc_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 455 of file cmd_type.c.

455  {
456  if (argc > 2) {
457  if (!rz_type_func_cc_set(core->analysis->typedb, argv[1], argv[2])) {
458  RZ_LOG_ERROR("Cannot set function \"%s\" calling convention \"%s\"\n", argv[1], argv[2]);
459  return RZ_CMD_STATUS_ERROR;
460  }
461  } else {
462  const char *cc = rz_type_func_cc(core->analysis->typedb, argv[1]);
463  if (!cc) {
464  RZ_LOG_ERROR("Cannot find function \"%s\" in types database\n", argv[1]);
465  return RZ_CMD_STATUS_ERROR;
466  }
467  rz_cons_println(cc);
468  }
469  return RZ_CMD_STATUS_OK;
470 }
RZ_API void rz_cons_println(const char *str)
Definition: cons.c:233
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 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

References rz_core_t::analysis, argv, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), RZ_LOG_ERROR, rz_type_func_cc(), rz_type_func_cc_set(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_function_del_all_handler()

RZ_IPI RzCmdStatus rz_type_function_del_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 450 of file cmd_type.c.

450  {
452  return RZ_CMD_STATUS_OK;
453 }
RZ_API void rz_type_func_delete_all(RzTypeDB *typedb)
Removes all RzCallable types.
Definition: function.c:192

References rz_core_t::analysis, RZ_CMD_STATUS_OK, rz_type_func_delete_all(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_function_del_handler()

RZ_IPI RzCmdStatus rz_type_function_del_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 445 of file cmd_type.c.

445  {
447  return RZ_CMD_STATUS_OK;
448 }
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

References rz_core_t::analysis, argv, RZ_CMD_STATUS_OK, rz_type_func_delete(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_handler()

RZ_IPI RzCmdStatus rz_type_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 256 of file cmd_type.c.

256  {
257  const char *type = argc > 1 ? argv[1] : NULL;
258  if (type) {
260  } else {
262  }
263  return RZ_CMD_STATUS_OK;
264 }
RZ_IPI void rz_core_types_print_all(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:984
RZ_IPI void rz_core_types_show_format(RzCore *core, const char *name, RzOutputMode mode)
Definition: ctypes.c:568

References argv, NULL, RZ_CMD_STATUS_OK, rz_core_types_print_all(), rz_core_types_show_format(), and type.

Referenced by rzshell_cmddescs_init().

◆ rz_type_link_del_all_handler()

RZ_IPI RzCmdStatus rz_type_link_del_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 495 of file cmd_type.c.

495  {
497  return RZ_CMD_STATUS_OK;
498 }

References rz_core_t::analysis, rz_analysis_type_unlink_all(), and RZ_CMD_STATUS_OK.

Referenced by rzshell_cmddescs_init().

◆ rz_type_link_del_handler()

RZ_IPI RzCmdStatus rz_type_link_del_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 489 of file cmd_type.c.

489  {
490  ut64 addr = rz_num_math(core->num, argv[1]);
492  return RZ_CMD_STATUS_OK;
493 }
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
RzNum * num
Definition: rz_core.h:316
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58

References addr, rz_core_t::analysis, argv, rz_core_t::num, rz_analysis_type_unlink(), RZ_CMD_STATUS_OK, rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_type_link_handler()

RZ_IPI RzCmdStatus rz_type_link_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 472 of file cmd_type.c.

472  {
473  const char *name = argc > 1 ? argv[1] : NULL;
474  ut64 addr = argc > 2 ? rz_num_math(core->num, argv[2]) : core->offset;
475  if (name) {
476  rz_core_types_link(core, name, addr);
477  } else {
479  }
480  return RZ_CMD_STATUS_OK;
481 }
RZ_IPI void rz_core_types_link_print_all(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:931
RZ_API void rz_core_types_link(RzCore *core, const char *typestr, ut64 addr)
Link an address addr to the type referenced by typestr.
Definition: ctypes.c:954
voidpf uLong offset
Definition: ioapi.h:144
Definition: z80asm.h:102

References addr, argv, NULL, rz_core_t::num, rz_core_t::offset, RZ_CMD_STATUS_OK, rz_core_types_link(), rz_core_types_link_print_all(), rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_type_link_show_handler()

RZ_IPI RzCmdStatus rz_type_link_show_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 483 of file cmd_type.c.

483  {
484  ut64 addr = rz_num_math(core->num, argv[1]);
486  return RZ_CMD_STATUS_OK;
487 }
RZ_IPI void rz_core_types_link_show(RzCore *core, ut64 addr)
Definition: ctypes.c:975

References addr, argv, rz_core_t::num, RZ_CMD_STATUS_OK, rz_core_types_link_show(), rz_num_math(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_type_list_c_handler()

RZ_IPI RzCmdStatus rz_type_list_c_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 298 of file cmd_type.c.

298  {
299  if (argc > 1) {
300  char *str = rz_core_types_as_c(core, argv[1], true);
301  if (!str) {
302  RZ_LOG_ERROR("Type \"%s\" not found\n", argv[1]);
303  return RZ_CMD_STATUS_ERROR;
304  }
305  rz_cons_print(str);
306  free(str);
307  } else {
308  type_list_c_all(core);
309  }
310  return RZ_CMD_STATUS_OK;
311 }
static void type_list_c_all(RzCore *core)
Definition: cmd_type.c:72
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 (.
Definition: ctypes.c:424

References argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_as_c(), RZ_LOG_ERROR, cmd_descs_generate::str, and type_list_c_all().

Referenced by rzshell_cmddescs_init().

◆ rz_type_list_c_nl_handler()

RZ_IPI RzCmdStatus rz_type_list_c_nl_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 313 of file cmd_type.c.

313  {
314  if (argc > 1) {
315  char *str = rz_core_types_as_c(core, argv[1], false);
316  if (!str) {
317  RZ_LOG_ERROR("Type \"%s\" not found\n", argv[1]);
318  return RZ_CMD_STATUS_ERROR;
319  }
320  rz_cons_print(str);
321  free(str);
322  } else {
323  type_list_c_all_nl(core);
324  }
325  return RZ_CMD_STATUS_OK;
326 }
static void type_list_c_all_nl(RzCore *core)
Definition: cmd_type.c:80

References argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_as_c(), RZ_LOG_ERROR, cmd_descs_generate::str, and type_list_c_all_nl().

Referenced by rzshell_cmddescs_init().

◆ rz_type_list_enum_handler()

RZ_IPI RzCmdStatus rz_type_list_enum_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 334 of file cmd_type.c.

334  {
335  if (argc > 1) {
336  if (argc > 2) {
337  // TODO: Reconsider the `te <enum_name> <member_value>` syntax change
338  return types_enum_member_find(core, argv[1], argv[2]);
339  } else {
340  PJ *pj = (mode == RZ_OUTPUT_MODE_JSON) ? pj_new() : NULL;
341  RzBaseType *btype = rz_type_db_get_enum(core->analysis->typedb, argv[1]);
342  if (!btype) {
343  RZ_LOG_ERROR("Cannot find \"%s\" enum type\n", argv[1]);
344  pj_free(pj);
345  return RZ_CMD_STATUS_ERROR;
346  }
347  rz_core_types_enum_print(core, btype, mode, pj);
348  if (mode == RZ_OUTPUT_MODE_JSON) {
350  pj_free(pj);
351  }
352  }
353  } else {
354  // A special case, since by default `te` returns only the list of all enums
355  if (mode == RZ_OUTPUT_MODE_STANDARD) {
357  }
359  }
360  return RZ_CMD_STATUS_OK;
361 }
static RzCmdStatus types_enum_member_find(RzCore *core, const char *enum_name, const char *enum_value)
Definition: cmd_type.c:43
RZ_IPI void rz_core_types_enum_print(RzCore *core, const RzBaseType *btype, RzOutputMode mode, PJ *pj)
Definition: ctypes.c:65
RZ_IPI void rz_core_types_enum_print_all(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:104
RZ_API PJ * pj_new(void)
Definition: pj.c:25
RZ_API const char * pj_string(PJ *pj)
Definition: pj.c:57
RZ_API void pj_free(PJ *j)
Definition: pj.c:34
@ RZ_OUTPUT_MODE_JSON
Definition: rz_types.h:40
@ RZ_OUTPUT_MODE_QUIET
Definition: rz_types.h:42
@ RZ_OUTPUT_MODE_STANDARD
Definition: rz_types.h:39
Definition: rz_pj.h:12

References rz_core_t::analysis, argv, NULL, pj_free(), pj_new(), pj_string(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), rz_core_types_enum_print(), rz_core_types_enum_print_all(), RZ_LOG_ERROR, RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_QUIET, RZ_OUTPUT_MODE_STANDARD, rz_type_db_get_enum(), rz_analysis_t::typedb, and types_enum_member_find().

Referenced by rzshell_cmddescs_init().

◆ rz_type_list_function_handler()

RZ_IPI RzCmdStatus rz_type_list_function_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 430 of file cmd_type.c.

430  {
431  const char *function = argc > 1 ? argv[1] : NULL;
432  if (function) {
433  PJ *pj = (mode == RZ_OUTPUT_MODE_JSON) ? pj_new() : NULL;
434  rz_core_types_function_print(core->analysis->typedb, function, mode, pj);
435  if (mode == RZ_OUTPUT_MODE_JSON) {
437  pj_free(pj);
438  }
439  } else {
441  }
442  return RZ_CMD_STATUS_OK;
443 }
RZ_IPI void rz_core_types_function_print(RzTypeDB *typedb, const char *function, RzOutputMode mode, PJ *pj)
Definition: ctypes.c:472
RZ_IPI void rz_core_types_function_print_all(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:509

References rz_core_t::analysis, argv, NULL, pj_free(), pj_new(), pj_string(), RZ_CMD_STATUS_OK, rz_cons_println(), rz_core_types_function_print(), rz_core_types_function_print_all(), RZ_OUTPUT_MODE_JSON, and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_list_noreturn_handler()

RZ_IPI RzCmdStatus rz_type_list_noreturn_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 500 of file cmd_type.c.

500  {
501  const char *name = argc > 1 ? argv[1] : NULL;
502  if (name) {
503  ut64 n = rz_num_math(core->num, name);
504  if (n) {
506  } else {
508  }
509  } else {
511  }
512  return RZ_CMD_STATUS_OK;
513 }
RZ_API bool rz_analysis_noreturn_add(RzAnalysis *analysis, const char *name, ut64 addr)
Definition: analysis.c:466
RZ_IPI void rz_core_types_function_noreturn_print(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:553
int n
Definition: mipsasm.c:19
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

References rz_core_t::analysis, argv, n, NULL, rz_core_t::num, rz_analysis_noreturn_add(), RZ_CMD_STATUS_OK, rz_core_types_function_noreturn_print(), rz_num_math(), rz_type_func_noreturn_add(), rz_analysis_t::typedb, and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_type_list_structure_handler()

RZ_IPI RzCmdStatus rz_type_list_structure_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 575 of file cmd_type.c.

575  {
576  if (argc > 1) {
577  if (mode == RZ_OUTPUT_MODE_STANDARD) {
579  } else {
580  PJ *pj = (mode == RZ_OUTPUT_MODE_JSON) ? pj_new() : NULL;
581  RzBaseType *btype = rz_type_db_get_struct(core->analysis->typedb, argv[1]);
582  if (!btype) {
583  RZ_LOG_ERROR("Cannot find \"%s\" struct type\n", argv[1]);
584  pj_free(pj);
585  return RZ_CMD_STATUS_ERROR;
586  }
587  rz_core_types_struct_print(core, btype, mode, pj);
588  if (mode == RZ_OUTPUT_MODE_JSON) {
590  pj_free(pj);
591  }
592  }
593  } else {
594  if (mode == RZ_OUTPUT_MODE_RIZIN) {
596  } else {
598  }
599  }
600  return RZ_CMD_STATUS_OK;
601 }
RZ_IPI void rz_core_types_struct_print_all(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:293
RZ_IPI void rz_core_types_struct_print_format_all(RzCore *core)
Definition: ctypes.c:602
RZ_IPI void rz_core_types_struct_print(RzCore *core, const RzBaseType *btype, RzOutputMode mode, PJ *pj)
Definition: ctypes.c:246
@ RZ_OUTPUT_MODE_RIZIN
Definition: rz_types.h:41
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

References rz_core_t::analysis, argv, NULL, pj_free(), pj_new(), pj_string(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), rz_core_types_show_format(), rz_core_types_struct_print(), rz_core_types_struct_print_all(), rz_core_types_struct_print_format_all(), RZ_LOG_ERROR, RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_RIZIN, RZ_OUTPUT_MODE_STANDARD, rz_type_db_get_struct(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_list_typedef_handler()

RZ_IPI RzCmdStatus rz_type_list_typedef_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 653 of file cmd_type.c.

653  {
654  if (argc > 1) {
655  PJ *pj = (mode == RZ_OUTPUT_MODE_JSON) ? pj_new() : NULL;
657  if (!btype) {
658  RZ_LOG_ERROR("Cannot find \"%s\" typedef type\n", argv[1]);
659  pj_free(pj);
660  return RZ_CMD_STATUS_ERROR;
661  }
662  rz_core_types_typedef_print(core, btype, mode, pj);
663  if (mode == RZ_OUTPUT_MODE_JSON) {
665  pj_free(pj);
666  }
667  } else {
669  }
670  return RZ_CMD_STATUS_OK;
671 }
RZ_IPI void rz_core_types_typedef_print_all(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:366
RZ_IPI void rz_core_types_typedef_print(RzCore *core, const RzBaseType *btype, RzOutputMode mode, PJ *pj)
Definition: ctypes.c:338
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

References rz_core_t::analysis, argv, NULL, pj_free(), pj_new(), pj_string(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), rz_core_types_typedef_print(), rz_core_types_typedef_print_all(), RZ_LOG_ERROR, RZ_OUTPUT_MODE_JSON, rz_type_db_get_typedef(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_list_union_handler()

RZ_IPI RzCmdStatus rz_type_list_union_handler ( RzCore core,
int  argc,
const char **  argv,
RzOutputMode  mode 
)

Definition at line 699 of file cmd_type.c.

699  {
700  if (argc > 1) {
701  if (mode == RZ_OUTPUT_MODE_STANDARD) {
703  } else {
704  PJ *pj = (mode == RZ_OUTPUT_MODE_JSON) ? pj_new() : NULL;
705  RzBaseType *btype = rz_type_db_get_union(core->analysis->typedb, argv[1]);
706  if (!btype) {
707  RZ_LOG_ERROR("Cannot find \"%s\" union type\n", argv[1]);
708  pj_free(pj);
709  return RZ_CMD_STATUS_ERROR;
710  }
711  rz_core_types_union_print(core, btype, mode, pj);
712  if (mode == RZ_OUTPUT_MODE_JSON) {
714  pj_free(pj);
715  }
716  }
717  } else {
718  if (mode == RZ_OUTPUT_MODE_RIZIN) {
720  } else {
722  }
723  }
724  return RZ_CMD_STATUS_OK;
725 }
RZ_IPI void rz_core_types_union_print_format_all(RzCore *core)
Definition: ctypes.c:613
RZ_IPI void rz_core_types_union_print_all(RzCore *core, RzOutputMode mode)
Definition: ctypes.c:198
RZ_IPI void rz_core_types_union_print(RzCore *core, const RzBaseType *btype, RzOutputMode mode, PJ *pj)
Definition: ctypes.c:152
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

References rz_core_t::analysis, argv, NULL, pj_free(), pj_new(), pj_string(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), rz_core_types_show_format(), rz_core_types_union_print(), rz_core_types_union_print_all(), rz_core_types_union_print_format_all(), RZ_LOG_ERROR, RZ_OUTPUT_MODE_JSON, RZ_OUTPUT_MODE_RIZIN, RZ_OUTPUT_MODE_STANDARD, rz_type_db_get_union(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_noreturn_del_all_handler()

RZ_IPI RzCmdStatus rz_type_noreturn_del_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 522 of file cmd_type.c.

522  {
524  RzListIter *iter;
525  char *name;
526  rz_list_foreach (noretl, iter, name) {
528  }
529  return RZ_CMD_STATUS_OK;
530 }
const char * name
Definition: op.c:541
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_OWN RzList * rz_type_noreturn_function_names(RzTypeDB *typedb)
Returns the list of all noreturn function type names.
Definition: function.c:588

References rz_core_t::analysis, name, RZ_CMD_STATUS_OK, rz_type_func_noreturn_drop(), rz_type_noreturn_function_names(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_noreturn_del_handler()

RZ_IPI RzCmdStatus rz_type_noreturn_del_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 515 of file cmd_type.c.

515  {
516  for (int i = 1; i < argc; i++) {
518  }
519  return RZ_CMD_STATUS_OK;
520 }
lzma_index ** i
Definition: index.h:629

References rz_core_t::analysis, argv, i, RZ_CMD_STATUS_OK, rz_type_func_noreturn_drop(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_open_editor_handler()

RZ_IPI RzCmdStatus rz_type_open_editor_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 539 of file cmd_type.c.

539  {
540  if (!rz_types_open_editor(core, argv[1])) {
541  return RZ_CMD_STATUS_ERROR;
542  }
543  return RZ_CMD_STATUS_OK;
544 }
RZ_IPI bool rz_types_open_editor(RzCore *core, RZ_NONNULL const char *typename)
Definition: ctypes.c:1075

References argv, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, and rz_types_open_editor().

Referenced by rzshell_cmddescs_init().

◆ rz_type_open_file_handler()

RZ_IPI RzCmdStatus rz_type_open_file_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 532 of file cmd_type.c.

532  {
533  if (!rz_types_open_file(core, argv[1])) {
534  return RZ_CMD_STATUS_ERROR;
535  }
536  return RZ_CMD_STATUS_OK;
537 }
RZ_IPI bool rz_types_open_file(RzCore *core, const char *path)
Definition: ctypes.c:1046

References argv, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, and rz_types_open_file().

Referenced by rzshell_cmddescs_init().

◆ rz_type_open_sdb_handler()

RZ_IPI RzCmdStatus rz_type_open_sdb_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 546 of file cmd_type.c.

546  {
548  return RZ_CMD_STATUS_OK;
549 }
RZ_API bool rz_type_db_load_sdb(RzTypeDB *typedb, RZ_NONNULL const char *path)
Loads the types from compiled SDB specified by path.

References rz_core_t::analysis, argv, RZ_CMD_STATUS_OK, rz_type_db_load_sdb(), and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_print_handler()

RZ_IPI RzCmdStatus rz_type_print_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 551 of file cmd_type.c.

551  {
552  const char *addr_or_var = argc > 2 ? argv[2] : NULL;
553  if (!addr_or_var) {
554  return type_format_print(core, argv[1], core->offset);
555  }
556  ut64 addr = rz_num_math(core->num, addr_or_var);
557  if (!addr) {
558  return type_format_print_variable(core, argv[1], addr_or_var);
559  }
560  return type_format_print(core, argv[1], addr);
561 }
static RzCmdStatus type_format_print(RzCore *core, const char *type, ut64 address)
Definition: cmd_type.c:88
static RzCmdStatus type_format_print_variable(RzCore *core, const char *type, const char *varname)
Definition: cmd_type.c:100
ut64 offset
Definition: rz_core.h:301

References addr, argv, NULL, rz_core_t::num, rz_core_t::offset, rz_num_math(), type_format_print(), type_format_print_variable(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_type_print_hexstring_handler()

RZ_IPI RzCmdStatus rz_type_print_hexstring_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 571 of file cmd_type.c.

571  {
572  return type_format_print_hexstring(core, argv[1], argv[2]);
573 }
static RzCmdStatus type_format_print_hexstring(RzCore *core, const char *type, const char *hexpairs)
Definition: cmd_type.c:137

References argv, and type_format_print_hexstring().

Referenced by rzshell_cmddescs_init().

◆ rz_type_print_value_handler()

RZ_IPI RzCmdStatus rz_type_print_value_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 563 of file cmd_type.c.

563  {
564  const char *value = argc > 2 ? argv[2] : NULL;
565  if (!value) {
566  return type_format_print_value(core, argv[1], core->offset);
567  }
568  return type_format_print_value(core, argv[1], rz_num_math(core->num, value));
569 }
static RzCmdStatus type_format_print_value(RzCore *core, const char *type, ut64 val)
Definition: cmd_type.c:125

References argv, NULL, rz_core_t::num, rz_core_t::offset, rz_num_math(), type_format_print_value(), and value.

Referenced by rzshell_cmddescs_init().

◆ rz_type_structure_c_handler()

RZ_IPI RzCmdStatus rz_type_structure_c_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 603 of file cmd_type.c.

603  {
604  if (argc > 1) {
605  RzBaseType *btype = rz_type_db_get_struct(core->analysis->typedb, argv[1]);
606  if (!btype) {
607  RZ_LOG_ERROR("Cannot find \"%s\" struct type\n", argv[1]);
608  return RZ_CMD_STATUS_ERROR;
609  }
610  char *str = rz_core_types_struct_as_c(core->analysis->typedb, btype, true);
611  if (!str) {
612  RZ_LOG_ERROR("Cannot get C representation of \"%s\" struct type\n", argv[1]);
613  return RZ_CMD_STATUS_ERROR;
614  }
615  rz_cons_print(str);
616  free(str);
617  } else {
618  char *str = rz_core_types_struct_as_c_all(core->analysis->typedb, true);
619  if (!str) {
620  return RZ_CMD_STATUS_ERROR;
621  }
622  rz_cons_print(str);
623  free(str);
624  }
625  return RZ_CMD_STATUS_OK;
626 }
RZ_IPI RZ_OWN char * rz_core_types_struct_as_c_all(RzTypeDB *typedb, bool multiline)
Definition: ctypes.c:320
RZ_IPI RZ_OWN char * rz_core_types_struct_as_c(RzTypeDB *typedb, const RzBaseType *btype, bool multiline)
Definition: ctypes.c:312

References rz_core_t::analysis, argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_struct_as_c(), rz_core_types_struct_as_c_all(), RZ_LOG_ERROR, rz_type_db_get_struct(), cmd_descs_generate::str, and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_structure_c_nl_handler()

RZ_IPI RzCmdStatus rz_type_structure_c_nl_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 628 of file cmd_type.c.

628  {
629  if (argc > 1) {
630  RzBaseType *btype = rz_type_db_get_struct(core->analysis->typedb, argv[1]);
631  if (!btype) {
632  RZ_LOG_ERROR("Cannot find \"%s\" struct type\n", argv[1]);
633  return RZ_CMD_STATUS_ERROR;
634  }
635  char *str = rz_core_types_struct_as_c(core->analysis->typedb, btype, false);
636  if (!str) {
637  RZ_LOG_ERROR("Cannot get C representation of \"%s\" struct type\n", argv[1]);
638  return RZ_CMD_STATUS_ERROR;
639  }
640  rz_cons_print(str);
641  free(str);
642  } else {
643  char *str = rz_core_types_struct_as_c_all(core->analysis->typedb, false);
644  if (!str) {
645  return RZ_CMD_STATUS_ERROR;
646  }
647  rz_cons_print(str);
648  free(str);
649  }
650  return RZ_CMD_STATUS_OK;
651 }

References rz_core_t::analysis, argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_struct_as_c(), rz_core_types_struct_as_c_all(), RZ_LOG_ERROR, rz_type_db_get_struct(), cmd_descs_generate::str, and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_typedef_c_handler()

RZ_IPI RzCmdStatus rz_type_typedef_c_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 673 of file cmd_type.c.

673  {
674  RzTypeDB *typedb = core->analysis->typedb;
675  if (argc > 1) {
677  if (!btype) {
678  RZ_LOG_ERROR("Cannot find \"%s\" typedef type\n", argv[1]);
679  return RZ_CMD_STATUS_ERROR;
680  }
681  char *str = rz_core_types_typedef_as_c(typedb, btype);
682  if (!str) {
683  RZ_LOG_ERROR("Cannot get C representation of \"%s\" typedef type\n", argv[1]);
684  return RZ_CMD_STATUS_ERROR;
685  }
686  rz_cons_print(str);
687  free(str);
688  } else {
689  char *str = rz_core_types_typedef_as_c_all(typedb);
690  if (!str) {
691  return RZ_CMD_STATUS_ERROR;
692  }
693  rz_cons_print(str);
694  free(str);
695  }
696  return RZ_CMD_STATUS_OK;
697 }
RZ_IPI RZ_OWN char * rz_core_types_typedef_as_c_all(RzTypeDB *typedb)
Definition: ctypes.c:392
RZ_IPI RZ_OWN char * rz_core_types_typedef_as_c(RzTypeDB *typedb, const RzBaseType *btype)
Definition: ctypes.c:385

References rz_core_t::analysis, argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_typedef_as_c(), rz_core_types_typedef_as_c_all(), RZ_LOG_ERROR, rz_type_db_get_typedef(), cmd_descs_generate::str, and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_union_c_handler()

RZ_IPI RzCmdStatus rz_type_union_c_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 727 of file cmd_type.c.

727  {
728  if (argc > 1) {
729  RzBaseType *btype = rz_type_db_get_union(core->analysis->typedb, argv[1]);
730  if (!btype) {
731  RZ_LOG_ERROR("Cannot find \"%s\" union type\n", argv[1]);
732  return RZ_CMD_STATUS_ERROR;
733  }
734  char *str = rz_core_types_union_as_c(core->analysis->typedb, btype, true);
735  if (!str) {
736  RZ_LOG_ERROR("Cannot get C representation of \"%s\" union type\n", argv[1]);
737  return RZ_CMD_STATUS_ERROR;
738  }
739  rz_cons_print(str);
740  free(str);
741  } else {
742  char *str = rz_core_types_union_as_c_all(core->analysis->typedb, true);
743  if (!str) {
744  return RZ_CMD_STATUS_ERROR;
745  }
746  rz_cons_print(str);
747  free(str);
748  }
749  return RZ_CMD_STATUS_OK;
750 }
RZ_IPI RZ_OWN char * rz_core_types_union_as_c_all(RzTypeDB *typedb, bool multiline)
Definition: ctypes.c:228
RZ_IPI RZ_OWN char * rz_core_types_union_as_c(RzTypeDB *typedb, const RzBaseType *btype, bool multiline)
Definition: ctypes.c:217

References rz_core_t::analysis, argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_union_as_c(), rz_core_types_union_as_c_all(), RZ_LOG_ERROR, rz_type_db_get_union(), cmd_descs_generate::str, and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_union_c_nl_handler()

RZ_IPI RzCmdStatus rz_type_union_c_nl_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 752 of file cmd_type.c.

752  {
753  if (argc > 1) {
754  RzBaseType *btype = rz_type_db_get_union(core->analysis->typedb, argv[1]);
755  if (!btype) {
756  RZ_LOG_ERROR("Cannot find \"%s\" union type\n", argv[1]);
757  return RZ_CMD_STATUS_ERROR;
758  }
759  char *str = rz_core_types_union_as_c(core->analysis->typedb, btype, false);
760  if (!str) {
761  RZ_LOG_ERROR("Cannot get C representation of \"%s\" union type\n", argv[1]);
762  return RZ_CMD_STATUS_ERROR;
763  }
764  rz_cons_print(str);
765  free(str);
766  } else {
767  char *str = rz_core_types_union_as_c_all(core->analysis->typedb, false);
768  if (!str) {
769  return RZ_CMD_STATUS_ERROR;
770  }
771  rz_cons_print(str);
772  free(str);
773  }
774  return RZ_CMD_STATUS_OK;
775 }

References rz_core_t::analysis, argv, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_types_union_as_c(), rz_core_types_union_as_c_all(), RZ_LOG_ERROR, rz_type_db_get_union(), cmd_descs_generate::str, and rz_analysis_t::typedb.

Referenced by rzshell_cmddescs_init().

◆ rz_type_xrefs_function_handler()

RZ_IPI RzCmdStatus rz_type_xrefs_function_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 787 of file cmd_type.c.

787  {
788  ut64 addr = argc > 1 ? rz_num_math(core->num, argv[1]) : core->offset;
789  return types_xrefs_function(core, addr);
790 }
static RzCmdStatus types_xrefs_function(RzCore *core, ut64 addr)
Definition: cmd_type.c:193

References addr, argv, rz_core_t::num, rz_core_t::offset, rz_num_math(), types_xrefs_function(), and ut64().

Referenced by rzshell_cmddescs_init().

◆ rz_type_xrefs_graph_handler()

RZ_IPI RzCmdStatus rz_type_xrefs_graph_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 792 of file cmd_type.c.

792  {
793  types_xrefs_graph(core);
794  return RZ_CMD_STATUS_OK;
795 }
static void types_xrefs_graph(RzCore *core)
Definition: cmd_type.c:212

References RZ_CMD_STATUS_OK, and types_xrefs_graph().

Referenced by rzshell_cmddescs_init().

◆ rz_type_xrefs_list_all_handler()

RZ_IPI RzCmdStatus rz_type_xrefs_list_all_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 797 of file cmd_type.c.

797  {
798  types_xrefs_all(core);
799  return RZ_CMD_STATUS_OK;
800 }
static void types_xrefs_all(RzCore *core)
Definition: cmd_type.c:231

References RZ_CMD_STATUS_OK, and types_xrefs_all().

Referenced by rzshell_cmddescs_init().

◆ rz_type_xrefs_list_handler()

RZ_IPI RzCmdStatus rz_type_xrefs_list_handler ( RzCore core,
int  argc,
const char **  argv 
)

Definition at line 777 of file cmd_type.c.

777  {
778  const char *typename = argc > 1 ? argv[1] : NULL;
779  if (typename) {
780  types_xrefs(core, typename);
781  } else {
782  types_xrefs_summary(core);
783  }
784  return RZ_CMD_STATUS_OK;
785 }
static void types_xrefs(RzCore *core, const char *typestr)
Definition: cmd_type.c:149
static void types_xrefs_summary(RzCore *core)
Definition: cmd_type.c:173

References argv, NULL, RZ_CMD_STATUS_OK, types_xrefs(), and types_xrefs_summary().

Referenced by rzshell_cmddescs_init().

◆ type_format_print()

static RzCmdStatus type_format_print ( RzCore core,
const char *  type,
ut64  address 
)
static

Definition at line 88 of file cmd_type.c.

88  {
89  char *fmt = rz_type_format(core->analysis->typedb, type);
90  if (RZ_STR_ISEMPTY(fmt)) {
91  RZ_LOG_ERROR("Cannot find type %s\n", type);
92  free(fmt);
93  return RZ_CMD_STATUS_ERROR;
94  }
95  rz_core_cmdf(core, "pf %s @ 0x%08" PFMT64x "\n", fmt, address);
96  free(fmt);
97  return RZ_CMD_STATUS_OK;
98 }
RZ_API int rz_core_cmdf(RzCore *core, const char *fmt,...)
Definition: cmd.c:5413
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
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
#define PFMT64x
Definition: rz_types.h:393

References rz_core_t::analysis, free(), PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_cmdf(), RZ_LOG_ERROR, RZ_STR_ISEMPTY, rz_type_format(), type, and rz_analysis_t::typedb.

Referenced by rz_type_print_handler().

◆ type_format_print_hexstring()

static RzCmdStatus type_format_print_hexstring ( RzCore core,
const char *  type,
const char *  hexpairs 
)
static

Definition at line 137 of file cmd_type.c.

137  {
138  char *fmt = rz_type_format(core->analysis->typedb, type);
139  if (RZ_STR_ISEMPTY(fmt)) {
140  RZ_LOG_ERROR("Cannot find type %s\n", type);
141  free(fmt);
142  return RZ_CMD_STATUS_ERROR;
143  }
144  rz_core_cmdf(core, "pf %s @x:%s", fmt, hexpairs);
145  free(fmt);
146  return RZ_CMD_STATUS_OK;
147 }

References rz_core_t::analysis, free(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_cmdf(), RZ_LOG_ERROR, RZ_STR_ISEMPTY, rz_type_format(), type, and rz_analysis_t::typedb.

Referenced by rz_type_print_hexstring_handler().

◆ type_format_print_value()

static RzCmdStatus type_format_print_value ( RzCore core,
const char *  type,
ut64  val 
)
static

Definition at line 125 of file cmd_type.c.

125  {
126  char *fmt = rz_type_format(core->analysis->typedb, type);
127  if (RZ_STR_ISEMPTY(fmt)) {
128  RZ_LOG_ERROR("Cannot find type %s\n", type);
129  free(fmt);
130  return RZ_CMD_STATUS_ERROR;
131  }
132  rz_core_cmdf(core, "pf %s @v:0x%08" PFMT64x "\n", fmt, val);
133  free(fmt);
134  return RZ_CMD_STATUS_OK;
135 }
ut16 val
Definition: armass64_const.h:6

References rz_core_t::analysis, free(), PFMT64x, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_cmdf(), RZ_LOG_ERROR, RZ_STR_ISEMPTY, rz_type_format(), type, rz_analysis_t::typedb, and val.

Referenced by rz_type_print_value_handler().

◆ type_format_print_variable()

static RzCmdStatus type_format_print_variable ( RzCore core,
const char *  type,
const char *  varname 
)
static

Definition at line 100 of file cmd_type.c.

100  {
101  char *fmt = rz_type_format(core->analysis->typedb, type);
102  if (RZ_STR_ISEMPTY(fmt)) {
103  RZ_LOG_ERROR("Cannot find type \"%s\"\n", type);
104  free(fmt);
105  return RZ_CMD_STATUS_ERROR;
106  }
107  RzAnalysisFunction *fcn = rz_analysis_get_fcn_in(core->analysis, core->offset, -1);
108  if (!fcn) {
109  RZ_LOG_ERROR("Cannot find function at the current offset\n");
110  free(fmt);
111  return RZ_CMD_STATUS_ERROR;
112  }
114  if (!var) {
115  RZ_LOG_ERROR("Cannot find variable \"%s\" in the current function\n", varname);
116  free(fmt);
117  return RZ_CMD_STATUS_ERROR;
118  }
120  rz_core_cmdf(core, "pf %s @ 0x%08" PFMT64x "\n", fmt, addr);
121  free(fmt);
122  return RZ_CMD_STATUS_OK;
123 }
RZ_DEPRECATE RZ_API RzAnalysisFunction * rz_analysis_get_fcn_in(RzAnalysis *analysis, ut64 addr, int type)
Definition: fcn.c:1687
RZ_API ut64 rz_analysis_var_addr(RzAnalysisVar *var)
Definition: var.c:270
RZ_API RZ_BORROW RzAnalysisVar * rz_analysis_function_get_var_byname(RzAnalysisFunction *fcn, const char *name)
Definition: var.c:247

References addr, rz_core_t::analysis, free(), rz_core_t::offset, PFMT64x, rz_analysis_function_get_var_byname(), rz_analysis_get_fcn_in(), rz_analysis_var_addr(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_core_cmdf(), RZ_LOG_ERROR, RZ_STR_ISEMPTY, rz_type_format(), type, rz_analysis_t::typedb, and ut64().

Referenced by rz_type_print_handler().

◆ type_list_c_all()

static void type_list_c_all ( RzCore core)
static

Definition at line 72 of file cmd_type.c.

72  {
73  char *str = rz_core_types_as_c_all(core, true);
74  if (str) {
75  rz_cons_print(str);
76  free(str);
77  }
78 }
RZ_API RZ_OWN char * rz_core_types_as_c_all(RZ_NONNULL RzCore *core, bool multiline)
Get all types with pretty printing.
Definition: ctypes.c:439

References free(), rz_core_types_as_c_all(), and cmd_descs_generate::str.

Referenced by rz_type_list_c_handler().

◆ type_list_c_all_nl()

static void type_list_c_all_nl ( RzCore core)
static

Definition at line 80 of file cmd_type.c.

80  {
81  char *str = rz_core_types_as_c_all(core, false);
82  if (str) {
83  rz_cons_print(str);
84  free(str);
85  }
86 }

References free(), rz_core_types_as_c_all(), and cmd_descs_generate::str.

Referenced by rz_type_list_c_nl_handler().

◆ types_cc_print()

static void types_cc_print ( RzCore core,
const char *  cc,
RzOutputMode  mode 
)
static

Definition at line 16 of file cmd_type.c.

16  {
18  if (strchr(cc, '(')) {
19  if (!rz_analysis_cc_set(core->analysis, cc)) {
20  RZ_LOG_ERROR("Invalid syntax in cc signature.");
21  }
22  } else {
23  const char *ccname = rz_str_trim_head_ro(cc);
24  char *result = rz_analysis_cc_get(core->analysis, ccname);
25  if (result) {
26  if (mode == RZ_OUTPUT_MODE_JSON) {
27  PJ *pj = pj_new();
28  pj_a(pj);
29  pj_ks(pj, "cc", result);
30  pj_end(pj);
32  pj_free(pj);
33  } else {
34  rz_cons_printf("%s\n", result);
35  }
36  free(result);
37  }
38  }
39 }
RZ_API char * rz_analysis_cc_get(RzAnalysis *analysis, const char *name)
Definition: cc.c:75
RZ_API bool rz_analysis_cc_set(RzAnalysis *analysis, const char *expr)
Definition: cc.c:25
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
RZ_API PJ * pj_end(PJ *j)
Definition: pj.c:87
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
Definition: pj.c:170
RZ_API PJ * pj_a(PJ *j)
Definition: pj.c:81
RZ_API const char * rz_str_trim_head_ro(const char *str)
Definition: str_trim.c:86

References rz_core_t::analysis, free(), pj_a(), pj_end(), pj_free(), pj_ks(), pj_new(), pj_string(), rz_analysis_cc_get(), rz_analysis_cc_set(), rz_cons_printf(), rz_cons_println(), RZ_LOG_ERROR, RZ_OUTPUT_MODE_JSON, rz_return_if_fail, and rz_str_trim_head_ro().

Referenced by rz_type_cc_list_handler().

◆ types_enum_member_find()

static RzCmdStatus types_enum_member_find ( RzCore core,
const char *  enum_name,
const char *  enum_value 
)
static

Definition at line 43 of file cmd_type.c.

43  {
44  rz_return_val_if_fail(enum_name || enum_value, RZ_CMD_STATUS_ERROR);
45  ut64 value = rz_num_math(core->num, enum_value);
46  const char *enum_member = rz_type_db_enum_member_by_val(core->analysis->typedb, enum_name, value);
47  if (!enum_member) {
48  RZ_LOG_ERROR("Cannot find matching enum member");
49  return RZ_CMD_STATUS_ERROR;
50  }
51  rz_cons_println(enum_member);
52  return RZ_CMD_STATUS_OK;
53 }
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
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

References rz_core_t::analysis, rz_core_t::num, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), RZ_LOG_ERROR, rz_num_math(), rz_return_val_if_fail, rz_type_db_enum_member_by_val(), rz_analysis_t::typedb, ut64(), and value.

Referenced by rz_type_list_enum_handler().

◆ types_enum_member_find_all()

static RzCmdStatus types_enum_member_find_all ( RzCore core,
const char *  enum_value 
)
static

Definition at line 55 of file cmd_type.c.

55  {
57  ut64 value = rz_num_math(core->num, enum_value);
59  if (!matches || rz_list_empty(matches)) {
60  RZ_LOG_ERROR("Cannot find matching enum member");
61  return RZ_CMD_STATUS_ERROR;
62  }
64  char *match;
65  rz_list_foreach (matches, iter, match) {
67  }
68  rz_list_free(matches);
69  return RZ_CMD_STATUS_OK;
70 }
unsigned char match[65280+2]
Definition: gun.c:165
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
Definition: engine.c:71
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

References rz_core_t::analysis, match, rz_core_t::num, RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), rz_list_free(), RZ_LOG_ERROR, rz_num_math(), rz_return_val_if_fail, rz_type_db_find_enums_by_val(), rz_analysis_t::typedb, ut64(), and value.

Referenced by rz_type_enum_find_handler().

◆ types_xrefs()

static void types_xrefs ( RzCore core,
const char *  typestr 
)
static

Definition at line 149 of file cmd_type.c.

149  {
150  char *error_msg = NULL;
151  RzType *type = rz_type_parse_string_single(core->analysis->typedb->parser, typestr, &error_msg);
152  if (!type || error_msg) {
153  if (error_msg) {
154  RZ_LOG_ERROR("%s", error_msg);
155  free(error_msg);
156  }
157  return;
158  }
159  RzType *type2;
160  RzListIter *iter, *iter2;
161  RzAnalysisFunction *fcn;
162  rz_list_foreach (core->analysis->fcns, iter, fcn) {
163  RzList *uniq = rz_analysis_types_from_fcn(core->analysis, fcn);
164  rz_list_foreach (uniq, iter2, type2) {
165  if (rz_types_equal(type2, type)) {
166  rz_cons_printf("%s\n", fcn->name);
167  break;
168  }
169  }
170  }
171 }
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 RZ_OWN RzList * rz_analysis_types_from_fcn(RzAnalysis *analysis, RzAnalysisFunction *fcn)
Definition: fcn.c:2545
RzList * fcns
Definition: rz_analysis.h:565
RzTypeParser * parser
Definition: rz_type.h:37
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

References rz_core_t::analysis, rz_analysis_t::fcns, free(), rz_analysis_function_t::name, NULL, rz_type_db_t::parser, rz_analysis_types_from_fcn(), rz_cons_printf(), RZ_LOG_ERROR, rz_type_parse_string_single(), rz_types_equal(), type, and rz_analysis_t::typedb.

Referenced by rz_type_xrefs_list_handler().

◆ types_xrefs_all()

static void types_xrefs_all ( RzCore core)
static

Definition at line 231 of file cmd_type.c.

231  {
232  RzType *type;
233  RzListIter *iter, *iter2;
234  RzAnalysisFunction *fcn;
235  RzList *types_list = rz_list_newf(free);
236  rz_list_foreach (core->analysis->fcns, iter, fcn) {
238  rz_list_foreach (types, iter2, type) {
239  const char *ident = rz_type_identifier(type);
240  if (ident) {
241  rz_list_push(types_list, strdup(ident));
242  }
243  }
245  }
246  RzList *uniq_types = rz_list_uniq(types_list, (RzListComparator)strcmp);
247  rz_list_free(types_list);
248  rz_list_sort(uniq_types, (RzListComparator)strcmp);
249  char *typestr;
250  rz_list_foreach (uniq_types, iter, typestr) {
251  rz_cons_printf("%s\n", typestr);
252  }
253  rz_list_free(uniq_types);
254 }
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.
Definition: list.c:756
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp)
Sorts via merge sort or via insertion sort a list.
Definition: list.c:743
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
Definition: list.c:60
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[]
Definition: or1k_disas.c:7
int(* RzListComparator)(const void *value, const void *list_data)
Definition: rz_list.h:33
RZ_API RZ_BORROW const char * rz_type_identifier(RZ_NONNULL const RzType *type)
Returns the type C identifier.
Definition: type.c:1155

References rz_core_t::analysis, rz_analysis_t::fcns, free(), rz_analysis_types_from_fcn(), rz_cons_printf(), rz_list_free(), rz_list_newf(), rz_list_push(), rz_list_sort(), rz_list_uniq(), rz_type_identifier(), strdup(), type, and types.

Referenced by rz_type_xrefs_list_all_handler().

◆ types_xrefs_function()

static RzCmdStatus types_xrefs_function ( RzCore core,
ut64  addr 
)
static

Definition at line 193 of file cmd_type.c.

193  {
194  RzType *type;
195  RzListIter *iter;
196  RzAnalysis *analysis = core->analysis;
198  if (!fcn) {
199  RZ_LOG_ERROR("Cannot find function at 0x%08" PFMT64x "\n", addr);
200  return RZ_CMD_STATUS_ERROR;
201  }
202  RzList *uniq = rz_analysis_types_from_fcn(analysis, fcn);
203  rz_list_foreach (uniq, iter, type) {
204  char *str = rz_type_as_string(analysis->typedb, type);
206  free(str);
207  }
208  rz_list_free(uniq);
209  return RZ_CMD_STATUS_OK;
210 }
RZ_API RzAnalysisFunction * rz_analysis_get_function_at(RzAnalysis *analysis, ut64 addr)
Definition: function.c:184
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

References addr, rz_core_t::analysis, free(), PFMT64x, rz_analysis_get_function_at(), rz_analysis_types_from_fcn(), RZ_CMD_STATUS_ERROR, RZ_CMD_STATUS_OK, rz_cons_println(), rz_list_free(), RZ_LOG_ERROR, rz_type_as_string(), cmd_descs_generate::str, type, and rz_analysis_t::typedb.

Referenced by rz_type_xrefs_function_handler().

◆ types_xrefs_graph()

static void types_xrefs_graph ( RzCore core)
static

Definition at line 212 of file cmd_type.c.

212  {
213  RzType *type;
214  RzListIter *iter, *iter2;
215  RzAnalysisFunction *fcn;
216  rz_list_foreach (core->analysis->fcns, iter, fcn) {
217  RzList *uniq = rz_analysis_types_from_fcn(core->analysis, fcn);
218  if (rz_list_length(uniq)) {
219  rz_cons_printf("agn %s\n", fcn->name);
220  }
221  rz_list_foreach (uniq, iter2, type) {
222  char *typestr = rz_type_as_string(core->analysis->typedb, type);
223  rz_str_replace_ch(typestr, ' ', '_', true);
224  rz_cons_printf("agn %s\n", typestr);
225  rz_cons_printf("age %s %s\n", typestr, fcn->name);
226  free(typestr);
227  }
228  }
229 }
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
RZ_API int rz_str_replace_ch(char *s, char a, char b, bool g)
Definition: str.c:139

References rz_core_t::analysis, rz_analysis_t::fcns, free(), rz_analysis_function_t::name, rz_analysis_types_from_fcn(), rz_cons_printf(), rz_list_length(), rz_str_replace_ch(), rz_type_as_string(), type, and rz_analysis_t::typedb.

Referenced by rz_type_xrefs_graph_handler().

◆ types_xrefs_summary()

static void types_xrefs_summary ( RzCore core)
static

Definition at line 173 of file cmd_type.c.

173  {
174  RzType *type;
175  RzListIter *iter, *iter2;
176  RzAnalysisFunction *fcn;
177  RzAnalysis *analysis = core->analysis;
178  rz_list_foreach (analysis->fcns, iter, fcn) {
179  RzList *uniq = rz_analysis_types_from_fcn(analysis, fcn);
180  if (rz_list_length(uniq)) {
181  rz_cons_printf("%s: ", fcn->name);
182  }
183  rz_list_foreach (uniq, iter2, type) {
184  char *str = rz_type_as_string(analysis->typedb, type);
185  if (str) {
186  rz_cons_printf("%s%s", str, iter2->n ? "," : "\n");
187  }
188  free(str);
189  }
190  }
191 }
struct rz_list_iter_t * n
Definition: rz_list.h:15

References rz_core_t::analysis, rz_analysis_t::fcns, free(), rz_list_iter_t::n, rz_analysis_function_t::name, rz_analysis_types_from_fcn(), rz_cons_printf(), rz_list_length(), rz_type_as_string(), cmd_descs_generate::str, type, and rz_analysis_t::typedb.

Referenced by rz_type_xrefs_list_handler().