IDA C++ SDK 9.2
Loading...
Searching...
No Matches
typeinf.hpp
Go to the documentation of this file.
1/*
2 * Interactive disassembler (IDA)
3 * Copyright (c) 1990-2026 Hex-Rays
4 * ALL RIGHTS RESERVED.
5 */
6
7#ifndef _TYPEINF_HPP
8#define _TYPEINF_HPP
9#include <functional>
10#include <idp.hpp>
11#include <name.hpp>
12
94
97typedef uchar type_t;
101typedef uchar p_list;
104#define DEFMASK64 bmask64_t(-1)
105
106struct til_t; // type information library
107class lexer_t; // lexical analyzer
108class argloc_t; // argument location
109class tinfo_t; // type info object
110class func_t; // function
111
112struct func_type_data_t;
113struct til_bucket_t;
114struct til_stream_t;
115struct value_repr_t;
116struct udm_t;
117struct edm_t;
118struct tinfo_changes_t;
119
120//------------------------------------------------------------------------
121#define RESERVED_BYTE 0xFF
122//------------------------------------------------------------------------
126
129const type_t TYPE_BASE_MASK = 0x0F;
135
138
152const type_t BT_UNK = 0x00;
153const type_t BT_VOID = 0x01;
154const type_t BTMT_SIZE0 = 0x00;
155const type_t BTMT_SIZE12 = 0x10;
156const type_t BTMT_SIZE48 = 0x20;
157const type_t BTMT_SIZE128 = 0x30;
160
163const type_t BT_INT8 = 0x02;
164const type_t BT_INT16 = 0x03;
165const type_t BT_INT32 = 0x04;
166const type_t BT_INT64 = 0x05;
167const type_t BT_INT128 = 0x06;
168const type_t BT_INT = 0x07;
169const type_t BTMT_UNKSIGN = 0x00;
170const type_t BTMT_SIGNED = 0x10;
171const type_t BTMT_USIGNED = 0x20;
173const type_t BTMT_CHAR = 0x30;
178
181const type_t BT_BOOL = 0x08;
182const type_t BTMT_DEFBOOL = 0x00;
183const type_t BTMT_BOOL1 = 0x10;
184const type_t BTMT_BOOL2 = 0x20;
185const type_t BTMT_BOOL8 = 0x20;
186const type_t BTMT_BOOL4 = 0x30;
188
191const type_t BT_FLOAT = 0x09;
192const type_t BTMT_FLOAT = 0x00;
193const type_t BTMT_DOUBLE = 0x10;
194const type_t BTMT_LNGDBL = 0x20;
195const type_t BTMT_SPECFLT = 0x30;
199
206
211const type_t BT_PTR = 0x0A;
214const type_t BTMT_DEFPTR = 0x00;
215const type_t BTMT_NEAR = 0x10;
216const type_t BTMT_FAR = 0x20;
217const type_t BTMT_CLOSURE = 0x30;
227
232const type_t BT_ARRAY = 0x0B;
233const type_t BTMT_NONBASED = 0x10;
241const type_t BTMT_ARRESERV = 0x20;
243
249const type_t BT_FUNC = 0x0C;
277
278const type_t BTMT_DEFCALL = 0x00;
279const type_t BTMT_NEARCALL = 0x10;
280const type_t BTMT_FARCALL = 0x20;
281const type_t BTMT_INTCALL = 0x30;
284
287const type_t BT_COMPLEX = 0x0D;
310const type_t BTMT_STRUCT = 0x00;
312const type_t BTMT_UNION = 0x10;
314const type_t BTMT_ENUM = 0x20;
319const type_t BTMT_TYPEDEF = 0x30;
321
322const type_t BT_BITFIELD = 0x0E;
326const type_t BTMT_BFLDI8 = 0x00;
327const type_t BTMT_BFLDI16 = 0x10;
328const type_t BTMT_BFLDI32 = 0x20;
329const type_t BTMT_BFLDI64 = 0x30;
331
332const type_t BT_RESERVED = 0x0F;
333
334
335//------------------------------------------------------------------------
340const type_t BTM_CONST = 0x40;
341const type_t BTM_VOLATILE = 0x80;
343
344//------------------------------------------------------------------------
347typedef uchar bte_t;
348
349const bte_t BTE_SIZE_MASK = 0x07;
353const bte_t BTE_RESERVED = 0x08;
355const bte_t BTE_BITMASK = 0x10;
363const bte_t BTE_OUT_MASK = 0x60;
364const bte_t BTE_HEX = 0x00;
365const bte_t BTE_CHAR = 0x20;
366const bte_t BTE_SDEC = 0x40;
367const bte_t BTE_UDEC = 0x60;
368const bte_t BTE_ALWAYS = 0x80;
370
375
385
386//------------------------------------------------------------------------
392
397
400
403
406
409
413
415
420
426
428
429//------------------------------------------------------------------------
430// convenience functions:
431
432inline THREAD_SAFE bool is_type_const(type_t t) { return (t & BTM_CONST) != 0; }
433inline THREAD_SAFE bool is_type_volatile(type_t t) { return (t & BTM_VOLATILE) != 0; }
434
435inline THREAD_SAFE type_t get_base_type(type_t t) { return (t & TYPE_BASE_MASK); }
436inline THREAD_SAFE type_t get_type_flags(type_t t) { return (t & TYPE_FLAGS_MASK); }
437inline THREAD_SAFE type_t get_full_type(type_t t) { return (t & TYPE_FULL_MASK); }
438
441inline THREAD_SAFE bool is_typeid_last(type_t t) { return(get_base_type(t) <= _BT_LAST_BASIC); }
442
444inline THREAD_SAFE bool is_type_partial(type_t t) { return(get_base_type(t) <= BT_VOID) && get_type_flags(t) != 0; }
445
446inline THREAD_SAFE bool is_type_void(type_t t) { return(get_full_type(t) == BTF_VOID); }
447inline THREAD_SAFE bool is_type_unknown(type_t t) { return(get_full_type(t) == BT_UNKNOWN); }
448
449inline THREAD_SAFE bool is_type_ptr(type_t t) { return(get_base_type(t) == BT_PTR); }
450inline THREAD_SAFE bool is_type_complex(type_t t) { return(get_base_type(t) == BT_COMPLEX); }
451inline THREAD_SAFE bool is_type_func(type_t t) { return(get_base_type(t) == BT_FUNC); }
452inline THREAD_SAFE bool is_type_array(type_t t) { return(get_base_type(t) == BT_ARRAY); }
453
454inline THREAD_SAFE bool is_type_typedef(type_t t) { return(get_full_type(t) == BTF_TYPEDEF); }
455inline THREAD_SAFE bool is_type_sue(type_t t) { return is_type_complex(t) && !is_type_typedef(t); }
456inline THREAD_SAFE bool is_type_struct(type_t t) { return(get_full_type(t) == BTF_STRUCT); }
457inline THREAD_SAFE bool is_type_union(type_t t) { return(get_full_type(t) == BTF_UNION); }
458inline THREAD_SAFE bool is_type_struni(type_t t) { return(is_type_struct(t) || is_type_union(t)); }
459inline THREAD_SAFE bool is_type_enum(type_t t) { return(get_full_type(t) == BTF_ENUM); }
460
461inline THREAD_SAFE bool is_type_bitfld(type_t t) { return(get_base_type(t) == BT_BITFIELD); }
462
463
465inline THREAD_SAFE bool is_type_int(type_t bt) { bt = get_base_type(bt); return bt >= BT_INT8 && bt <= BT_INT; }
466
468inline THREAD_SAFE bool is_type_int128(type_t t)
469{
472}
473
475inline THREAD_SAFE bool is_type_int64(type_t t)
476{
479}
480
482inline THREAD_SAFE bool is_type_int32(type_t t)
483{
486}
487
489inline THREAD_SAFE bool is_type_int16(type_t t)
490{
493}
494
496inline THREAD_SAFE bool is_type_char(type_t t) // chars are signed by default(?)
497{
498 return get_full_type(t) == (BT_INT8|BTMT_CHAR)
500}
501
503inline THREAD_SAFE bool is_type_paf(type_t t)
504{
505 t = get_base_type(t);
506 return t >= BT_PTR && t <= BT_FUNC;
507}
508
510inline THREAD_SAFE bool is_type_ptr_or_array(type_t t) { t = get_base_type(t); return t == BT_PTR || t == BT_ARRAY; }
512inline THREAD_SAFE bool is_type_floating(type_t t) { return get_base_type(t) == BT_FLOAT; } // any floating type
514inline THREAD_SAFE bool is_type_integral(type_t t) { return get_full_type(t) > BT_VOID && get_base_type(t) <= BT_BOOL; }
516inline THREAD_SAFE bool is_type_ext_integral(type_t t) { return is_type_integral(t) || is_type_enum(t); }
518inline THREAD_SAFE bool is_type_arithmetic(type_t t) { return get_full_type(t) > BT_VOID && get_base_type(t) <= BT_FLOAT; }
520inline THREAD_SAFE bool is_type_ext_arithmetic(type_t t) { return is_type_arithmetic(t) || is_type_enum(t); }
521
522inline THREAD_SAFE bool is_type_uint(type_t t) { return get_full_type(t) == BTF_UINT; }
523inline THREAD_SAFE bool is_type_uchar(type_t t) { return get_full_type(t) == BTF_UCHAR; }
524inline THREAD_SAFE bool is_type_uint16(type_t t) { return get_full_type(t) == BTF_UINT16; }
525inline THREAD_SAFE bool is_type_uint32(type_t t) { return get_full_type(t) == BTF_UINT32; }
526inline THREAD_SAFE bool is_type_uint64(type_t t) { return get_full_type(t) == BTF_UINT64; }
527inline THREAD_SAFE bool is_type_uint128(type_t t) { return get_full_type(t) == BTF_UINT128; }
528inline THREAD_SAFE bool is_type_ldouble(type_t t) { return get_full_type(t) == BTF_LDOUBLE; }
529inline THREAD_SAFE bool is_type_double(type_t t) { return get_full_type(t) == BTF_DOUBLE; }
530inline THREAD_SAFE bool is_type_float(type_t t) { return get_full_type(t) == BTF_FLOAT; }
531inline THREAD_SAFE bool is_type_tbyte(type_t t) { return get_full_type(t) == BTF_TBYTE; }
532inline THREAD_SAFE bool is_type_bool(type_t t) { return get_base_type(t) == BT_BOOL; }
533
540#define TAH_BYTE 0xFE
541#define FAH_BYTE 0xFF
542
543#define MAX_DECL_ALIGN 0x000F
544
547#define TAH_HASATTRS 0x0010
549
552#define TAUDT_UNALIGNED 0x0040
553#define TAUDT_MSSTRUCT 0x0020
554#define TAUDT_CPPOBJ 0x0080
555#define TAUDT_VFTABLE 0x0100
556#define TAUDT_FIXED 0x0400
558#define TAUDT_TUPLE 0x0800
560#define TAUDT_IFACE 0x1000
562
565#define TAFLD_BASECLASS 0x0020
566#define TAFLD_UNALIGNED 0x0040
567#define TAFLD_VIRTBASE 0x0080
568#define TAFLD_VFTABLE 0x0100
569#define TAFLD_METHOD 0x0200
570#define TAFLD_GAP 0x0400
571#define TAFLD_REGCMT 0x0800
572#define TAFLD_FRAME_R 0x1000
573#define TAFLD_FRAME_S 0x2000
574#define TAFLD_BYTIL 0x4000
576
579#define TAPTR_PTR32 0x0020
580#define TAPTR_PTR64 0x0040
581#define TAPTR_RESTRICT 0x0060
582#define TAPTR_SHIFTED 0x0080
584
587#define TAENUM_64BIT 0x0020
588#define TAENUM_UNSIGNED 0x0040
589#define TAENUM_SIGNED 0x0080
590#define TAENUM_OCT 0x0100
591#define TAENUM_BIN 0x0200
594#define TAENUM_NUMSIGN 0x0400
595#define TAENUM_LZERO 0x0800
597
598#define TAH_ALL 0x7FF0
599
601
602
605
606inline THREAD_SAFE bool is_tah_byte(type_t t)
607{
608 return t == TAH_BYTE;
609}
610
611
620
621inline THREAD_SAFE bool is_sdacl_byte(type_t t)
622{
623 return ((t & ~TYPE_FLAGS_MASK) ^ TYPE_MODIF_MASK) <= BT_VOID;
624}
625
626#ifndef SWIG
631
632inline THREAD_SAFE bool operator <(const bytevec_t &v1, const bytevec_t &v2)
633{
634 size_t n = qmin(v1.size(), v2.size());
635 for ( size_t i=0; i < n; i++ )
636 {
637 uchar k1 = v1[i];
638 uchar k2 = v2[i];
639 if ( k1 < k2 )
640 return true;
641 if ( k1 > k2 )
642 return false;
643 }
644 return v1.size() < v2.size();
645}
646#endif
647
652{
655#define TA_ORG_TYPEDEF "__org_typedef"
656#define TA_ORG_ARRDIM "__org_arrdim"
657#define TA_FORMAT "format"
662#define TA_VALUE_REPR "\x01"
664 bool operator < (const type_attr_t &r) const { return key < r.key; }
665 bool operator >= (const type_attr_t &r) const { return !(*this < r); }
666};
668
671
672typedef int type_sign_t;
673const type_sign_t
678
679//---------------------------------------------------------------------------
680idaman bool ida_export append_argloc(qtype *out, const argloc_t &vloc);
684idaman bool ida_export extract_argloc(argloc_t *vloc, const type_t **ptype, bool forbid_stkoff);
685
686idaman DEPRECATED const type_t *ida_export resolve_typedef(const til_t *til, const type_t *type);
687
692idaman type_t ida_export get_realtype(const til_t *til, const type_t *type);
693
694// low level functions to be used in predicate_t::should_display()
695// in other places please use tinfo_t
696inline bool is_restype_void(const til_t *til, const type_t *type)
697{
698 return is_type_void(get_realtype(til, type));
699}
700
701inline bool is_restype_enum(const til_t *til, const type_t *type)
702{
703 return is_type_enum(get_realtype(til, type));
704}
705
706inline bool is_restype_struni(const til_t *til, const type_t *type)
707{
708 return is_type_struni(get_realtype(til, type));
709}
710
711inline bool is_restype_struct(const til_t *til, const type_t *type)
712{
713 return is_type_struct(get_realtype(til, type));
714}
715
716// Get a base type for the specified size.
717// This function prefers to return integer types
718// \param size size in bytes; should be 1,2,4,8,16 or sizeof(floating point)
719// \return BT_INT.. or BT_FLOAT... or BT_UNK
720
721idaman type_t ida_export get_scalar_bt(size_t size);
722
723
724//------------------------------------------------------------------------
726//------------------------------------------------------------------------
727struct til_t
728{
729 char *name = nullptr;
730 char *desc = nullptr;
731 int nbases = 0;
732 til_t **base = nullptr;
737#define TIL_ZIP 0x0001
738#define TIL_MAC 0x0002
739#define TIL_ESI 0x0004
740#define TIL_UNI 0x0008
741#define TIL_ORD 0x0010
742#define TIL_ALI 0x0020
743#define TIL_MOD 0x0040
744#define TIL_STM 0x0080
745#define TIL_SLD 0x0100
746#define TIL_ECC 0x0200
749 inline bool is_dirty() const { return (flags & TIL_MOD) != 0; }
751 inline void set_dirty() { flags |= TIL_MOD; }
752
756 inline til_t *find_base(const char *n)
757 {
758 if ( n != nullptr )
759 {
760 for ( int i = 0; i < nbases; ++i )
761 if ( streq(base[i]->name, n) )
762 return base[i];
763 }
764 return nullptr;
765 }
766
768 til_bucket_t *syms = nullptr;
769 til_bucket_t *types = nullptr;
770 til_bucket_t *macros = nullptr;
771 int nrefs = 0;
772 int nstreams = 0;
773 til_stream_t **streams = nullptr;
774};
775
776
778
779idaman til_t *ida_export new_til(const char *name, const char *desc);
780
781
790
791idaman int ida_export add_base_tils(qstring *errbuf, til_t *ti, const char *tildir, const char *bases, bool gen_events);
792
796#define TIL_ADD_FAILED 0
797#define TIL_ADD_OK 1
798#define TIL_ADD_ALREADY 2
800
801
811
812idaman til_t *ida_export load_til(const char *name, qstring *errbuf, const char *tildir=nullptr);
813
814
817
818idaman bool ida_export sort_til(til_t *ti);
819
820
824
825idaman bool ida_export compact_til(til_t *ti);
826
827
836
837idaman bool ida_export store_til(til_t *ti, const char *tildir, const char *name);
838
839
841
842idaman void ida_export free_til(til_t *ti);
843
844
846
847idaman til_t *ida_export load_til_header(const char *tildir, const char *name, qstring *errbuf);
848
849
850//------------------------------------------------------------------------
854
857const cm_t CM_MASK = 0x03;
858const cm_t CM_UNKNOWN = 0x00;
859const cm_t CM_N8_F16 = 0x01;
860const cm_t CM_N64 = 0x01;
861const cm_t CM_N16_F32 = 0x02;
862const cm_t CM_N32_F48 = 0x03;
866const cm_t CM_M_MASK = 0x0C;
867const cm_t CM_M_NN = 0x00;
868const cm_t CM_M_FF = 0x04;
869const cm_t CM_M_NF = 0x08;
870const cm_t CM_M_FN = 0x0C;
871
873inline THREAD_SAFE bool is_code_far(cm_t cm) { return((cm & 4) != 0); }
875inline THREAD_SAFE bool is_data_far(cm_t cm) { return((cm &= CM_M_MASK) && cm != CM_M_FN); }
877
886const callcnv_t CM_CC_CDECL = 0x30;
892const callcnv_t CM_CC_SWIFT = 0x90;
904
905const callcnv_t CM_CC_GOSTK = 0x100;
906const callcnv_t CM_CC_RUST = 0x101;
907
908const callcnv_t CM_CC_FIRST_PLAIN_CUSTOM = 0x200; // please note that variadic or usercall
909 // codes have their own ranges
910// recommendation:
911// use 0x100 and higher for new calling convention codes.
912// max calling convention code is MAX_DT.
913// however, for calling conventions with special traits the following code may be used:
914// - usercall variations may use values between 0xD0..0xFF.
915// - ellipsis variations may use values 0x40..0x4F and 0xD0..0xDF.
916
918
920
926const type_t BFA_NORET = 0x01;
927const type_t BFA_PURE = 0x02;
928const type_t BFA_HIGH = 0x04;
929const type_t BFA_STATIC = 0x08;
930const type_t BFA_VIRTUAL = 0x10;
931
932const cm_t BFA_FUNC_MARKER = 0x0F;
935
936#ifndef SWIG
938#define ARGLOC_HELPER_DEFINITIONS(decl) \
939decl void ida_export copy_argloc(argloc_t *dst, const argloc_t *src); \
940decl void ida_export cleanup_argloc(argloc_t *vloc);\
941decl int ida_export compare_arglocs(const argloc_t &a, const argloc_t &b);
942#else
943#define ARGLOC_HELPER_DEFINITIONS(decl)
944#endif // SWIG
945ARGLOC_HELPER_DEFINITIONS(idaman)
946
947
950
953typedef int argloc_type_t;
956const argloc_type_t
966
968struct rrel_t
969{
971 int reg;
972};
973
974class scattered_aloc_t;
975
979{
980 size_t cbsize;
981 const char *name;
982
984 void (idaapi *copy)(argloc_t *empty_dst, const argloc_t &src);
985
987 void (idaapi *cleanup)(argloc_t *loc);
988
990 bool (idaapi *verify)(
991 const argloc_t &loc,
992 int size,
993 const rangeset_t *gaps,
995
997 int (idaapi *compare)(const argloc_t &a, const argloc_t &b);
998
1000 size_t (idaapi *print)(
1001 char *buf,
1002 size_t bufsize,
1005 int praloc_flags); // PRALOC_...
1006
1009 bool (idaapi *deref_field)(
1010 argloc_t *out,
1015 const qstring &name);
1016
1019 bool (idaapi *deref_array)(
1020 argloc_t *out,
1021 tinfo_t *tif,
1026
1029 bool (idaapi *deref_ptr)(
1030 argloc_t *out,
1031 tinfo_t *tif,
1033
1036 bool (idaapi *read_value)(
1037 value_union_t *value,
1039 int size,
1040 const tinfo_t &tif);
1041
1045 bool (idaapi *write_value)(
1046 const argloc_t &loc,
1049 int size,
1051
1053 asize_t (idaapi *calc_string_length)(
1054 const argloc_t &loc,
1056
1059 bool (idaapi *get_string)(
1060 qstring *out,
1064 size_t len);
1065
1067 asize_t (idaapi *guess_array_size)(
1068 const argloc_t &loc,
1070
1072 bool (idaapi *get_tinfo)(
1073 tinfo_t *out,
1074 const argloc_t &loc);
1075
1079
1083 size_t (idaapi *print_ptr_value)(
1084 char *buf,
1085 size_t bufsize,
1088 const tinfo_t &tif);
1089};
1090
1091
1093idaman int ida_export install_custom_argloc(const custloc_desc_t *custloc);
1095idaman bool ida_export remove_custom_argloc(int idx);
1097idaman const custloc_desc_t *ida_export retrieve_custom_argloc(int idx);
1098
1104class argloc_t // #argloc
1105{
1106public:
1107 typedef size_t biggest_t;
1108
1109private:
1110 argloc_type_t type;
1111 union
1112 {
1113 sval_t sval; // ::ALOC_STACK, ::ALOC_STATIC
1114 uint32 reginfo; // ::ALOC_REG1, ::ALOC_REG2
1115 rrel_t *rrel; // ::ALOC_RREL
1116 scattered_aloc_t *dist; // ::ALOC_DIST
1117 void *custom; // ::ALOC_CUSTOM
1118 biggest_t biggest; // to facilitate manipulation of this union
1119 };
1120 ARGLOC_HELPER_DEFINITIONS(friend)
1121
1122public:
1123 argloc_t() : type(ALOC_NONE), biggest(0) {}
1124 argloc_t(const argloc_t &r) : type(ALOC_NONE) { copy_argloc(this, &r); }
1125 ~argloc_t() { cleanup_argloc(this); }
1126 argloc_t &operator=(const argloc_t &r) { copy_argloc(this, &r); return *this; }
1127 DEFINE_MEMORY_ALLOCATION_FUNCS()
1128
1129
1130 void swap(argloc_t &r)
1131 {
1132 biggest_t tmp = biggest; biggest = r.biggest; r.biggest = tmp;
1133 argloc_type_t t = type; type = r.type; r.type = t;
1134 }
1135
1136 const char *dstr() const;
1137
1138 argloc_type_t atype() const { return type; }
1139 bool is_reg1() const { return type == ALOC_REG1; }
1140 bool is_reg2() const { return type == ALOC_REG2; }
1141 bool is_reg() const { return type == ALOC_REG1 || type == ALOC_REG2; }
1142 bool is_rrel() const { return type == ALOC_RREL; }
1143 bool is_ea() const { return type == ALOC_STATIC; }
1144 bool is_stkoff() const { return type == ALOC_STACK; }
1145 bool is_scattered() const { return type == ALOC_DIST; }
1146 inline bool has_reg() const;
1147 inline bool has_stkoff() const;
1148 inline bool is_mixed_scattered() const;
1149 inline bool in_stack() const;
1150 bool is_fragmented() const { return type == ALOC_DIST || type == ALOC_REG2; }
1151 bool is_custom() const { return type >= ALOC_CUSTOM; }
1152 bool is_badloc() const { return type == ALOC_NONE; }
1153
1156 int reg1() const { return uint16(reginfo); }
1157
1160 int regoff() const { return uint16(reginfo >> 16); }
1161
1164 int reg2() const { return uint16(reginfo >> 16); }
1165
1168 uint32 get_reginfo() const { return reginfo; }
1169
1172 sval_t stkoff() const { return sval; }
1173
1176 ea_t get_ea() const { return sval; }
1177
1180 scattered_aloc_t &scattered() { return *dist; }
1181 const scattered_aloc_t &scattered() const { return *dist; }
1182
1185 rrel_t &get_rrel() { return *rrel; }
1186 const rrel_t &get_rrel() const { return *rrel; }
1187
1190 void *get_custom() const { return custom; }
1191
1193 biggest_t get_biggest() const { return biggest; }
1194
1195 // be careful with these functions, they do not cleanup!
1196 void _set_badloc() { type = ALOC_NONE; }
1197 void _set_reg1(int reg, int off=0) { type = ALOC_REG1; reginfo = reg | (off << 16); }
1198 void _set_reg2(int _reg1, int _reg2) { type = ALOC_REG2; reginfo = _reg1 | (_reg2 << 16); }
1199 void _set_stkoff(sval_t off) { type = ALOC_STACK; sval = off; }
1200 void _set_ea(ea_t _ea) { type = ALOC_STATIC; sval = _ea; }
1202 bool _consume_rrel(rrel_t *p) //lint -sem(argloc_t::_consume_rrel, custodial(1))
1203 {
1204 if ( p == nullptr )
1205 return false;
1206 type = ALOC_RREL;
1207 rrel = p;
1208 return true;
1209 }
1211 bool _consume_scattered(scattered_aloc_t *p)
1212 {
1213 if ( p == nullptr )
1214 return false;
1215 type = ALOC_DIST;
1216 dist = p;
1217 return true;
1218 }
1219
1221 void _set_custom(argloc_type_t ct, void *pdata) { type = ct; custom = pdata; }
1222
1224 void _set_biggest(argloc_type_t ct, biggest_t data) { type = ct; biggest = data; }
1225
1227 void set_reg1(int reg, int off=0) { cleanup_argloc(this); _set_reg1(reg, off); }
1228
1230 void set_reg2(int _reg1, int _reg2) { cleanup_argloc(this); _set_reg2(_reg1, _reg2); }
1231
1233 void set_stkoff(sval_t off) { cleanup_argloc(this); _set_stkoff(off); }
1234
1236 void set_ea(ea_t _ea) { cleanup_argloc(this); _set_ea(_ea); }
1237
1239 void consume_rrel(rrel_t *p) { cleanup_argloc(this); _consume_rrel(p); }
1240
1242 void consume_scattered(scattered_aloc_t *p) { cleanup_argloc(this); _consume_scattered(p); }
1243
1245 void set_badloc() { cleanup_argloc(this); }
1246
1248 sval_t calc_offset() const
1249 {
1250 switch ( type )
1251 {
1252 default:
1253 case ALOC_NONE:
1254 case ALOC_DIST:
1255 case ALOC_REG2:
1256 return -1;
1257 case ALOC_RREL:
1258 return rrel->off;
1259 case ALOC_STACK:
1260 case ALOC_STATIC:
1261 return sval;
1262 case ALOC_REG1:
1263 return reg1();
1264 }
1265 }
1266
1268 bool advance(int delta)
1269 {
1270 switch ( type )
1271 {
1272 case ALOC_REG1:
1273 _set_reg1(reg1()+delta, regoff());
1274 break;
1275 case ALOC_STACK:
1276 case ALOC_STATIC:
1277 sval += delta;
1278 break;
1279 case ALOC_RREL:
1280 rrel->off += delta;
1281 break;
1282 default:
1283 return false;
1284 }
1285 return true;
1286 }
1287
1289 void align_reg_high(size_t size, size_t _slotsize)
1290 {
1291 if ( is_reg1() )
1292 _set_reg1(reg1(), size < _slotsize ? int(_slotsize - size) : 0);
1293 }
1294
1296 void align_stkoff_high(size_t size, size_t _slotsize)
1297 {
1298 if ( is_stkoff() )
1299 {
1300 sval_t off = align_down(stkoff(), int(_slotsize));
1301 if ( size < _slotsize )
1302 off += _slotsize - size;
1303 _set_stkoff(off);
1304 }
1305 }
1306
1307 DECLARE_COMPARISONS(argloc_t)
1308 {
1309 return compare_arglocs(*this, r);
1310 }
1311};
1314
1316struct argpart_t : public argloc_t
1317{
1321 argpart_t(const argloc_t &a) : argloc_t(a), off(0xFFFF), size(0) {}
1322 argpart_t() : off(0xFFFF), size(0) {}
1323 argpart_t &copy_from(const argloc_t &a) { *(argloc_t*)this = a; return *this; }
1324
1326 bool bad_offset() const { return off == 0xFFFF; }
1327
1329 bool bad_size() const { return size == 0; }
1330
1332 bool operator < (const argpart_t &r) const { return off < r.off; }
1333
1336 {
1337 argloc_t::swap(r);
1338 qswap(off, r.off);
1339 qswap(size, r.size);
1340 }
1341};
1344
1347{
1348public:
1350};
1352
1353
1360
1361idaman int ida_export verify_argloc(const argloc_t &vloc, int size, const rangeset_t *gaps);
1362
1363
1368
1369idaman bool ida_export optimize_argloc(argloc_t *vloc, int size, const rangeset_t *gaps);
1370
1371
1373
1374idaman size_t ida_export print_argloc(
1375 char *buf,
1376 size_t bufsize,
1377 const argloc_t &vloc,
1378 int size=0,
1379 int vflags=0);
1380#define PRALOC_VERIFY 0x01
1381#define PRALOC_STKOFF 0x02
1382
1383
1387{
1388 virtual int idaapi visit_location(argloc_t &v, int off, int size) = 0;
1389 virtual ~aloc_visitor_t() {}
1390};
1391
1393idaman int ida_export for_all_arglocs(aloc_visitor_t &vv, argloc_t &vloc, int size, int off=0);
1394
1397{
1398 virtual int idaapi visit_location(const argloc_t &v, int off, int size) = 0;
1400};
1401
1403inline int idaapi for_all_const_arglocs(const_aloc_visitor_t &vv, const argloc_t &vloc, int size, int off=0)
1404{
1405 return for_all_arglocs(*(aloc_visitor_t*)(&vv),
1406 CONST_CAST(argloc_t&)(vloc),
1407 size,
1408 off);
1409}
1410
1411//--------------------------------------------------------------------------
1423
1424
1425// Helper functions that maintain binary compatibility with old plugins
1426// (when possible) yet let us work with 32-bit calling convention codes.
1427inline callcnv_t helper_get_cc(cm_t cm, callcnv_t new_callcnv)
1428{
1429 cm_t cc = cm & CM_CC_MASK;
1430 if ( cc == CM_CC_RESERVE3 )
1431 return new_callcnv;
1432 else
1433 return cc;
1434}
1435
1436inline void helper_set_cc(cm_t *cm, callcnv_t *new_callcnv, callcnv_t cc)
1437{
1438 *cm &= ~CM_CC_MASK;
1439 if ( (cc & ~CM_CC_MASK) == 0 && cc != CM_CC_RESERVE3 )
1440 {
1441 *cm |= cc;
1442 *new_callcnv = 0;
1443 }
1444 else
1445 {
1446 *cm |= CM_CC_RESERVE3;
1447 *new_callcnv = cc;
1448 }
1449}
1450
1453
1456{
1457 // if the calling convention is not specified, use the default one
1458 if ( cc <= CM_CC_UNKNOWN )
1459 cc = inf_get_callcnv();
1460 return cc;
1461}
1462
1464inline constexpr THREAD_SAFE bool is_user_cc(callcnv_t cc)
1465{
1466 return cc >= CM_CC_SPECIALE && cc <= CM_CC_LAST_USERCALL;
1467}
1468
1470inline constexpr THREAD_SAFE bool is_vararg_cc(callcnv_t cc)
1471{
1472 cc &= ~0xF; // the range of vararg codes is 0x40..0x4F and 0xD0..0xDF.
1473 return cc == CM_CC_ELLIPSIS || cc == CM_CC_SPECIALE;
1474}
1475
1478inline constexpr THREAD_SAFE bool is_purging_cc(callcnv_t cc)
1479{
1480 cc &= ~0xF; // mask out the last 4 bits
1481 return cc == CM_CC_STDCALL
1482 || cc == CM_CC_PASCAL
1483 || cc == CM_CC_SPECIALP
1484 || cc == CM_CC_FASTCALL
1485 || cc == CM_CC_THISCALL
1486 || cc == CM_CC_SWIFT;
1487}
1488
1490inline constexpr bool is_golang_cc(callcnv_t cc)
1491{
1492 return cc == CM_CC_GOLANG || cc == CM_CC_GOSTK;
1493}
1494
1496inline constexpr bool is_rust_cc(callcnv_t cc)
1497{
1498 return cc == CM_CC_RUST;
1499}
1500
1503{
1504 if ( cc >= CM_CC_FIRST_PLAIN_CUSTOM )
1505 return true;
1506 if ( cc <= 0xFF && (cc & ~CM_CC_MASK) != 0 )
1507 return true;
1508 return false;
1509}
1510
1512
1513inline constexpr bool is_swift_cc(callcnv_t cc)
1514{
1515 return cc == CM_CC_SWIFT;
1516}
1517
1518
1519//-------------------------------------------------------------------------
1523idaman bool ida_export get_stkarg_area_info(
1524 stkarg_area_info_t *out,
1525 callcnv_t cc);
1526
1549
1550//--------------------------------------------------------------------------
1553{
1554 int cbsize = sizeof(*this);
1556#define CCI_VARARG 0x0001
1557#define CCI_PURGE 0x0002
1558#define CCI_USER 0x0004
1561
1562 bool is_vararg() const { return (flags & CCI_VARARG) != 0; }
1563 bool is_purging() const { return (flags & CCI_PURGE) != 0; }
1564 bool is_usercall() const { return (flags & CCI_USER) != 0; }
1565
1572 virtual bool validate_func(const func_type_data_t &fti, qstring *reterr) const
1573 {
1574 qnotused(fti);
1575 qnotused(reterr);
1576 return true;
1577 }
1578
1583 virtual bool calc_retloc(func_type_data_t *fti) const = 0;
1584
1590 virtual bool calc_arglocs(func_type_data_t *fti) const = 0;
1591
1603 func_type_data_t *fti,
1604 ea_t call_ea,
1605 class mblock_t *blk) const
1606 {
1607 qnotused(call_ea);
1608 qnotused(fti);
1609 qnotused(blk);
1610 return 0;
1611 }
1612
1621 virtual bool calc_varglocs(
1622 func_type_data_t *fti,
1623 regobjs_t *regs,
1624 relobj_t *stkargs,
1625 int nfixed) const
1626 {
1627 qnotused(fti);
1628 qnotused(regs);
1629 qnotused(stkargs);
1630 qnotused(nfixed);
1631 return false;
1632 }
1633
1635 virtual bool get_cc_regs(callregs_t *out) const
1636 {
1637 qnotused(out);
1638 return false;
1639 }
1640
1643 {
1644 qnotused(out);
1645 return false;
1646 }
1647
1652 const func_type_data_t &fti,
1653 ea_t call_ea=BADADDR) const
1654 {
1655 qnotused(fti);
1656 qnotused(call_ea);
1657 return 0;
1658 }
1659
1664 inline virtual bool decorate_name(
1665 qstring *outbuf,
1666 const char *name,
1667 bool should_decorate,
1668 callcnv_t cc,
1669 const tinfo_t &type) const;
1670
1675 virtual int lower_func_type(func_type_data_t *fti) const
1676 {
1677 qnotused(fti);
1678 return 0;
1679 }
1680
1681 custom_callcnv_t() = default;
1682 custom_callcnv_t(const char *_name, uint64 f, uint32 _abibits)
1683 : flags(f), name(_name), abibits(_abibits)
1684 {}
1686#ifndef SWIG
1688#endif
1689};
1690// Not movable: polymorphic interface object, not intended for bytewise relocation.
1691
1702
1705idaman bool ida_export unregister_custom_callcnv(callcnv_t callcnv);
1706
1708idaman const custom_callcnv_t *ida_export get_custom_callcnv(callcnv_t callcnv);
1709
1712idaman callcnv_t ida_export find_custom_callcnv(const char *name);
1713
1719idaman size_t ida_export get_custom_callcnvs(qstrvec_t *names, callcnvs_t *codes);
1720
1721//--------------------------------------------------------------------------
1737
1739
1743{
1744 bool set_inds(int *p_ind1, int *p_ind2, int ind) const
1745 {
1746 if ( ind == -1 )
1747 return false;
1748 *p_ind1 = ind;
1749 *p_ind2 = by_slots() ? ind : -1;
1750 return true;
1751 }
1752
1753 // copy -1-terminated array to a vector
1754 static void set_regarray(intvec_t *regvec, const int *regarray)
1755 {
1756 regvec->clear();
1757 if ( regarray != nullptr )
1758 while ( *regarray != -1 )
1759 regvec->push_back(*regarray++);
1760 }
1761 void calc_nregs()
1762 {
1763 nregs = int(gpregs.size());
1766 || policy == ARGREGS_RISCV )
1767 {
1768 nregs += int(fpregs.size());
1769 }
1770 }
1771
1772public:
1774 int nregs = 0;
1777
1780
1783
1786 {
1787 std::swap(policy, r.policy);
1788 std::swap(nregs, r.nregs);
1789 gpregs.swap(r.gpregs);
1790 fpregs.swap(r.fpregs);
1791 }
1792
1795 {
1796 if ( is_custom_callcnv(cc) )
1797 {
1798 const custom_callcnv_t *ccc = get_custom_callcnv(cc);
1799 if ( ccc == nullptr )
1800 return false;
1801 return ccc->get_cc_regs(this);
1802 }
1803 return processor_t::get_cc_regs(this, cc) > 0;
1804 }
1805
1806 // policy-specific options
1807 bool by_slots() const { return policy == ARGREGS_BY_SLOTS; }
1808
1810 void set(argreg_policy_t _policy, const int *gprs, const int *fprs)
1811 {
1812 policy = _policy;
1813 set_regarray(&gpregs, gprs);
1814 set_regarray(&fpregs, fprs);
1815 calc_nregs();
1816 }
1817
1820 void append_registers(reg_kind_t kind, int first_reg, int last_reg)
1821 {
1822 intvec_t &regvec = kind == FPREGS ? fpregs : gpregs;
1823 size_t n = regvec.size();
1824 regvec.resize(n + last_reg - first_reg + 1);
1825 for ( int i = first_reg; i <= last_reg; ++i )
1826 regvec[n + i - first_reg] = i;
1827 }
1828 void set_registers(reg_kind_t kind, int first_reg, int last_reg)
1829 {
1830 intvec_t &regvec = kind == FPREGS ? fpregs : gpregs;
1831 regvec.clear();
1832 append_registers(kind, first_reg, last_reg);
1833 }
1834
1836 void reset()
1837 {
1838 set(ARGREGS_POLICY_UNDEFINED, nullptr, nullptr);
1839 }
1840
1842 static int regcount(callcnv_t cc)
1843 {
1844 callregs_t vr(cc);
1845 return vr.nregs;
1846 }
1847
1848 // return index of register, -1 else
1849 static int findreg(const intvec_t &regs, int r)
1850 {
1851 intvec_t::const_iterator p = regs.find(r);
1852 return p == regs.end() ? -1 : int(p-regs.begin());
1853 }
1854
1857 bool reginds(int *gp_ind, int *fp_ind, int r) const
1858 {
1859 return findregs(gp_ind, fp_ind, r, gpregs, fpregs);
1860 }
1861
1862protected:
1865 bool findregs(int *gp_ind, int *fp_ind, int r, const intvec_t &gprs, const intvec_t &fprs) const
1866 {
1867 *gp_ind = *fp_ind = -1;
1868 return set_inds(gp_ind, fp_ind, findreg(gprs, r))
1869 || set_inds(fp_ind, gp_ind, findreg(fprs, r));
1870 }
1871};
1872
1873//--------------------------------------------------------------------------
1877
1880const comp_t COMP_MASK = 0x0F;
1881const comp_t COMP_UNK = 0x00;
1882const comp_t COMP_MS = 0x01;
1883const comp_t COMP_BC = 0x02;
1884const comp_t COMP_WATCOM = 0x03;
1885// const comp_t COMP_ = 0x04
1886// const comp_t COMP_ = 0x05
1887const comp_t COMP_GNU = 0x06;
1888const comp_t COMP_VISAGE = 0x07;
1889const comp_t COMP_BP = 0x08;
1890//----
1891const comp_t COMP_UNSURE = 0x80;
1893
1894
1897
1899
1900inline THREAD_SAFE comp_t get_comp(comp_t comp) { return(comp & COMP_MASK); }
1901
1902
1904
1905idaman const char *ida_export get_compiler_name(comp_t id);
1906
1907
1909
1910idaman const char *ida_export get_compiler_abbr(comp_t id);
1911
1914
1915
1917
1918idaman void ida_export get_compilers(compvec_t *ids, qstrvec_t *names, qstrvec_t *abbrs);
1919
1920
1922
1923inline THREAD_SAFE comp_t is_comp_unsure(comp_t comp) { return (comp & COMP_UNSURE); }
1924
1925
1927
1929
1930
1932
1933inline bool is_gcc() { return default_compiler() == COMP_GNU; }
1934
1935
1937
1938inline bool is_gcc32() { return is_gcc() && !inf_is_64bit(); }
1939
1940
1942
1943inline bool is_gcc64() { return is_gcc() && inf_is_64bit(); }
1944
1945
1947
1948inline bool gcc_layout() { return is_gcc() || (inf_get_abibits() & ABI_GCC_LAYOUT) != 0; }
1949
1950
1956
1957idaman bool ida_export set_compiler(
1958 const compiler_info_t &cc,
1959 int flags,
1960 const char *abiname=nullptr);
1961
1964#define SETCOMP_OVERRIDE 0x0001
1965#define SETCOMP_ONLY_ID 0x0002
1968#define SETCOMP_ONLY_ABI 0x0004
1969#define SETCOMP_BY_USER 0x0008
1971
1972
1974
1975inline bool idaapi set_compiler_id(comp_t id, const char *abiname=nullptr)
1976{
1977 compiler_info_t cc;
1978 cc.id = id;
1979 return set_compiler(cc, SETCOMP_ONLY_ID, abiname);
1980}
1981
1983
1984inline bool idaapi set_abi_name(const char *abiname, bool user_level = false)
1985{
1986 compiler_info_t cc;
1987 cc.id = 0;
1988 int flags = SETCOMP_ONLY_ABI | (user_level ? SETCOMP_BY_USER : 0);
1989 return set_compiler(cc, flags, abiname);
1990}
1991
1994
1995idaman ssize_t ida_export get_abi_name(qstring *out);
1996
1997
2003idaman bool ida_export append_abi_opts(const char *abi_opts, bool user_level = false);
2004idaman bool ida_export remove_abi_opts(const char *abi_opts, bool user_level = false);
2005
2009idaman bool ida_export set_compiler_string(const char *compstr, bool user_level);
2010
2011
2013inline bool use_golang_cc()
2014{
2015 return is_golang_cc(inf_get_callcnv());
2016}
2017
2018
2020inline void switch_to_golang()
2021{
2023 if ( default_compiler() == COMP_UNK )
2025}
2026
2027
2029inline bool use_rust_cc()
2030{
2031 return is_rust_cc(inf_get_callcnv());
2032}
2033
2034
2036idaman void ida_export switch_to_rust();
2037
2038
2041
2042//--------------------------------------------------------------------------
2043const size_t BADSIZE = size_t(-1);
2044#define MAX_FUNC_ARGS 256
2045#define MAX_ARRAY_NELEMS 0x7FFFFFFF
2046
2047//--------------------------------------------------------------------------
2066
2070
2073#define HTI_CPP 0x00000001
2074#define HTI_INT 0x00000002
2075#define HTI_EXT 0x00000004
2076#define HTI_LEX 0x00000008
2077#define HTI_UNP 0x00000010
2078#define HTI_TST 0x00000020
2079#define HTI_FIL 0x00000040
2081#define HTI_MAC 0x00000080
2082#define HTI_NWR 0x00000100
2083#define HTI_NER 0x00000200
2084#define HTI_DCL 0x00000400
2085#define HTI_NDC 0x00000800
2086#define HTI_PAK 0x00007000
2087#define HTI_PAK_SHIFT 12
2091#define HTI_PAKDEF 0x00000000
2092#define HTI_PAK1 0x00001000
2093#define HTI_PAK2 0x00002000
2094#define HTI_PAK4 0x00003000
2095#define HTI_PAK8 0x00004000
2096#define HTI_PAK16 0x00005000
2097#define HTI_HIGH 0x00008000
2099#define HTI_LOWER 0x00010000
2100#define HTI_RAWARGS 0x00020000
2101#define HTI_RELAXED 0x00080000
2102#define HTI_NOBASE 0x00100000
2103#define HTI_SEMICOLON 0x00200000
2104#define HTI_STANDALONE 0x00400000
2108#define HTI_VOID_OK 0x00800000
2109#define HTI_NO_MANGLE 0x01000000
2111
2112
2120
2121typedef int idaapi h2ti_type_cb(
2122 const char *name,
2123 const tinfo_t &tif,
2124 const char *cmt,
2125 const uint64 *value,
2126 void *cb_data);
2127
2128
2131typedef AS_PRINTF(1, 2) int printer_t(const char *format, ...);
2132
2133
2146
2147idaman int ida_export h2ti(
2148 til_t *ti,
2149 lexer_t *lx,
2150 const char *input,
2151 int flags=HTI_HIGH,
2152 h2ti_type_cb *type_cb=nullptr,
2153 h2ti_type_cb *var_cb=nullptr,
2154 printer_t *print_cb=nullptr,
2155 void *_cb_data=nullptr,
2156 abs_t _isabs=ABS_UNK);
2157
2158
2162
2163inline THREAD_SAFE int convert_pt_flags_to_hti(int pt_flags)
2164{
2165 return ((pt_flags >> 4) & 0x1f) << HTI_PAK_SHIFT;
2166}
2167
2168
2180
2181idaman bool ida_export parse_decl(
2182 tinfo_t *out_tif,
2183 qstring *out_name,
2184 til_t *til,
2185 const char *decl,
2186 int pt_flags);
2187
2188
2191#define PT_SIL 0x00000001
2192#define PT_NDC 0x00000002
2193#define PT_TYP 0x00000004
2194#define PT_VAR 0x00000008
2195#define PT_PACKMASK 0x00000070
2196#define PT_HIGH 0x00000080
2198#define PT_LOWER 0x00000100
2199#define PT_REPLACE 0x00000200
2200#define PT_RAWARGS 0x00000400
2201#define PT_RELAXED 0x00001000
2202#define PT_EMPTY 0x00002000
2203#define PT_SEMICOLON 0x00004000
2204#define PT_SYMBOL 0x00008000
2206#define PT_VOID_OK 0x00010000
2207#define PT_NO_MANGLE 0x00020000
2209
2210
2220
2221idaman int ida_export parse_decls(
2222 til_t *til,
2223 const char *input,
2224 printer_t *printer,
2225 int hti_flags);
2226
2227
2233
2234idaman bool ida_export print_type(qstring *out, ea_t ea, int prtype_flags);
2235
2236
2239#define PRTYPE_1LINE 0x00000
2240#define PRTYPE_MULTI 0x00001
2241#define PRTYPE_TYPE 0x00002
2242#define PRTYPE_PRAGMA 0x00004
2243#define PRTYPE_SEMI 0x00008
2244#define PRTYPE_CPP 0x00010
2245#define PRTYPE_DEF 0x00020
2246#define PRTYPE_NOARGS 0x00040
2247#define PRTYPE_NOARRS 0x00080
2248#define PRTYPE_NORES 0x00100
2249#define PRTYPE_RESTORE 0x00200
2250#define PRTYPE_NOREGEX 0x00400
2251#define PRTYPE_COLORED 0x00800
2252#define PRTYPE_METHODS 0x01000
2253#define PRTYPE_1LINCMT 0x02000
2254#define PRTYPE_HEADER 0x04000
2255#define PRTYPE_OFFSETS 0x08000
2256#define PRTYPE_MAXSTR 0x10000
2257#define PRTYPE_TAIL 0x20000
2258#define PRTYPE_ARGLOCS 0x40000
2260
2262
2263
2267
2268
2287
2288idaman int ida_export get_named_type(
2289 const til_t *ti,
2290 const char *name,
2291 int ntf_flags,
2292 const type_t **type=nullptr,
2293 const p_list **fields=nullptr,
2294 const char **cmt=nullptr,
2295 const p_list **fieldcmts=nullptr,
2296 sclass_t *sclass=nullptr,
2297 uint32 *value=nullptr);
2298
2301#define NTF_TYPE 0x00000001
2302#define NTF_SYMU 0x00000008
2303#define NTF_SYMM 0x00000000
2305#define NTF_NOBASE 0x00000002
2306#define NTF_REPLACE 0x00000004
2307#define NTF_UMANGLED 0x00000008
2308#define NTF_NOCUR 0x00000020
2309#define NTF_64BIT 0x00000040
2310#define NTF_FIXNAME 0x00000080
2312#define NTF_IDBENC 0x00000100
2315#define NTF_CHKSYNC 0x00000200
2317#define NTF_NO_NAMECHK 0x00000400
2319#define NTF_COPY 0x00001000
2321
2322
2323// Tag to denote a regular comment in serialized form.
2324// If a comment has it as its first character, it is a regular comment,
2325// otherwise it is a repeatable comment. The comments returned by
2326// ::get_named_type and ::get_numbered_type may have this symbol.
2327#define TPOS_REGCMT '\x06'
2328
2329
2333
2334inline int idaapi get_named_type64(
2335 const til_t *ti,
2336 const char *name,
2337 int ntf_flags,
2338 const type_t **type=nullptr,
2339 const p_list **fields=nullptr,
2340 const char **cmt=nullptr,
2341 const p_list **fieldcmts=nullptr,
2342 sclass_t *sclass=nullptr,
2343 uint64 *value=nullptr)
2344{
2345 return get_named_type(ti, name, ntf_flags | NTF_64BIT,
2346 type, fields, cmt, fieldcmts, sclass, (uint32 *)value);
2347}
2348
2349
2394
2397
2398idaman const char *ida_export tinfo_errstr(tinfo_code_t code);
2399
2400
2406
2407idaman bool ida_export del_named_type(til_t *ti, const char *name, int ntf_flags);
2408
2409
2415
2416idaman const char *ida_export first_named_type(const til_t *ti, int ntf_flags);
2417
2418
2421
2422idaman const char *ida_export next_named_type(
2423 const til_t *ti,
2424 const char *name,
2425 int ntf_flags);
2426
2427
2436idaman uint32 ida_export copy_named_type(
2437 til_t *dsttil,
2438 const til_t *srctil,
2439 const char *name);
2440
2448idaman bool ida_export decorate_name(
2449 qstring *out,
2450 const char *name,
2451 bool should_decorate,
2453 const tinfo_t *type = nullptr);
2454
2456idaman bool ida_export gen_decorate_name(
2457 qstring *out,
2458 const char *name,
2459 bool should_decorate,
2460 callcnv_t cc,
2461 const tinfo_t *type);
2462
2465 qstring *out,
2466 const char *_name,
2467 bool should_decorate,
2468 callcnv_t /*cc*/,
2469 const tinfo_t &type) const
2470{
2471 return gen_decorate_name(out, _name, should_decorate, CM_CC_FASTCALL, &type);
2472}
2473
2479
2480idaman ssize_t ida_export calc_c_cpp_name(
2481 qstring *out,
2482 const char *name,
2483 const tinfo_t *type,
2484 int ccn_flags);
2487#define CCN_C 0x00 // prepare C name
2488#define CCN_CPP 0x01 // prepare C++ name
2490
2492
2493//--------------------------------------------------------------------------
2502
2505
2506idaman bool ida_export enable_numbered_types(til_t *ti, bool enable);
2507
2508
2510
2511idaman bool ida_export get_numbered_type(
2512 const til_t *ti,
2513 uint32 ordinal,
2514 const type_t **type=nullptr,
2515 const p_list **fields=nullptr,
2516 const char **cmt=nullptr,
2517 const p_list **fieldcmts=nullptr,
2518 sclass_t *sclass=nullptr);
2519
2520
2525
2526idaman uint32 ida_export alloc_type_ordinals(til_t *ti, int qty);
2527
2528
2530
2532
2533
2540
2541idaman uint32 ida_export get_ordinal_limit(const til_t *ti=nullptr);
2542
2543
2547
2548inline uint32 get_ordinal_count(const til_t *ti=nullptr)
2549{
2550 uint32 maxord = get_ordinal_limit(ti);
2551 return maxord == 0 || maxord == uint32(-1) ? 0 : maxord - 1;
2552}
2553
2554
2556
2557idaman bool ida_export del_numbered_type(til_t *ti, uint32 ordinal);
2558
2559
2563
2564idaman bool ida_export set_type_alias(til_t *ti, uint32 src_ordinal, uint32 dst_ordinal);
2565
2566
2570
2571idaman uint32 ida_export get_alias_target(const til_t *ti, uint32 ordinal);
2572
2573
2575
2576idaman int32 ida_export get_type_ordinal(const til_t *ti, const char *name);
2577
2580
2581idaman const char *ida_export get_numbered_type_name(const til_t *ti, uint32 ordinal);
2582
2583
2588
2589idaman ssize_t ida_export create_numbered_type_name(qstring *buf, int32 ord);
2590
2591
2594
2595idaman bool ida_export is_ordinal_name(const char *name, uint32 *ord=nullptr);
2596
2597
2606
2607idaman int ida_export compact_numbered_types(
2608 til_t *ti,
2609 uint32 min_ord=0,
2610 intvec_t *p_ordmap=nullptr,
2611 int flags=0);
2612
2613
2617idaman bool ida_export is_type_choosable(const til_t *ti, uint32 ordinal);
2618
2623idaman void ida_export set_type_choosable(til_t *ti, uint32 ordinal, bool value);
2624
2626
2627//--------------------------------------------------------------------------
2630
2634
2635idaman ea_t ida_export get_vftable_ea(uint32 ordinal);
2636
2637
2641
2642idaman uint32 ida_export get_vftable_ordinal(ea_t vftable_ea);
2643
2644
2649
2650idaman bool ida_export set_vftable_ea(uint32 ordinal, ea_t vftable_ea);
2651
2652
2656
2657inline bool del_vftable_ea(uint32 ordinal) { return set_vftable_ea(ordinal, BADADDR); }
2658
2659
2661
2662//--------------------------------------------------------------------------
2663// ALIGNMENT
2664
2667
2668inline size_t get_default_align() { return inf_get_cc_defalign(); }
2669
2670
2676
2677inline THREAD_SAFE void align_size(size_t &cur_tot_size, size_t elem_size, size_t algn)
2678{
2679 size_t al = elem_size;
2680 if ( algn != 0 && algn < al )
2681 al = algn;
2682 cur_tot_size = align_up(cur_tot_size, int(al));
2683}
2684
2692
2693idaman bool ida_export deref_ptr(
2694 ea_t *ptr_ea,
2695 const tinfo_t &tif,
2696 ea_t *closure_obj=nullptr);
2697
2698
2703
2704idaman bool ida_export remove_tinfo_pointer(tinfo_t *tif, const char **pname, const til_t *til=nullptr);
2705
2711
2712idaman int ida_export add_til(const char *name, int flags);
2713
2717#define ADDTIL_DEFAULT 0x0000
2718#define ADDTIL_INCOMP 0x0001
2719#define ADDTIL_SILENT 0x0002
2721
2725#define ADDTIL_FAILED 0
2726#define ADDTIL_OK 1
2727#define ADDTIL_COMP 2
2728#define ADDTIL_ABORTED 3
2730
2731
2733
2734idaman bool ida_export del_til(const char *name);
2735
2736
2741
2742idaman bool ida_export apply_named_type(ea_t ea, const char *name);
2743
2744
2752
2753idaman bool ida_export apply_tinfo(
2754 ea_t ea,
2755 const tinfo_t &tif,
2756 uint32 flags);
2757
2761#define TINFO_GUESSED 0x0000
2762#define TINFO_DEFINITE 0x0001
2763#define TINFO_DELAYFUNC 0x0002
2766#define TINFO_STRICT 0x0004
2768
2769
2777
2778idaman bool ida_export apply_cdecl(til_t *til, ea_t ea, const char *decl, int flags=0);
2779
2780
2791
2792idaman bool ida_export apply_callee_tinfo(ea_t caller, const tinfo_t &tif);
2793
2794
2801
2802idaman bool ida_export get_arg_addrs(eavec_t *out, ea_t caller);
2803
2804
2817
2818idaman bool ida_export apply_once_tinfo_and_name(
2819 ea_t dea,
2820 const tinfo_t &tif,
2821 const char *name);
2822
2823
2824// To retrieve the type information attach to an address, use get_tinfo() function
2825// (see nalt.hpp)
2826
2827
2831
2832idaman int ida_export guess_tinfo(tinfo_t *out, tid_t id);
2833
2837#define GUESS_FUNC_FAILED 0
2838#define GUESS_FUNC_TRIVIAL 1
2839#define GUESS_FUNC_OK 2
2841
2842
2843// The following functions should eventually be replaced by exported functions
2844#ifndef __KERNEL__
2846inline void set_c_header_path(const char *incdir) { setinf_buf(INF_H_PATH, incdir); }
2847
2850
2852inline void set_c_macros(const char *macros) { setinf_buf(INF_C_MACROS, macros); }
2853
2856#endif
2857
2858//------------------------------------------------------------------------
2859// HIGH LEVEL FUNCTIONS TO SUPPORT TILS IN THE IDA KERNEL
2860
2863
2864idaman til_t *ida_export get_idati();
2865
2866
2873
2874idaman bool ida_export get_idainfo_by_type(
2875 size_t *out_size,
2876 flags64_t *out_flags,
2877 opinfo_t *out_mt,
2878 const tinfo_t &tif,
2879 size_t *out_alsize=nullptr);
2880
2881
2885
2886idaman bool ida_export get_tinfo_by_flags(tinfo_t *out, flags64_t flags);
2887
2888//------------------------------------------------------------------------
2889// Type information object: tinfo_t
2890
2891struct ptr_type_data_t;
2892struct udt_type_data_t;
2893struct enum_type_data_t;
2894struct array_type_data_t;
2895struct typedef_type_data_t;
2897struct udtmembervec_t;
2898
2935
2940{
2941 ETF_NO_SAVE = 0x00000001,
2945 ETF_NO_LAYOUT = 0x00000002,
2946 ETF_MAY_DESTROY = 0x00000004,
2947 ETF_COMPATIBLE = 0x00000008,
2948 ETF_FUNCARG = 0x00000010,
2949 ETF_FORCENAME = 0x00000020,
2950 ETF_AUTONAME = 0x00000040,
2951 ETF_BYTIL = 0x00000080,
2952 ETF_NO_ARRAY = 0x00000100,
2953};
2954
2955
2965
2974
2977{
2978 GTS_NESTED = 0x01,
2980};
2981
2985#define SUDT_SORT 0x0001
2986#define SUDT_ALIGN 0x0002
2988#define SUDT_GAPS 0x0004
2989#define SUDT_UNEX 0x0008
2993#define SUDT_FAST 0x0010
2994
2995#define SUDT_CONST 0x0040
2996#define SUDT_VOLATILE 0x0080
2997
2998#define SUDT_TRUNC 0x0100
2999#define SUDT_SERDEF 0x0200
3001
3003
3005#define DECLARE_TINFO_HELPERS(decl)\
3006decl void ida_export copy_tinfo_t(tinfo_t *_this, const tinfo_t &r); \
3007decl bool ida_export detach_tinfo_t(tinfo_t *_this); \
3008decl void ida_export clear_tinfo_t(tinfo_t *_this);\
3009decl bool ida_export create_tinfo(tinfo_t *_this, type_t bt, type_t bt2, void *ptr);\
3010decl int ida_export verify_tinfo(typid_t typid);\
3011decl bool ida_export get_tinfo_details(typid_t typid, type_t bt2, void *buf);\
3012decl size_t ida_export get_tinfo_size(uint32 *p_effalign, typid_t typid, int gts_code);\
3013decl size_t ida_export get_tinfo_pdata(void *outptr, typid_t typid, int what);\
3014decl size_t ida_export get_tinfo_property(typid_t typid, int gta_prop);\
3015decl size_t ida_export get_tinfo_property4(typid_t typid, int gta_prop, size_t p1, size_t p2, size_t p3, size_t p4);\
3016decl size_t ida_export set_tinfo_property(tinfo_t *tif, int sta_prop, size_t x);\
3017decl size_t ida_export set_tinfo_property4(tinfo_t *tif, int sta_prop, size_t p1, size_t p2, size_t p3, size_t p4);\
3018decl bool ida_export serialize_tinfo(qtype *type, qtype *fields, qtype *fldcmts, const tinfo_t *tif, int sudt_flags);\
3019decl bool ida_export deserialize_tinfo(tinfo_t *tif, const til_t *til, const type_t **ptype, const p_list **pfields, const p_list **pfldcmts, const char *cmt);\
3020decl int ida_export find_tinfo_udt_member(udm_t *udm, typid_t typid, int strmem_flags);\
3021decl bool ida_export print_tinfo(qstring *result, const char *prefix, int indent, int cmtindent, int flags, const tinfo_t *tif, const char *name, const char *cmt);\
3022decl const char *ida_export dstr_tinfo(const tinfo_t *tif);\
3023decl int ida_export visit_subtypes(struct tinfo_visitor_t *visitor, struct type_mods_t *out, const tinfo_t &tif, const char *name, const char *cmt);\
3024decl bool ida_export compare_tinfo(typid_t t1, typid_t t2, int tcflags);\
3025decl int ida_export lexcompare_tinfo(typid_t t1, typid_t t2, int);\
3026decl bool ida_export get_stock_tinfo(tinfo_t *tif, stock_type_id_t id);\
3027decl uint64 ida_export read_tinfo_bitfield_value(typid_t typid, uint64 v, int bitoff);\
3028decl uint64 ida_export write_tinfo_bitfield_value(typid_t typid, uint64 dst, uint64 v, int bitoff);\
3029decl bool ida_export get_tinfo_attr(typid_t typid, const qstring &key, bytevec_t *bv, bool all_attrs);\
3030decl bool ida_export set_tinfo_attr(tinfo_t *tif, const type_attr_t &ta, bool may_overwrite);\
3031decl bool ida_export del_tinfo_attr(tinfo_t *tif, const qstring &key, bool make_copy);\
3032decl bool ida_export get_tinfo_attrs(typid_t typid, type_attrs_t *tav, bool include_ref_attrs);\
3033decl bool ida_export set_tinfo_attrs(tinfo_t *tif, type_attrs_t *ta);\
3034decl uint32 ida_export score_tinfo(const tinfo_t *tif);\
3035decl tinfo_code_t ida_export save_tinfo(tinfo_t *tif, til_t *til, size_t ord, const char *name, int ntf_flags);\
3036decl bool ida_export append_tinfo_covered(rangeset_t *out, typid_t typid, uint64 offset);\
3037decl bool ida_export calc_tinfo_gaps(rangeset_t *out, typid_t typid);\
3038decl bool ida_export name_requires_qualifier(qstring *out, typid_t typid, const char *name, uint64 offset);\
3039decl bool ida_export value_repr_t__from_opinfo(value_repr_t *_this, flags64_t flags, aflags_t afl, const opinfo_t *opinfo, const array_parameters_t *ap); \
3040decl size_t ida_export value_repr_t__print_(const value_repr_t *_this, qstring *result, bool colored); \
3041decl bool ida_export value_repr_t__parse_value_repr(value_repr_t *_this, const qstring &attr, type_t target_type); \
3042decl ssize_t ida_export udt_type_data_t__find_member(const udt_type_data_t *_this, udm_t *udm, int strmem_flags); \
3043decl ssize_t ida_export udt_type_data_t__get_best_fit_member(const udt_type_data_t *_this, asize_t disp); \
3044decl bool ida_export udt_type_data_t__deduplicate_members(udt_type_data_t *_this); \
3045decl bool ida_export udm_t__compare_with(const udm_t *_this, const udm_t &r, int tcflags); \
3046decl uchar ida_export enum_type_data_t__get_max_serial(const enum_type_data_t *ei, uint64 value); \
3047decl tinfo_code_t ida_export enum_type_data_t__set_value_repr(enum_type_data_t *ei, const value_repr_t &repr); \
3048decl tinfo_code_t ida_export enum_type_data_t__get_value_repr(const enum_type_data_t *ei, value_repr_t *repr); \
3049decl void ida_export tinfo_get_innermost_udm(tinfo_t *itif, const tinfo_t *tif, uint64 offset, size_t *udm_idx, uint64 *bit_offset, bool return_member_type); \
3050decl ssize_t ida_export get_udm_by_tid(tinfo_t *tif, udm_t *udm, tid_t tid); \
3051decl ssize_t ida_export get_edm_by_tid(tinfo_t *tif, edm_t *edm, tid_t tid); \
3052decl bool ida_export get_type_by_tid(tinfo_t *tif, tid_t tid); \
3053decl tid_t ida_export get_tinfo_tid(tinfo_t *tif, bool force_tid); \
3054decl ssize_t ida_export get_tinfo_by_edm_name(tinfo_t *tif, const til_t *til, const char *mname); \
3055decl ssize_t ida_export get_frame_var(tinfo_t *tif, sval_t *actval, const insn_t &insn, const op_t *x, sval_t v); \
3056decl bool ida_export tinfo_get_func_frame(tinfo_t *tif, const func_t *pfn); \
3057decl bool ida_export tinfo_get_func_frame_ea(tinfo_t *tif, ea_t func_ea); \
3058decl bool ida_export tinfo_t__build_anon_type_name(qstring *out, const tinfo_t &tif); \
3059
3060DECLARE_TINFO_HELPERS(idaman)
3061
3062
3070const int FIRST_NONTRIVIAL_TYPID = 0x100;
3071const int TYPID_ISREF = 0x100;
3072const int TYPID_SHIFT = 9;
3074
3076class tinfo_t // #tinfo_t #tif
3077{
3078 typid_t typid;
3079 bool create_type(type_t decl_type, type_t bt2, void *details)
3080 {
3081 return create_tinfo(this, decl_type, bt2, details);
3082 }
3087 bool get_type_details(type_t bt2, void *buf) const { return get_tinfo_details(typid, bt2, buf); }
3088 void copy(const tinfo_t &r) { copy_tinfo_t(this, r); }
3089 DECLARE_TINFO_HELPERS(friend)
3090 friend struct type_detail_t;
3091 friend tinfo_t remove_pointer(const tinfo_t &tif);
3093 enum gta_prop_t
3094 {
3095 GTA_DECLALIGN,
3096 GTA_RESOLVE,
3097 GTA_REALTYPE,
3098 GTA_TYPE_SIGN,
3099 GTA_FROM_SUBTIL,
3100 GTA_IS_FORWARD,
3101 GTA_IS_FUNCPTR,
3102 GTA_ORDINAL,
3103 GTA_FINAL_ORDINAL,
3104 GTA_PTR_OBJ,
3105 GTA_SAFE_PTR_OBJ,
3106 GTA_ARRAY_ELEM,
3107 GTA_ARRAY_NELEMS,
3108 GTA_PTRARR_SUBTIF,
3109 GTA_PTRARR_SIZE,
3110 GTA_UNPADDED_SIZE,
3111 GTA_UDT_NMEMBERS,
3112 GTA_IS_SMALL_UDT,
3113 GTA_ONEMEM_TYPE,
3114 GTA_ENUM_BASE_TYPE,
3115 GTA_FUNC_CC,
3116 GTA_PURGED_BYTES,
3117 GTA_IS_HIGH_TYPE,
3118 GTA_FUNC_NARGS,
3119 GTA_FUNC_RET,
3120 GTA_FUNC_ARG,
3121 GTA_LAST_FUNC_ARG = GTA_FUNC_ARG + 255,
3122 GTA_IS_SSE_TYPE,
3123 GTA_IS_ANON_UDT,
3124 GTA_OBSOLETE1,
3125 GTA_HAS_VFTABLE,
3126 GTA_IS_SHIFTED_PTR,
3127 GTA_IS_VARSTRUCT,
3128 GTA_IS_VARMEMBER,
3129 GTA_IS_TYPEDEF,
3130 GTA_FINAL_ELEM,
3131 GTA_FORWARD_TYPE,
3132 GTA_BITMASK,
3133 GTA_ENUM_RADIX,
3134 GTA_EDM,
3135 GTA_EDM_BYVAL,
3136 GTA_EDM_BYNAME,
3137 GTA_HAS_UNION,
3138 GTA_UDM_TID,
3139 GTA_ALIAS,
3140 GTA_EDM_TID,
3141 GTA_FRAME_FUNC,
3142 GTA_UDM_IS_BYTIL,
3143 GTA_OBSOLETE2,
3144 GTA_EDT_NMEMBERS,
3145 GTA_ENUM_WIDTH,
3146 GTA_ENUM_REPR,
3147 GTA_UDT_BITS,
3148 GTA_IS_ANON_NAME,
3149 };
3150 enum sta_prop_t
3151 {
3152 STA_DECLALIGN,
3153 STA_TYPE_SIGN,
3154 STA_UDT_ALIGN,
3155 STA_UDT_METHODS,
3156 STA_RENAME,
3157 STA_COMMENT,
3158 STA_CLR_MODIFS,
3159 STA_SET_SDA,
3160 STA_SET_PACK,
3161 STA_ADD_UDM,
3162 STA_DEL_UDMS,
3163 STA_UDM_NAME,
3164 STA_UDM_TYPE,
3165 STA_UDM_CMT,
3166 STA_UDM_REPR,
3167 STA_EXPAND_UDT,
3168 STA_ENUM_WIDTH,
3169 STA_ENUM_SIGN,
3170 STA_BITMASK,
3171 STA_ENUM_REPR,
3172 STA_ADD_EDM,
3173 STA_DEL_EDMS,
3174 STA_EDM_NAME,
3175 STA_EDM_CMT,
3176 STA_EDIT_EDM,
3177 STA_ALIAS,
3178 STA_ALIGNMENT,
3179 STA_UDM_SET_BYTIL,
3180 STA_FIXED_STRUCT,
3181 STA_STRUCT_SIZE,
3182 STA_FUNCARG_NAME,
3183 STA_FUNCARG_TYPE,
3184 STA_FUNC_RETTYPE,
3185 STA_DEL_FUNCARGS,
3186 STA_ADD_FUNCARG,
3187 STA_FUNC_CC,
3188 STA_ENUM_RADIX,
3189 STA_FUNCARG_LOC,
3190 STA_FUNC_RETLOC,
3191 STA_TUPLE,
3192 STA_IFACE,
3193 };
3194 enum gta_pdata_t
3195 {
3196 GTP_NAME,
3197 GTP_NEXT_NAME,
3198 GTP_FINAL_NAME,
3199 GTP_TIL,
3200 GTP_UDT_METHODS,
3201 GTP_COMMENT,
3202 GTP_RPTCMT,
3203 GTP_BIT_BUCKETS,
3204 GTP_NICE_NAME,
3205 };
3206
3207public:
3209 tinfo_t() : typid(BT_UNK) {}
3211 explicit tinfo_t(type_t decl_type) : typid(decl_type) {}
3213 explicit tinfo_t(const char *decl, til_t *til=nullptr, int pt_flags=0)
3214 : typid(0)
3215 {
3216 parse(decl, til, pt_flags);
3217 }
3218
3220 tinfo_t(const tinfo_t &r) : typid(0) { copy(r); }
3222 tinfo_t &operator=(const tinfo_t &r) { copy(r); return *this; }
3226 void clear() { clear_tinfo_t(this); }
3228 void swap(tinfo_t &r) { typid_t tmp = typid; typid = r.typid; r.typid = tmp; }
3230
3231
3242 inline bool get_named_type(
3243 const til_t *til,
3244 const char *name,
3246 bool resolve=true,
3247 bool try_ordinal=true);
3248
3249 inline bool get_named_type(const char *name, type_t decl_type=BTF_TYPEDEF, bool resolve=true, bool try_ordinal=true) { return get_named_type(nullptr, name, decl_type, resolve, try_ordinal); }
3250
3261 inline bool get_numbered_type(
3262 const til_t *til,
3263 uint32 ordinal,
3265 bool resolve=true);
3266
3267 inline bool get_numbered_type(uint32 ordinal, type_t decl_type=BTF_TYPEDEF, bool resolve=true) { return get_numbered_type(nullptr, ordinal, decl_type, resolve); }
3268
3274 bool detach() { return detach_tinfo_t(this); }
3275
3278 qtype *type,
3279 qtype *fields=nullptr,
3280 qtype *fldcmts=nullptr,
3281 int sudt_flags=SUDT_FAST|SUDT_TRUNC) const
3282 {
3283 return serialize_tinfo(type, fields, fldcmts, this, sudt_flags);
3284 }
3285
3288 const til_t *til,
3289 const type_t **ptype,
3290 const p_list **pfields=nullptr,
3291 const p_list **pfldcmts=nullptr,
3292 const char *cmt=nullptr)
3293 {
3294 return deserialize_tinfo(this, til, ptype, pfields, pfldcmts, cmt);
3295 }
3296
3298 const til_t *til,
3299 const qtype *ptype,
3300 const qtype *pfields=nullptr,
3301 const qtype *pfldcmts=nullptr,
3302 const char *cmt=nullptr)
3303 {
3304 const type_t *tp = ptype->begin();
3305 const p_list *fp = pfields == nullptr ? nullptr : pfields->begin();
3306 const p_list *cp = pfldcmts == nullptr ? nullptr : pfldcmts->begin();
3307 const p_list **pfp = fp == nullptr ? nullptr : &fp;
3308 const p_list **pcp = cp == nullptr ? nullptr : &cp;
3309 return deserialize(til, &tp, pfp, pcp, cmt);
3310 }
3311
3318 bool is_correct() const { return verify_tinfo(typid) == 0; }
3319
3331 type_t get_realtype(bool full=false) const { return (type_t)get_tinfo_property(typid, full ? GTA_RESOLVE : GTA_REALTYPE); }
3332
3338 THREAD_SAFE type_t get_decltype() const { return type_t(typid); }
3339
3341 THREAD_SAFE bool empty() const { return get_decltype() == BT_UNK; }
3342
3344 bool present() const { return get_realtype() != BT_UNK; }
3345
3350 size_t get_size(uint32 *p_effalign=nullptr, int gts_code=0) const { return get_tinfo_size(p_effalign, typid, gts_code); }
3351
3354 size_t get_unpadded_size() const { return get_tinfo_property(typid, GTA_UNPADDED_SIZE); }
3355
3359 {
3360 uint32 alignment = 0;
3361 get_size(&alignment);
3362 return alignment;
3363 }
3364
3366 type_sign_t get_sign() const { return type_sign_t(get_tinfo_property(typid, GTA_TYPE_SIGN)); }
3367
3369 bool is_signed() const { return get_sign() == type_signed; }
3370
3372 bool is_unsigned() const { return get_sign() == type_unsigned; }
3373
3375 uchar get_declalign() const { return uchar(get_tinfo_property(typid, GTA_DECLALIGN)); }
3376
3378 THREAD_SAFE bool is_typeref() const { return (typid & TYPID_ISREF) != 0; }
3379
3381 THREAD_SAFE bool has_details() const { return typid >= FIRST_NONTRIVIAL_TYPID; }
3382
3388 bool get_type_name(qstring *out) const { return is_typeref() && get_tinfo_pdata(out, typid, GTP_NAME); }
3389
3392 bool get_nice_type_name(qstring *out) const { return is_typeref() && get_tinfo_pdata(out, typid, GTP_NICE_NAME); }
3393
3395 bool build_anon_type_name(qstring *out) const { return tinfo_t__build_anon_type_name(out, *this); }
3396
3401 tinfo_code_t rename_type(const char *name, int ntf_flags=0) { return tinfo_code_t(set_tinfo_property4(this, STA_RENAME, size_t(name), size_t(NTF_TYPE|ntf_flags), 0, 0)); }
3402
3406 bool get_final_type_name(qstring *out) const { return is_typeref() && get_tinfo_pdata(out, typid, GTP_FINAL_NAME); }
3407
3411 bool get_next_type_name(qstring *out) const { return is_typeref() && get_tinfo_pdata(out, typid, GTP_NEXT_NAME); }
3412
3422 tid_t get_tid() const { return get_tinfo_tid((tinfo_t *)this, false); }
3423
3430 tid_t force_tid() { return get_tinfo_tid(this, true); }
3431
3433 uint32 get_ordinal() const { return uint32(get_tinfo_property(typid, GTA_ORDINAL)); }
3434
3436 uint32 get_final_ordinal() const { return uint32(get_tinfo_property(typid, GTA_FINAL_ORDINAL)); }
3437
3439 til_t *get_til() const { til_t *til; get_tinfo_pdata(&til, typid, GTP_TIL); return til; }
3440
3444 bool is_from_subtil() const { return is_typeref() && get_tinfo_property(typid, GTA_FROM_SUBTIL); }
3445
3448 bool is_forward_decl() const { return bool(get_tinfo_property(typid, GTA_IS_FORWARD)); }
3449
3453 type_t get_forward_type() const { return type_t(get_tinfo_property(typid, GTA_FORWARD_TYPE)); }
3457
3461 bool is_typedef() const { return get_tinfo_property(typid, GTA_IS_TYPEDEF) != 0; }
3462
3465 int get_type_cmt(qstring *out) const { return has_details() ? int(get_tinfo_pdata(out, typid, GTP_COMMENT)) : 0; }
3466
3468 bool get_type_rptcmt(qstring *out) const { return has_details() && get_tinfo_pdata(out, typid, GTP_RPTCMT); }
3469
3470 THREAD_SAFE bool is_decl_const() const { return is_type_const(get_decltype()); }
3471 THREAD_SAFE bool is_decl_volatile() const { return is_type_volatile(get_decltype()); }
3472 THREAD_SAFE bool is_decl_void() const { return is_type_void(get_decltype()); }
3473 THREAD_SAFE bool is_decl_partial() const { return is_type_partial(get_decltype()); }
3474 THREAD_SAFE bool is_decl_unknown() const { return is_type_unknown(get_decltype()); }
3475 THREAD_SAFE bool is_decl_last() const { return is_typeid_last(get_decltype()); }
3476 THREAD_SAFE bool is_decl_ptr() const { return is_type_ptr(get_decltype()); }
3477 THREAD_SAFE bool is_decl_array() const { return is_type_array(get_decltype()); }
3478 THREAD_SAFE bool is_decl_func() const { return is_type_func(get_decltype()); }
3479 THREAD_SAFE bool is_decl_complex() const { return is_type_complex(get_decltype()); }
3480 THREAD_SAFE bool is_decl_typedef() const { return is_type_typedef(get_decltype()); }
3481 THREAD_SAFE bool is_decl_sue() const { return is_type_sue(get_decltype()); }
3482 THREAD_SAFE bool is_decl_struct() const { return is_type_struct(get_decltype()); }
3483 THREAD_SAFE bool is_decl_union() const { return is_type_union(get_decltype()); }
3484 THREAD_SAFE bool is_decl_udt() const { return is_type_struni(get_decltype()); }
3485 THREAD_SAFE bool is_decl_enum() const { return is_type_enum(get_decltype()); }
3486 THREAD_SAFE bool is_decl_bitfield() const { return is_type_bitfld(get_decltype()); }
3487 THREAD_SAFE bool is_decl_int128() const { return is_type_int128(get_decltype()); }
3488 THREAD_SAFE bool is_decl_int64() const { return is_type_int64(get_decltype()); }
3489 THREAD_SAFE bool is_decl_int32() const { return is_type_int32(get_decltype()); }
3490 THREAD_SAFE bool is_decl_int16() const { return is_type_int16(get_decltype()); }
3491 THREAD_SAFE bool is_decl_int() const { return is_type_int(get_decltype()); }
3492 THREAD_SAFE bool is_decl_char() const { return is_type_char(get_decltype()); }
3493 THREAD_SAFE bool is_decl_uint() const { return is_type_uint(get_decltype()); }
3494 THREAD_SAFE bool is_decl_uchar() const { return is_type_uchar(get_decltype()); }
3495 THREAD_SAFE bool is_decl_uint16() const { return is_type_uint16(get_decltype()); }
3496 THREAD_SAFE bool is_decl_uint32() const { return is_type_uint32(get_decltype()); }
3497 THREAD_SAFE bool is_decl_uint64() const { return is_type_uint64(get_decltype()); }
3498 THREAD_SAFE bool is_decl_uint128() const { return is_type_uint128(get_decltype()); }
3499 THREAD_SAFE bool is_decl_ldouble() const { return is_type_ldouble(get_decltype()); }
3500 THREAD_SAFE bool is_decl_double() const { return is_type_double(get_decltype()); }
3501 THREAD_SAFE bool is_decl_float() const { return is_type_float(get_decltype()); }
3502 THREAD_SAFE bool is_decl_tbyte() const { return is_type_tbyte(get_decltype()); }
3503 THREAD_SAFE bool is_decl_floating() const { return is_type_floating(get_decltype()); }
3504 THREAD_SAFE bool is_decl_bool() const { return is_type_bool(get_decltype()); }
3505 THREAD_SAFE bool is_decl_paf() const { return is_type_paf(get_decltype()); }
3506 THREAD_SAFE bool is_well_defined() const { return !empty() && !is_decl_partial() && !is_punknown(); }
3507
3508 // Probe the resolved type for various attributes:
3509 bool is_const() const { return is_type_const(get_realtype()); }
3510 bool is_volatile() const { return is_type_volatile(get_realtype()); }
3511 bool is_void() const { return is_type_void(get_realtype()); }
3512 bool is_partial() const { return is_type_partial(get_realtype()); }
3513 bool is_unknown() const { return is_type_unknown(get_realtype()); }
3514 bool is_ptr() const { return is_type_ptr(get_realtype()); }
3515 bool is_array() const { return is_type_array(get_realtype()); }
3516 bool is_func() const { return is_type_func(get_realtype()); }
3517 bool is_complex() const { return is_type_complex(get_realtype()); }
3518 bool is_struct() const { return is_type_struct(get_realtype()); }
3519 bool is_union() const { return is_type_union(get_realtype()); }
3520 bool is_udt() const { return is_type_struni(get_realtype()); }
3521 bool is_enum() const { return is_type_enum(get_realtype()); }
3522 bool is_sue() const { return is_type_sue(get_realtype()); }
3523 bool is_bitfield() const { return is_type_bitfld(get_realtype()); }
3524 bool is_int128() const { return is_type_int128(get_realtype()); }
3525 bool is_int64() const { return is_type_int64(get_realtype()); }
3526 bool is_int32() const { return is_type_int32(get_realtype()); }
3527 bool is_int16() const { return is_type_int16(get_realtype()); }
3528 bool is_int() const { return is_type_int(get_realtype()); }
3529 bool is_char() const { return is_type_char(get_realtype()); }
3530 bool is_uint() const { return is_type_uint(get_realtype()); }
3531 bool is_uchar() const { return is_type_uchar(get_realtype()); }
3532 bool is_uint16() const { return is_type_uint16(get_realtype()); }
3533 bool is_uint32() const { return is_type_uint32(get_realtype()); }
3534 bool is_uint64() const { return is_type_uint64(get_realtype()); }
3535 bool is_uint128() const { return is_type_uint128(get_realtype()); }
3536 bool is_ldouble() const { return is_type_ldouble(get_realtype()); }
3537 bool is_double() const { return is_type_double(get_realtype()); }
3538 bool is_float() const { return is_type_float(get_realtype()); }
3539 bool is_tbyte() const { return is_type_tbyte(get_realtype()); }
3540 bool is_bool() const { return is_type_bool(get_realtype()); }
3541 bool is_paf() const { return is_type_paf(get_realtype()); }
3543 bool is_integral() const { return is_type_integral(get_realtype()); }
3545 bool is_floating() const { return is_type_floating(get_realtype()); }
3546 bool is_arithmetic() const { return is_type_arithmetic(get_realtype()); }
3549 bool is_scalar() const { type_t bt = get_realtype(); return get_base_type(bt) <= BT_PTR || is_type_enum(bt); }
3550
3553 {
3554 return get_type_details(BT_PTR, pi);
3555 }
3556
3559 {
3560 return get_type_details(BT_ARRAY, ai);
3561 }
3562
3565 {
3566 return get_type_details(BTF_ENUM, ei);
3567 }
3568
3571 {
3572 return get_type_details(BT_BITFIELD, bi);
3573 }
3574
3577 {
3578 return get_type_details(BTF_STRUCT|gtd, udt);
3579 }
3580
3583 {
3584 return get_type_details(BT_FUNC|gtd, fi);
3585 }
3586
3588 bool is_funcptr() const { return get_tinfo_property(typid, GTA_IS_FUNCPTR) != 0; }
3589
3591 bool is_shifted_ptr() const { return get_tinfo_property(typid, GTA_IS_SHIFTED_PTR) != 0; }
3592
3594 bool is_varstruct() const { return get_tinfo_property(typid, GTA_IS_VARSTRUCT) != 0; }
3595
3599 bool is_varmember() const { return get_tinfo_property(typid, GTA_IS_VARMEMBER) != 0; }
3600
3602 int get_ptrarr_objsize() const { return int(get_tinfo_property(typid, GTA_PTRARR_SIZE)); }
3603
3606 tinfo_t get_ptrarr_object() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_PTRARR_SUBTIF); return r; }
3607
3611 tinfo_t get_pointed_object() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_PTR_OBJ); return r; }
3612
3615 bool is_pvoid() const { return get_pointed_object().is_void(); }
3616
3619 bool is_punknown() const { return get_pointed_object().is_unknown(); }
3620
3622 tinfo_t get_array_element() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_ARRAY_ELEM); return r; }
3623
3625 tinfo_t get_final_element() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_FINAL_ELEM); return r; }
3626
3628 int get_array_nelems() const { return int(get_tinfo_property(typid, GTA_ARRAY_NELEMS)); }
3629
3632 {
3633 tinfo_t r;
3634 if ( n >= -1 && n < MAX_FUNC_ARGS )
3635 r.typid = get_tinfo_property(typid, GTA_FUNC_ARG+n);
3636 return r;
3637 }
3638
3640 tinfo_t get_rettype() const { return get_nth_arg(-1); }
3641
3643 int get_nargs() const { return int(get_tinfo_property(typid, GTA_FUNC_NARGS)); }
3644
3646 callcnv_t get_cc() const { return (callcnv_t)get_tinfo_property(typid, GTA_FUNC_CC); }
3647 bool is_user_cc() const { return ::is_user_cc(get_cc()); }
3648 bool is_vararg_cc() const { return ::is_vararg_cc(get_cc()); }
3649 bool is_purging_cc() const { return ::is_purging_cc(get_cc()); }
3650
3652 int calc_purged_bytes() const { return int(get_tinfo_property(typid, GTA_PURGED_BYTES)); }
3653
3655 bool is_high_func() const { return get_tinfo_property(typid, GTA_IS_HIGH_TYPE) != 0; }
3656
3659 bool get_methods(udtmembervec_t *methods) const { return get_tinfo_pdata(methods, typid, GTP_UDT_METHODS) != 0; }
3660
3664 bool get_bit_buckets(range64vec_t *buckets) const { return get_tinfo_pdata(buckets, typid, GTP_BIT_BUCKETS) != 0; }
3665
3673 int find_udm(udm_t *udm, int strmem_flags) const { return find_tinfo_udt_member(udm, typid, strmem_flags); }
3677#define STRMEM_MASK 0x000F
3678#define STRMEM_OFFSET 0x0000
3680#define STRMEM_INDEX 0x0001
3682#define STRMEM_AUTO 0x0002
3685#define STRMEM_NAME 0x0003
3687#define STRMEM_TYPE 0x0004
3690#define STRMEM_SIZE 0x0005
3692#define STRMEM_MINS 0x0006
3693#define STRMEM_MAXS 0x0007
3694#define STRMEM_LOWBND 0x0008
3696#define STRMEM_NEXT 0x0009
3698
3699#define STRMEM_VFTABLE 0x10000000
3702#define STRMEM_SKIP_EMPTY 0x20000000
3706#define STRMEM_CASTABLE_TO 0x40000000
3709#define STRMEM_ANON 0x80000000
3712#define STRMEM_SKIP_GAPS 0x01000000
3716
3719 inline int find_udm(uint64 offset, int strmem_flags=0) const;
3720
3723 inline int find_udm(const char *name, int strmem_flags=0) const;
3724
3729 inline int get_udm(udm_t *out, const char *name) const;
3730
3735 inline int get_udm(udm_t *out, size_t index) const;
3736
3741 inline int get_udm_by_offset(udm_t *out, uint64 offset) const;
3742
3744 int get_udt_nmembers() const { return int(get_tinfo_property(typid, GTA_UDT_NMEMBERS)); }
3745
3747 bool is_empty_udt() const { return get_udt_nmembers() == 0; }
3748
3750 bool is_small_udt() const { return get_tinfo_property(typid, GTA_IS_SMALL_UDT) != 0; }
3751
3753 uint32 get_udt_taudt_bits() const { return uint32(get_tinfo_property(typid, GTA_UDT_BITS)); }
3754
3756 bool is_unaligned_struct() const { return (get_udt_taudt_bits() & TAUDT_UNALIGNED) != 0; }
3757
3759 bool is_msstruct() const { return (get_udt_taudt_bits() & TAUDT_MSSTRUCT) != 0; }
3760
3762 bool is_cpp_struct() const { return (get_udt_taudt_bits() & TAUDT_CPPOBJ) != 0; }
3763
3765 bool is_vftable() const { return (get_udt_taudt_bits() & TAUDT_VFTABLE) != 0; }
3766
3768 bool is_fixed_struct() const { return (get_udt_taudt_bits() & TAUDT_FIXED) != 0; }
3769
3771 bool is_tuple() const { return (get_udt_taudt_bits() & TAUDT_TUPLE) != 0; }
3772
3774 bool is_iface() const { return (get_udt_taudt_bits() & TAUDT_IFACE) != 0; }
3775
3781 bool requires_qualifier(qstring *out, const char *name, uint64 offset) const { return name_requires_qualifier(out, typid, name, offset); }
3782
3786 bool append_covered(rangeset_t *out, uint64 offset=0) const { return append_tinfo_covered(out, typid, offset); }
3787
3790 bool calc_gaps(rangeset_t *out) const { return calc_tinfo_gaps(out, typid); }
3791
3793 bool is_one_fpval() const { return get_onemember_type().is_floating(); }
3794
3796 bool is_sse_type() const { return get_tinfo_property(typid, GTA_IS_SSE_TYPE) != 0; }
3797
3800 bool is_anonymous_udt() const { return get_tinfo_property(typid, GTA_IS_ANON_UDT) != 0; }
3801
3803 bool is_anonymous_type_name() const { return get_tinfo_property(typid, GTA_IS_ANON_NAME) != 0; }
3804
3806 bool has_vftable() const { return get_tinfo_property(typid, GTA_HAS_VFTABLE) != 0; }
3807
3809 bool has_union() const { return get_tinfo_property(typid, GTA_HAS_UNION) != 0; }
3810
3813 size_t get_enum_nmembers() const { return get_tinfo_property(typid, GTA_EDT_NMEMBERS); }
3814
3816 bool is_empty_enum() const { return get_enum_nmembers() == 0; }
3817
3820 type_t get_enum_base_type() const { return (type_t)get_tinfo_property(typid, GTA_ENUM_BASE_TYPE); }
3821
3825 bool is_bitmask_enum() const { return get_tinfo_property(typid, GTA_BITMASK) != 0; }
3826
3830 int get_enum_radix() const { return int(get_tinfo_property(typid, GTA_ENUM_RADIX)); }
3831
3834 tinfo_code_t get_enum_repr(value_repr_t *repr) const { return tinfo_code_t(get_tinfo_property4(typid, GTA_ENUM_REPR, size_t(repr), 0, 0, 0)); }
3835
3839 int get_enum_width() const { return int(get_tinfo_property(typid, GTA_ENUM_WIDTH)); }
3841
3846 ssize_t get_edm(edm_t *out, const char *name) const { return get_tinfo_property4(typid, GTA_EDM_BYNAME, size_t(out), size_t(name), 0, 0); }
3847
3851 tinfo_code_t get_edm(edm_t *edm, size_t idx) const { return tinfo_code_t(get_tinfo_property4(typid, GTA_EDM, size_t(edm), idx, 0, 0)); }
3852
3859 ssize_t get_edm_by_value(edm_t *out, uint64 value, bmask64_t bmask=DEFMASK64, uchar serial=0) const { return get_tinfo_property4(typid, GTA_EDM_BYVAL, size_t(out), value, bmask, serial); }
3860
3866 tid_t get_edm_tid(size_t idx) const { return get_tinfo_property4(typid, GTA_EDM_TID, idx, 0, 0, 0); }
3867
3869 tinfo_t get_onemember_type() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_ONEMEM_TYPE); return r; }
3870
3877 tinfo_t get_innermost_udm(uint64 bitoffset, size_t *out_index=nullptr, uint64 *out_bitoffset=nullptr) const { tinfo_t itif; tinfo_get_innermost_udm(&itif, this, bitoffset, out_index, out_bitoffset, false); return itif; }
3878
3879
3884 tinfo_t get_innermost_member_type(uint64 bitoffset, uint64 *out_bitoffset=nullptr) const { tinfo_t itif; tinfo_get_innermost_udm(&itif, this, bitoffset, nullptr, out_bitoffset, true); return itif; }
3885
3887 uint32 calc_score() const { return score_tinfo(this); }
3888
3898 bool print(
3899 qstring *out,
3900 const char *name=nullptr,
3901 int prtype_flags=PRTYPE_1LINE,
3902 int indent=0,
3903 int cmtindent=0,
3904 const char *prefix=nullptr,
3905 const char *cmt=nullptr) const
3906 {
3907 return print_tinfo(out, prefix, indent, cmtindent, prtype_flags, this, name, cmt);
3908 }
3909
3911 const char *dstr() const { return dstr_tinfo(this); }
3912
3914 bool get_attrs(type_attrs_t *tav, bool all_attrs=false) const { return get_tinfo_attrs(typid, tav, all_attrs); }
3915
3917 bool get_attr(const qstring &key, bytevec_t *bv, bool all_attrs=true) const { return get_tinfo_attr(typid, key, bv, all_attrs); }
3918
3922 bool set_attrs(type_attrs_t *tav) { return set_tinfo_attrs(this, tav); }
3923
3925 bool set_attr(const type_attr_t &ta, bool may_overwrite=true) { return set_tinfo_attr(this, ta, may_overwrite); }
3926
3928 void del_attrs() { set_tinfo_attrs(this, nullptr); }
3929
3931 bool del_attr(const qstring &key, bool make_copy=true) { return del_tinfo_attr(this, key, make_copy); }
3932
3933 bool create_simple_type(type_t decl_type) { return create_type(decl_type, BT_INT, nullptr); }
3934 bool create_ptr(const ptr_type_data_t &p, type_t decl_type=BT_PTR) { return create_type(decl_type, BT_PTR, (void*)&p); }
3935 bool create_array(const array_type_data_t &p, type_t decl_type=BT_ARRAY) { return create_type(decl_type, BT_ARRAY, (void*)&p); }
3936 bool create_bitfield(const bitfield_type_data_t &p, type_t decl_type=BT_BITFIELD) { return create_type(decl_type, BT_BITFIELD, (void*)&p); }
3938 {
3940 return create_type(decl_type, bt2, (void *)&p);
3941 }
3942
3945 inline bool create_ptr(const tinfo_t &tif, uchar bps=0, type_t decl_type=BT_PTR);
3946 inline bool create_array(const tinfo_t &tif, uint32 nelems=0, uint32 base=0, type_t decl_type=BT_ARRAY);
3947 inline void create_typedef(const til_t *til, const char *name, type_t decl_type=BTF_TYPEDEF, bool try_ordinal=true) { get_named_type(til, name, decl_type, false, try_ordinal); }
3948 inline void create_typedef(const til_t *til, uint ord, type_t decl_type=BTF_TYPEDEF) { get_numbered_type(til, ord, decl_type, false); }
3949 inline bool create_bitfield(uchar nbytes, uchar width, bool is_unsigned=false, type_t decl_type=BT_BITFIELD);
3951
3956 bool parse(const char *decl, til_t *til=nullptr, int pt_flags=0)
3957 {
3958 return ::parse_decl(this, nullptr, til, decl, pt_flags | PT_SEMICOLON);
3959 }
3960
3962 inline bool create_udt(bool is_union=false);
3963
3965 inline bool create_enum(bte_t bte=BTE_ALWAYS|BTE_HEX);
3966
3970 inline bool create_udt(udt_type_data_t &p);
3971 bool create_udt(udt_type_data_t &p, type_t decl_type) { return create_type(decl_type, BTF_STRUCT, &p); }
3973 bool create_func(func_type_data_t &p, type_t decl_type=BT_FUNC) { return create_type(decl_type, BT_FUNC, &p); }
3975
3984 ssize_t get_udm_by_tid(udm_t *udm, tid_t tid) { return ::get_udm_by_tid(this, udm, tid); }
3985 ssize_t get_edm_by_tid(edm_t *edm, tid_t tid) { return ::get_edm_by_tid(this, edm, tid); }
3986 bool get_type_by_tid(tid_t tid) { return ::get_type_by_tid(this, tid); }
3988
3994 ssize_t get_by_edm_name(const char *mname, const til_t *til=nullptr) { return ::get_tinfo_by_edm_name(this, til, mname); }
3995
4002 tinfo_code_t set_named_type(til_t *til, const char *name, int ntf_flags=0) { return save_tinfo(this, til, 0, name, ntf_flags|NTF_TYPE); }
4003 tinfo_code_t set_symbol_type(til_t *til, const char *name, int ntf_flags=0) { return save_tinfo(this, til, 0, name, ntf_flags); } // NTF_SYMM and NTF_SYMU are permitted
4004 tinfo_code_t set_numbered_type(til_t *til, uint32 ord, int ntf_flags=0, const char *name=nullptr) { return save_tinfo(this, til, ord, name, ntf_flags); }
4005 tinfo_code_t save_type(int ntf_flags=NTF_TYPE|NTF_REPLACE) { return save_tinfo(this, nullptr, 0, nullptr, ntf_flags); }
4006 tinfo_code_t copy_type(til_t *til, const char *name, int ntf_flags=NTF_TYPE|NTF_COPY) { return save_tinfo(this, til, 0, name, ntf_flags); }
4008
4011 tinfo_code_t create_forward_decl(til_t *til, type_t decl_type, const char *name, int ntf_flags=0)
4012 {
4013 create_typedef(til, "", decl_type, false);
4014 return set_named_type(til, name, ntf_flags);
4015 }
4016
4026 static tinfo_t get_stock(stock_type_id_t id) { tinfo_t t; get_stock_tinfo(&t, id); return t; }
4027
4030 inline bool convert_array_to_ptr();
4031
4038 {
4039 tinfo_t tif = get_ptrarr_object();
4040 if ( tif.empty() )
4041 return false;
4042 swap(tif);
4043 return true;
4044 }
4045
4049 uint64 read_bitfield_value(uint64 v, int bitoff) const { return read_tinfo_bitfield_value(typid, v, bitoff); }
4050 uint64 write_bitfield_value(uint64 dst, uint64 v, int bitoff) const { return write_tinfo_bitfield_value(typid, dst, v, bitoff); }
4052
4056 type_t get_modifiers() const { return typid & TYPE_MODIF_MASK; }
4057 void set_modifiers(type_t mod) { if ( !empty() ) typid = (typid & ~TYPE_MODIF_MASK) | (mod & TYPE_MODIF_MASK); }
4058 void set_const() { if ( !empty() ) typid |= BTM_CONST; }
4059 void set_volatile() { if ( !empty() ) typid |= BTM_VOLATILE; }
4060 // remove modifiers for trivial types, without resolving the type
4062 // remove modifiers from non-trivial types. for example, if the type was defined
4063 // as "const struct s { int field; }", the "const" modifier will be removed.
4064 // however, these function cannot remove modifiers from typedefs (ex: typedef const int constint)
4065 bool clr_const() { return bool(set_tinfo_property(this, STA_CLR_MODIFS, BTM_CONST)); }
4066 bool clr_volatile() { return bool(set_tinfo_property(this, STA_CLR_MODIFS, BTM_VOLATILE)); }
4067 bool clr_const_volatile() { return bool(set_tinfo_property(this, STA_CLR_MODIFS, BTM_CONST|BTM_VOLATILE)); }
4069
4072 {
4073 return tinfo_code_t(set_tinfo_property4(this, STA_ALIGNMENT, declalign, 0, 0, etf_flags));
4074 }
4075#ifndef NO_OBSOLETE_FUNCS
4076 DEPRECATED bool set_declalign(uchar declalign) { return set_tinfo_property(this, STA_DECLALIGN, declalign) != 0; }
4077#endif
4078
4080 bool change_sign(type_sign_t sign) { return set_tinfo_property(this, STA_TYPE_SIGN, sign) != 0; }
4081
4084 bool calc_udt_aligns(int sudt_flags=SUDT_GAPS)
4085 { return set_tinfo_property(this, STA_UDT_ALIGN, sudt_flags) != 0; }
4086
4090 {
4091 return set_tinfo_property(this, STA_UDT_METHODS, size_t(&methods)) != 0;
4092 }
4093
4096 tinfo_code_t set_type_cmt(const char *cmt, bool is_regcmt=false, uint etf_flags=0)
4097 {
4098 return tinfo_code_t(set_tinfo_property4(this, STA_COMMENT, size_t(cmt), is_regcmt, etf_flags, 0));
4099 }
4100
4104 {
4105 return uint32(get_tinfo_property(typid, GTA_ALIAS));
4106 }
4107 bool is_aliased() const { return get_alias_target() != 0; }
4108
4112 bool set_type_alias(uint32 dest_ord)
4113 {
4114 return set_tinfo_property4(this, STA_ALIAS, dest_ord, 0, 0, 0) != 0;
4115 }
4116
4123 {
4124 return tinfo_code_t(set_tinfo_property4(this, STA_SET_SDA, sda, 0, 0, etf_flags));
4125 }
4126
4134 tinfo_code_t set_udt_pack(int pack, uint etf_flags=0)
4135 {
4136 return tinfo_code_t(set_tinfo_property4(this, STA_SET_PACK, pack, 0, 0, etf_flags));
4137 }
4138
4144 tid_t get_udm_tid(size_t idx) const { return get_tinfo_property4(typid, GTA_UDM_TID, idx, 0, 0, 0); }
4145
4155 tinfo_code_t add_udm(const udm_t &udm, uint etf_flags=0, size_t times=1, ssize_t idx=-1)
4156 {
4157 return tinfo_code_t(set_tinfo_property4(this, STA_ADD_UDM, size_t(&udm), times, idx, etf_flags));
4158 }
4159
4176 inline tinfo_code_t add_udm(
4177 const char *name,
4178 const tinfo_t &type,
4179 uint64 offset=0,
4180 uint etf_flags=0,
4181 size_t times=1,
4182 ssize_t idx=-1);
4183
4201 inline tinfo_code_t add_udm(
4202 const char *name,
4203 type_t type,
4204 uint64 offset=0,
4205 uint etf_flags=0,
4206 size_t times=1,
4207 ssize_t idx=-1);
4208
4225 inline tinfo_code_t add_udm(
4226 const char *name,
4227 const char *type,
4228 uint64 offset=0,
4229 uint etf_flags=0,
4230 size_t times=1,
4231 ssize_t idx=-1);
4232
4234 tinfo_code_t del_udm(size_t index, uint etf_flags=0)
4235 {
4236 return del_udms(index, index+1, etf_flags);
4237 }
4238
4240 tinfo_code_t del_udms(size_t idx1, size_t idx2, uint etf_flags=0)
4241 {
4242 return tinfo_code_t(set_tinfo_property4(this, STA_DEL_UDMS, idx1, idx2, 0, etf_flags));
4243 }
4244
4248 tinfo_code_t rename_udm(size_t index, const char *name, uint etf_flags=0)
4249 {
4250 return tinfo_code_t(set_tinfo_property4(this, STA_UDM_NAME, index, size_t(name), 0, etf_flags));
4251 }
4252
4259 tinfo_code_t set_udm_type(size_t index, const tinfo_t &tif, uint etf_flags=0, const value_repr_t *repr=nullptr)
4260 {
4261 return tinfo_code_t(set_tinfo_property4(this, STA_UDM_TYPE, index, size_t(&tif), size_t(repr), etf_flags));
4262 }
4263
4266 tinfo_code_t set_udm_cmt(size_t index, const char *cmt, bool is_regcmt=false, uint etf_flags=0)
4267 {
4268 return tinfo_code_t(set_tinfo_property4(this, STA_UDM_CMT, index, size_t(cmt), is_regcmt, etf_flags));
4269 }
4270
4272 tinfo_code_t set_udm_repr(size_t index, const value_repr_t &repr, uint etf_flags=0)
4273 {
4274 return tinfo_code_t(set_tinfo_property4(this, STA_UDM_REPR, index, size_t(&repr), 0, etf_flags));
4275 }
4276
4279 bool is_udm_by_til(size_t idx) const { return get_tinfo_property4(typid, GTA_UDM_IS_BYTIL, idx, 0, 0, 0) != 0; }
4280
4285 tinfo_code_t set_udm_by_til(size_t idx, bool on=true, uint etf_flags=0) { return tinfo_code_t(set_tinfo_property4(this, STA_UDM_SET_BYTIL, idx, on, 0, etf_flags)); }
4286
4292 tinfo_code_t set_fixed_struct(bool on=true) { return tinfo_code_t(set_tinfo_property4(this, STA_FIXED_STRUCT, on, 0, 0, 0)); }
4293
4299 tinfo_code_t set_struct_size(size_t new_size) { return tinfo_code_t(set_tinfo_property4(this, STA_STRUCT_SIZE, new_size, 0, 0, 0)); }
4300
4323 tinfo_code_t expand_udt(size_t idx, adiff_t delta, uint etf_flags=0)
4324 {
4325 return tinfo_code_t(set_tinfo_property4(this, STA_EXPAND_UDT, idx, delta, 0, etf_flags));
4326 }
4327
4334 tinfo_code_t set_tuple(bool on=true) { return tinfo_code_t(set_tinfo_property4(this, STA_TUPLE, on, 0, 0, 0)); }
4335
4339 tinfo_code_t set_iface(bool on=true) { return tinfo_code_t(set_tinfo_property4(this, STA_IFACE, on, 0, 0, 0)); }
4340
4344 DEPRECATED bool get_func_frame(const func_t *pfn) { return pfn != nullptr && tinfo_get_func_frame_ea(this, pfn->start_ea); }
4345
4348 bool get_function_frame(ea_t func_ea) { return tinfo_get_func_frame_ea(this, func_ea); }
4349
4351 bool is_frame() const { return get_frame_func() != BADADDR; }
4352
4354 ea_t get_frame_func() const { return get_tinfo_property4(typid, GTA_FRAME_FUNC, 0, 0, 0, 0); }
4355
4367 sval_t *actval,
4368 const insn_t &insn,
4369 const op_t *x,
4370 sval_t v)
4371 {
4372 return ::get_frame_var(this, actval, insn, x, v);
4373 }
4374
4379 {
4380 return tinfo_code_t(set_tinfo_property4(this, STA_ENUM_WIDTH, nbytes, 0, 0, etf_flags));
4381 }
4382
4387 {
4388 return tinfo_code_t(set_tinfo_property4(this, STA_ENUM_SIGN, sign, 0, 0, etf_flags));
4389 }
4390
4414 tinfo_code_t set_enum_is_bitmask(bitmask_cvt_stance_t stance=ENUMBM_ON, uint etf_flags=0) { return tinfo_code_t(set_tinfo_property4(this, STA_BITMASK, stance, 0, 0, etf_flags)); }
4415
4419 tinfo_code_t set_enum_repr(const value_repr_t &repr, uint etf_flags=0) { return tinfo_code_t(set_tinfo_property4(this, STA_ENUM_REPR, size_t(&repr), 0, 0, etf_flags)); }
4420
4425 tinfo_code_t set_enum_radix(int radix, bool sign, uint etf_flags=0) { return tinfo_code_t(set_tinfo_property4(this, STA_ENUM_RADIX, radix, sign, 0, etf_flags)); }
4426
4443 tinfo_code_t add_edm(const edm_t &edm, bmask64_t bmask=DEFMASK64, uint etf_flags=0, ssize_t idx=-1)
4444 {
4445 return tinfo_code_t(set_tinfo_property4(this, STA_ADD_EDM, size_t(&edm), bmask, idx, etf_flags));
4446 }
4447
4457 inline tinfo_code_t add_edm(
4458 const char *name,
4459 uint64 value,
4460 bmask64_t bmask=DEFMASK64,
4461 uint etf_flags=0,
4462 ssize_t idx=-1);
4463
4474 tinfo_code_t del_edms(size_t idx1, size_t idx2, uint etf_flags=0)
4475 {
4476 return tinfo_code_t(set_tinfo_property4(this, STA_DEL_EDMS, idx1, idx2, 0, etf_flags));
4477 }
4478 tinfo_code_t del_edm(size_t idx, uint etf_flags=0) { return del_edms(idx, idx+1, etf_flags); }
4479
4485 inline tinfo_code_t del_edm(const char *name, uint etf_flags=0);
4486
4494 inline tinfo_code_t del_edm_by_value(uint64 value, uint etf_flags=0, bmask64_t bmask=DEFMASK64, uchar serial=0);
4495
4502 tinfo_code_t rename_edm(size_t idx, const char *name, uint etf_flags=0)
4503 {
4504 return tinfo_code_t(set_tinfo_property4(this, STA_EDM_NAME, idx, size_t(name), 0, etf_flags));
4505 }
4506
4512 tinfo_code_t set_edm_cmt(size_t idx, const char *cmt, uint etf_flags=0)
4513 {
4514 return tinfo_code_t(set_tinfo_property4(this, STA_EDM_CMT, idx, size_t(cmt), 0, etf_flags));
4515 }
4516
4523 tinfo_code_t edit_edm(size_t idx, uint64 value, bmask64_t bmask=DEFMASK64, uint etf_flags=0)
4524 {
4525 return tinfo_code_t(set_tinfo_property4(this, STA_EDIT_EDM, idx, value, bmask, etf_flags));
4526 }
4527
4534 tinfo_code_t rename_funcarg(size_t index, const char *name, uint etf_flags=0)
4535 {
4536 return tinfo_code_t(set_tinfo_property4(this, STA_FUNCARG_NAME, index, size_t(name), 0, etf_flags));
4537 }
4538
4544 tinfo_code_t set_funcarg_type(size_t index, const tinfo_t &tif, uint etf_flags=0)
4545 {
4546 return tinfo_code_t(set_tinfo_property4(this, STA_FUNCARG_TYPE, index, size_t(&tif), 0, etf_flags));
4547 }
4548
4554 {
4555 return tinfo_code_t(set_tinfo_property4(this, STA_FUNC_RETTYPE, size_t(&tif), 0, 0, etf_flags));
4556 }
4557
4563 tinfo_code_t del_funcargs(size_t idx1, size_t idx2, uint etf_flags=0)
4564 {
4565 return tinfo_code_t(set_tinfo_property4(this, STA_DEL_FUNCARGS, idx1, idx2, 0, etf_flags));
4566 }
4567 tinfo_code_t del_funcarg(size_t idx, uint etf_flags=0) { return del_funcargs(idx, idx+1, etf_flags); }
4568
4576 tinfo_code_t add_funcarg(const funcarg_t &farg, uint etf_flags=0, ssize_t idx=-1)
4577 {
4578 return tinfo_code_t(set_tinfo_property4(this, STA_ADD_FUNCARG, size_t(&farg), idx, 0, etf_flags));
4579 }
4580
4583 {
4584 return tinfo_code_t(set_tinfo_property4(this, STA_FUNC_CC, cc, 0, 0, etf_flags));
4585 }
4586
4592 tinfo_code_t set_funcarg_loc(size_t index, const argloc_t &argloc, uint etf_flags=0)
4593 {
4594 return tinfo_code_t(set_tinfo_property4(this, STA_FUNCARG_LOC, index, size_t(&argloc), 0, etf_flags));
4595 }
4596
4601 tinfo_code_t set_func_retloc(const argloc_t &argloc, uint etf_flags=0)
4602 {
4603 return tinfo_code_t(set_tinfo_property4(this, STA_FUNC_RETLOC, size_t(&argloc), 0, 0, etf_flags));
4604 }
4605
4607 { // simple comparison: good enough to organize std::map, etc
4608 // for this function "unsigned char" and "uchar" are different
4609 // for deeper comparison see compare_with()
4610 return lexcompare_tinfo(typid, r.typid, 0);
4611 }
4612
4615#define TCMP_EQUAL 0x0000
4616#define TCMP_IGNMODS 0x0001
4617#define TCMP_AUTOCAST 0x0002
4618#define TCMP_MANCAST 0x0004
4619#define TCMP_CALL 0x0008
4620#define TCMP_DELPTR 0x0010
4621#define TCMP_DECL 0x0020
4622#define TCMP_ANYBASE 0x0040
4623#define TCMP_SKIPTHIS 0x0080
4624#define TCMP_DEEP_UDT 0x0100
4627 bool compare_with(const tinfo_t &r, int tcflags=0) const { return compare_tinfo(typid, r.typid, tcflags); }
4628 bool equals_to(const tinfo_t &r) const { return compare_with(r, 0); }
4629 bool is_castable_to(const tinfo_t &target) const { return compare_with(target, TCMP_AUTOCAST); }
4630 bool is_manually_castable_to(const tinfo_t &target) const { return compare_with(target, TCMP_MANCAST); }
4631};
4634
4635//------------------------------------------------------------------------
4638{
4639 static constexpr uint16 SIMD_VARIADIC = 0xFFFF;
4640
4641 const char *name;
4652
4653 simd_info_t(const char *nm = nullptr, uint16 sz = 0, type_t memt = BTF_UNK)
4654 : name(nm), size(sz), memtype(memt) {}
4655
4656 bool is_variadic() const { return size == SIMD_VARIADIC; }
4657
4658 bool match_pattern(const simd_info_t *pattern)
4659 {
4660 if ( pattern == nullptr )
4661 return true;
4662 if ( pattern->size != 0 && pattern->size != size
4663 || pattern->name != nullptr && !streq(pattern->name, name)
4664 || !pattern->tif.empty() && !pattern->tif.compare_with(tif) )
4665 {
4666 return false;
4667 }
4668 if ( pattern->memtype == BTF_UNK || pattern->memtype == memtype )
4669 return true;
4670 return pattern->memtype == BTF_INT && is_type_int(memtype)
4671 || pattern->memtype == BTF_TBYTE
4672 && !is_variadic()
4674 }
4675 bool operator == (const simd_info_t &r) const
4676 {
4677 return size == r.size
4678 && memtype == r.memtype
4679 && tif == r.tif
4680 && (name == r.name
4681 || name != nullptr && r.name != nullptr && streq(name, r.name));
4682 }
4683 bool operator != (const simd_info_t &r) const { return !(*this == r); }
4684};
4686struct simd_info_vec_t : public qvector<simd_info_t> {};
4687
4688//------------------------------------------------------------------------
4690idaman callcnv_t ida_export guess_func_cc(
4691 const func_type_data_t &fti,
4692 int npurged,
4693 int cc_flags);
4695idaman bool ida_export dump_func_type_data(
4696 qstring *out,
4697 const func_type_data_t &fti,
4698 int praloc_bits);
4699idaman bool ida_export calc_retloc(func_type_data_t *fti);
4700idaman bool ida_export calc_arglocs(func_type_data_t *fti);
4701idaman bool ida_export calc_varglocs(
4702 func_type_data_t *fti,
4703 regobjs_t *regs,
4704 relobj_t *stkargs,
4705 int nfixed);
4706
4707//------------------------------------------------------------------------
4709struct ptr_type_data_t // #ptr
4710{
4718 tinfo_t c=tinfo_t(),
4719 uchar bps=0,
4720 tinfo_t p=tinfo_t(),
4721 int32 d=0)
4722 : closure(c), parent(p), delta(d), based_ptr_size(bps) {}
4724 void swap(ptr_type_data_t &r) { qswap(*this, r); }
4725 bool operator == (const ptr_type_data_t &r) const
4726 {
4727 return obj_type == r.obj_type
4728 && closure == r.closure
4730 }
4731 bool operator != (const ptr_type_data_t &r) const { return !(*this == r); }
4732 bool is_code_ptr() const { return obj_type.is_func(); }
4733 bool is_shifted() const { return delta != 0; }
4734};
4736
4737//------------------------------------------------------------------------
4739struct array_type_data_t // #array
4740{
4746 void swap(array_type_data_t &r) { qswap(*this, r); }
4747};
4749
4750//-------------------------------------------------------------------------
4753{
4762#define FAI_HIDDEN 0x0001
4763#define FAI_RETPTR 0x0002
4764#define FAI_STRUCT 0x0004
4765#define FAI_ARRAY 0x0008
4768#define FAI_UNUSED 0x0010
4769#define FAI_SWIFTSELF 0x0020
4773
4774 funcarg_t() = default;
4775
4777 bool is_swiftself() const { return (flags & FAI_SWIFTSELF) != 0; }
4778
4784 funcarg_t(const char *_name, const tinfo_t &_type, const argloc_t &_argloc=argloc_t())
4785 : argloc(_argloc), name(_name), type(_type)
4786 {
4787 }
4788
4795 funcarg_t(const char *_name, const type_t _type, const argloc_t &_argloc=argloc_t())
4796 : argloc(_argloc), name(_name), type(_type)
4797 {
4798 }
4799
4808 funcarg_t(const char *_name, const char *_type, const argloc_t &_argloc=argloc_t())
4809 : argloc(_argloc), name(_name)
4810 {
4811 type.parse(_type, nullptr, PT_SEMICOLON);
4812 }
4813
4814 bool operator == (const funcarg_t &r) const
4815 {
4816 return argloc == r.argloc
4817 && name == r.name
4818// && cmt == r.cmt
4819 && type == r.type;
4820 }
4821 bool operator != (const funcarg_t &r) const { return !(*this == r); }
4822
4823};
4826
4828struct func_type_data_t : public funcargvec_t // #func
4829{
4830 int flags = 0;
4834#define FTI_SPOILED 0x0001
4835#define FTI_NORET 0x0002
4836#define FTI_PURE 0x0004
4837#define FTI_HIGH 0x0008
4838#define FTI_STATIC 0x0010
4839#define FTI_VIRTUAL 0x0020
4840#define FTI_CALLTYPE 0x00C0
4841#define FTI_DEFCALL 0x0000
4842#define FTI_NEARCALL 0x0040
4843#define FTI_FARCALL 0x0080
4844#define FTI_INTCALL 0x00C0
4845#define FTI_ARGLOCS 0x0100
4847#define FTI_EXPLOCS 0x0200
4848#define FTI_CONST 0x0400
4849#define FTI_CTOR 0x0800
4850#define FTI_DTOR 0x1000
4851#define FTI_SYNCHRONIZED 0x2000
4852#define FTI_SWIFTASYNC 0x4000
4856#define FTI_SWIFTTHROWS 0x8000
4861#define FTI_ALL 0xFFFF
4863 callcnv_t _new_callcnv = 0;// Do not access directly, use get_cc/set_cc
4870 cm_t _old_cc = CM_CC_UNKNOWN; // calling convention, legacy codes. do not access
4874 void swap(func_type_data_t &r) { qswap(*this, r); }
4875 bool is_high() const { return (flags & FTI_HIGH) != 0; }
4876 bool is_noret() const { return (flags & FTI_NORET) != 0; }
4877 bool is_pure() const { return (flags & FTI_PURE) != 0; }
4878 bool is_static() const { return (flags & FTI_STATIC) != 0; }
4879 bool is_virtual() const { return (flags & FTI_VIRTUAL) != 0; }
4880 bool is_const() const { return (flags & FTI_CONST) != 0; }
4881 bool is_ctor() const { return (flags & FTI_CTOR) != 0; }
4882 bool is_dtor() const { return (flags & FTI_DTOR) != 0; }
4883 bool is_synchronized() const { return (flags & FTI_SYNCHRONIZED) != 0; }
4884 bool is_swiftasync() const { return (flags & FTI_SWIFTASYNC) != 0; }
4885 bool is_swiftthrows() const { return (flags & FTI_SWIFTTHROWS) != 0; }
4886 int get_call_method() const { return flags & FTI_CALLTYPE; }
4887 bool is_vararg_cc() const { return ::is_vararg_cc(get_cc()); }
4888 bool is_golang_cc() const { return ::is_golang_cc(get_cc()); }
4889 bool is_rust_cc() const { return ::is_rust_cc(get_cc()); }
4890 bool is_swift_cc() const { return ::is_swift_cc(get_cc()); }
4891 bool is_user_cc() const { return ::is_user_cc(get_explicit_cc()); }
4892
4895 callcnv_t guess_cc(int purged, int cc_flags) const
4896 {
4897 return guess_func_cc(*this, purged, cc_flags);
4898 }
4899#define CC_CDECL_OK 0x01
4900#define CC_ALLOW_ARGPERM 0x02
4901#define CC_ALLOW_REGHOLES 0x04
4902#define CC_HAS_ELLIPSIS 0x08
4903#define CC_GOLANG_OK 0x10
4904#define CC_RUST_OK 0x20
4907 bool dump(qstring *out, int praloc_bits=PRALOC_STKOFF) const
4908 {
4909 return dump_func_type_data(out, *this, praloc_bits);
4910 }
4911
4913 ssize_t find_argument(const char *name, size_t from=0, size_t to=size_t(-1)) const
4914 {
4915 if ( from < size() )
4916 {
4917 const_iterator e = begin() + qmin(size(), to);
4918 for ( const_iterator p=begin()+from; p != e; ++p )
4919 if ( p->name == name )
4920 return p - begin();
4921 }
4922 return -1;
4923 }
4924
4925};
4927
4928//-------------------------------------------------------------------------
4937
4938//-------------------------------------------------------------------------
4940struct edm_t // #edm
4941{
4943 qstring cmt; // repeatable comment
4945
4946 edm_t() = default;
4947
4953 edm_t(const char *_name, uint64 _value, const char *_cmt=nullptr)
4954 : name(_name), cmt(_cmt), value(_value) {}
4955
4956 // a enum constant must at least have a name
4957 bool empty() const { return name.empty(); }
4958
4959 bool operator == (const edm_t &r) const
4960 {
4961 return name == r.name
4962// && cmt == r.cmt
4963 && value == r.value;
4964 }
4965 bool operator != (const edm_t &r) const { return !(*this == r); }
4966 void swap(edm_t &r) { qswap(*this, r); }
4967 inline tid_t get_tid() const;
4968
4969
4970 DEFINE_MEMORY_ALLOCATION_FUNCS()
4971};
4978
4980struct enum_type_data_t : public edmvec_t // #enum
4981{
4989
4990 // How the enum members should be printed in the enum definition
4993 int get_enum_radix() const
4994 {
4995 switch ( bte & BTE_OUT_MASK )
4996 {
4997 case BTE_CHAR:
4998 return 1;
4999 case BTE_HEX:
5000 if ( (taenum_bits & TAENUM_BIN) != 0 )
5001 return 2;
5002 if ( (taenum_bits & TAENUM_OCT) != 0 )
5003 return 8;
5004 break;
5005 case BTE_SDEC:
5006 case BTE_UDEC:
5007 return 10;
5008 }
5009 return 16;
5010 }
5011 bool is_number_signed() const
5012 {
5013 return (bte & BTE_OUT_MASK) == BTE_SDEC
5014 || (bte & BTE_OUT_MASK) == BTE_HEX && (taenum_bits & TAENUM_NUMSIGN) != 0;
5015 }
5016
5019 void set_enum_radix(int radix, bool sign)
5020 {
5021 bte = (bte & ~BTE_OUT_MASK) | BTE_HEX;
5022 taenum_bits &= ~(TAENUM_BIN|TAENUM_OCT);
5023 setflag(taenum_bits, TAENUM_NUMSIGN, sign);
5024 switch ( radix )
5025 {
5026 case 1: bte |= BTE_CHAR; break;
5027 case 2: taenum_bits |= TAENUM_BIN; break;
5028 case 8: taenum_bits |= TAENUM_OCT; break;
5029 case 10: bte |= sign ? BTE_SDEC : BTE_UDEC; break;
5030 }
5031 }
5032 bool is_char() const { return (bte & BTE_OUT_MASK) == BTE_CHAR; }
5033 bool is_dec() const { return (bte & BTE_OUT_MASK) == BTE_SDEC; }
5034 bool is_hex() const { return get_enum_radix() == 16; }
5035 bool is_oct() const { return get_enum_radix() == 8; }
5036 bool is_bin() const { return get_enum_radix() == 2; }
5037 bool is_udec() const { return (bte & BTE_OUT_MASK) == BTE_UDEC; }
5038 bool is_shex() const { return is_number_signed() && is_hex(); }
5039 bool is_soct() const { return is_number_signed() && is_oct(); }
5040 bool is_sbin() const { return is_number_signed() && is_bin(); }
5041
5042 bool has_lzero() const { return (taenum_bits & TAENUM_LZERO) != 0; }
5043 void set_lzero(bool on) { setflag(taenum_bits, TAENUM_LZERO, on); }
5044
5046 bool store_64bit_values() const { return (taenum_bits & TAENUM_64BIT) != 0; }
5047
5049 bool is_bf() const { return (bte & BTE_BITMASK) != 0; }
5050
5052 int calc_nbytes() const
5053 {
5054 int emsize = bte & BTE_SIZE_MASK;
5055 return emsize != 0 ? 1 << (emsize-1) : inf_get_cc_size_e();
5056 }
5057
5059 {
5061 return false; // bad width
5062 int idb_width = 0;
5063 if ( nbytes != 0 )
5064 idb_width = log2ceil(nbytes) + 1;
5065 bte = (bte & ~BTE_SIZE_MASK) | idb_width;
5066 return true;
5067 }
5068
5074 bool get_constant_group(size_t *group_start_index, size_t *group_size, size_t idx) const
5075 {
5076 if ( !group_sizes.empty() )
5077 {
5078 size_t grp_start = 0;
5079 for ( auto grp_size : group_sizes )
5080 {
5081 if ( grp_start + grp_size > idx )
5082 {
5083 if ( group_start_index != nullptr )
5084 *group_start_index = grp_start;
5085 if ( group_size != nullptr )
5086 *group_size = grp_size;
5087 return true;
5088 }
5089 grp_start += grp_size;
5090 }
5091 }
5092 return false;
5093 }
5094
5100 bool is_group_mask_at(size_t idx) const
5101 {
5102 size_t grp_start;
5103 size_t grp_size;
5104 return get_constant_group(&grp_start, &grp_size, idx)
5105 && grp_start == idx && grp_size > 1;
5106 }
5107
5110 {
5111 if ( !group_sizes.empty() )
5112 {
5113 size_t sum = 0;
5114 for ( int s : group_sizes )
5115 {
5116 if ( s == 0 )
5117 return false;
5118 sum += s;
5119 }
5120 return sum == size();
5121 }
5122 return true;
5123 }
5124
5126 ssize_t find_member(const char *name, size_t from=0, size_t to=size_t(-1)) const
5127 {
5128 if ( from < size() )
5129 {
5130 const_iterator e = begin() + qmin(size(), to);
5131 for ( const_iterator p=begin()+from; p != e; ++p )
5132 if ( p->name == name )
5133 return p - begin();
5134 }
5135 return -1;
5136 }
5137
5139 ssize_t find_member(uint64 value, uchar serial, size_t from=0, size_t to=size_t(-1), uint64 vmask=uint64(-1)) const
5140 {
5141 if ( from < size() )
5142 {
5143 if ( vmask == uint64(-1) )
5144 vmask = calc_mask();
5145 value &= vmask;
5146 uint64 value_signed = value | ~vmask;
5147 const_iterator e = begin() + qmin(size(), to);
5148 for ( const_iterator p=begin()+from; p != e; ++p )
5149 if ( (p->value == value || p->value == value_signed) && serial-- == 0 )
5150 return p - begin();
5151 }
5152 return -1;
5153 }
5154
5156 void swap(enum_type_data_t &r) { qswap(*this, r); }
5157
5159 void add_constant(const char *name, uint64 value, const char *cmt=nullptr)
5160 {
5161 auto &c = push_back();
5162 c.name = name;
5163 c.value = value;
5164 c.cmt = cmt;
5165 }
5166
5169 tinfo_code_t get_value_repr(value_repr_t *repr) const { return enum_type_data_t__get_value_repr(this, repr); }
5170
5173 tinfo_code_t set_value_repr(const value_repr_t &repr) { return enum_type_data_t__set_value_repr(this, repr); }
5174
5176 uchar get_serial(size_t index) const
5177 {
5178 uchar serial = 0;
5179 if ( index < size() )
5180 {
5181 uint64 value = at(index).value;
5182 for ( size_t i=0; i < index; ++i )
5183 if ( at(i).value == value )
5184 serial++;
5185 }
5186 return serial;
5187 }
5188
5190 uchar get_max_serial(uint64 value) const { return enum_type_data_t__get_max_serial(this, value); }
5191
5192#ifndef SWIG
5194 int for_all_constants(std::function<int(size_t idx, size_t grp_start, int grp_size)> v) const
5195 {
5196 if ( !group_sizes.empty() )
5197 {
5198 auto gv = [v](size_t grp_start, int grp_size)
5199 {
5200 if ( grp_size == 1 )
5201 return v(grp_start, grp_start, grp_size);
5202 size_t grp_end = grp_start + grp_size;
5203 for ( size_t idx=grp_start+1; idx < grp_end; ++idx )
5204 {
5205 int code = v(idx, grp_start, grp_size);
5206 if ( code != 0 )
5207 return code;
5208 }
5209 return 0;
5210 };
5211 return for_all_groups(gv);
5212 }
5213 else
5214 {
5215 size_t sz = size();
5216 for ( size_t idx=0; idx < sz; ++idx )
5217 {
5218 int code = v(idx, 0, int(sz));
5219 if ( code != 0 )
5220 return code;
5221 }
5222 }
5223 return 0;
5224 }
5225
5227 int for_all_groups(std::function<int(size_t grp_start, int grp_size)> v, bool skip_trivial=false) const
5228 {
5229 if ( !group_sizes.empty() && is_valid_group_sizes() )
5230 {
5231 size_t grp_start = 0;
5232 for ( auto grp_size : group_sizes )
5233 {
5234 if ( !skip_trivial || grp_size != 1 )
5235 {
5236 int code = v(grp_start, grp_size);
5237 if ( code != 0 )
5238 return code;
5239 }
5240 grp_start += grp_size;
5241 }
5242 }
5243 return 0;
5244 }
5245#endif
5246
5247};
5249
5250//-------------------------------------------------------------------------
5253
5254//-------------------------------------------------------------------------
5256struct typedef_type_data_t // #typedef
5257{
5258 const til_t *til;
5259 union
5260 {
5261 const char *name;
5263 };
5265 bool resolve;
5266 typedef_type_data_t(const til_t *_til, const char *_name, bool _resolve=false)
5267 : is_ordref(false), resolve(_resolve)
5268 {
5269 name = _name;
5270 til = _til == nullptr ? get_idati() : _til;
5271 }
5272 typedef_type_data_t(const til_t *_til, uint32 ord, bool _resolve=false)
5273 : is_ordref(true), resolve(_resolve)
5274 {
5275 name = nullptr;
5276 ordinal = ord;
5277 til = _til == nullptr ? get_idati() : _til;
5278 }
5281};
5283
5284//-------------------------------------------------------------------------
5285// A high level variant of custom_data_type_ids_t
5291
5293struct value_repr_t // #repr
5294{
5296#define FRB_MASK 0xF
5297#define FRB_UNK 0x0
5298#define FRB_NUMB 0x1
5299#define FRB_NUMO 0x2
5300#define FRB_NUMH 0x3
5301#define FRB_NUMD 0x4
5302#define FRB_FLOAT 0x5
5304#define FRB_CHAR 0x6
5305#define FRB_SEG 0x7
5306#define FRB_ENUM 0x8
5307#define FRB_OFFSET 0x9
5308#define FRB_STRLIT 0xA
5309#define FRB_STROFF 0xB
5310#define FRB_CUSTOM 0xC
5311#define FRB_INVSIGN 0x0100
5312#define FRB_INVBITS 0x0200
5313#define FRB_SIGNED 0x0400
5314#define FRB_LZERO 0x0800
5315#define FRB_TABFORM 0x1000
5317 union
5318 {
5321 struct
5322 {
5325 };
5327 };
5330
5331public:
5332 void swap(value_repr_t &r) { ::qswap(*this, r); }
5334
5335 void clear() { bits = 0; }
5336
5337 bool empty() const { return bits == 0; }
5338 bool is_enum() const { return (bits & FRB_MASK) == FRB_ENUM; }
5339 bool is_offset() const { return (bits & FRB_MASK) == FRB_OFFSET; }
5340 bool is_strlit() const { return (bits & FRB_MASK) == FRB_STRLIT; }
5341 bool is_custom() const { return (bits & FRB_MASK) == FRB_CUSTOM; }
5342 bool is_stroff() const { return (bits & FRB_MASK) == FRB_STROFF; }
5343 bool is_typref() const { return is_enum() || is_stroff(); }
5344 bool is_signed() const { return (bits & FRB_SIGNED) != 0; }
5345 bool has_tabform() const { return (bits & FRB_TABFORM) != 0; }
5346 bool has_lzeroes() const { return (bits & FRB_LZERO) != 0; }
5347
5348 uint64 get_vtype() const { return bits & FRB_MASK; }
5349 void set_vtype(uint64 vt) { bits &= ~FRB_MASK; bits |= (vt & FRB_MASK); }
5350 void set_signed(bool on) { setflag(bits, FRB_SIGNED, on); }
5351 void set_tabform(bool on) { setflag(bits, FRB_TABFORM, on); }
5352 void set_lzeroes(bool on) { setflag(bits, FRB_LZERO, on); }
5353
5355 {
5356 ap = _ap;
5357 set_signed((ap.flags & AP_SIGNED) != 0);
5358 ap.flags &= ~AP_SIGNED;
5359 set_tabform(!ap.is_default());
5360 }
5362 {
5363 if ( _ap != nullptr )
5364 {
5365 if ( has_tabform() )
5366 *_ap = ap;
5367 setflag(_ap->flags, AP_SIGNED, is_signed());
5368 }
5369 }
5370
5371 bool from_opinfo(flags64_t flags, aflags_t afl, const opinfo_t *opinfo, const array_parameters_t *_ap)
5372 {
5373 return value_repr_t__from_opinfo(this, flags, afl, opinfo, _ap);
5374 }
5375 size_t print(qstring *result, bool colored=false) const
5376 {
5377 return value_repr_t__print_(this, result, colored);
5378 }
5379 bool parse_value_repr(const qstring &attr, type_t target_type=BTF_STRUCT)
5380 {
5381 return value_repr_t__parse_value_repr(this, attr, target_type);
5382 }
5383
5384#ifndef SWIG
5386#endif
5387};
5389
5390//-------------------------------------------------------------------------
5392struct udm_t // #udm
5393{
5400 int effalign = 0;
5403
5404 udm_t() = default;
5405
5415 udm_t(const char *_name, const tinfo_t &_type, uint64 _offset = 0)
5416 : offset(_offset), name(_name), type(_type)
5417 {
5418 size = _type.get_size() * 8;
5419 }
5420
5431 udm_t(const char *_name, const type_t _type, uint64 _offset = 0)
5432 : offset(_offset), name(_name)
5433 {
5434 if ( is_type_arithmetic(_type) )
5435 {
5436 type = tinfo_t(_type);
5437 size = type.get_size() * 8;
5438 }
5439 }
5440
5450 udm_t(const char *_name, const char *_type, uint64 _offset = 0)
5451 : offset(_offset), name(_name)
5452 {
5453 if ( type.parse(_type, nullptr, PT_SEMICOLON) )
5454 size = type.get_size() * 8;
5455 }
5456
5457 // a udt member must at least have a type
5458 bool empty() const { return type.empty(); }
5459
5460 bool is_bitfield() const { return type.is_decl_bitfield(); }
5461 bool is_zero_bitfield() const { return size == 0 && is_bitfield(); }
5462 bool is_unaligned() const { return (tafld_bits & TAFLD_UNALIGNED) != 0; }
5463 bool is_baseclass() const { return (tafld_bits & TAFLD_BASECLASS) != 0; }
5464 bool is_virtbase() const { return (tafld_bits & TAFLD_VIRTBASE) != 0; }
5465 bool is_vftable() const { return (tafld_bits & TAFLD_VFTABLE) != 0; }
5466 bool is_method() const { return (tafld_bits & TAFLD_METHOD) != 0; }
5467 bool is_gap() const { return (tafld_bits & TAFLD_GAP) != 0; }
5468 bool is_regcmt() const { return (tafld_bits & TAFLD_REGCMT) != 0; }
5469 bool is_retaddr() const { return (tafld_bits & TAFLD_FRAME_R) != 0; }
5470 bool is_savregs() const { return (tafld_bits & TAFLD_FRAME_S) != 0; }
5471 bool is_special_member() const { return is_retaddr() || is_savregs(); }
5472 bool is_by_til() const { return (tafld_bits & TAFLD_BYTIL) != 0; }
5473
5474 void set_unaligned(bool on=true) { setflag(tafld_bits, TAFLD_UNALIGNED, on); }
5475 void set_baseclass(bool on=true) { setflag(tafld_bits, TAFLD_BASECLASS, on); }
5476 void set_virtbase(bool on=true) { setflag(tafld_bits, TAFLD_VIRTBASE, on); }
5477 void set_vftable(bool on=true) { setflag(tafld_bits, TAFLD_VFTABLE, on); }
5478 void set_method(bool on=true) { setflag(tafld_bits, TAFLD_METHOD, on); }
5479 void set_regcmt(bool on=true) { setflag(tafld_bits, TAFLD_REGCMT, on); }
5480 void set_retaddr(bool on=true) { setflag(tafld_bits, TAFLD_FRAME_R, on); }
5481 void set_savregs(bool on=true) { setflag(tafld_bits, TAFLD_FRAME_S, on); }
5482 void set_by_til(bool on=true) { setflag(tafld_bits, TAFLD_BYTIL, on); }
5483 void clr_unaligned() { tafld_bits &= ~TAFLD_UNALIGNED; }
5484 void clr_baseclass() { tafld_bits &= ~TAFLD_BASECLASS; }
5485 void clr_virtbase() { tafld_bits &= ~TAFLD_VIRTBASE; }
5486 void clr_vftable() { tafld_bits &= ~TAFLD_VFTABLE; }
5487 void clr_method() { tafld_bits &= ~TAFLD_METHOD; }
5488 uint64 begin() const { return offset; }
5489 uint64 end() const { return offset + size; }
5490 bool operator < (const udm_t &r) const
5491 {
5492 return offset < r.offset;
5493 }
5494 bool operator == (const udm_t &r) const
5495 {
5496 return compare_with(r, 0);
5497 }
5498 bool compare_with(const udm_t &r, int tcflags) const
5499 {
5500 return udm_t__compare_with(this, r, tcflags);
5501 }
5502
5503 bool operator != (const udm_t &r) const { return !(*this == r); }
5504
5507
5508 // the user cannot enter anonymous fields in ida (they can come only from tils),
5509 // so we use the following trick: if the field type starts with $ and the name
5510 // with __, then we consider the field as anonymous
5511 bool is_anonymous_udm() const
5512 {
5513 return name[0] == '_' && name[1] == '_' && type.is_anonymous_udt();
5514 }
5515
5516 void set_value_repr(const value_repr_t &r) { repr = r; }
5517 bool can_be_dtor() const { return name[0] == '~'; }
5518 bool can_rename() const
5519 {
5520 return !is_gap() && !is_baseclass() && !can_be_dtor();
5521 }
5522
5523};
5525struct udtmembervec_t : public qvector<udm_t> {};
5526
5527struct udt_type_data_t : public udtmembervec_t // #udt
5528{
5529 static constexpr int VERSION = 1;
5530 size_t total_size = 0;
5531 size_t unpadded_size = 0;
5537 bool is_union = false;
5538
5539 void swap(udt_type_data_t &r) { qswap(*this, r); }
5541 bool is_unaligned() const { return (taudt_bits & TAUDT_UNALIGNED) != 0; }
5542 bool is_msstruct() const { return (taudt_bits & TAUDT_MSSTRUCT) != 0; }
5543 bool is_cppobj() const { return (taudt_bits & TAUDT_CPPOBJ) != 0; }
5544 bool is_vftable() const { return (taudt_bits & TAUDT_VFTABLE) != 0; }
5545 bool is_fixed() const { return (taudt_bits & TAUDT_FIXED) != 0; }
5546 bool is_tuple() const { return (taudt_bits & TAUDT_TUPLE) != 0; }
5547 bool is_iface() const { return (taudt_bits & TAUDT_IFACE) != 0; }
5548
5549 void set_vftable(bool on=true) { setflag(taudt_bits, TAUDT_VFTABLE, on); }
5550 void set_fixed(bool on=true) { setflag(taudt_bits, TAUDT_FIXED, on); }
5551 void set_tuple(bool on=true) { setflag(taudt_bits, TAUDT_TUPLE, on); }
5552 void set_iface(bool on=true) { setflag(taudt_bits, TAUDT_IFACE, on); }
5553
5554 bool is_last_baseclass(size_t idx) // we assume idx is valid
5555 {
5556 return at(idx).is_baseclass()
5557 && (idx+1 == size() || !at(idx+1).is_baseclass());
5558 }
5559
5568 udm_t &add_member(const char *_name, const tinfo_t &_type, uint64 _offset = 0)
5569 {
5570 udm_t &udm = push_back();
5571 udm.name = _name;
5572 udm.type = _type;
5573 udm.size = _type.get_size() * 8;
5574 udm.offset = _offset;
5575 return udm;
5576 }
5577
5581 ssize_t find_member(udm_t *pattern_udm, int strmem_flags) const { return udt_type_data_t__find_member(this, pattern_udm, strmem_flags); }
5582
5583 ssize_t find_member(const char *name) const
5584 {
5585 udm_t udm;
5586 udm.name = name;
5587 return find_member(&udm, STRMEM_NAME);
5588 }
5589
5590 ssize_t find_member(uint64 bit_offset) const
5591 {
5592 udm_t udm;
5593 udm.offset = bit_offset;
5594 return find_member(&udm, STRMEM_OFFSET);
5595 }
5596
5599 ssize_t get_best_fit_member(asize_t disp) const { return udt_type_data_t__get_best_fit_member(this, disp); }
5600
5605 inline ssize_t get_best_fit_member(udm_t *out, asize_t disp) const;
5606
5612 bool deduplicate_members() { return udt_type_data_t__deduplicate_members(this); }
5613
5614};
5616
5617// separator to construct full udm name
5618#define STRUC_SEPARATOR '.'
5619
5620// The type name of a virtual function table (__vftable) of a class is
5621// constructed by appending the following suffix to the class name.
5622// In the case of multiple inheritance we append the vft offset
5623// to the class name (with format %04X)
5624// Example: CLS_0024_vtbl is used for the vft located at the offset 0x24 of CLS
5625
5626#define VTBL_SUFFIX "_vtbl"
5627
5628// Name of type with virtual function table layout is
5629// constructed by appending the following suffix to the
5630// type name of a virtual function table.
5631// Example: CLS_0024_vtbl_layout
5632
5633#define VTBL_LAYOUT_SUFFIX "_layout"
5634
5635// The member name of a virtual function table
5636// Complex cases are not handled yet.
5637
5638#define VTBL_MEMNAME "__vftable"
5639
5640//--------------------------------------------------------------------------
5642inline bool stroff_as_size(int plen, const tinfo_t &tif, asize_t value)
5643{
5644 return plen == 1
5645 && value > 0
5646 && !tif.is_varstruct()
5647 && value == tif.get_size();
5648}
5649
5650//--------------------------------------------------------------------------
5652{
5657 virtual int idaapi visit_udm(
5658 tid_t tid,
5659 const tinfo_t *tif,
5660 const udt_type_data_t *udt,
5661 ssize_t idx) = 0;
5662 virtual ~udm_visitor_t() {}
5663};
5664
5665//--------------------------------------------------------------------------
5674idaman int ida_export visit_stroff_udms(
5675 udm_visitor_t &sfv,
5676 const tid_t *path,
5677 int plen,
5678 adiff_t *disp,
5679 bool appzero);
5680
5681//-------------------------------------------------------------------------
5683struct bitfield_type_data_t // #bitfield
5684{
5688 bitfield_type_data_t(uchar _nbytes=0, uchar _width=0, bool _is_unsigned=false)
5689 : nbytes(_nbytes), width(_width), is_unsigned(_is_unsigned)
5690 {
5691 }
5692 bool serialize(qtype *type, type_t mods) const;
5694 {
5695 if ( nbytes != r.nbytes )
5696 return nbytes > r.nbytes ? 1 : -1;
5697 if ( width != r.width )
5698 return width > r.width ? 1 : -1;
5699 if ( is_unsigned )
5700 {
5701 if ( !r.is_unsigned )
5702 return 1;
5703 }
5704 else
5705 {
5706 if ( r.is_unsigned )
5707 return -1;
5708 }
5709 return 0;
5710 }
5711 void swap(bitfield_type_data_t &r) { qswap(*this, r); }
5713 {
5714 if ( nbytes != 1 && nbytes != 2 && nbytes != 4 && nbytes != 8 )
5715 return false;
5716 if ( width > nbytes*8 )
5717 return false;
5718 return true;
5719 }
5720};
5722
5723
5724//-------------------------------------------------------------------------
5726inline THREAD_SAFE bool is_one_bit_mask(uval_t mask)
5727{
5728 return is_pow2(mask);
5729}
5730
5731//-------------------------------------------------------------------------
5733{
5735}
5736
5737//-------------------------------------------------------------------------
5739{
5741}
5742
5743//-------------------------------------------------------------------------
5745{
5747}
5748
5749//-------------------------------------------------------------------------
5750// return argument alignment (depends on ABI, CC and natural type alignment)
5751inline int get_arg_align(int type_align, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
5752{
5753 QASSERT(2858, is_pow2(type_align));
5754 if ( type_align > slotsize*2 )
5755 {
5756 if ( inf_huge_arg_align(cc) )
5757 return type_align;
5758 type_align = slotsize*2;
5759 }
5760 return type_align < slotsize
5761 ? inf_pack_stkargs(cc) ? type_align : slotsize
5762 : inf_big_arg_align(cc) ? type_align : slotsize;
5763}
5764
5765inline int get_arg_align(const tinfo_t &tif, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
5766{
5767 uint32 align = 0;
5768 tif.get_size(&align);
5769 return get_arg_align(align, slotsize, cc);
5770}
5771
5772//-------------------------------------------------------------------------
5773inline sval_t align_stkarg_up(sval_t spoff, int type_align, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
5774{
5775 uint32 align = get_arg_align(type_align, slotsize, cc);
5776 return align_up(spoff, align);
5777}
5778
5779inline sval_t align_stkarg_up(sval_t spoff, const tinfo_t &tif, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
5780{
5781 uint32 align = get_arg_align(tif, slotsize, cc);
5782 return align_up(spoff, align);
5783}
5784
5785inline bool argloc_t::has_reg() const
5786{
5787 if ( !is_scattered() )
5788 return is_reg();
5789 for ( const auto &part : scattered() )
5790 if ( part.is_reg() )
5791 return true;
5792 return false;
5793};
5794
5795inline bool argloc_t::has_stkoff() const
5796{
5797 if ( !is_scattered() )
5798 return is_stkoff();
5799 for ( const auto &part : scattered() )
5800 if ( part.is_stkoff() )
5801 return true;
5802 return false;
5803};
5804
5805inline bool argloc_t::in_stack() const
5806{
5807 if ( !is_scattered() )
5808 return is_stkoff();
5809 for ( const auto &part : scattered() )
5810 if ( !part.is_stkoff() )
5811 return false;
5812 return true;
5813}
5814
5815inline bool argloc_t::is_mixed_scattered() const
5816{
5817 if ( !is_scattered() )
5818 return false;
5819 bool reg_found = false;
5820 bool stkoff_found = false;
5821 for ( const auto &part : scattered() )
5822 {
5823 if ( part.is_reg() )
5824 reg_found = true;
5825 if ( part.is_stkoff() )
5826 stkoff_found = true;
5827 }
5828 return reg_found && stkoff_found;
5829}
5830
5831inline bool tinfo_t::get_named_type(
5832 const til_t *til,
5833 const char *name,
5834 type_t decl_type,
5835 bool resolve,
5836 bool try_ordinal)
5837{
5838 if ( name == nullptr )
5839 return false;
5840 typedef_type_data_t tp(til, name, resolve);
5842}
5843
5845 const til_t *til,
5846 uint32 ordinal,
5848 bool resolve)
5849{
5850 typedef_type_data_t tp(til, ordinal, resolve);
5851 return create_typedef(tp, decl_type, false);
5852}
5853
5855{
5857 p.is_union = is_union;
5858 return create_udt(p);
5859}
5860
5862{
5863 return create_udt(p, p.is_union ? BTF_UNION : BTF_STRUCT);
5864}
5865
5867{
5869 p.bte = BTE_ALWAYS | bte;
5870 return create_enum(p);
5871}
5872
5874 const tinfo_t &tif,
5875 uchar bps,
5877{
5878 ptr_type_data_t pi(tinfo_t(), bps);
5879 pi.obj_type = tif;
5880 return create_ptr(pi, decl_type);
5881}
5882
5884 const tinfo_t &tif,
5885 uint32 nelems,
5886 uint32 base,
5888{
5889 array_type_data_t ai(base, nelems);
5890 ai.elem_type = tif;
5891 return create_array(ai, decl_type);
5892}
5893
5895 uchar nbytes,
5896 uchar width,
5897 bool _is_unsigned,
5899{
5900 bitfield_type_data_t bi(nbytes, width, _is_unsigned);
5901 return create_bitfield(bi, decl_type);
5902}
5903
5905{
5906 bool ok = false;
5908 if ( get_array_details(&ai) )
5909 {
5910 ptr_type_data_t pi;
5911 pi.obj_type.swap(ai.elem_type);
5912 create_ptr(pi);
5913 ok = true;
5914 }
5915 return ok;
5916}
5917
5919 const char *name,
5920 const tinfo_t &type,
5921 uint64 offset,
5922 uint etf_flags,
5923 size_t times,
5924 ssize_t idx)
5925{
5926 return add_udm(udm_t(name, type, offset), etf_flags, times, idx);
5927}
5928
5930 const char *name,
5931 type_t type,
5932 uint64 offset,
5933 uint etf_flags,
5934 size_t times,
5935 ssize_t idx)
5936{
5937 return add_udm(udm_t(name, type, offset), etf_flags, times, idx);
5938}
5939
5941 const char *name,
5942 const char *type,
5943 uint64 offset,
5944 uint etf_flags,
5945 size_t times,
5946 ssize_t idx)
5947{
5948 return add_udm(udm_t(name, type, offset), etf_flags, times, idx);
5949}
5950
5951inline int tinfo_t::find_udm(uint64 offset, int strmem_flags) const
5952{
5953 udm_t udm;
5954 udm.offset = offset;
5955 return find_tinfo_udt_member(&udm, typid, STRMEM_OFFSET|strmem_flags);
5956}
5957
5958inline int tinfo_t::find_udm(const char *name, int strmem_flags) const
5959{
5960 udm_t udm;
5961 udm.name = name;
5962 return find_tinfo_udt_member(&udm, typid, STRMEM_NAME|strmem_flags);
5963}
5964
5965inline int tinfo_t::get_udm(udm_t *out, const char *name) const
5966{
5967 udm_t tmp;
5968 tmp.name = name;
5969 int rc = find_udm(&tmp, STRMEM_NAME);
5970 if ( rc >= 0 )
5971 out->swap(tmp);
5972 return rc;
5973}
5974
5975inline int tinfo_t::get_udm(udm_t *out, size_t index) const
5976{
5977 udm_t tmp;
5978 tmp.offset = index;
5979 int rc = find_udm(&tmp, STRMEM_INDEX);
5980 if ( rc >= 0 )
5981 out->swap(tmp);
5982 return rc;
5983
5984}
5985
5986inline int tinfo_t::get_udm_by_offset(udm_t *out, uint64 offset) const
5987{
5988 udm_t tmp;
5989 tmp.offset = offset;
5990 int rc = find_udm(&tmp, STRMEM_OFFSET);
5991 if ( rc >= 0 )
5992 out->swap(tmp);
5993 return rc;
5994}
5995
5997 const char *name,
5998 uint64 value,
5999 bmask64_t bmask,
6000 uint etf_flags,
6001 ssize_t idx)
6002{
6003 return add_edm(edm_t(name, value), bmask, etf_flags, idx);
6004}
6005
6007 const char *name,
6008 uint etf_flags)
6009{
6010 edm_t edm;
6011 ssize_t idx = get_edm(&edm, name);
6012 return idx < 0 ? TERR_NOT_FOUND : del_edm(idx, etf_flags);
6013}
6014
6016 uint64 value,
6017 uint etf_flags,
6018 bmask64_t bmask,
6019 uchar serial)
6020{
6021 edm_t edm;
6022 ssize_t idx = get_edm_by_value(&edm, value, bmask, serial);
6023 return idx < 0 ? TERR_NOT_FOUND : del_edm(idx, etf_flags);
6024}
6025
6027{
6029 if ( rc >= 0 )
6030 *out = at(rc);
6031 return rc;
6032}
6033
6038{
6039 tinfo_t r;
6040 r.typid = get_tinfo_property(tif.typid, tinfo_t::GTA_SAFE_PTR_OBJ);
6041 return r;
6042}
6043
6046{
6050 int flags = 0;
6054#define TVIS_TYPE 0x0001
6055#define TVIS_NAME 0x0002
6056#define TVIS_CMT 0x0004
6057#define TVIS_RPTCMT 0x0008
6059 void clear() { flags = 0; }
6060
6064 void set_new_type(const tinfo_t &t) { type = t; flags |= TVIS_TYPE; }
6065 void set_new_name(const qstring &n) { name = n; flags |= TVIS_NAME; }
6066 void set_new_cmt(const qstring &c, bool rptcmt)
6067 {
6068 cmt = c;
6069 flags |= TVIS_CMT;
6070 setflag(flags, TVIS_RPTCMT, rptcmt);
6071 }
6072
6073 bool has_type() const { return (flags & TVIS_TYPE) != 0; }
6074 bool has_name() const { return (flags & TVIS_NAME) != 0; }
6075 bool has_cmt() const { return (flags & TVIS_CMT) != 0; }
6076 bool is_rptcmt() const { return (flags & TVIS_RPTCMT) != 0; }
6077 bool has_info() const { return flags != 0; }
6078};
6079
6082{
6083 int state;
6087#define TVST_PRUNE 0x01
6088#define TVST_DEF 0x02
6089#define TVST_LEVEL 0x04 // has level member (internal use)
6091 int level; // recursion level (internal use)
6092 tinfo_visitor_t(int s=0) : state(s|TVST_LEVEL), level(0) {}
6093
6094 virtual ~tinfo_visitor_t() {}
6095
6102 virtual int idaapi visit_type(
6103 type_mods_t *out,
6104 const tinfo_t &tif,
6105 const char *name,
6106 const char *cmt) = 0;
6107
6109 void prune_now() { state |= TVST_PRUNE; }
6110
6112 int apply_to(const tinfo_t &tif, type_mods_t *out=nullptr, const char *name=nullptr, const char *cmt=nullptr)
6113 {
6114 return visit_subtypes(this, out, tif, name, cmt);
6115 }
6116};
6117
6118
6119//------------------------------------------------------------------------
6120// Definitions for packing/unpacking idc objects
6121
6124{
6128 size_t size() const { return value.size(); }
6129};
6132
6133struct regobjs_t : public regobjvec_t {};
6134
6135
6137
6139 idc_value_t *obj,
6140 const tinfo_t &tif,
6141 ea_t ea,
6142 const bytevec_t *off0, // if !nullptr: bytevec that represents object at 'ea'
6143 int pio_flags=0);
6144#define PIO_NOATTR_FAIL 0x0004
6145#define PIO_IGNORE_PTRS 0x0008
6146
6147
6149
6151 idc_value_t *obj,
6152 const tinfo_t &tif,
6153 const bytevec_t &bytes,
6154 int pio_flags=0);
6155
6156
6158
6159idaman error_t ida_export pack_idcobj_to_idb(
6160 const idc_value_t *obj,
6161 const tinfo_t &tif,
6162 ea_t ea,
6163 int pio_flags=0);
6164
6165
6168
6169idaman error_t ida_export pack_idcobj_to_bv(
6170 const idc_value_t *obj,
6171 const tinfo_t &tif,
6172 relobj_t *bytes,
6173 void *objoff, // nullptr - append object to 'bytes'
6174 // if not nullptr:
6175 // in: int32*: offset in 'bytes' for the object
6176 // -1 means 'do not store the object itself in bytes
6177 // store only pointed objects'
6178 // out: data for object (if *(int32*)objoff == -1)
6179 int pio_flags=0);
6180
6181
6184
6185idaman bool ida_export apply_tinfo_to_stkarg(
6186 const insn_t &insn,
6187 const op_t &x,
6188 uval_t v,
6189 const tinfo_t &tif,
6190 const char *name);
6191
6192//------------------------------------------------------------------------
6197{
6198 int src;
6199 int dst;
6202};
6203
6204//------------------------------------------------------------------------
6205// Helper struct for the processor modules: process call arguments
6207{
6208 size_t reserved = 0;
6209
6211
6213 virtual bool idaapi set_op_tinfo(
6214 const insn_t &insn,
6215 const op_t &x,
6216 const tinfo_t &tif,
6217 const char *name) = 0;
6218
6224 virtual bool idaapi is_stkarg_load(const insn_t &insn, int *src, int *dst) = 0;
6225
6227 virtual bool idaapi has_delay_slot(ea_t /*caller*/) { return false; }
6228
6231 inline void use_arg_tinfos(ea_t caller, func_type_data_t *fti, funcargvec_t *rargs);
6232};
6233
6235idaman void ida_export gen_use_arg_tinfos(
6236 struct argtinfo_helper_t *_this,
6237 ea_t caller,
6238 func_type_data_t *fti,
6239 funcargvec_t *rargs);
6240
6242 ea_t caller,
6243 func_type_data_t *fti,
6244 funcargvec_t *rargs)
6245{
6246 gen_use_arg_tinfos(this, caller, fti, rargs);
6247}
6248
6249//-------------------------------------------------------------------------
6250
6254
6255idaman bool ida_export func_has_stkframe_hole(ea_t ea, const func_type_data_t &fti);
6256
6257//-------------------------------------------------------------------------
6260{
6261public:
6263 virtual bool idaapi func_has_stkframe_hole(
6264 const tinfo_t &candidate,
6265 const func_type_data_t &candidate_data) = 0;
6266
6267 virtual int idaapi get_func_purged_bytes(
6268 const tinfo_t &candidate,
6269 const func_type_data_t &candidate_data) = 0;
6270};
6271
6272//-------------------------------------------------------------------------
6276{
6277 const tinfo_t &tif;
6278 ea_t ea;
6279 int purged_bytes;
6280
6281public:
6282 ida_lowertype_helper_t(const tinfo_t &_tif, ea_t _ea, int _pb)
6283 : tif(_tif), ea(_ea), purged_bytes(_pb) {}
6284
6285 virtual bool idaapi func_has_stkframe_hole(
6286 const tinfo_t &candidate,
6287 const func_type_data_t &candidate_data) override
6288 {
6289 return candidate == tif
6290 ? ::func_has_stkframe_hole(ea, candidate_data)
6291 : false;
6292 }
6293
6294 virtual int idaapi get_func_purged_bytes(
6295 const tinfo_t &candidate,
6296 const func_type_data_t &) override
6297 {
6298 return candidate == tif
6299 ? purged_bytes
6300 : -1;
6301 }
6302};
6303
6304//-------------------------------------------------------------------------
6319
6320idaman int ida_export lower_type(
6321 til_t *til,
6322 tinfo_t *tif,
6323 const char *name=nullptr,
6324 lowertype_helper_t *_helper=nullptr);
6325
6326
6333
6334idaman int ida_export replace_ordinal_typerefs(til_t *til, tinfo_t *tif);
6335
6336
6343
6347
6348idaman void ida_export begin_type_updating(update_type_t utp);
6349
6350
6352
6353idaman void ida_export end_type_updating(update_type_t utp);
6354
6355//-------------------------------------------------------------------------
6358
6372
6386idaman bool ida_export resolve_field_path(
6387 field_path_t *out,
6388 const til_t *til,
6389 const char *dotted_path);
6390
6391
6395idaman tid_t ida_export get_named_type_tid(const char *name);
6396
6397inline tid_t edm_t::get_tid() const { return get_named_type_tid(name.c_str()); }
6398
6399
6405idaman bool ida_export get_tid_name(qstring *out, tid_t tid);
6406
6407
6411idaman uint32 ida_export get_tid_ordinal(tid_t tid);
6412
6413
6418idaman ssize_t ida_export get_udm_by_fullname(udm_t *udm, const char *fullname);
6419
6420
6427idaman bool ida_export get_idainfo_by_udm(
6428 flags64_t *flags,
6429 opinfo_t *ti,
6430 const udm_t &udm,
6431 ea_t refinfo_ea=BADADDR);
6432
6433
6445 const char *enum_name,
6446 enum_type_data_t &ei,
6447 int enum_width,
6448 type_sign_t sign,
6449 bool convert_to_bitmask,
6450 const char *enum_cmt=nullptr)
6451{
6452 if ( sign == type_signed )
6453 ei.taenum_bits |= TAENUM_SIGNED;
6454 else if ( sign == type_unsigned )
6455 ei.taenum_bits |= TAENUM_UNSIGNED;
6456 ei.set_nbytes(enum_width);
6457
6458 tid_t tid = BADADDR;
6459 tinfo_t tif;
6460 if ( tif.create_enum(ei)
6461 && (enum_cmt == nullptr || tif.set_type_cmt(enum_cmt) == TERR_OK)
6462 && tif.set_enum_is_bitmask(convert_to_bitmask ? tinfo_t::ENUMBM_ON : tinfo_t::ENUMBM_OFF) == TERR_OK
6463 && tif.set_named_type(nullptr, enum_name, NTF_TYPE|NTF_REPLACE) == TERR_OK )
6464 {
6465 tid = get_named_type_tid(enum_name);
6466 }
6467 return tid;
6468}
6469
6471
6472//-------------------------------------------------------------------------
6475{
6476 int ptvf;
6480#define PTV_DEREF 0x0001
6483#define PTV_QUEST 0x0002
6484#define PTV_EMPTY 0x0004
6486#define PTV_CSTR 0x0008
6487#define PTV_EXPAND 0x0010
6490#define PTV_LZERO 0x0020
6491#define PTV_STPFLT 0x0040
6493#define PTV_SPACE 0x0080
6494#define PTV_DEBUG 0x0100
6495#define PTV_NOPTR 0x0200
6496#define PTV_NTOP 0x40000000
6497#define PTV_KEEP 0x80000000
6499 int radix;
6512
6514 : ptvf(PTV_EMPTY|PTV_CSTR|PTV_SPACE), radix(10), max_length(0),
6515 arrbase(0), arrnelems(0),
6516 margin(80), indent(2) {}
6517};
6518
6521{
6525 valinfo_t(argloc_t l=argloc_t(), const char *name=nullptr, const tinfo_t &tif=tinfo_t())
6526 : loc(l), label(name), type(tif) {}
6528 {
6529 loc.swap(r.loc);
6530 label.swap(r.label);
6531 type.swap(r.type);
6532 }
6533 DEFINE_MEMORY_ALLOCATION_FUNCS()
6534};
6536
6537
6542{
6543public:
6545 size_t length;
6548 int props;
6549#define VALSTR_OPEN 0x01
6550
6551 valstr_t() : length(0), members(nullptr), info(nullptr), props(0) {}
6552 ~valstr_t();
6553 DEFINE_MEMORY_ALLOCATION_FUNCS()
6554private:
6555 struct flatten_args_t
6556 {
6557 const valstr_t *may_not_collapse;
6558 int ptvf;
6559 int max_length;
6560 int margin;
6561 int indent;
6562 };
6563 friend struct valstr_sink_t;
6564 void update_length(int ptvf);
6565 void set_oneline(const char *line, int len)
6566 {
6567 oneline.append(line, len);
6568 length = oneline.length();
6569 }
6570 void consume_oneline(const qstring &line)
6571 {
6572 oneline.append(line);
6573 length = oneline.length();
6574 }
6575 bool append_char(char c, int max_length);
6576 bool convert_to_one_line(int ptvf, int max_length);
6577 bool flatten(const flatten_args_t &flargs, int level);
6578};
6581
6582struct valstrs_t : public valstrvec_t {};
6583
6585{
6586 delete members;
6587 delete info;
6588}
6589
6590
6599
6600idaman bool ida_export format_cdata(
6601 qstrvec_t *outvec,
6602 const idc_value_t &idc_value,
6603 const tinfo_t *tif,
6604 valstr_t *vtree=nullptr,
6605 const format_data_info_t *fdi=nullptr);
6606
6609{
6610 virtual ~text_sink_t() {}
6612 virtual int idaapi print(const char *str) = 0;
6613};
6614
6615
6623
6624idaman int ida_export print_cdata(
6625 text_sink_t &printer,
6626 const idc_value_t &idc_value,
6627 const tinfo_t *tif,
6628 const format_data_info_t *fdi=nullptr);
6629
6630//-------------------------------------------------------------------------
6633#define PDF_INCL_DEPS 0x01
6634#define PDF_DEF_FWD 0x02
6635#define PDF_DEF_BASE 0x04
6636#define PDF_HEADER_CMT 0x08
6637#define PDF_NO_ANON_NAME 0x10
6639
6641
6652
6653idaman int ida_export print_decls(
6654 text_sink_t &printer,
6655 const til_t *til,
6656 const ordvec_t *ordinals,
6657 uint32 pdf_flags);
6658
6659
6667
6668idaman int ida_export calc_number_of_children(
6669 const argloc_t &loc,
6670 const tinfo_t &tif,
6671 bool dont_deref_ptr=false);
6672
6673
6683
6684idaman bool ida_export get_enum_member_expr(
6685 qstring *buf,
6686 const tinfo_t &tif,
6687 int serial,
6688 uint64 value);
6689
6690
6691//-------------------------------------------------------------------------
6692// Dialogs to choose a symbol from a type library
6693//------------------------------------------------------------------------
6694
6697{
6698 const char *name;
6699 const til_t *til;
6700 til_symbol_t(const char *n = nullptr, const til_t *t = nullptr): name(n), til(t) {}
6701};
6703
6704
6707
6709{
6710 virtual bool idaapi should_display(
6711 const til_t *til,
6712 const char *name,
6713 const type_t *type,
6714 const p_list *fields) = 0;
6715 virtual ~predicate_t() {}
6716};
6717
6718
6726
6727idaman bool ida_export choose_named_type(
6728 til_symbol_t *out_sym,
6729 const til_t *root_til,
6730 const char *title,
6731 int ntf_flags,
6732 predicate_t *predicate=nullptr);
6733
6734
6735
6742using enum_type_visitor_t = std::function<ssize_t(const struct enum_type_data_t &ei, size_t idx, uint64 value, uint64 bmask)>;
6743
6760idaman ssize_t ida_export visit_edms(
6761 const tinfo_t &tif,
6762 uint64 value,
6763 int nbytes,
6764 uchar serial,
6765 const enum_type_visitor_t &visitor);
6766
6767//-------------------------------------------------------------------------
6769{
6770 if ( PH.ti() )
6771 return notify(ev_equal_reglocs, &a1, &a2);
6772 else
6773 return a1.compare(a2);
6774}
6775
6776//-------------------------------------------------------------------------
6778 qstring *outbuf,
6779 const char *name,
6780 bool mangle,
6781 callcnv_t cc,
6782 const tinfo_t &type)
6783{
6784 ssize_t code = notify(ev_decorate_name, outbuf, name, mangle, cc, &type);
6785 if ( code == 0 )
6786 code = gen_decorate_name(outbuf, name, mangle, cc, &type);
6787 return code;
6788}
6789
6790//-------------------------------------------------------------------------
6791inline bool calc_retloc(argloc_t *retloc, const tinfo_t &rettype, callcnv_t cc)
6792{
6793 func_type_data_t fti;
6794 fti.set_cc(cc);
6795 fti.rettype = rettype;
6796 if ( !calc_retloc(&fti) )
6797 return false;
6798 retloc->swap(fti.retloc);
6799 return true;
6800}
6801
6802//-------------------------------------------------------------------------
6803// this structure is used to hold context data for the 'types' view
6805{
6806 size_t cb = sizeof(til_type_ref_t);
6807 tinfo_t tif; //< type info, !empty() during runtime
6808 tif_cursor_t cursor = TIF_CURSOR_HEADER; //< 'pointer' inside a type
6809 uint32 ordinal = 0; //< cached value of tif.get_ordinal()
6810 bool is_writable = false; //< can we modify the type? (either in a RW til, or writable backend)
6811 bool is_detached = false; //< type is not backed by a backend that will cause views to be updated automatically
6812 bool is_forward = false; //< is the type a forward declaration?
6813 type_t kind = BT_UNK; //< one of BTF_TYPEDEF, BTF_STRUCT, BTF_UNION, BTF_ENUM, BT_FUNC
6814 ssize_t memidx = -1; //< index of the current BTF_STRUCT, BTF_UNION, BTF_ENUM member or BT_FUNC argument
6815 size_t nmembers = 0; //< number of members in the BTF_STRUCT, BTF_UNION, BTF_ENUM or number of arguments in the BT_FUNC
6816
6819 size_t total_size = 0;
6820 size_t unpadded_size = 0;
6822 uint64 bucket_start = uint64(-1); //< bucket offset (equal to 'offset' except for bitfields)
6823 int bf_bitoff = -1; //< for bitfields, bit offset from bucket_start
6824 uint64 offset = uint64(-1); //< the current offset (regardless if
6825 //< we have a defined member at the current
6826 //< offset or not)
6827
6830
6832 const funcarg_t *fa = nullptr;
6833
6834 void clear() { *this = til_type_ref_t(); }
6835 bool on_member() const { return memidx != -1; }
6836 bool is_typedef() const { return kind == BTF_TYPEDEF; }
6837 bool is_struct() const { return kind == BTF_STRUCT; }
6838 bool is_union() const { return kind == BTF_UNION; }
6839 bool is_enum() const { return kind == BTF_ENUM; }
6840 bool is_func() const { return kind == BT_FUNC; }
6841 bool is_udt() const { return kind == BTF_STRUCT || kind == BTF_UNION; }
6842};
6843
6844
6845#ifndef NO_OBSOLETE_FUNCS
6846idaman DEPRECATED uint32 ida_export choose_local_tinfo(const til_t *, const char *, til_tinfo_predicate_t *, uint32, void *); // Use choose_til_type instead
6847idaman DEPRECATED uint32 ida_export choose_local_tinfo_and_delta(int32 *, const til_t *, const char *, til_tinfo_predicate_t *, uint32, void *); // Use choose_til_type_and_delta instead
6848idaman DEPRECATED void ida_export build_anon_type_name(qstring *buf, const type_t *type, const p_list *fields);
6849#endif
6850
6851#endif // _TYPEINF_HPP
iterator begin(void)
Get a pointer to the beginning of the qstring.
Definition pro.h:3253
Describes an argument location.
Definition typeinf.hpp:1105
rrel_t * rrel
Definition typeinf.hpp:1115
uint32 reginfo
Definition typeinf.hpp:1114
scattered_aloc_t * dist
Definition typeinf.hpp:1116
void * custom
Definition typeinf.hpp:1117
biggest_t biggest
Definition typeinf.hpp:1118
size_t biggest_t
Definition typeinf.hpp:1107
sval_t sval
Definition typeinf.hpp:1113
Vector of bytes (use for dynamic memory)
Definition pro.h:3850
Register allocation calling convention.
Definition typeinf.hpp:1743
callregs_t(callcnv_t cc)
Constructor - initialize with the given request (see init_regs())
Definition typeinf.hpp:1782
reg_kind_t
Init registers (sequential)
Definition typeinf.hpp:1819
@ FPREGS
Definition typeinf.hpp:1819
@ GPREGS
Definition typeinf.hpp:1819
void swap(callregs_t &r)
swap two instances
Definition typeinf.hpp:1785
argreg_policy_t policy
argument policy
Definition typeinf.hpp:1773
static int findreg(const intvec_t &regs, int r)
Definition typeinf.hpp:1849
bool reginds(int *gp_ind, int *fp_ind, int r) const
Get register indexes within GP/FP arrays.
Definition typeinf.hpp:1857
void reset()
Set policy and registers to invalid values.
Definition typeinf.hpp:1836
void set_registers(reg_kind_t kind, int first_reg, int last_reg)
Definition typeinf.hpp:1828
bool init_regs(callcnv_t cc)
Init policy & registers for given CC.
Definition typeinf.hpp:1794
void set(argreg_policy_t _policy, const int *gprs, const int *fprs)
Init policy & registers (arrays are -1-terminated)
Definition typeinf.hpp:1810
static int regcount(callcnv_t cc)
Get max number of registers may be used in a function call.
Definition typeinf.hpp:1842
intvec_t fpregs
array of fp registers (floating point)
Definition typeinf.hpp:1776
bool findregs(int *gp_ind, int *fp_ind, int r, const intvec_t &gprs, const intvec_t &fprs) const
Search for register r in gprs and fprs.
Definition typeinf.hpp:1865
int nregs
max number of registers that can be used in a call
Definition typeinf.hpp:1774
intvec_t gpregs
array of gp registers (general purpose)
Definition typeinf.hpp:1775
callregs_t()
Constructor.
Definition typeinf.hpp:1779
void append_registers(reg_kind_t kind, int first_reg, int last_reg)
Definition typeinf.hpp:1820
bool by_slots() const
Definition typeinf.hpp:1807
A function is a set of continuous ranges of addresses with characteristics.
Definition funcs.hpp:106
virtual int idaapi get_func_purged_bytes(const tinfo_t &candidate, const func_type_data_t &) override
Definition typeinf.hpp:6294
virtual bool idaapi func_has_stkframe_hole(const tinfo_t &candidate, const func_type_data_t &candidate_data) override
Definition typeinf.hpp:6285
ida_lowertype_helper_t(const tinfo_t &_tif, ea_t _ea, int _pb)
Definition typeinf.hpp:6282
Class to hold idc values.
Definition expr.hpp:315
Interface class - see ida_lowertype_helper_t.
Definition typeinf.hpp:6260
virtual int idaapi get_func_purged_bytes(const tinfo_t &candidate, const func_type_data_t &candidate_data)=0
virtual bool idaapi func_has_stkframe_hole(const tinfo_t &candidate, const func_type_data_t &candidate_data)=0
virtual ~lowertype_helper_t()
Definition typeinf.hpp:6262
Microcode of one basic block.
Definition hexrays.hpp:4329
Operand of an instruction.
Definition ua.hpp:170
Reimplementation of vector class from STL.
Definition pro.h:2262
void clear(void)
Destroy all elements and free memory.
Definition pro.h:2510
DEFINE_MEMORY_ALLOCATION_FUNCS() void push_back(const argpart_t &x)
Definition pro.h:2420
const int * const_iterator
Definition pro.h:2681
iterator end(void)
Get an iterator that points to the end of the qvector (NOT the last element)
Definition pro.h:2684
void resize(size_t _newsize, const T &x)
Resize to the given size.
Definition pro.h:2540
const edm_t & at(size_t _idx) const
Definition pro.h:2498
iterator find(const T &x)
Find an element in the qvector.
Definition pro.h:2777
qvector(void)
Definition pro.h:2374
edm_t & push_back(void)
Definition pro.h:2473
iterator begin(void)
Get an iterator that points to the first element in the qvector.
Definition pro.h:2683
void push_back(T &&x)
Append a new element to the end the qvector with a move semantics.
Definition pro.h:2432
size_t size(void) const
Get the number of elements in the qvector.
Definition pro.h:2494
ssize_t index(const edm_t &x) const
Definition pro.h:2797
Used to manage arguments that are described by multiple locations (also see ALOC_DIST)
Definition typeinf.hpp:1347
Primary mechanism for managing type information.
Definition typeinf.hpp:3077
bool remove_ptr_or_array()
Replace the current type with the ptr obj or array element.
Definition typeinf.hpp:4037
tinfo_code_t get_edm(edm_t *edm, size_t idx) const
Get enum member by its index.
Definition typeinf.hpp:3851
type_t get_forward_type() const
Get type of a forward declaration.
Definition typeinf.hpp:3453
THREAD_SAFE bool is_decl_udt() const
is_type_struni(get_decltype())
Definition typeinf.hpp:3484
DECLARE_COMPARISONS(tinfo_t)
Definition typeinf.hpp:4606
THREAD_SAFE bool is_decl_uint128() const
is_type_uint128(get_decltype())
Definition typeinf.hpp:3498
bool is_int64() const
is_type_int64(get_realtype())
Definition typeinf.hpp:3525
THREAD_SAFE bool is_decl_floating() const
is_type_floating(get_decltype())
Definition typeinf.hpp:3503
tinfo_code_t set_udm_by_til(size_t idx, bool on=true, uint etf_flags=0)
The member is created due to the type system.
Definition typeinf.hpp:4285
bool is_scalar() const
Does the type represent a single number?
Definition typeinf.hpp:3549
THREAD_SAFE bool is_decl_tbyte() const
is_type_tbyte(get_decltype())
Definition typeinf.hpp:3502
tinfo_code_t set_udm_repr(size_t index, const value_repr_t &repr, uint etf_flags=0)
Set the representation of a structure/union member.
Definition typeinf.hpp:4272
void create_typedef(const til_t *til, uint ord, type_t decl_type=BTF_TYPEDEF)
Definition typeinf.hpp:3948
bool get_array_details(array_type_data_t *ai) const
Get the array specific info.
Definition typeinf.hpp:3558
bool create_typedef(const typedef_type_data_t &p, type_t decl_type=BTF_TYPEDEF, bool try_ordinal=true)
Definition typeinf.hpp:3937
tinfo_code_t set_enum_radix(int radix, bool sign, uint etf_flags=0)
Set enum radix to display constants.
Definition typeinf.hpp:4425
tinfo_code_t set_enum_width(int nbytes, uint etf_flags=0)
Set the width of enum base type.
Definition typeinf.hpp:4378
tinfo_t get_rettype() const
BT_FUNC or BT_PTR BT_FUNC: Get the function's return type
Definition typeinf.hpp:3640
DEPRECATED bool set_declalign(uchar declalign)
Definition typeinf.hpp:4076
bool is_fixed_struct() const
Is a structure with fixed offsets?
Definition typeinf.hpp:3768
int get_type_cmt(qstring *out) const
Get type comment.
Definition typeinf.hpp:3465
tinfo_code_t set_named_type(til_t *til, const char *name, int ntf_flags=0)
Definition typeinf.hpp:4002
bool get_numbered_type(uint32 ordinal, type_t decl_type=BTF_TYPEDEF, bool resolve=true)
Definition typeinf.hpp:3267
bool has_vftable() const
Has a vftable?
Definition typeinf.hpp:3806
bool set_attrs(type_attrs_t *tav)
Set type attributes.
Definition typeinf.hpp:3922
tinfo_t get_onemember_type() const
For objects consisting of one member entirely: return type of the member.
Definition typeinf.hpp:3869
bool del_attr(const qstring &key, bool make_copy=true)
Del a type attribute. typerefs cannot be modified by this function.
Definition typeinf.hpp:3931
bool get_bit_buckets(range64vec_t *buckets) const
BT_STRUCT: get bit buckets Bit buckets are used to layout bitfields
Definition typeinf.hpp:3664
uint32 get_alignment() const
Get type alignment This function returns the effective type alignment.
Definition typeinf.hpp:3358
tinfo_code_t set_udt_alignment(int sda, uint etf_flags=0)
Set declared structure alignment (sda) This alignment supersedes the alignment returned by get_declal...
Definition typeinf.hpp:4122
tinfo_t get_innermost_member_type(uint64 bitoffset, uint64 *out_bitoffset=nullptr) const
Get the innermost member type at the given offset.
Definition typeinf.hpp:3884
size_t get_enum_nmembers() const
Get number of enum members.
Definition typeinf.hpp:3813
bool get_named_type(const char *name, type_t decl_type=BTF_TYPEDEF, bool resolve=true, bool try_ordinal=true)
Definition typeinf.hpp:3249
THREAD_SAFE bool is_decl_complex() const
is_type_complex(get_decltype())
Definition typeinf.hpp:3479
uint32 get_final_ordinal() const
Get final type ordinal (0 if none)
Definition typeinf.hpp:3436
bool create_udt(bool is_union=false)
Create an empty structure/union.
Definition typeinf.hpp:5854
THREAD_SAFE bool is_decl_uchar() const
is_type_uchar(get_decltype())
Definition typeinf.hpp:3494
tinfo_code_t set_enum_sign(type_sign_t sign, uint etf_flags=0)
Set enum sign.
Definition typeinf.hpp:4386
bool get_type_name(qstring *out) const
Does a type refer to a name?
Definition typeinf.hpp:3388
bool is_one_fpval() const
Floating value or an object consisting of one floating member entirely.
Definition typeinf.hpp:3793
THREAD_SAFE bool is_decl_uint32() const
is_type_uint32(get_decltype())
Definition typeinf.hpp:3496
bool is_ext_arithmetic() const
is_type_ext_arithmetic(get_realtype())
Definition typeinf.hpp:3547
type_sign_t get_sign() const
Get type sign.
Definition typeinf.hpp:3366
bool is_volatile() const
is_type_volatile(get_realtype())
Definition typeinf.hpp:3510
THREAD_SAFE bool is_decl_ldouble() const
is_type_ldouble(get_decltype())
Definition typeinf.hpp:3499
static tinfo_t get_stock(stock_type_id_t id)
Get stock type information.
Definition typeinf.hpp:4026
void set_modifiers(type_t mod)
Definition typeinf.hpp:4057
uint32 get_alias_target() const
Get type alias If the type has no alias, return 0.
Definition typeinf.hpp:4103
bool deserialize(const til_t *til, const type_t **ptype, const p_list **pfields=nullptr, const p_list **pfldcmts=nullptr, const char *cmt=nullptr)
Deserialize a type string into a tinfo_t object.
Definition typeinf.hpp:3287
ssize_t get_udm_by_tid(udm_t *udm, tid_t tid)
Retrive tinfo using type TID or struct/enum member MID.
Definition typeinf.hpp:3984
bool is_ptr_or_array() const
is_type_ptr_or_array(get_realtype())
Definition typeinf.hpp:3542
bool is_vararg_cc() const
is_vararg_cc(get_cc())
Definition typeinf.hpp:3648
tinfo_code_t set_type_alignment(uchar declalign, uint etf_flags=0)
Set type alignment.
Definition typeinf.hpp:4071
bool is_uint() const
is_type_uint(get_realtype())
Definition typeinf.hpp:3530
bool get_enum_details(enum_type_data_t *ei) const
Get the enum specific info.
Definition typeinf.hpp:3564
tinfo_t get_ptrarr_object() const
BT_PTR & BT_ARRAY: get the pointed object or array element.
Definition typeinf.hpp:3606
tinfo_code_t save_type(int ntf_flags=NTF_TYPE|NTF_REPLACE)
Definition typeinf.hpp:4005
bool is_user_cc() const
is_user_cc(get_cc())
Definition typeinf.hpp:3647
til_t * get_til() const
Get the type library for tinfo_t.
Definition typeinf.hpp:3439
uchar get_declalign() const
Get declared alignment of the type.
Definition typeinf.hpp:3375
bool is_tuple() const
Is a tuple?
Definition typeinf.hpp:3771
bool is_varmember() const
Can the type be of a variable struct member?
Definition typeinf.hpp:3599
THREAD_SAFE bool is_decl_union() const
is_type_union(get_decltype())
Definition typeinf.hpp:3483
tinfo_code_t set_func_cc(callcnv_t cc, uint etf_flags=0)
Set function calling convention.
Definition typeinf.hpp:4582
bool get_attrs(type_attrs_t *tav, bool all_attrs=false) const
Get type attributes (all_attrs: include attributes of referenced types, if any)
Definition typeinf.hpp:3914
int get_udt_nmembers() const
Get number of udt members. -1-error.
Definition typeinf.hpp:3744
bool is_float() const
is_type_float(get_realtype())
Definition typeinf.hpp:3538
ssize_t get_edm_by_value(edm_t *out, uint64 value, bmask64_t bmask=DEFMASK64, uchar serial=0) const
Get enum member by its value.
Definition typeinf.hpp:3859
const char * dstr() const
Function to facilitate debugging.
Definition typeinf.hpp:3911
bool get_nice_type_name(qstring *out) const
Get the beautified type name.
Definition typeinf.hpp:3392
bool is_empty_enum() const
Is an empty enum? (has no constants)
Definition typeinf.hpp:3816
ssize_t get_by_edm_name(const char *mname, const til_t *til=nullptr)
Retrieve enum tinfo using enum member name.
Definition typeinf.hpp:3994
bool is_arithmetic() const
is_type_arithmetic(get_realtype())
Definition typeinf.hpp:3546
THREAD_SAFE bool is_decl_char() const
is_type_char(get_decltype())
Definition typeinf.hpp:3492
bool is_floating() const
is_type_floating(get_realtype())
Definition typeinf.hpp:3545
bool clr_const()
Definition typeinf.hpp:4065
tinfo_code_t set_funcarg_type(size_t index, const tinfo_t &tif, uint etf_flags=0)
Set type of a function argument.
Definition typeinf.hpp:4544
THREAD_SAFE bool is_decl_enum() const
is_type_enum(get_decltype())
Definition typeinf.hpp:3485
tid_t get_tid() const
Get the type tid Each type in the local type library has a so-called tid associated with it.
Definition typeinf.hpp:3422
bool is_char() const
is_type_char(get_realtype())
Definition typeinf.hpp:3529
void set_const()
Definition typeinf.hpp:4058
tinfo_t(const tinfo_t &r)
Constructor.
Definition typeinf.hpp:3220
THREAD_SAFE bool is_decl_uint() const
is_type_uint(get_decltype())
Definition typeinf.hpp:3493
bool create_simple_type(type_t decl_type)
Definition typeinf.hpp:3933
tinfo_code_t set_enum_repr(const value_repr_t &repr, uint etf_flags=0)
Set the representation of enum members.
Definition typeinf.hpp:4419
bool is_int128() const
is_type_int128(get_realtype())
Definition typeinf.hpp:3524
bool calc_udt_aligns(int sudt_flags=SUDT_GAPS)
Calculate the udt alignments using the field offsets/sizes and the total udt size This function does ...
Definition typeinf.hpp:4084
bool is_unaligned_struct() const
Is an unaligned struct.
Definition typeinf.hpp:3756
tinfo_code_t rename_funcarg(size_t index, const char *name, uint etf_flags=0)
Rename a function argument.
Definition typeinf.hpp:4534
THREAD_SAFE bool is_decl_unknown() const
is_type_unknown(get_decltype())
Definition typeinf.hpp:3474
THREAD_SAFE bool is_decl_int64() const
is_type_int64(get_decltype())
Definition typeinf.hpp:3488
THREAD_SAFE bool is_decl_int128() const
is_type_int128(get_decltype())
Definition typeinf.hpp:3487
bool is_int16() const
is_type_int16(get_realtype())
Definition typeinf.hpp:3527
bool set_type_alias(uint32 dest_ord)
Set type alias Redirects all references to source type to the destination type.
Definition typeinf.hpp:4112
tinfo_t get_pointed_object() const
BT_PTR: get type of pointed object.
Definition typeinf.hpp:3611
tinfo_code_t del_udms(size_t idx1, size_t idx2, uint etf_flags=0)
Delete structure/union members in the range [idx1, idx2)
Definition typeinf.hpp:4240
bool is_forward_struct() const
Definition typeinf.hpp:3454
bool get_function_frame(ea_t func_ea)
Create a tinfo_t object for the function frame.
Definition typeinf.hpp:4348
const char type_t decl_type
Definition typeinf.hpp:3245
bool is_small_udt() const
Is a small udt? (can fit a register or a pair of registers)
Definition typeinf.hpp:3750
bool is_unsigned() const
Is this an unsigned type?
Definition typeinf.hpp:3372
friend tinfo_t remove_pointer(const tinfo_t &tif)
BT_PTR: If the current type is a pointer, return the pointed object.
Definition typeinf.hpp:6037
bool print(qstring *out, const char *name=nullptr, int prtype_flags=PRTYPE_1LINE, int indent=0, int cmtindent=0, const char *prefix=nullptr, const char *cmt=nullptr) const
Get a C-like string representation of the type.
Definition typeinf.hpp:3898
tinfo_t(type_t decl_type)
Constructor - can only be used to initialize simple types!
Definition typeinf.hpp:3211
tinfo_code_t create_forward_decl(til_t *til, type_t decl_type, const char *name, int ntf_flags=0)
Create a forward declaration.
Definition typeinf.hpp:4011
tinfo_code_t set_numbered_type(til_t *til, uint32 ord, int ntf_flags=0, const char *name=nullptr)
Definition typeinf.hpp:4004
bool is_cpp_struct() const
Is a c++ object, not simple pod type.
Definition typeinf.hpp:3762
bool is_varstruct() const
Is a variable-size structure?
Definition typeinf.hpp:3594
bool is_msstruct() const
Is gcc msstruct attribute applied.
Definition typeinf.hpp:3759
bool deserialize(const til_t *til, const qtype *ptype, const qtype *pfields=nullptr, const qtype *pfldcmts=nullptr, const char *cmt=nullptr)
Deserialize a type string into a tinfo_t object.
Definition typeinf.hpp:3297
uint32 get_ordinal() const
Get type ordinal (only if the type was created as a numbered type, 0 if none)
Definition typeinf.hpp:3433
bool get_udt_details(udt_type_data_t *udt, gtd_udt_t gtd=GTD_CALC_LAYOUT) const
Get the udt specific info.
Definition typeinf.hpp:3576
const char type_t bool bool try_ordinal
Definition typeinf.hpp:3247
THREAD_SAFE bool is_decl_array() const
is_type_array(get_decltype())
Definition typeinf.hpp:3477
tid_t get_udm_tid(size_t idx) const
Get udt member TID.
Definition typeinf.hpp:4144
uint64 write_bitfield_value(uint64 dst, uint64 v, int bitoff) const
Definition typeinf.hpp:4050
bool is_typedef() const
Is this a typedef?
Definition typeinf.hpp:3461
THREAD_SAFE bool empty() const
Was tinfo_t initialized with some type info or not?
Definition typeinf.hpp:3341
bool create_enum(enum_type_data_t &p, type_t decl_type=BTF_ENUM)
Definition typeinf.hpp:3972
tinfo_code_t del_udm(size_t index, uint etf_flags=0)
Delete a structure/union member.
Definition typeinf.hpp:4234
tinfo_code_t del_funcarg(size_t idx, uint etf_flags=0)
Definition typeinf.hpp:4567
bool is_shifted_ptr() const
Is a shifted pointer?
Definition typeinf.hpp:3591
bool get_ptr_details(ptr_type_data_t *pi) const
Get the pointer info.
Definition typeinf.hpp:3552
bool is_sue() const
is_type_sue(get_realtype())
Definition typeinf.hpp:3522
int get_ptrarr_objsize() const
BT_PTR & BT_ARRAY: get size of pointed object or array element. On error returns -1
Definition typeinf.hpp:3602
ssize_t get_stkvar(sval_t *actval, const insn_t &insn, const op_t *x, sval_t v)
Retrieve frame tinfo for a stack variable.
Definition typeinf.hpp:4366
tinfo_code_t set_func_rettype(const tinfo_t &tif, uint etf_flags=0)
Set function return type .
Definition typeinf.hpp:4553
bool clr_volatile()
Definition typeinf.hpp:4066
THREAD_SAFE bool is_decl_void() const
is_type_void(get_decltype())
Definition typeinf.hpp:3472
THREAD_SAFE bool is_decl_uint16() const
is_type_uint16(get_decltype())
Definition typeinf.hpp:3495
uint32 get_udt_taudt_bits() const
Get udt_type_data_t::taudt_bits.
Definition typeinf.hpp:3753
tinfo_code_t set_fixed_struct(bool on=true)
Declare struct member offsets as fixed.
Definition typeinf.hpp:4292
bool is_funcptr() const
Is this pointer to a function?
Definition typeinf.hpp:3588
bool is_forward_enum() const
Definition typeinf.hpp:3456
tinfo_code_t expand_udt(size_t idx, adiff_t delta, uint etf_flags=0)
Expand/shrink a structure by adding/removing a gap before the specified member.
Definition typeinf.hpp:4323
bool is_integral() const
is_type_integral(get_realtype())
Definition typeinf.hpp:3543
type_t get_enum_base_type() const
Get enum base type (convert enum to integer type) Returns BT_UNK if failed to convert.
Definition typeinf.hpp:3820
ssize_t get_edm_by_tid(edm_t *edm, tid_t tid)
Definition typeinf.hpp:3985
THREAD_SAFE bool has_details() const
Does this type refer to a nontrivial type?
Definition typeinf.hpp:3381
THREAD_SAFE bool is_decl_int32() const
is_type_int32(get_decltype())
Definition typeinf.hpp:3489
bool is_high_func() const
BT_FUNC: Is high level type?
Definition typeinf.hpp:3655
THREAD_SAFE bool is_decl_float() const
is_type_float(get_decltype())
Definition typeinf.hpp:3501
bool convert_array_to_ptr()
Convert an array into a pointer.
Definition typeinf.hpp:5904
bool is_bitfield() const
is_type_bitfld(get_realtype())
Definition typeinf.hpp:3523
bool equals_to(const tinfo_t &r) const
Definition typeinf.hpp:4628
THREAD_SAFE bool is_decl_struct() const
is_type_struct(get_decltype())
Definition typeinf.hpp:3482
tinfo_code_t rename_udm(size_t index, const char *name, uint etf_flags=0)
Rename a structure/union member.
Definition typeinf.hpp:4248
tinfo_code_t set_symbol_type(til_t *til, const char *name, int ntf_flags=0)
Definition typeinf.hpp:4003
THREAD_SAFE bool is_decl_sue() const
is_type_sue(get_decltype())
Definition typeinf.hpp:3481
DEPRECATED bool get_func_frame(const func_t *pfn)
Create a tinfo_t object for the function frame.
Definition typeinf.hpp:4344
void create_typedef(const til_t *til, const char *name, type_t decl_type=BTF_TYPEDEF, bool try_ordinal=true)
Definition typeinf.hpp:3947
bool create_func(func_type_data_t &p, type_t decl_type=BT_FUNC)
Definition typeinf.hpp:3973
tinfo_code_t edit_edm(size_t idx, uint64 value, bmask64_t bmask=DEFMASK64, uint etf_flags=0)
Change constant value and/or bitmask.
Definition typeinf.hpp:4523
bool is_uchar() const
is_type_uchar(get_realtype())
Definition typeinf.hpp:3531
tinfo_code_t add_udm(const udm_t &udm, uint etf_flags=0, size_t times=1, ssize_t idx=-1)
Add a structure/union member.
Definition typeinf.hpp:4155
bool create_udt(udt_type_data_t &p, type_t decl_type)
Definition typeinf.hpp:3971
bool change_sign(type_sign_t sign)
Change the type sign. Works only for the types that may have sign.
Definition typeinf.hpp:4080
bool present() const
Is the type really present? (not a reference to a missing type, for example)
Definition typeinf.hpp:3344
tinfo_code_t set_struct_size(size_t new_size)
Explicitly specify the struct size.
Definition typeinf.hpp:4299
tinfo_code_t del_edms(size_t idx1, size_t idx2, uint etf_flags=0)
Delete enum members.
Definition typeinf.hpp:4474
bool is_manually_castable_to(const tinfo_t &target) const
Definition typeinf.hpp:4630
uint64 read_bitfield_value(uint64 v, int bitoff) const
Definition typeinf.hpp:4049
bool has_union() const
Has a member of type "union"?
Definition typeinf.hpp:3809
bool get_numbered_type(const til_t *til, uint32 ordinal, type_t decl_type=BTF_TYPEDEF, bool resolve=true)
Create a tinfo_t object for an existing ordinal type.
Definition typeinf.hpp:5844
THREAD_SAFE bool is_decl_int() const
is_type_int(get_decltype())
Definition typeinf.hpp:3491
bool create_bitfield(const bitfield_type_data_t &p, type_t decl_type=BT_BITFIELD)
Definition typeinf.hpp:3936
int get_array_nelems() const
BT_ARRAY: get number of elements (-1 means error)
Definition typeinf.hpp:3628
bool is_frame() const
Is a function frame?
Definition typeinf.hpp:4351
tinfo_code_t add_edm(const edm_t &edm, bmask64_t bmask=DEFMASK64, uint etf_flags=0, ssize_t idx=-1)
Add a new enum member (a new symbolic constant)
Definition typeinf.hpp:4443
bool append_covered(rangeset_t *out, uint64 offset=0) const
Calculate set of covered bytes for the type.
Definition typeinf.hpp:3786
bool clr_const_volatile()
Definition typeinf.hpp:4067
bool create_enum(bte_t bte=BTE_ALWAYS|BTE_HEX)
Create an empty enum.
Definition typeinf.hpp:5866
const char * name
Definition typeinf.hpp:3244
THREAD_SAFE bool is_well_defined() const
!(empty()) && !(is_decl_partial()) && !(is_punknown())
Definition typeinf.hpp:3506
bool is_udm_by_til(size_t idx) const
Was the member created due to the type system.
Definition typeinf.hpp:4279
size_t get_unpadded_size() const
Get the type size in bytes without the final padding, in bytes.
Definition typeinf.hpp:3354
bool detach()
Detach tinfo_t from the underlying type.
Definition typeinf.hpp:3274
THREAD_SAFE bool is_decl_volatile() const
is_type_volatile(get_decltype())
Definition typeinf.hpp:3471
bool is_enum() const
is_type_enum(get_realtype())
Definition typeinf.hpp:3521
int get_udm(udm_t *out, const char *name) const
Retrieve a structure/union member with the specified name.
Definition typeinf.hpp:5965
tinfo_t get_final_element() const
repeat recursively: if an array, return the type of its element; else return the type itself.
Definition typeinf.hpp:3625
bool is_array() const
is_type_array(get_realtype())
Definition typeinf.hpp:3515
bool is_tbyte() const
is_type_tbyte(get_realtype())
Definition typeinf.hpp:3539
tinfo_code_t copy_type(til_t *til, const char *name, int ntf_flags=NTF_TYPE|NTF_COPY)
Definition typeinf.hpp:4006
bool create_ptr(const ptr_type_data_t &p, type_t decl_type=BT_PTR)
Definition typeinf.hpp:3934
THREAD_SAFE bool is_decl_const() const
is_type_const(get_decltype())
Definition typeinf.hpp:3470
bool is_ext_integral() const
is_type_ext_integral(get_realtype())
Definition typeinf.hpp:3544
bool is_int() const
is_type_int(get_realtype())
Definition typeinf.hpp:3528
bool set_methods(udtmembervec_t &methods)
BT_COMPLEX: set the list of member functions.
Definition typeinf.hpp:4089
bool is_forward_union() const
Definition typeinf.hpp:3455
THREAD_SAFE bool is_decl_func() const
is_type_func(get_decltype())
Definition typeinf.hpp:3478
bool is_uint128() const
is_type_uint128(get_realtype())
Definition typeinf.hpp:3535
THREAD_SAFE bool is_decl_ptr() const
is_type_ptr(get_decltype())
Definition typeinf.hpp:3476
THREAD_SAFE bool is_decl_double() const
is_type_double(get_decltype())
Definition typeinf.hpp:3500
bool calc_gaps(rangeset_t *out) const
Calculate set of padding bytes for the type.
Definition typeinf.hpp:3790
bool get_final_type_name(qstring *out) const
Use in the case of typedef chain (TYPE1 -> TYPE2 -> TYPE3...TYPEn).
Definition typeinf.hpp:3406
bool is_from_subtil() const
Was the named type found in some base type library (not the top level type library)?
Definition typeinf.hpp:3444
tid_t force_tid()
Get the type tid.
Definition typeinf.hpp:3430
THREAD_SAFE bool is_decl_last() const
is_typeid_last(get_decltype())
Definition typeinf.hpp:3475
bool create_array(const array_type_data_t &p, type_t decl_type=BT_ARRAY)
Definition typeinf.hpp:3935
bool is_correct() const
Is the type object correct?
Definition typeinf.hpp:3318
tinfo_t()
Constructor.
Definition typeinf.hpp:3209
bool is_forward_decl() const
Is this a forward declaration?
Definition typeinf.hpp:3448
bool is_int32() const
is_type_int32(get_realtype())
Definition typeinf.hpp:3526
bool is_bitmask_enum() const
Is bitmask enum?
Definition typeinf.hpp:3825
tinfo_code_t del_funcargs(size_t idx1, size_t idx2, uint etf_flags=0)
Delete function arguments.
Definition typeinf.hpp:4563
void del_attrs()
Del all type attributes. typerefs cannot be modified by this function.
Definition typeinf.hpp:3928
tinfo_t & operator=(const tinfo_t &r)
Copy contents of given tinfo into this one.
Definition typeinf.hpp:3222
bool is_bool() const
is_type_bool(get_realtype())
Definition typeinf.hpp:3540
tinfo_t(const char *decl, til_t *til=nullptr, int pt_flags=0)
Constructor - will attempt to parse the provided C declaration.
Definition typeinf.hpp:3213
bool is_aliased() const
Definition typeinf.hpp:4107
ea_t get_frame_func() const
Get function address for the frame.
Definition typeinf.hpp:4354
bool is_anonymous_type_name() const
Is an anonymous type?
Definition typeinf.hpp:3803
bool is_empty_udt() const
Is an empty struct/union? (has no fields)
Definition typeinf.hpp:3747
tinfo_code_t set_enum_is_bitmask(bitmask_cvt_stance_t stance=ENUMBM_ON, uint etf_flags=0)
Definition typeinf.hpp:4414
int get_nargs() const
BT_FUNC or BT_PTR BT_FUNC: Calculate number of arguments (-1 - error)
Definition typeinf.hpp:3643
tinfo_code_t set_udm_cmt(size_t index, const char *cmt, bool is_regcmt=false, uint etf_flags=0)
Set a comment for a structure/union member.
Definition typeinf.hpp:4266
bool is_anonymous_udt() const
Is an anonymous struct/union?
Definition typeinf.hpp:3800
tinfo_t get_innermost_udm(uint64 bitoffset, size_t *out_index=nullptr, uint64 *out_bitoffset=nullptr) const
Get the innermost member at the given offset.
Definition typeinf.hpp:3877
bitmask_cvt_stance_t
Set or clear the 'bitmask' attribute of an enum.
Definition typeinf.hpp:4409
@ ENUMBM_ON
convert to bitmask enum
Definition typeinf.hpp:4411
@ ENUMBM_OFF
convert to ordinal enum
Definition typeinf.hpp:4410
@ ENUMBM_AUTO
convert to bitmask if the outcome is nice and useful
Definition typeinf.hpp:4412
type_t get_modifiers() const
Definition typeinf.hpp:4056
tinfo_code_t add_funcarg(const funcarg_t &farg, uint etf_flags=0, ssize_t idx=-1)
Add a function argument.
Definition typeinf.hpp:4576
type_t get_realtype(bool full=false) const
Get the resolved base type.
Definition typeinf.hpp:3331
tinfo_code_t set_func_retloc(const argloc_t &argloc, uint etf_flags=0)
Set location of function return value.
Definition typeinf.hpp:4601
tinfo_code_t set_type_cmt(const char *cmt, bool is_regcmt=false, uint etf_flags=0)
Set type comment This function works only for non-trivial types.
Definition typeinf.hpp:4096
int calc_purged_bytes() const
BT_FUNC: Calculate number of purged bytes
Definition typeinf.hpp:3652
void set_volatile()
Definition typeinf.hpp:4059
bool is_iface() const
Is an interface?
Definition typeinf.hpp:3774
void swap(tinfo_t &r)
Assign this = r and r = this.
Definition typeinf.hpp:3228
void clear()
Clear contents of this tinfo, and remove from the type system.
Definition typeinf.hpp:3226
bool is_partial() const
is_type_partial(get_realtype())
Definition typeinf.hpp:3512
bool get_methods(udtmembervec_t *methods) const
BT_COMPLEX: get a list of member functions declared in this udt.
Definition typeinf.hpp:3659
bool is_pvoid() const
Is "void *"?
Definition typeinf.hpp:3615
int get_udm_by_offset(udm_t *out, uint64 offset) const
Retrieve a structure/union member with the specified offset.
Definition typeinf.hpp:5986
bool is_ldouble() const
is_type_ldouble(get_realtype())
Definition typeinf.hpp:3536
bool parse(const char *decl, til_t *til=nullptr, int pt_flags=0)
Convenience function to parse a string with a type declaration.
Definition typeinf.hpp:3956
bool get_attr(const qstring &key, bytevec_t *bv, bool all_attrs=true) const
Get a type attribute.
Definition typeinf.hpp:3917
uint32 calc_score() const
Calculate the type score (the higher - the nicer is the type)
Definition typeinf.hpp:3887
tinfo_t get_array_element() const
BT_ARRAY: get type of array element. See also get_ptrarr_object()
Definition typeinf.hpp:3622
bool build_anon_type_name(qstring *out) const
Generate a name like $hex_numbers based on the field types and names.
Definition typeinf.hpp:3395
bool is_const() const
is_type_const(get_realtype())
Definition typeinf.hpp:3509
int get_enum_width() const
Get enum width.
Definition typeinf.hpp:3839
bool serialize(qtype *type, qtype *fields=nullptr, qtype *fldcmts=nullptr, int sudt_flags=SUDT_FAST|SUDT_TRUNC) const
Serialize tinfo_t object into a type string.
Definition typeinf.hpp:3277
tinfo_code_t rename_type(const char *name, int ntf_flags=0)
Rename a type.
Definition typeinf.hpp:3401
DEFINE_MEMORY_ALLOCATION_FUNCS() inline bool get_named_type(const til_t *til
Create a tinfo_t object for an existing named type.
bool is_sse_type() const
Is a SSE vector type?
Definition typeinf.hpp:3796
THREAD_SAFE bool is_decl_uint64() const
is_type_uint64(get_decltype())
Definition typeinf.hpp:3497
bool is_double() const
is_type_double(get_realtype())
Definition typeinf.hpp:3537
bool is_func() const
is_type_func(get_realtype())
Definition typeinf.hpp:3516
bool get_next_type_name(qstring *out) const
Use In the case of typedef chain (TYPE1 -> TYPE2 -> TYPE3...TYPEn).
Definition typeinf.hpp:3411
bool is_uint64() const
is_type_uint64(get_realtype())
Definition typeinf.hpp:3534
bool is_ptr() const
is_type_ptr(get_realtype())
Definition typeinf.hpp:3514
bool get_type_by_tid(tid_t tid)
Definition typeinf.hpp:3986
bool requires_qualifier(qstring *out, const char *name, uint64 offset) const
Requires full qualifier?
Definition typeinf.hpp:3781
int find_udm(udm_t *udm, int strmem_flags) const
BTF_STRUCT,BTF_UNION: Find a udt member.
Definition typeinf.hpp:3673
bool get_bitfield_details(bitfield_type_data_t *bi) const
Get the bitfield specific info.
Definition typeinf.hpp:3570
tinfo_code_t set_iface(bool on=true)
Declare struct as an interface.
Definition typeinf.hpp:4339
tinfo_code_t get_enum_repr(value_repr_t *repr) const
Set the representation of enum members.
Definition typeinf.hpp:3834
ssize_t get_edm(edm_t *out, const char *name) const
Get enum member by its name.
Definition typeinf.hpp:3846
bool set_attr(const type_attr_t &ta, bool may_overwrite=true)
Set a type attribute. If necessary, a new typid will be created.
Definition typeinf.hpp:3925
bool is_struct() const
is_type_struct(get_realtype())
Definition typeinf.hpp:3518
size_t get_size(uint32 *p_effalign=nullptr, int gts_code=0) const
Get the type size in bytes.
Definition typeinf.hpp:3350
bool is_purging_cc() const
is_purging_cc(get_cc())
Definition typeinf.hpp:3649
THREAD_SAFE bool is_decl_paf() const
is_type_paf(get_decltype())
Definition typeinf.hpp:3505
bool is_complex() const
is_type_complex(get_realtype())
Definition typeinf.hpp:3517
tinfo_code_t set_edm_cmt(size_t idx, const char *cmt, uint etf_flags=0)
Set a comment for an enum member.
Definition typeinf.hpp:4512
bool get_type_rptcmt(qstring *out) const
Get type comment only if it is repeatable.
Definition typeinf.hpp:3468
bool get_func_details(func_type_data_t *fi, gtd_func_t gtd=GTD_CALC_ARGLOCS) const
Get only the function specific info for this tinfo_t.
Definition typeinf.hpp:3582
tinfo_code_t del_edm_by_value(uint64 value, uint etf_flags=0, bmask64_t bmask=DEFMASK64, uchar serial=0)
Delete enum member by its value.
Definition typeinf.hpp:6015
bool is_paf() const
is_type_paf(get_realtype())
Definition typeinf.hpp:3541
bool is_punknown() const
Is "_UNKNOWN *"?
Definition typeinf.hpp:3619
THREAD_SAFE bool is_decl_bitfield() const
is_type_bitfld(get_decltype())
Definition typeinf.hpp:3486
tinfo_code_t set_tuple(bool on=true)
Declare struct as a tuple.
Definition typeinf.hpp:4334
bool is_signed() const
Is this a signed type?
Definition typeinf.hpp:3369
THREAD_SAFE bool is_decl_int16() const
is_type_int16(get_decltype())
Definition typeinf.hpp:3490
tid_t get_edm_tid(size_t idx) const
Get enum member TID.
Definition typeinf.hpp:3866
tinfo_code_t rename_edm(size_t idx, const char *name, uint etf_flags=0)
Rename a enum member.
Definition typeinf.hpp:4502
tinfo_code_t set_udm_type(size_t index, const tinfo_t &tif, uint etf_flags=0, const value_repr_t *repr=nullptr)
Set type of a structure/union member.
Definition typeinf.hpp:4259
tinfo_code_t del_edm(size_t idx, uint etf_flags=0)
Definition typeinf.hpp:4478
THREAD_SAFE bool is_decl_partial() const
is_type_partial(get_decltype())
Definition typeinf.hpp:3473
bool is_uint32() const
is_type_uint32(get_realtype())
Definition typeinf.hpp:3533
bool is_unknown() const
is_type_unknown(get_realtype())
Definition typeinf.hpp:3513
THREAD_SAFE bool is_decl_bool() const
is_type_bool(get_decltype())
Definition typeinf.hpp:3504
const char type_t bool resolve
Definition typeinf.hpp:3246
int get_enum_radix() const
Get enum constant radix.
Definition typeinf.hpp:3830
THREAD_SAFE bool is_decl_typedef() const
is_type_typedef(get_decltype())
Definition typeinf.hpp:3480
bool is_union() const
is_type_union(get_realtype())
Definition typeinf.hpp:3519
tinfo_code_t set_funcarg_loc(size_t index, const argloc_t &argloc, uint etf_flags=0)
Set location of a function argument.
Definition typeinf.hpp:4592
THREAD_SAFE type_t get_decltype() const
Get declared type (without resolving type references; they are returned as is).
Definition typeinf.hpp:3338
bool is_vftable() const
Is a vftable type?
Definition typeinf.hpp:3765
bool compare_with(const tinfo_t &r, int tcflags=0) const
Compare two types, based on given flags (see tinfo_t comparison flags)
Definition typeinf.hpp:4627
void clr_decl_const_volatile()
Definition typeinf.hpp:4061
~tinfo_t()
Destructor.
Definition typeinf.hpp:3224
callcnv_t get_cc() const
BT_FUNC or BT_PTR BT_FUNC: Get calling convention
Definition typeinf.hpp:3646
bool is_castable_to(const tinfo_t &target) const
Definition typeinf.hpp:4629
bool is_udt() const
is_type_struni(get_realtype())
Definition typeinf.hpp:3520
bool is_void() const
is_type_void(get_realtype())
Definition typeinf.hpp:3511
tinfo_t get_nth_arg(int n) const
BT_FUNC or BT_PTR BT_FUNC: Get type of n-th arg (-1 means return type, see get_rettype())
Definition typeinf.hpp:3631
THREAD_SAFE bool is_typeref() const
Is this type a type reference?
Definition typeinf.hpp:3378
tinfo_code_t set_udt_pack(int pack, uint etf_flags=0)
Set structure packing.
Definition typeinf.hpp:4134
bool is_uint16() const
is_type_uint16(get_realtype())
Definition typeinf.hpp:3532
uint64 calc_enum_mask() const
Definition typeinf.hpp:3840
Text representation of a data value (value string).
Definition typeinf.hpp:6542
qstring oneline
result if printed on one line in UTF-8 encoding
Definition typeinf.hpp:6544
bool append_char(char c, int max_length)
bool flatten(const flatten_args_t &flargs, int level)
void set_oneline(const char *line, int len)
Definition typeinf.hpp:6565
bool convert_to_one_line(int ptvf, int max_length)
~valstr_t()
Definition typeinf.hpp:6584
struct valstrs_t * members
strings for members, each member separately
Definition typeinf.hpp:6546
void consume_oneline(const qstring &line)
Definition typeinf.hpp:6570
void update_length(int ptvf)
int props
temporary properties, used internally
Definition typeinf.hpp:6548
valinfo_t * info
additional info
Definition typeinf.hpp:6547
valstr_t()
Definition typeinf.hpp:6551
friend struct() private valstr_sink_t
Definition typeinf.hpp:6553
size_t length
length if printed on one line
Definition typeinf.hpp:6545
idaman callcnv_t ida_export find_custom_callcnv(const char *name)
Find a calling convention by its name.
idaman size_t ida_export get_custom_callcnvs(qstrvec_t *names, callcnvs_t *codes)
Get all custom calling conventions.
argreg_policy_t
Function argument passing: how GP & FP registers cooperate with each other.
Definition typeinf.hpp:1724
idaman int ida_export verify_argloc(const argloc_t &vloc, int size, const rangeset_t *gaps)
Verify argloc_t.
constexpr THREAD_SAFE bool is_purging_cc(callcnv_t cc)
Does the calling convention clean the stack arguments upon return?
Definition typeinf.hpp:1478
void helper_set_cc(cm_t *cm, callcnv_t *new_callcnv, callcnv_t cc)
Definition typeinf.hpp:1436
constexpr THREAD_SAFE bool is_vararg_cc(callcnv_t cc)
Does the calling convention use ellipsis?
Definition typeinf.hpp:1470
idaman const custom_callcnv_t *ida_export get_custom_callcnv(callcnv_t callcnv)
Retrieve custom calling convention details.
constexpr bool is_rust_cc(callcnv_t cc)
Rust language calling convention?
Definition typeinf.hpp:1496
idaman int ida_export install_custom_argloc(const custloc_desc_t *custloc)
Save a custom argloc.
int idaapi for_all_const_arglocs(const_aloc_visitor_t &vv, const argloc_t &vloc, int size, int off=0)
See for_all_arglocs()
Definition typeinf.hpp:1403
const argloc_type_t ALOC_NONE
none
Definition typeinf.hpp:957
callcnv_t helper_get_cc(cm_t cm, callcnv_t new_callcnv)
Definition typeinf.hpp:1427
qvector< argpart_t > argpartvec_t
Definition typeinf.hpp:1343
const argloc_type_t ALOC_CUSTOM
custom argloc (7 or higher)
Definition typeinf.hpp:964
const argloc_type_t ALOC_RREL
register relative
Definition typeinf.hpp:962
const argloc_type_t ALOC_DIST
distributed (scattered)
Definition typeinf.hpp:959
const argloc_type_t ALOC_REG2
register pair
Definition typeinf.hpp:961
idaman bool ida_export unregister_custom_callcnv(callcnv_t callcnv)
Unregister a calling convention.
const argloc_type_t ALOC_STATIC
global address
Definition typeinf.hpp:963
idaman bool ida_export get_stkarg_area_info(stkarg_area_info_t *out, callcnv_t cc)
Some calling conventions foresee special areas on the stack for call arguments.
const argloc_type_t ALOC_REG1
one register (and offset within it)
Definition typeinf.hpp:960
idaman const custloc_desc_t *ida_export retrieve_custom_argloc(int idx)
Retrieve the custom argloc at the given index.
constexpr THREAD_SAFE bool is_user_cc(callcnv_t cc)
Does the calling convention specify argument locations explicitly?
Definition typeinf.hpp:1464
idaman size_t ida_export print_argloc(char *buf, size_t bufsize, const argloc_t &vloc, int size=0, int vflags=0)
Convert an argloc to human readable form.
constexpr bool is_swift_cc(callcnv_t cc)
Swift calling convention (arguments and return values in registers)?
Definition typeinf.hpp:1513
idaman int ida_export for_all_arglocs(aloc_visitor_t &vv, argloc_t &vloc, int size, int off=0)
Compress larger argloc types and initiate the aloc visitor.
constexpr bool is_golang_cc(callcnv_t cc)
GO language calling convention (return value in stack)?
Definition typeinf.hpp:1490
void set_cc(callcnv_t cc)
Definition typeinf.hpp:1452
qvector< argloc_t > arglocs_t
vector of argument locations
Definition typeinf.hpp:1313
idaman callcnv_t ida_export register_custom_callcnv(const custom_callcnv_t &ccinf)
Register a calling convention.
idaman bool ida_export optimize_argloc(argloc_t *vloc, int size, const rangeset_t *gaps)
Verify and optimize scattered argloc into simple form.
idaman bool ida_export remove_custom_argloc(int idx)
Delete the custom argloc at the given index.
const argloc_type_t ALOC_STACK
stack offset
Definition typeinf.hpp:958
callcnv_t get_cc() const
Definition typeinf.hpp:1451
bool is_custom_callcnv(callcnv_t cc)
Is custom calling convention?
Definition typeinf.hpp:1502
callcnv_t get_effective_cc(callcnv_t cc)
Get effective calling convention (with respect to default CC)
Definition typeinf.hpp:1455
@ ARGREGS_GP_ONLY
GP registers used for all arguments.
Definition typeinf.hpp:1726
@ ARGREGS_POLICY_UNDEFINED
Definition typeinf.hpp:1725
@ ARGREGS_RISCV
Risc-V API FP arguments are passed in GP registers if FP registers are exhausted and GP ones are not.
Definition typeinf.hpp:1731
@ ARGREGS_FP_MASKS_GP
FP register also consumes one or more GP regs but not vice versa (aix ppc ABI)
Definition typeinf.hpp:1729
@ ARGREGS_BY_SLOTS
fixed FP/GP register per each slot (like vc64)
Definition typeinf.hpp:1728
@ ARGREGS_MIPS_O32
MIPS ABI o32.
Definition typeinf.hpp:1730
@ ARGREGS_INDEPENDENT
FP/GP registers used separately (like gcc64)
Definition typeinf.hpp:1727
const type_t BFA_STATIC
static
Definition typeinf.hpp:929
const type_t BFA_FUNC_EXT_FORMAT
This is NOT a real attribute (used internally as marker for extended format)
Definition typeinf.hpp:933
const type_t BFA_NORET
__noreturn
Definition typeinf.hpp:926
const cm_t BFA_FUNC_MARKER
This is NOT a cc! (used internally as a marker)
Definition typeinf.hpp:932
const type_t BFA_VIRTUAL
virtual
Definition typeinf.hpp:930
const type_t BFA_HIGH
high level prototype (with possibly hidden args)
Definition typeinf.hpp:928
const type_t BFA_PURE
__pure
Definition typeinf.hpp:927
const cm_t C_PC_FLAT
Definition typeinf.hpp:1421
const cm_t C_PC_SMALL
Definition typeinf.hpp:1416
const cm_t C_PC_MEDIUM
Definition typeinf.hpp:1418
const cm_t C_PC_LARGE
Definition typeinf.hpp:1419
const cm_t C_PC_TINY
Definition typeinf.hpp:1415
const cm_t C_PC_HUGE
Definition typeinf.hpp:1420
const cm_t C_PC_COMPACT
Definition typeinf.hpp:1417
bool is_gcc()
Is the target compiler COMP_GNU?
Definition typeinf.hpp:1933
bool idaapi set_abi_name(const char *abiname, bool user_level=false)
Set abi name (see Compiler IDs)
Definition typeinf.hpp:1984
idaman void ida_export get_compilers(compvec_t *ids, qstrvec_t *names, qstrvec_t *abbrs)
Get names of all built-in compilers.
idaman bool ida_export set_compiler_string(const char *compstr, bool user_level)
bool use_golang_cc()
is GOLANG calling convention used by default?
Definition typeinf.hpp:2013
THREAD_SAFE comp_t get_comp(comp_t comp)
Get compiler bits.
Definition typeinf.hpp:1900
bool is_gcc32()
Is the target compiler 32 bit gcc?
Definition typeinf.hpp:1938
bool use_rust_cc()
is RUST calling convention used by default?
Definition typeinf.hpp:2029
idaman bool ida_export set_compiler(const compiler_info_t &cc, int flags, const char *abiname=nullptr)
Change current compiler.
bool gcc_layout()
Should use the struct/union layout as done by gcc?
Definition typeinf.hpp:1948
idaman ssize_t ida_export get_abi_name(qstring *out)
Get ABI name.
comp_t default_compiler()
Get compiler specified by inf.cc.
Definition typeinf.hpp:1928
idaman bool ida_export remove_abi_opts(const char *abi_opts, bool user_level=false)
THREAD_SAFE comp_t is_comp_unsure(comp_t comp)
See COMP_UNSURE.
Definition typeinf.hpp:1923
idaman const char *ida_export get_compiler_name(comp_t id)
Get full compiler name.
qvector< comp_t > compvec_t
Collection of compiler descriptions.
Definition typeinf.hpp:1913
idaman bool ida_export append_abi_opts(const char *abi_opts, bool user_level=false)
Add/remove/check ABI option General form of full abi name: abiname-opt1-opt2-... or -opt1-opt2-....
void switch_to_golang()
switch to GOLANG calling convention (to be used as default CC)
Definition typeinf.hpp:2020
idaman void ida_export switch_to_rust()
switch to RUST calling convention (to be used as default CC)
bool idaapi set_compiler_id(comp_t id, const char *abiname=nullptr)
Set the compiler id (see Compiler IDs)
Definition typeinf.hpp:1975
bool is_gcc64()
Is the target compiler 64 bit gcc?
Definition typeinf.hpp:1943
idaman const char *ida_export get_compiler_abbr(comp_t id)
Get abbreviated compiler name.
const callcnv_t CM_CC_PASCAL
stack, purged, reverse order of args
Definition typeinf.hpp:889
const callcnv_t CM_CC_SWIFT
(Swift) arguments and return values in registers (compiler-dependent)
Definition typeinf.hpp:892
const callcnv_t CM_CC_RESERVE3
reserved; used for internal needs
Definition typeinf.hpp:898
const callcnv_t CM_CC_CDECL
stack
Definition typeinf.hpp:886
const callcnv_t CM_CC_INVALID
this value is invalid
Definition typeinf.hpp:881
const callcnv_t CM_CC_SPECIALP
Equal to CM_CC_SPECIAL, but with purged stack.
Definition typeinf.hpp:900
const callcnv_t CM_CC_RUST
(Rust) arguments and return value follow the Rust ABI
Definition typeinf.hpp:906
const callcnv_t CM_CC_GOLANG
(Go) arguments and return value reg/stack depending on version
Definition typeinf.hpp:897
const callcnv_t CM_CC_FASTCALL
stack, purged (x86), first args are in regs (compiler-dependent)
Definition typeinf.hpp:890
const callcnv_t CM_CC_STDCALL
stack, purged
Definition typeinf.hpp:888
const callcnv_t CM_CC_SPECIAL
usercall: locations of all arguments and the return value are explicitly specified
Definition typeinf.hpp:901
const callcnv_t CM_CC_THISCALL
stack, purged (x86), first arg is in reg (compiler-dependent)
Definition typeinf.hpp:891
const callcnv_t CM_CC_VOIDARG
function without arguments if has other cc and argnum == 0, represent as f() - unknown list
Definition typeinf.hpp:883
const callcnv_t CM_CC_GOSTK
(Go) arguments and return value in stack
Definition typeinf.hpp:905
const callcnv_t CM_CC_SPOILED
This is NOT a cc!
Definition typeinf.hpp:893
const callcnv_t CM_CC_MASK
Definition typeinf.hpp:880
const callcnv_t CM_CC_LAST_USERCALL
Definition typeinf.hpp:903
const callcnv_t CM_CC_UNKNOWN
unknown calling convention
Definition typeinf.hpp:882
const callcnv_t CM_CC_FIRST_PLAIN_CUSTOM
Definition typeinf.hpp:908
const callcnv_t CM_CC_ELLIPSIS
cdecl + ellipsis
Definition typeinf.hpp:887
const callcnv_t CM_CC_SPECIALE
CM_CC_SPECIAL with ellipsis
Definition typeinf.hpp:899
const cm_t CM_M_MASK
Definition typeinf.hpp:866
THREAD_SAFE bool is_code_far(cm_t cm)
Does the given model specify far code?
Definition typeinf.hpp:873
THREAD_SAFE bool is_data_far(cm_t cm)
Does the given model specify far data?
Definition typeinf.hpp:875
const cm_t CM_M_NN
small: code=near, data=near (or unknown if CM_UNKNOWN)
Definition typeinf.hpp:867
const cm_t CM_M_FN
medium: code=far, data=near
Definition typeinf.hpp:870
const cm_t CM_M_FF
large: code=far, data=far
Definition typeinf.hpp:868
const cm_t CM_M_NF
compact: code=near, data=far
Definition typeinf.hpp:869
const cm_t CM_N32_F48
near 4 bytes, far 6 bytes
Definition typeinf.hpp:862
const cm_t CM_N16_F32
near 2 bytes, far 4 bytes
Definition typeinf.hpp:861
const cm_t CM_UNKNOWN
unknown
Definition typeinf.hpp:858
const cm_t CM_N8_F16
if sizeof(int)<=2: near 1 byte, far 2 bytes
Definition typeinf.hpp:859
const cm_t CM_MASK
Definition typeinf.hpp:857
const cm_t CM_N64
if sizeof(int)>2: near 8 bytes, far 8 bytes
Definition typeinf.hpp:860
const comp_t COMP_BP
Delphi.
Definition typeinf.hpp:1889
const comp_t COMP_WATCOM
Watcom C++.
Definition typeinf.hpp:1884
const comp_t COMP_MASK
Definition typeinf.hpp:1880
const comp_t COMP_UNK
Unknown.
Definition typeinf.hpp:1881
const comp_t COMP_BC
Borland C++.
Definition typeinf.hpp:1883
const comp_t COMP_GNU
GNU C++.
Definition typeinf.hpp:1887
const comp_t COMP_MS
Visual C++.
Definition typeinf.hpp:1882
const comp_t COMP_UNSURE
uncertain compiler id
Definition typeinf.hpp:1891
const comp_t COMP_VISAGE
Visual Age C++.
Definition typeinf.hpp:1888
etf_flag_t
Definition typeinf.hpp:2940
@ ETF_NO_LAYOUT
don't calc type layout before editing
Definition typeinf.hpp:2945
@ ETF_FUNCARG
udm - member is a function argument (cannot create arrays)
Definition typeinf.hpp:2948
@ ETF_AUTONAME
udm - generate a member name if was not specified (add_udm, set_udm_type)
Definition typeinf.hpp:2950
@ ETF_NO_ARRAY
add_udm, set_udm_type - do not convert type to an array on the size mismatch
Definition typeinf.hpp:2952
@ ETF_FORCENAME
anyway use name, see below for more usage description
Definition typeinf.hpp:2949
@ ETF_NO_SAVE
don't save to til (normally typerefs are saved to til) A call with ETF_NO_SAVE must be followed by a ...
Definition typeinf.hpp:2941
@ ETF_COMPATIBLE
new type must be compatible with the old
Definition typeinf.hpp:2947
@ ETF_MAY_DESTROY
may destroy other members
Definition typeinf.hpp:2946
@ ETF_BYTIL
udm - new type was created by the type subsystem
Definition typeinf.hpp:2951
idaman bool ida_export decorate_name(qstring *out, const char *name, bool should_decorate, callcnv_t cc=CM_CC_UNKNOWN, const tinfo_t *type=nullptr)
Decorate/undecorate a C symbol name.
idaman ssize_t ida_export calc_c_cpp_name(qstring *out, const char *name, const tinfo_t *type, int ccn_flags)
Get C or C++ form of the name.
idaman bool ida_export del_named_type(til_t *ti, const char *name, int ntf_flags)
Delete information about a symbol.
idaman const char *ida_export next_named_type(const til_t *ti, const char *name, int ntf_flags)
Enumerate types.
idaman bool ida_export gen_decorate_name(qstring *out, const char *name, bool should_decorate, callcnv_t cc, const tinfo_t *type)
Generic function for decorate_name() (may be used in IDP modules)
idaman const char *ida_export first_named_type(const til_t *ti, int ntf_flags)
Enumerate types.
tinfo_code_t
Error codes various tinfo functions:
Definition typeinf.hpp:2352
virtual bool decorate_name(qstring *outbuf, const char *name, bool should_decorate, callcnv_t cc, const tinfo_t &type) const
Decorate a function name.
Definition typeinf.hpp:2464
idaman const char *ida_export tinfo_errstr(tinfo_code_t code)
Helper function to convert an error code into a printable string.
int idaapi get_named_type64(const til_t *ti, const char *name, int ntf_flags, const type_t **type=nullptr, const p_list **fields=nullptr, const char **cmt=nullptr, const p_list **fieldcmts=nullptr, sclass_t *sclass=nullptr, uint64 *value=nullptr)
See get_named_type() above.
Definition typeinf.hpp:2334
idaman int ida_export get_named_type(const til_t *ti, const char *name, int ntf_flags, const type_t **type=nullptr, const p_list **fields=nullptr, const char **cmt=nullptr, const p_list **fieldcmts=nullptr, sclass_t *sclass=nullptr, uint32 *value=nullptr)
Get named typeinfo.
idaman uint32 ida_export copy_named_type(til_t *dsttil, const til_t *srctil, const char *name)
Copy a named type from one til to another.
@ TERR_ENUM_SIZE
bad enum size
Definition typeinf.hpp:2386
@ TERR_NOT_COMPAT
the new type is not compatible with the old type
Definition typeinf.hpp:2380
@ TERR_NOT_IMPL
not implemented
Definition typeinf.hpp:2387
@ TERR_NOT_FOUND
member not found
Definition typeinf.hpp:2391
@ TERR_BAD_OFFSET
bad member offset s
Definition typeinf.hpp:2363
@ TERR_BAD_ARG
bad argument
Definition typeinf.hpp:2357
@ TERR_BAD_GROUPS
bad group sizes for bitmask enum
Definition typeinf.hpp:2382
@ TERR_STRUCT_SIZE
bad fixed structure size
Definition typeinf.hpp:2390
@ TERR_BAD_NAME
name s is not acceptable
Definition typeinf.hpp:2356
@ TERR_BAD_FX_SIZE
cannot extend struct beyond fixed size
Definition typeinf.hpp:2389
@ TERR_BAD_GAP
bad gap
Definition typeinf.hpp:2378
@ TERR_BAD_VARLAST
variable sized member must be the last member in the structure
Definition typeinf.hpp:2365
@ TERR_BAD_BF
bitfields are forbidden as function arguments
Definition typeinf.hpp:2362
@ TERR_BAD_BMASK
Bad enum member mask 0xI64X. The specified mask should not intersect with any existing mask in the en...
Definition typeinf.hpp:2370
@ TERR_BAD_BASE
bad base class
Definition typeinf.hpp:2377
@ TERR_STOCK
stock type info cannot be modified
Definition typeinf.hpp:2385
@ TERR_BAD_TAH
bad bits in the type attributes (TAH bits)
Definition typeinf.hpp:2376
@ TERR_BAD_REPR
bad or incompatible field representation
Definition typeinf.hpp:2372
@ TERR_UNION_BF
unions cannot have bitfields
Definition typeinf.hpp:2375
@ TERR_BAD_MSKVAL
bad bmask and value combination (value=0xI64X; bitmask 0xI64X)
Definition typeinf.hpp:2371
@ TERR_GRP_NOEMPTY
could not delete group mask for not empty group 0xI64X
Definition typeinf.hpp:2373
@ TERR_SERIALIZE
failed to serialize
Definition typeinf.hpp:2355
@ TERR_BAD_TYPE
bad type
Definition typeinf.hpp:2358
@ TERR_BAD_ARRAY
arrays are forbidden as function arguments
Definition typeinf.hpp:2361
@ TERR_TYPE_WORSE
the new type is worse than the old type
Definition typeinf.hpp:2388
@ TERR_NO_BMASK
bitmask 0xI64X is not found
Definition typeinf.hpp:2369
@ TERR_OVERLAP
the member overlaps with other members that cannot be deleted
Definition typeinf.hpp:2366
@ TERR_ALIEN_NAME
enum member name is used in another enum
Definition typeinf.hpp:2384
@ TERR_COUNT
Definition typeinf.hpp:2392
@ TERR_DUPNAME
duplicate name s
Definition typeinf.hpp:2374
@ TERR_BAD_SERIAL
enum value has too many serials
Definition typeinf.hpp:2383
@ TERR_BAD_UNIVAR
unions cannot have variable sized members
Definition typeinf.hpp:2364
@ TERR_BAD_LAYOUT
failed to calculate the structure/union layout
Definition typeinf.hpp:2381
@ TERR_BAD_SUBTYPE
recursive structure nesting is forbidden
Definition typeinf.hpp:2367
@ TERR_BAD_SIZE
bad size d
Definition typeinf.hpp:2359
@ TERR_OK
ok
Definition typeinf.hpp:2353
@ TERR_BAD_VALUE
value 0xI64X is not acceptable
Definition typeinf.hpp:2368
@ TERR_BAD_INDEX
bad index d
Definition typeinf.hpp:2360
@ TERR_NESTED
recursive structure nesting is forbidden
Definition typeinf.hpp:2379
@ TERR_SAVE_ERROR
failed to save
Definition typeinf.hpp:2354
idaman bool ida_export is_ordinal_name(const char *name, uint32 *ord=nullptr)
Check if the name is an ordinal name.
idaman bool ida_export is_type_choosable(const til_t *ti, uint32 ordinal)
Check if a struct/union type is choosable.
idaman uint32 ida_export alloc_type_ordinals(til_t *ti, int qty)
Allocate a range of ordinal numbers for new types.
idaman uint32 ida_export get_ordinal_limit(const til_t *ti=nullptr)
Get number of allocated ordinals + 1.
idaman int32 ida_export get_type_ordinal(const til_t *ti, const char *name)
Get type ordinal by its name.
uint32 alloc_type_ordinal(til_t *ti)
alloc_type_ordinals(ti, 1)
Definition typeinf.hpp:2531
idaman const char *ida_export get_numbered_type_name(const til_t *ti, uint32 ordinal)
Get type name (if exists) by its ordinal.
idaman void ida_export set_type_choosable(til_t *ti, uint32 ordinal, bool value)
Enable/disable 'choosability' flag for a struct/union type.
idaman bool ida_export del_numbered_type(til_t *ti, uint32 ordinal)
Delete a numbered type.
idaman bool ida_export get_numbered_type(const til_t *ti, uint32 ordinal, const type_t **type=nullptr, const p_list **fields=nullptr, const char **cmt=nullptr, const p_list **fieldcmts=nullptr, sclass_t *sclass=nullptr)
Retrieve a type by its ordinal number.
idaman uint32 ida_export get_alias_target(const til_t *ti, uint32 ordinal)
Find the final alias destination.
idaman bool ida_export set_type_alias(til_t *ti, uint32 src_ordinal, uint32 dst_ordinal)
Create a type alias.
idaman bool ida_export enable_numbered_types(til_t *ti, bool enable)
Enable the use of numbered types in til.
idaman ssize_t ida_export create_numbered_type_name(qstring *buf, int32 ord)
Create anonymous name for numbered type.
uint32 get_ordinal_count(const til_t *ti=nullptr)
Get number of allocated ordinals.
Definition typeinf.hpp:2548
idaman int ida_export compact_numbered_types(til_t *ti, uint32 min_ord=0, intvec_t *p_ordmap=nullptr, int flags=0)
Compact numbered types to get rid of empty slots.
int idaapi h2ti_type_cb(const char *name, const tinfo_t &tif, const char *cmt, const uint64 *value, void *cb_data)
This callback will be called for each type/variable declaration.
Definition typeinf.hpp:2121
idaman bool ida_export print_type(qstring *out, ea_t ea, int prtype_flags)
Get type declaration for the specified address.
idaman int ida_export h2ti(til_t *ti, lexer_t *lx, const char *input, int flags=HTI_HIGH, h2ti_type_cb *type_cb=nullptr, h2ti_type_cb *var_cb=nullptr, printer_t *print_cb=nullptr, void *_cb_data=nullptr, abs_t _isabs=ABS_UNK)
Convert declarations to type_t*.
Definition typeinf.hpp:2147
idaman bool ida_export parse_decl(tinfo_t *out_tif, qstring *out_name, til_t *til, const char *decl, int pt_flags)
Parse ONE declaration.
typedef AS_PRINTF(1, 2) int printer_t(const char *format
Specify a printing callback when parsing types.
idaman int ida_export parse_decls(til_t *til, const char *input, printer_t *printer, int hti_flags)
Parse many declarations and store them in a til.
THREAD_SAFE int convert_pt_flags_to_hti(int pt_flags)
Convert Type parsing flags to Type formatting flags.
Definition typeinf.hpp:2163
idaman THREAD_SAFE const char * format
Definition fpro.h:78
int code
Definition fpro.h:88
idaman size_t n
Definition pro.h:1000
const type_sign_t type_unsigned
unsigned type
Definition typeinf.hpp:676
qvector< type_attr_t > type_attrs_t
this vector must be sorted by keys
Definition typeinf.hpp:670
int type_sign_t
type signedness
Definition typeinf.hpp:672
const type_sign_t no_sign
no sign, or unknown
Definition typeinf.hpp:674
const type_sign_t type_signed
signed type
Definition typeinf.hpp:675
DECLARE_TYPE_AS_MOVABLE(type_attr_t)
const type_t BTMT_NONBASED
Definition typeinf.hpp:233
const type_t BTMT_ARRESERV
reserved bit
Definition typeinf.hpp:241
const type_t BT_ARRAY
array
Definition typeinf.hpp:232
const type_t BT_BOOL
bool
Definition typeinf.hpp:181
const type_t BTMT_BOOL8
size 8 bytes - inf_is_64bit()
Definition typeinf.hpp:185
const type_t BTMT_BOOL2
size 2 bytes - !inf_is_64bit()
Definition typeinf.hpp:184
const type_t BTMT_BOOL4
size 4 bytes
Definition typeinf.hpp:186
const type_t BTMT_DEFBOOL
size is model specific or unknown(?)
Definition typeinf.hpp:182
const type_t BTMT_BOOL1
size 1 byte
Definition typeinf.hpp:183
const type_t BTMT_BFLDI16
__int16
Definition typeinf.hpp:327
const type_t BT_BITFIELD
bitfield (only in struct) ['bitmasked' enum see below] next byte is dt ((size in bits << 1) | (unsign...
Definition typeinf.hpp:322
const type_t BTMT_BFLDI32
__int32
Definition typeinf.hpp:328
const type_t BTMT_BFLDI64
__int64
Definition typeinf.hpp:329
const type_t BT_COMPLEX
struct/union/enum/typedef.
Definition typeinf.hpp:287
const type_t BTMT_ENUM
enum: next byte bte_t (see below) N records: de delta(s) OR blocks (see below)
Definition typeinf.hpp:314
const type_t BTMT_TYPEDEF
named reference always p_string name
Definition typeinf.hpp:319
const type_t BTMT_BFLDI8
__int8
Definition typeinf.hpp:326
const type_t BTMT_STRUCT
struct: MCNT records: type_t; [sdacl-typeattrs];
Definition typeinf.hpp:310
const type_t BTMT_UNION
union: MCNT records: type_t...
Definition typeinf.hpp:312
const type_t BT_SEGREG
segment register
Definition typeinf.hpp:373
const type_t BT_UNK_DWORD
4 bytes
Definition typeinf.hpp:380
const type_t BT_UNKNOWN
unknown size - for parameters
Definition typeinf.hpp:383
const type_t BT_UNK_BYTE
1 byte
Definition typeinf.hpp:378
const type_t BT_UNK_QWORD
8 bytes
Definition typeinf.hpp:381
const type_t BT_UNK_OWORD
16 bytes
Definition typeinf.hpp:382
const type_t BT_UNK_WORD
2 bytes
Definition typeinf.hpp:379
const bte_t BTE_HEX
hex
Definition typeinf.hpp:364
const bte_t BTE_UDEC
unsigned decimal
Definition typeinf.hpp:367
const bte_t BTE_RESERVED
must be 0, in order to distinguish from a tah-byte
Definition typeinf.hpp:353
uchar bte_t
Enum type flags.
Definition typeinf.hpp:347
const bte_t BTE_BITMASK
'subarrays'.
Definition typeinf.hpp:355
const bte_t BTE_CHAR
char or hex
Definition typeinf.hpp:365
const bte_t BTE_SDEC
signed decimal
Definition typeinf.hpp:366
const bte_t BTE_ALWAYS
this bit MUST be present
Definition typeinf.hpp:368
const bte_t BTE_SIZE_MASK
storage size.
Definition typeinf.hpp:349
const bte_t BTE_OUT_MASK
output style mask
Definition typeinf.hpp:363
const type_t BTMT_SPECFLT
float (variable size).
Definition typeinf.hpp:195
const type_t BTMT_LNGDBL
long double (compiler specific)
Definition typeinf.hpp:194
const type_t BT_FLOAT
float
Definition typeinf.hpp:191
const type_t BTMT_FLOAT
float (4 bytes)
Definition typeinf.hpp:192
const type_t BTMT_DOUBLE
double (8 bytes)
Definition typeinf.hpp:193
const type_t BTMT_FARCALL
function returns by retf
Definition typeinf.hpp:280
const type_t BTMT_DEFCALL
call method - default for model or unknown
Definition typeinf.hpp:278
const type_t BT_FUNC
function.
Definition typeinf.hpp:249
const type_t BTMT_NEARCALL
function returns by retn
Definition typeinf.hpp:279
const type_t BTMT_INTCALL
function returns by iret in this case cc MUST be 'unknown'
Definition typeinf.hpp:281
const type_t BT_INT
natural int. (size provided by idp module)
Definition typeinf.hpp:168
const type_t BT_INT16
__int16
Definition typeinf.hpp:164
const type_t BTMT_UNKSIGN
unknown signedness
Definition typeinf.hpp:169
const type_t BT_INT64
__int64
Definition typeinf.hpp:166
const type_t BT_INT128
__int128 (for alpha & future use)
Definition typeinf.hpp:167
const type_t BTMT_CHAR
specify char or segment register
Definition typeinf.hpp:173
const type_t BT_INT32
__int32
Definition typeinf.hpp:165
const type_t BTMT_UNSIGNED
Definition typeinf.hpp:172
const type_t BT_INT8
__int8
Definition typeinf.hpp:163
const type_t BTMT_USIGNED
unsigned
Definition typeinf.hpp:171
const type_t BTMT_SIGNED
signed
Definition typeinf.hpp:170
const type_t _BT_LAST_BASIC
the last basic type, all basic types may be followed by [tah-typeattrs]
Definition typeinf.hpp:202
const type_t TYPE_FULL_MASK
basic type with type flags
Definition typeinf.hpp:136
const type_t TYPE_FLAGS_MASK
type flags - they have different meaning depending on the basic type
Definition typeinf.hpp:130
const type_t TYPE_BASE_MASK
the low 4 bits define the basic type
Definition typeinf.hpp:129
const type_t TYPE_MODIF_MASK
modifiers.
Definition typeinf.hpp:132
const type_t BTM_CONST
const
Definition typeinf.hpp:340
const type_t BTM_VOLATILE
volatile
Definition typeinf.hpp:341
const type_t BTMT_CLOSURE
closure.
Definition typeinf.hpp:217
const type_t BT_PTR
pointer.
Definition typeinf.hpp:211
const type_t BTMT_NEAR
near
Definition typeinf.hpp:215
const type_t BTMT_DEFPTR
default for model
Definition typeinf.hpp:214
const type_t BTMT_FAR
far
Definition typeinf.hpp:216
const type_t BTF_INT64
signed long
Definition typeinf.hpp:404
const type_t BTF_UNION
union
Definition typeinf.hpp:422
const type_t BTF_UINT16
unsigned short
Definition typeinf.hpp:399
const type_t BTF_DOUBLE
double
Definition typeinf.hpp:417
const type_t BTF_UNK
unknown
Definition typeinf.hpp:390
const type_t BTF_UINT128
unsigned 128-bit value
Definition typeinf.hpp:408
const type_t BTF_INT16
signed short
Definition typeinf.hpp:398
const type_t BTF_UINT64
unsigned long
Definition typeinf.hpp:405
const type_t BTF_BYTE
byte
Definition typeinf.hpp:389
const type_t BTF_UINT
unsigned int
Definition typeinf.hpp:411
const type_t BTF_UINT32
unsigned int
Definition typeinf.hpp:402
const type_t BTF_ENUM
enum
Definition typeinf.hpp:423
const type_t BTF_TYPEDEF
typedef
Definition typeinf.hpp:424
const type_t BTF_UCHAR
unsigned char
Definition typeinf.hpp:395
const type_t BTF_STRUCT
struct
Definition typeinf.hpp:421
const type_t BTF_VOID
void
Definition typeinf.hpp:391
const type_t BTF_CHAR
signed char
Definition typeinf.hpp:394
const type_t BTF_LDOUBLE
long double
Definition typeinf.hpp:418
const type_t BTF_TBYTE
see BTMT_SPECFLT
Definition typeinf.hpp:419
const type_t BTF_INT8
signed byte
Definition typeinf.hpp:393
const type_t BTF_INT
int, unknown signedness
Definition typeinf.hpp:410
const type_t BTF_INT128
signed 128-bit value
Definition typeinf.hpp:407
const type_t BTF_INT32
signed int
Definition typeinf.hpp:401
const type_t BTF_FLOAT
float
Definition typeinf.hpp:416
const type_t BTF_UINT8
unsigned byte
Definition typeinf.hpp:396
const type_t BTF_SINT
signed int
Definition typeinf.hpp:412
const type_t BTF_BOOL
boolean
Definition typeinf.hpp:414
const type_t BTMT_SIZE12
size = 1 byte if BT_VOID; 2 if BT_UNK
Definition typeinf.hpp:155
const type_t BT_UNK
unknown
Definition typeinf.hpp:152
const type_t BTMT_SIZE48
size = 4 bytes if BT_VOID; 8 if BT_UNK
Definition typeinf.hpp:156
const type_t BTMT_SIZE128
size = 16 bytes if BT_VOID; unknown if BT_UNK (IN struct alignment - see below)
Definition typeinf.hpp:157
const type_t BTMT_SIZE0
BT_VOID - normal void; BT_UNK - don't use
Definition typeinf.hpp:154
const type_t BT_VOID
void
Definition typeinf.hpp:153
const type_t BT_RESERVED
RESERVED.
Definition typeinf.hpp:332
idaman uint32 ida_export get_tid_ordinal(tid_t tid)
Get type ordinal number for TID.
idaman bool ida_export get_idainfo_by_udm(flags64_t *flags, opinfo_t *ti, const udm_t &udm, ea_t refinfo_ea=BADADDR)
Calculate IDA info from udt member.
idaman bool ida_export resolve_field_path(field_path_t *out, const til_t *til, const char *dotted_path)
Resolve a dotted field path like "Top.Field1.Field2.Leaf".
tid_t get_tid() const
Definition typeinf.hpp:6397
idaman tid_t ida_export get_named_type_tid(const char *name)
Get named local type TID.
idaman ssize_t ida_export get_udm_by_fullname(udm_t *udm, const char *fullname)
Get udt member by full name.
idaman bool ida_export get_tid_name(qstring *out, tid_t tid)
Get a type name for the specified TID.
tid_t create_enum_type(const char *enum_name, enum_type_data_t &ei, int enum_width, type_sign_t sign, bool convert_to_bitmask, const char *enum_cmt=nullptr)
Create type enum.
Definition typeinf.hpp:6444
bool del_vftable_ea(uint32 ordinal)
Delete the address of a vftable instance for a vftable type.
Definition typeinf.hpp:2657
idaman uint32 ida_export get_vftable_ordinal(ea_t vftable_ea)
Get ordinal number of the virtual function table.
idaman bool ida_export set_vftable_ea(uint32 ordinal, ea_t vftable_ea)
Set the address of a vftable instance for a vftable type.
idaman ea_t ida_export get_vftable_ea(uint32 ordinal)
Get address of a virtual function table.
cexpr_t * e
Definition hexrays.hpp:7705
const tinfo_t & type
Definition hexrays.hpp:7698
@ INF_H_PATH
C header path.
Definition ida.hpp:520
@ INF_C_MACROS
C predefined macros.
Definition ida.hpp:521
bool inf_big_arg_align(void)
Definition ida.hpp:982
uchar inf_get_cc_defalign()
Definition ida.hpp:1026
uint32 inf_get_abibits()
Definition ida.hpp:976
uchar inf_get_cc_size_e()
Definition ida.hpp:1023
qvector< callcnv_t > callcnvs_t
Definition ida.hpp:76
uchar cm_t
calling convention and memory model
Definition ida.hpp:74
callcnv_t inf_get_callcnv()
Definition ida.hpp:1014
uint32 callcnv_t
Definition ida.hpp:75
bool inf_is_64bit(void)
Definition ida.hpp:638
idaman ssize_t ida_export getinf_str(qstring *buf, inftag_t tag)
Get program specific information (a non-scalar value)
idaman bool ida_export setinf_buf(inftag_t tag, const void *buf, size_t bufsize=0)
Set program specific information.
uchar comp_t
target compiler id
Definition ida.hpp:73
bool inf_huge_arg_align(void)
Definition ida.hpp:996
bool inf_set_callcnv(callcnv_t _v)
Definition ida.hpp:1015
bool inf_pack_stkargs(void)
Definition ida.hpp:980
comp_t inf_get_cc_id()
Definition ida.hpp:1008
Contains definition of the interface to IDP modules.
qvector< reg_info_t > reginfovec_t
vector of register info objects
Definition idp.hpp:2966
int nbytes
Definition kernwin.hpp:3037
bool ok
Definition kernwin.hpp:7410
uval_t uval_t
Definition kernwin.hpp:1926
ssize_t rc
Definition kernwin.hpp:7505
qvector< uint32 > ordvec_t
Definition kernwin.hpp:1766
idaman size_t len
Definition kernwin.hpp:1389
asize_t size
Definition kernwin.hpp:6701
uint64 tif_cursor_t
A location in a tinfo_t.
Definition kernwin.hpp:1930
void(idaapi *range_marker)(ea_t ea
Pointer to range marker function (for idaviews and hexviews) This pointer is initialized by setup_ran...
bool result
Definition kernwin.hpp:8332
int idaapi til_tinfo_predicate_t(uint32 ord, const tinfo_t &type, void *ud)
Controls which types are displayed/selected when choosing a types from a library.
Definition kernwin.hpp:2165
cast_t token_t * ct
Definition lex.hpp:172
unsigned __int64 uint64
Definition llong.hpp:13
qvector< qstring > qstrvec_t
Definition lumina.hpp:831
idaman bool ida_export get_tinfo(tinfo_t *tif, ea_t ea)
uchar type_t
In serialized form, a type is represented by a byte sequence.
Definition nalt.hpp:1312
flags_t aflags_t
Definition nalt.hpp:288
uchar p_list
several p_string's
Definition nalt.hpp:1313
Functions that deal with names.
idaman size_t const char time_t t
Definition pro.h:606
unsigned short uint16
unsigned 16 bit value
Definition pro.h:350
int bool
Definition pro.h:333
unsigned int uint32
unsigned 32 bit value
Definition pro.h:352
qvector< int > intvec_t
vector of integers
Definition pro.h:2839
uint64 asize_t
Definition pro.h:427
constexpr T make_mask(int count)
Make a mask of 'count' bits.
Definition pro.h:1524
T align_up(T val, int elsize)
Align element up to nearest boundary.
Definition pro.h:4721
adiff_t sval_t
signed value used by the processor.
Definition pro.h:450
short int16
signed 16 bit value
Definition pro.h:349
int64 adiff_t
Definition pro.h:428
uint64 ea_t
Definition pro.h:425
int int32
signed 32 bit value
Definition pro.h:351
unsigned char uchar
unsigned 8 bit value
Definition pro.h:341
THREAD_SAFE void qswap(T &a, T &b)
Swap 2 objects of the same type using memory copies.
Definition pro.h:1728
idaman size_t bufsize
Definition pro.h:604
_qstring< uchar > qtype
type string
Definition pro.h:3772
unsigned int uint
unsigned 32 bit value
Definition pro.h:343
int error_t
Error code (errno)
Definition pro.h:462
qvector< ea_t > eavec_t
vector of addresses
Definition pro.h:2838
uint64 flags64_t
64-bit flags for each address
Definition pro.h:5106
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:385
unsigned short ushort
unsigned 16 bit value
Definition pro.h:342
T align_down(T val, int elsize)
Align element down to nearest boundary.
Definition pro.h:4731
void idaapi setflag(T &where, U bit, bool cnd)
Set a 'bit' in 'where' if 'value' is not zero.
Definition pro.h:1530
ea_t tid_t
type id (for enums, structs, etc)
Definition pro.h:5107
constexpr bool is_pow2(T val)
is power of 2? (or zero)
Definition pro.h:1435
_qstring< char > qstring
regular string
Definition pro.h:3771
idaman int ida_export log2ceil(uint64 d64)
calculate ceil(log2(d64)) or floor(log2(d64)), it returns 0 if d64 == 0
int compare(const T &a, const T &b)
Definition pro.h:4607
unsigned int
Definition pronet.h:99
void swap(qpair< F, S > &a, qpair< F, S > &b) noexcept(noexcept(a.swap(b)))
Definition qpair.hpp:78
Visit all argument locations.
Definition typeinf.hpp:1387
virtual ~aloc_visitor_t()
Definition typeinf.hpp:1389
virtual int idaapi visit_location(argloc_t &v, int off, int size)=0
Subsection of an argument location.
Definition typeinf.hpp:1317
bool operator<(const argpart_t &r) const
Compare two argparts, based on their offset.
Definition typeinf.hpp:1332
DEFINE_MEMORY_ALLOCATION_FUNCS() argpart_t(const argloc_t &a)
Constructor.
Definition typeinf.hpp:1320
argpart_t()
Constructor.
Definition typeinf.hpp:1322
ushort size
the number of bytes
Definition typeinf.hpp:1319
void swap(argpart_t &r)
Assign this = r and r = this.
Definition typeinf.hpp:1335
ushort off
offset from the beginning of the argument
Definition typeinf.hpp:1318
bool bad_size() const
Does this argpart have a valid size?
Definition typeinf.hpp:1329
bool bad_offset() const
Does this argpart have a valid offset?
Definition typeinf.hpp:1326
argpart_t & copy_from(const argloc_t &a)
Definition typeinf.hpp:1323
Definition typeinf.hpp:6207
virtual bool idaapi set_op_tinfo(const insn_t &insn, const op_t &x, const tinfo_t &tif, const char *name)=0
Set the operand type as specified.
virtual bool idaapi has_delay_slot(ea_t)
The call instruction with a delay slot?
Definition typeinf.hpp:6227
size_t reserved
Definition typeinf.hpp:6208
virtual ~argtinfo_helper_t()
Definition typeinf.hpp:6210
void use_arg_tinfos(ea_t caller, func_type_data_t *fti, funcargvec_t *rargs)
This function is to be called by the processor module in response to ev_use_arg_types.
Definition typeinf.hpp:6241
virtual bool idaapi is_stkarg_load(const insn_t &insn, int *src, int *dst)=0
Is the current insn a stkarg load?
Definition nalt.hpp:671
int32 flags
Definition nalt.hpp:672
Array type information (see tinfo_t::get_array_details())
Definition typeinf.hpp:4740
array_type_data_t(uint32 b=0, uint32 n=0)
Constructor.
Definition typeinf.hpp:4744
DEFINE_MEMORY_ALLOCATION_FUNCS() void swap(array_type_data_t &r)
set this = r and r = this
Definition typeinf.hpp:4745
uint32 nelems
number of elements
Definition typeinf.hpp:4743
tinfo_t elem_type
element type
Definition typeinf.hpp:4741
uint32 base
array base
Definition typeinf.hpp:4742
Bitfield type information (see tinfo_t::get_bitfield_details())
Definition typeinf.hpp:5684
void swap(bitfield_type_data_t &r)
Definition typeinf.hpp:5711
uchar nbytes
enclosing type size (1,2,4,8 bytes)
Definition typeinf.hpp:5685
uchar width
number of bits
Definition typeinf.hpp:5686
bool is_unsigned
is bitfield unsigned?
Definition typeinf.hpp:5687
DECLARE_COMPARISONS(bitfield_type_data_t)
Definition typeinf.hpp:5693
bool serialize(qtype *type, type_t mods) const
bool is_valid_bitfield() const
Definition typeinf.hpp:5712
bitfield_type_data_t(uchar _nbytes=0, uchar _width=0, bool _is_unsigned=false)
Definition typeinf.hpp:5688
Information about the target compiler.
Definition ida.hpp:80
comp_t id
compiler id (see Compiler IDs)
Definition ida.hpp:81
cm_t cm
memory model and calling convention (see CM) see also get_cc/set_cc
Definition ida.hpp:82
callcnv_t _new_callcnv
Definition ida.hpp:92
Same as aloc_visitor_t, but may not modify the argloc.
Definition typeinf.hpp:1397
virtual ~const_aloc_visitor_t()
Definition typeinf.hpp:1399
virtual int idaapi visit_location(const argloc_t &v, int off, int size)=0
Description of a custom argloc.
Definition typeinf.hpp:979
tinfo_t * elem_tif
Definition typeinf.hpp:1061
bool(idaapi *get_tinfo)(tinfo_t *out
Retrieve type of the object at 'loc'.
const char * name
name of the custom argloc type. must be unique
Definition typeinf.hpp:981
bool(idaapi *deref_array)(argloc_t *out
Dereference the array pointed by 'arrloc': take member number 'n' (element size is 'elsize'),...
tinfo_t const argloc_t const tinfo_t asize_t n
Definition typeinf.hpp:1024
size_t const argloc_t & loc
Definition typeinf.hpp:1003
tinfo_t const argloc_t const tinfo_t size_t len
Definition typeinf.hpp:1064
const idc_value_t const value_union_t int qstring * errbuf
Definition typeinf.hpp:1050
tinfo_t const argloc_t const tinfo_t & array_tif
Definition typeinf.hpp:1023
int const rangeset_t * gaps
Definition typeinf.hpp:993
asize_t(idaapi *guess_array_size)(const argloc_t &loc
Retrieve size of array at 'loc' (number of elements)
tinfo_t const argloc_t & strloc
Definition typeinf.hpp:1012
size_t(idaapi *print_ptr_value)(char *buf
Get string containing a printable representation of the pointer at 'loc'.
const idc_value_t & idcv
Definition typeinf.hpp:1047
const argloc_t & src
Definition typeinf.hpp:984
bool(idaapi *deref_field)(argloc_t *out
Dereference the struct/union pointed by 'strloc': take member at offset 'off' (or use the field name)...
size_t bool * is_valid_ptr
Definition typeinf.hpp:1086
tinfo_t const argloc_t & ptrloc
Definition typeinf.hpp:1032
void(idaapi *cleanup)(argloc_t *loc)
Clear contents of loc before it is modified (may be nullptr)
void(idaapi *copy)(argloc_t *empty_dst
Copy src into empty_dst.
tinfo_t * tif
Definition typeinf.hpp:1011
bool(idaapi *verify)(const argloc_t &loc
May be nullptr.
tinfo_t const argloc_t const tinfo_t asize_t off
Definition typeinf.hpp:1014
const tinfo_t & string_tif
Definition typeinf.hpp:1055
int size
Definition typeinf.hpp:992
size_t bufsize
Definition typeinf.hpp:1002
asize_t(idaapi *calc_string_length)(const argloc_t &loc
Calc max natural string length at 'loc' in the debugged process memory.
bool(idaapi *write_value)(const argloc_t &loc
Update value at 'loc'.
size_t cbsize
size of this structure
Definition typeinf.hpp:980
size_t const argloc_t asize_t int praloc_flags
Definition typeinf.hpp:1005
int(idaapi *calc_number_of_children)(const argloc_t &loc
Calculate the number of children for the given location.
bool(idaapi *read_value)(value_union_t *value
Read the pointer at 'loc': retrieve value of a simple object.
bool(idaapi *get_string)(qstring *out
Retrieve string at 'loc' from the debugged process memory, returns quoted string value.
int const rangeset_t bool part_of_scattered
Definition typeinf.hpp:994
tinfo_t const argloc_t & arrloc
Definition typeinf.hpp:1022
tinfo_t const argloc_t const tinfo_t & struct_tif
Definition typeinf.hpp:1013
const idc_value_t const value_union_t & scalar_value
Definition typeinf.hpp:1048
const argloc_t & b
Definition typeinf.hpp:997
size_t(idaapi *print)(char *buf
Get textual description of the location (not the value at the location!)
tinfo_t const argloc_t const tinfo_t asize_t asize_t elsize
Definition typeinf.hpp:1025
bool(idaapi *deref_ptr)(argloc_t *out
Dereference the pointer at 'loc': retrieve location of the pointed object, improve 'tif' of the point...
Description of a custom calling convention.
Definition typeinf.hpp:1553
virtual ssize_t find_varargs(func_type_data_t *fti, ea_t call_ea, class mblock_t *blk) const
Discover variadic arguments.
Definition typeinf.hpp:1602
virtual bool calc_retloc(func_type_data_t *fti) const =0
Calculate the location of the return value.
uint32 abibits
abibits to be used for the calling convention
Definition typeinf.hpp:1560
int cbsize
Definition typeinf.hpp:1554
bool is_purging() const
Definition typeinf.hpp:1563
virtual bool calc_arglocs(func_type_data_t *fti) const =0
Calculate the argument locations.
DECLARE_COMPARISONS(custom_callcnv_t)
custom_callcnv_t(const char *_name, uint64 f, uint32 _abibits)
Definition typeinf.hpp:1682
uint64 flags
Definition typeinf.hpp:1555
bool is_vararg() const
Definition typeinf.hpp:1562
virtual bool get_cc_regs(callregs_t *out) const
Retrieve generic information about call registers.
Definition typeinf.hpp:1635
virtual int lower_func_type(func_type_data_t *fti) const
Lower a function type.
Definition typeinf.hpp:1675
virtual int calc_purged_bytes(const func_type_data_t &fti, ea_t call_ea=BADADDR) const
Calculate the number of purged bytes.
Definition typeinf.hpp:1651
virtual bool calc_varglocs(func_type_data_t *fti, regobjs_t *regs, relobj_t *stkargs, int nfixed) const
Calculate the argument locations for a variadic function.
Definition typeinf.hpp:1621
qstring name
the name is used as a keyword in the function prototype
Definition typeinf.hpp:1559
custom_callcnv_t()=default
virtual bool validate_func(const func_type_data_t &fti, qstring *reterr) const
Validate a function prototype.
Definition typeinf.hpp:1572
virtual bool get_stkarg_area_info(stkarg_area_info_t *out) const
Retrieve generic information about stack arguments.
Definition typeinf.hpp:1642
virtual ~custom_callcnv_t()
Definition typeinf.hpp:1685
bool is_usercall() const
Definition typeinf.hpp:1564
Definition typeinf.hpp:5287
int16 fid
data format ids
Definition typeinf.hpp:5289
int16 dtid
data type id
Definition typeinf.hpp:5288
This structure describes an enum value.
Definition typeinf.hpp:4941
qstring name
Definition typeinf.hpp:4942
edm_t(const char *_name, uint64 _value, const char *_cmt=nullptr)
Create an enumeration value with the specified name and value.
Definition typeinf.hpp:4953
bool empty() const
Definition typeinf.hpp:4957
uint64 value
Definition typeinf.hpp:4944
void swap(edm_t &r)
Definition typeinf.hpp:4966
qstring cmt
Definition typeinf.hpp:4943
edm_t()=default
bool operator==(const edm_t &r) const
Definition typeinf.hpp:4959
bool operator!=(const edm_t &r) const
Definition typeinf.hpp:4965
Enum type information (see tinfo_t::get_enum_details())
Definition typeinf.hpp:4981
enum_type_data_t(bte_t _bte=BTE_ALWAYS|BTE_HEX)
Definition typeinf.hpp:4987
bool is_bin() const
Definition typeinf.hpp:5036
bool is_soct() const
Definition typeinf.hpp:5039
int for_all_groups(std::function< int(size_t grp_start, int grp_size)> v, bool skip_trivial=false) const
visit all enum groups, for bitmask enum only
Definition typeinf.hpp:5227
bool has_lzero() const
Definition typeinf.hpp:5042
bool is_sbin() const
Definition typeinf.hpp:5040
bool is_bf() const
is bitmask or ordinary enum?
Definition typeinf.hpp:5049
bte_t bte
enum member sizes (shift amount) and style.
Definition typeinf.hpp:4985
bool is_udec() const
Definition typeinf.hpp:5037
void add_constant(const char *name, uint64 value, const char *cmt=nullptr)
add constant for regular enum
Definition typeinf.hpp:5159
uchar get_serial(size_t index) const
returns serial for the constant
Definition typeinf.hpp:5176
bool is_char() const
Definition typeinf.hpp:5032
bool is_oct() const
Definition typeinf.hpp:5035
bool get_constant_group(size_t *group_start_index, size_t *group_size, size_t idx) const
get group parameters for the constant, valid for bitmask enum
Definition typeinf.hpp:5074
void set_lzero(bool on)
Definition typeinf.hpp:5043
bool set_nbytes(int nbytes)
set enum width (nbytes)
Definition typeinf.hpp:5058
intvec_t group_sizes
if present, specifies bitmask group sizes each non-trivial group starts with a mask member
Definition typeinf.hpp:4982
bool is_group_mask_at(size_t idx) const
is the enum member at IDX a non-trivial group mask?
Definition typeinf.hpp:5100
DEFINE_MEMORY_ALLOCATION_FUNCS() int get_enum_radix() const
Get enum constant radix.
Definition typeinf.hpp:4988
int for_all_constants(std::function< int(size_t idx, size_t grp_start, int grp_size)> v) const
visit all enum constants not bmasks
Definition typeinf.hpp:5194
bool is_shex() const
Definition typeinf.hpp:5038
tinfo_code_t set_value_repr(const value_repr_t &repr)
set enum radix and other representation info
Definition typeinf.hpp:5173
ssize_t find_member(uint64 value, uchar serial, size_t from=0, size_t to=size_t(-1), uint64 vmask=uint64(-1)) const
find member (constant or bmask) by value
Definition typeinf.hpp:5139
bool is_valid_group_sizes() const
is valid group sizes
Definition typeinf.hpp:5109
bool is_dec() const
Definition typeinf.hpp:5033
bool store_64bit_values() const
Definition typeinf.hpp:5046
void set_enum_radix(int radix, bool sign)
Set radix to display constants.
Definition typeinf.hpp:5019
bool is_number_signed() const
Definition typeinf.hpp:5011
int calc_nbytes() const
get the width of enum in bytes
Definition typeinf.hpp:5052
uint32 taenum_bits
Type attributes for enums
Definition typeinf.hpp:4984
bool is_hex() const
Definition typeinf.hpp:5034
tinfo_code_t get_value_repr(value_repr_t *repr) const
get enum radix and other representation info
Definition typeinf.hpp:5169
ssize_t find_member(const char *name, size_t from=0, size_t to=size_t(-1)) const
find member (constant or bmask) by name
Definition typeinf.hpp:5126
uint64 calc_mask() const
Definition typeinf.hpp:5045
void swap(enum_type_data_t &r)
swap two instances
Definition typeinf.hpp:5156
uchar get_max_serial(uint64 value) const
return the maximum serial for the value
Definition typeinf.hpp:5190
Result of resolve_field_path(): resolved leaf info plus disambiguation context.
Definition typeinf.hpp:6361
qvector< tid_t > stroff_path
ready-to-use op_stroff() path: top_tif's TID at [0], followed by one member TID per union descent (in...
Definition typeinf.hpp:6367
tinfo_t leaf_tif
type of the leaf member (== top_tif if path is just a type name)
Definition typeinf.hpp:6363
uint64 cumul_bitoff
cumulative bit offset of the leaf member from top of top_tif
Definition typeinf.hpp:6366
tinfo_t top_tif
top-level type (after resolving first segment)
Definition typeinf.hpp:6362
tid_t leaf_udm_tid
TID of the leaf member, or BADADDR if path is just a type name (no member at the end of the path)
Definition typeinf.hpp:6364
See format_cdata()
Definition typeinf.hpp:6475
format_data_info_t()
Definition typeinf.hpp:6513
int arrnelems
for arrays: number of elements to print
Definition typeinf.hpp:6506
int ptvf
Definition typeinf.hpp:6476
int indent
how many spaces to use to indent nested structures/arrays
Definition typeinf.hpp:6511
int max_length
max length of the formatted text (0 means no limit) should be used to format huge arrays for the scre...
Definition typeinf.hpp:6500
int arrbase
for arrays: the first element of array to print
Definition typeinf.hpp:6505
int margin
length of one line (0 means to print everything on one line) if an item cannot be printed in a shorte...
Definition typeinf.hpp:6507
int radix
number representation (8,10,16)
Definition typeinf.hpp:6499
Function type information (see tinfo_t::get_func_details())
Definition typeinf.hpp:4829
bool is_noret() const
Definition typeinf.hpp:4876
bool is_pure() const
Definition typeinf.hpp:4877
bool is_vararg_cc() const
Definition typeinf.hpp:4887
callcnv_t _new_callcnv
Definition typeinf.hpp:4863
bool is_swiftthrows() const
Definition typeinf.hpp:4885
bool is_ctor() const
Definition typeinf.hpp:4881
uval_t stkargs
size of stack arguments (not used in build_func_type)
Definition typeinf.hpp:4866
bool is_synchronized() const
Definition typeinf.hpp:4883
void set_cc(callcnv_t cc)
Definition typeinf.hpp:4873
bool is_high() const
Definition typeinf.hpp:4875
callcnv_t get_cc() const
Definition typeinf.hpp:4872
bool is_user_cc() const
Definition typeinf.hpp:4891
int flags
Function type data property bits
Definition typeinf.hpp:4830
bool is_static() const
Definition typeinf.hpp:4878
bool is_virtual() const
Definition typeinf.hpp:4879
callcnv_t guess_cc(int purged, int cc_flags) const
Guess function calling convention use the following info: argument locations and 'stkargs'.
Definition typeinf.hpp:4895
ssize_t find_argument(const char *name, size_t from=0, size_t to=size_t(-1)) const
find argument by name
Definition typeinf.hpp:4913
int get_call_method() const
Definition typeinf.hpp:4886
bool is_swift_cc() const
Definition typeinf.hpp:4890
reginfovec_t spoiled
spoiled register information.
Definition typeinf.hpp:4867
argloc_t retloc
return location
Definition typeinf.hpp:4865
bool is_const() const
Definition typeinf.hpp:4880
bool is_dtor() const
Definition typeinf.hpp:4882
bool is_swiftasync() const
Definition typeinf.hpp:4884
cm_t _old_cc
Definition typeinf.hpp:4870
void swap(func_type_data_t &r)
Definition typeinf.hpp:4874
bool is_rust_cc() const
Definition typeinf.hpp:4889
bool dump(qstring *out, int praloc_bits=PRALOC_STKOFF) const
Dump information that is not always visible in the function prototype.
Definition typeinf.hpp:4907
bool is_golang_cc() const
Definition typeinf.hpp:4888
tinfo_t rettype
return type
Definition typeinf.hpp:4864
callcnv_t get_explicit_cc() const
Definition typeinf.hpp:4871
Information about a single function argument.
Definition typeinf.hpp:4753
tinfo_t type
argument type
Definition typeinf.hpp:4757
argloc_t argloc
argument location
Definition typeinf.hpp:4754
qstring cmt
argument comment (may be empty)
Definition typeinf.hpp:4756
bool operator!=(const funcarg_t &r) const
Definition typeinf.hpp:4821
qstring name
argument name (may be empty)
Definition typeinf.hpp:4755
funcarg_t()=default
bool is_swiftself() const
Definition typeinf.hpp:4777
funcarg_t(const char *_name, const char *_type, const argloc_t &_argloc=argloc_t())
Create a function argument, with the specified name and type.
Definition typeinf.hpp:4808
uint32 flags
Function argument property bits
Definition typeinf.hpp:4758
funcarg_t(const char *_name, const tinfo_t &_type, const argloc_t &_argloc=argloc_t())
Create a function argument, with the specified name and arbitrary type.
Definition typeinf.hpp:4784
bool operator==(const funcarg_t &r) const
Definition typeinf.hpp:4814
funcarg_t(const char *_name, const type_t _type, const argloc_t &_argloc=argloc_t())
Create a function argument, with the specified name and simple type.
Definition typeinf.hpp:4795
Helper class for choose_named_type().
Definition typeinf.hpp:6709
virtual bool idaapi should_display(const til_t *til, const char *name, const type_t *type, const p_list *fields)=0
virtual ~predicate_t()
Definition typeinf.hpp:6715
@ ev_decorate_name
Decorate/undecorate a C symbol name.
Definition idp.hpp:1868
@ ev_equal_reglocs
Are 2 register arglocs the same?
Definition idp.hpp:1825
static ssize_t equal_reglocs(const argloc_t &a1, const argloc_t &a2)
Definition typeinf.hpp:6768
static ssize_t notify(event_t event_code,...)
Definition idp.hpp:1927
static ssize_t get_cc_regs(callregs_t *regs, callcnv_t cc)
Definition idp.hpp:2851
static ssize_t _decorate_name(qstring *outbuf, const char *name, bool mangle, callcnv_t cc, const tinfo_t &type)
Definition typeinf.hpp:6777
Pointer type information (see tinfo_t::get_ptr_details())
Definition typeinf.hpp:4710
bool operator!=(const ptr_type_data_t &r) const
Definition typeinf.hpp:4731
uchar based_ptr_size
Definition typeinf.hpp:4715
int32 delta
Offset from the beginning of the parent struct.
Definition typeinf.hpp:4714
bool operator==(const ptr_type_data_t &r) const
Definition typeinf.hpp:4725
bool is_shifted() const
Definition typeinf.hpp:4733
uchar taptr_bits
TAH bits.
Definition typeinf.hpp:4716
tinfo_t obj_type
pointed object type
Definition typeinf.hpp:4711
DEFINE_MEMORY_ALLOCATION_FUNCS() void swap(ptr_type_data_t &r)
Set this = r and r = this.
Definition typeinf.hpp:4723
tinfo_t closure
cannot have both closure and based_ptr_size
Definition typeinf.hpp:4712
ptr_type_data_t(tinfo_t c=tinfo_t(), uchar bps=0, tinfo_t p=tinfo_t(), int32 d=0)
Definition typeinf.hpp:4717
tinfo_t parent
Parent struct.
Definition typeinf.hpp:4713
bool is_code_ptr() const
Are we pointing to code?
Definition typeinf.hpp:4732
Definition range.hpp:328
ea_t start_ea
start_ea included
Definition range.hpp:37
Information about a reference.
Definition nalt.hpp:1001
Object that represents a register.
Definition typeinf.hpp:6124
bytevec_t value
Definition typeinf.hpp:6127
size_t size() const
Definition typeinf.hpp:6128
int regidx
index into dbg->registers
Definition typeinf.hpp:6125
int relocate
0-plain num, 1-must relocate
Definition typeinf.hpp:6126
Definition typeinf.hpp:6133
Relocatable object.
Definition pro.h:4103
Register-relative argument location.
Definition typeinf.hpp:969
sval_t off
displacement from the address pointed by the register
Definition typeinf.hpp:970
int reg
register index (into ph.reg_names)
Definition typeinf.hpp:971
SIMD type info.
Definition typeinf.hpp:4638
uint16 size
SIMD type size in bytes (0-undefined, 0xFFFF-variadic)
Definition typeinf.hpp:4643
static constexpr uint16 SIMD_VARIADIC
Definition typeinf.hpp:4639
bool is_variadic() const
Definition typeinf.hpp:4656
bool operator!=(const simd_info_t &r) const
Definition typeinf.hpp:4683
type_t memtype
member type BTF_INT8/16/32/64/128, BTF_UINT8/16/32/64/128 BTF_INT - integrals of any size/sign BTF_FL...
Definition typeinf.hpp:4644
const char * name
name of SIMD type (nullptr-undefined)
Definition typeinf.hpp:4641
tinfo_t tif
SIMD type (empty-undefined)
Definition typeinf.hpp:4642
bool operator==(const simd_info_t &r) const
Definition typeinf.hpp:4675
bool match_pattern(const simd_info_t *pattern)
Definition typeinf.hpp:4658
simd_info_t(const char *nm=nullptr, uint16 sz=0, type_t memt=BTF_UNK)
Definition typeinf.hpp:4653
Definition typeinf.hpp:4686
Definition typeinf.hpp:1528
size_t cb
Definition typeinf.hpp:1529
bool get_info(callcnv_t cc)
Definition typeinf.hpp:1547
sval_t shadow_size
Size of the shadow area.
Definition typeinf.hpp:1538
sval_t linkage_area
Size of the linkage area.
Definition typeinf.hpp:1543
sval_t stkarg_offset
Offset from the SP to the first stack argument (can include linkage area) examples: pc: 0,...
Definition typeinf.hpp:1533
stkarg_area_info_t()=default
stkarg_area_info_t(callcnv_t cc)
Definition typeinf.hpp:1546
A single stkarg-store action returned by processor_t::get_stkarg_parts.
Definition typeinf.hpp:6197
int dst
destination operand index, or -1 for push semantics
Definition typeinf.hpp:6199
int src
source operand index in \insn_t{ops}
Definition typeinf.hpp:6198
sval_t off
when dst != -1, stack offset for this part (used in place of \insn_t{ops}[dst].addr); ignored for pus...
Definition typeinf.hpp:6200
Flush formatted text.
Definition typeinf.hpp:6609
virtual int idaapi print(const char *str)=0
virtual ~text_sink_t()
Definition typeinf.hpp:6610
A symbol in a type library.
Definition typeinf.hpp:6697
const til_t * til
pointer to til
Definition typeinf.hpp:6699
til_symbol_t(const char *n=nullptr, const til_t *t=nullptr)
Definition typeinf.hpp:6700
const char * name
symbol name
Definition typeinf.hpp:6698
Type Information Library.
Definition typeinf.hpp:728
uint32 flags
Type info library property bits
Definition typeinf.hpp:733
char * desc
human readable til description
Definition typeinf.hpp:730
compiler_info_t cc
information about the target compiler
Definition typeinf.hpp:767
til_stream_t ** streams
symbol stream storage
Definition typeinf.hpp:773
void set_dirty()
Mark the til as modified (TIL_MOD)
Definition typeinf.hpp:751
til_t * find_base(const char *n)
Find the base til with the provided name.
Definition typeinf.hpp:756
til_bucket_t * types
types
Definition typeinf.hpp:769
bool is_dirty() const
Has the til been modified? (TIL_MOD)
Definition typeinf.hpp:749
til_t ** base
tils that our til is based on
Definition typeinf.hpp:732
til_bucket_t * macros
macros
Definition typeinf.hpp:770
int nstreams
number of extra streams
Definition typeinf.hpp:772
char * name
short file name (without path and extension)
Definition typeinf.hpp:729
int nbases
number of base tils
Definition typeinf.hpp:731
til_bucket_t * syms
symbols
Definition typeinf.hpp:768
int nrefs
number of references to the til
Definition typeinf.hpp:771
Definition typeinf.hpp:6805
bool is_writable
Definition typeinf.hpp:6810
tif_cursor_t cursor
Definition typeinf.hpp:6808
bool is_detached
Definition typeinf.hpp:6811
udm_t udm
BTF_STRUCT or BTF_UNION: the current member.
Definition typeinf.hpp:6818
uint32 ordinal
Definition typeinf.hpp:6809
bool is_func() const
Definition typeinf.hpp:6840
size_t unpadded_size
Definition typeinf.hpp:6820
const funcarg_t * fa
BT_FUNC: the current argument, nullptr - ellipsis.
Definition typeinf.hpp:6832
bool is_enum() const
Definition typeinf.hpp:6839
type_t kind
Definition typeinf.hpp:6813
size_t total_size
Definition typeinf.hpp:6819
uint64 last_udm_offset
Definition typeinf.hpp:6821
bool is_forward
Definition typeinf.hpp:6812
bool is_union() const
Definition typeinf.hpp:6838
uint64 bucket_start
Definition typeinf.hpp:6822
uint64 offset
Definition typeinf.hpp:6824
void clear()
Definition typeinf.hpp:6834
int bf_bitoff
Definition typeinf.hpp:6823
tinfo_t tif
Definition typeinf.hpp:6807
bool on_member() const
Definition typeinf.hpp:6835
bool is_udt() const
Definition typeinf.hpp:6841
size_t cb
Definition typeinf.hpp:6806
bool is_struct() const
Definition typeinf.hpp:6837
size_t nmembers
Definition typeinf.hpp:6815
ssize_t memidx
Definition typeinf.hpp:6814
edm_t edm
BTF_ENUM: the current enum member.
Definition typeinf.hpp:6829
bool is_typedef() const
Definition typeinf.hpp:6836
virtual ~tinfo_visitor_t()
Definition typeinf.hpp:6094
virtual int idaapi visit_type(type_mods_t *out, const tinfo_t &tif, const char *name, const char *cmt)=0
Visit a subtype.
tinfo_visitor_t(int s=0)
Definition typeinf.hpp:6092
int apply_to(const tinfo_t &tif, type_mods_t *out=nullptr, const char *name=nullptr, const char *cmt=nullptr)
Call this function to initiate the traversal.
Definition typeinf.hpp:6112
int state
tinfo visitor states
Definition typeinf.hpp:6083
int level
Definition typeinf.hpp:6091
void prune_now()
To refuse to visit children of the current type, use this:
Definition typeinf.hpp:6109
Definition typeinf.hpp:652
qstring key
one-symbol keys are reserved to be used by the kernel the ones starting with an underscore are reserv...
Definition typeinf.hpp:653
bytevec_t value
attribute bytes
Definition typeinf.hpp:663
bool operator>=(const type_attr_t &r) const
Definition typeinf.hpp:665
bool operator<(const type_attr_t &r) const
Definition typeinf.hpp:664
Information about how to modify the current type, used by tinfo_visitor_t.
Definition typeinf.hpp:6046
bool has_name() const
Definition typeinf.hpp:6074
bool is_rptcmt() const
Definition typeinf.hpp:6076
bool has_type() const
Definition typeinf.hpp:6073
bool has_info() const
Definition typeinf.hpp:6077
qstring name
current type name
Definition typeinf.hpp:6048
tinfo_t type
current type
Definition typeinf.hpp:6047
int flags
Type modification bits
Definition typeinf.hpp:6050
bool has_cmt() const
Definition typeinf.hpp:6075
void set_new_cmt(const qstring &c, bool rptcmt)
Definition typeinf.hpp:6066
qstring cmt
comment for current type
Definition typeinf.hpp:6049
void clear()
Definition typeinf.hpp:6059
void set_new_name(const qstring &n)
Definition typeinf.hpp:6065
void set_new_type(const tinfo_t &t)
The visit_type() function may optionally save the modified type info.
Definition typeinf.hpp:6064
Type information for typedefs.
Definition typeinf.hpp:5257
bool resolve
should resolve immediately?
Definition typeinf.hpp:5265
DEFINE_MEMORY_ALLOCATION_FUNCS() void swap(typedef_type_data_t &r)
Definition typeinf.hpp:5279
uint32 ordinal
is_ordref=true: type ordinal number
Definition typeinf.hpp:5262
typedef_type_data_t(const til_t *_til, const char *_name, bool _resolve=false)
Definition typeinf.hpp:5266
const char * name
is_ordref=false: target type name. we do not own this pointer!
Definition typeinf.hpp:5261
typedef_type_data_t(const til_t *_til, uint32 ord, bool _resolve=false)
Definition typeinf.hpp:5272
bool is_ordref
is reference by ordinal?
Definition typeinf.hpp:5264
const til_t * til
type library to use when resolving
Definition typeinf.hpp:5258
An object to represent struct or union members.
Definition typeinf.hpp:5393
void set_unaligned(bool on=true)
Definition typeinf.hpp:5474
bool is_zero_bitfield() const
Definition typeinf.hpp:5461
bool is_method() const
Definition typeinf.hpp:5466
void clr_virtbase()
Definition typeinf.hpp:5485
bool is_gap() const
Definition typeinf.hpp:5467
qstring cmt
member comment
Definition typeinf.hpp:5397
bool operator==(const udm_t &r) const
Definition typeinf.hpp:5494
bool is_retaddr() const
Definition typeinf.hpp:5469
bool is_unaligned() const
Definition typeinf.hpp:5462
void clr_unaligned()
Definition typeinf.hpp:5483
void set_savregs(bool on=true)
Definition typeinf.hpp:5481
void clr_vftable()
Definition typeinf.hpp:5486
bool compare_with(const udm_t &r, int tcflags) const
Definition typeinf.hpp:5498
udm_t(const char *_name, const type_t _type, uint64 _offset=0)
Create a structure/union member, with the specified name and simple type.
Definition typeinf.hpp:5431
uint32 tafld_bits
TAH bits.
Definition typeinf.hpp:5401
bool operator!=(const udm_t &r) const
Definition typeinf.hpp:5503
void clr_baseclass()
Definition typeinf.hpp:5484
uint64 end() const
Definition typeinf.hpp:5489
bool can_rename() const
Definition typeinf.hpp:5518
bool is_savregs() const
Definition typeinf.hpp:5470
bool operator<(const udm_t &r) const
Definition typeinf.hpp:5490
uint64 begin() const
Definition typeinf.hpp:5488
void set_vftable(bool on=true)
Definition typeinf.hpp:5477
bool is_vftable() const
Definition typeinf.hpp:5465
void set_retaddr(bool on=true)
Definition typeinf.hpp:5480
bool is_baseclass() const
Definition typeinf.hpp:5463
int effalign
effective field alignment (in bytes)
Definition typeinf.hpp:5400
uint64 offset
member offset in bits
Definition typeinf.hpp:5394
void set_baseclass(bool on=true)
Definition typeinf.hpp:5475
bool can_be_dtor() const
Definition typeinf.hpp:5517
udm_t()=default
bool is_by_til() const
Definition typeinf.hpp:5472
uint64 size
size in bits
Definition typeinf.hpp:5395
bool is_special_member() const
Definition typeinf.hpp:5471
udm_t(const char *_name, const tinfo_t &_type, uint64 _offset=0)
Create a structure/union member, with the specified name and arbitrary type.
Definition typeinf.hpp:5415
bool is_anonymous_udm() const
Definition typeinf.hpp:5511
uchar fda
field alignment (shift amount)
Definition typeinf.hpp:5402
void set_method(bool on=true)
Definition typeinf.hpp:5478
void clr_method()
Definition typeinf.hpp:5487
DEFINE_MEMORY_ALLOCATION_FUNCS() void swap(udm_t &r)
Definition typeinf.hpp:5505
value_repr_t repr
radix, refinfo, strpath, custom_id, strtype
Definition typeinf.hpp:5399
bool is_regcmt() const
Definition typeinf.hpp:5468
qstring name
member name
Definition typeinf.hpp:5396
void set_virtbase(bool on=true)
Definition typeinf.hpp:5476
tinfo_t type
member type
Definition typeinf.hpp:5398
void set_value_repr(const value_repr_t &r)
Definition typeinf.hpp:5516
void set_by_til(bool on=true)
Definition typeinf.hpp:5482
udm_t(const char *_name, const char *_type, uint64 _offset=0)
Create a structure/union member, with the specified name and type.
Definition typeinf.hpp:5450
void set_regcmt(bool on=true)
Definition typeinf.hpp:5479
bool empty() const
Definition typeinf.hpp:5458
bool is_bitfield() const
Definition typeinf.hpp:5460
bool is_virtbase() const
Definition typeinf.hpp:5464
Definition typeinf.hpp:5652
virtual int idaapi visit_udm(tid_t tid, const tinfo_t *tif, const udt_type_data_t *udt, ssize_t idx)=0
virtual ~udm_visitor_t()
Definition typeinf.hpp:5662
Definition typeinf.hpp:5528
ssize_t find_member(const char *name) const
Definition typeinf.hpp:5583
bool is_vftable() const
Definition typeinf.hpp:5544
void swap(udt_type_data_t &r)
Definition typeinf.hpp:5539
bool is_iface() const
Definition typeinf.hpp:5547
uchar pack
pragma pack() alignment (shift amount)
Definition typeinf.hpp:5536
bool is_tuple() const
Definition typeinf.hpp:5546
ssize_t get_best_fit_member(asize_t disp) const
Get the member that is most likely referenced by the specified offset.
Definition typeinf.hpp:5599
bool deduplicate_members()
Rename members with the same names.
Definition typeinf.hpp:5612
uchar sda
declared structure alignment (shift amount+1). 0 - unspecified
Definition typeinf.hpp:5535
ssize_t find_member(udm_t *pattern_udm, int strmem_flags) const
tinfo_t::find_udm
Definition typeinf.hpp:5581
static constexpr int VERSION
Definition typeinf.hpp:5529
udm_t & add_member(const char *_name, const tinfo_t &_type, uint64 _offset=0)
Add a new member to a structure or union.
Definition typeinf.hpp:5568
uint32 taudt_bits
TA... and TAUDT... bits.
Definition typeinf.hpp:5533
bool is_union
is union or struct?
Definition typeinf.hpp:5537
bool is_last_baseclass(size_t idx)
Definition typeinf.hpp:5554
bool is_cppobj() const
Definition typeinf.hpp:5543
void set_iface(bool on=true)
Definition typeinf.hpp:5552
bool is_fixed() const
Definition typeinf.hpp:5545
uint32 effalign
effective structure alignment (in bytes)
Definition typeinf.hpp:5532
void set_fixed(bool on=true)
Definition typeinf.hpp:5550
void set_tuple(bool on=true)
Definition typeinf.hpp:5551
bool is_msstruct() const
Definition typeinf.hpp:5542
DEFINE_MEMORY_ALLOCATION_FUNCS() bool is_unaligned() const
Definition typeinf.hpp:5540
void set_vftable(bool on=true)
Definition typeinf.hpp:5549
uchar version
version of udt_type_data_t
Definition typeinf.hpp:5534
size_t unpadded_size
unpadded structure size in bytes
Definition typeinf.hpp:5531
size_t total_size
total structure size in bytes
Definition typeinf.hpp:5530
ssize_t find_member(uint64 bit_offset) const
Definition typeinf.hpp:5590
vector of udt member objects
Definition typeinf.hpp:5525
Additional information about the output lines.
Definition typeinf.hpp:6521
void swap(valinfo_t &r)
Definition typeinf.hpp:6527
qstring label
Definition typeinf.hpp:6523
argloc_t loc
Definition typeinf.hpp:6522
tinfo_t type
Definition typeinf.hpp:6524
valinfo_t(argloc_t l=argloc_t(), const char *name=nullptr, const tinfo_t &tif=tinfo_t())
Definition typeinf.hpp:6525
Collection of value strings.
Definition typeinf.hpp:6582
Visual representation of a member of a complex type (struct/union/enum)
Definition typeinf.hpp:5294
bool is_offset() const
Definition typeinf.hpp:5339
void set_lzeroes(bool on)
Definition typeinf.hpp:5352
bool is_custom() const
Definition typeinf.hpp:5341
uint64 bits
Definition typeinf.hpp:5295
refinfo_t ri
FRB_OFFSET.
Definition typeinf.hpp:5319
bool is_enum() const
Definition typeinf.hpp:5338
uint32 type_ordinal
FRB_STROFF, FRB_ENUM.
Definition typeinf.hpp:5324
bool empty() const
Definition typeinf.hpp:5337
DEFINE_MEMORY_ALLOCATION_FUNCS() void clear()
Definition typeinf.hpp:5333
array_parameters_t ap
FRB_TABFORM, AP_SIGNED is ignored, use FRB_SIGNED instead.
Definition typeinf.hpp:5328
void swap(value_repr_t &r)
Definition typeinf.hpp:5332
bool is_typref() const
Definition typeinf.hpp:5343
uint64 get_vtype() const
Definition typeinf.hpp:5348
bool parse_value_repr(const qstring &attr, type_t target_type=BTF_STRUCT)
Definition typeinf.hpp:5379
DECLARE_COMPARISONS(value_repr_t)
adiff_t delta
FRB_STROFF.
Definition typeinf.hpp:5323
bool has_tabform() const
Definition typeinf.hpp:5345
bool from_opinfo(flags64_t flags, aflags_t afl, const opinfo_t *opinfo, const array_parameters_t *_ap)
Definition typeinf.hpp:5371
void init_ap(array_parameters_t *_ap) const
Definition typeinf.hpp:5361
void set_vtype(uint64 vt)
Definition typeinf.hpp:5349
int32 strtype
FRB_STRLIT.
Definition typeinf.hpp:5320
custom_data_type_info_t cd
FRB_CUSTOM.
Definition typeinf.hpp:5326
size_t print(qstring *result, bool colored=false) const
Definition typeinf.hpp:5375
bool is_signed() const
Definition typeinf.hpp:5344
bool has_lzeroes() const
Definition typeinf.hpp:5346
bool is_stroff() const
Definition typeinf.hpp:5342
bool is_strlit() const
Definition typeinf.hpp:5340
void set_tabform(bool on)
Definition typeinf.hpp:5351
void set_ap(const array_parameters_t &_ap)
Definition typeinf.hpp:5354
void set_signed(bool on)
Definition typeinf.hpp:5350
THREAD_SAFE bool is_type_uint32(type_t t)
See BTF_UINT32.
Definition typeinf.hpp:525
THREAD_SAFE bool is_type_ext_arithmetic(type_t t)
Is the type an extended arithmetic type? (arithmetic or enum)
Definition typeinf.hpp:520
THREAD_SAFE type_t get_base_type(type_t t)
Get basic type bits (TYPE_BASE_MASK)
Definition typeinf.hpp:435
idaman int ida_export calc_number_of_children(const argloc_t &loc, const tinfo_t &tif, bool dont_deref_ptr=false)
Calculate max number of lines of a formatted c data, when expanded (PTV_EXPAND).
idaman bool ida_export extract_argloc(argloc_t *vloc, const type_t **ptype, bool forbid_stkoff)
Deserialize an argument location.
THREAD_SAFE type_t get_full_type(type_t t)
Get basic type bits + type flags (TYPE_FULL_MASK)
Definition typeinf.hpp:437
idaman bool ida_export apply_named_type(ea_t ea, const char *name)
Apply the specified named type to the address.
idaman bool ida_export get_idainfo_by_type(size_t *out_size, flags64_t *out_flags, opinfo_t *out_mt, const tinfo_t &tif, size_t *out_alsize=nullptr)
Extract information from a tinfo_t.
THREAD_SAFE bool is_type_int16(type_t t)
Does the type specify a 16-bit value? (signed or unsigned, see Basic type: integer)
Definition typeinf.hpp:489
THREAD_SAFE bool is_type_func(type_t t)
See BT_FUNC.
Definition typeinf.hpp:451
idaman error_t ida_export pack_idcobj_to_idb(const idc_value_t *obj, const tinfo_t &tif, ea_t ea, int pio_flags=0)
Write a typed idc object to the database.
gts_code_t
Constants to be used with get_size()
Definition typeinf.hpp:2977
@ GTS_NESTED
nested type (embedded into a udt)
Definition typeinf.hpp:2978
@ GTS_BASECLASS
is baseclass of a udt
Definition typeinf.hpp:2979
idaman error_t ida_export unpack_idcobj_from_bv(idc_value_t *obj, const tinfo_t &tif, const bytevec_t &bytes, int pio_flags=0)
Read a typed idc object from the byte vector.
idaman int ida_export guess_tinfo(tinfo_t *out, tid_t id)
Generate a type information about the id from the disassembly.
THREAD_SAFE bool is_type_char(type_t t)
Does the type specify a char value? (signed or unsigned, see Basic type: integer)
Definition typeinf.hpp:496
THREAD_SAFE bool is_type_struct(type_t t)
See BTF_STRUCT.
Definition typeinf.hpp:456
idaman bool ida_export del_til(const char *name)
Unload a til file.
idaman DEPRECATED uint32 ida_export choose_local_tinfo_and_delta(int32 *, const til_t *, const char *, til_tinfo_predicate_t *, uint32, void *)
THREAD_SAFE bool is_type_double(type_t t)
See BTF_DOUBLE.
Definition typeinf.hpp:529
THREAD_SAFE bool is_type_typedef(type_t t)
See BTF_TYPEDEF.
Definition typeinf.hpp:454
const int TYPID_SHIFT
First type detail bit.
Definition typeinf.hpp:3072
ssize_t get_c_header_path(qstring *buf)
Get the include directory path of the target compiler.
Definition typeinf.hpp:2849
void set_c_header_path(const char *incdir)
Set include directory path the target compiler.
Definition typeinf.hpp:2846
bool is_restype_void(const til_t *til, const type_t *type)
Definition typeinf.hpp:696
idaman type_t ida_export get_scalar_bt(size_t size)
THREAD_SAFE bool is_type_ptr_or_array(type_t t)
Is the type a pointer or array type?
Definition typeinf.hpp:510
qvector< regobj_t > regobjvec_t
Definition typeinf.hpp:6131
uint64 bmask64_t
unsigned value that describes a bitmask
Definition typeinf.hpp:103
idaman bool ida_export func_has_stkframe_hole(ea_t ea, const func_type_data_t &fti)
Looks for a hole at the beginning of the stack arguments.
idaman int ida_export lower_type(til_t *til, tinfo_t *tif, const char *name=nullptr, lowertype_helper_t *_helper=nullptr)
Lower type.
THREAD_SAFE bool is_type_uint16(type_t t)
See BTF_UINT16.
Definition typeinf.hpp:524
idaman bool ida_export calc_arglocs(func_type_data_t *fti)
THREAD_SAFE bool is_type_integral(type_t t)
Is the type an integral type (char/short/int/long/bool)?
Definition typeinf.hpp:514
THREAD_SAFE bool is_type_union(type_t t)
See BTF_UNION.
Definition typeinf.hpp:457
THREAD_SAFE bool is_tah_byte(type_t t)
The TAH byte (type attribute header byte) denotes the start of type attributes.
Definition typeinf.hpp:606
THREAD_SAFE bool is_type_bitfld(type_t t)
See BT_BITFIELD.
Definition typeinf.hpp:461
uchar p_string
Inside a type string, a Pascal-like string: dt length, characters.
Definition typeinf.hpp:99
idaman error_t ida_export pack_idcobj_to_bv(const idc_value_t *obj, const tinfo_t &tif, relobj_t *bytes, void *objoff, int pio_flags=0)
Write a typed idc object to the byte vector.
stock_type_id_t
IDs for common types.
Definition typeinf.hpp:2901
@ STI_PINT
int *
Definition typeinf.hpp:2907
@ STI_PCVOID
const void *
Definition typeinf.hpp:2911
@ STI_AEABI_LCMP
int __fastcall __pure(int64 x, int64 y)
Definition typeinf.hpp:2919
@ STI_RTC_CHECK_8
int64 __fastcall(int64 x)
Definition typeinf.hpp:2929
@ STI_SSIZE_T
ssize_t
Definition typeinf.hpp:2923
@ STI_PUNKNOWN
_UNKNOWN *
Definition typeinf.hpp:2932
@ STI_AUCHAR
uint8[]
Definition typeinf.hpp:2913
@ STI_AEABI_MEMSET
void __fastcall(void *, size_t, int)
Definition typeinf.hpp:2925
@ STI_ACHAR
char[]
Definition typeinf.hpp:2912
@ STI_DONT_USE
unused stock type id; should not be used
Definition typeinf.hpp:2921
@ STI_COMPLEX128
struct complex128_t { double real, imag; }
Definition typeinf.hpp:2931
@ STI_PCCHAR
const char *
Definition typeinf.hpp:2904
@ STI_PUINT
unsigned int *
Definition typeinf.hpp:2908
@ STI_ACCHAR
const char[]
Definition typeinf.hpp:2914
@ STI_PCUCHAR
const uint8 *
Definition typeinf.hpp:2905
@ STI_COMPLEX64
struct complex64_t { float real, imag; }
Definition typeinf.hpp:2930
@ STI_RTC_CHECK_2
int16 __fastcall(int16 x)
Definition typeinf.hpp:2927
@ STI_RTC_CHECK_4
int32 __fastcall(int32 x)
Definition typeinf.hpp:2928
@ STI_AEABI_MEMCPY
void __fastcall(void *, const void *, size_t)
Definition typeinf.hpp:2924
@ STI_MSGSEND
void *(void *, const char *, ...)
Definition typeinf.hpp:2918
@ STI_LAST
Definition typeinf.hpp:2933
@ STI_FDELOP
void __cdecl(void *)
Definition typeinf.hpp:2917
@ STI_PVOID
void *
Definition typeinf.hpp:2909
@ STI_PPVOID
void **
Definition typeinf.hpp:2910
@ STI_AEABI_ULCMP
int __fastcall __pure(uint64 x, uint64 y)
Definition typeinf.hpp:2920
@ STI_AEABI_MEMCLR
void __fastcall(void *, size_t)
Definition typeinf.hpp:2926
@ STI_FPURGING
void __userpurge(int)
Definition typeinf.hpp:2916
@ STI_PCHAR
char *
Definition typeinf.hpp:2902
@ STI_PUCHAR
uint8 *
Definition typeinf.hpp:2903
@ STI_ACUCHAR
const uint8[]
Definition typeinf.hpp:2915
@ STI_PBYTE
_BYTE *
Definition typeinf.hpp:2906
@ STI_SIZE_T
size_t
Definition typeinf.hpp:2922
THREAD_SAFE bool is_type_int32(type_t t)
Does the type specify a 32-bit value? (signed or unsigned, see Basic type: integer)
Definition typeinf.hpp:482
THREAD_SAFE bool is_type_uchar(type_t t)
See BTF_UCHAR.
Definition typeinf.hpp:523
THREAD_SAFE bool is_type_floating(type_t t)
Is the type a floating point type?
Definition typeinf.hpp:512
idaman DEPRECATED uint32 ida_export choose_local_tinfo(const til_t *, const char *, til_tinfo_predicate_t *, uint32, void *)
THREAD_SAFE bool is_type_uint(type_t t)
See BTF_UINT.
Definition typeinf.hpp:522
THREAD_SAFE bool is_type_partial(type_t t)
Identifies an unknown or void type with a known size (see Basic type: unknown & void)
Definition typeinf.hpp:444
idaman int ida_export visit_stroff_udms(udm_visitor_t &sfv, const tid_t *path, int plen, adiff_t *disp, bool appzero)
Visit structure fields in a stroff expression or in a reference to a struct data variable.
bool stroff_as_size(int plen, const tinfo_t &tif, asize_t value)
Should display a structure offset expression as the structure size?
Definition typeinf.hpp:5642
qvector< tinfo_t > tinfovec_t
vector of tinfo objects
Definition typeinf.hpp:4633
tinfo_t remove_pointer(const tinfo_t &tif)
BT_PTR: If the current type is a pointer, return the pointed object.
Definition typeinf.hpp:6037
idaman bool ida_export dump_func_type_data(qstring *out, const func_type_data_t &fti, int praloc_bits)
Use func_type_data_t::dump()
const uchar MAX_ENUM_SERIAL
Max number of identical constants allowed for one enum type.
Definition typeinf.hpp:5252
idaman bool ida_export apply_tinfo_to_stkarg(const insn_t &insn, const op_t &x, uval_t v, const tinfo_t &tif, const char *name)
Helper function for the processor modules.
format_functype_t
Function index for the 'format' attribute.
Definition typeinf.hpp:4931
@ FMTFUNC_SCANF
Definition typeinf.hpp:4933
@ FMTFUNC_STRFTIME
Definition typeinf.hpp:4934
@ FMTFUNC_STRFMON
Definition typeinf.hpp:4935
@ FMTFUNC_PRINTF
Definition typeinf.hpp:4932
THREAD_SAFE bool is_type_int(type_t bt)
Does the type_t specify one of the basic types in Basic type: integer?
Definition typeinf.hpp:465
THREAD_SAFE bool is_type_arithmetic(type_t t)
Is the type an arithmetic type? (floating or integral)
Definition typeinf.hpp:518
idaman bool ida_export choose_named_type(til_symbol_t *out_sym, const til_t *root_til, const char *title, int ntf_flags, predicate_t *predicate=nullptr)
Choose a type from a type library.
idaman bool ida_export apply_cdecl(til_t *til, ea_t ea, const char *decl, int flags=0)
Apply the specified type to the address.
const int TYPID_ISREF
Identifies that a type that is a typeref.
Definition typeinf.hpp:3071
THREAD_SAFE bool is_type_const(type_t t)
See BTM_CONST.
Definition typeinf.hpp:432
bool is_restype_struni(const til_t *til, const type_t *type)
Definition typeinf.hpp:706
idaman bool ida_export apply_tinfo(ea_t ea, const tinfo_t &tif, uint32 flags)
Apply the specified type to the specified address.
idaman int ida_export add_base_tils(qstring *errbuf, til_t *ti, const char *tildir, const char *bases, bool gen_events)
Add multiple base tils.
gtd_udt_t
Constants to be used with get_udt_details()
Definition typeinf.hpp:2958
@ GTD_CALC_LAYOUT
calculate udt layout
Definition typeinf.hpp:2959
@ GTD_NO_LAYOUT
don't calculate udt layout please note that udt layout may have been calculated earlier
Definition typeinf.hpp:2960
@ GTD_DEL_BITFLDS
delete udt bitfields
Definition typeinf.hpp:2963
THREAD_SAFE bool is_type_enum(type_t t)
See BTF_ENUM.
Definition typeinf.hpp:459
idaman int ida_export add_til(const char *name, int flags)
Load a til file and add it the database type libraries list.
qvector< funcarg_t > funcargvec_t
vector of function argument objects
Definition typeinf.hpp:4825
THREAD_SAFE bool is_type_complex(type_t t)
See BT_COMPLEX.
Definition typeinf.hpp:450
THREAD_SAFE bool is_type_array(type_t t)
See BT_ARRAY.
Definition typeinf.hpp:452
idaman til_t *ida_export load_til(const char *name, qstring *errbuf, const char *tildir=nullptr)
Load til from a file without adding it to the database list (see also add_til).
THREAD_SAFE void align_size(size_t &cur_tot_size, size_t elem_size, size_t algn)
Get alignment delta for the a structure field.
Definition typeinf.hpp:2677
ssize_t get_c_macros(qstring *buf)
Get predefined macros for the target compiler.
Definition typeinf.hpp:2855
idaman void ida_export gen_use_arg_tinfos(struct argtinfo_helper_t *_this, ea_t caller, func_type_data_t *fti, funcargvec_t *rargs)
Do not call this function directly, use argtinfo_helper_t.
uint64 typid_t
Definition typeinf.hpp:3002
idaman til_t *ida_export load_til_header(const char *tildir, const char *name, qstring *errbuf)
Get human-readable til description.
idaman bool ida_export deref_ptr(ea_t *ptr_ea, const tinfo_t &tif, ea_t *closure_obj=nullptr)
Dereference a pointer.
idaman bool ida_export get_enum_member_expr(qstring *buf, const tinfo_t &tif, int serial, uint64 value)
Return a C expression that can be used to represent an enum member.
abs_t
abstractness of declaration (see h2ti())
Definition typeinf.hpp:2050
@ ABS_YES
Definition typeinf.hpp:2053
@ ABS_NO
Definition typeinf.hpp:2052
@ ABS_UNK
Definition typeinf.hpp:2051
THREAD_SAFE bool is_type_void(type_t t)
See BTF_VOID.
Definition typeinf.hpp:446
update_type_t
See begin_type_updating()
Definition typeinf.hpp:6339
@ UTP_STRUCT
Definition typeinf.hpp:6341
@ UTP_ENUM
Definition typeinf.hpp:6340
THREAD_SAFE bool is_type_ldouble(type_t t)
See BTF_LDOUBLE.
Definition typeinf.hpp:528
idaman bool ida_export get_arg_addrs(eavec_t *out, ea_t caller)
Retrieve argument initialization addresses.
idaman void ida_export free_til(til_t *ti)
Free memory allocated by til.
THREAD_SAFE bool is_type_bool(type_t t)
See BTF_BOOL.
Definition typeinf.hpp:532
idaman bool ida_export compact_til(til_t *ti)
Collect garbage in til.
idaman bool ida_export store_til(til_t *ti, const char *tildir, const char *name)
Store til to a file.
idaman DEPRECATED const type_t *ida_export resolve_typedef(const til_t *til, const type_t *type)
THREAD_SAFE bool is_one_bit_mask(uval_t mask)
Is bitmask one bit?
Definition typeinf.hpp:5726
const size_t BADSIZE
bad type size
Definition typeinf.hpp:2043
sval_t align_stkarg_up(sval_t spoff, int type_align, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
Definition typeinf.hpp:5773
THREAD_SAFE bool is_type_struni(type_t t)
Is the type a struct or union?
Definition typeinf.hpp:458
size_t get_default_align()
Get default alignment for structure fields.
Definition typeinf.hpp:2668
THREAD_SAFE bool is_type_ext_integral(type_t t)
Is the type an extended integral type? (integral or enum)
Definition typeinf.hpp:516
bool is_restype_struct(const til_t *til, const type_t *type)
Definition typeinf.hpp:711
sclass_t
< storage class
Definition typeinf.hpp:2056
@ SC_EXT
extern
Definition typeinf.hpp:2059
@ SC_FRIEND
friend
Definition typeinf.hpp:2063
@ SC_VIRT
virtual
Definition typeinf.hpp:2064
@ SC_UNK
unknown
Definition typeinf.hpp:2057
@ SC_AUTO
auto
Definition typeinf.hpp:2062
@ SC_TYPE
typedef
Definition typeinf.hpp:2058
@ SC_REG
register
Definition typeinf.hpp:2061
@ SC_STAT
static
Definition typeinf.hpp:2060
THREAD_SAFE bool is_sdacl_byte(type_t t)
Identify an sdacl byte.
Definition typeinf.hpp:621
qvector< valstr_t > valstrvec_t
Definition typeinf.hpp:6580
THREAD_SAFE bool is_type_uint64(type_t t)
See BTF_UINT64.
Definition typeinf.hpp:526
THREAD_SAFE type_t get_type_flags(type_t t)
Get type flags (TYPE_FLAGS_MASK)
Definition typeinf.hpp:436
idaman void ida_export begin_type_updating(update_type_t utp)
Mark the beginning of a large update operation on the types.
THREAD_SAFE bool is_type_paf(type_t t)
Is the type a pointer, array, or function type?
Definition typeinf.hpp:503
THREAD_SAFE bool is_type_tbyte(type_t t)
See BTF_FLOAT.
Definition typeinf.hpp:531
idaman til_t *ida_export get_idati()
Pointer to the local type library - this til is private for each IDB file Functions that accept til_t...
THREAD_SAFE bool operator<(const bytevec_t &v1, const bytevec_t &v2)
Compare two bytevecs with '<'.
Definition typeinf.hpp:632
idaman bool ida_export sort_til(til_t *ti)
Sort til (use after modifying it).
bool is_restype_enum(const til_t *til, const type_t *type)
Definition typeinf.hpp:701
std::function< ssize_t(const struct enum_type_data_t &ei, size_t idx, uint64 value, uint64 bmask)> enum_type_visitor_t
Callback for visit_edms.
Definition typeinf.hpp:6742
THREAD_SAFE bool is_type_uint128(type_t t)
See BTF_UINT128.
Definition typeinf.hpp:527
idaman bool ida_export remove_tinfo_pointer(tinfo_t *tif, const char **pname, const til_t *til=nullptr)
Remove pointer of a type.
gtd_func_t
Constants to be used with get_func_details()
Definition typeinf.hpp:2968
@ GTD_NO_ARGLOCS
don't calculate func arg locations please note that the locations may have been calculated earlier
Definition typeinf.hpp:2970
@ GTD_CALC_ARGLOCS
calculate func arg locations
Definition typeinf.hpp:2969
void set_c_macros(const char *macros)
Set predefined macros for the target compiler.
Definition typeinf.hpp:2852
THREAD_SAFE bool is_type_unknown(type_t t)
See BT_UNKNOWN.
Definition typeinf.hpp:447
idaman void ida_export end_type_updating(update_type_t utp)
Mark the end of a large update operation on the types (see begin_type_updating())
idaman bool ida_export apply_once_tinfo_and_name(ea_t dea, const tinfo_t &tif, const char *name)
Apply the specified type and name to the address.
idaman int ida_export print_decls(text_sink_t &printer, const til_t *til, const ordvec_t *ordinals, uint32 pdf_flags)
Print types (and possibly their dependencies) in a format suitable for using in a header file.
idaman bool ida_export calc_retloc(func_type_data_t *fti)
THREAD_SAFE bool is_type_float(type_t t)
See BTF_FLOAT.
Definition typeinf.hpp:530
idaman bool ida_export apply_callee_tinfo(ea_t caller, const tinfo_t &tif)
Apply the type of the called function to the calling instruction.
THREAD_SAFE bool is_type_ptr(type_t t)
See BT_PTR.
Definition typeinf.hpp:449
idaman int ida_export print_cdata(text_sink_t &printer, const idc_value_t &idc_value, const tinfo_t *tif, const format_data_info_t *fdi=nullptr)
The same as format_cdata(), but instead of returning the answer in a vector, print it.
idaman int ida_export replace_ordinal_typerefs(til_t *til, tinfo_t *tif)
Replace references to ordinal types by name references.
int get_arg_align(int type_align, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
Definition typeinf.hpp:5751
idaman bool ida_export append_argloc(qtype *out, const argloc_t &vloc)
Serialize argument location.
THREAD_SAFE bool is_type_volatile(type_t t)
See BTM_VOLATILE.
Definition typeinf.hpp:433
idaman type_t ida_export get_realtype(const til_t *til, const type_t *type)
Get the resolved base type.
idaman til_t *ida_export new_til(const char *name, const char *desc)
Initialize a til.
THREAD_SAFE bool is_typeid_last(type_t t)
Is the type_t the last byte of type declaration?
Definition typeinf.hpp:441
idaman bool ida_export format_cdata(qstrvec_t *outvec, const idc_value_t &idc_value, const tinfo_t *tif, valstr_t *vtree=nullptr, const format_data_info_t *fdi=nullptr)
Format a data value as a C initializer.
THREAD_SAFE bool is_type_sue(type_t t)
Is the type a struct/union/enum?
Definition typeinf.hpp:455
idaman bool ida_export calc_varglocs(func_type_data_t *fti, regobjs_t *regs, relobj_t *stkargs, int nfixed)
idaman ssize_t ida_export visit_edms(const tinfo_t &tif, uint64 value, int nbytes, uchar serial, const enum_type_visitor_t &visitor)
Visit enum members having the specified value.
qvector< edm_t > edmvec_t
vector of enum values.
Definition typeinf.hpp:4977
THREAD_SAFE bool is_type_int64(type_t t)
Does the type specify a 64-bit value? (signed or unsigned, see Basic type: integer)
Definition typeinf.hpp:475
idaman DEPRECATED void ida_export build_anon_type_name(qstring *buf, const type_t *type, const p_list *fields)
THREAD_SAFE bool is_type_int128(type_t t)
Does the type specify a 128-bit value? (signed or unsigned, see Basic type: integer)
Definition typeinf.hpp:468
idaman error_t ida_export unpack_idcobj_from_idb(idc_value_t *obj, const tinfo_t &tif, ea_t ea, const bytevec_t *off0, int pio_flags=0)
Collection of register objects.
idaman bool ida_export get_tinfo_by_flags(tinfo_t *out, flags64_t flags)
Get tinfo object that corresponds to data flags.
idaman callcnv_t ida_export guess_func_cc(const func_type_data_t &fti, int npurged, int cc_flags)
Use func_type_data_t::guess_cc()
Additional information about an operand type.
Definition nalt.hpp:1239
This union is used to pass byte values to various helper functions.
Definition ua.hpp:569