[BACK]Return to itype.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / ctfconv

Annotation of src/usr.bin/ctfconv/itype.h, Revision 1.3

1.3     ! mpi         1: /*     $OpenBSD: itype.h,v 1.2 2017/08/11 14:58:56 jasper Exp $ */
1.2       jasper      2:
1.1       mpi         3: /*
                      4:  * Copyright (c) 2016-2017 Martin Pieuchot
                      5:  * Copyright (c) 2016 Jasper Lievisse Adriaanse <jasper@openbsd.org>
                      6:  *
                      7:  * Permission to use, copy, modify, and distribute this software for any
                      8:  * purpose with or without fee is hereby granted, provided that the above
                      9:  * copyright notice and this permission notice appear in all copies.
                     10:  *
                     11:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     12:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     13:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     14:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     15:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     16:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     17:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     18:  */
                     19:
                     20: #ifndef _ITTYPE_H_
                     21: #define _ITTYPE_H_
                     22:
                     23: #define ITNAME_MAX     128
                     24:
                     25: struct imember;
                     26: struct itref;
                     27:
                     28: /*
                     29:  * Internal type representation.
                     30:  *
                     31:  * Some bits of DWARF that we want to keep around to resolve types and
                     32:  * variables to their intrinsics.
                     33:  */
                     34: struct itype {
                     35:        TAILQ_ENTRY(itype)       it_next;   /* itype: global queue of types */
                     36:        TAILQ_ENTRY(itype)       it_symb;   /* itype: global queue of symbol */
                     37:        RB_ENTRY(itype)          it_node;   /* itype: per-type tree of types */
                     38:
                     39:        SIMPLEQ_HEAD(, itref)    it_refs;   /* itpye: backpointing refs */
                     40:
                     41:        TAILQ_HEAD(, imember)    it_members;/* itype: members of struct/union */
                     42:
                     43:        size_t                   it_off;    /* DWARF: matching .abbrev offset */
                     44:        uint64_t                 it_ref;    /* DWARF: CU offset of ref. type */
                     45:
                     46:        struct itype            *it_refp;   /* itype: resolved type */
                     47:
                     48:        char                     it_name[ITNAME_MAX];/* CTF: type name */
                     49:        uint32_t                 it_size;   /* CTF: size in byte or bits */
                     50:        uint32_t                 it_nelems; /* CTF: # of members or arguments */
                     51:        uint16_t                 it_enc;    /* CTF: base type encoding */
                     52:        uint16_t                 it_idx;    /* CTF: generated type ID */
                     53:        uint16_t                 it_type;   /* CTF: type */
                     54:        uint8_t                  __pad[2];
                     55:
                     56:        unsigned int             it_flags;  /* itype: parser flags */
                     57: #define        ITF_UNRES                0x01       /* needs to be resolved */
                     58: #define        ITF_UNRES_MEMB           0x02       /* members need to be resolved */
                     59: #define        ITF_FUNC                 0x04       /* is a function */
                     60: #define        ITF_OBJ                  0x08       /* is an object */
                     61: #define        ITF_VARARGS              0x10       /* takes varargs */
                     62: #define        ITF_INSERTED             0x20       /* already found/inserted */
                     63: #define        ITF_USED                 0x40       /* referenced in the current CU */
                     64: #define        ITF_ANON                 0x80       /* type without name */
                     65: #define        ITF_MASK                (ITF_INSERTED|ITF_USED)
                     66: };
                     67:
                     68: /*
                     69:  * Member for types with a variable length (struct, array, etc).
                     70:  */
                     71: struct imember {
                     72:        TAILQ_ENTRY(imember)     im_next;
                     73:        char                     im_name[ITNAME_MAX]; /* struct field name */
                     74:        size_t                   im_ref;    /* CU offset of the field type */
                     75:        size_t                   im_off;    /* field offset in struct/union */
                     76:        struct itype            *im_refp;   /* resolved CTF type */
                     77:        unsigned int             im_flags;  /* parser flags */
1.3     ! mpi        78: #define        IMF_ANON                 0x01       /* member without name */
1.1       mpi        79: };
                     80:
                     81: /*
                     82:  * Used to build a list of backpointing references to speed up
                     83:  * merging duplicated types.
                     84:  */
                     85: struct itref {
                     86:        SIMPLEQ_ENTRY(itref)     ir_next;
                     87:        struct itype            *ir_itp;
                     88: };
                     89:
                     90: TAILQ_HEAD(itype_queue, itype);
                     91: RB_HEAD(isymb_tree, itype);
                     92:
                     93: /* lists of types, functions & data objects */
                     94: extern struct itype_queue itypeq, ifuncq, iobjq;
                     95: extern struct isymb_tree isymbt;           /* tree of symbols */
                     96: extern uint16_t tidx;                      /* type index */
                     97: extern uint16_t long_tidx;                 /* type ID for "long" */
                     98:
                     99: RB_PROTOTYPE(isymb_tree, itype, it_node, it_name_cmp);
                    100:
                    101: struct itype *it_dup(struct itype *);
                    102: const char *it_name(struct itype *);
1.3     ! mpi       103: const char *im_name(struct imember *);
1.1       mpi       104:
                    105: #endif /*_ITTYPE_H_ */