1d876124dSJohn Birrell /* 2d876124dSJohn Birrell * CDDL HEADER START 3d876124dSJohn Birrell * 4d876124dSJohn Birrell * The contents of this file are subject to the terms of the 5d876124dSJohn Birrell * Common Development and Distribution License, Version 1.0 only 6d876124dSJohn Birrell * (the "License"). You may not use this file except in compliance 7d876124dSJohn Birrell * with the License. 8d876124dSJohn Birrell * 9d876124dSJohn Birrell * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10d876124dSJohn Birrell * or http://www.opensolaris.org/os/licensing. 11d876124dSJohn Birrell * See the License for the specific language governing permissions 12d876124dSJohn Birrell * and limitations under the License. 13d876124dSJohn Birrell * 14d876124dSJohn Birrell * When distributing Covered Code, include this CDDL HEADER in each 15d876124dSJohn Birrell * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16d876124dSJohn Birrell * If applicable, add the following below this CDDL HEADER, with the 17d876124dSJohn Birrell * fields enclosed by brackets "[]" replaced with your own identifying 18d876124dSJohn Birrell * information: Portions Copyright [yyyy] [name of copyright owner] 19d876124dSJohn Birrell * 20d876124dSJohn Birrell * CDDL HEADER END 21d876124dSJohn Birrell */ 22d876124dSJohn Birrell 23d876124dSJohn Birrell /* 24d876124dSJohn Birrell * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25d876124dSJohn Birrell * Use is subject to license terms. 26d876124dSJohn Birrell */ 273f0164abSXin LI /* 283f0164abSXin LI * Copyright (c) 2012, Joyent, Inc. All rights reserved. 293f0164abSXin LI */ 30d876124dSJohn Birrell 31d876124dSJohn Birrell #ifndef _CTF_IMPL_H 32d876124dSJohn Birrell #define _CTF_IMPL_H 33d876124dSJohn Birrell 34d876124dSJohn Birrell #include <sys/types.h> 35d876124dSJohn Birrell #include <sys/errno.h> 36d876124dSJohn Birrell #include <sys/sysmacros.h> 37d876124dSJohn Birrell #include <sys/ctf_api.h> 38d876124dSJohn Birrell 39d876124dSJohn Birrell #ifdef _KERNEL 40d876124dSJohn Birrell 41d876124dSJohn Birrell #include <sys/systm.h> 42d876124dSJohn Birrell #include <sys/cmn_err.h> 43d876124dSJohn Birrell #include <sys/varargs.h> 44d876124dSJohn Birrell 45d876124dSJohn Birrell #define isspace(c) \ 46d876124dSJohn Birrell ((c) == ' ' || (c) == '\t' || (c) == '\n' || \ 47d876124dSJohn Birrell (c) == '\r' || (c) == '\f' || (c) == '\v') 48d876124dSJohn Birrell 49d876124dSJohn Birrell #define MAP_FAILED ((void *)-1) 50d876124dSJohn Birrell 51d876124dSJohn Birrell #else /* _KERNEL */ 52d876124dSJohn Birrell 53d876124dSJohn Birrell #include <strings.h> 54d876124dSJohn Birrell #include <stdlib.h> 55d876124dSJohn Birrell #include <stdarg.h> 56d876124dSJohn Birrell #include <stdio.h> 57d876124dSJohn Birrell #include <limits.h> 58d876124dSJohn Birrell #include <ctype.h> 59d876124dSJohn Birrell 60d876124dSJohn Birrell #endif /* _KERNEL */ 61d876124dSJohn Birrell 62d876124dSJohn Birrell #ifdef __cplusplus 63d876124dSJohn Birrell extern "C" { 64d876124dSJohn Birrell #endif 65d876124dSJohn Birrell 66d876124dSJohn Birrell typedef struct ctf_helem { 67d876124dSJohn Birrell uint_t h_name; /* reference to name in string table */ 68*a6fb8691SMark Johnston uint_t h_type; /* corresponding type ID number */ 69*a6fb8691SMark Johnston uint_t h_next; /* index of next element in hash chain */ 70d876124dSJohn Birrell } ctf_helem_t; 71d876124dSJohn Birrell 72d876124dSJohn Birrell typedef struct ctf_hash { 73*a6fb8691SMark Johnston uint_t *h_buckets; /* hash bucket array (chain indices) */ 74d876124dSJohn Birrell ctf_helem_t *h_chains; /* hash chains buffer */ 75*a6fb8691SMark Johnston uint_t h_nbuckets; /* number of elements in bucket array */ 76*a6fb8691SMark Johnston uint_t h_nelems; /* number of elements in hash table */ 77d876124dSJohn Birrell uint_t h_free; /* index of next free hash element */ 78d876124dSJohn Birrell } ctf_hash_t; 79d876124dSJohn Birrell 80d876124dSJohn Birrell typedef struct ctf_strs { 81d876124dSJohn Birrell const char *cts_strs; /* base address of string table */ 82d876124dSJohn Birrell size_t cts_len; /* size of string table in bytes */ 83d876124dSJohn Birrell } ctf_strs_t; 84d876124dSJohn Birrell 85d876124dSJohn Birrell typedef struct ctf_dmodel { 86d876124dSJohn Birrell const char *ctd_name; /* data model name */ 87d876124dSJohn Birrell int ctd_code; /* data model code */ 88d876124dSJohn Birrell size_t ctd_pointer; /* size of void * in bytes */ 89d876124dSJohn Birrell size_t ctd_char; /* size of char in bytes */ 90d876124dSJohn Birrell size_t ctd_short; /* size of short in bytes */ 91d876124dSJohn Birrell size_t ctd_int; /* size of int in bytes */ 92d876124dSJohn Birrell size_t ctd_long; /* size of long in bytes */ 93d876124dSJohn Birrell } ctf_dmodel_t; 94d876124dSJohn Birrell 95d876124dSJohn Birrell typedef struct ctf_lookup { 96d876124dSJohn Birrell const char *ctl_prefix; /* string prefix for this lookup */ 97d876124dSJohn Birrell size_t ctl_len; /* length of prefix string in bytes */ 98d876124dSJohn Birrell ctf_hash_t *ctl_hash; /* pointer to hash table for lookup */ 99d876124dSJohn Birrell } ctf_lookup_t; 100d876124dSJohn Birrell 101d876124dSJohn Birrell typedef struct ctf_fileops { 102*a6fb8691SMark Johnston uint_t (*ctfo_get_kind)(uint_t); 103*a6fb8691SMark Johnston uint_t (*ctfo_get_root)(uint_t); 104*a6fb8691SMark Johnston uint_t (*ctfo_get_vlen)(uint_t); 105*a6fb8691SMark Johnston uint_t (*ctfo_get_max_vlen)(void); 106*a6fb8691SMark Johnston uint_t (*ctfo_get_max_size)(void); 107*a6fb8691SMark Johnston uint_t (*ctfo_get_max_type)(void); 108*a6fb8691SMark Johnston uint_t (*ctfo_get_lsize_sent)(void); 109*a6fb8691SMark Johnston uint_t (*ctfo_get_lstruct_thresh)(void); 110*a6fb8691SMark Johnston 111*a6fb8691SMark Johnston uint_t (*ctfo_type_info)(uint_t, uint_t, uint_t); 112*a6fb8691SMark Johnston int (*ctfo_type_isparent)(uint_t); 113*a6fb8691SMark Johnston int (*ctfo_type_ischild)(uint_t); 114*a6fb8691SMark Johnston uint_t (*ctfo_type_to_index)(uint_t); 115*a6fb8691SMark Johnston uint_t (*ctfo_index_to_type)(uint_t, uint_t); 116d876124dSJohn Birrell } ctf_fileops_t; 117d876124dSJohn Birrell 118d876124dSJohn Birrell typedef struct ctf_list { 119d876124dSJohn Birrell struct ctf_list *l_prev; /* previous pointer or tail pointer */ 120d876124dSJohn Birrell struct ctf_list *l_next; /* next pointer or head pointer */ 121d876124dSJohn Birrell } ctf_list_t; 122d876124dSJohn Birrell 123d876124dSJohn Birrell typedef enum { 124d876124dSJohn Birrell CTF_PREC_BASE, 125d876124dSJohn Birrell CTF_PREC_POINTER, 126d876124dSJohn Birrell CTF_PREC_ARRAY, 127d876124dSJohn Birrell CTF_PREC_FUNCTION, 128d876124dSJohn Birrell CTF_PREC_MAX 129d876124dSJohn Birrell } ctf_decl_prec_t; 130d876124dSJohn Birrell 131d876124dSJohn Birrell typedef struct ctf_decl_node { 132d876124dSJohn Birrell ctf_list_t cd_list; /* linked list pointers */ 133d876124dSJohn Birrell ctf_id_t cd_type; /* type identifier */ 134d876124dSJohn Birrell uint_t cd_kind; /* type kind */ 135d876124dSJohn Birrell uint_t cd_n; /* type dimension if array */ 136d876124dSJohn Birrell } ctf_decl_node_t; 137d876124dSJohn Birrell 138d876124dSJohn Birrell typedef struct ctf_decl { 139d876124dSJohn Birrell ctf_list_t cd_nodes[CTF_PREC_MAX]; /* declaration node stacks */ 140d876124dSJohn Birrell int cd_order[CTF_PREC_MAX]; /* storage order of decls */ 141d876124dSJohn Birrell ctf_decl_prec_t cd_qualp; /* qualifier precision */ 142d876124dSJohn Birrell ctf_decl_prec_t cd_ordp; /* ordered precision */ 143d876124dSJohn Birrell char *cd_buf; /* buffer for output */ 144d876124dSJohn Birrell char *cd_ptr; /* buffer location */ 145d876124dSJohn Birrell char *cd_end; /* buffer limit */ 146d876124dSJohn Birrell size_t cd_len; /* buffer space required */ 147d876124dSJohn Birrell int cd_err; /* saved error value */ 148d876124dSJohn Birrell } ctf_decl_t; 149d876124dSJohn Birrell 150d876124dSJohn Birrell typedef struct ctf_dmdef { 151d876124dSJohn Birrell ctf_list_t dmd_list; /* list forward/back pointers */ 152d876124dSJohn Birrell char *dmd_name; /* name of this member */ 153d876124dSJohn Birrell ctf_id_t dmd_type; /* type of this member (for sou) */ 154d876124dSJohn Birrell ulong_t dmd_offset; /* offset of this member in bits (for sou) */ 155d876124dSJohn Birrell int dmd_value; /* value of this member (for enum) */ 156d876124dSJohn Birrell } ctf_dmdef_t; 157d876124dSJohn Birrell 158d876124dSJohn Birrell typedef struct ctf_dtdef { 159d876124dSJohn Birrell ctf_list_t dtd_list; /* list forward/back pointers */ 160d876124dSJohn Birrell struct ctf_dtdef *dtd_hash; /* hash chain pointer for ctf_dthash */ 161d876124dSJohn Birrell char *dtd_name; /* name associated with definition (if any) */ 162d876124dSJohn Birrell ctf_id_t dtd_type; /* type identifier for this definition */ 163*a6fb8691SMark Johnston struct ctf_type_v3 dtd_data; /* type node (see <sys/ctf.h>) */ 1643f0164abSXin LI int dtd_ref; /* recfount for dyanmic types */ 165d876124dSJohn Birrell union { 166d876124dSJohn Birrell ctf_list_t dtu_members; /* struct, union, or enum */ 167d876124dSJohn Birrell ctf_arinfo_t dtu_arr; /* array */ 168d876124dSJohn Birrell ctf_encoding_t dtu_enc; /* integer or float */ 169d876124dSJohn Birrell ctf_id_t *dtu_argv; /* function */ 170d876124dSJohn Birrell } dtd_u; 171d876124dSJohn Birrell } ctf_dtdef_t; 172d876124dSJohn Birrell 173d876124dSJohn Birrell typedef struct ctf_bundle { 174d876124dSJohn Birrell ctf_file_t *ctb_file; /* CTF container handle */ 175d876124dSJohn Birrell ctf_id_t ctb_type; /* CTF type identifier */ 176d876124dSJohn Birrell ctf_dtdef_t *ctb_dtd; /* CTF dynamic type definition (if any) */ 177d876124dSJohn Birrell } ctf_bundle_t; 178d876124dSJohn Birrell 179d876124dSJohn Birrell /* 180d876124dSJohn Birrell * The ctf_file is the structure used to represent a CTF container to library 181d876124dSJohn Birrell * clients, who see it only as an opaque pointer. Modifications can therefore 182d876124dSJohn Birrell * be made freely to this structure without regard to client versioning. The 183d876124dSJohn Birrell * ctf_file_t typedef appears in <sys/ctf_api.h> and declares a forward tag. 184d876124dSJohn Birrell * 185d876124dSJohn Birrell * NOTE: ctf_update() requires that everything inside of ctf_file either be an 186d876124dSJohn Birrell * immediate value, a pointer to dynamically allocated data *outside* of the 187d876124dSJohn Birrell * ctf_file itself, or a pointer to statically allocated data. If you add a 188d876124dSJohn Birrell * pointer to ctf_file that points to something within the ctf_file itself, 189d876124dSJohn Birrell * you must make corresponding changes to ctf_update(). 190d876124dSJohn Birrell */ 191d876124dSJohn Birrell struct ctf_file { 192d876124dSJohn Birrell const ctf_fileops_t *ctf_fileops; /* version-specific file operations */ 193d876124dSJohn Birrell ctf_sect_t ctf_data; /* CTF data from object file */ 194d876124dSJohn Birrell ctf_sect_t ctf_symtab; /* symbol table from object file */ 195d876124dSJohn Birrell ctf_sect_t ctf_strtab; /* string table from object file */ 196d876124dSJohn Birrell ctf_hash_t ctf_structs; /* hash table of struct types */ 197d876124dSJohn Birrell ctf_hash_t ctf_unions; /* hash table of union types */ 198d876124dSJohn Birrell ctf_hash_t ctf_enums; /* hash table of enum types */ 199d876124dSJohn Birrell ctf_hash_t ctf_names; /* hash table of remaining type names */ 200d876124dSJohn Birrell ctf_lookup_t ctf_lookups[5]; /* pointers to hashes for name lookup */ 201d876124dSJohn Birrell ctf_strs_t ctf_str[2]; /* array of string table base and bounds */ 202d876124dSJohn Birrell const uchar_t *ctf_base; /* base of CTF header + uncompressed buffer */ 203d876124dSJohn Birrell const uchar_t *ctf_buf; /* uncompressed CTF data buffer */ 204d876124dSJohn Birrell size_t ctf_size; /* size of CTF header + uncompressed data */ 205d876124dSJohn Birrell uint_t *ctf_sxlate; /* translation table for symtab entries */ 206d876124dSJohn Birrell ulong_t ctf_nsyms; /* number of entries in symtab xlate table */ 207d876124dSJohn Birrell uint_t *ctf_txlate; /* translation table for type IDs */ 208*a6fb8691SMark Johnston uint_t *ctf_ptrtab; /* translation table for pointer-to lookups */ 209d876124dSJohn Birrell ulong_t ctf_typemax; /* maximum valid type ID number */ 210d876124dSJohn Birrell const ctf_dmodel_t *ctf_dmodel; /* data model pointer (see above) */ 211d876124dSJohn Birrell struct ctf_file *ctf_parent; /* parent CTF container (if any) */ 212d876124dSJohn Birrell const char *ctf_parlabel; /* label in parent container (if any) */ 213d876124dSJohn Birrell const char *ctf_parname; /* basename of parent (if any) */ 214d876124dSJohn Birrell uint_t ctf_refcnt; /* reference count (for parent links) */ 215d876124dSJohn Birrell uint_t ctf_flags; /* libctf flags (see below) */ 216d876124dSJohn Birrell int ctf_errno; /* error code for most recent error */ 217d876124dSJohn Birrell int ctf_version; /* CTF data version */ 218*a6fb8691SMark Johnston size_t ctf_idwidth; /* Size, in bytes, of a type ID */ 219d876124dSJohn Birrell ctf_dtdef_t **ctf_dthash; /* hash of dynamic type definitions */ 220d876124dSJohn Birrell ulong_t ctf_dthashlen; /* size of dynamic type hash bucket array */ 221d876124dSJohn Birrell ctf_list_t ctf_dtdefs; /* list of dynamic type definitions */ 222d876124dSJohn Birrell size_t ctf_dtstrlen; /* total length of dynamic type strings */ 223d876124dSJohn Birrell ulong_t ctf_dtnextid; /* next dynamic type id to assign */ 224d876124dSJohn Birrell ulong_t ctf_dtoldid; /* oldest id that has been committed */ 225d876124dSJohn Birrell void *ctf_specific; /* data for ctf_get/setspecific */ 226d876124dSJohn Birrell }; 227d876124dSJohn Birrell 228d876124dSJohn Birrell #define LCTF_INDEX_TO_TYPEPTR(fp, i) \ 229*a6fb8691SMark Johnston ((void *)((uintptr_t)(fp)->ctf_buf + (fp)->ctf_txlate[(i)])) 230d876124dSJohn Birrell 231d876124dSJohn Birrell #define LCTF_INFO_KIND(fp, info) ((fp)->ctf_fileops->ctfo_get_kind(info)) 232d876124dSJohn Birrell #define LCTF_INFO_ROOT(fp, info) ((fp)->ctf_fileops->ctfo_get_root(info)) 233d876124dSJohn Birrell #define LCTF_INFO_VLEN(fp, info) ((fp)->ctf_fileops->ctfo_get_vlen(info)) 234*a6fb8691SMark Johnston #define LCTF_MAX_VLEN(fp) ((fp)->ctf_fileops->ctfo_get_max_vlen()) 235*a6fb8691SMark Johnston #define LCTF_MAX_SIZE(fp) ((fp)->ctf_fileops->ctfo_get_max_size()) 236*a6fb8691SMark Johnston #define LCTF_MAX_TYPE(fp) ((fp)->ctf_fileops->ctfo_get_max_type()) 237*a6fb8691SMark Johnston #define LCTF_LSIZE_SENT(fp) \ 238*a6fb8691SMark Johnston ((fp)->ctf_fileops->ctfo_get_lsize_sent()) 239*a6fb8691SMark Johnston #define LCTF_LSTRUCT_THRESH(fp) \ 240*a6fb8691SMark Johnston ((fp)->ctf_fileops->ctfo_get_lstruct_thresh()) 241*a6fb8691SMark Johnston 242*a6fb8691SMark Johnston #define LCTF_TYPE_INFO(fp, k, r, l) ((fp)->ctf_fileops->ctfo_type_info(k, r, l)) 243*a6fb8691SMark Johnston #define LCTF_TYPE_ISPARENT(fp, id) ((fp)->ctf_fileops->ctfo_type_isparent(id)) 244*a6fb8691SMark Johnston #define LCTF_TYPE_ISCHILD(fp, id) ((fp)->ctf_fileops->ctfo_type_ischild(id)) 245*a6fb8691SMark Johnston #define LCTF_TYPE_TO_INDEX(fp, t) ((fp)->ctf_fileops->ctfo_type_to_index(t)) 246*a6fb8691SMark Johnston #define LCTF_INDEX_TO_TYPE(fp, id, c) ((fp)->ctf_fileops->ctfo_index_to_type(id, c)) 247d876124dSJohn Birrell 248d876124dSJohn Birrell #define LCTF_MMAP 0x0001 /* libctf should munmap buffers on close */ 249d876124dSJohn Birrell #define LCTF_CHILD 0x0002 /* CTF container is a child */ 250d876124dSJohn Birrell #define LCTF_RDWR 0x0004 /* CTF container is writable */ 251d876124dSJohn Birrell #define LCTF_DIRTY 0x0008 /* CTF container has been modified */ 252d876124dSJohn Birrell 253d876124dSJohn Birrell #define ECTF_BASE 1000 /* base value for libctf errnos */ 254d876124dSJohn Birrell 255d876124dSJohn Birrell enum { 256d876124dSJohn Birrell ECTF_FMT = ECTF_BASE, /* file is not in CTF or ELF format */ 257d876124dSJohn Birrell ECTF_ELFVERS, /* ELF version is more recent than libctf */ 258d876124dSJohn Birrell ECTF_CTFVERS, /* CTF version is more recent than libctf */ 259d876124dSJohn Birrell ECTF_ENDIAN, /* data is different endian-ness than lib */ 260d876124dSJohn Birrell ECTF_SYMTAB, /* symbol table uses invalid entry size */ 261d876124dSJohn Birrell ECTF_SYMBAD, /* symbol table data buffer invalid */ 262d876124dSJohn Birrell ECTF_STRBAD, /* string table data buffer invalid */ 263d876124dSJohn Birrell ECTF_CORRUPT, /* file data corruption detected */ 264d876124dSJohn Birrell ECTF_NOCTFDATA, /* ELF file does not contain CTF data */ 265d876124dSJohn Birrell ECTF_NOCTFBUF, /* buffer does not contain CTF data */ 266d876124dSJohn Birrell ECTF_NOSYMTAB, /* symbol table data is not available */ 267d876124dSJohn Birrell ECTF_NOPARENT, /* parent CTF container is not available */ 268d876124dSJohn Birrell ECTF_DMODEL, /* data model mismatch */ 269d876124dSJohn Birrell ECTF_MMAP, /* failed to mmap a data section */ 270d876124dSJohn Birrell ECTF_ZMISSING, /* decompression library not installed */ 271d876124dSJohn Birrell ECTF_ZINIT, /* failed to initialize decompression library */ 272d876124dSJohn Birrell ECTF_ZALLOC, /* failed to allocate decompression buffer */ 273d876124dSJohn Birrell ECTF_DECOMPRESS, /* failed to decompress CTF data */ 274d876124dSJohn Birrell ECTF_STRTAB, /* string table for this string is missing */ 275d876124dSJohn Birrell ECTF_BADNAME, /* string offset is corrupt w.r.t. strtab */ 276d876124dSJohn Birrell ECTF_BADID, /* invalid type ID number */ 277d876124dSJohn Birrell ECTF_NOTSOU, /* type is not a struct or union */ 278d876124dSJohn Birrell ECTF_NOTENUM, /* type is not an enum */ 279d876124dSJohn Birrell ECTF_NOTSUE, /* type is not a struct, union, or enum */ 280d876124dSJohn Birrell ECTF_NOTINTFP, /* type is not an integer or float */ 281d876124dSJohn Birrell ECTF_NOTARRAY, /* type is not an array */ 282d876124dSJohn Birrell ECTF_NOTREF, /* type does not reference another type */ 283d876124dSJohn Birrell ECTF_NAMELEN, /* buffer is too small to hold type name */ 284d876124dSJohn Birrell ECTF_NOTYPE, /* no type found corresponding to name */ 285d876124dSJohn Birrell ECTF_SYNTAX, /* syntax error in type name */ 286d876124dSJohn Birrell ECTF_NOTFUNC, /* symtab entry does not refer to a function */ 287d876124dSJohn Birrell ECTF_NOFUNCDAT, /* no func info available for function */ 288d876124dSJohn Birrell ECTF_NOTDATA, /* symtab entry does not refer to a data obj */ 289d876124dSJohn Birrell ECTF_NOTYPEDAT, /* no type info available for object */ 290d876124dSJohn Birrell ECTF_NOLABEL, /* no label found corresponding to name */ 291d876124dSJohn Birrell ECTF_NOLABELDATA, /* file does not contain any labels */ 292d876124dSJohn Birrell ECTF_NOTSUP, /* feature not supported */ 293d876124dSJohn Birrell ECTF_NOENUMNAM, /* enum element name not found */ 294d876124dSJohn Birrell ECTF_NOMEMBNAM, /* member name not found */ 295d876124dSJohn Birrell ECTF_RDONLY, /* CTF container is read-only */ 296d876124dSJohn Birrell ECTF_DTFULL, /* CTF type is full (no more members allowed) */ 297d876124dSJohn Birrell ECTF_FULL, /* CTF container is full */ 298d876124dSJohn Birrell ECTF_DUPMEMBER, /* duplicate member name definition */ 2993f0164abSXin LI ECTF_CONFLICT, /* conflicting type definition present */ 3003f0164abSXin LI ECTF_REFERENCED, /* type has outstanding references */ 3013f0164abSXin LI ECTF_NOTDYN /* type is not a dynamic type */ 302d876124dSJohn Birrell }; 303d876124dSJohn Birrell 304*a6fb8691SMark Johnston extern void ctf_get_ctt_index(const ctf_file_t *fp, const void *v, 305*a6fb8691SMark Johnston uint_t *indexp, uint_t *typep, int *ischildp); 306*a6fb8691SMark Johnston extern ssize_t ctf_get_ctt_size(const ctf_file_t *, const void *v, ssize_t *, 307*a6fb8691SMark Johnston ssize_t *); 308*a6fb8691SMark Johnston extern void ctf_get_ctt_info(const ctf_file_t *, const void *v, uint_t *kind, 309*a6fb8691SMark Johnston uint_t *vlen, int *isroot); 310d876124dSJohn Birrell 311*a6fb8691SMark Johnston extern void ctf_get_ctm_info(const ctf_file_t *fp, const void *v, size_t sz, 312*a6fb8691SMark Johnston size_t *incrementp, uint_t *typep, ulong_t *offsetp, const char **namep); 313*a6fb8691SMark Johnston 314*a6fb8691SMark Johnston extern const void *ctf_lookup_by_id(ctf_file_t **, ctf_id_t); 315*a6fb8691SMark Johnston extern const char *ctf_type_rname(ctf_file_t *, const void *); 316d876124dSJohn Birrell 317d876124dSJohn Birrell extern int ctf_hash_create(ctf_hash_t *, ulong_t); 318*a6fb8691SMark Johnston extern int ctf_hash_insert(ctf_hash_t *, ctf_file_t *, uint_t, uint_t); 319*a6fb8691SMark Johnston extern int ctf_hash_define(ctf_hash_t *, ctf_file_t *, uint_t, uint_t); 320d876124dSJohn Birrell extern ctf_helem_t *ctf_hash_lookup(ctf_hash_t *, ctf_file_t *, 321d876124dSJohn Birrell const char *, size_t); 322d876124dSJohn Birrell extern uint_t ctf_hash_size(const ctf_hash_t *); 323d876124dSJohn Birrell extern void ctf_hash_destroy(ctf_hash_t *); 324d876124dSJohn Birrell 325d876124dSJohn Birrell #define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev)) 326d876124dSJohn Birrell #define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next)) 327d876124dSJohn Birrell 328d876124dSJohn Birrell extern void ctf_list_append(ctf_list_t *, void *); 329d876124dSJohn Birrell extern void ctf_list_prepend(ctf_list_t *, void *); 330d876124dSJohn Birrell extern void ctf_list_delete(ctf_list_t *, void *); 331d876124dSJohn Birrell 332d876124dSJohn Birrell extern void ctf_dtd_insert(ctf_file_t *, ctf_dtdef_t *); 333d876124dSJohn Birrell extern void ctf_dtd_delete(ctf_file_t *, ctf_dtdef_t *); 334d876124dSJohn Birrell extern ctf_dtdef_t *ctf_dtd_lookup(ctf_file_t *, ctf_id_t); 335d876124dSJohn Birrell 336d876124dSJohn Birrell extern void ctf_decl_init(ctf_decl_t *, char *, size_t); 337d876124dSJohn Birrell extern void ctf_decl_fini(ctf_decl_t *); 338d876124dSJohn Birrell extern void ctf_decl_push(ctf_decl_t *, ctf_file_t *, ctf_id_t); 339d876124dSJohn Birrell extern void ctf_decl_sprintf(ctf_decl_t *, const char *, ...); 340d876124dSJohn Birrell 34145c23c26SMark Johnston extern const char *ctf_strraw(const ctf_file_t *, uint_t); 34245c23c26SMark Johnston extern const char *ctf_strptr(const ctf_file_t *, uint_t); 343d876124dSJohn Birrell 344d876124dSJohn Birrell extern ctf_file_t *ctf_set_open_errno(int *, int); 345d876124dSJohn Birrell extern long ctf_set_errno(ctf_file_t *, int); 346d876124dSJohn Birrell 347d876124dSJohn Birrell extern const void *ctf_sect_mmap(ctf_sect_t *, int); 348d876124dSJohn Birrell extern void ctf_sect_munmap(const ctf_sect_t *); 349d876124dSJohn Birrell 350d876124dSJohn Birrell extern void *ctf_data_alloc(size_t); 351d876124dSJohn Birrell extern void ctf_data_free(void *, size_t); 352d876124dSJohn Birrell extern void ctf_data_protect(void *, size_t); 353d876124dSJohn Birrell 354d876124dSJohn Birrell extern void *ctf_alloc(size_t); 355d876124dSJohn Birrell extern void ctf_free(void *, size_t); 356d876124dSJohn Birrell 357d876124dSJohn Birrell extern char *ctf_strdup(const char *); 358d876124dSJohn Birrell extern const char *ctf_strerror(int); 359d876124dSJohn Birrell extern void ctf_dprintf(const char *, ...); 360d876124dSJohn Birrell 361d876124dSJohn Birrell extern void *ctf_zopen(int *); 362d876124dSJohn Birrell 363d876124dSJohn Birrell extern const char _CTF_SECTION[]; /* name of CTF ELF section */ 364d876124dSJohn Birrell extern const char _CTF_NULLSTR[]; /* empty string */ 365d876124dSJohn Birrell 366d876124dSJohn Birrell extern int _libctf_version; /* library client version */ 367d876124dSJohn Birrell extern int _libctf_debug; /* debugging messages enabled */ 368d876124dSJohn Birrell 369d876124dSJohn Birrell #ifdef __cplusplus 370d876124dSJohn Birrell } 371d876124dSJohn Birrell #endif 372d876124dSJohn Birrell 373d876124dSJohn Birrell #endif /* _CTF_IMPL_H */ 374