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-2025 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
561
564#define TAFLD_BASECLASS 0x0020
565#define TAFLD_UNALIGNED 0x0040
566#define TAFLD_VIRTBASE 0x0080
567#define TAFLD_VFTABLE 0x0100
568#define TAFLD_METHOD 0x0200
569#define TAFLD_GAP 0x0400
570#define TAFLD_REGCMT 0x0800
571#define TAFLD_FRAME_R 0x1000
572#define TAFLD_FRAME_S 0x2000
573#define TAFLD_BYTIL 0x4000
575
578#define TAPTR_PTR32 0x0020
579#define TAPTR_PTR64 0x0040
580#define TAPTR_RESTRICT 0x0060
581#define TAPTR_SHIFTED 0x0080
583
586#define TAENUM_64BIT 0x0020
587#define TAENUM_UNSIGNED 0x0040
588#define TAENUM_SIGNED 0x0080
589#define TAENUM_OCT 0x0100
590#define TAENUM_BIN 0x0200
593#define TAENUM_NUMSIGN 0x0400
594#define TAENUM_LZERO 0x0800
596
597#define TAH_ALL 0x7FF0
598
600
601
604
605inline THREAD_SAFE bool is_tah_byte(type_t t)
606{
607 return t == TAH_BYTE;
608}
609
610
619
620inline THREAD_SAFE bool is_sdacl_byte(type_t t)
621{
622 return ((t & ~TYPE_FLAGS_MASK) ^ TYPE_MODIF_MASK) <= BT_VOID;
623}
624
625#ifndef SWIG
630
631inline THREAD_SAFE bool operator <(const bytevec_t &v1, const bytevec_t &v2)
632{
633 size_t n = qmin(v1.size(), v2.size());
634 for ( size_t i=0; i < n; i++ )
635 {
636 uchar k1 = v1[i];
637 uchar k2 = v2[i];
638 if ( k1 < k2 )
639 return true;
640 if ( k1 > k2 )
641 return false;
642 }
643 return v1.size() < v2.size();
644}
645#endif
646
651{
654#define TA_ORG_TYPEDEF "__org_typedef"
655#define TA_ORG_ARRDIM "__org_arrdim"
656#define TA_FORMAT "format"
661#define TA_VALUE_REPR "\x01"
663 bool operator < (const type_attr_t &r) const { return key < r.key; }
664 bool operator >= (const type_attr_t &r) const { return !(*this < r); }
665};
667
670
671typedef int type_sign_t;
672const type_sign_t
677
678//---------------------------------------------------------------------------
679idaman bool ida_export append_argloc(qtype *out, const argloc_t &vloc);
683idaman bool ida_export extract_argloc(argloc_t *vloc, const type_t **ptype, bool forbid_stkoff);
684
685idaman const type_t *ida_export resolve_typedef(const til_t *til, const type_t *type);
686
687// low level functions to be used in predicate_t::should_display()
688// in other places please use tinfo_t
689inline bool is_restype_void(const til_t *til, const type_t *type)
690{
691 type = resolve_typedef(til, type);
692 return type != nullptr && is_type_void(*type);
693}
694
695inline bool is_restype_enum(const til_t *til, const type_t *type)
696{
697 type = resolve_typedef(til, type);
698 return type != nullptr && is_type_enum(*type);
699}
700
701inline bool is_restype_struni(const til_t *til, const type_t *type)
702{
703 type = resolve_typedef(til, type);
704 return type != nullptr && is_type_struni(*type);
705}
706
707inline bool is_restype_struct(const til_t *til, const type_t *type)
708{
709 type = resolve_typedef(til, type);
710 return type != nullptr && is_type_struct(*type);
711}
712
713// Get a base type for the specified size.
714// This function prefers to return integer types
715// \param size size in bytes; should be 1,2,4,8,16 or sizeof(floating point)
716// \return BT_INT.. or BT_FLOAT... or BT_UNK
717
718idaman type_t ida_export get_scalar_bt(int size);
719
720
721//------------------------------------------------------------------------
723//------------------------------------------------------------------------
724struct til_t
725{
726 char *name = nullptr;
727 char *desc = nullptr;
728 int nbases = 0;
729 til_t **base = nullptr;
734#define TIL_ZIP 0x0001
735#define TIL_MAC 0x0002
736#define TIL_ESI 0x0004
737#define TIL_UNI 0x0008
738#define TIL_ORD 0x0010
739#define TIL_ALI 0x0020
740#define TIL_MOD 0x0040
741#define TIL_STM 0x0080
742#define TIL_SLD 0x0100
743#define TIL_ECC 0x0200
746 inline bool is_dirty() const { return (flags & TIL_MOD) != 0; }
748 inline void set_dirty() { flags |= TIL_MOD; }
749
753 inline til_t *find_base(const char *n)
754 {
755 if ( n != nullptr )
756 {
757 for ( int i = 0; i < nbases; ++i )
758 if ( streq(base[i]->name, n) )
759 return base[i];
760 }
761 return nullptr;
762 }
763
765 til_bucket_t *syms = nullptr;
766 til_bucket_t *types = nullptr;
767 til_bucket_t *macros = nullptr;
768 int nrefs = 0;
769 int nstreams = 0;
770 til_stream_t **streams = nullptr;
771};
772
773
775
776idaman til_t *ida_export new_til(const char *name, const char *desc);
777
778
787
788idaman int ida_export add_base_tils(qstring *errbuf, til_t *ti, const char *tildir, const char *bases, bool gen_events);
789
793#define TIL_ADD_FAILED 0
794#define TIL_ADD_OK 1
795#define TIL_ADD_ALREADY 2
797
798
808
809idaman til_t *ida_export load_til(const char *name, qstring *errbuf, const char *tildir=nullptr);
810
811
814
815idaman bool ida_export sort_til(til_t *ti);
816
817
821
822idaman bool ida_export compact_til(til_t *ti);
823
824
833
834idaman bool ida_export store_til(til_t *ti, const char *tildir, const char *name);
835
836
838
839idaman void ida_export free_til(til_t *ti);
840
841
843
844idaman til_t *ida_export load_til_header(const char *tildir, const char *name, qstring *errbuf);
845
846
847//------------------------------------------------------------------------
851
854const cm_t CM_MASK = 0x03;
855const cm_t CM_UNKNOWN = 0x00;
856const cm_t CM_N8_F16 = 0x01;
857const cm_t CM_N64 = 0x01;
858const cm_t CM_N16_F32 = 0x02;
859const cm_t CM_N32_F48 = 0x03;
863const cm_t CM_M_MASK = 0x0C;
864const cm_t CM_M_NN = 0x00;
865const cm_t CM_M_FF = 0x04;
866const cm_t CM_M_NF = 0x08;
867const cm_t CM_M_FN = 0x0C;
868
870inline THREAD_SAFE bool is_code_far(cm_t cm) { return((cm & 4) != 0); }
872inline THREAD_SAFE bool is_data_far(cm_t cm) { return((cm &= CM_M_MASK) && cm != CM_M_FN); }
874
883const callcnv_t CM_CC_CDECL = 0x30;
889const callcnv_t CM_CC_SWIFT = 0x90;
901
902const callcnv_t CM_CC_GOSTK = 0x100;
903
904const callcnv_t CM_CC_FIRST_PLAIN_CUSTOM = 0x200; // please note that variadic or usercall
905 // codes have their own ranges
906// recommendation:
907// use 0x100 and higher for new calling convention codes.
908// max calling convention code is MAX_DT.
909// however, for calling conventions with special traits the following code may be used:
910// - usercall variations may use values between 0xD0..0xFF.
911// - ellipsis variations may use values 0x40..0x4F and 0xD0..0xDF.
912
914
916
922const type_t BFA_NORET = 0x01;
923const type_t BFA_PURE = 0x02;
924const type_t BFA_HIGH = 0x04;
925const type_t BFA_STATIC = 0x08;
926const type_t BFA_VIRTUAL = 0x10;
927
928const cm_t BFA_FUNC_MARKER = 0x0F;
931
932#ifndef SWIG
934#define ARGLOC_HELPER_DEFINITIONS(decl) \
935decl void ida_export copy_argloc(argloc_t *dst, const argloc_t *src); \
936decl void ida_export cleanup_argloc(argloc_t *vloc);\
937decl int ida_export compare_arglocs(const argloc_t &a, const argloc_t &b);
938#else
939#define ARGLOC_HELPER_DEFINITIONS(decl)
940#endif // SWIG
941ARGLOC_HELPER_DEFINITIONS(idaman)
942
943
946
949typedef int argloc_type_t;
952const argloc_type_t
962
964struct rrel_t
965{
967 int reg;
968};
969
970class scattered_aloc_t;
971
975{
976 size_t cbsize;
977 const char *name;
978
980 void (idaapi *copy)(argloc_t *empty_dst, const argloc_t &src);
981
983 void (idaapi *cleanup)(argloc_t *loc);
984
986 bool (idaapi *verify)(
987 const argloc_t &loc,
988 int size,
989 const rangeset_t *gaps,
991
993 int (idaapi *compare)(const argloc_t &a, const argloc_t &b);
994
996 size_t (idaapi *print)(
997 char *buf,
998 size_t bufsize,
999 const argloc_t &loc,
1001 int praloc_flags); // PRALOC_...
1002
1005 bool (idaapi *deref_field)(
1006 argloc_t *out,
1011 const qstring &name);
1012
1015 bool (idaapi *deref_array)(
1016 argloc_t *out,
1017 tinfo_t *tif,
1022
1025 bool (idaapi *deref_ptr)(
1026 argloc_t *out,
1027 tinfo_t *tif,
1029
1032 bool (idaapi *read_value)(
1033 value_union_t *value,
1035 int size,
1036 const tinfo_t &tif);
1037
1041 bool (idaapi *write_value)(
1042 const argloc_t &loc,
1045 int size,
1047
1049 asize_t (idaapi *calc_string_length)(
1050 const argloc_t &loc,
1052
1055 bool (idaapi *get_string)(
1056 qstring *out,
1060 size_t len);
1061
1063 asize_t (idaapi *guess_array_size)(
1064 const argloc_t &loc,
1066
1068 bool (idaapi *get_tinfo)(
1069 tinfo_t *out,
1070 const argloc_t &loc);
1071
1075
1079 size_t (idaapi *print_ptr_value)(
1080 char *buf,
1081 size_t bufsize,
1084 const tinfo_t &tif);
1085};
1086
1087
1089idaman int ida_export install_custom_argloc(const custloc_desc_t *custloc);
1091idaman bool ida_export remove_custom_argloc(int idx);
1093idaman const custloc_desc_t *ida_export retrieve_custom_argloc(int idx);
1094
1100class argloc_t // #argloc
1101{
1102public:
1103 typedef size_t biggest_t;
1104
1105private:
1106 argloc_type_t type;
1107 union
1108 {
1109 sval_t sval; // ::ALOC_STACK, ::ALOC_STATIC
1110 uint32 reginfo; // ::ALOC_REG1, ::ALOC_REG2
1111 rrel_t *rrel; // ::ALOC_RREL
1112 scattered_aloc_t *dist; // ::ALOC_DIST
1113 void *custom; // ::ALOC_CUSTOM
1114 biggest_t biggest; // to facilitate manipulation of this union
1115 };
1116 ARGLOC_HELPER_DEFINITIONS(friend)
1117
1118public:
1119 argloc_t() : type(ALOC_NONE), biggest(0) {}
1120 argloc_t(const argloc_t &r) : type(ALOC_NONE) { copy_argloc(this, &r); }
1121 ~argloc_t() { cleanup_argloc(this); }
1122 argloc_t &operator=(const argloc_t &r) { copy_argloc(this, &r); return *this; }
1123 DEFINE_MEMORY_ALLOCATION_FUNCS()
1124
1125
1126 void swap(argloc_t &r)
1127 {
1128 biggest_t tmp = biggest; biggest = r.biggest; r.biggest = tmp;
1129 argloc_type_t t = type; type = r.type; r.type = t;
1130 }
1131
1132 const char *dstr() const;
1133
1134 argloc_type_t atype() const { return type; }
1135 bool is_reg1() const { return type == ALOC_REG1; }
1136 bool is_reg2() const { return type == ALOC_REG2; }
1137 bool is_reg() const { return type == ALOC_REG1 || type == ALOC_REG2; }
1138 bool is_rrel() const { return type == ALOC_RREL; }
1139 bool is_ea() const { return type == ALOC_STATIC; }
1140 bool is_stkoff() const { return type == ALOC_STACK; }
1141 bool is_scattered() const { return type == ALOC_DIST; }
1142 inline bool has_reg() const;
1143 inline bool has_stkoff() const;
1144 inline bool is_mixed_scattered() const;
1145 inline bool in_stack() const;
1146 bool is_fragmented() const { return type == ALOC_DIST || type == ALOC_REG2; }
1147 bool is_custom() const { return type >= ALOC_CUSTOM; }
1148 bool is_badloc() const { return type == ALOC_NONE; }
1149
1152 int reg1() const { return uint16(reginfo); }
1153
1156 int regoff() const { return uint16(reginfo >> 16); }
1157
1160 int reg2() const { return uint16(reginfo >> 16); }
1161
1164 uint32 get_reginfo() const { return reginfo; }
1165
1168 sval_t stkoff() const { return sval; }
1169
1172 ea_t get_ea() const { return sval; }
1173
1176 scattered_aloc_t &scattered() { return *dist; }
1177 const scattered_aloc_t &scattered() const { return *dist; }
1178
1181 rrel_t &get_rrel() { return *rrel; }
1182 const rrel_t &get_rrel() const { return *rrel; }
1183
1186 void *get_custom() const { return custom; }
1187
1189 biggest_t get_biggest() const { return biggest; }
1190
1191 // be careful with these functions, they do not cleanup!
1192 void _set_badloc() { type = ALOC_NONE; }
1193 void _set_reg1(int reg, int off=0) { type = ALOC_REG1; reginfo = reg | (off << 16); }
1194 void _set_reg2(int _reg1, int _reg2) { type = ALOC_REG2; reginfo = _reg1 | (_reg2 << 16); }
1195 void _set_stkoff(sval_t off) { type = ALOC_STACK; sval = off; }
1196 void _set_ea(ea_t _ea) { type = ALOC_STATIC; sval = _ea; }
1198 bool _consume_rrel(rrel_t *p) //lint -sem(argloc_t::_consume_rrel, custodial(1))
1199 {
1200 if ( p == nullptr )
1201 return false;
1202 type = ALOC_RREL;
1203 rrel = p;
1204 return true;
1205 }
1207 bool _consume_scattered(scattered_aloc_t *p)
1208 {
1209 if ( p == nullptr )
1210 return false;
1211 type = ALOC_DIST;
1212 dist = p;
1213 return true;
1214 }
1215
1217 void _set_custom(argloc_type_t ct, void *pdata) { type = ct; custom = pdata; }
1218
1220 void _set_biggest(argloc_type_t ct, biggest_t data) { type = ct; biggest = data; }
1221
1223 void set_reg1(int reg, int off=0) { cleanup_argloc(this); _set_reg1(reg, off); }
1224
1226 void set_reg2(int _reg1, int _reg2) { cleanup_argloc(this); _set_reg2(_reg1, _reg2); }
1227
1229 void set_stkoff(sval_t off) { cleanup_argloc(this); _set_stkoff(off); }
1230
1232 void set_ea(ea_t _ea) { cleanup_argloc(this); _set_ea(_ea); }
1233
1235 void consume_rrel(rrel_t *p) { cleanup_argloc(this); _consume_rrel(p); }
1236
1238 void consume_scattered(scattered_aloc_t *p) { cleanup_argloc(this); _consume_scattered(p); }
1239
1241 void set_badloc() { cleanup_argloc(this); }
1242
1244 sval_t calc_offset() const
1245 {
1246 switch ( type )
1247 {
1248 default:
1249 case ALOC_NONE:
1250 case ALOC_DIST:
1251 case ALOC_REG2:
1252 return -1;
1253 case ALOC_RREL:
1254 return rrel->off;
1255 case ALOC_STACK:
1256 case ALOC_STATIC:
1257 return sval;
1258 case ALOC_REG1:
1259 return reg1();
1260 }
1261 }
1262
1264 bool advance(int delta)
1265 {
1266 switch ( type )
1267 {
1268 case ALOC_REG1:
1269 _set_reg1(reg1()+delta, regoff());
1270 break;
1271 case ALOC_STACK:
1272 case ALOC_STATIC:
1273 sval += delta;
1274 break;
1275 case ALOC_RREL:
1276 rrel->off += delta;
1277 break;
1278 default:
1279 return false;
1280 }
1281 return true;
1282 }
1283
1285 void align_reg_high(size_t size, size_t _slotsize)
1286 {
1287 if ( is_reg1() )
1288 _set_reg1(reg1(), size < _slotsize ? _slotsize - size : 0);
1289 }
1290
1292 void align_stkoff_high(size_t size, size_t _slotsize)
1293 {
1294 if ( is_stkoff() )
1295 {
1296 sval_t off = align_down(stkoff(), _slotsize);
1297 if ( size < _slotsize )
1298 off += _slotsize - size;
1299 _set_stkoff(off);
1300 }
1301 }
1302
1303 DECLARE_COMPARISONS(argloc_t)
1304 {
1305 return compare_arglocs(*this, r);
1306 }
1307};
1310
1312struct argpart_t : public argloc_t
1313{
1317 argpart_t(const argloc_t &a) : argloc_t(a), off(0xFFFF), size(0) {}
1318 argpart_t() : off(0xFFFF), size(0) {}
1319 argpart_t &copy_from(const argloc_t &a) { *(argloc_t*)this = a; return *this; }
1320
1322 bool bad_offset() const { return off == 0xFFFF; }
1323
1325 bool bad_size() const { return size == 0; }
1326
1328 bool operator < (const argpart_t &r) const { return off < r.off; }
1329
1332 {
1333 argloc_t::swap(r);
1334 qswap(off, r.off);
1335 qswap(size, r.size);
1336 }
1337};
1340
1343{
1344public:
1346};
1348
1349
1356
1357idaman int ida_export verify_argloc(const argloc_t &vloc, int size, const rangeset_t *gaps);
1358
1359
1364
1365idaman bool ida_export optimize_argloc(argloc_t *vloc, int size, const rangeset_t *gaps);
1366
1367
1369
1370idaman size_t ida_export print_argloc(
1371 char *buf,
1372 size_t bufsize,
1373 const argloc_t &vloc,
1374 int size=0,
1375 int vflags=0);
1376#define PRALOC_VERIFY 0x01
1377#define PRALOC_STKOFF 0x02
1378
1379
1383{
1384 virtual int idaapi visit_location(argloc_t &v, int off, int size) = 0;
1385 virtual ~aloc_visitor_t() {}
1386};
1387
1389idaman int ida_export for_all_arglocs(aloc_visitor_t &vv, argloc_t &vloc, int size, int off=0);
1390
1393{
1394 virtual int idaapi visit_location(const argloc_t &v, int off, int size) = 0;
1396};
1397
1399inline int idaapi for_all_const_arglocs(const_aloc_visitor_t &vv, const argloc_t &vloc, int size, int off=0)
1400{
1401 return for_all_arglocs(*(aloc_visitor_t*)(&vv),
1402 CONST_CAST(argloc_t&)(vloc),
1403 size,
1404 off);
1405}
1406
1407//--------------------------------------------------------------------------
1419
1420
1421// Helper functions that maintain binary compatibility with old plugins
1422// (when possible) yet let us work with 32-bit calling convention codes.
1423inline callcnv_t helper_get_cc(cm_t cm, callcnv_t new_callcnv)
1424{
1425 cm_t cc = cm & CM_CC_MASK;
1426 if ( cc == CM_CC_RESERVE3 )
1427 return new_callcnv;
1428 else
1429 return cc;
1430}
1431
1432inline void helper_set_cc(cm_t *cm, callcnv_t *new_callcnv, callcnv_t cc)
1433{
1434 *cm &= ~CM_CC_MASK;
1435 if ( (cc & ~CM_CC_MASK) == 0 && cc != CM_CC_RESERVE3 )
1436 {
1437 *cm |= cc;
1438 *new_callcnv = 0;
1439 }
1440 else
1441 {
1442 *cm |= CM_CC_RESERVE3;
1443 *new_callcnv = cc;
1444 }
1445}
1446
1449
1452{
1453 // if the calling convention is not specified, use the default one
1454 if ( cc <= CM_CC_UNKNOWN )
1455 cc = inf_get_callcnv();
1456 return cc;
1457}
1458
1460inline constexpr THREAD_SAFE bool is_user_cc(callcnv_t cc)
1461{
1462 return cc >= CM_CC_SPECIALE && cc <= CM_CC_LAST_USERCALL;
1463}
1464
1466inline constexpr THREAD_SAFE bool is_vararg_cc(callcnv_t cc)
1467{
1468 cc &= ~0xF; // the range of vararg codes is 0x40..0x4F and 0xD0..0xDF.
1469 return cc == CM_CC_ELLIPSIS || cc == CM_CC_SPECIALE;
1470}
1471
1474inline constexpr THREAD_SAFE bool is_purging_cc(callcnv_t cc)
1475{
1476 cc &= ~0xF; // mask out the last 4 bits
1477 return cc == CM_CC_STDCALL
1478 || cc == CM_CC_PASCAL
1479 || cc == CM_CC_SPECIALP
1480 || cc == CM_CC_FASTCALL
1481 || cc == CM_CC_THISCALL
1482 || cc == CM_CC_SWIFT;
1483}
1484
1486inline constexpr bool is_golang_cc(callcnv_t cc)
1487{
1488 return cc == CM_CC_GOLANG || cc == CM_CC_GOSTK;
1489}
1490
1493{
1494 if ( cc >= CM_CC_FIRST_PLAIN_CUSTOM )
1495 return true;
1496 if ( cc <= 0xFF && (cc & ~CM_CC_MASK) != 0 )
1497 return true;
1498 return false;
1499}
1500
1502
1503inline constexpr bool is_swift_cc(callcnv_t cc)
1504{
1505 return cc == CM_CC_SWIFT;
1506}
1507
1508
1509//-------------------------------------------------------------------------
1513idaman bool ida_export get_stkarg_area_info(
1514 stkarg_area_info_t *out,
1515 callcnv_t cc);
1516
1539
1540//--------------------------------------------------------------------------
1543{
1544 int cbsize = sizeof(*this);
1546#define CCI_VARARG 0x0001
1547#define CCI_PURGE 0x0002
1548#define CCI_USER 0x0004
1551
1552 bool is_vararg() const { return (flags & CCI_VARARG) != 0; }
1553 bool is_purging() const { return (flags & CCI_PURGE) != 0; }
1554 bool is_usercall() const { return (flags & CCI_USER) != 0; }
1555
1562 virtual bool validate_func(const func_type_data_t &fti, qstring *reterr) const
1563 {
1564 qnotused(fti);
1565 qnotused(reterr);
1566 return true;
1567 }
1568
1573 virtual bool calc_retloc(func_type_data_t *fti) const = 0;
1574
1580 virtual bool calc_arglocs(func_type_data_t *fti) const = 0;
1581
1593 func_type_data_t *fti,
1594 ea_t call_ea,
1595 class mblock_t *blk) const
1596 {
1597 qnotused(call_ea);
1598 qnotused(fti);
1599 qnotused(blk);
1600 return 0;
1601 }
1602
1611 virtual bool calc_varglocs(
1612 func_type_data_t *fti,
1613 regobjs_t *regs,
1614 relobj_t *stkargs,
1615 int nfixed) const
1616 {
1617 qnotused(fti);
1618 qnotused(regs);
1619 qnotused(stkargs);
1620 qnotused(nfixed);
1621 return false;
1622 }
1623
1625 virtual bool get_cc_regs(callregs_t *out) const
1626 {
1627 qnotused(out);
1628 return false;
1629 }
1630
1633 {
1634 qnotused(out);
1635 return false;
1636 }
1637
1642 const func_type_data_t &fti,
1643 ea_t call_ea=BADADDR) const
1644 {
1645 qnotused(fti);
1646 qnotused(call_ea);
1647 return 0;
1648 }
1649
1654 inline virtual bool decorate_name(
1655 qstring *outbuf,
1656 const char *name,
1657 bool should_decorate,
1658 callcnv_t cc,
1659 const tinfo_t &type) const;
1660
1665 virtual int lower_func_type(func_type_data_t *fti) const
1666 {
1667 qnotused(fti);
1668 return 0;
1669 }
1670
1671 custom_callcnv_t() = default;
1672 custom_callcnv_t(const char *_name, uint64 f, uint32 _abibits)
1673 : flags(f), name(_name), abibits(_abibits)
1674 {}
1676#ifndef SWIG
1678#endif
1679};
1681
1692
1695idaman bool ida_export unregister_custom_callcnv(callcnv_t callcnv);
1696
1698idaman const custom_callcnv_t *ida_export get_custom_callcnv(callcnv_t callcnv);
1699
1702idaman callcnv_t ida_export find_custom_callcnv(const char *name);
1703
1709idaman size_t ida_export get_custom_callcnvs(qstrvec_t *names, callcnvs_t *codes);
1710
1711//--------------------------------------------------------------------------
1727
1729
1733{
1734 bool set_inds(int *p_ind1, int *p_ind2, int ind) const
1735 {
1736 if ( ind == -1 )
1737 return false;
1738 *p_ind1 = ind;
1739 *p_ind2 = by_slots() ? ind : -1;
1740 return true;
1741 }
1742
1743 // copy -1-terminated array to a vector
1744 static void set_regarray(intvec_t *regvec, const int *regarray)
1745 {
1746 regvec->clear();
1747 if ( regarray != nullptr )
1748 while ( *regarray != -1 )
1749 regvec->push_back(*regarray++);
1750 }
1751 void calc_nregs()
1752 {
1753 nregs = gpregs.size();
1756 || policy == ARGREGS_RISCV )
1757 {
1758 nregs += int(fpregs.size());
1759 }
1760 }
1761
1762public:
1764 int nregs = 0;
1767
1770
1773
1776 {
1777 std::swap(policy, r.policy);
1778 std::swap(nregs, r.nregs);
1779 gpregs.swap(r.gpregs);
1780 fpregs.swap(r.fpregs);
1781 }
1782
1785 {
1786 if ( is_custom_callcnv(cc) )
1787 {
1788 const custom_callcnv_t *ccc = get_custom_callcnv(cc);
1789 if ( ccc == nullptr )
1790 return false;
1791 return ccc->get_cc_regs(this);
1792 }
1793 return processor_t::get_cc_regs(this, cc) > 0;
1794 }
1795
1796 // policy-specific options
1797 bool by_slots() const { return policy == ARGREGS_BY_SLOTS; }
1798
1800 void set(argreg_policy_t _policy, const int *gprs, const int *fprs)
1801 {
1802 policy = _policy;
1803 set_regarray(&gpregs, gprs);
1804 set_regarray(&fpregs, fprs);
1805 calc_nregs();
1806 }
1807
1810 void append_registers(reg_kind_t kind, int first_reg, int last_reg)
1811 {
1812 intvec_t &regvec = kind == FPREGS ? fpregs : gpregs;
1813 size_t n = regvec.size();
1814 regvec.resize(n + last_reg - first_reg + 1);
1815 for ( int i = first_reg; i <= last_reg; ++i )
1816 regvec[n + i - first_reg] = i;
1817 }
1818 void set_registers(reg_kind_t kind, int first_reg, int last_reg)
1819 {
1820 intvec_t &regvec = kind == FPREGS ? fpregs : gpregs;
1821 regvec.clear();
1822 append_registers(kind, first_reg, last_reg);
1823 }
1824
1826 void reset()
1827 {
1828 set(ARGREGS_POLICY_UNDEFINED, nullptr, nullptr);
1829 }
1830
1832 static int regcount(callcnv_t cc)
1833 {
1834 callregs_t vr(cc);
1835 return vr.nregs;
1836 }
1837
1838 // return index of register, -1 else
1839 static int findreg(const intvec_t &regs, int r)
1840 {
1841 intvec_t::const_iterator p = regs.find(r);
1842 return p == regs.end() ? -1 : (p-regs.begin());
1843 }
1844
1847 bool reginds(int *gp_ind, int *fp_ind, int r) const
1848 {
1849 return findregs(gp_ind, fp_ind, r, gpregs, fpregs);
1850 }
1851
1852protected:
1855 bool findregs(int *gp_ind, int *fp_ind, int r, const intvec_t &gprs, const intvec_t &fprs) const
1856 {
1857 *gp_ind = *fp_ind = -1;
1858 return set_inds(gp_ind, fp_ind, findreg(gprs, r))
1859 || set_inds(fp_ind, gp_ind, findreg(fprs, r));
1860 }
1861};
1862
1863//--------------------------------------------------------------------------
1867
1870const comp_t COMP_MASK = 0x0F;
1871const comp_t COMP_UNK = 0x00;
1872const comp_t COMP_MS = 0x01;
1873const comp_t COMP_BC = 0x02;
1874const comp_t COMP_WATCOM = 0x03;
1875// const comp_t COMP_ = 0x04
1876// const comp_t COMP_ = 0x05
1877const comp_t COMP_GNU = 0x06;
1878const comp_t COMP_VISAGE = 0x07;
1879const comp_t COMP_BP = 0x08;
1880//----
1881const comp_t COMP_UNSURE = 0x80;
1883
1884
1887
1889
1890inline THREAD_SAFE comp_t get_comp(comp_t comp) { return(comp & COMP_MASK); }
1891
1892
1894
1895idaman const char *ida_export get_compiler_name(comp_t id);
1896
1897
1899
1900idaman const char *ida_export get_compiler_abbr(comp_t id);
1901
1904
1905
1907
1908idaman void ida_export get_compilers(compvec_t *ids, qstrvec_t *names, qstrvec_t *abbrs);
1909
1910
1912
1913inline THREAD_SAFE comp_t is_comp_unsure(comp_t comp) { return (comp & COMP_UNSURE); }
1914
1915
1917
1919
1920
1922
1923inline bool is_gcc() { return default_compiler() == COMP_GNU; }
1924
1925
1927
1928inline bool is_gcc32() { return is_gcc() && !inf_is_64bit(); }
1929
1930
1932
1933inline bool is_gcc64() { return is_gcc() && inf_is_64bit(); }
1934
1935
1937
1938inline bool gcc_layout() { return is_gcc() || (inf_get_abibits() & ABI_GCC_LAYOUT) != 0; }
1939
1940
1946
1947idaman bool ida_export set_compiler(
1948 const compiler_info_t &cc,
1949 int flags,
1950 const char *abiname=nullptr);
1951
1954#define SETCOMP_OVERRIDE 0x0001
1955#define SETCOMP_ONLY_ID 0x0002
1958#define SETCOMP_ONLY_ABI 0x0004
1959#define SETCOMP_BY_USER 0x0008
1961
1962
1964
1965inline bool idaapi set_compiler_id(comp_t id, const char *abiname=nullptr)
1966{
1967 compiler_info_t cc;
1968 cc.id = id;
1969 return set_compiler(cc, SETCOMP_ONLY_ID, abiname);
1970}
1971
1973
1974inline bool idaapi set_abi_name(const char *abiname, bool user_level = false)
1975{
1976 compiler_info_t cc;
1977 cc.id = 0;
1978 int flags = SETCOMP_ONLY_ABI | (user_level ? SETCOMP_BY_USER : 0);
1979 return set_compiler(cc, flags, abiname);
1980}
1981
1984
1985idaman ssize_t ida_export get_abi_name(qstring *out);
1986
1987
1993idaman bool ida_export append_abi_opts(const char *abi_opts, bool user_level = false);
1994idaman bool ida_export remove_abi_opts(const char *abi_opts, bool user_level = false);
1995
1999idaman bool ida_export set_compiler_string(const char *compstr, bool user_level);
2000
2001
2003inline bool use_golang_cc()
2004{
2005 return is_golang_cc(inf_get_callcnv());
2006}
2007
2008
2010inline void switch_to_golang()
2011{
2013 if ( default_compiler() == COMP_UNK )
2015}
2016
2019
2020//--------------------------------------------------------------------------
2021const size_t BADSIZE = size_t(-1);
2022#define MAX_FUNC_ARGS 256
2023
2024//--------------------------------------------------------------------------
2043
2047
2050#define HTI_CPP 0x00000001
2051#define HTI_INT 0x00000002
2052#define HTI_EXT 0x00000004
2053#define HTI_LEX 0x00000008
2054#define HTI_UNP 0x00000010
2055#define HTI_TST 0x00000020
2056#define HTI_FIL 0x00000040
2058#define HTI_MAC 0x00000080
2059#define HTI_NWR 0x00000100
2060#define HTI_NER 0x00000200
2061#define HTI_DCL 0x00000400
2062#define HTI_NDC 0x00000800
2063#define HTI_PAK 0x00007000
2064#define HTI_PAK_SHIFT 12
2068#define HTI_PAKDEF 0x00000000
2069#define HTI_PAK1 0x00001000
2070#define HTI_PAK2 0x00002000
2071#define HTI_PAK4 0x00003000
2072#define HTI_PAK8 0x00004000
2073#define HTI_PAK16 0x00005000
2074#define HTI_HIGH 0x00008000
2076#define HTI_LOWER 0x00010000
2077#define HTI_RAWARGS 0x00020000
2078#define HTI_RELAXED 0x00080000
2079#define HTI_NOBASE 0x00100000
2080#define HTI_SEMICOLON 0x00200000
2081#define HTI_STANDALONE 0x00400000
2086
2087
2095
2096typedef int idaapi h2ti_type_cb(
2097 const char *name,
2098 const tinfo_t &tif,
2099 const char *cmt,
2100 const uint64 *value,
2101 void *cb_data);
2102
2103
2106typedef AS_PRINTF(1, 2) int printer_t(const char *format, ...);
2107
2108
2121
2122idaman int ida_export h2ti(
2123 til_t *ti,
2124 lexer_t *lx,
2125 const char *input,
2126 int flags=HTI_HIGH,
2127 h2ti_type_cb *type_cb=nullptr,
2128 h2ti_type_cb *var_cb=nullptr,
2129 printer_t *print_cb=nullptr,
2130 void *_cb_data=nullptr,
2131 abs_t _isabs=ABS_UNK);
2132
2133
2137
2138inline THREAD_SAFE int convert_pt_flags_to_hti(int pt_flags)
2139{
2140 return ((pt_flags >> 4) & 0x1f) << HTI_PAK_SHIFT;
2141}
2142
2143
2155
2156idaman bool ida_export parse_decl(
2157 tinfo_t *out_tif,
2158 qstring *out_name,
2159 til_t *til,
2160 const char *decl,
2161 int pt_flags);
2162
2163
2166#define PT_SIL 0x0001
2167#define PT_NDC 0x0002
2168#define PT_TYP 0x0004
2169#define PT_VAR 0x0008
2170#define PT_PACKMASK 0x0070
2171#define PT_HIGH 0x0080
2173#define PT_LOWER 0x0100
2174#define PT_REPLACE 0x0200
2175#define PT_RAWARGS 0x0400
2176#define PT_RELAXED 0x1000
2177#define PT_EMPTY 0x2000
2178#define PT_SEMICOLON 0x4000
2179#define PT_SYMBOL 0x8000
2182
2183
2193
2194idaman int ida_export parse_decls(
2195 til_t *til,
2196 const char *input,
2197 printer_t *printer,
2198 int hti_flags);
2199
2200
2206
2207idaman bool ida_export print_type(qstring *out, ea_t ea, int prtype_flags);
2208
2209
2212#define PRTYPE_1LINE 0x00000
2213#define PRTYPE_MULTI 0x00001
2214#define PRTYPE_TYPE 0x00002
2215#define PRTYPE_PRAGMA 0x00004
2216#define PRTYPE_SEMI 0x00008
2217#define PRTYPE_CPP 0x00010
2218#define PRTYPE_DEF 0x00020
2219#define PRTYPE_NOARGS 0x00040
2220#define PRTYPE_NOARRS 0x00080
2221#define PRTYPE_NORES 0x00100
2222#define PRTYPE_RESTORE 0x00200
2223#define PRTYPE_NOREGEX 0x00400
2224#define PRTYPE_COLORED 0x00800
2225#define PRTYPE_METHODS 0x01000
2226#define PRTYPE_1LINCMT 0x02000
2227#define PRTYPE_HEADER 0x04000
2228#define PRTYPE_OFFSETS 0x08000
2229#define PRTYPE_MAXSTR 0x10000
2230#define PRTYPE_TAIL 0x20000
2231#define PRTYPE_ARGLOCS 0x40000
2233
2235
2236
2240
2241
2260
2261idaman int ida_export get_named_type(
2262 const til_t *ti,
2263 const char *name,
2264 int ntf_flags,
2265 const type_t **type=nullptr,
2266 const p_list **fields=nullptr,
2267 const char **cmt=nullptr,
2268 const p_list **fieldcmts=nullptr,
2269 sclass_t *sclass=nullptr,
2270 uint32 *value=nullptr);
2271
2274#define NTF_TYPE 0x0001
2275#define NTF_SYMU 0x0008
2276#define NTF_SYMM 0x0000
2278#define NTF_NOBASE 0x0002
2279#define NTF_REPLACE 0x0004
2280#define NTF_UMANGLED 0x0008
2281#define NTF_NOCUR 0x0020
2282#define NTF_64BIT 0x0040
2283#define NTF_FIXNAME 0x0080
2285#define NTF_IDBENC 0x0100
2288#define NTF_CHKSYNC 0x0200
2290#define NTF_NO_NAMECHK 0x0400
2292#define NTF_COPY 0x1000
2294
2295
2299
2300inline int idaapi get_named_type64(
2301 const til_t *ti,
2302 const char *name,
2303 int ntf_flags,
2304 const type_t **type=nullptr,
2305 const p_list **fields=nullptr,
2306 const char **cmt=nullptr,
2307 const p_list **fieldcmts=nullptr,
2308 sclass_t *sclass=nullptr,
2309 uint64 *value=nullptr)
2310{
2311 return get_named_type(ti, name, ntf_flags | NTF_64BIT,
2312 type, fields, cmt, fieldcmts, sclass, (uint32 *)value);
2313}
2314
2315
2360
2363
2364idaman const char *ida_export tinfo_errstr(tinfo_code_t code);
2365
2366
2372
2373idaman bool ida_export del_named_type(til_t *ti, const char *name, int ntf_flags);
2374
2375
2381
2382idaman const char *ida_export first_named_type(const til_t *ti, int ntf_flags);
2383
2384
2387
2388idaman const char *ida_export next_named_type(
2389 const til_t *ti,
2390 const char *name,
2391 int ntf_flags);
2392
2393
2401idaman uint32 ida_export copy_named_type(
2402 til_t *dsttil,
2403 const til_t *srctil,
2404 const char *name);
2405
2413idaman bool ida_export decorate_name(
2414 qstring *out,
2415 const char *name,
2416 bool should_decorate,
2418 const tinfo_t *type = nullptr);
2419
2421idaman bool ida_export gen_decorate_name(
2422 qstring *out,
2423 const char *name,
2424 bool should_decorate,
2425 callcnv_t cc,
2426 const tinfo_t *type);
2427
2430 qstring *out,
2431 const char *_name,
2432 bool should_decorate,
2433 callcnv_t /*cc*/,
2434 const tinfo_t &type) const
2435{
2436 return gen_decorate_name(out, _name, should_decorate, CM_CC_FASTCALL, &type);
2437}
2438
2444
2445idaman ssize_t ida_export calc_c_cpp_name(
2446 qstring *out,
2447 const char *name,
2448 const tinfo_t *type,
2449 int ccn_flags);
2452#define CCN_C 0x00 // prepare C name
2453#define CCN_CPP 0x01 // prepare C++ name
2455
2457
2458//--------------------------------------------------------------------------
2467
2470
2471idaman bool ida_export enable_numbered_types(til_t *ti, bool enable);
2472
2473
2475
2476idaman bool ida_export get_numbered_type(
2477 const til_t *ti,
2478 uint32 ordinal,
2479 const type_t **type=nullptr,
2480 const p_list **fields=nullptr,
2481 const char **cmt=nullptr,
2482 const p_list **fieldcmts=nullptr,
2483 sclass_t *sclass=nullptr);
2484
2485
2490
2491idaman uint32 ida_export alloc_type_ordinals(til_t *ti, int qty);
2492
2493
2495
2497
2498
2505
2506idaman uint32 ida_export get_ordinal_limit(const til_t *ti=nullptr);
2507
2508
2512
2513inline uint32 get_ordinal_count(const til_t *ti=nullptr)
2514{
2515 uint32 maxord = get_ordinal_limit(ti);
2516 return maxord == 0 || maxord == uint32(-1) ? 0 : maxord - 1;
2517}
2518
2519
2521
2522idaman bool ida_export del_numbered_type(til_t *ti, uint32 ordinal);
2523
2524
2528
2529idaman bool ida_export set_type_alias(til_t *ti, uint32 src_ordinal, uint32 dst_ordinal);
2530
2531
2535
2536idaman uint32 ida_export get_alias_target(const til_t *ti, uint32 ordinal);
2537
2538
2540
2541idaman int32 ida_export get_type_ordinal(const til_t *ti, const char *name);
2542
2545
2546idaman const char *ida_export get_numbered_type_name(const til_t *ti, uint32 ordinal);
2547
2548
2553
2554idaman ssize_t ida_export create_numbered_type_name(qstring *buf, int32 ord);
2555
2556
2559
2560idaman bool ida_export is_ordinal_name(const char *name, uint32 *ord=nullptr);
2561
2562
2564
2565idaman void ida_export build_anon_type_name(
2566 qstring *buf,
2567 const type_t *type,
2568 const p_list *fields);
2569
2570
2579
2580idaman int ida_export compact_numbered_types(
2581 til_t *ti,
2582 uint32 min_ord=0,
2583 intvec_t *p_ordmap=nullptr,
2584 int flags=0);
2585
2586
2590idaman bool ida_export is_type_choosable(const til_t *ti, uint32 ordinal);
2591
2596idaman void ida_export set_type_choosable(til_t *ti, uint32 ordinal, bool value);
2597
2599
2600//--------------------------------------------------------------------------
2603
2607
2608idaman ea_t ida_export get_vftable_ea(uint32 ordinal);
2609
2610
2614
2615idaman uint32 ida_export get_vftable_ordinal(ea_t vftable_ea);
2616
2617
2622
2623idaman bool ida_export set_vftable_ea(uint32 ordinal, ea_t vftable_ea);
2624
2625
2629
2630inline bool del_vftable_ea(uint32 ordinal) { return set_vftable_ea(ordinal, BADADDR); }
2631
2632
2634
2635//--------------------------------------------------------------------------
2636// ALIGNMENT
2637
2640
2641inline size_t get_default_align() { return inf_get_cc_defalign(); }
2642
2643
2649
2650inline THREAD_SAFE void align_size(size_t &cur_tot_size, size_t elem_size, size_t algn)
2651{
2652 size_t al = elem_size;
2653 if ( algn != 0 && algn < al )
2654 al = algn;
2655 cur_tot_size = align_up(cur_tot_size, al);
2656}
2657
2665
2666idaman bool ida_export deref_ptr(
2667 ea_t *ptr_ea,
2668 const tinfo_t &tif,
2669 ea_t *closure_obj=nullptr);
2670
2671
2676
2677idaman bool ida_export remove_tinfo_pointer(tinfo_t *tif, const char **pname, const til_t *til=nullptr);
2678
2684
2685idaman int ida_export add_til(const char *name, int flags);
2686
2690#define ADDTIL_DEFAULT 0x0000
2691#define ADDTIL_INCOMP 0x0001
2692#define ADDTIL_SILENT 0x0002
2694
2698#define ADDTIL_FAILED 0
2699#define ADDTIL_OK 1
2700#define ADDTIL_COMP 2
2701#define ADDTIL_ABORTED 3
2703
2704
2706
2707idaman bool ida_export del_til(const char *name);
2708
2709
2714
2715idaman bool ida_export apply_named_type(ea_t ea, const char *name);
2716
2717
2725
2726idaman bool ida_export apply_tinfo(
2727 ea_t ea,
2728 const tinfo_t &tif,
2729 uint32 flags);
2730
2734#define TINFO_GUESSED 0x0000
2735#define TINFO_DEFINITE 0x0001
2736#define TINFO_DELAYFUNC 0x0002
2739#define TINFO_STRICT 0x0004
2741
2742
2750
2751idaman bool ida_export apply_cdecl(til_t *til, ea_t ea, const char *decl, int flags=0);
2752
2753
2764
2765idaman bool ida_export apply_callee_tinfo(ea_t caller, const tinfo_t &tif);
2766
2767
2774
2775idaman bool ida_export get_arg_addrs(eavec_t *out, ea_t caller);
2776
2777
2790
2791idaman bool ida_export apply_once_tinfo_and_name(
2792 ea_t dea,
2793 const tinfo_t &tif,
2794 const char *name);
2795
2796
2797// To retrieve the type information attach to an address, use get_tinfo() function
2798// (see nalt.hpp)
2799
2800
2804
2805idaman int ida_export guess_tinfo(tinfo_t *out, tid_t id);
2806
2810#define GUESS_FUNC_FAILED 0
2811#define GUESS_FUNC_TRIVIAL 1
2812#define GUESS_FUNC_OK 2
2814
2815
2816// The following functions should eventually be replaced by exported functions
2817#ifndef __KERNEL__
2819inline void set_c_header_path(const char *incdir) { setinf_buf(INF_H_PATH, incdir); }
2820
2823
2825inline void set_c_macros(const char *macros) { setinf_buf(INF_C_MACROS, macros); }
2826
2829#endif
2830
2831//------------------------------------------------------------------------
2832// HIGH LEVEL FUNCTIONS TO SUPPORT TILS IN THE IDA KERNEL
2833
2836
2837idaman til_t *ida_export get_idati();
2838
2839
2846
2847idaman bool ida_export get_idainfo_by_type(
2848 size_t *out_size,
2849 flags64_t *out_flags,
2850 opinfo_t *out_mt,
2851 const tinfo_t &tif,
2852 size_t *out_alsize=nullptr);
2853
2854
2858
2859idaman bool ida_export get_tinfo_by_flags(tinfo_t *out, flags64_t flags);
2860
2861//------------------------------------------------------------------------
2862// Type information object: tinfo_t
2863
2864struct ptr_type_data_t;
2865struct udt_type_data_t;
2866struct enum_type_data_t;
2867struct array_type_data_t;
2868struct typedef_type_data_t;
2870struct udtmembervec_t;
2871
2908
2913{
2914 ETF_NO_SAVE = 0x00000001,
2918 ETF_NO_LAYOUT = 0x00000002,
2919 ETF_MAY_DESTROY = 0x00000004,
2920 ETF_COMPATIBLE = 0x00000008,
2921 ETF_FUNCARG = 0x00000010,
2922 ETF_FORCENAME = 0x00000020,
2923 ETF_AUTONAME = 0x00000040,
2924 ETF_BYTIL = 0x00000080,
2925 ETF_NO_ARRAY = 0x00000100,
2926};
2927
2928
2938
2947
2950{
2951 GTS_NESTED = 0x01,
2953};
2954
2958#define SUDT_SORT 0x0001
2959#define SUDT_ALIGN 0x0002
2961#define SUDT_GAPS 0x0004
2962#define SUDT_UNEX 0x0008
2966#define SUDT_FAST 0x0010
2967
2968#define SUDT_CONST 0x0040
2969#define SUDT_VOLATILE 0x0080
2970
2971#define SUDT_TRUNC 0x0100
2972#define SUDT_SERDEF 0x0200
2974
2976
2978#define DECLARE_TINFO_HELPERS(decl)\
2979decl void ida_export copy_tinfo_t(tinfo_t *_this, const tinfo_t &r); \
2980decl bool ida_export detach_tinfo_t(tinfo_t *_this); \
2981decl void ida_export clear_tinfo_t(tinfo_t *_this);\
2982decl bool ida_export create_tinfo(tinfo_t *_this, type_t bt, type_t bt2, void *ptr);\
2983decl int ida_export verify_tinfo(typid_t typid);\
2984decl bool ida_export get_tinfo_details(typid_t typid, type_t bt2, void *buf);\
2985decl size_t ida_export get_tinfo_size(uint32 *p_effalign, typid_t typid, int gts_code);\
2986decl size_t ida_export get_tinfo_pdata(void *outptr, typid_t typid, int what);\
2987decl size_t ida_export get_tinfo_property(typid_t typid, int gta_prop);\
2988decl 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);\
2989decl size_t ida_export set_tinfo_property(tinfo_t *tif, int sta_prop, size_t x);\
2990decl 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);\
2991decl bool ida_export serialize_tinfo(qtype *type, qtype *fields, qtype *fldcmts, const tinfo_t *tif, int sudt_flags);\
2992decl 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);\
2993decl int ida_export find_tinfo_udt_member(udm_t *udm, typid_t typid, int strmem_flags);\
2994decl 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);\
2995decl const char *ida_export dstr_tinfo(const tinfo_t *tif);\
2996decl 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);\
2997decl bool ida_export compare_tinfo(typid_t t1, typid_t t2, int tcflags);\
2998decl int ida_export lexcompare_tinfo(typid_t t1, typid_t t2, int);\
2999decl bool ida_export get_stock_tinfo(tinfo_t *tif, stock_type_id_t id);\
3000decl uint64 ida_export read_tinfo_bitfield_value(typid_t typid, uint64 v, int bitoff);\
3001decl uint64 ida_export write_tinfo_bitfield_value(typid_t typid, uint64 dst, uint64 v, int bitoff);\
3002decl bool ida_export get_tinfo_attr(typid_t typid, const qstring &key, bytevec_t *bv, bool all_attrs);\
3003decl bool ida_export set_tinfo_attr(tinfo_t *tif, const type_attr_t &ta, bool may_overwrite);\
3004decl bool ida_export del_tinfo_attr(tinfo_t *tif, const qstring &key, bool make_copy);\
3005decl bool ida_export get_tinfo_attrs(typid_t typid, type_attrs_t *tav, bool include_ref_attrs);\
3006decl bool ida_export set_tinfo_attrs(tinfo_t *tif, type_attrs_t *ta);\
3007decl uint32 ida_export score_tinfo(const tinfo_t *tif);\
3008decl tinfo_code_t ida_export save_tinfo(tinfo_t *tif, til_t *til, size_t ord, const char *name, int ntf_flags);\
3009decl bool ida_export append_tinfo_covered(rangeset_t *out, typid_t typid, uint64 offset);\
3010decl bool ida_export calc_tinfo_gaps(rangeset_t *out, typid_t typid);\
3011decl bool ida_export name_requires_qualifier(qstring *out, typid_t typid, const char *name, uint64 offset);\
3012decl 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); \
3013decl size_t ida_export value_repr_t__print_(const value_repr_t *_this, qstring *result, bool colored); \
3014decl bool ida_export value_repr_t__parse_value_repr(value_repr_t *_this, const qstring &attr, type_t target_type); \
3015decl ssize_t ida_export udt_type_data_t__find_member(const udt_type_data_t *_this, udm_t *udm, int strmem_flags); \
3016decl ssize_t ida_export udt_type_data_t__get_best_fit_member(const udt_type_data_t *_this, asize_t disp); \
3017decl uchar ida_export enum_type_data_t__get_max_serial(const enum_type_data_t *ei, uint64 value); \
3018decl tinfo_code_t ida_export enum_type_data_t__set_value_repr(enum_type_data_t *ei, const value_repr_t &repr); \
3019decl tinfo_code_t ida_export enum_type_data_t__get_value_repr(const enum_type_data_t *ei, value_repr_t *repr); \
3020decl 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); \
3021decl ssize_t ida_export get_udm_by_tid(tinfo_t *tif, udm_t *udm, tid_t tid); \
3022decl ssize_t ida_export get_edm_by_tid(tinfo_t *tif, edm_t *edm, tid_t tid); \
3023decl bool ida_export get_type_by_tid(tinfo_t *tif, tid_t tid); \
3024decl tid_t ida_export get_tinfo_tid(tinfo_t *tif, bool force_tid); \
3025decl ssize_t ida_export get_tinfo_by_edm_name(tinfo_t *tif, const til_t *til, const char *mname); \
3026decl ssize_t ida_export get_frame_var(tinfo_t *tif, sval_t *actval, const insn_t &insn, const op_t *x, sval_t v); \
3027decl bool ida_export tinfo_get_func_frame(tinfo_t *tif, const func_t *pfn); \
3028
3029DECLARE_TINFO_HELPERS(idaman)
3030
3031
3039const int FIRST_NONTRIVIAL_TYPID = 0x100;
3040const int TYPID_ISREF = 0x100;
3041const int TYPID_SHIFT = 9;
3043
3045class tinfo_t // #tinfo_t #tif
3046{
3047 typid_t typid;
3048 bool create_type(type_t decl_type, type_t bt2, void *details)
3049 {
3050 return create_tinfo(this, decl_type, bt2, details);
3051 }
3056 bool get_type_details(type_t bt2, void *buf) const { return get_tinfo_details(typid, bt2, buf); }
3057 void copy(const tinfo_t &r) { copy_tinfo_t(this, r); }
3058 DECLARE_TINFO_HELPERS(friend)
3059 friend struct type_detail_t;
3060 friend tinfo_t remove_pointer(const tinfo_t &tif);
3062 enum gta_prop_t
3063 {
3064 GTA_DECLALIGN,
3065 GTA_RESOLVE,
3066 GTA_REALTYPE,
3067 GTA_TYPE_SIGN,
3068 GTA_FROM_SUBTIL,
3069 GTA_IS_FORWARD,
3070 GTA_IS_FUNCPTR,
3071 GTA_ORDINAL,
3072 GTA_FINAL_ORDINAL,
3073 GTA_PTR_OBJ,
3074 GTA_SAFE_PTR_OBJ,
3075 GTA_ARRAY_ELEM,
3076 GTA_ARRAY_NELEMS,
3077 GTA_PTRARR_SUBTIF,
3078 GTA_PTRARR_SIZE,
3079 GTA_UNPADDED_SIZE,
3080 GTA_UDT_NMEMBERS,
3081 GTA_IS_SMALL_UDT,
3082 GTA_ONEMEM_TYPE,
3083 GTA_ENUM_BASE_TYPE,
3084 GTA_FUNC_CC,
3085 GTA_PURGED_BYTES,
3086 GTA_IS_HIGH_TYPE,
3087 GTA_FUNC_NARGS,
3088 GTA_FUNC_RET,
3089 GTA_FUNC_ARG,
3090 GTA_LAST_FUNC_ARG = GTA_FUNC_ARG + 255,
3091 GTA_IS_SSE_TYPE,
3092 GTA_IS_ANON_UDT,
3093 GTA_OBSOLETE1,
3094 GTA_HAS_VFTABLE,
3095 GTA_IS_SHIFTED_PTR,
3096 GTA_IS_VARSTRUCT,
3097 GTA_IS_VARMEMBER,
3098 GTA_IS_TYPEDEF,
3099 GTA_FINAL_ELEM,
3100 GTA_FORWARD_TYPE,
3101 GTA_BITMASK,
3102 GTA_ENUM_RADIX,
3103 GTA_EDM,
3104 GTA_EDM_BYVAL,
3105 GTA_EDM_BYNAME,
3106 GTA_HAS_UNION,
3107 GTA_UDM_TID,
3108 GTA_ALIAS,
3109 GTA_EDM_TID,
3110 GTA_FRAME_FUNC,
3111 GTA_UDM_IS_BYTIL,
3112 GTA_OBSOLETE2,
3113 GTA_EDT_NMEMBERS,
3114 GTA_ENUM_WIDTH,
3115 GTA_ENUM_REPR,
3116 GTA_UDT_BITS,
3117 };
3118 enum sta_prop_t
3119 {
3120 STA_DECLALIGN,
3121 STA_TYPE_SIGN,
3122 STA_UDT_ALIGN,
3123 STA_UDT_METHODS,
3124 STA_RENAME,
3125 STA_COMMENT,
3126 STA_CLR_MODIFS,
3127 STA_SET_SDA,
3128 STA_SET_PACK,
3129 STA_ADD_UDM,
3130 STA_DEL_UDMS,
3131 STA_UDM_NAME,
3132 STA_UDM_TYPE,
3133 STA_UDM_CMT,
3134 STA_UDM_REPR,
3135 STA_EXPAND_UDT,
3136 STA_ENUM_WIDTH,
3137 STA_ENUM_SIGN,
3138 STA_BITMASK,
3139 STA_ENUM_REPR,
3140 STA_ADD_EDM,
3141 STA_DEL_EDMS,
3142 STA_EDM_NAME,
3143 STA_EDM_CMT,
3144 STA_EDIT_EDM,
3145 STA_ALIAS,
3146 STA_ALIGNMENT,
3147 STA_UDM_SET_BYTIL,
3148 STA_FIXED_STRUCT,
3149 STA_STRUCT_SIZE,
3150 STA_FUNCARG_NAME,
3151 STA_FUNCARG_TYPE,
3152 STA_FUNC_RETTYPE,
3153 STA_DEL_FUNCARGS,
3154 STA_ADD_FUNCARG,
3155 STA_FUNC_CC,
3156 STA_ENUM_RADIX,
3157 STA_FUNCARG_LOC,
3158 STA_FUNC_RETLOC,
3159 STA_TUPLE,
3160 };
3161 enum gta_pdata_t
3162 {
3163 GTP_NAME,
3164 GTP_NEXT_NAME,
3165 GTP_FINAL_NAME,
3166 GTP_TIL,
3167 GTP_UDT_METHODS,
3168 GTP_COMMENT,
3169 GTP_RPTCMT,
3170 GTP_BIT_BUCKETS,
3171 GTP_NICE_NAME,
3172 };
3173
3174public:
3176 tinfo_t() : typid(BT_UNK) {}
3178 explicit tinfo_t(type_t decl_type) : typid(decl_type) {}
3180 explicit tinfo_t(const char *decl, til_t *til=nullptr, int pt_flags=0)
3181 : typid(0)
3182 {
3183 parse(decl, til, pt_flags);
3184 }
3185
3187 tinfo_t(const tinfo_t &r) : typid(0) { copy(r); }
3189 tinfo_t &operator=(const tinfo_t &r) { copy(r); return *this; }
3193 void clear() { clear_tinfo_t(this); }
3195 void swap(tinfo_t &r) { typid_t tmp = typid; typid = r.typid; r.typid = tmp; }
3197
3198
3209 inline bool get_named_type(
3210 const til_t *til,
3211 const char *name,
3213 bool resolve=true,
3214 bool try_ordinal=true);
3215
3216 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); }
3217
3228 inline bool get_numbered_type(
3229 const til_t *til,
3230 uint32 ordinal,
3232 bool resolve=true);
3233
3234 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); }
3235
3241 bool detach() { return detach_tinfo_t(this); }
3242
3245 qtype *type,
3246 qtype *fields=nullptr,
3247 qtype *fldcmts=nullptr,
3248 int sudt_flags=SUDT_FAST|SUDT_TRUNC) const
3249 {
3250 return serialize_tinfo(type, fields, fldcmts, this, sudt_flags);
3251 }
3252
3255 const til_t *til,
3256 const type_t **ptype,
3257 const p_list **pfields=nullptr,
3258 const p_list **pfldcmts=nullptr,
3259 const char *cmt=nullptr)
3260 {
3261 return deserialize_tinfo(this, til, ptype, pfields, pfldcmts, cmt);
3262 }
3263
3265 const til_t *til,
3266 const qtype *ptype,
3267 const qtype *pfields=nullptr,
3268 const qtype *pfldcmts=nullptr,
3269 const char *cmt=nullptr)
3270 {
3271 const type_t *tp = ptype->begin();
3272 const p_list *fp = pfields == nullptr ? nullptr : pfields->begin();
3273 const p_list *cp = pfldcmts == nullptr ? nullptr : pfldcmts->begin();
3274 const p_list **pfp = fp == nullptr ? nullptr : &fp;
3275 const p_list **pcp = cp == nullptr ? nullptr : &cp;
3276 return deserialize(til, &tp, pfp, pcp, cmt);
3277 }
3278
3285 bool is_correct() const { return verify_tinfo(typid) == 0; }
3286
3298 type_t get_realtype(bool full=false) const { return (type_t)get_tinfo_property(typid, full ? GTA_RESOLVE : GTA_REALTYPE); }
3299
3305 THREAD_SAFE type_t get_decltype() const { return type_t(typid); }
3306
3308 THREAD_SAFE bool empty() const { return get_decltype() == BT_UNK; }
3309
3311 bool present() const { return get_realtype() != BT_UNK; }
3312
3317 size_t get_size(uint32 *p_effalign=nullptr, int gts_code=0) const { return get_tinfo_size(p_effalign, typid, gts_code); }
3318
3321 size_t get_unpadded_size() const { return get_tinfo_property(typid, GTA_UNPADDED_SIZE); }
3322
3326 {
3327 uint32 alignment = 0;
3328 get_size(&alignment);
3329 return alignment;
3330 }
3331
3333 type_sign_t get_sign() const { return get_tinfo_property(typid, GTA_TYPE_SIGN); }
3334
3336 bool is_signed() const { return get_sign() == type_signed; }
3337
3339 bool is_unsigned() const { return get_sign() == type_unsigned; }
3340
3342 uchar get_declalign() const { return uchar(get_tinfo_property(typid, GTA_DECLALIGN)); }
3343
3345 THREAD_SAFE bool is_typeref() const { return (typid & TYPID_ISREF) != 0; }
3346
3348 THREAD_SAFE bool has_details() const { return typid >= FIRST_NONTRIVIAL_TYPID; }
3349
3355 bool get_type_name(qstring *out) const { return is_typeref() && get_tinfo_pdata(out, typid, GTP_NAME); }
3356
3359 bool get_nice_type_name(qstring *out) const { return is_typeref() && get_tinfo_pdata(out, typid, GTP_NICE_NAME); }
3360
3365 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)); }
3366
3370 bool get_final_type_name(qstring *out) const { return is_typeref() && get_tinfo_pdata(out, typid, GTP_FINAL_NAME); }
3371
3375 bool get_next_type_name(qstring *out) const { return is_typeref() && get_tinfo_pdata(out, typid, GTP_NEXT_NAME); }
3376
3386 tid_t get_tid() const { return get_tinfo_tid((tinfo_t *)this, false); }
3387
3394 tid_t force_tid() { return get_tinfo_tid(this, true); }
3395
3397 uint32 get_ordinal() const { return get_tinfo_property(typid, GTA_ORDINAL); }
3398
3400 uint32 get_final_ordinal() const { return get_tinfo_property(typid, GTA_FINAL_ORDINAL); }
3401
3403 til_t *get_til() const { til_t *til; get_tinfo_pdata(&til, typid, GTP_TIL); return til; }
3404
3408 bool is_from_subtil() const { return is_typeref() && get_tinfo_property(typid, GTA_FROM_SUBTIL); }
3409
3412 bool is_forward_decl() const { return bool(get_tinfo_property(typid, GTA_IS_FORWARD)); }
3413
3417 type_t get_forward_type() const { return get_tinfo_property(typid, GTA_FORWARD_TYPE); }
3421
3425 bool is_typedef() const { return get_tinfo_property(typid, GTA_IS_TYPEDEF) != 0; }
3426
3429 int get_type_cmt(qstring *out) const { return has_details() ? get_tinfo_pdata(out, typid, GTP_COMMENT) : 0; }
3430
3432 bool get_type_rptcmt(qstring *out) const { return has_details() && get_tinfo_pdata(out, typid, GTP_RPTCMT); }
3433
3434 THREAD_SAFE bool is_decl_const() const { return is_type_const(get_decltype()); }
3435 THREAD_SAFE bool is_decl_volatile() const { return is_type_volatile(get_decltype()); }
3436 THREAD_SAFE bool is_decl_void() const { return is_type_void(get_decltype()); }
3437 THREAD_SAFE bool is_decl_partial() const { return is_type_partial(get_decltype()); }
3438 THREAD_SAFE bool is_decl_unknown() const { return is_type_unknown(get_decltype()); }
3439 THREAD_SAFE bool is_decl_last() const { return is_typeid_last(get_decltype()); }
3440 THREAD_SAFE bool is_decl_ptr() const { return is_type_ptr(get_decltype()); }
3441 THREAD_SAFE bool is_decl_array() const { return is_type_array(get_decltype()); }
3442 THREAD_SAFE bool is_decl_func() const { return is_type_func(get_decltype()); }
3443 THREAD_SAFE bool is_decl_complex() const { return is_type_complex(get_decltype()); }
3444 THREAD_SAFE bool is_decl_typedef() const { return is_type_typedef(get_decltype()); }
3445 THREAD_SAFE bool is_decl_sue() const { return is_type_sue(get_decltype()); }
3446 THREAD_SAFE bool is_decl_struct() const { return is_type_struct(get_decltype()); }
3447 THREAD_SAFE bool is_decl_union() const { return is_type_union(get_decltype()); }
3448 THREAD_SAFE bool is_decl_udt() const { return is_type_struni(get_decltype()); }
3449 THREAD_SAFE bool is_decl_enum() const { return is_type_enum(get_decltype()); }
3450 THREAD_SAFE bool is_decl_bitfield() const { return is_type_bitfld(get_decltype()); }
3451 THREAD_SAFE bool is_decl_int128() const { return is_type_int128(get_decltype()); }
3452 THREAD_SAFE bool is_decl_int64() const { return is_type_int64(get_decltype()); }
3453 THREAD_SAFE bool is_decl_int32() const { return is_type_int32(get_decltype()); }
3454 THREAD_SAFE bool is_decl_int16() const { return is_type_int16(get_decltype()); }
3455 THREAD_SAFE bool is_decl_int() const { return is_type_int(get_decltype()); }
3456 THREAD_SAFE bool is_decl_char() const { return is_type_char(get_decltype()); }
3457 THREAD_SAFE bool is_decl_uint() const { return is_type_uint(get_decltype()); }
3458 THREAD_SAFE bool is_decl_uchar() const { return is_type_uchar(get_decltype()); }
3459 THREAD_SAFE bool is_decl_uint16() const { return is_type_uint16(get_decltype()); }
3460 THREAD_SAFE bool is_decl_uint32() const { return is_type_uint32(get_decltype()); }
3461 THREAD_SAFE bool is_decl_uint64() const { return is_type_uint64(get_decltype()); }
3462 THREAD_SAFE bool is_decl_uint128() const { return is_type_uint128(get_decltype()); }
3463 THREAD_SAFE bool is_decl_ldouble() const { return is_type_ldouble(get_decltype()); }
3464 THREAD_SAFE bool is_decl_double() const { return is_type_double(get_decltype()); }
3465 THREAD_SAFE bool is_decl_float() const { return is_type_float(get_decltype()); }
3466 THREAD_SAFE bool is_decl_tbyte() const { return is_type_tbyte(get_decltype()); }
3467 THREAD_SAFE bool is_decl_floating() const { return is_type_floating(get_decltype()); }
3468 THREAD_SAFE bool is_decl_bool() const { return is_type_bool(get_decltype()); }
3469 THREAD_SAFE bool is_decl_paf() const { return is_type_paf(get_decltype()); }
3470 THREAD_SAFE bool is_well_defined() const { return !empty() && !is_decl_partial() && !is_punknown(); }
3471
3472 // Probe the resolved type for various attributes:
3473 bool is_const() const { return is_type_const(get_realtype()); }
3474 bool is_volatile() const { return is_type_volatile(get_realtype()); }
3475 bool is_void() const { return is_type_void(get_realtype()); }
3476 bool is_partial() const { return is_type_partial(get_realtype()); }
3477 bool is_unknown() const { return is_type_unknown(get_realtype()); }
3478 bool is_ptr() const { return is_type_ptr(get_realtype()); }
3479 bool is_array() const { return is_type_array(get_realtype()); }
3480 bool is_func() const { return is_type_func(get_realtype()); }
3481 bool is_complex() const { return is_type_complex(get_realtype()); }
3482 bool is_struct() const { return is_type_struct(get_realtype()); }
3483 bool is_union() const { return is_type_union(get_realtype()); }
3484 bool is_udt() const { return is_type_struni(get_realtype()); }
3485 bool is_enum() const { return is_type_enum(get_realtype()); }
3486 bool is_sue() const { return is_type_sue(get_realtype()); }
3487 bool is_bitfield() const { return is_type_bitfld(get_realtype()); }
3488 bool is_int128() const { return is_type_int128(get_realtype()); }
3489 bool is_int64() const { return is_type_int64(get_realtype()); }
3490 bool is_int32() const { return is_type_int32(get_realtype()); }
3491 bool is_int16() const { return is_type_int16(get_realtype()); }
3492 bool is_int() const { return is_type_int(get_realtype()); }
3493 bool is_char() const { return is_type_char(get_realtype()); }
3494 bool is_uint() const { return is_type_uint(get_realtype()); }
3495 bool is_uchar() const { return is_type_uchar(get_realtype()); }
3496 bool is_uint16() const { return is_type_uint16(get_realtype()); }
3497 bool is_uint32() const { return is_type_uint32(get_realtype()); }
3498 bool is_uint64() const { return is_type_uint64(get_realtype()); }
3499 bool is_uint128() const { return is_type_uint128(get_realtype()); }
3500 bool is_ldouble() const { return is_type_ldouble(get_realtype()); }
3501 bool is_double() const { return is_type_double(get_realtype()); }
3502 bool is_float() const { return is_type_float(get_realtype()); }
3503 bool is_tbyte() const { return is_type_tbyte(get_realtype()); }
3504 bool is_bool() const { return is_type_bool(get_realtype()); }
3505 bool is_paf() const { return is_type_paf(get_realtype()); }
3507 bool is_integral() const { return is_type_integral(get_realtype()); }
3509 bool is_floating() const { return is_type_floating(get_realtype()); }
3510 bool is_arithmetic() const { return is_type_arithmetic(get_realtype()); }
3513 bool is_scalar() const { type_t bt = get_realtype(); return get_base_type(bt) <= BT_PTR || is_type_enum(bt); }
3514
3517 {
3518 return get_type_details(BT_PTR, pi);
3519 }
3520
3523 {
3524 return get_type_details(BT_ARRAY, ai);
3525 }
3526
3529 {
3530 return get_type_details(BTF_ENUM, ei);
3531 }
3532
3535 {
3536 return get_type_details(BT_BITFIELD, bi);
3537 }
3538
3541 {
3542 return get_type_details(BTF_STRUCT|gtd, udt);
3543 }
3544
3547 {
3548 return get_type_details(BT_FUNC|gtd, fi);
3549 }
3550
3552 bool is_funcptr() const { return get_tinfo_property(typid, GTA_IS_FUNCPTR) != 0; }
3553
3555 bool is_shifted_ptr() const { return get_tinfo_property(typid, GTA_IS_SHIFTED_PTR) != 0; }
3556
3558 bool is_varstruct() const { return get_tinfo_property(typid, GTA_IS_VARSTRUCT) != 0; }
3559
3563 bool is_varmember() const { return get_tinfo_property(typid, GTA_IS_VARMEMBER) != 0; }
3564
3566 int get_ptrarr_objsize() const { return get_tinfo_property(typid, GTA_PTRARR_SIZE); }
3567
3570 tinfo_t get_ptrarr_object() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_PTRARR_SUBTIF); return r; }
3571
3575 tinfo_t get_pointed_object() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_PTR_OBJ); return r; }
3576
3578 bool is_pvoid() const { return get_pointed_object().is_void(); }
3579
3581 bool is_punknown() const { return get_pointed_object().is_unknown(); }
3582
3584 tinfo_t get_array_element() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_ARRAY_ELEM); return r; }
3585
3587 tinfo_t get_final_element() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_FINAL_ELEM); return r; }
3588
3590 int get_array_nelems() const { return get_tinfo_property(typid, GTA_ARRAY_NELEMS); }
3591
3594 {
3595 tinfo_t r;
3596 if ( n >= -1 && n < MAX_FUNC_ARGS )
3597 r.typid = get_tinfo_property(typid, GTA_FUNC_ARG+n);
3598 return r;
3599 }
3600
3602 tinfo_t get_rettype() const { return get_nth_arg(-1); }
3603
3605 int get_nargs() const { return get_tinfo_property(typid, GTA_FUNC_NARGS); }
3606
3608 callcnv_t get_cc() const { return (callcnv_t)get_tinfo_property(typid, GTA_FUNC_CC); }
3609 bool is_user_cc() const { return ::is_user_cc(get_cc()); }
3610 bool is_vararg_cc() const { return ::is_vararg_cc(get_cc()); }
3611 bool is_purging_cc() const { return ::is_purging_cc(get_cc()); }
3612
3614 int calc_purged_bytes() const { return get_tinfo_property(typid, GTA_PURGED_BYTES); }
3615
3617 bool is_high_func() const { return get_tinfo_property(typid, GTA_IS_HIGH_TYPE) != 0; }
3618
3621 bool get_methods(udtmembervec_t *methods) const { return get_tinfo_pdata(methods, typid, GTP_UDT_METHODS) != 0; }
3622
3626 bool get_bit_buckets(range64vec_t *buckets) const { return get_tinfo_pdata(buckets, typid, GTP_BIT_BUCKETS) != 0; }
3627
3635 int find_udm(udm_t *udm, int strmem_flags) const { return find_tinfo_udt_member(udm, typid, strmem_flags); }
3639#define STRMEM_MASK 0x000F
3640#define STRMEM_OFFSET 0x0000
3642#define STRMEM_INDEX 0x0001
3644#define STRMEM_AUTO 0x0002
3647#define STRMEM_NAME 0x0003
3649#define STRMEM_TYPE 0x0004
3652#define STRMEM_SIZE 0x0005
3654#define STRMEM_MINS 0x0006
3655#define STRMEM_MAXS 0x0007
3656#define STRMEM_LOWBND 0x0008
3658#define STRMEM_NEXT 0x0009
3660
3661#define STRMEM_VFTABLE 0x10000000
3664#define STRMEM_SKIP_EMPTY 0x20000000
3668#define STRMEM_CASTABLE_TO 0x40000000
3671#define STRMEM_ANON 0x80000000
3674#define STRMEM_SKIP_GAPS 0x01000000
3678
3681 inline int find_udm(uint64 offset, int strmem_flags=0) const;
3682
3685 inline int find_udm(const char *name, int strmem_flags=0) const;
3686
3691 inline int get_udm(udm_t *out, const char *name) const;
3692
3697 inline int get_udm(udm_t *out, size_t index) const;
3698
3703 inline int get_udm_by_offset(udm_t *out, uint64 offset) const;
3704
3706 int get_udt_nmembers() const { return get_tinfo_property(typid, GTA_UDT_NMEMBERS); }
3707
3709 bool is_empty_udt() const { return get_udt_nmembers() == 0; }
3710
3712 bool is_small_udt() const { return get_tinfo_property(typid, GTA_IS_SMALL_UDT) != 0; }
3713
3715 uint32 get_udt_taudt_bits() const { return get_tinfo_property(typid, GTA_UDT_BITS); }
3716
3718 bool is_unaligned_struct() const { return (get_udt_taudt_bits() & TAUDT_UNALIGNED) != 0; }
3719
3721 bool is_msstruct() const { return (get_udt_taudt_bits() & TAUDT_MSSTRUCT) != 0; }
3722
3724 bool is_cpp_struct() const { return (get_udt_taudt_bits() & TAUDT_CPPOBJ) != 0; }
3725
3727 bool is_vftable() const { return (get_udt_taudt_bits() & TAUDT_VFTABLE) != 0; }
3728
3730 bool is_fixed_struct() const { return (get_udt_taudt_bits() & TAUDT_FIXED) != 0; }
3731
3733 bool is_tuple() const { return (get_udt_taudt_bits() & TAUDT_TUPLE) != 0; }
3734
3740 bool requires_qualifier(qstring *out, const char *name, uint64 offset) const { return name_requires_qualifier(out, typid, name, offset); }
3741
3745 bool append_covered(rangeset_t *out, uint64 offset=0) const { return append_tinfo_covered(out, typid, offset); }
3746
3749 bool calc_gaps(rangeset_t *out) const { return calc_tinfo_gaps(out, typid); }
3750
3752 bool is_one_fpval() const { return get_onemember_type().is_floating(); }
3753
3755 bool is_sse_type() const { return get_tinfo_property(typid, GTA_IS_SSE_TYPE) != 0; }
3756
3759 bool is_anonymous_udt() const { return get_tinfo_property(typid, GTA_IS_ANON_UDT) != 0; }
3760
3762 bool has_vftable() const { return get_tinfo_property(typid, GTA_HAS_VFTABLE) != 0; }
3763
3765 bool has_union() const { return get_tinfo_property(typid, GTA_HAS_UNION) != 0; }
3766
3769 size_t get_enum_nmembers() const { return get_tinfo_property(typid, GTA_EDT_NMEMBERS); }
3770
3772 bool is_empty_enum() const { return get_enum_nmembers() == 0; }
3773
3776 type_t get_enum_base_type() const { return (type_t)get_tinfo_property(typid, GTA_ENUM_BASE_TYPE); }
3777
3781 bool is_bitmask_enum() const { return get_tinfo_property(typid, GTA_BITMASK) != 0; }
3782
3786 int get_enum_radix() const { return get_tinfo_property(typid, GTA_ENUM_RADIX); }
3787
3790 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)); }
3791
3795 int get_enum_width() const { return get_tinfo_property(typid, GTA_ENUM_WIDTH); }
3797
3802 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); }
3803
3807 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)); }
3808
3815 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); }
3816
3822 tid_t get_edm_tid(size_t idx) const { return get_tinfo_property4(typid, GTA_EDM_TID, idx, 0, 0, 0); }
3823
3825 tinfo_t get_onemember_type() const { tinfo_t r; r.typid = get_tinfo_property(typid, GTA_ONEMEM_TYPE); return r; }
3826
3833 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; }
3834
3835
3840 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; }
3841
3843 uint32 calc_score() const { return score_tinfo(this); }
3844
3854 bool print(
3855 qstring *out,
3856 const char *name=nullptr,
3857 int prtype_flags=PRTYPE_1LINE,
3858 int indent=0,
3859 int cmtindent=0,
3860 const char *prefix=nullptr,
3861 const char *cmt=nullptr) const
3862 {
3863 return print_tinfo(out, prefix, indent, cmtindent, prtype_flags, this, name, cmt);
3864 }
3865
3867 const char *dstr() const { return dstr_tinfo(this); }
3868
3870 bool get_attrs(type_attrs_t *tav, bool all_attrs=false) const { return get_tinfo_attrs(typid, tav, all_attrs); }
3871
3873 bool get_attr(const qstring &key, bytevec_t *bv, bool all_attrs=true) const { return get_tinfo_attr(typid, key, bv, all_attrs); }
3874
3878 bool set_attrs(type_attrs_t *tav) { return set_tinfo_attrs(this, tav); }
3879
3881 bool set_attr(const type_attr_t &ta, bool may_overwrite=true) { return set_tinfo_attr(this, ta, may_overwrite); }
3882
3884 void del_attrs() { set_tinfo_attrs(this, nullptr); }
3885
3887 bool del_attr(const qstring &key, bool make_copy=true) { return del_tinfo_attr(this, key, make_copy); }
3888
3889 bool create_simple_type(type_t decl_type) { return create_type(decl_type, BT_INT, nullptr); }
3890 bool create_ptr(const ptr_type_data_t &p, type_t decl_type=BT_PTR) { return create_type(decl_type, BT_PTR, (void*)&p); }
3891 bool create_array(const array_type_data_t &p, type_t decl_type=BT_ARRAY) { return create_type(decl_type, BT_ARRAY, (void*)&p); }
3892 bool create_bitfield(const bitfield_type_data_t &p, type_t decl_type=BT_BITFIELD) { return create_type(decl_type, BT_BITFIELD, (void*)&p); }
3894 {
3896 return create_type(decl_type, bt2, (void *)&p);
3897 }
3898
3901 inline bool create_ptr(const tinfo_t &tif, uchar bps=0, type_t decl_type=BT_PTR);
3902 inline bool create_array(const tinfo_t &tif, uint32 nelems=0, uint32 base=0, type_t decl_type=BT_ARRAY);
3903 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); }
3904 inline void create_typedef(const til_t *til, uint ord, type_t decl_type=BTF_TYPEDEF) { get_numbered_type(til, ord, decl_type, false); }
3905 inline bool create_bitfield(uchar nbytes, uchar width, bool is_unsigned=false, type_t decl_type=BT_BITFIELD);
3907
3912 bool parse(const char *decl, til_t *til=nullptr, int pt_flags=0)
3913 {
3914 return ::parse_decl(this, nullptr, til, decl, pt_flags | PT_SEMICOLON);
3915 }
3916
3918 inline bool create_udt(bool is_union=false);
3919
3921 inline bool create_enum(bte_t bte=BTE_ALWAYS|BTE_HEX);
3922
3926 inline bool create_udt(udt_type_data_t &p);
3927 bool create_udt(udt_type_data_t &p, type_t decl_type) { return create_type(decl_type, BTF_STRUCT, &p); }
3929 bool create_func(func_type_data_t &p, type_t decl_type=BT_FUNC) { return create_type(decl_type, BT_FUNC, &p); }
3931
3940 ssize_t get_udm_by_tid(udm_t *udm, tid_t tid) { return ::get_udm_by_tid(this, udm, tid); }
3941 ssize_t get_edm_by_tid(edm_t *edm, tid_t tid) { return ::get_edm_by_tid(this, edm, tid); }
3942 bool get_type_by_tid(tid_t tid) { return ::get_type_by_tid(this, tid); }
3944
3950 ssize_t get_by_edm_name(const char *mname, const til_t *til=nullptr) { return ::get_tinfo_by_edm_name(this, til, mname); }
3951
3958 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); }
3959 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
3960 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); }
3961 tinfo_code_t save_type(int ntf_flags=NTF_TYPE|NTF_REPLACE) { return save_tinfo(this, nullptr, 0, nullptr, ntf_flags); }
3962 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); }
3964
3967 tinfo_code_t create_forward_decl(til_t *til, type_t decl_type, const char *name, int ntf_flags=0)
3968 {
3969 create_typedef(til, "", decl_type, false);
3970 return set_named_type(til, name, ntf_flags);
3971 }
3972
3982 static tinfo_t get_stock(stock_type_id_t id) { tinfo_t t; get_stock_tinfo(&t, id); return t; }
3983
3986 inline bool convert_array_to_ptr();
3987
3994 {
3995 tinfo_t tif = get_ptrarr_object();
3996 if ( tif.empty() )
3997 return false;
3998 swap(tif);
3999 return true;
4000 }
4001
4005 uint64 read_bitfield_value(uint64 v, int bitoff) const { return read_tinfo_bitfield_value(typid, v, bitoff); }
4006 uint64 write_bitfield_value(uint64 dst, uint64 v, int bitoff) const { return write_tinfo_bitfield_value(typid, dst, v, bitoff); }
4008
4012 type_t get_modifiers() const { return typid & TYPE_MODIF_MASK; }
4013 void set_modifiers(type_t mod) { if ( !empty() ) typid = (typid & ~TYPE_MODIF_MASK) | (mod & TYPE_MODIF_MASK); }
4014 void set_const() { if ( !empty() ) typid |= BTM_CONST; }
4015 void set_volatile() { if ( !empty() ) typid |= BTM_VOLATILE; }
4016 // remove modifiers for trivial types, without resolving the type
4018 // remove modifiers from non-trivial types. for example, if the type was defined
4019 // as "const struct s { int field; }", the "const" modifier will be removed.
4020 // however, these function cannot remove modifiers from typedefs (ex: typedef const int constint)
4021 bool clr_const() { return bool(set_tinfo_property(this, STA_CLR_MODIFS, BTM_CONST)); }
4022 bool clr_volatile() { return bool(set_tinfo_property(this, STA_CLR_MODIFS, BTM_VOLATILE)); }
4023 bool clr_const_volatile() { return bool(set_tinfo_property(this, STA_CLR_MODIFS, BTM_CONST|BTM_VOLATILE)); }
4025
4028 {
4029 return tinfo_code_t(set_tinfo_property4(this, STA_ALIGNMENT, declalign, 0, 0, etf_flags));
4030 }
4031#ifndef NO_OBSOLETE_FUNCS
4032 DEPRECATED bool set_declalign(uchar declalign) { return set_tinfo_property(this, STA_DECLALIGN, declalign) != 0; }
4033#endif
4034
4036 bool change_sign(type_sign_t sign) { return set_tinfo_property(this, STA_TYPE_SIGN, sign) != 0; }
4037
4040 bool calc_udt_aligns(int sudt_flags=SUDT_GAPS)
4041 { return set_tinfo_property(this, STA_UDT_ALIGN, sudt_flags) != 0; }
4042
4046 {
4047 return set_tinfo_property(this, STA_UDT_METHODS, size_t(&methods)) != 0;
4048 }
4049
4052 tinfo_code_t set_type_cmt(const char *cmt, bool is_regcmt=false, uint etf_flags=0)
4053 {
4054 return tinfo_code_t(set_tinfo_property4(this, STA_COMMENT, size_t(cmt), is_regcmt, etf_flags, 0));
4055 }
4056
4060 {
4061 return get_tinfo_property(typid, GTA_ALIAS);
4062 }
4063 bool is_aliased() const { return get_alias_target() != 0; }
4064
4068 bool set_type_alias(uint32 dest_ord)
4069 {
4070 return set_tinfo_property4(this, STA_ALIAS, dest_ord, 0, 0, 0) != 0;
4071 }
4072
4079 {
4080 return tinfo_code_t(set_tinfo_property4(this, STA_SET_SDA, sda, 0, 0, etf_flags));
4081 }
4082
4090 tinfo_code_t set_udt_pack(int pack, uint etf_flags=0)
4091 {
4092 return tinfo_code_t(set_tinfo_property4(this, STA_SET_PACK, pack, 0, 0, etf_flags));
4093 }
4094
4100 tid_t get_udm_tid(size_t idx) const { return get_tinfo_property4(typid, GTA_UDM_TID, idx, 0, 0, 0); }
4101
4111 tinfo_code_t add_udm(const udm_t &udm, uint etf_flags=0, size_t times=1, ssize_t idx=-1)
4112 {
4113 return tinfo_code_t(set_tinfo_property4(this, STA_ADD_UDM, size_t(&udm), times, idx, etf_flags));
4114 }
4115
4132 inline tinfo_code_t add_udm(
4133 const char *name,
4134 const tinfo_t &type,
4135 uint64 offset=0,
4136 uint etf_flags=0,
4137 size_t times=1,
4138 ssize_t idx=-1);
4139
4157 inline tinfo_code_t add_udm(
4158 const char *name,
4159 type_t type,
4160 uint64 offset=0,
4161 uint etf_flags=0,
4162 size_t times=1,
4163 ssize_t idx=-1);
4164
4181 inline tinfo_code_t add_udm(
4182 const char *name,
4183 const char *type,
4184 uint64 offset=0,
4185 uint etf_flags=0,
4186 size_t times=1,
4187 ssize_t idx=-1);
4188
4190 tinfo_code_t del_udm(size_t index, uint etf_flags=0)
4191 {
4192 return del_udms(index, index+1, etf_flags);
4193 }
4194
4196 tinfo_code_t del_udms(size_t idx1, size_t idx2, uint etf_flags=0)
4197 {
4198 return tinfo_code_t(set_tinfo_property4(this, STA_DEL_UDMS, idx1, idx2, 0, etf_flags));
4199 }
4200
4204 tinfo_code_t rename_udm(size_t index, const char *name, uint etf_flags=0)
4205 {
4206 return tinfo_code_t(set_tinfo_property4(this, STA_UDM_NAME, index, size_t(name), 0, etf_flags));
4207 }
4208
4215 tinfo_code_t set_udm_type(size_t index, const tinfo_t &tif, uint etf_flags=0, const value_repr_t *repr=nullptr)
4216 {
4217 return tinfo_code_t(set_tinfo_property4(this, STA_UDM_TYPE, index, size_t(&tif), size_t(repr), etf_flags));
4218 }
4219
4222 tinfo_code_t set_udm_cmt(size_t index, const char *cmt, bool is_regcmt=false, uint etf_flags=0)
4223 {
4224 return tinfo_code_t(set_tinfo_property4(this, STA_UDM_CMT, index, size_t(cmt), is_regcmt, etf_flags));
4225 }
4226
4228 tinfo_code_t set_udm_repr(size_t index, const value_repr_t &repr, uint etf_flags=0)
4229 {
4230 return tinfo_code_t(set_tinfo_property4(this, STA_UDM_REPR, index, size_t(&repr), 0, etf_flags));
4231 }
4232
4235 bool is_udm_by_til(size_t idx) const { return get_tinfo_property4(typid, GTA_UDM_IS_BYTIL, idx, 0, 0, 0) != 0; }
4236
4241 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)); }
4242
4248 tinfo_code_t set_fixed_struct(bool on=true) { return tinfo_code_t(set_tinfo_property4(this, STA_FIXED_STRUCT, on, 0, 0, 0)); }
4249
4255 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)); }
4256
4279 tinfo_code_t expand_udt(size_t idx, adiff_t delta, uint etf_flags=0)
4280 {
4281 return tinfo_code_t(set_tinfo_property4(this, STA_EXPAND_UDT, idx, delta, 0, etf_flags));
4282 }
4283
4290 tinfo_code_t set_tuple(bool on=true) { return tinfo_code_t(set_tinfo_property4(this, STA_TUPLE, on, 0, 0, 0)); }
4291
4294 bool get_func_frame(const func_t *pfn) { return tinfo_get_func_frame(this, pfn); }
4295
4297 bool is_frame() const { return get_frame_func() != BADADDR; }
4298
4300 ea_t get_frame_func() const { return get_tinfo_property4(typid, GTA_FRAME_FUNC, 0, 0, 0, 0); }
4301
4313 sval_t *actval,
4314 const insn_t &insn,
4315 const op_t *x,
4316 sval_t v)
4317 {
4318 return ::get_frame_var(this, actval, insn, x, v);
4319 }
4320
4325 {
4326 return tinfo_code_t(set_tinfo_property4(this, STA_ENUM_WIDTH, nbytes, 0, 0, etf_flags));
4327 }
4328
4333 {
4334 return tinfo_code_t(set_tinfo_property4(this, STA_ENUM_SIGN, sign, 0, 0, etf_flags));
4335 }
4336
4360 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)); }
4361
4365 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)); }
4366
4371 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)); }
4372
4389 tinfo_code_t add_edm(const edm_t &edm, bmask64_t bmask=DEFMASK64, uint etf_flags=0, ssize_t idx=-1)
4390 {
4391 return tinfo_code_t(set_tinfo_property4(this, STA_ADD_EDM, size_t(&edm), bmask, idx, etf_flags));
4392 }
4393
4403 inline tinfo_code_t add_edm(
4404 const char *name,
4405 uint64 value,
4406 bmask64_t bmask=DEFMASK64,
4407 uint etf_flags=0,
4408 ssize_t idx=-1);
4409
4420 tinfo_code_t del_edms(size_t idx1, size_t idx2, uint etf_flags=0)
4421 {
4422 return tinfo_code_t(set_tinfo_property4(this, STA_DEL_EDMS, idx1, idx2, 0, etf_flags));
4423 }
4424 tinfo_code_t del_edm(size_t idx, uint etf_flags=0) { return del_edms(idx, idx+1, etf_flags); }
4425
4431 inline tinfo_code_t del_edm(const char *name, uint etf_flags=0);
4432
4440 inline tinfo_code_t del_edm_by_value(uint64 value, uint etf_flags=0, bmask64_t bmask=DEFMASK64, uchar serial=0);
4441
4448 tinfo_code_t rename_edm(size_t idx, const char *name, uint etf_flags=0)
4449 {
4450 return tinfo_code_t(set_tinfo_property4(this, STA_EDM_NAME, idx, size_t(name), 0, etf_flags));
4451 }
4452
4458 tinfo_code_t set_edm_cmt(size_t idx, const char *cmt, uint etf_flags=0)
4459 {
4460 return tinfo_code_t(set_tinfo_property4(this, STA_EDM_CMT, idx, size_t(cmt), 0, etf_flags));
4461 }
4462
4469 tinfo_code_t edit_edm(size_t idx, uint64 value, bmask64_t bmask=DEFMASK64, uint etf_flags=0)
4470 {
4471 return tinfo_code_t(set_tinfo_property4(this, STA_EDIT_EDM, idx, value, bmask, etf_flags));
4472 }
4473
4480 tinfo_code_t rename_funcarg(size_t index, const char *name, uint etf_flags=0)
4481 {
4482 return tinfo_code_t(set_tinfo_property4(this, STA_FUNCARG_NAME, index, size_t(name), 0, etf_flags));
4483 }
4484
4490 tinfo_code_t set_funcarg_type(size_t index, const tinfo_t &tif, uint etf_flags=0)
4491 {
4492 return tinfo_code_t(set_tinfo_property4(this, STA_FUNCARG_TYPE, index, size_t(&tif), 0, etf_flags));
4493 }
4494
4500 {
4501 return tinfo_code_t(set_tinfo_property4(this, STA_FUNC_RETTYPE, size_t(&tif), 0, 0, etf_flags));
4502 }
4503
4509 tinfo_code_t del_funcargs(size_t idx1, size_t idx2, uint etf_flags=0)
4510 {
4511 return tinfo_code_t(set_tinfo_property4(this, STA_DEL_FUNCARGS, idx1, idx2, 0, etf_flags));
4512 }
4513 tinfo_code_t del_funcarg(size_t idx, uint etf_flags=0) { return del_funcargs(idx, idx+1, etf_flags); }
4514
4522 tinfo_code_t add_funcarg(const funcarg_t &farg, uint etf_flags=0, ssize_t idx=-1)
4523 {
4524 return tinfo_code_t(set_tinfo_property4(this, STA_ADD_FUNCARG, size_t(&farg), idx, 0, etf_flags));
4525 }
4526
4529 {
4530 return tinfo_code_t(set_tinfo_property4(this, STA_FUNC_CC, cc, 0, 0, etf_flags));
4531 }
4532
4538 tinfo_code_t set_funcarg_loc(size_t index, const argloc_t &argloc, uint etf_flags=0)
4539 {
4540 return tinfo_code_t(set_tinfo_property4(this, STA_FUNCARG_LOC, index, size_t(&argloc), 0, etf_flags));
4541 }
4542
4547 tinfo_code_t set_func_retloc(const argloc_t &argloc, uint etf_flags=0)
4548 {
4549 return tinfo_code_t(set_tinfo_property4(this, STA_FUNC_RETLOC, size_t(&argloc), 0, 0, etf_flags));
4550 }
4551
4553 { // simple comparison: good enough to organize std::map, etc
4554 // for this function "unsigned char" and "uchar" are different
4555 // for deeper comparison see compare_with()
4556 return lexcompare_tinfo(typid, r.typid, 0);
4557 }
4558
4561#define TCMP_EQUAL 0x0000
4562#define TCMP_IGNMODS 0x0001
4563#define TCMP_AUTOCAST 0x0002
4564#define TCMP_MANCAST 0x0004
4565#define TCMP_CALL 0x0008
4566#define TCMP_DELPTR 0x0010
4567#define TCMP_DECL 0x0020
4568#define TCMP_ANYBASE 0x0040
4569#define TCMP_SKIPTHIS 0x0080
4570#define TCMP_DEEP_UDT 0x0100
4573 bool compare_with(const tinfo_t &r, int tcflags=0) const { return compare_tinfo(typid, r.typid, tcflags); }
4574 bool equals_to(const tinfo_t &r) const { return compare_with(r, 0); }
4575 bool is_castable_to(const tinfo_t &target) const { return compare_with(target, TCMP_AUTOCAST); }
4576 bool is_manually_castable_to(const tinfo_t &target) const { return compare_with(target, TCMP_MANCAST); }
4577};
4580
4581//------------------------------------------------------------------------
4584{
4585 const char *name;
4595
4596 simd_info_t(const char *nm = nullptr, uint16 sz = 0, type_t memt = BTF_UNK)
4597 : name(nm), size(sz), memtype(memt) {}
4598
4599 bool match_pattern(const simd_info_t *pattern)
4600 {
4601 if ( pattern == nullptr )
4602 return true;
4603 if ( pattern->size != 0 && pattern->size != size
4604 || pattern->name != nullptr && !streq(pattern->name, name)
4605 || !pattern->tif.empty() && !pattern->tif.compare_with(tif) )
4606 {
4607 return false;
4608 }
4609 if ( pattern->memtype == BTF_UNK || pattern->memtype == memtype )
4610 return true;
4611 return pattern->memtype == BTF_TBYTE && is_type_float(memtype)
4612 || pattern->memtype == BTF_INT && is_type_int(memtype);
4613 }
4614};
4617
4618//------------------------------------------------------------------------
4620idaman callcnv_t ida_export guess_func_cc(
4621 const func_type_data_t &fti,
4622 int npurged,
4623 int cc_flags);
4625idaman bool ida_export dump_func_type_data(
4626 qstring *out,
4627 const func_type_data_t &fti,
4628 int praloc_bits);
4629idaman bool ida_export calc_retloc(func_type_data_t *fti);
4630idaman bool ida_export calc_arglocs(func_type_data_t *fti);
4631idaman bool ida_export calc_varglocs(
4632 func_type_data_t *fti,
4633 regobjs_t *regs,
4634 relobj_t *stkargs,
4635 int nfixed);
4636
4637//------------------------------------------------------------------------
4639struct ptr_type_data_t // #ptr
4640{
4648 tinfo_t c=tinfo_t(),
4649 uchar bps=0,
4650 tinfo_t p=tinfo_t(),
4651 int32 d=0)
4652 : closure(c), parent(p), delta(d), based_ptr_size(bps) {}
4654 void swap(ptr_type_data_t &r) { qswap(*this, r); }
4655 bool operator == (const ptr_type_data_t &r) const
4656 {
4657 return obj_type == r.obj_type
4658 && closure == r.closure
4660 }
4661 bool operator != (const ptr_type_data_t &r) const { return !(*this == r); }
4662 bool is_code_ptr() const { return obj_type.is_func(); }
4663 bool is_shifted() const { return delta != 0; }
4664};
4666
4667//------------------------------------------------------------------------
4669struct array_type_data_t // #array
4670{
4674 array_type_data_t(size_t b=0, size_t n=0) : base(b), nelems(n) {}
4676 void swap(array_type_data_t &r) { qswap(*this, r); }
4677};
4679
4680//-------------------------------------------------------------------------
4683{
4692#define FAI_HIDDEN 0x0001
4693#define FAI_RETPTR 0x0002
4694#define FAI_STRUCT 0x0004
4695#define FAI_ARRAY 0x0008
4698#define FAI_UNUSED 0x0010
4700
4701 funcarg_t() = default;
4702
4708 funcarg_t(const char *_name, const tinfo_t &_type, const argloc_t &_argloc=argloc_t())
4709 : argloc(_argloc), name(_name), type(_type)
4710 {
4711 }
4712
4719 funcarg_t(const char *_name, const type_t _type, const argloc_t &_argloc=argloc_t())
4720 : argloc(_argloc), name(_name), type(_type)
4721 {
4722 }
4723
4732 funcarg_t(const char *_name, const char *_type, const argloc_t &_argloc=argloc_t())
4733 : argloc(_argloc), name(_name)
4734 {
4735 type.parse(_type, nullptr, PT_SEMICOLON);
4736 }
4737
4738 bool operator == (const funcarg_t &r) const
4739 {
4740 return argloc == r.argloc
4741 && name == r.name
4742// && cmt == r.cmt
4743 && type == r.type;
4744 }
4745 bool operator != (const funcarg_t &r) const { return !(*this == r); }
4746
4747};
4750
4752struct func_type_data_t : public funcargvec_t // #func
4753{
4754 int flags = 0;
4758#define FTI_SPOILED 0x0001
4759#define FTI_NORET 0x0002
4760#define FTI_PURE 0x0004
4761#define FTI_HIGH 0x0008
4762#define FTI_STATIC 0x0010
4763#define FTI_VIRTUAL 0x0020
4764#define FTI_CALLTYPE 0x00C0
4765#define FTI_DEFCALL 0x0000
4766#define FTI_NEARCALL 0x0040
4767#define FTI_FARCALL 0x0080
4768#define FTI_INTCALL 0x00C0
4769#define FTI_ARGLOCS 0x0100
4771#define FTI_EXPLOCS 0x0200
4772#define FTI_CONST 0x0400
4773#define FTI_CTOR 0x0800
4774#define FTI_DTOR 0x1000
4775#define FTI_ALL 0x1FFF
4777 callcnv_t _new_callcnv = 0;// Do not access directly, use get_cc/set_cc
4784 cm_t _old_cc = CM_CC_UNKNOWN; // calling convention, legacy codes. do not access
4788 void swap(func_type_data_t &r) { qswap(*this, r); }
4789 bool is_high() const { return (flags & FTI_HIGH) != 0; }
4790 bool is_noret() const { return (flags & FTI_NORET) != 0; }
4791 bool is_pure() const { return (flags & FTI_PURE) != 0; }
4792 bool is_static() const { return (flags & FTI_STATIC) != 0; }
4793 bool is_virtual() const { return (flags & FTI_VIRTUAL) != 0; }
4794 bool is_const() const { return (flags & FTI_CONST) != 0; }
4795 bool is_ctor() const { return (flags & FTI_CTOR) != 0; }
4796 bool is_dtor() const { return (flags & FTI_DTOR) != 0; }
4797 int get_call_method() const { return flags & FTI_CALLTYPE; }
4798 bool is_vararg_cc() const { return ::is_vararg_cc(get_cc()); }
4799 bool is_golang_cc() const { return ::is_golang_cc(get_cc()); }
4800 bool is_swift_cc() const { return ::is_swift_cc(get_cc()); }
4801 bool is_user_cc() const { return ::is_user_cc(get_explicit_cc()); }
4802
4805 callcnv_t guess_cc(int purged, int cc_flags) const
4806 {
4807 return guess_func_cc(*this, purged, cc_flags);
4808 }
4809#define CC_CDECL_OK 0x01
4810#define CC_ALLOW_ARGPERM 0x02
4811#define CC_ALLOW_REGHOLES 0x04
4812#define CC_HAS_ELLIPSIS 0x08
4813#define CC_GOLANG_OK 0x10
4816 bool dump(qstring *out, int praloc_bits=PRALOC_STKOFF) const
4817 {
4818 return dump_func_type_data(out, *this, praloc_bits);
4819 }
4820
4822 ssize_t find_argument(const char *name, size_t from=0, size_t to=size_t(-1)) const
4823 {
4824 if ( from < size() )
4825 {
4826 const_iterator e = begin() + qmin(size(), to);
4827 for ( const_iterator p=begin()+from; p != e; ++p )
4828 if ( p->name == name )
4829 return p - begin();
4830 }
4831 return -1;
4832 }
4833
4834};
4835
4836//-------------------------------------------------------------------------
4845
4846//-------------------------------------------------------------------------
4848struct edm_t // #edm
4849{
4851 qstring cmt; // repeatable comment
4853
4854 edm_t() = default;
4855
4861 edm_t(const char *_name, uint64 _value, const char *_cmt=nullptr)
4862 : name(_name), cmt(_cmt), value(_value) {}
4863
4864 // a enum constant must at least have a name
4865 bool empty() const { return name.empty(); }
4866
4867 bool operator == (const edm_t &r) const
4868 {
4869 return name == r.name
4870// && cmt == r.cmt
4871 && value == r.value;
4872 }
4873 bool operator != (const edm_t &r) const { return !(*this == r); }
4874 void swap(edm_t &r) { qswap(*this, r); }
4875 inline tid_t get_tid() const;
4876
4877
4878 DEFINE_MEMORY_ALLOCATION_FUNCS()
4879};
4886
4888struct enum_type_data_t : public edmvec_t // #enum
4889{
4897
4898 // How the enum members should be printed in the enum definition
4901 int get_enum_radix() const
4902 {
4903 switch ( bte & BTE_OUT_MASK )
4904 {
4905 case BTE_CHAR:
4906 return 1;
4907 case BTE_HEX:
4908 if ( (taenum_bits & TAENUM_BIN) != 0 )
4909 return 2;
4910 if ( (taenum_bits & TAENUM_OCT) != 0 )
4911 return 8;
4912 break;
4913 case BTE_SDEC:
4914 case BTE_UDEC:
4915 return 10;
4916 }
4917 return 16;
4918 }
4919 bool is_number_signed() const
4920 {
4921 return (bte & BTE_OUT_MASK) == BTE_SDEC
4922 || (bte & BTE_OUT_MASK) == BTE_HEX && (taenum_bits & TAENUM_NUMSIGN) != 0;
4923 }
4924
4927 void set_enum_radix(int radix, bool sign)
4928 {
4929 bte = (bte & ~BTE_OUT_MASK) | BTE_HEX;
4930 taenum_bits &= ~(TAENUM_BIN|TAENUM_OCT);
4931 setflag(taenum_bits, TAENUM_NUMSIGN, sign);
4932 switch ( radix )
4933 {
4934 case 1: bte |= BTE_CHAR; break;
4935 case 2: taenum_bits |= TAENUM_BIN; break;
4936 case 8: taenum_bits |= TAENUM_OCT; break;
4937 case 10: bte |= sign ? BTE_SDEC : BTE_UDEC; break;
4938 }
4939 }
4940 bool is_char() const { return (bte & BTE_OUT_MASK) == BTE_CHAR; }
4941 bool is_dec() const { return (bte & BTE_OUT_MASK) == BTE_SDEC; }
4942 bool is_hex() const { return get_enum_radix() == 16; }
4943 bool is_oct() const { return get_enum_radix() == 8; }
4944 bool is_bin() const { return get_enum_radix() == 2; }
4945 bool is_udec() const { return (bte & BTE_OUT_MASK) == BTE_UDEC; }
4946 bool is_shex() const { return is_number_signed() && is_hex(); }
4947 bool is_soct() const { return is_number_signed() && is_oct(); }
4948 bool is_sbin() const { return is_number_signed() && is_bin(); }
4949
4950 bool has_lzero() const { return (taenum_bits & TAENUM_LZERO) != 0; }
4951 void set_lzero(bool on) { setflag(taenum_bits, TAENUM_LZERO, on); }
4952
4954 bool store_64bit_values() const { return (taenum_bits & TAENUM_64BIT) != 0; }
4955
4957 bool is_bf() const { return (bte & BTE_BITMASK) != 0; }
4958
4960 int calc_nbytes() const
4961 {
4962 int emsize = bte & BTE_SIZE_MASK;
4963 return emsize != 0 ? 1 << (emsize-1) : inf_get_cc_size_e();
4964 }
4965
4967 {
4969 return false; // bad width
4970 int idb_width = 0;
4971 if ( nbytes != 0 )
4972 idb_width = log2ceil(nbytes) + 1;
4973 bte = (bte & ~BTE_SIZE_MASK) | idb_width;
4974 return true;
4975 }
4976
4982 bool get_constant_group(size_t *group_start_index, size_t *group_size, size_t idx) const
4983 {
4984 if ( !group_sizes.empty() )
4985 {
4986 size_t grp_start = 0;
4987 for ( auto grp_size : group_sizes )
4988 {
4989 if ( grp_start + grp_size > idx )
4990 {
4991 if ( group_start_index != nullptr )
4992 *group_start_index = grp_start;
4993 if ( group_size != nullptr )
4994 *group_size = grp_size;
4995 return true;
4996 }
4997 grp_start += grp_size;
4998 }
4999 }
5000 return false;
5001 }
5002
5008 bool is_group_mask_at(size_t idx) const
5009 {
5010 size_t grp_start;
5011 size_t grp_size;
5012 return get_constant_group(&grp_start, &grp_size, idx)
5013 && grp_start == idx && grp_size > 1;
5014 }
5015
5018 {
5019 if ( !group_sizes.empty() )
5020 {
5021 size_t sum = 0;
5022 for ( int s : group_sizes )
5023 {
5024 if ( s == 0 )
5025 return false;
5026 sum += s;
5027 }
5028 return sum == size();
5029 }
5030 return true;
5031 }
5032
5034 ssize_t find_member(const char *name, size_t from=0, size_t to=size_t(-1)) const
5035 {
5036 if ( from < size() )
5037 {
5038 const_iterator e = begin() + qmin(size(), to);
5039 for ( const_iterator p=begin()+from; p != e; ++p )
5040 if ( p->name == name )
5041 return p - begin();
5042 }
5043 return -1;
5044 }
5045
5047 ssize_t find_member(uint64 value, uchar serial, size_t from=0, size_t to=size_t(-1), uint64 vmask=uint64(-1)) const
5048 {
5049 if ( from < size() )
5050 {
5051 if ( vmask == uint64(-1) )
5052 vmask = calc_mask();
5053 value &= vmask;
5054 uint64 value_signed = value | ~vmask;
5055 const_iterator e = begin() + qmin(size(), to);
5056 for ( const_iterator p=begin()+from; p != e; ++p )
5057 if ( (p->value == value || p->value == value_signed) && serial-- == 0 )
5058 return p - begin();
5059 }
5060 return -1;
5061 }
5062
5064 void swap(enum_type_data_t &r) { qswap(*this, r); }
5065
5067 void add_constant(const char *name, uint64 value, const char *cmt=nullptr)
5068 {
5069 auto &c = push_back();
5070 c.name = name;
5071 c.value = value;
5072 c.cmt = cmt;
5073 }
5074
5077 tinfo_code_t get_value_repr(value_repr_t *repr) const { return enum_type_data_t__get_value_repr(this, repr); }
5078
5081 tinfo_code_t set_value_repr(const value_repr_t &repr) { return enum_type_data_t__set_value_repr(this, repr); }
5082
5084 uchar get_serial(size_t index) const
5085 {
5086 uchar serial = 0;
5087 if ( index < size() )
5088 {
5089 uint64 value = at(index).value;
5090 for ( size_t i=0; i < index; ++i )
5091 if ( at(i).value == value )
5092 serial++;
5093 }
5094 return serial;
5095 }
5096
5098 uchar get_max_serial(uint64 value) const { return enum_type_data_t__get_max_serial(this, value); }
5099
5100#ifndef SWIG
5102 int for_all_constants(std::function<int(size_t idx, size_t grp_start, int grp_size)> v) const
5103 {
5104 if ( !group_sizes.empty() )
5105 {
5106 auto gv = [v](size_t grp_start, int grp_size)
5107 {
5108 if ( grp_size == 1 )
5109 return v(grp_start, grp_start, grp_size);
5110 size_t grp_end = grp_start + grp_size;
5111 for ( size_t idx=grp_start+1; idx < grp_end; ++idx )
5112 {
5113 int code = v(idx, grp_start, grp_size);
5114 if ( code != 0 )
5115 return code;
5116 }
5117 return 0;
5118 };
5119 return for_all_groups(gv);
5120 }
5121 else
5122 {
5123 size_t sz = size();
5124 for ( size_t idx=0; idx < sz; ++idx )
5125 {
5126 int code = v(idx, 0, sz);
5127 if ( code != 0 )
5128 return code;
5129 }
5130 }
5131 return 0;
5132 }
5133
5135 int for_all_groups(std::function<int(size_t grp_start, int grp_size)> v, bool skip_trivial=false) const
5136 {
5137 if ( !group_sizes.empty() && is_valid_group_sizes() )
5138 {
5139 size_t grp_start = 0;
5140 for ( auto grp_size : group_sizes )
5141 {
5142 if ( !skip_trivial || grp_size != 1 )
5143 {
5144 int code = v(grp_start, grp_size);
5145 if ( code != 0 )
5146 return code;
5147 }
5148 grp_start += grp_size;
5149 }
5150 }
5151 return 0;
5152 }
5153#endif
5154
5155};
5157
5158//-------------------------------------------------------------------------
5161
5162//-------------------------------------------------------------------------
5164struct typedef_type_data_t // #typedef
5165{
5166 const til_t *til;
5167 union
5168 {
5169 const char *name;
5171 };
5173 bool resolve;
5174 typedef_type_data_t(const til_t *_til, const char *_name, bool _resolve=false)
5175 : is_ordref(false), resolve(_resolve)
5176 {
5177 name = _name;
5178 til = _til == nullptr ? get_idati() : _til;
5179 }
5180 typedef_type_data_t(const til_t *_til, uint32 ord, bool _resolve=false)
5181 : is_ordref(true), resolve(_resolve)
5182 {
5183 name = nullptr;
5184 ordinal = ord;
5185 til = _til == nullptr ? get_idati() : _til;
5186 }
5189};
5191
5192//-------------------------------------------------------------------------
5193// A high level variant of custom_data_type_ids_t
5199
5201struct value_repr_t // #repr
5202{
5204#define FRB_MASK 0xF
5205#define FRB_UNK 0x0
5206#define FRB_NUMB 0x1
5207#define FRB_NUMO 0x2
5208#define FRB_NUMH 0x3
5209#define FRB_NUMD 0x4
5210#define FRB_FLOAT 0x5
5212#define FRB_CHAR 0x6
5213#define FRB_SEG 0x7
5214#define FRB_ENUM 0x8
5215#define FRB_OFFSET 0x9
5216#define FRB_STRLIT 0xA
5217#define FRB_STROFF 0xB
5218#define FRB_CUSTOM 0xC
5219#define FRB_INVSIGN 0x0100
5220#define FRB_INVBITS 0x0200
5221#define FRB_SIGNED 0x0400
5222#define FRB_LZERO 0x0800
5223#define FRB_TABFORM 0x1000
5225 union
5226 {
5229 struct
5230 {
5233 };
5235 };
5238
5239public:
5240 void swap(value_repr_t &r) { ::qswap(*this, r); }
5242
5243 void clear() { bits = 0; }
5244
5245 bool empty() const { return bits == 0; }
5246 bool is_enum() const { return (bits & FRB_MASK) == FRB_ENUM; }
5247 bool is_offset() const { return (bits & FRB_MASK) == FRB_OFFSET; }
5248 bool is_strlit() const { return (bits & FRB_MASK) == FRB_STRLIT; }
5249 bool is_custom() const { return (bits & FRB_MASK) == FRB_CUSTOM; }
5250 bool is_stroff() const { return (bits & FRB_MASK) == FRB_STROFF; }
5251 bool is_typref() const { return is_enum() || is_stroff(); }
5252 bool is_signed() const { return (bits & FRB_SIGNED) != 0; }
5253 bool has_tabform() const { return (bits & FRB_TABFORM) != 0; }
5254 bool has_lzeroes() const { return (bits & FRB_LZERO) != 0; }
5255
5256 uint64 get_vtype() const { return bits & FRB_MASK; }
5257 void set_vtype(uint64 vt) { bits &= ~FRB_MASK; bits |= (vt & FRB_MASK); }
5258 void set_signed(bool on) { setflag(bits, FRB_SIGNED, on); }
5259 void set_tabform(bool on) { setflag(bits, FRB_TABFORM, on); }
5260 void set_lzeroes(bool on) { setflag(bits, FRB_LZERO, on); }
5261
5263 {
5264 ap = _ap;
5265 set_signed((ap.flags & AP_SIGNED) != 0);
5266 ap.flags &= ~AP_SIGNED;
5267 set_tabform(!ap.is_default());
5268 }
5270 {
5271 if ( _ap != nullptr )
5272 {
5273 if ( has_tabform() )
5274 *_ap = ap;
5275 setflag(_ap->flags, AP_SIGNED, is_signed());
5276 }
5277 }
5278
5279 bool from_opinfo(flags64_t flags, aflags_t afl, const opinfo_t *opinfo, const array_parameters_t *_ap)
5280 {
5281 return value_repr_t__from_opinfo(this, flags, afl, opinfo, _ap);
5282 }
5283 size_t print(qstring *result, bool colored=false) const
5284 {
5285 return value_repr_t__print_(this, result, colored);
5286 }
5287 bool parse_value_repr(const qstring &attr, type_t target_type=BTF_STRUCT)
5288 {
5289 return value_repr_t__parse_value_repr(this, attr, target_type);
5290 }
5291
5292#ifndef SWIG
5294#endif
5295};
5296
5297//-------------------------------------------------------------------------
5299struct udm_t // #udm
5300{
5307 int effalign = 0;
5310
5311 udm_t() = default;
5312
5322 udm_t(const char *_name, const tinfo_t &_type, uint64 _offset = 0)
5323 : offset(_offset), name(_name), type(_type)
5324 {
5325 size = _type.get_size() * 8;
5326 }
5327
5338 udm_t(const char *_name, const type_t _type, uint64 _offset = 0)
5339 : offset(_offset), name(_name)
5340 {
5341 if ( is_type_arithmetic(_type) )
5342 {
5343 type = tinfo_t(_type);
5344 size = type.get_size() * 8;
5345 }
5346 }
5347
5357 udm_t(const char *_name, const char *_type, uint64 _offset = 0)
5358 : offset(_offset), name(_name)
5359 {
5360 if ( type.parse(_type, nullptr, PT_SEMICOLON) )
5361 size = type.get_size() * 8;
5362 }
5363
5364 // a udt member must at least have a type
5365 bool empty() const { return type.empty(); }
5366
5367 bool is_bitfield() const { return type.is_decl_bitfield(); }
5368 bool is_zero_bitfield() const { return size == 0 && is_bitfield(); }
5369 bool is_unaligned() const { return (tafld_bits & TAFLD_UNALIGNED) != 0; }
5370 bool is_baseclass() const { return (tafld_bits & TAFLD_BASECLASS) != 0; }
5371 bool is_virtbase() const { return (tafld_bits & TAFLD_VIRTBASE) != 0; }
5372 bool is_vftable() const { return (tafld_bits & TAFLD_VFTABLE) != 0; }
5373 bool is_method() const { return (tafld_bits & TAFLD_METHOD) != 0; }
5374 bool is_gap() const { return (tafld_bits & TAFLD_GAP) != 0; }
5375 bool is_regcmt() const { return (tafld_bits & TAFLD_REGCMT) != 0; }
5376 bool is_retaddr() const { return (tafld_bits & TAFLD_FRAME_R) != 0; }
5377 bool is_savregs() const { return (tafld_bits & TAFLD_FRAME_S) != 0; }
5378 bool is_special_member() const { return is_retaddr() || is_savregs(); }
5379 bool is_by_til() const { return (tafld_bits & TAFLD_BYTIL) != 0; }
5380
5381 void set_unaligned(bool on=true) { setflag(tafld_bits, TAFLD_UNALIGNED, on); }
5382 void set_baseclass(bool on=true) { setflag(tafld_bits, TAFLD_BASECLASS, on); }
5383 void set_virtbase(bool on=true) { setflag(tafld_bits, TAFLD_VIRTBASE, on); }
5384 void set_vftable(bool on=true) { setflag(tafld_bits, TAFLD_VFTABLE, on); }
5385 void set_method(bool on=true) { setflag(tafld_bits, TAFLD_METHOD, on); }
5386 void set_regcmt(bool on=true) { setflag(tafld_bits, TAFLD_REGCMT, on); }
5387 void set_retaddr(bool on=true) { setflag(tafld_bits, TAFLD_FRAME_R, on); }
5388 void set_savregs(bool on=true) { setflag(tafld_bits, TAFLD_FRAME_S, on); }
5389 void set_by_til(bool on=true) { setflag(tafld_bits, TAFLD_BYTIL, on); }
5390 void clr_unaligned() { tafld_bits &= ~TAFLD_UNALIGNED; }
5391 void clr_baseclass() { tafld_bits &= ~TAFLD_BASECLASS; }
5392 void clr_virtbase() { tafld_bits &= ~TAFLD_VIRTBASE; }
5393 void clr_vftable() { tafld_bits &= ~TAFLD_VFTABLE; }
5394 void clr_method() { tafld_bits &= ~TAFLD_METHOD; }
5395 uint64 begin() const { return offset; }
5396 uint64 end() const { return offset + size; }
5397 bool operator < (const udm_t &r) const
5398 {
5399 return offset < r.offset;
5400 }
5401 bool operator == (const udm_t &r) const
5402 {
5403 return compare_with(r, 0);
5404 }
5405 bool compare_with(const udm_t &r, int tcflags) const
5406 {
5407 return offset == r.offset
5408 && size == r.size
5409 && name == r.name
5410// && cmt == r.cmt
5411 && type.compare_with(r.type, tcflags)
5412 && fda == r.fda
5413 && tafld_bits == r.tafld_bits
5414 && effalign == r.effalign;
5415 }
5416 bool operator != (const udm_t &r) const { return !(*this == r); }
5417
5419 void swap(udm_t &r) { qswap(*this, r); }
5420
5421 // the user cannot enter anonymous fields in ida (they can come only from tils),
5422 // so we use the following trick: if the field type starts with $ and the name
5423 // with __, then we consider the field as anonymous
5424 bool is_anonymous_udm() const
5425 {
5426 return name[0] == '_' && name[1] == '_' && type.is_anonymous_udt();
5427 }
5428
5429 void set_value_repr(const value_repr_t &r) { repr = r; }
5430 bool can_be_dtor() const { return name[0] == '~'; }
5431 bool can_rename() const
5432 {
5433 return !is_gap() && !is_baseclass() && !can_be_dtor();
5434 }
5435
5436};
5438struct udtmembervec_t : public qvector<udm_t> {};
5439
5440struct udt_type_data_t : public udtmembervec_t // #udt
5441{
5442 static constexpr int VERSION = 1;
5443 size_t total_size = 0;
5444 size_t unpadded_size = 0;
5450 bool is_union = false;
5451
5452 void swap(udt_type_data_t &r) { qswap(*this, r); }
5454 bool is_unaligned() const { return (taudt_bits & TAUDT_UNALIGNED) != 0; }
5455 bool is_msstruct() const { return (taudt_bits & TAUDT_MSSTRUCT) != 0; }
5456 bool is_cppobj() const { return (taudt_bits & TAUDT_CPPOBJ) != 0; }
5457 bool is_vftable() const { return (taudt_bits & TAUDT_VFTABLE) != 0; }
5458 bool is_fixed() const { return (taudt_bits & TAUDT_FIXED) != 0; }
5459 bool is_tuple() const { return (taudt_bits & TAUDT_TUPLE) != 0; }
5460
5461 void set_vftable(bool on=true) { setflag(taudt_bits, TAUDT_VFTABLE, on); }
5462 void set_fixed(bool on=true) { setflag(taudt_bits, TAUDT_FIXED, on); }
5463 void set_tuple(bool on=true) { setflag(taudt_bits, TAUDT_TUPLE, on); }
5464
5465 bool is_last_baseclass(size_t idx) // we assume idx is valid
5466 {
5467 return at(idx).is_baseclass()
5468 && (idx+1 == size() || !at(idx+1).is_baseclass());
5469 }
5470
5479 udm_t &add_member(const char *_name, const tinfo_t &_type, uint64 _offset = 0)
5480 {
5481 udm_t &udm = push_back();
5482 udm.name = _name;
5483 udm.type = _type;
5484 udm.size = _type.get_size() * 8;
5485 udm.offset = _offset;
5486 return udm;
5487 }
5488
5492 ssize_t find_member(udm_t *pattern_udm, int strmem_flags) const { return udt_type_data_t__find_member(this, pattern_udm, strmem_flags); }
5493
5494 ssize_t find_member(const char *name) const
5495 {
5496 udm_t udm;
5497 udm.name = name;
5498 return find_member(&udm, STRMEM_NAME);
5499 }
5500
5501 ssize_t find_member(uint64 bit_offset) const
5502 {
5503 udm_t udm;
5504 udm.offset = bit_offset;
5505 return find_member(&udm, STRMEM_OFFSET);
5506 }
5507
5510 ssize_t get_best_fit_member(asize_t disp) const { return udt_type_data_t__get_best_fit_member(this, disp); }
5511
5516 inline ssize_t get_best_fit_member(udm_t *out, asize_t disp) const;
5517
5518};
5520
5521// separator to construct full udm name
5522#define STRUC_SEPARATOR '.'
5523
5524// The type name of a virtual function table (__vftable) of a class is
5525// constructed by appending the following suffix to the class name.
5526// In the case of multiple inheritance we append the vft offset
5527// to the class name (with format %04X)
5528// Example: CLS_0024_vtbl is used for the vft located at the offset 0x24 of CLS
5529
5530#define VTBL_SUFFIX "_vtbl"
5531
5532// The member name of a virtual function table
5533// Complex cases are not handled yet.
5534
5535#define VTBL_MEMNAME "__vftable"
5536
5537//--------------------------------------------------------------------------
5539inline bool stroff_as_size(int plen, const tinfo_t &tif, asize_t value)
5540{
5541 return plen == 1
5542 && value > 0
5543 && !tif.is_varstruct()
5544 && value == tif.get_size();
5545}
5546
5547//--------------------------------------------------------------------------
5549{
5554 virtual int idaapi visit_udm(
5555 tid_t tid,
5556 const tinfo_t *tif,
5557 const udt_type_data_t *udt,
5558 ssize_t idx) = 0;
5559 virtual ~udm_visitor_t() {}
5560};
5561
5562//--------------------------------------------------------------------------
5571idaman int ida_export visit_stroff_udms(
5572 udm_visitor_t &sfv,
5573 const tid_t *path,
5574 int plen,
5575 adiff_t *disp,
5576 bool appzero);
5577
5578//-------------------------------------------------------------------------
5580struct bitfield_type_data_t // #bitfield
5581{
5585 bitfield_type_data_t(uchar _nbytes=0, uchar _width=0, bool _is_unsigned=false)
5586 : nbytes(_nbytes), width(_width), is_unsigned(_is_unsigned)
5587 {
5588 }
5589 bool serialize(qtype *type, type_t mods) const;
5591 {
5592 if ( nbytes != r.nbytes )
5593 return nbytes > r.nbytes ? 1 : -1;
5594 if ( width != r.width )
5595 return width > r.width ? 1 : -1;
5596 if ( is_unsigned )
5597 {
5598 if ( !r.is_unsigned )
5599 return 1;
5600 }
5601 else
5602 {
5603 if ( r.is_unsigned )
5604 return -1;
5605 }
5606 return 0;
5607 }
5608 void swap(bitfield_type_data_t &r) { qswap(*this, r); }
5610 {
5611 if ( nbytes != 1 && nbytes != 2 && nbytes != 4 && nbytes != 8 )
5612 return false;
5613 if ( width > nbytes*8 )
5614 return false;
5615 return true;
5616 }
5617};
5619
5620//--------------------------------------------------------------------------
5621// This tag can be used at the beginning of
5622// udm_t::cmt
5623// funcarg_t::cmt
5624// edm_t::cmt
5625// to specify the line number where it is defined.
5626// Example: "\x05123." means the line number 123
5627#define TPOS_LNNUM "\x05"
5628
5629// Tag to denote a regular comment in serialized form.
5630// If a comment has it as its first character, it is a regular comment,
5631// otherwise it is a repeatable comment. The comments returned by
5632// ::get_named_type and ::get_numbered_type may have this symbol.
5633#define TPOS_REGCMT '\x06'
5634
5635//-------------------------------------------------------------------------
5637inline THREAD_SAFE bool is_one_bit_mask(uval_t mask)
5638{
5639 return is_pow2(mask);
5640}
5641
5642//-------------------------------------------------------------------------
5644{
5646}
5647
5648//-------------------------------------------------------------------------
5650{
5652}
5653
5654//-------------------------------------------------------------------------
5656{
5658}
5659
5660//-------------------------------------------------------------------------
5661// return argument alignment (depends on ABI, CC and natural type alignment)
5662inline int get_arg_align(int type_align, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
5663{
5664 QASSERT(2858, is_pow2(type_align));
5665 if ( type_align > slotsize*2 )
5666 {
5667 if ( inf_huge_arg_align(cc) )
5668 return type_align;
5669 type_align = slotsize*2;
5670 }
5671 return type_align < slotsize
5672 ? inf_pack_stkargs(cc) ? type_align : slotsize
5673 : inf_big_arg_align(cc) ? type_align : slotsize;
5674}
5675
5676inline int get_arg_align(const tinfo_t &tif, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
5677{
5678 uint32 align = 0;
5679 tif.get_size(&align);
5680 return get_arg_align(align, slotsize, cc);
5681}
5682
5683//-------------------------------------------------------------------------
5684inline sval_t align_stkarg_up(sval_t spoff, int type_align, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
5685{
5686 uint32 align = get_arg_align(type_align, slotsize, cc);
5687 return align_up(spoff, align);
5688}
5689
5690inline sval_t align_stkarg_up(sval_t spoff, const tinfo_t &tif, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
5691{
5692 uint32 align = get_arg_align(tif, slotsize, cc);
5693 return align_up(spoff, align);
5694}
5695
5696inline bool argloc_t::has_reg() const
5697{
5698 if ( !is_scattered() )
5699 return is_reg();
5700 for ( const auto &part : scattered() )
5701 if ( part.is_reg() )
5702 return true;
5703 return false;
5704};
5705
5706inline bool argloc_t::has_stkoff() const
5707{
5708 if ( !is_scattered() )
5709 return is_stkoff();
5710 for ( const auto &part : scattered() )
5711 if ( part.is_stkoff() )
5712 return true;
5713 return false;
5714};
5715
5716inline bool argloc_t::in_stack() const
5717{
5718 if ( !is_scattered() )
5719 return is_stkoff();
5720 for ( const auto &part : scattered() )
5721 if ( !part.is_stkoff() )
5722 return false;
5723 return true;
5724}
5725
5726inline bool argloc_t::is_mixed_scattered() const
5727{
5728 if ( !is_scattered() )
5729 return false;
5730 bool reg_found = false;
5731 bool stkoff_found = false;
5732 for ( const auto &part : scattered() )
5733 {
5734 if ( part.is_reg() )
5735 reg_found = true;
5736 if ( part.is_stkoff() )
5737 stkoff_found = true;
5738 }
5739 return reg_found && stkoff_found;
5740}
5741
5742inline bool tinfo_t::get_named_type(
5743 const til_t *til,
5744 const char *name,
5745 type_t decl_type,
5746 bool resolve,
5747 bool try_ordinal)
5748{
5749 if ( name == nullptr )
5750 return false;
5751 typedef_type_data_t tp(til, name, resolve);
5753}
5754
5756 const til_t *til,
5757 uint32 ordinal,
5759 bool resolve)
5760{
5761 typedef_type_data_t tp(til, ordinal, resolve);
5762 return create_typedef(tp, decl_type, false);
5763}
5764
5766{
5768 p.is_union = is_union;
5769 return create_udt(p);
5770}
5771
5773{
5774 return create_udt(p, p.is_union ? BTF_UNION : BTF_STRUCT);
5775}
5776
5778{
5780 p.bte = BTE_ALWAYS | bte;
5781 return create_enum(p);
5782}
5783
5785 const tinfo_t &tif,
5786 uchar bps,
5788{
5789 ptr_type_data_t pi(tinfo_t(), bps);
5790 pi.obj_type = tif;
5791 return create_ptr(pi, decl_type);
5792}
5793
5795 const tinfo_t &tif,
5796 uint32 nelems,
5797 uint32 base,
5799{
5800 array_type_data_t ai(base, nelems);
5801 ai.elem_type = tif;
5802 return create_array(ai, decl_type);
5803}
5804
5806 uchar nbytes,
5807 uchar width,
5808 bool _is_unsigned,
5810{
5811 bitfield_type_data_t bi(nbytes, width, _is_unsigned);
5812 return create_bitfield(bi, decl_type);
5813}
5814
5816{
5817 bool ok = false;
5819 if ( get_array_details(&ai) )
5820 {
5821 ptr_type_data_t pi;
5822 pi.obj_type.swap(ai.elem_type);
5823 create_ptr(pi);
5824 ok = true;
5825 }
5826 return ok;
5827}
5828
5830 const char *name,
5831 const tinfo_t &type,
5832 uint64 offset,
5833 uint etf_flags,
5834 size_t times,
5835 ssize_t idx)
5836{
5837 return add_udm(udm_t(name, type, offset), etf_flags, times, idx);
5838}
5839
5841 const char *name,
5842 type_t type,
5843 uint64 offset,
5844 uint etf_flags,
5845 size_t times,
5846 ssize_t idx)
5847{
5848 return add_udm(udm_t(name, type, offset), etf_flags, times, idx);
5849}
5850
5852 const char *name,
5853 const char *type,
5854 uint64 offset,
5855 uint etf_flags,
5856 size_t times,
5857 ssize_t idx)
5858{
5859 return add_udm(udm_t(name, type, offset), etf_flags, times, idx);
5860}
5861
5862inline int tinfo_t::find_udm(uint64 offset, int strmem_flags) const
5863{
5864 udm_t udm;
5865 udm.offset = offset;
5866 return find_tinfo_udt_member(&udm, typid, STRMEM_OFFSET|strmem_flags);
5867}
5868
5869inline int tinfo_t::find_udm(const char *name, int strmem_flags) const
5870{
5871 udm_t udm;
5872 udm.name = name;
5873 return find_tinfo_udt_member(&udm, typid, STRMEM_NAME|strmem_flags);
5874}
5875
5876inline int tinfo_t::get_udm(udm_t *out, const char *name) const
5877{
5878 udm_t tmp;
5879 tmp.name = name;
5880 int rc = find_udm(&tmp, STRMEM_NAME);
5881 if ( rc >= 0 )
5882 out->swap(tmp);
5883 return rc;
5884}
5885
5886inline int tinfo_t::get_udm(udm_t *out, size_t index) const
5887{
5888 udm_t tmp;
5889 tmp.offset = index;
5890 int rc = find_udm(&tmp, STRMEM_INDEX);
5891 if ( rc >= 0 )
5892 out->swap(tmp);
5893 return rc;
5894
5895}
5896
5897inline int tinfo_t::get_udm_by_offset(udm_t *out, uint64 offset) const
5898{
5899 udm_t tmp;
5900 tmp.offset = offset;
5901 int rc = find_udm(&tmp, STRMEM_OFFSET);
5902 if ( rc >= 0 )
5903 out->swap(tmp);
5904 return rc;
5905}
5906
5908 const char *name,
5909 uint64 value,
5910 bmask64_t bmask,
5911 uint etf_flags,
5912 ssize_t idx)
5913{
5914 return add_edm(edm_t(name, value), bmask, etf_flags, idx);
5915}
5916
5918 const char *name,
5919 uint etf_flags)
5920{
5921 edm_t edm;
5922 ssize_t idx = get_edm(&edm, name);
5923 return idx < 0 ? TERR_NOT_FOUND : del_edm(idx, etf_flags);
5924}
5925
5927 uint64 value,
5928 uint etf_flags,
5929 bmask64_t bmask,
5930 uchar serial)
5931{
5932 edm_t edm;
5933 ssize_t idx = get_edm_by_value(&edm, value, bmask, serial);
5934 return idx < 0 ? TERR_NOT_FOUND : del_edm(idx, etf_flags);
5935}
5936
5938{
5940 if ( rc >= 0 )
5941 *out = at(rc);
5942 return rc;
5943}
5944
5949{
5950 tinfo_t r;
5951 r.typid = get_tinfo_property(tif.typid, tinfo_t::GTA_SAFE_PTR_OBJ);
5952 return r;
5953}
5954
5957{
5961 int flags = 0;
5965#define TVIS_TYPE 0x0001
5966#define TVIS_NAME 0x0002
5967#define TVIS_CMT 0x0004
5968#define TVIS_RPTCMT 0x0008
5970 void clear() { flags = 0; }
5971
5975 void set_new_type(const tinfo_t &t) { type = t; flags |= TVIS_TYPE; }
5976 void set_new_name(const qstring &n) { name = n; flags |= TVIS_NAME; }
5977 void set_new_cmt(const qstring &c, bool rptcmt)
5978 {
5979 cmt = c;
5980 flags |= TVIS_CMT;
5981 setflag(flags, TVIS_RPTCMT, rptcmt);
5982 }
5983
5984 bool has_type() const { return (flags & TVIS_TYPE) != 0; }
5985 bool has_name() const { return (flags & TVIS_NAME) != 0; }
5986 bool has_cmt() const { return (flags & TVIS_CMT) != 0; }
5987 bool is_rptcmt() const { return (flags & TVIS_RPTCMT) != 0; }
5988 bool has_info() const { return flags != 0; }
5989};
5990
5993{
5994 int state;
5998#define TVST_PRUNE 0x01
5999#define TVST_DEF 0x02
6000#define TVST_LEVEL 0x04 // has level member (internal use)
6002 int level; // recursion level (internal use)
6003 tinfo_visitor_t(int s=0) : state(s|TVST_LEVEL), level(0) {}
6004
6005 virtual ~tinfo_visitor_t() {}
6006
6013 virtual int idaapi visit_type(
6014 type_mods_t *out,
6015 const tinfo_t &tif,
6016 const char *name,
6017 const char *cmt) = 0;
6018
6020 void prune_now() { state |= TVST_PRUNE; }
6021
6023 int apply_to(const tinfo_t &tif, type_mods_t *out=nullptr, const char *name=nullptr, const char *cmt=nullptr)
6024 {
6025 return visit_subtypes(this, out, tif, name, cmt);
6026 }
6027};
6028
6029
6030//------------------------------------------------------------------------
6031// Definitions for packing/unpacking idc objects
6032
6035{
6039 size_t size() const { return value.size(); }
6040};
6043
6044struct regobjs_t : public regobjvec_t {};
6045
6046
6048
6050 idc_value_t *obj,
6051 const tinfo_t &tif,
6052 ea_t ea,
6053 const bytevec_t *off0, // if !nullptr: bytevec that represents object at 'ea'
6054 int pio_flags=0);
6055#define PIO_NOATTR_FAIL 0x0004
6056#define PIO_IGNORE_PTRS 0x0008
6057
6058
6060
6062 idc_value_t *obj,
6063 const tinfo_t &tif,
6064 const bytevec_t &bytes,
6065 int pio_flags=0);
6066
6067
6069
6070idaman error_t ida_export pack_idcobj_to_idb(
6071 const idc_value_t *obj,
6072 const tinfo_t &tif,
6073 ea_t ea,
6074 int pio_flags=0);
6075
6076
6079
6080idaman error_t ida_export pack_idcobj_to_bv(
6081 const idc_value_t *obj,
6082 const tinfo_t &tif,
6083 relobj_t *bytes,
6084 void *objoff, // nullptr - append object to 'bytes'
6085 // if not nullptr:
6086 // in: int32*: offset in 'bytes' for the object
6087 // -1 means 'do not store the object itself in bytes
6088 // store only pointed objects'
6089 // out: data for object (if *(int32*)objoff == -1)
6090 int pio_flags=0);
6091
6092
6095
6096idaman bool ida_export apply_tinfo_to_stkarg(
6097 const insn_t &insn,
6098 const op_t &x,
6099 uval_t v,
6100 const tinfo_t &tif,
6101 const char *name);
6102
6103//------------------------------------------------------------------------
6104// Helper struct for the processor modules: process call arguments
6106{
6107 size_t reserved = 0;
6108
6110
6112 virtual bool idaapi set_op_tinfo(
6113 const insn_t &insn,
6114 const op_t &x,
6115 const tinfo_t &tif,
6116 const char *name) = 0;
6117
6123 virtual bool idaapi is_stkarg_load(const insn_t &insn, int *src, int *dst) = 0;
6124
6126 virtual bool idaapi has_delay_slot(ea_t /*caller*/) { return false; }
6127
6130 inline void use_arg_tinfos(ea_t caller, func_type_data_t *fti, funcargvec_t *rargs);
6131};
6132
6134idaman void ida_export gen_use_arg_tinfos(
6135 struct argtinfo_helper_t *_this,
6136 ea_t caller,
6137 func_type_data_t *fti,
6138 funcargvec_t *rargs);
6139
6141 ea_t caller,
6142 func_type_data_t *fti,
6143 funcargvec_t *rargs)
6144{
6145 gen_use_arg_tinfos(this, caller, fti, rargs);
6146}
6147
6148//-------------------------------------------------------------------------
6149
6153
6154idaman bool ida_export func_has_stkframe_hole(ea_t ea, const func_type_data_t &fti);
6155
6156//-------------------------------------------------------------------------
6159{
6160public:
6162 virtual bool idaapi func_has_stkframe_hole(
6163 const tinfo_t &candidate,
6164 const func_type_data_t &candidate_data) = 0;
6165
6166 virtual int idaapi get_func_purged_bytes(
6167 const tinfo_t &candidate,
6168 const func_type_data_t &candidate_data) = 0;
6169};
6170
6171//-------------------------------------------------------------------------
6175{
6176 const tinfo_t &tif;
6177 ea_t ea;
6178 int purged_bytes;
6179
6180public:
6181 ida_lowertype_helper_t(const tinfo_t &_tif, ea_t _ea, int _pb)
6182 : tif(_tif), ea(_ea), purged_bytes(_pb) {}
6183
6184 virtual bool idaapi func_has_stkframe_hole(
6185 const tinfo_t &candidate,
6186 const func_type_data_t &candidate_data) override
6187 {
6188 return candidate == tif
6189 ? ::func_has_stkframe_hole(ea, candidate_data)
6190 : false;
6191 }
6192
6193 virtual int idaapi get_func_purged_bytes(
6194 const tinfo_t &candidate,
6195 const func_type_data_t &) override
6196 {
6197 return candidate == tif
6198 ? purged_bytes
6199 : -1;
6200 }
6201};
6202
6203//-------------------------------------------------------------------------
6218
6219idaman int ida_export lower_type(
6220 til_t *til,
6221 tinfo_t *tif,
6222 const char *name=nullptr,
6223 lowertype_helper_t *_helper=nullptr);
6224
6225
6232
6233idaman int ida_export replace_ordinal_typerefs(til_t *til, tinfo_t *tif);
6234
6235
6242
6246
6247idaman void ida_export begin_type_updating(update_type_t utp);
6248
6249
6251
6252idaman void ida_export end_type_updating(update_type_t utp);
6253
6254//-------------------------------------------------------------------------
6257
6261idaman tid_t ida_export get_named_type_tid(const char *name);
6262
6263inline tid_t edm_t::get_tid() const { return get_named_type_tid(name.c_str()); }
6264
6265
6271idaman bool ida_export get_tid_name(qstring *out, tid_t tid);
6272
6273
6277idaman uint32 ida_export get_tid_ordinal(tid_t tid);
6278
6279
6284idaman ssize_t ida_export get_udm_by_fullname(udm_t *udm, const char *fullname);
6285
6286
6293idaman bool ida_export get_idainfo_by_udm(
6294 flags64_t *flags,
6295 opinfo_t *ti,
6296 const udm_t &udm,
6297 ea_t refinfo_ea=BADADDR);
6298
6299
6311 const char *enum_name,
6312 enum_type_data_t &ei,
6313 int enum_width,
6314 type_sign_t sign,
6315 bool convert_to_bitmask,
6316 const char *enum_cmt=nullptr)
6317{
6318 if ( sign == type_signed )
6319 ei.taenum_bits |= TAENUM_SIGNED;
6320 else if ( sign == type_unsigned )
6321 ei.taenum_bits |= TAENUM_UNSIGNED;
6322 ei.set_nbytes(enum_width);
6323
6324 tid_t tid = BADADDR;
6325 tinfo_t tif;
6326 if ( tif.create_enum(ei)
6327 && (enum_cmt == nullptr || tif.set_type_cmt(enum_cmt) == TERR_OK)
6328 && tif.set_enum_is_bitmask(convert_to_bitmask ? tinfo_t::ENUMBM_ON : tinfo_t::ENUMBM_OFF) == TERR_OK
6329 && tif.set_named_type(nullptr, enum_name, NTF_TYPE|NTF_REPLACE) == TERR_OK )
6330 {
6331 tid = get_named_type_tid(enum_name);
6332 }
6333 return tid;
6334}
6335
6337
6338//-------------------------------------------------------------------------
6341{
6342 int ptvf;
6346#define PTV_DEREF 0x0001
6349#define PTV_QUEST 0x0002
6350#define PTV_EMPTY 0x0004
6352#define PTV_CSTR 0x0008
6353#define PTV_EXPAND 0x0010
6356#define PTV_LZERO 0x0020
6357#define PTV_STPFLT 0x0040
6359#define PTV_SPACE 0x0080
6360#define PTV_DEBUG 0x0100
6361#define PTV_NOPTR 0x0200
6362#define PTV_NTOP 0x40000000
6363#define PTV_KEEP 0x80000000
6365 int radix;
6378
6380 : ptvf(PTV_EMPTY|PTV_CSTR|PTV_SPACE), radix(10), max_length(0),
6381 arrbase(0), arrnelems(0),
6382 margin(80), indent(2) {}
6383};
6384
6387{
6391 valinfo_t(argloc_t l=argloc_t(), const char *name=nullptr, const tinfo_t &tif=tinfo_t())
6392 : loc(l), label(name), type(tif) {}
6394 {
6395 loc.swap(r.loc);
6396 label.swap(r.label);
6397 type.swap(r.type);
6398 }
6399 DEFINE_MEMORY_ALLOCATION_FUNCS()
6400};
6402
6403
6408{
6409public:
6411 size_t length;
6414 int props;
6415#define VALSTR_OPEN 0x01
6416
6417 valstr_t() : length(0), members(nullptr), info(nullptr), props(0) {}
6418 ~valstr_t();
6419 DEFINE_MEMORY_ALLOCATION_FUNCS()
6420private:
6421 struct flatten_args_t
6422 {
6423 const valstr_t *may_not_collapse;
6424 int ptvf;
6425 int max_length;
6426 int margin;
6427 int indent;
6428 };
6429 friend struct valstr_sink_t;
6430 void update_length(int ptvf);
6431 void set_oneline(const char *line, int len)
6432 {
6433 oneline.append(line, len);
6434 length = oneline.length();
6435 }
6436 void consume_oneline(const qstring &line)
6437 {
6438 oneline.append(line);
6439 length = oneline.length();
6440 }
6441 bool append_char(char c, int max_length);
6442 bool convert_to_one_line(int ptvf, int max_length);
6443 bool flatten(const flatten_args_t &flargs, int level);
6444};
6447
6448struct valstrs_t : public valstrvec_t {};
6449
6451{
6452 delete members;
6453 delete info;
6454}
6455
6456
6465
6466idaman bool ida_export format_cdata(
6467 qstrvec_t *outvec,
6468 const idc_value_t &idc_value,
6469 const tinfo_t *tif,
6470 valstr_t *vtree=nullptr,
6471 const format_data_info_t *fdi=nullptr);
6472
6475{
6476 virtual ~text_sink_t() {}
6478 virtual int idaapi print(const char *str) = 0;
6479};
6480
6481
6489
6490idaman int ida_export print_cdata(
6491 text_sink_t &printer,
6492 const idc_value_t &idc_value,
6493 const tinfo_t *tif,
6494 const format_data_info_t *fdi=nullptr);
6495
6496//-------------------------------------------------------------------------
6499#define PDF_INCL_DEPS 0x1
6500#define PDF_DEF_FWD 0x2
6501#define PDF_DEF_BASE 0x4
6502#define PDF_HEADER_CMT 0x8
6504
6506
6517
6518idaman int ida_export print_decls(
6519 text_sink_t &printer,
6520 const til_t *til,
6521 const ordvec_t *ordinals,
6522 uint32 pdf_flags);
6523
6524
6532
6533idaman int ida_export calc_number_of_children(
6534 const argloc_t &loc,
6535 const tinfo_t &tif,
6536 bool dont_deref_ptr=false);
6537
6538
6548
6549idaman bool ida_export get_enum_member_expr(
6550 qstring *buf,
6551 const tinfo_t &tif,
6552 int serial,
6553 uint64 value);
6554
6555
6556//-------------------------------------------------------------------------
6557// Dialogs to choose a symbol from a type library
6558//------------------------------------------------------------------------
6559
6562{
6563 const char *name;
6564 const til_t *til;
6565 til_symbol_t(const char *n = nullptr, const til_t *t = nullptr): name(n), til(t) {}
6566};
6568
6569
6572
6574{
6575 virtual bool idaapi should_display(
6576 const til_t *til,
6577 const char *name,
6578 const type_t *type,
6579 const p_list *fields) = 0;
6580 virtual ~predicate_t() {}
6581};
6582
6583
6591
6592idaman bool ida_export choose_named_type(
6593 til_symbol_t *out_sym,
6594 const til_t *root_til,
6595 const char *title,
6596 int ntf_flags,
6597 predicate_t *predicate=nullptr);
6598
6599
6603
6604typedef int idaapi local_tinfo_predicate_t(uint32 ord, const tinfo_t &type, void *ud);
6605
6606
6614
6615idaman uint32 ida_export choose_local_tinfo(
6616 const til_t *ti,
6617 const char *title,
6618 local_tinfo_predicate_t *func = nullptr,
6619 uint32 def_ord = 0,
6620 void *ud = nullptr);
6621
6622
6631
6633 int32 *delta,
6634 const til_t *ti,
6635 const char *title,
6636 local_tinfo_predicate_t *func = nullptr,
6637 uint32 def_ord = 0,
6638 void *ud = nullptr);
6639
6640
6647using enum_type_visitor_t = std::function<ssize_t(const struct enum_type_data_t &ei, size_t idx, uint64 value, uint64 bmask)>;
6648
6665idaman ssize_t ida_export visit_edms(
6666 const tinfo_t &tif,
6667 uint64 value,
6668 int nbytes,
6669 uchar serial,
6670 const enum_type_visitor_t &visitor);
6671
6672//-------------------------------------------------------------------------
6674{
6675 if ( PH.ti() )
6676 return notify(ev_equal_reglocs, &a1, &a2);
6677 else
6678 return a1.compare(a2);
6679}
6680
6681//-------------------------------------------------------------------------
6683 qstring *outbuf,
6684 const char *name,
6685 bool mangle,
6686 callcnv_t cc,
6687 const tinfo_t &type)
6688{
6689 ssize_t code = notify(ev_decorate_name, outbuf, name, mangle, cc, &type);
6690 if ( code == 0 )
6691 code = gen_decorate_name(outbuf, name, mangle, cc, &type);
6692 return code;
6693}
6694
6695//-------------------------------------------------------------------------
6696inline bool calc_retloc(argloc_t *retloc, const tinfo_t &rettype, callcnv_t cc)
6697{
6698 func_type_data_t fti;
6699 fti.set_cc(cc);
6700 fti.rettype = rettype;
6701 if ( !calc_retloc(&fti) )
6702 return false;
6703 retloc->swap(fti.retloc);
6704 return true;
6705}
6706
6707//-------------------------------------------------------------------------
6708// this structure is used to hold context data for the 'types' view
6710{
6711 size_t cb = sizeof(til_type_ref_t);
6712 tinfo_t tif; //< type info, !empty() during runtime
6713 tif_cursor_t cursor = TIF_CURSOR_HEADER; //< 'pointer' inside a type
6714 uint32 ordinal = 0; //< cached value of tif.get_ordinal()
6715 bool is_writable = false; //< can we modify the type? (either in a RW til, or writable backend)
6716 bool is_detached = false; //< type is not backed by a backend that will cause views to be updated automatically
6717 bool is_forward = false; //< is the type a forward declaration?
6718 type_t kind = BT_UNK; //< one of BTF_TYPEDEF, BTF_STRUCT, BTF_UNION, BTF_ENUM, BT_FUNC
6719 ssize_t memidx = -1; //< index of the current BTF_STRUCT, BTF_UNION, BTF_ENUM member or BT_FUNC argument
6720 size_t nmembers = 0; //< number of members in the BTF_STRUCT, BTF_UNION, BTF_ENUM or number of arguments in the BT_FUNC
6721
6724 size_t total_size = 0;
6725 size_t unpadded_size = 0;
6727 uint64 bucket_start = uint64(-1); //< bucket offset (equal to 'offset' except for bitfields)
6728 int bf_bitoff = -1; //< for bitfields, bit offset from bucket_start
6729 uint64 offset = uint64(-1); //< the current offset (regardless if
6730 //< we have a defined member at the current
6731 //< offset or not)
6732
6735
6737 const funcarg_t *fa = nullptr;
6738
6739 void clear() { *this = til_type_ref_t(); }
6740 bool on_member() const { return memidx != -1; }
6741 bool is_typedef() const { return kind == BTF_TYPEDEF; }
6742 bool is_struct() const { return kind == BTF_STRUCT; }
6743 bool is_union() const { return kind == BTF_UNION; }
6744 bool is_enum() const { return kind == BTF_ENUM; }
6745 bool is_func() const { return kind == BT_FUNC; }
6746 bool is_udt() const { return kind == BTF_STRUCT || kind == BTF_UNION; }
6747};
6748
6749
6750#endif // _TYPEINF_HPP
iterator begin(void)
Get a pointer to the beginning of the qstring.
Definition pro.h:3177
Describes an argument location.
Definition typeinf.hpp:1101
rrel_t * rrel
Definition typeinf.hpp:1111
uint32 reginfo
Definition typeinf.hpp:1110
scattered_aloc_t * dist
Definition typeinf.hpp:1112
void * custom
Definition typeinf.hpp:1113
biggest_t biggest
Definition typeinf.hpp:1114
size_t biggest_t
Definition typeinf.hpp:1103
sval_t sval
Definition typeinf.hpp:1109
Vector of bytes (use for dynamic memory)
Definition pro.h:3773
Register allocation calling convention.
Definition typeinf.hpp:1733
callregs_t(callcnv_t cc)
Constructor - initialize with the given request (see init_regs())
Definition typeinf.hpp:1772
reg_kind_t
Init registers (sequential)
Definition typeinf.hpp:1809
@ FPREGS
Definition typeinf.hpp:1809
@ GPREGS
Definition typeinf.hpp:1809
void swap(callregs_t &r)
swap two instances
Definition typeinf.hpp:1775
argreg_policy_t policy
argument policy
Definition typeinf.hpp:1763
static int findreg(const intvec_t &regs, int r)
Definition typeinf.hpp:1839
bool reginds(int *gp_ind, int *fp_ind, int r) const
Get register indexes within GP/FP arrays.
Definition typeinf.hpp:1847
void reset()
Set policy and registers to invalid values.
Definition typeinf.hpp:1826
void set_registers(reg_kind_t kind, int first_reg, int last_reg)
Definition typeinf.hpp:1818
bool init_regs(callcnv_t cc)
Init policy & registers for given CC.
Definition typeinf.hpp:1784
void set(argreg_policy_t _policy, const int *gprs, const int *fprs)
Init policy & registers (arrays are -1-terminated)
Definition typeinf.hpp:1800
static int regcount(callcnv_t cc)
Get max number of registers may be used in a function call.
Definition typeinf.hpp:1832
intvec_t fpregs
array of fp registers (floating point)
Definition typeinf.hpp:1766
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:1855
int nregs
max number of registers that can be used in a call
Definition typeinf.hpp:1764
intvec_t gpregs
array of gp registers (general purpose)
Definition typeinf.hpp:1765
callregs_t()
Constructor.
Definition typeinf.hpp:1769
void append_registers(reg_kind_t kind, int first_reg, int last_reg)
Definition typeinf.hpp:1810
bool by_slots() const
Definition typeinf.hpp:1797
A function is a set of continuous ranges of addresses with characteristics.
Definition funcs.hpp:85
virtual int idaapi get_func_purged_bytes(const tinfo_t &candidate, const func_type_data_t &) override
Definition typeinf.hpp:6193
virtual bool idaapi func_has_stkframe_hole(const tinfo_t &candidate, const func_type_data_t &candidate_data) override
Definition typeinf.hpp:6184
ida_lowertype_helper_t(const tinfo_t &_tif, ea_t _ea, int _pb)
Definition typeinf.hpp:6181
Class to hold idc values.
Definition expr.hpp:315
Interface class - see ida_lowertype_helper_t.
Definition typeinf.hpp:6159
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:6161
Microcode of one basic block.
Definition hexrays.hpp:4184
Operand of an instruction.
Definition ua.hpp:170
Reimplementation of vector class from STL.
Definition pro.h:2250
void clear(void)
Destroy all elements and free memory.
Definition pro.h:2439
DEFINE_MEMORY_ALLOCATION_FUNCS() void push_back(const argpart_t &x)
Definition pro.h:2349
const int * const_iterator
Definition pro.h:2607
iterator end(void)
Get an iterator that points to the end of the qvector (NOT the last element)
Definition pro.h:2610
void resize(size_t _newsize, const T &x)
Resize to the given size.
Definition pro.h:2469
const edm_t & at(size_t _idx) const
Definition pro.h:2427
iterator find(const T &x)
Find an element in the qvector.
Definition pro.h:2703
qvector(void)
Definition pro.h:2328
edm_t & push_back(void)
Definition pro.h:2402
iterator begin(void)
Get an iterator that points to the first element in the qvector.
Definition pro.h:2609
void push_back(T &&x)
Append a new element to the end the qvector with a move semantics.
Definition pro.h:2361
size_t size(void) const
Get the number of elements in the qvector.
Definition pro.h:2423
ssize_t index(const edm_t &x) const
Definition pro.h:2723
Used to manage arguments that are described by multiple locations (also see ALOC_DIST)
Definition typeinf.hpp:1343
Primary mechanism for managing type information.
Definition typeinf.hpp:3046
bool remove_ptr_or_array()
Replace the current type with the ptr obj or array element.
Definition typeinf.hpp:3993
tinfo_code_t get_edm(edm_t *edm, size_t idx) const
Get enum member by its index.
Definition typeinf.hpp:3807
type_t get_forward_type() const
Get type of a forward declaration.
Definition typeinf.hpp:3417
THREAD_SAFE bool is_decl_udt() const
is_type_struni(get_decltype())
Definition typeinf.hpp:3448
DECLARE_COMPARISONS(tinfo_t)
Definition typeinf.hpp:4552
THREAD_SAFE bool is_decl_uint128() const
is_type_uint128(get_decltype())
Definition typeinf.hpp:3462
bool is_int64() const
is_type_int64(get_realtype())
Definition typeinf.hpp:3489
THREAD_SAFE bool is_decl_floating() const
is_type_floating(get_decltype())
Definition typeinf.hpp:3467
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:4241
bool is_scalar() const
Does the type represent a single number?
Definition typeinf.hpp:3513
THREAD_SAFE bool is_decl_tbyte() const
is_type_tbyte(get_decltype())
Definition typeinf.hpp:3466
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:4228
void create_typedef(const til_t *til, uint ord, type_t decl_type=BTF_TYPEDEF)
Definition typeinf.hpp:3904
bool get_array_details(array_type_data_t *ai) const
Get the array specific info.
Definition typeinf.hpp:3522
bool create_typedef(const typedef_type_data_t &p, type_t decl_type=BTF_TYPEDEF, bool try_ordinal=true)
Definition typeinf.hpp:3893
tinfo_code_t set_enum_radix(int radix, bool sign, uint etf_flags=0)
Set enum radix to display constants.
Definition typeinf.hpp:4371
tinfo_code_t set_enum_width(int nbytes, uint etf_flags=0)
Set the width of enum base type.
Definition typeinf.hpp:4324
tinfo_t get_rettype() const
BT_FUNC or BT_PTR BT_FUNC: Get the function's return type
Definition typeinf.hpp:3602
DEPRECATED bool set_declalign(uchar declalign)
Definition typeinf.hpp:4032
bool is_fixed_struct() const
Is a structure with fixed offsets?
Definition typeinf.hpp:3730
int get_type_cmt(qstring *out) const
Get type comment.
Definition typeinf.hpp:3429
tinfo_code_t set_named_type(til_t *til, const char *name, int ntf_flags=0)
Definition typeinf.hpp:3958
bool get_numbered_type(uint32 ordinal, type_t decl_type=BTF_TYPEDEF, bool resolve=true)
Definition typeinf.hpp:3234
bool has_vftable() const
Has a vftable?
Definition typeinf.hpp:3762
bool set_attrs(type_attrs_t *tav)
Set type attributes.
Definition typeinf.hpp:3878
tinfo_t get_onemember_type() const
For objects consisting of one member entirely: return type of the member.
Definition typeinf.hpp:3825
bool del_attr(const qstring &key, bool make_copy=true)
Del a type attribute. typerefs cannot be modified by this function.
Definition typeinf.hpp:3887
bool get_bit_buckets(range64vec_t *buckets) const
BT_STRUCT: get bit buckets Bit buckets are used to layout bitfields
Definition typeinf.hpp:3626
uint32 get_alignment() const
Get type alignment This function returns the effective type alignment.
Definition typeinf.hpp:3325
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:4078
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:3840
size_t get_enum_nmembers() const
Get number of enum members.
Definition typeinf.hpp:3769
bool get_named_type(const char *name, type_t decl_type=BTF_TYPEDEF, bool resolve=true, bool try_ordinal=true)
Definition typeinf.hpp:3216
THREAD_SAFE bool is_decl_complex() const
is_type_complex(get_decltype())
Definition typeinf.hpp:3443
uint32 get_final_ordinal() const
Get final type ordinal (0 if none)
Definition typeinf.hpp:3400
bool create_udt(bool is_union=false)
Create an empty structure/union.
Definition typeinf.hpp:5765
THREAD_SAFE bool is_decl_uchar() const
is_type_uchar(get_decltype())
Definition typeinf.hpp:3458
tinfo_code_t set_enum_sign(type_sign_t sign, uint etf_flags=0)
Set enum sign.
Definition typeinf.hpp:4332
bool get_type_name(qstring *out) const
Does a type refer to a name?
Definition typeinf.hpp:3355
bool is_one_fpval() const
Floating value or an object consisting of one floating member entirely.
Definition typeinf.hpp:3752
THREAD_SAFE bool is_decl_uint32() const
is_type_uint32(get_decltype())
Definition typeinf.hpp:3460
bool is_ext_arithmetic() const
is_type_ext_arithmetic(get_realtype())
Definition typeinf.hpp:3511
type_sign_t get_sign() const
Get type sign.
Definition typeinf.hpp:3333
bool is_volatile() const
is_type_volatile(get_realtype())
Definition typeinf.hpp:3474
THREAD_SAFE bool is_decl_ldouble() const
is_type_ldouble(get_decltype())
Definition typeinf.hpp:3463
static tinfo_t get_stock(stock_type_id_t id)
Get stock type information.
Definition typeinf.hpp:3982
void set_modifiers(type_t mod)
Definition typeinf.hpp:4013
uint32 get_alias_target() const
Get type alias If the type has no alias, return 0.
Definition typeinf.hpp:4059
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:3254
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:3940
bool is_ptr_or_array() const
is_type_ptr_or_array(get_realtype())
Definition typeinf.hpp:3506
bool is_vararg_cc() const
is_vararg_cc(get_cc())
Definition typeinf.hpp:3610
tinfo_code_t set_type_alignment(uchar declalign, uint etf_flags=0)
Set type alignment.
Definition typeinf.hpp:4027
bool is_uint() const
is_type_uint(get_realtype())
Definition typeinf.hpp:3494
bool get_enum_details(enum_type_data_t *ei) const
Get the enum specific info.
Definition typeinf.hpp:3528
tinfo_t get_ptrarr_object() const
BT_PTR & BT_ARRAY: get the pointed object or array element.
Definition typeinf.hpp:3570
tinfo_code_t save_type(int ntf_flags=NTF_TYPE|NTF_REPLACE)
Definition typeinf.hpp:3961
bool is_user_cc() const
is_user_cc(get_cc())
Definition typeinf.hpp:3609
til_t * get_til() const
Get the type library for tinfo_t.
Definition typeinf.hpp:3403
uchar get_declalign() const
Get declared alignment of the type.
Definition typeinf.hpp:3342
bool is_tuple() const
Is a tuple?
Definition typeinf.hpp:3733
bool is_varmember() const
Can the type be of a variable struct member?
Definition typeinf.hpp:3563
THREAD_SAFE bool is_decl_union() const
is_type_union(get_decltype())
Definition typeinf.hpp:3447
tinfo_code_t set_func_cc(callcnv_t cc, uint etf_flags=0)
Set function calling convention.
Definition typeinf.hpp:4528
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:3870
int get_udt_nmembers() const
Get number of udt members. -1-error.
Definition typeinf.hpp:3706
bool is_float() const
is_type_float(get_realtype())
Definition typeinf.hpp:3502
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:3815
const char * dstr() const
Function to facilitate debugging.
Definition typeinf.hpp:3867
bool get_nice_type_name(qstring *out) const
Get the beautified type name.
Definition typeinf.hpp:3359
bool is_empty_enum() const
Is an empty enum? (has no constants)
Definition typeinf.hpp:3772
ssize_t get_by_edm_name(const char *mname, const til_t *til=nullptr)
Retrieve enum tinfo using enum member name.
Definition typeinf.hpp:3950
bool is_arithmetic() const
is_type_arithmetic(get_realtype())
Definition typeinf.hpp:3510
THREAD_SAFE bool is_decl_char() const
is_type_char(get_decltype())
Definition typeinf.hpp:3456
bool is_floating() const
is_type_floating(get_realtype())
Definition typeinf.hpp:3509
bool clr_const()
Definition typeinf.hpp:4021
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:4490
THREAD_SAFE bool is_decl_enum() const
is_type_enum(get_decltype())
Definition typeinf.hpp:3449
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:3386
bool is_char() const
is_type_char(get_realtype())
Definition typeinf.hpp:3493
void set_const()
Definition typeinf.hpp:4014
tinfo_t(const tinfo_t &r)
Constructor.
Definition typeinf.hpp:3187
THREAD_SAFE bool is_decl_uint() const
is_type_uint(get_decltype())
Definition typeinf.hpp:3457
bool create_simple_type(type_t decl_type)
Definition typeinf.hpp:3889
tinfo_code_t set_enum_repr(const value_repr_t &repr, uint etf_flags=0)
Set the representation of enum members.
Definition typeinf.hpp:4365
bool is_int128() const
is_type_int128(get_realtype())
Definition typeinf.hpp:3488
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:4040
bool is_unaligned_struct() const
Is an unaligned struct.
Definition typeinf.hpp:3718
tinfo_code_t rename_funcarg(size_t index, const char *name, uint etf_flags=0)
Rename a function argument.
Definition typeinf.hpp:4480
THREAD_SAFE bool is_decl_unknown() const
is_type_unknown(get_decltype())
Definition typeinf.hpp:3438
THREAD_SAFE bool is_decl_int64() const
is_type_int64(get_decltype())
Definition typeinf.hpp:3452
THREAD_SAFE bool is_decl_int128() const
is_type_int128(get_decltype())
Definition typeinf.hpp:3451
bool is_int16() const
is_type_int16(get_realtype())
Definition typeinf.hpp:3491
bool set_type_alias(uint32 dest_ord)
Set type alias Redirects all references to source type to the destination type.
Definition typeinf.hpp:4068
tinfo_t get_pointed_object() const
BT_PTR: get type of pointed object.
Definition typeinf.hpp:3575
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:4196
bool is_forward_struct() const
Definition typeinf.hpp:3418
const char type_t decl_type
Definition typeinf.hpp:3212
bool is_small_udt() const
Is a small udt? (can fit a register or a pair of registers)
Definition typeinf.hpp:3712
bool is_unsigned() const
Is this an unsigned type?
Definition typeinf.hpp:3339
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:5948
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:3854
tinfo_t(type_t decl_type)
Constructor - can only be used to initialize simple types!
Definition typeinf.hpp:3178
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:3967
tinfo_code_t set_numbered_type(til_t *til, uint32 ord, int ntf_flags=0, const char *name=nullptr)
Definition typeinf.hpp:3960
bool is_cpp_struct() const
Is a c++ object, not simple pod type.
Definition typeinf.hpp:3724
bool is_varstruct() const
Is a variable-size structure?
Definition typeinf.hpp:3558
bool is_msstruct() const
Is gcc msstruct attribute applied.
Definition typeinf.hpp:3721
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:3264
uint32 get_ordinal() const
Get type ordinal (only if the type was created as a numbered type, 0 if none)
Definition typeinf.hpp:3397
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:3540
const char type_t bool bool try_ordinal
Definition typeinf.hpp:3214
THREAD_SAFE bool is_decl_array() const
is_type_array(get_decltype())
Definition typeinf.hpp:3441
tid_t get_udm_tid(size_t idx) const
Get udt member TID.
Definition typeinf.hpp:4100
uint64 write_bitfield_value(uint64 dst, uint64 v, int bitoff) const
Definition typeinf.hpp:4006
bool is_typedef() const
Is this a typedef?
Definition typeinf.hpp:3425
THREAD_SAFE bool empty() const
Was tinfo_t initialized with some type info or not?
Definition typeinf.hpp:3308
bool create_enum(enum_type_data_t &p, type_t decl_type=BTF_ENUM)
Definition typeinf.hpp:3928
tinfo_code_t del_udm(size_t index, uint etf_flags=0)
Delete a structure/union member.
Definition typeinf.hpp:4190
tinfo_code_t del_funcarg(size_t idx, uint etf_flags=0)
Definition typeinf.hpp:4513
bool is_shifted_ptr() const
Is a shifted pointer?
Definition typeinf.hpp:3555
bool get_ptr_details(ptr_type_data_t *pi) const
Get the pointer info.
Definition typeinf.hpp:3516
bool is_sue() const
is_type_sue(get_realtype())
Definition typeinf.hpp:3486
int get_ptrarr_objsize() const
BT_PTR & BT_ARRAY: get size of pointed object or array element. On error returns -1
Definition typeinf.hpp:3566
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:4312
tinfo_code_t set_func_rettype(const tinfo_t &tif, uint etf_flags=0)
Set function return type .
Definition typeinf.hpp:4499
bool clr_volatile()
Definition typeinf.hpp:4022
THREAD_SAFE bool is_decl_void() const
is_type_void(get_decltype())
Definition typeinf.hpp:3436
THREAD_SAFE bool is_decl_uint16() const
is_type_uint16(get_decltype())
Definition typeinf.hpp:3459
uint32 get_udt_taudt_bits() const
Get udt_type_data_t::taudt_bits.
Definition typeinf.hpp:3715
tinfo_code_t set_fixed_struct(bool on=true)
Declare struct member offsets as fixed.
Definition typeinf.hpp:4248
bool is_funcptr() const
Is this pointer to a function?
Definition typeinf.hpp:3552
bool is_forward_enum() const
Definition typeinf.hpp:3420
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:4279
bool is_integral() const
is_type_integral(get_realtype())
Definition typeinf.hpp:3507
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:3776
ssize_t get_edm_by_tid(edm_t *edm, tid_t tid)
Definition typeinf.hpp:3941
THREAD_SAFE bool has_details() const
Does this type refer to a nontrivial type?
Definition typeinf.hpp:3348
THREAD_SAFE bool is_decl_int32() const
is_type_int32(get_decltype())
Definition typeinf.hpp:3453
bool is_high_func() const
BT_FUNC: Is high level type?
Definition typeinf.hpp:3617
THREAD_SAFE bool is_decl_float() const
is_type_float(get_decltype())
Definition typeinf.hpp:3465
bool convert_array_to_ptr()
Convert an array into a pointer.
Definition typeinf.hpp:5815
bool is_bitfield() const
is_type_bitfld(get_realtype())
Definition typeinf.hpp:3487
bool equals_to(const tinfo_t &r) const
Definition typeinf.hpp:4574
THREAD_SAFE bool is_decl_struct() const
is_type_struct(get_decltype())
Definition typeinf.hpp:3446
tinfo_code_t rename_udm(size_t index, const char *name, uint etf_flags=0)
Rename a structure/union member.
Definition typeinf.hpp:4204
tinfo_code_t set_symbol_type(til_t *til, const char *name, int ntf_flags=0)
Definition typeinf.hpp:3959
THREAD_SAFE bool is_decl_sue() const
is_type_sue(get_decltype())
Definition typeinf.hpp:3445
void create_typedef(const til_t *til, const char *name, type_t decl_type=BTF_TYPEDEF, bool try_ordinal=true)
Definition typeinf.hpp:3903
bool create_func(func_type_data_t &p, type_t decl_type=BT_FUNC)
Definition typeinf.hpp:3929
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:4469
bool is_uchar() const
is_type_uchar(get_realtype())
Definition typeinf.hpp:3495
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:4111
bool create_udt(udt_type_data_t &p, type_t decl_type)
Definition typeinf.hpp:3927
bool change_sign(type_sign_t sign)
Change the type sign. Works only for the types that may have sign.
Definition typeinf.hpp:4036
bool present() const
Is the type really present? (not a reference to a missing type, for example)
Definition typeinf.hpp:3311
tinfo_code_t set_struct_size(size_t new_size)
Explicitly specify the struct size.
Definition typeinf.hpp:4255
tinfo_code_t del_edms(size_t idx1, size_t idx2, uint etf_flags=0)
Delete enum members.
Definition typeinf.hpp:4420
bool is_manually_castable_to(const tinfo_t &target) const
Definition typeinf.hpp:4576
uint64 read_bitfield_value(uint64 v, int bitoff) const
Definition typeinf.hpp:4005
bool has_union() const
Has a member of type "union"?
Definition typeinf.hpp:3765
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:5755
THREAD_SAFE bool is_decl_int() const
is_type_int(get_decltype())
Definition typeinf.hpp:3455
bool create_bitfield(const bitfield_type_data_t &p, type_t decl_type=BT_BITFIELD)
Definition typeinf.hpp:3892
int get_array_nelems() const
BT_ARRAY: get number of elements (-1 means error)
Definition typeinf.hpp:3590
bool is_frame() const
Is a function frame?
Definition typeinf.hpp:4297
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:4389
bool append_covered(rangeset_t *out, uint64 offset=0) const
Calculate set of covered bytes for the type.
Definition typeinf.hpp:3745
bool clr_const_volatile()
Definition typeinf.hpp:4023
bool create_enum(bte_t bte=BTE_ALWAYS|BTE_HEX)
Create an empty enum.
Definition typeinf.hpp:5777
const char * name
Definition typeinf.hpp:3211
THREAD_SAFE bool is_well_defined() const
!(empty()) && !(is_decl_partial()) && !(is_punknown())
Definition typeinf.hpp:3470
bool is_udm_by_til(size_t idx) const
Was the member created due to the type system.
Definition typeinf.hpp:4235
size_t get_unpadded_size() const
Get the type size in bytes without the final padding, in bytes.
Definition typeinf.hpp:3321
bool detach()
Detach tinfo_t from the underlying type.
Definition typeinf.hpp:3241
THREAD_SAFE bool is_decl_volatile() const
is_type_volatile(get_decltype())
Definition typeinf.hpp:3435
bool is_enum() const
is_type_enum(get_realtype())
Definition typeinf.hpp:3485
int get_udm(udm_t *out, const char *name) const
Retrieve a structure/union member with the specified name.
Definition typeinf.hpp:5876
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:3587
bool is_array() const
is_type_array(get_realtype())
Definition typeinf.hpp:3479
bool is_tbyte() const
is_type_tbyte(get_realtype())
Definition typeinf.hpp:3503
tinfo_code_t copy_type(til_t *til, const char *name, int ntf_flags=NTF_TYPE|NTF_COPY)
Definition typeinf.hpp:3962
bool create_ptr(const ptr_type_data_t &p, type_t decl_type=BT_PTR)
Definition typeinf.hpp:3890
THREAD_SAFE bool is_decl_const() const
is_type_const(get_decltype())
Definition typeinf.hpp:3434
bool is_ext_integral() const
is_type_ext_integral(get_realtype())
Definition typeinf.hpp:3508
bool is_int() const
is_type_int(get_realtype())
Definition typeinf.hpp:3492
bool set_methods(udtmembervec_t &methods)
BT_COMPLEX: set the list of member functions.
Definition typeinf.hpp:4045
bool is_forward_union() const
Definition typeinf.hpp:3419
THREAD_SAFE bool is_decl_func() const
is_type_func(get_decltype())
Definition typeinf.hpp:3442
bool is_uint128() const
is_type_uint128(get_realtype())
Definition typeinf.hpp:3499
THREAD_SAFE bool is_decl_ptr() const
is_type_ptr(get_decltype())
Definition typeinf.hpp:3440
THREAD_SAFE bool is_decl_double() const
is_type_double(get_decltype())
Definition typeinf.hpp:3464
bool calc_gaps(rangeset_t *out) const
Calculate set of padding bytes for the type.
Definition typeinf.hpp:3749
bool get_final_type_name(qstring *out) const
Use in the case of typedef chain (TYPE1 -> TYPE2 -> TYPE3...TYPEn).
Definition typeinf.hpp:3370
bool is_from_subtil() const
Was the named type found in some base type library (not the top level type library)?
Definition typeinf.hpp:3408
tid_t force_tid()
Get the type tid.
Definition typeinf.hpp:3394
THREAD_SAFE bool is_decl_last() const
is_typeid_last(get_decltype())
Definition typeinf.hpp:3439
bool create_array(const array_type_data_t &p, type_t decl_type=BT_ARRAY)
Definition typeinf.hpp:3891
bool is_correct() const
Is the type object correct?
Definition typeinf.hpp:3285
tinfo_t()
Constructor.
Definition typeinf.hpp:3176
bool is_forward_decl() const
Is this a forward declaration?
Definition typeinf.hpp:3412
bool is_int32() const
is_type_int32(get_realtype())
Definition typeinf.hpp:3490
bool is_bitmask_enum() const
Is bitmask enum?
Definition typeinf.hpp:3781
tinfo_code_t del_funcargs(size_t idx1, size_t idx2, uint etf_flags=0)
Delete function arguments.
Definition typeinf.hpp:4509
void del_attrs()
Del all type attributes. typerefs cannot be modified by this function.
Definition typeinf.hpp:3884
tinfo_t & operator=(const tinfo_t &r)
Copy contents of given tinfo into this one.
Definition typeinf.hpp:3189
bool is_bool() const
is_type_bool(get_realtype())
Definition typeinf.hpp:3504
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:3180
bool is_aliased() const
Definition typeinf.hpp:4063
ea_t get_frame_func() const
Get function address for the frame.
Definition typeinf.hpp:4300
bool is_empty_udt() const
Is an empty struct/union? (has no fields)
Definition typeinf.hpp:3709
tinfo_code_t set_enum_is_bitmask(bitmask_cvt_stance_t stance=ENUMBM_ON, uint etf_flags=0)
Definition typeinf.hpp:4360
int get_nargs() const
BT_FUNC or BT_PTR BT_FUNC: Calculate number of arguments (-1 - error)
Definition typeinf.hpp:3605
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:4222
bool is_anonymous_udt() const
Is an anonymous struct/union?
Definition typeinf.hpp:3759
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:3833
bitmask_cvt_stance_t
Set or clear the 'bitmask' attribute of an enum.
Definition typeinf.hpp:4355
@ ENUMBM_ON
convert to bitmask enum
Definition typeinf.hpp:4357
@ ENUMBM_OFF
convert to ordinal enum
Definition typeinf.hpp:4356
@ ENUMBM_AUTO
convert to bitmask if the outcome is nice and useful
Definition typeinf.hpp:4358
type_t get_modifiers() const
Definition typeinf.hpp:4012
bool get_func_frame(const func_t *pfn)
Create a tinfo_t object for the function frame.
Definition typeinf.hpp:4294
tinfo_code_t add_funcarg(const funcarg_t &farg, uint etf_flags=0, ssize_t idx=-1)
Add a function argument.
Definition typeinf.hpp:4522
type_t get_realtype(bool full=false) const
Get the resolved base type.
Definition typeinf.hpp:3298
tinfo_code_t set_func_retloc(const argloc_t &argloc, uint etf_flags=0)
Set location of function return value.
Definition typeinf.hpp:4547
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:4052
int calc_purged_bytes() const
BT_FUNC: Calculate number of purged bytes
Definition typeinf.hpp:3614
void set_volatile()
Definition typeinf.hpp:4015
void swap(tinfo_t &r)
Assign this = r and r = this.
Definition typeinf.hpp:3195
void clear()
Clear contents of this tinfo, and remove from the type system.
Definition typeinf.hpp:3193
bool is_partial() const
is_type_partial(get_realtype())
Definition typeinf.hpp:3476
bool get_methods(udtmembervec_t *methods) const
BT_COMPLEX: get a list of member functions declared in this udt.
Definition typeinf.hpp:3621
bool is_pvoid() const
Is "void *"?. This function does not check the pointer attributes and type modifiers.
Definition typeinf.hpp:3578
int get_udm_by_offset(udm_t *out, uint64 offset) const
Retrieve a structure/union member with the specified offset.
Definition typeinf.hpp:5897
bool is_ldouble() const
is_type_ldouble(get_realtype())
Definition typeinf.hpp:3500
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:3912
bool get_attr(const qstring &key, bytevec_t *bv, bool all_attrs=true) const
Get a type attribute.
Definition typeinf.hpp:3873
uint32 calc_score() const
Calculate the type score (the higher - the nicer is the type)
Definition typeinf.hpp:3843
tinfo_t get_array_element() const
BT_ARRAY: get type of array element. See also get_ptrarr_object()
Definition typeinf.hpp:3584
bool is_const() const
is_type_const(get_realtype())
Definition typeinf.hpp:3473
int get_enum_width() const
Get enum width.
Definition typeinf.hpp:3795
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:3244
tinfo_code_t rename_type(const char *name, int ntf_flags=0)
Rename a type.
Definition typeinf.hpp:3365
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:3755
THREAD_SAFE bool is_decl_uint64() const
is_type_uint64(get_decltype())
Definition typeinf.hpp:3461
bool is_double() const
is_type_double(get_realtype())
Definition typeinf.hpp:3501
bool is_func() const
is_type_func(get_realtype())
Definition typeinf.hpp:3480
bool get_next_type_name(qstring *out) const
Use In the case of typedef chain (TYPE1 -> TYPE2 -> TYPE3...TYPEn).
Definition typeinf.hpp:3375
bool is_uint64() const
is_type_uint64(get_realtype())
Definition typeinf.hpp:3498
bool is_ptr() const
is_type_ptr(get_realtype())
Definition typeinf.hpp:3478
bool get_type_by_tid(tid_t tid)
Definition typeinf.hpp:3942
bool requires_qualifier(qstring *out, const char *name, uint64 offset) const
Requires full qualifier?
Definition typeinf.hpp:3740
int find_udm(udm_t *udm, int strmem_flags) const
BTF_STRUCT,BTF_UNION: Find a udt member.
Definition typeinf.hpp:3635
bool get_bitfield_details(bitfield_type_data_t *bi) const
Get the bitfield specific info.
Definition typeinf.hpp:3534
tinfo_code_t get_enum_repr(value_repr_t *repr) const
Set the representation of enum members.
Definition typeinf.hpp:3790
ssize_t get_edm(edm_t *out, const char *name) const
Get enum member by its name.
Definition typeinf.hpp:3802
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:3881
bool is_struct() const
is_type_struct(get_realtype())
Definition typeinf.hpp:3482
size_t get_size(uint32 *p_effalign=nullptr, int gts_code=0) const
Get the type size in bytes.
Definition typeinf.hpp:3317
bool is_purging_cc() const
is_purging_cc(get_cc())
Definition typeinf.hpp:3611
THREAD_SAFE bool is_decl_paf() const
is_type_paf(get_decltype())
Definition typeinf.hpp:3469
bool is_complex() const
is_type_complex(get_realtype())
Definition typeinf.hpp:3481
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:4458
bool get_type_rptcmt(qstring *out) const
Get type comment only if it is repeatable.
Definition typeinf.hpp:3432
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:3546
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:5926
bool is_paf() const
is_type_paf(get_realtype())
Definition typeinf.hpp:3505
bool is_punknown() const
Is "_UNKNOWN *"?. This function does not check the pointer attributes and type modifiers.
Definition typeinf.hpp:3581
THREAD_SAFE bool is_decl_bitfield() const
is_type_bitfld(get_decltype())
Definition typeinf.hpp:3450
tinfo_code_t set_tuple(bool on=true)
Declare struct as a tuple.
Definition typeinf.hpp:4290
bool is_signed() const
Is this a signed type?
Definition typeinf.hpp:3336
THREAD_SAFE bool is_decl_int16() const
is_type_int16(get_decltype())
Definition typeinf.hpp:3454
tid_t get_edm_tid(size_t idx) const
Get enum member TID.
Definition typeinf.hpp:3822
tinfo_code_t rename_edm(size_t idx, const char *name, uint etf_flags=0)
Rename a enum member.
Definition typeinf.hpp:4448
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:4215
tinfo_code_t del_edm(size_t idx, uint etf_flags=0)
Definition typeinf.hpp:4424
THREAD_SAFE bool is_decl_partial() const
is_type_partial(get_decltype())
Definition typeinf.hpp:3437
bool is_uint32() const
is_type_uint32(get_realtype())
Definition typeinf.hpp:3497
bool is_unknown() const
is_type_unknown(get_realtype())
Definition typeinf.hpp:3477
THREAD_SAFE bool is_decl_bool() const
is_type_bool(get_decltype())
Definition typeinf.hpp:3468
const char type_t bool resolve
Definition typeinf.hpp:3213
int get_enum_radix() const
Get enum constant radix.
Definition typeinf.hpp:3786
THREAD_SAFE bool is_decl_typedef() const
is_type_typedef(get_decltype())
Definition typeinf.hpp:3444
bool is_union() const
is_type_union(get_realtype())
Definition typeinf.hpp:3483
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:4538
THREAD_SAFE type_t get_decltype() const
Get declared type (without resolving type references; they are returned as is).
Definition typeinf.hpp:3305
bool is_vftable() const
Is a vftable type?
Definition typeinf.hpp:3727
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:4573
void clr_decl_const_volatile()
Definition typeinf.hpp:4017
~tinfo_t()
Destructor.
Definition typeinf.hpp:3191
callcnv_t get_cc() const
BT_FUNC or BT_PTR BT_FUNC: Get calling convention
Definition typeinf.hpp:3608
bool is_castable_to(const tinfo_t &target) const
Definition typeinf.hpp:4575
bool is_udt() const
is_type_struni(get_realtype())
Definition typeinf.hpp:3484
bool is_void() const
is_type_void(get_realtype())
Definition typeinf.hpp:3475
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:3593
THREAD_SAFE bool is_typeref() const
Is this type a type reference?.
Definition typeinf.hpp:3345
tinfo_code_t set_udt_pack(int pack, uint etf_flags=0)
Set structure packing.
Definition typeinf.hpp:4090
bool is_uint16() const
is_type_uint16(get_realtype())
Definition typeinf.hpp:3496
uint64 calc_enum_mask() const
Definition typeinf.hpp:3796
Text representation of a data value (value string).
Definition typeinf.hpp:6408
qstring oneline
result if printed on one line in UTF-8 encoding
Definition typeinf.hpp:6410
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:6431
bool convert_to_one_line(int ptvf, int max_length)
~valstr_t()
Definition typeinf.hpp:6450
struct valstrs_t * members
strings for members, each member separately
Definition typeinf.hpp:6412
void consume_oneline(const qstring &line)
Definition typeinf.hpp:6436
void update_length(int ptvf)
int props
temporary properties, used internally
Definition typeinf.hpp:6414
valinfo_t * info
additional info
Definition typeinf.hpp:6413
valstr_t()
Definition typeinf.hpp:6417
friend struct() private valstr_sink_t
Definition typeinf.hpp:6419
size_t length
length if printed on one line
Definition typeinf.hpp:6411
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:1714
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:1474
void helper_set_cc(cm_t *cm, callcnv_t *new_callcnv, callcnv_t cc)
Definition typeinf.hpp:1432
constexpr THREAD_SAFE bool is_vararg_cc(callcnv_t cc)
Does the calling convention use ellipsis?
Definition typeinf.hpp:1466
idaman const custom_callcnv_t *ida_export get_custom_callcnv(callcnv_t callcnv)
Retrieve custom calling convention details.
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:1399
const argloc_type_t ALOC_NONE
none
Definition typeinf.hpp:953
callcnv_t helper_get_cc(cm_t cm, callcnv_t new_callcnv)
Definition typeinf.hpp:1423
qvector< argpart_t > argpartvec_t
Definition typeinf.hpp:1339
const argloc_type_t ALOC_CUSTOM
custom argloc (7 or higher)
Definition typeinf.hpp:960
const argloc_type_t ALOC_RREL
register relative
Definition typeinf.hpp:958
const argloc_type_t ALOC_DIST
distributed (scattered)
Definition typeinf.hpp:955
const argloc_type_t ALOC_REG2
register pair
Definition typeinf.hpp:957
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:959
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:956
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:1460
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:1503
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:1486
void set_cc(callcnv_t cc)
Definition typeinf.hpp:1448
qvector< argloc_t > arglocs_t
vector of argument locations
Definition typeinf.hpp:1309
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:954
callcnv_t get_cc() const
Definition typeinf.hpp:1447
bool is_custom_callcnv(callcnv_t cc)
Is custom calling convention?
Definition typeinf.hpp:1492
callcnv_t get_effective_cc(callcnv_t cc)
Get effective calling convention (with respect to default CC)
Definition typeinf.hpp:1451
@ ARGREGS_GP_ONLY
GP registers used for all arguments.
Definition typeinf.hpp:1716
@ ARGREGS_POLICY_UNDEFINED
Definition typeinf.hpp:1715
@ 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:1721
@ ARGREGS_FP_MASKS_GP
FP register also consumes one or more GP regs but not vice versa (aix ppc ABI)
Definition typeinf.hpp:1719
@ ARGREGS_BY_SLOTS
fixed FP/GP register per each slot (like vc64)
Definition typeinf.hpp:1718
@ ARGREGS_MIPS_O32
MIPS ABI o32.
Definition typeinf.hpp:1720
@ ARGREGS_INDEPENDENT
FP/GP registers used separately (like gcc64)
Definition typeinf.hpp:1717
const type_t BFA_STATIC
static
Definition typeinf.hpp:925
const type_t BFA_FUNC_EXT_FORMAT
This is NOT a real attribute (used internally as marker for extended format)
Definition typeinf.hpp:929
const type_t BFA_NORET
__noreturn
Definition typeinf.hpp:922
const cm_t BFA_FUNC_MARKER
This is NOT a cc! (used internally as a marker)
Definition typeinf.hpp:928
const type_t BFA_VIRTUAL
virtual
Definition typeinf.hpp:926
const type_t BFA_HIGH
high level prototype (with possibly hidden args)
Definition typeinf.hpp:924
const type_t BFA_PURE
__pure
Definition typeinf.hpp:923
const cm_t C_PC_FLAT
Definition typeinf.hpp:1417
const cm_t C_PC_SMALL
Definition typeinf.hpp:1412
const cm_t C_PC_MEDIUM
Definition typeinf.hpp:1414
const cm_t C_PC_LARGE
Definition typeinf.hpp:1415
const cm_t C_PC_TINY
Definition typeinf.hpp:1411
const cm_t C_PC_HUGE
Definition typeinf.hpp:1416
const cm_t C_PC_COMPACT
Definition typeinf.hpp:1413
bool is_gcc()
Is the target compiler COMP_GNU?
Definition typeinf.hpp:1923
bool idaapi set_abi_name(const char *abiname, bool user_level=false)
Set abi name (see Compiler IDs)
Definition typeinf.hpp:1974
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:2003
THREAD_SAFE comp_t get_comp(comp_t comp)
Get compiler bits.
Definition typeinf.hpp:1890
bool is_gcc32()
Is the target compiler 32 bit gcc?
Definition typeinf.hpp:1928
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:1938
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:1918
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:1913
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:1903
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:2010
bool idaapi set_compiler_id(comp_t id, const char *abiname=nullptr)
Set the compiler id (see Compiler IDs)
Definition typeinf.hpp:1965
bool is_gcc64()
Is the target compiler 64 bit gcc?
Definition typeinf.hpp:1933
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:886
const callcnv_t CM_CC_SWIFT
(Swift) arguments and return values in registers (compiler-dependent)
Definition typeinf.hpp:889
const callcnv_t CM_CC_RESERVE3
reserved; used for internal needs
Definition typeinf.hpp:895
const callcnv_t CM_CC_CDECL
stack
Definition typeinf.hpp:883
const callcnv_t CM_CC_INVALID
this value is invalid
Definition typeinf.hpp:878
const callcnv_t CM_CC_SPECIALP
Equal to CM_CC_SPECIAL, but with purged stack.
Definition typeinf.hpp:897
const callcnv_t CM_CC_GOLANG
(Go) arguments and return value reg/stack depending on version
Definition typeinf.hpp:894
const callcnv_t CM_CC_FASTCALL
stack, purged (x86), first args are in regs (compiler-dependent)
Definition typeinf.hpp:887
const callcnv_t CM_CC_STDCALL
stack, purged
Definition typeinf.hpp:885
const callcnv_t CM_CC_SPECIAL
usercall: locations of all arguments and the return value are explicitly specified
Definition typeinf.hpp:898
const callcnv_t CM_CC_THISCALL
stack, purged (x86), first arg is in reg (compiler-dependent)
Definition typeinf.hpp:888
const callcnv_t CM_CC_VOIDARG
function without arguments if has other cc and argnum == 0, represent as f() - unknown list
Definition typeinf.hpp:880
const callcnv_t CM_CC_GOSTK
(Go) arguments and return value in stack
Definition typeinf.hpp:902
const callcnv_t CM_CC_SPOILED
This is NOT a cc!
Definition typeinf.hpp:890
const callcnv_t CM_CC_MASK
Definition typeinf.hpp:877
const callcnv_t CM_CC_LAST_USERCALL
Definition typeinf.hpp:900
const callcnv_t CM_CC_UNKNOWN
unknown calling convention
Definition typeinf.hpp:879
const callcnv_t CM_CC_FIRST_PLAIN_CUSTOM
Definition typeinf.hpp:904
const callcnv_t CM_CC_ELLIPSIS
cdecl + ellipsis
Definition typeinf.hpp:884
const callcnv_t CM_CC_SPECIALE
CM_CC_SPECIAL with ellipsis
Definition typeinf.hpp:896
const cm_t CM_M_MASK
Definition typeinf.hpp:863
THREAD_SAFE bool is_code_far(cm_t cm)
Does the given model specify far code?.
Definition typeinf.hpp:870
THREAD_SAFE bool is_data_far(cm_t cm)
Does the given model specify far data?.
Definition typeinf.hpp:872
const cm_t CM_M_NN
small: code=near, data=near (or unknown if CM_UNKNOWN)
Definition typeinf.hpp:864
const cm_t CM_M_FN
medium: code=far, data=near
Definition typeinf.hpp:867
const cm_t CM_M_FF
large: code=far, data=far
Definition typeinf.hpp:865
const cm_t CM_M_NF
compact: code=near, data=far
Definition typeinf.hpp:866
const cm_t CM_N32_F48
near 4 bytes, far 6 bytes
Definition typeinf.hpp:859
const cm_t CM_N16_F32
near 2 bytes, far 4 bytes
Definition typeinf.hpp:858
const cm_t CM_UNKNOWN
unknown
Definition typeinf.hpp:855
const cm_t CM_N8_F16
if sizeof(int)<=2: near 1 byte, far 2 bytes
Definition typeinf.hpp:856
const cm_t CM_MASK
Definition typeinf.hpp:854
const cm_t CM_N64
if sizeof(int)>2: near 8 bytes, far 8 bytes
Definition typeinf.hpp:857
const comp_t COMP_BP
Delphi.
Definition typeinf.hpp:1879
const comp_t COMP_WATCOM
Watcom C++.
Definition typeinf.hpp:1874
const comp_t COMP_MASK
Definition typeinf.hpp:1870
const comp_t COMP_UNK
Unknown.
Definition typeinf.hpp:1871
const comp_t COMP_BC
Borland C++.
Definition typeinf.hpp:1873
const comp_t COMP_GNU
GNU C++.
Definition typeinf.hpp:1877
const comp_t COMP_MS
Visual C++.
Definition typeinf.hpp:1872
const comp_t COMP_UNSURE
uncertain compiler id
Definition typeinf.hpp:1881
const comp_t COMP_VISAGE
Visual Age C++.
Definition typeinf.hpp:1878
etf_flag_t
Definition typeinf.hpp:2913
@ ETF_NO_LAYOUT
don't calc type layout before editing
Definition typeinf.hpp:2918
@ ETF_FUNCARG
udm - member is a function argument (cannot create arrays)
Definition typeinf.hpp:2921
@ ETF_AUTONAME
udm - generate a member name if was not specified (add_udm, set_udm_type)
Definition typeinf.hpp:2923
@ ETF_NO_ARRAY
add_udm, set_udm_type - do not convert type to an array on the size mismatch
Definition typeinf.hpp:2925
@ ETF_FORCENAME
anyway use name, see below for more usage description
Definition typeinf.hpp:2922
@ 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:2914
@ ETF_COMPATIBLE
new type must be compatible with the old
Definition typeinf.hpp:2920
@ ETF_MAY_DESTROY
may destroy other members
Definition typeinf.hpp:2919
@ ETF_BYTIL
udm - new type was created by the type subsystem
Definition typeinf.hpp:2924
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:2318
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:2429
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:2300
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:2352
@ TERR_NOT_COMPAT
the new type is not compatible with the old type
Definition typeinf.hpp:2346
@ TERR_NOT_IMPL
not implemented
Definition typeinf.hpp:2353
@ TERR_NOT_FOUND
member not found
Definition typeinf.hpp:2357
@ TERR_BAD_OFFSET
bad member offset s
Definition typeinf.hpp:2329
@ TERR_BAD_ARG
bad argument
Definition typeinf.hpp:2323
@ TERR_BAD_GROUPS
bad group sizes for bitmask enum
Definition typeinf.hpp:2348
@ TERR_STRUCT_SIZE
bad fixed structure size
Definition typeinf.hpp:2356
@ TERR_BAD_NAME
name s is not acceptable
Definition typeinf.hpp:2322
@ TERR_BAD_FX_SIZE
cannot extend struct beyond fixed size
Definition typeinf.hpp:2355
@ TERR_BAD_GAP
bad gap
Definition typeinf.hpp:2344
@ TERR_BAD_VARLAST
variable sized member must be the last member in the structure
Definition typeinf.hpp:2331
@ TERR_BAD_BF
bitfields are forbidden as function arguments
Definition typeinf.hpp:2328
@ TERR_BAD_BMASK
Bad enum member mask 0xI64X. The specified mask should not intersect with any existing mask in the en...
Definition typeinf.hpp:2336
@ TERR_BAD_BASE
bad base class
Definition typeinf.hpp:2343
@ TERR_STOCK
stock type info cannot be modified
Definition typeinf.hpp:2351
@ TERR_BAD_TAH
bad bits in the type attributes (TAH bits)
Definition typeinf.hpp:2342
@ TERR_BAD_REPR
bad or incompatible field representation
Definition typeinf.hpp:2338
@ TERR_UNION_BF
unions cannot have bitfields
Definition typeinf.hpp:2341
@ TERR_BAD_MSKVAL
bad bmask and value combination (value=0xI64X; bitmask 0xI64X)
Definition typeinf.hpp:2337
@ TERR_GRP_NOEMPTY
could not delete group mask for not empty group 0xI64X
Definition typeinf.hpp:2339
@ TERR_SERIALIZE
failed to serialize
Definition typeinf.hpp:2321
@ TERR_BAD_TYPE
bad type
Definition typeinf.hpp:2324
@ TERR_BAD_ARRAY
arrays are forbidden as function arguments
Definition typeinf.hpp:2327
@ TERR_TYPE_WORSE
the new type is worse than the old type
Definition typeinf.hpp:2354
@ TERR_NO_BMASK
bitmask 0xI64X is not found
Definition typeinf.hpp:2335
@ TERR_OVERLAP
the member overlaps with other members that cannot be deleted
Definition typeinf.hpp:2332
@ TERR_ALIEN_NAME
enum member name is used in another enum
Definition typeinf.hpp:2350
@ TERR_COUNT
Definition typeinf.hpp:2358
@ TERR_DUPNAME
duplicate name s
Definition typeinf.hpp:2340
@ TERR_BAD_SERIAL
enum value has too many serials
Definition typeinf.hpp:2349
@ TERR_BAD_UNIVAR
unions cannot have variable sized members
Definition typeinf.hpp:2330
@ TERR_BAD_LAYOUT
failed to calculate the structure/union layout
Definition typeinf.hpp:2347
@ TERR_BAD_SUBTYPE
recursive structure nesting is forbidden
Definition typeinf.hpp:2333
@ TERR_BAD_SIZE
bad size d
Definition typeinf.hpp:2325
@ TERR_OK
ok
Definition typeinf.hpp:2319
@ TERR_BAD_VALUE
value 0xI64X is not acceptable
Definition typeinf.hpp:2334
@ TERR_BAD_INDEX
bad index d
Definition typeinf.hpp:2326
@ TERR_NESTED
recursive structure nesting is forbidden
Definition typeinf.hpp:2345
@ TERR_SAVE_ERROR
failed to save
Definition typeinf.hpp:2320
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:2496
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 build_anon_type_name(qstring *buf, const type_t *type, const p_list *fields)
Generate a name like $hex_numbers based on the field types and names.
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:2513
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:2096
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:2122
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:2138
idaman THREAD_SAFE const char * format
Definition fpro.h:78
int code
Definition fpro.h:88
idaman size_t n
Definition pro.h:997
const type_sign_t type_unsigned
unsigned type
Definition typeinf.hpp:675
qvector< type_attr_t > type_attrs_t
this vector must be sorted by keys
Definition typeinf.hpp:669
int type_sign_t
type signedness
Definition typeinf.hpp:671
const type_sign_t no_sign
no sign, or unknown
Definition typeinf.hpp:673
const type_sign_t type_signed
signed type
Definition typeinf.hpp:674
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 8bytes - inf_is_64bit()
Definition typeinf.hpp:185
const type_t BTMT_BOOL2
size 2bytes - !inf_is_64bit()
Definition typeinf.hpp:184
const type_t BTMT_BOOL4
size 4bytes
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 1byte
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
singed 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.
tid_t get_tid() const
Definition typeinf.hpp:6263
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:6310
bool del_vftable_ea(uint32 ordinal)
Delete the address of a vftable instance for a vftable type.
Definition typeinf.hpp:2630
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:7308
const tinfo_t & type
Definition hexrays.hpp:7301
@ INF_H_PATH
C header path.
Definition ida.hpp:513
@ INF_C_MACROS
C predefined macros.
Definition ida.hpp:514
bool inf_big_arg_align(void)
Definition ida.hpp:966
uchar inf_get_cc_defalign()
Definition ida.hpp:1010
uint32 inf_get_abibits()
Definition ida.hpp:960
uchar inf_get_cc_size_e()
Definition ida.hpp:1007
qvector< callcnv_t > callcnvs_t
Definition ida.hpp:75
uchar cm_t
calling convention and memory model
Definition ida.hpp:73
callcnv_t inf_get_callcnv()
Definition ida.hpp:998
uint32 callcnv_t
Definition ida.hpp:74
bool inf_is_64bit(void)
Definition ida.hpp:631
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:72
bool inf_huge_arg_align(void)
Definition ida.hpp:980
bool inf_set_callcnv(callcnv_t _v)
Definition ida.hpp:999
bool inf_pack_stkargs(void)
Definition ida.hpp:964
comp_t inf_get_cc_id()
Definition ida.hpp:992
Contains definition of the interface to IDP modules.
qvector< reg_info_t > reginfovec_t
vector of register info objects
Definition idp.hpp:2718
int nbytes
Definition kernwin.hpp:2861
bool ok
Definition kernwin.hpp:7006
uval_t uval_t
Definition kernwin.hpp:1878
ssize_t rc
Definition kernwin.hpp:7101
idaman size_t len
Definition kernwin.hpp:1356
asize_t size
Definition kernwin.hpp:6339
uint64 tif_cursor_t
A location in a tinfo_t.
Definition kernwin.hpp:1882
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:7890
cast_t token_t * ct
Definition lex.hpp:172
unsigned __int64 uint64
Definition llong.hpp:13
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:1317
flags_t aflags_t
Definition nalt.hpp:289
uchar p_list
several p_string's
Definition nalt.hpp:1318
Functions that deal with names.
idaman size_t const char time_t t
Definition pro.h:602
unsigned short uint16
unsigned 16 bit value
Definition pro.h:346
int bool
Definition pro.h:329
unsigned int uint32
unsigned 32 bit value
Definition pro.h:348
qvector< int > intvec_t
vector of integers
Definition pro.h:2765
uint64 asize_t
Definition pro.h:423
constexpr T make_mask(int count)
Make a mask of 'count' bits.
Definition pro.h:1521
T align_up(T val, int elsize)
Align element up to nearest boundary.
Definition pro.h:4628
adiff_t sval_t
signed value used by the processor.
Definition pro.h:446
short int16
signed 16 bit value
Definition pro.h:345
int64 adiff_t
Definition pro.h:424
uint64 ea_t
Definition pro.h:421
int int32
signed 32 bit value
Definition pro.h:347
unsigned char uchar
unsigned 8 bit value
Definition pro.h:337
THREAD_SAFE void qswap(T &a, T &b)
Swap 2 objects of the same type using memory copies.
Definition pro.h:1715
idaman size_t bufsize
Definition pro.h:600
_qstring< uchar > qtype
type string
Definition pro.h:3695
unsigned int uint
unsigned 32 bit value
Definition pro.h:339
int error_t
Error code (errno)
Definition pro.h:458
qvector< ea_t > eavec_t
vector of addresses
Definition pro.h:2764
uint64 flags64_t
64-bit flags for each address
Definition pro.h:5009
ptrdiff_t ssize_t
Signed size_t - used to check for size overflows when the counter becomes negative.
Definition pro.h:381
unsigned short ushort
unsigned 16 bit value
Definition pro.h:338
T align_down(T val, int elsize)
Align element down to nearest boundary.
Definition pro.h:4638
void idaapi setflag(T &where, U bit, bool cnd)
Set a 'bit' in 'where' if 'value' if not zero.
Definition pro.h:1527
ea_t tid_t
type id (for enums, structs, etc)
Definition pro.h:5010
constexpr bool is_pow2(T val)
is power of 2? (or zero)
Definition pro.h:1432
_qstring< char > qstring
regular string
Definition pro.h:3694
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:4514
qvector< qstring > qstrvec_t
vector of strings
Definition pro.h:3697
Visit all argument locations.
Definition typeinf.hpp:1383
virtual ~aloc_visitor_t()
Definition typeinf.hpp:1385
virtual int idaapi visit_location(argloc_t &v, int off, int size)=0
Subsection of an argument location.
Definition typeinf.hpp:1313
bool operator<(const argpart_t &r) const
Compare two argparts, based on their offset.
Definition typeinf.hpp:1328
DEFINE_MEMORY_ALLOCATION_FUNCS() argpart_t(const argloc_t &a)
Constructor.
Definition typeinf.hpp:1316
argpart_t()
Constructor.
Definition typeinf.hpp:1318
ushort size
the number of bytes
Definition typeinf.hpp:1315
void swap(argpart_t &r)
Assign this = r and r = this.
Definition typeinf.hpp:1331
ushort off
offset from the beginning of the argument
Definition typeinf.hpp:1314
bool bad_size() const
Does this argpart have a valid size?
Definition typeinf.hpp:1325
bool bad_offset() const
Does this argpart have a valid offset?
Definition typeinf.hpp:1322
argpart_t & copy_from(const argloc_t &a)
Definition typeinf.hpp:1319
Definition typeinf.hpp:6106
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:6126
size_t reserved
Definition typeinf.hpp:6107
virtual ~argtinfo_helper_t()
Definition typeinf.hpp:6109
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:6140
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:682
int32 flags
Definition nalt.hpp:683
Array type information (see tinfo_t::get_array_details())
Definition typeinf.hpp:4670
DEFINE_MEMORY_ALLOCATION_FUNCS() void swap(array_type_data_t &r)
set this = r and r = this
Definition typeinf.hpp:4675
uint32 nelems
number of elements
Definition typeinf.hpp:4673
tinfo_t elem_type
element type
Definition typeinf.hpp:4671
array_type_data_t(size_t b=0, size_t n=0)
Constructor.
Definition typeinf.hpp:4674
uint32 base
array base
Definition typeinf.hpp:4672
Bitfield type information (see tinfo_t::get_bitfield_details())
Definition typeinf.hpp:5581
void swap(bitfield_type_data_t &r)
Definition typeinf.hpp:5608
uchar nbytes
enclosing type size (1,2,4,8 bytes)
Definition typeinf.hpp:5582
uchar width
number of bits
Definition typeinf.hpp:5583
bool is_unsigned
is bitfield unsigned?
Definition typeinf.hpp:5584
DECLARE_COMPARISONS(bitfield_type_data_t)
Definition typeinf.hpp:5590
bool serialize(qtype *type, type_t mods) const
bool is_valid_bitfield() const
Definition typeinf.hpp:5609
bitfield_type_data_t(uchar _nbytes=0, uchar _width=0, bool _is_unsigned=false)
Definition typeinf.hpp:5585
Information about the target compiler.
Definition ida.hpp:79
comp_t id
compiler id (see Compiler IDs)
Definition ida.hpp:80
cm_t cm
memory model and calling convention (see CM) see also get_cc/set_cc
Definition ida.hpp:81
callcnv_t _new_callcnv
Definition ida.hpp:91
Same as aloc_visitor_t, but may not modify the argloc.
Definition typeinf.hpp:1393
virtual ~const_aloc_visitor_t()
Definition typeinf.hpp:1395
virtual int idaapi visit_location(const argloc_t &v, int off, int size)=0
Description of a custom argloc.
Definition typeinf.hpp:975
tinfo_t * elem_tif
Definition typeinf.hpp:1057
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:977
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:1020
size_t const argloc_t & loc
Definition typeinf.hpp:999
tinfo_t const argloc_t const tinfo_t size_t len
Definition typeinf.hpp:1060
const idc_value_t const value_union_t int qstring * errbuf
Definition typeinf.hpp:1046
tinfo_t const argloc_t const tinfo_t & array_tif
Definition typeinf.hpp:1019
int const rangeset_t * gaps
Definition typeinf.hpp:989
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:1008
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:1043
const argloc_t & src
Definition typeinf.hpp:980
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:1082
tinfo_t const argloc_t & ptrloc
Definition typeinf.hpp:1028
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:1007
bool(idaapi *verify)(const argloc_t &loc
May be nullptr.
tinfo_t const argloc_t const tinfo_t asize_t off
Definition typeinf.hpp:1010
const tinfo_t & string_tif
Definition typeinf.hpp:1051
int size
Definition typeinf.hpp:988
size_t bufsize
Definition typeinf.hpp:998
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:976
size_t const argloc_t asize_t int praloc_flags
Definition typeinf.hpp:1001
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:990
tinfo_t const argloc_t & arrloc
Definition typeinf.hpp:1018
tinfo_t const argloc_t const tinfo_t & struct_tif
Definition typeinf.hpp:1009
const idc_value_t const value_union_t & scalar_value
Definition typeinf.hpp:1044
const argloc_t & b
Definition typeinf.hpp:993
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:1021
bool(idaapi *deref_ptr)(argloc_t *out
Dereference the pointer at 'loc': retrieve location of the pointed object, improve 'tif' of the point...
int(idaapi *compare)(const argloc_t &a
Lexical comparison of two arglocs.
Description of a custom calling convention.
Definition typeinf.hpp:1543
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:1592
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:1550
int cbsize
Definition typeinf.hpp:1544
bool is_purging() const
Definition typeinf.hpp:1553
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:1672
uint64 flags
Definition typeinf.hpp:1545
bool is_vararg() const
Definition typeinf.hpp:1552
virtual bool get_cc_regs(callregs_t *out) const
Retrieve generic information about call registers.
Definition typeinf.hpp:1625
virtual int lower_func_type(func_type_data_t *fti) const
Lower a function type.
Definition typeinf.hpp:1665
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:1641
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:1611
qstring name
the name is used as a keyword in the function prototype
Definition typeinf.hpp:1549
custom_callcnv_t()=default
virtual bool validate_func(const func_type_data_t &fti, qstring *reterr) const
Validate a function prototype.
Definition typeinf.hpp:1562
virtual bool get_stkarg_area_info(stkarg_area_info_t *out) const
Retrieve generic information about stack arguments.
Definition typeinf.hpp:1632
virtual ~custom_callcnv_t()
Definition typeinf.hpp:1675
bool is_usercall() const
Definition typeinf.hpp:1554
Definition typeinf.hpp:5195
int16 fid
data format ids
Definition typeinf.hpp:5197
int16 dtid
data type id
Definition typeinf.hpp:5196
This structure describes an enum value.
Definition typeinf.hpp:4849
qstring name
Definition typeinf.hpp:4850
edm_t(const char *_name, uint64 _value, const char *_cmt=nullptr)
Create an enumeration value with the specified name and value.
Definition typeinf.hpp:4861
bool empty() const
Definition typeinf.hpp:4865
uint64 value
Definition typeinf.hpp:4852
void swap(edm_t &r)
Definition typeinf.hpp:4874
qstring cmt
Definition typeinf.hpp:4851
edm_t()=default
bool operator==(const edm_t &r) const
Definition typeinf.hpp:4867
bool operator!=(const edm_t &r) const
Definition typeinf.hpp:4873
Enum type information (see tinfo_t::get_enum_details())
Definition typeinf.hpp:4889
enum_type_data_t(bte_t _bte=BTE_ALWAYS|BTE_HEX)
Definition typeinf.hpp:4895
bool is_bin() const
Definition typeinf.hpp:4944
bool is_soct() const
Definition typeinf.hpp:4947
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:5135
bool has_lzero() const
Definition typeinf.hpp:4950
bool is_sbin() const
Definition typeinf.hpp:4948
bool is_bf() const
is bitmask or ordinary enum?
Definition typeinf.hpp:4957
bte_t bte
enum member sizes (shift amount) and style.
Definition typeinf.hpp:4893
bool is_udec() const
Definition typeinf.hpp:4945
void add_constant(const char *name, uint64 value, const char *cmt=nullptr)
add constant for regular enum
Definition typeinf.hpp:5067
uchar get_serial(size_t index) const
returns serial for the constant
Definition typeinf.hpp:5084
bool is_char() const
Definition typeinf.hpp:4940
bool is_oct() const
Definition typeinf.hpp:4943
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:4982
void set_lzero(bool on)
Definition typeinf.hpp:4951
bool set_nbytes(int nbytes)
set enum width (nbytes)
Definition typeinf.hpp:4966
intvec_t group_sizes
if present, specifies bitmask group sizes each non-trivial group starts with a mask member
Definition typeinf.hpp:4890
bool is_group_mask_at(size_t idx) const
is the enum member at IDX a non-trivial group mask?
Definition typeinf.hpp:5008
DEFINE_MEMORY_ALLOCATION_FUNCS() int get_enum_radix() const
Get enum constant radix.
Definition typeinf.hpp:4896
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:5102
bool is_shex() const
Definition typeinf.hpp:4946
tinfo_code_t set_value_repr(const value_repr_t &repr)
set enum radix and other representation info
Definition typeinf.hpp:5081
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:5047
bool is_valid_group_sizes() const
is valid group sizes
Definition typeinf.hpp:5017
bool is_dec() const
Definition typeinf.hpp:4941
bool store_64bit_values() const
Definition typeinf.hpp:4954
void set_enum_radix(int radix, bool sign)
Set radix to display constants.
Definition typeinf.hpp:4927
bool is_number_signed() const
Definition typeinf.hpp:4919
int calc_nbytes() const
get the width of enum in bytes
Definition typeinf.hpp:4960
uint32 taenum_bits
Type attributes for enums
Definition typeinf.hpp:4892
bool is_hex() const
Definition typeinf.hpp:4942
tinfo_code_t get_value_repr(value_repr_t *repr) const
get enum radix and other representation info
Definition typeinf.hpp:5077
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:5034
uint64 calc_mask() const
Definition typeinf.hpp:4953
void swap(enum_type_data_t &r)
swap two instances
Definition typeinf.hpp:5064
uchar get_max_serial(uint64 value) const
return the maximum serial for the value
Definition typeinf.hpp:5098
See format_cdata()
Definition typeinf.hpp:6341
format_data_info_t()
Definition typeinf.hpp:6379
int arrnelems
for arrays: number of elements to print
Definition typeinf.hpp:6372
int ptvf
Definition typeinf.hpp:6342
int indent
how many spaces to use to indent nested structures/arrays
Definition typeinf.hpp:6377
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:6366
int arrbase
for arrays: the first element of array to print
Definition typeinf.hpp:6371
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:6373
int radix
number representation (8,10,16)
Definition typeinf.hpp:6365
Function type information (see tinfo_t::get_func_details())
Definition typeinf.hpp:4753
bool is_noret() const
Definition typeinf.hpp:4790
bool is_pure() const
Definition typeinf.hpp:4791
bool is_vararg_cc() const
Definition typeinf.hpp:4798
callcnv_t _new_callcnv
Definition typeinf.hpp:4777
bool is_ctor() const
Definition typeinf.hpp:4795
uval_t stkargs
size of stack arguments (not used in build_func_type)
Definition typeinf.hpp:4780
void set_cc(callcnv_t cc)
Definition typeinf.hpp:4787
bool is_high() const
Definition typeinf.hpp:4789
callcnv_t get_cc() const
Definition typeinf.hpp:4786
bool is_user_cc() const
Definition typeinf.hpp:4801
int flags
Function type data property bits
Definition typeinf.hpp:4754
bool is_static() const
Definition typeinf.hpp:4792
bool is_virtual() const
Definition typeinf.hpp:4793
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:4805
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:4822
int get_call_method() const
Definition typeinf.hpp:4797
bool is_swift_cc() const
Definition typeinf.hpp:4800
reginfovec_t spoiled
spoiled register information.
Definition typeinf.hpp:4781
argloc_t retloc
return location
Definition typeinf.hpp:4779
bool is_const() const
Definition typeinf.hpp:4794
bool is_dtor() const
Definition typeinf.hpp:4796
cm_t _old_cc
Definition typeinf.hpp:4784
void swap(func_type_data_t &r)
Definition typeinf.hpp:4788
bool dump(qstring *out, int praloc_bits=PRALOC_STKOFF) const
Dump information that is not always visible in the function prototype.
Definition typeinf.hpp:4816
bool is_golang_cc() const
Definition typeinf.hpp:4799
tinfo_t rettype
return type
Definition typeinf.hpp:4778
callcnv_t get_explicit_cc() const
Definition typeinf.hpp:4785
Information about a single function argument.
Definition typeinf.hpp:4683
tinfo_t type
argument type
Definition typeinf.hpp:4687
argloc_t argloc
argument location
Definition typeinf.hpp:4684
qstring cmt
argument comment (may be empty)
Definition typeinf.hpp:4686
bool operator!=(const funcarg_t &r) const
Definition typeinf.hpp:4745
qstring name
argument name (may be empty)
Definition typeinf.hpp:4685
funcarg_t()=default
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:4732
uint32 flags
Function argument property bits
Definition typeinf.hpp:4688
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:4708
bool operator==(const funcarg_t &r) const
Definition typeinf.hpp:4738
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:4719
Helper class for choose_named_type().
Definition typeinf.hpp:6574
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:6580
@ ev_decorate_name
Decorate/undecorate a C symbol name.
Definition idp.hpp:1732
@ ev_equal_reglocs
Are 2 register arglocs the same?
Definition idp.hpp:1689
static ssize_t equal_reglocs(const argloc_t &a1, const argloc_t &a2)
Definition typeinf.hpp:6673
static ssize_t notify(event_t event_code,...)
Definition idp.hpp:1766
static ssize_t get_cc_regs(callregs_t *regs, callcnv_t cc)
Definition idp.hpp:2611
static ssize_t _decorate_name(qstring *outbuf, const char *name, bool mangle, callcnv_t cc, const tinfo_t &type)
Definition typeinf.hpp:6682
Pointer type information (see tinfo_t::get_ptr_details())
Definition typeinf.hpp:4640
bool operator!=(const ptr_type_data_t &r) const
Definition typeinf.hpp:4661
uchar based_ptr_size
Definition typeinf.hpp:4645
int32 delta
Offset from the beginning of the parent struct.
Definition typeinf.hpp:4644
bool operator==(const ptr_type_data_t &r) const
Definition typeinf.hpp:4655
bool is_shifted() const
Definition typeinf.hpp:4663
uchar taptr_bits
TAH bits.
Definition typeinf.hpp:4646
tinfo_t obj_type
pointed object type
Definition typeinf.hpp:4641
DEFINE_MEMORY_ALLOCATION_FUNCS() void swap(ptr_type_data_t &r)
Set this = r and r = this.
Definition typeinf.hpp:4653
tinfo_t closure
cannot have both closure and based_ptr_size
Definition typeinf.hpp:4642
ptr_type_data_t(tinfo_t c=tinfo_t(), uchar bps=0, tinfo_t p=tinfo_t(), int32 d=0)
Definition typeinf.hpp:4647
tinfo_t parent
Parent struct.
Definition typeinf.hpp:4643
bool is_code_ptr() const
Are we pointing to code?
Definition typeinf.hpp:4662
Definition range.hpp:323
Information about a reference.
Definition nalt.hpp:1010
Object that represents a register.
Definition typeinf.hpp:6035
bytevec_t value
Definition typeinf.hpp:6038
size_t size() const
Definition typeinf.hpp:6039
int regidx
index into dbg->registers
Definition typeinf.hpp:6036
int relocate
0-plain num, 1-must relocate
Definition typeinf.hpp:6037
Definition typeinf.hpp:6044
Relocatable object.
Definition pro.h:4026
Register-relative argument location.
Definition typeinf.hpp:965
sval_t off
displacement from the address pointed by the register
Definition typeinf.hpp:966
int reg
register index (into ph.reg_names)
Definition typeinf.hpp:967
SIMD type info.
Definition typeinf.hpp:4584
uint16 size
SIMD type size in bytes (0-undefined)
Definition typeinf.hpp:4587
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:4588
const char * name
name of SIMD type (nullptr-undefined)
Definition typeinf.hpp:4585
tinfo_t tif
SIMD type (empty-undefined)
Definition typeinf.hpp:4586
bool match_pattern(const simd_info_t *pattern)
Definition typeinf.hpp:4599
simd_info_t(const char *nm=nullptr, uint16 sz=0, type_t memt=BTF_UNK)
Definition typeinf.hpp:4596
Definition typeinf.hpp:1518
size_t cb
Definition typeinf.hpp:1519
bool get_info(callcnv_t cc)
Definition typeinf.hpp:1537
sval_t shadow_size
Size of the shadow area.
Definition typeinf.hpp:1528
sval_t linkage_area
Size of the linkage area.
Definition typeinf.hpp:1533
sval_t stkarg_offset
Offset from the SP to the first stack argument (can include linkage area) examples: pc: 0,...
Definition typeinf.hpp:1523
stkarg_area_info_t()=default
stkarg_area_info_t(callcnv_t cc)
Definition typeinf.hpp:1536
Flush formatted text.
Definition typeinf.hpp:6475
virtual int idaapi print(const char *str)=0
virtual ~text_sink_t()
Definition typeinf.hpp:6476
A symbol in a type library.
Definition typeinf.hpp:6562
const til_t * til
pointer to til
Definition typeinf.hpp:6564
til_symbol_t(const char *n=nullptr, const til_t *t=nullptr)
Definition typeinf.hpp:6565
const char * name
symbol name
Definition typeinf.hpp:6563
Type Information Library.
Definition typeinf.hpp:725
uint32 flags
Type info library property bits
Definition typeinf.hpp:730
char * desc
human readable til description
Definition typeinf.hpp:727
compiler_info_t cc
information about the target compiler
Definition typeinf.hpp:764
til_stream_t ** streams
symbol stream storage
Definition typeinf.hpp:770
void set_dirty()
Mark the til as modified (TIL_MOD)
Definition typeinf.hpp:748
til_t * find_base(const char *n)
Find the base til with the provided name.
Definition typeinf.hpp:753
til_bucket_t * types
types
Definition typeinf.hpp:766
bool is_dirty() const
Has the til been modified? (TIL_MOD)
Definition typeinf.hpp:746
til_t ** base
tils that our til is based on
Definition typeinf.hpp:729
til_bucket_t * macros
macros
Definition typeinf.hpp:767
int nstreams
number of extra streams
Definition typeinf.hpp:769
char * name
short file name (without path and extension)
Definition typeinf.hpp:726
int nbases
number of base tils
Definition typeinf.hpp:728
til_bucket_t * syms
symbols
Definition typeinf.hpp:765
int nrefs
number of references to the til
Definition typeinf.hpp:768
Definition typeinf.hpp:6710
bool is_writable
Definition typeinf.hpp:6715
tif_cursor_t cursor
Definition typeinf.hpp:6713
bool is_detached
Definition typeinf.hpp:6716
udm_t udm
BTF_STRUCT or BTF_UNION: the current member.
Definition typeinf.hpp:6723
uint32 ordinal
Definition typeinf.hpp:6714
bool is_func() const
Definition typeinf.hpp:6745
size_t unpadded_size
Definition typeinf.hpp:6725
const funcarg_t * fa
BT_FUNC: the current argument, nullptr - ellipsis.
Definition typeinf.hpp:6737
bool is_enum() const
Definition typeinf.hpp:6744
type_t kind
Definition typeinf.hpp:6718
size_t total_size
Definition typeinf.hpp:6724
uint64 last_udm_offset
Definition typeinf.hpp:6726
bool is_forward
Definition typeinf.hpp:6717
bool is_union() const
Definition typeinf.hpp:6743
uint64 bucket_start
Definition typeinf.hpp:6727
uint64 offset
Definition typeinf.hpp:6729
void clear()
Definition typeinf.hpp:6739
int bf_bitoff
Definition typeinf.hpp:6728
tinfo_t tif
Definition typeinf.hpp:6712
bool on_member() const
Definition typeinf.hpp:6740
bool is_udt() const
Definition typeinf.hpp:6746
size_t cb
Definition typeinf.hpp:6711
bool is_struct() const
Definition typeinf.hpp:6742
size_t nmembers
Definition typeinf.hpp:6720
ssize_t memidx
Definition typeinf.hpp:6719
edm_t edm
BTF_ENUM: the current enum member.
Definition typeinf.hpp:6734
bool is_typedef() const
Definition typeinf.hpp:6741
virtual ~tinfo_visitor_t()
Definition typeinf.hpp:6005
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:6003
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:6023
int state
tinfo visitor states
Definition typeinf.hpp:5994
int level
Definition typeinf.hpp:6002
void prune_now()
To refuse to visit children of the current type, use this:
Definition typeinf.hpp:6020
Definition typeinf.hpp:651
qstring key
one symbol keys are reserved to be used by the kernel the ones starting with an underscore are reserv...
Definition typeinf.hpp:652
bytevec_t value
attribute bytes
Definition typeinf.hpp:662
bool operator>=(const type_attr_t &r) const
Definition typeinf.hpp:664
bool operator<(const type_attr_t &r) const
Definition typeinf.hpp:663
Information about how to modify the current type, used by tinfo_visitor_t.
Definition typeinf.hpp:5957
bool has_name() const
Definition typeinf.hpp:5985
bool is_rptcmt() const
Definition typeinf.hpp:5987
bool has_type() const
Definition typeinf.hpp:5984
bool has_info() const
Definition typeinf.hpp:5988
qstring name
current type name
Definition typeinf.hpp:5959
tinfo_t type
current type
Definition typeinf.hpp:5958
int flags
Type modification bits
Definition typeinf.hpp:5961
bool has_cmt() const
Definition typeinf.hpp:5986
void set_new_cmt(const qstring &c, bool rptcmt)
Definition typeinf.hpp:5977
qstring cmt
comment for current type
Definition typeinf.hpp:5960
void clear()
Definition typeinf.hpp:5970
void set_new_name(const qstring &n)
Definition typeinf.hpp:5976
void set_new_type(const tinfo_t &t)
The visit_type() function may optionally save the modified type info.
Definition typeinf.hpp:5975
Type information for typedefs.
Definition typeinf.hpp:5165
bool resolve
should resolve immediately?
Definition typeinf.hpp:5173
DEFINE_MEMORY_ALLOCATION_FUNCS() void swap(typedef_type_data_t &r)
Definition typeinf.hpp:5187
uint32 ordinal
is_ordref=true: type ordinal number
Definition typeinf.hpp:5170
typedef_type_data_t(const til_t *_til, const char *_name, bool _resolve=false)
Definition typeinf.hpp:5174
const char * name
is_ordref=false: target type name. we do not own this pointer!
Definition typeinf.hpp:5169
typedef_type_data_t(const til_t *_til, uint32 ord, bool _resolve=false)
Definition typeinf.hpp:5180
bool is_ordref
is reference by ordinal?
Definition typeinf.hpp:5172
const til_t * til
type library to use when resolving
Definition typeinf.hpp:5166
An object to represent struct or union members.
Definition typeinf.hpp:5300
void set_unaligned(bool on=true)
Definition typeinf.hpp:5381
bool is_zero_bitfield() const
Definition typeinf.hpp:5368
bool is_method() const
Definition typeinf.hpp:5373
void clr_virtbase()
Definition typeinf.hpp:5392
bool is_gap() const
Definition typeinf.hpp:5374
qstring cmt
member comment
Definition typeinf.hpp:5304
bool operator==(const udm_t &r) const
Definition typeinf.hpp:5401
bool is_retaddr() const
Definition typeinf.hpp:5376
bool is_unaligned() const
Definition typeinf.hpp:5369
void clr_unaligned()
Definition typeinf.hpp:5390
void set_savregs(bool on=true)
Definition typeinf.hpp:5388
void clr_vftable()
Definition typeinf.hpp:5393
bool compare_with(const udm_t &r, int tcflags) const
Definition typeinf.hpp:5405
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:5338
uint32 tafld_bits
TAH bits.
Definition typeinf.hpp:5308
bool operator!=(const udm_t &r) const
Definition typeinf.hpp:5416
void clr_baseclass()
Definition typeinf.hpp:5391
uint64 end() const
Definition typeinf.hpp:5396
bool can_rename() const
Definition typeinf.hpp:5431
bool is_savregs() const
Definition typeinf.hpp:5377
bool operator<(const udm_t &r) const
Definition typeinf.hpp:5397
uint64 begin() const
Definition typeinf.hpp:5395
void set_vftable(bool on=true)
Definition typeinf.hpp:5384
bool is_vftable() const
Definition typeinf.hpp:5372
void set_retaddr(bool on=true)
Definition typeinf.hpp:5387
bool is_baseclass() const
Definition typeinf.hpp:5370
int effalign
effective field alignment (in bytes)
Definition typeinf.hpp:5307
uint64 offset
member offset in bits
Definition typeinf.hpp:5301
void set_baseclass(bool on=true)
Definition typeinf.hpp:5382
bool can_be_dtor() const
Definition typeinf.hpp:5430
udm_t()=default
bool is_by_til() const
Definition typeinf.hpp:5379
uint64 size
size in bits
Definition typeinf.hpp:5302
bool is_special_member() const
Definition typeinf.hpp:5378
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:5322
bool is_anonymous_udm() const
Definition typeinf.hpp:5424
uchar fda
field alignment (shift amount)
Definition typeinf.hpp:5309
void set_method(bool on=true)
Definition typeinf.hpp:5385
void clr_method()
Definition typeinf.hpp:5394
DEFINE_MEMORY_ALLOCATION_FUNCS() void swap(udm_t &r)
Definition typeinf.hpp:5418
value_repr_t repr
radix, refinfo, strpath, custom_id, strtype
Definition typeinf.hpp:5306
bool is_regcmt() const
Definition typeinf.hpp:5375
qstring name
member name
Definition typeinf.hpp:5303
void set_virtbase(bool on=true)
Definition typeinf.hpp:5383
tinfo_t type
member type
Definition typeinf.hpp:5305
void set_value_repr(const value_repr_t &r)
Definition typeinf.hpp:5429
void set_by_til(bool on=true)
Definition typeinf.hpp:5389
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:5357
void set_regcmt(bool on=true)
Definition typeinf.hpp:5386
bool empty() const
Definition typeinf.hpp:5365
bool is_bitfield() const
Definition typeinf.hpp:5367
bool is_virtbase() const
Definition typeinf.hpp:5371
Definition typeinf.hpp:5549
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:5559
Definition typeinf.hpp:5441
ssize_t find_member(const char *name) const
Definition typeinf.hpp:5494
bool is_vftable() const
Definition typeinf.hpp:5457
void swap(udt_type_data_t &r)
Definition typeinf.hpp:5452
uchar pack
pragma pack() alignment (shift amount)
Definition typeinf.hpp:5449
bool is_tuple() const
Definition typeinf.hpp:5459
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:5510
uchar sda
declared structure alignment (shift amount+1). 0 - unspecified
Definition typeinf.hpp:5448
ssize_t find_member(udm_t *pattern_udm, int strmem_flags) const
tinfo_t::find_udm
Definition typeinf.hpp:5492
static constexpr int VERSION
Definition typeinf.hpp:5442
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:5479
uint32 taudt_bits
TA... and TAUDT... bits.
Definition typeinf.hpp:5446
bool is_union
is union or struct?
Definition typeinf.hpp:5450
bool is_last_baseclass(size_t idx)
Definition typeinf.hpp:5465
bool is_cppobj() const
Definition typeinf.hpp:5456
bool is_fixed() const
Definition typeinf.hpp:5458
uint32 effalign
effective structure alignment (in bytes)
Definition typeinf.hpp:5445
void set_fixed(bool on=true)
Definition typeinf.hpp:5462
void set_tuple(bool on=true)
Definition typeinf.hpp:5463
bool is_msstruct() const
Definition typeinf.hpp:5455
DEFINE_MEMORY_ALLOCATION_FUNCS() bool is_unaligned() const
Definition typeinf.hpp:5453
void set_vftable(bool on=true)
Definition typeinf.hpp:5461
uchar version
version of udt_type_data_t
Definition typeinf.hpp:5447
size_t unpadded_size
unpadded structure size in bytes
Definition typeinf.hpp:5444
size_t total_size
total structure size in bytes
Definition typeinf.hpp:5443
ssize_t find_member(uint64 bit_offset) const
Definition typeinf.hpp:5501
vector of udt member objects
Definition typeinf.hpp:5438
Additional information about the output lines.
Definition typeinf.hpp:6387
void swap(valinfo_t &r)
Definition typeinf.hpp:6393
qstring label
Definition typeinf.hpp:6389
argloc_t loc
Definition typeinf.hpp:6388
tinfo_t type
Definition typeinf.hpp:6390
valinfo_t(argloc_t l=argloc_t(), const char *name=nullptr, const tinfo_t &tif=tinfo_t())
Definition typeinf.hpp:6391
Collection of value strings.
Definition typeinf.hpp:6448
Visual representation of a member of a complex type (struct/union/enum)
Definition typeinf.hpp:5202
bool is_offset() const
Definition typeinf.hpp:5247
void set_lzeroes(bool on)
Definition typeinf.hpp:5260
bool is_custom() const
Definition typeinf.hpp:5249
uint64 bits
Definition typeinf.hpp:5203
refinfo_t ri
FRB_OFFSET.
Definition typeinf.hpp:5227
bool is_enum() const
Definition typeinf.hpp:5246
uint32 type_ordinal
FRB_STROFF, FRB_ENUM.
Definition typeinf.hpp:5232
bool empty() const
Definition typeinf.hpp:5245
DEFINE_MEMORY_ALLOCATION_FUNCS() void clear()
Definition typeinf.hpp:5241
array_parameters_t ap
FRB_TABFORM, AP_SIGNED is ignored, use FRB_SIGNED instead.
Definition typeinf.hpp:5236
void swap(value_repr_t &r)
Definition typeinf.hpp:5240
bool is_typref() const
Definition typeinf.hpp:5251
uint64 get_vtype() const
Definition typeinf.hpp:5256
bool parse_value_repr(const qstring &attr, type_t target_type=BTF_STRUCT)
Definition typeinf.hpp:5287
DECLARE_COMPARISONS(value_repr_t)
adiff_t delta
FRB_STROFF.
Definition typeinf.hpp:5231
bool has_tabform() const
Definition typeinf.hpp:5253
bool from_opinfo(flags64_t flags, aflags_t afl, const opinfo_t *opinfo, const array_parameters_t *_ap)
Definition typeinf.hpp:5279
void init_ap(array_parameters_t *_ap) const
Definition typeinf.hpp:5269
void set_vtype(uint64 vt)
Definition typeinf.hpp:5257
int32 strtype
FRB_STRLIT.
Definition typeinf.hpp:5228
custom_data_type_info_t cd
FRB_CUSTOM.
Definition typeinf.hpp:5234
size_t print(qstring *result, bool colored=false) const
Definition typeinf.hpp:5283
bool is_signed() const
Definition typeinf.hpp:5252
bool has_lzeroes() const
Definition typeinf.hpp:5254
bool is_stroff() const
Definition typeinf.hpp:5250
bool is_strlit() const
Definition typeinf.hpp:5248
void set_tabform(bool on)
Definition typeinf.hpp:5259
void set_ap(const array_parameters_t &_ap)
Definition typeinf.hpp:5262
void set_signed(bool on)
Definition typeinf.hpp:5258
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 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:2950
@ GTS_NESTED
nested type (embedded into a udt)
Definition typeinf.hpp:2951
@ GTS_BASECLASS
is baseclass of a udt
Definition typeinf.hpp:2952
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.
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:3041
ssize_t get_c_header_path(qstring *buf)
Get the include directory path of the target compiler.
Definition typeinf.hpp:2822
void set_c_header_path(const char *incdir)
Set include directory path the target compiler.
Definition typeinf.hpp:2819
bool is_restype_void(const til_t *til, const type_t *type)
Definition typeinf.hpp:689
THREAD_SAFE bool is_type_ptr_or_array(type_t t)
Is the type a pointer or array type?
Definition typeinf.hpp:510
idaman type_t ida_export get_scalar_bt(int size)
qvector< regobj_t > regobjvec_t
Definition typeinf.hpp:6042
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:605
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:2874
@ STI_PINT
int *
Definition typeinf.hpp:2880
@ STI_PCVOID
const void *
Definition typeinf.hpp:2884
@ STI_AEABI_LCMP
int __fastcall __pure(int64 x, int64 y)
Definition typeinf.hpp:2892
@ STI_RTC_CHECK_8
int64 __fastcall(int64 x)
Definition typeinf.hpp:2902
@ STI_SSIZE_T
ssize_t
Definition typeinf.hpp:2896
@ STI_PUNKNOWN
_UNKNOWN *
Definition typeinf.hpp:2905
@ STI_AUCHAR
uint8[]
Definition typeinf.hpp:2886
@ STI_AEABI_MEMSET
void __fastcall(void *, size_t, int)
Definition typeinf.hpp:2898
@ STI_ACHAR
char[]
Definition typeinf.hpp:2885
@ STI_DONT_USE
unused stock type id; should not be used
Definition typeinf.hpp:2894
@ STI_COMPLEX128
struct complex128_t { double real, imag; }
Definition typeinf.hpp:2904
@ STI_PCCHAR
const char *
Definition typeinf.hpp:2877
@ STI_PUINT
unsigned int *
Definition typeinf.hpp:2881
@ STI_ACCHAR
const char[]
Definition typeinf.hpp:2887
@ STI_PCUCHAR
const uint8 *
Definition typeinf.hpp:2878
@ STI_COMPLEX64
struct complex64_t { float real, imag; }
Definition typeinf.hpp:2903
@ STI_RTC_CHECK_2
int16 __fastcall(int16 x)
Definition typeinf.hpp:2900
@ STI_RTC_CHECK_4
int32 __fastcall(int32 x)
Definition typeinf.hpp:2901
@ STI_AEABI_MEMCPY
void __fastcall(void *, const void *, size_t)
Definition typeinf.hpp:2897
@ STI_MSGSEND
void *(void *, const char *, ...)
Definition typeinf.hpp:2891
@ STI_LAST
Definition typeinf.hpp:2906
@ STI_FDELOP
void __cdecl(void *)
Definition typeinf.hpp:2890
@ STI_PVOID
void *
Definition typeinf.hpp:2882
@ STI_PPVOID
void **
Definition typeinf.hpp:2883
@ STI_AEABI_ULCMP
int __fastcall __pure(uint64 x, uint64 y)
Definition typeinf.hpp:2893
@ STI_AEABI_MEMCLR
void __fastcall(void *, size_t)
Definition typeinf.hpp:2899
@ STI_FPURGING
void __userpurge(int)
Definition typeinf.hpp:2889
@ STI_PCHAR
char *
Definition typeinf.hpp:2875
@ STI_PUCHAR
uint8 *
Definition typeinf.hpp:2876
@ STI_ACUCHAR
const uint8[]
Definition typeinf.hpp:2888
@ STI_PBYTE
_BYTE *
Definition typeinf.hpp:2879
@ STI_SIZE_T
size_t
Definition typeinf.hpp:2895
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
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:5539
qvector< tinfo_t > tinfovec_t
vector of tinfo objects
Definition typeinf.hpp:4579
tinfo_t remove_pointer(const tinfo_t &tif)
BT_PTR: If the current type is a pointer, return the pointed object.
Definition typeinf.hpp:5948
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:5160
idaman uint32 ida_export choose_local_tinfo_and_delta(int32 *delta, const til_t *ti, const char *title, local_tinfo_predicate_t *func=nullptr, uint32 def_ord=0, void *ud=nullptr)
Choose a type from the local type library and specify the pointer shift value.
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:4839
@ FMTFUNC_SCANF
Definition typeinf.hpp:4841
@ FMTFUNC_STRFTIME
Definition typeinf.hpp:4842
@ FMTFUNC_STRFMON
Definition typeinf.hpp:4843
@ FMTFUNC_PRINTF
Definition typeinf.hpp:4840
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:3040
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:701
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:2931
@ GTD_CALC_LAYOUT
calculate udt layout
Definition typeinf.hpp:2932
@ GTD_NO_LAYOUT
don't calculate udt layout please note that udt layout may have been calculated earlier
Definition typeinf.hpp:2933
@ GTD_DEL_BITFLDS
delete udt bitfields
Definition typeinf.hpp:2936
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:4749
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).
qvector< uint32 > ordvec_t
Definition typeinf.hpp:6505
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:2650
ssize_t get_c_macros(qstring *buf)
Get predefined macros for the target compiler.
Definition typeinf.hpp:2828
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:2975
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:2027
@ ABS_YES
Definition typeinf.hpp:2030
@ ABS_NO
Definition typeinf.hpp:2029
@ ABS_UNK
Definition typeinf.hpp:2028
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:6238
@ UTP_STRUCT
Definition typeinf.hpp:6240
@ UTP_ENUM
Definition typeinf.hpp:6239
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.
THREAD_SAFE bool is_one_bit_mask(uval_t mask)
Is bitmask one bit?
Definition typeinf.hpp:5637
const size_t BADSIZE
bad type size
Definition typeinf.hpp:2021
sval_t align_stkarg_up(sval_t spoff, int type_align, int slotsize, callcnv_t cc=CM_CC_UNKNOWN)
Definition typeinf.hpp:5684
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:2641
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:707
idaman uint32 ida_export choose_local_tinfo(const til_t *ti, const char *title, local_tinfo_predicate_t *func=nullptr, uint32 def_ord=0, void *ud=nullptr)
Choose a type from the local type library.
sclass_t
< storage class
Definition typeinf.hpp:2033
@ SC_EXT
extern
Definition typeinf.hpp:2036
@ SC_FRIEND
friend
Definition typeinf.hpp:2040
@ SC_VIRT
virtual
Definition typeinf.hpp:2041
@ SC_UNK
unknown
Definition typeinf.hpp:2034
@ SC_AUTO
auto
Definition typeinf.hpp:2039
@ SC_TYPE
typedef
Definition typeinf.hpp:2035
@ SC_REG
register
Definition typeinf.hpp:2038
@ SC_STAT
static
Definition typeinf.hpp:2037
THREAD_SAFE bool is_sdacl_byte(type_t t)
Identify an sdacl byte.
Definition typeinf.hpp:620
qvector< valstr_t > valstrvec_t
Definition typeinf.hpp:6446
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:631
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:695
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:6647
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.
int idaapi local_tinfo_predicate_t(uint32 ord, const tinfo_t &type, void *ud)
Controls which types are displayed/selected when choosing local types.
Definition typeinf.hpp:6604
gtd_func_t
Constants to be used with get_func_details()
Definition typeinf.hpp:2941
@ GTD_NO_ARGLOCS
don't calculate func arg locations please note that the locations may have been calculated earlier
Definition typeinf.hpp:2943
@ GTD_CALC_ARGLOCS
calculate func arg locations
Definition typeinf.hpp:2942
void set_c_macros(const char *macros)
Set predefined macros for the target compiler.
Definition typeinf.hpp:2825
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())
qvector< simd_info_t > simd_info_vec_t
Definition typeinf.hpp:4616
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:5662
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 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:4885
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
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 const type_t *ida_export resolve_typedef(const til_t *til, const type_t *type)
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:1244
This union is used to pass byte values to various helper functions.
Definition ua.hpp:580