17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 260a47c91cSRobert Mustacchi /* 27*fe2dc8bdSJohn Levon * Copyright 2020 Joyent, Inc. 280a47c91cSRobert Mustacchi */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * This header file defines the interfaces available from the CTF debugger 327c478bd9Sstevel@tonic-gate * library, libctf, and an equivalent kernel module. This API can be used by 337c478bd9Sstevel@tonic-gate * a debugger to operate on data in the Compact ANSI-C Type Format (CTF). 347c478bd9Sstevel@tonic-gate * This is NOT a public interface, although it may eventually become one in 357c478bd9Sstevel@tonic-gate * the fullness of time after we gain more experience with the interfaces. 367c478bd9Sstevel@tonic-gate * 377c478bd9Sstevel@tonic-gate * In the meantime, be aware that any program linked with this API in this 387c478bd9Sstevel@tonic-gate * release of Solaris is almost guaranteed to break in the next release. 397c478bd9Sstevel@tonic-gate * 407c478bd9Sstevel@tonic-gate * In short, do not user this header file or the CTF routines for any purpose. 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifndef _CTF_API_H 447c478bd9Sstevel@tonic-gate #define _CTF_API_H 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #include <sys/types.h> 477c478bd9Sstevel@tonic-gate #include <sys/param.h> 487c478bd9Sstevel@tonic-gate #include <sys/elf.h> 497c478bd9Sstevel@tonic-gate #include <sys/ctf.h> 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate #ifdef __cplusplus 527c478bd9Sstevel@tonic-gate extern "C" { 537c478bd9Sstevel@tonic-gate #endif 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * Clients can open one or more CTF containers and obtain a pointer to an 577c478bd9Sstevel@tonic-gate * opaque ctf_file_t. Types are identified by an opaque ctf_id_t token. 587c478bd9Sstevel@tonic-gate * These opaque definitions allow libctf to evolve without breaking clients. 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate typedef struct ctf_file ctf_file_t; 617c478bd9Sstevel@tonic-gate typedef long ctf_id_t; 627c478bd9Sstevel@tonic-gate 63bc1f688bSRobert Mustacchi #define ECTF_BASE 1000 /* base value for libctf errnos */ 64bc1f688bSRobert Mustacchi 65bc1f688bSRobert Mustacchi enum { 66bc1f688bSRobert Mustacchi ECTF_FMT = ECTF_BASE, /* file is not in CTF or ELF format */ 67bc1f688bSRobert Mustacchi ECTF_ELFVERS, /* ELF version is more recent than libctf */ 68bc1f688bSRobert Mustacchi ECTF_CTFVERS, /* CTF version is more recent than libctf */ 69bc1f688bSRobert Mustacchi ECTF_ENDIAN, /* data is different endian-ness than lib */ 70bc1f688bSRobert Mustacchi ECTF_SYMTAB, /* symbol table uses invalid entry size */ 71bc1f688bSRobert Mustacchi ECTF_SYMBAD, /* symbol table data buffer invalid */ 72bc1f688bSRobert Mustacchi ECTF_STRBAD, /* string table data buffer invalid */ 73bc1f688bSRobert Mustacchi ECTF_CORRUPT, /* file data corruption detected */ 74bc1f688bSRobert Mustacchi ECTF_NOCTFDATA, /* ELF file does not contain CTF data */ 75bc1f688bSRobert Mustacchi ECTF_NOCTFBUF, /* buffer does not contain CTF data */ 76bc1f688bSRobert Mustacchi ECTF_NOSYMTAB, /* symbol table data is not available */ 77bc1f688bSRobert Mustacchi ECTF_NOPARENT, /* parent CTF container is not available */ 78bc1f688bSRobert Mustacchi ECTF_DMODEL, /* data model mismatch */ 79bc1f688bSRobert Mustacchi ECTF_MMAP, /* failed to mmap a data section */ 80bc1f688bSRobert Mustacchi ECTF_ZMISSING, /* decompression library not installed */ 81bc1f688bSRobert Mustacchi ECTF_ZINIT, /* failed to initialize decompression library */ 82bc1f688bSRobert Mustacchi ECTF_ZALLOC, /* failed to allocate decompression buffer */ 83bc1f688bSRobert Mustacchi ECTF_DECOMPRESS, /* failed to decompress CTF data */ 84bc1f688bSRobert Mustacchi ECTF_STRTAB, /* string table for this string is missing */ 85bc1f688bSRobert Mustacchi ECTF_BADNAME, /* string offset is corrupt w.r.t. strtab */ 86bc1f688bSRobert Mustacchi ECTF_BADID, /* invalid type ID number */ 87bc1f688bSRobert Mustacchi ECTF_NOTSOU, /* type is not a struct or union */ 88bc1f688bSRobert Mustacchi ECTF_NOTENUM, /* type is not an enum */ 89bc1f688bSRobert Mustacchi ECTF_NOTSUE, /* type is not a struct, union, or enum */ 90bc1f688bSRobert Mustacchi ECTF_NOTINTFP, /* type is not an integer or float */ 91bc1f688bSRobert Mustacchi ECTF_NOTARRAY, /* type is not an array */ 92bc1f688bSRobert Mustacchi ECTF_NOTREF, /* type does not reference another type */ 93bc1f688bSRobert Mustacchi ECTF_NAMELEN, /* buffer is too small to hold type name */ 94bc1f688bSRobert Mustacchi ECTF_NOTYPE, /* no type found corresponding to name */ 95bc1f688bSRobert Mustacchi ECTF_SYNTAX, /* syntax error in type name */ 96bc1f688bSRobert Mustacchi ECTF_NOTFUNC, /* symtab entry does not refer to a function */ 97bc1f688bSRobert Mustacchi ECTF_NOFUNCDAT, /* no func info available for function */ 98bc1f688bSRobert Mustacchi ECTF_NOTDATA, /* symtab entry does not refer to a data obj */ 99bc1f688bSRobert Mustacchi ECTF_NOTYPEDAT, /* no type info available for object */ 100bc1f688bSRobert Mustacchi ECTF_NOLABEL, /* no label found corresponding to name */ 101bc1f688bSRobert Mustacchi ECTF_NOLABELDATA, /* file does not contain any labels */ 102bc1f688bSRobert Mustacchi ECTF_NOTSUP, /* feature not supported */ 103bc1f688bSRobert Mustacchi ECTF_NOENUMNAM, /* enum element name not found */ 104bc1f688bSRobert Mustacchi ECTF_NOMEMBNAM, /* member name not found */ 105bc1f688bSRobert Mustacchi ECTF_RDONLY, /* CTF container is read-only */ 106bc1f688bSRobert Mustacchi ECTF_DTFULL, /* CTF type is full (no more members allowed) */ 107bc1f688bSRobert Mustacchi ECTF_FULL, /* CTF container is full */ 108bc1f688bSRobert Mustacchi ECTF_DUPMEMBER, /* duplicate member name definition */ 109bc1f688bSRobert Mustacchi ECTF_CONFLICT, /* conflicting type definition present */ 110bc1f688bSRobert Mustacchi ECTF_REFERENCED, /* type has outstanding references */ 111bc1f688bSRobert Mustacchi ECTF_NOTDYN, /* type is not a dynamic type */ 112bc1f688bSRobert Mustacchi ECTF_ELF, /* elf library failure */ 113bc1f688bSRobert Mustacchi ECTF_MCHILD, /* cannot merge child container */ 114bc1f688bSRobert Mustacchi ECTF_LABELEXISTS, /* label already exists */ 115bc1f688bSRobert Mustacchi ECTF_LCONFLICT, /* merged labels conflict */ 116bc1f688bSRobert Mustacchi ECTF_ZLIB, /* zlib library failure */ 117bc1f688bSRobert Mustacchi ECTF_CONVBKERR, /* CTF conversion backend error */ 118bc1f688bSRobert Mustacchi ECTF_CONVNOCSRC, /* No C source to convert from */ 1193eca6103SJohn Levon ECTF_CONVNODEBUG /* No debug info to convert into CTF */ 120bc1f688bSRobert Mustacchi }; 121bc1f688bSRobert Mustacchi 1227c478bd9Sstevel@tonic-gate /* 1237c478bd9Sstevel@tonic-gate * If the debugger needs to provide the CTF library with a set of raw buffers 1247c478bd9Sstevel@tonic-gate * for use as the CTF data, symbol table, and string table, it can do so by 1257c478bd9Sstevel@tonic-gate * filling in ctf_sect_t structures and passing them to ctf_bufopen(): 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate typedef struct ctf_sect { 1287c478bd9Sstevel@tonic-gate const char *cts_name; /* section name (if any) */ 1297c478bd9Sstevel@tonic-gate ulong_t cts_type; /* section type (ELF SHT_... value) */ 1307c478bd9Sstevel@tonic-gate ulong_t cts_flags; /* section flags (ELF SHF_... value) */ 1317c478bd9Sstevel@tonic-gate const void *cts_data; /* pointer to section data */ 1327c478bd9Sstevel@tonic-gate size_t cts_size; /* size of data in bytes */ 1337c478bd9Sstevel@tonic-gate size_t cts_entsize; /* size of each section entry (symtab only) */ 1347c478bd9Sstevel@tonic-gate off64_t cts_offset; /* file offset of this section (if any) */ 1357c478bd9Sstevel@tonic-gate } ctf_sect_t; 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 1387c478bd9Sstevel@tonic-gate * Encoding information for integers, floating-point values, and certain other 1397c478bd9Sstevel@tonic-gate * intrinsics can be obtained by calling ctf_type_encoding(), below. The flags 1407c478bd9Sstevel@tonic-gate * field will contain values appropriate for the type defined in <sys/ctf.h>. 1417c478bd9Sstevel@tonic-gate */ 1427c478bd9Sstevel@tonic-gate typedef struct ctf_encoding { 1437c478bd9Sstevel@tonic-gate uint_t cte_format; /* data format (CTF_INT_* or CTF_FP_* flags) */ 1447c478bd9Sstevel@tonic-gate uint_t cte_offset; /* offset of value in bits */ 1457c478bd9Sstevel@tonic-gate uint_t cte_bits; /* size of storage in bits */ 1467c478bd9Sstevel@tonic-gate } ctf_encoding_t; 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate typedef struct ctf_membinfo { 1497c478bd9Sstevel@tonic-gate ctf_id_t ctm_type; /* type of struct or union member */ 1507c478bd9Sstevel@tonic-gate ulong_t ctm_offset; /* offset of member in bits */ 1517c478bd9Sstevel@tonic-gate } ctf_membinfo_t; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate typedef struct ctf_arinfo { 1547c478bd9Sstevel@tonic-gate ctf_id_t ctr_contents; /* type of array contents */ 1557c478bd9Sstevel@tonic-gate ctf_id_t ctr_index; /* type of array index */ 1567c478bd9Sstevel@tonic-gate uint_t ctr_nelems; /* number of elements */ 1577c478bd9Sstevel@tonic-gate } ctf_arinfo_t; 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate typedef struct ctf_funcinfo { 1607c478bd9Sstevel@tonic-gate ctf_id_t ctc_return; /* function return type */ 1617c478bd9Sstevel@tonic-gate uint_t ctc_argc; /* number of typed arguments to function */ 1627c478bd9Sstevel@tonic-gate uint_t ctc_flags; /* function attributes (see below) */ 1637c478bd9Sstevel@tonic-gate } ctf_funcinfo_t; 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate typedef struct ctf_lblinfo { 1667c478bd9Sstevel@tonic-gate ctf_id_t ctb_typeidx; /* last type associated with the label */ 1677c478bd9Sstevel@tonic-gate } ctf_lblinfo_t; 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate #define CTF_FUNC_VARARG 0x1 /* function arguments end with varargs */ 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate /* 1727c478bd9Sstevel@tonic-gate * Functions that return integer status or a ctf_id_t use the following value 1737c478bd9Sstevel@tonic-gate * to indicate failure. ctf_errno() can be used to obtain an error code. 1747c478bd9Sstevel@tonic-gate */ 1757c478bd9Sstevel@tonic-gate #define CTF_ERR (-1L) 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* 1787c478bd9Sstevel@tonic-gate * The CTF data model is inferred to be the caller's data model or the data 1797c478bd9Sstevel@tonic-gate * model of the given object, unless ctf_setmodel() is explicitly called. 1807c478bd9Sstevel@tonic-gate */ 1817c478bd9Sstevel@tonic-gate #define CTF_MODEL_ILP32 1 /* object data model is ILP32 */ 1827c478bd9Sstevel@tonic-gate #define CTF_MODEL_LP64 2 /* object data model is LP64 */ 1837c478bd9Sstevel@tonic-gate #ifdef _LP64 1847c478bd9Sstevel@tonic-gate #define CTF_MODEL_NATIVE CTF_MODEL_LP64 1857c478bd9Sstevel@tonic-gate #else 1867c478bd9Sstevel@tonic-gate #define CTF_MODEL_NATIVE CTF_MODEL_ILP32 1877c478bd9Sstevel@tonic-gate #endif 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate /* 1907c478bd9Sstevel@tonic-gate * Dynamic CTF containers can be created using ctf_create(). The ctf_add_* 1917c478bd9Sstevel@tonic-gate * routines can be used to add new definitions to the dynamic container. 1927c478bd9Sstevel@tonic-gate * New types are labeled as root or non-root to determine whether they are 1937c478bd9Sstevel@tonic-gate * visible at the top-level program scope when subsequently doing a lookup. 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate #define CTF_ADD_NONROOT 0 /* type only visible in nested scope */ 1967c478bd9Sstevel@tonic-gate #define CTF_ADD_ROOT 1 /* type visible at top-level scope */ 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate * These typedefs are used to define the signature for callback functions 2007c478bd9Sstevel@tonic-gate * that can be used with the iteration and visit functions below: 2017c478bd9Sstevel@tonic-gate */ 2027c478bd9Sstevel@tonic-gate typedef int ctf_visit_f(const char *, ctf_id_t, ulong_t, int, void *); 2037c478bd9Sstevel@tonic-gate typedef int ctf_member_f(const char *, ctf_id_t, ulong_t, void *); 2047c478bd9Sstevel@tonic-gate typedef int ctf_enum_f(const char *, int, void *); 205bc1f688bSRobert Mustacchi typedef int ctf_type_f(ctf_id_t, boolean_t, void *); 2067c478bd9Sstevel@tonic-gate typedef int ctf_label_f(const char *, const ctf_lblinfo_t *, void *); 207bc1f688bSRobert Mustacchi typedef int ctf_function_f(const char *, ulong_t, ctf_funcinfo_t *, void *); 208bc1f688bSRobert Mustacchi typedef int ctf_object_f(const char *, ctf_id_t, ulong_t, void *); 209bc1f688bSRobert Mustacchi typedef int ctf_string_f(const char *, void *); 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate extern ctf_file_t *ctf_bufopen(const ctf_sect_t *, const ctf_sect_t *, 2127c478bd9Sstevel@tonic-gate const ctf_sect_t *, int *); 2137c478bd9Sstevel@tonic-gate extern ctf_file_t *ctf_fdopen(int, int *); 2147c478bd9Sstevel@tonic-gate extern ctf_file_t *ctf_open(const char *, int *); 2157c478bd9Sstevel@tonic-gate extern ctf_file_t *ctf_create(int *); 216bc1f688bSRobert Mustacchi extern ctf_file_t *ctf_fdcreate(int, int *); 217a386cc11SRobert Mustacchi extern ctf_file_t *ctf_dup(ctf_file_t *); 2187c478bd9Sstevel@tonic-gate extern void ctf_close(ctf_file_t *); 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate extern ctf_file_t *ctf_parent_file(ctf_file_t *); 2217c478bd9Sstevel@tonic-gate extern const char *ctf_parent_name(ctf_file_t *); 222bc1f688bSRobert Mustacchi extern const char *ctf_parent_label(ctf_file_t *); 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate extern int ctf_import(ctf_file_t *, ctf_file_t *); 2257c478bd9Sstevel@tonic-gate extern int ctf_setmodel(ctf_file_t *, int); 2267c478bd9Sstevel@tonic-gate extern int ctf_getmodel(ctf_file_t *); 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate extern void ctf_setspecific(ctf_file_t *, void *); 2297c478bd9Sstevel@tonic-gate extern void *ctf_getspecific(ctf_file_t *); 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate extern int ctf_errno(ctf_file_t *); 232bc1f688bSRobert Mustacchi extern uint_t ctf_flags(ctf_file_t *); 2337c478bd9Sstevel@tonic-gate extern const char *ctf_errmsg(int); 2347c478bd9Sstevel@tonic-gate extern int ctf_version(int); 2357c478bd9Sstevel@tonic-gate 236bc1f688bSRobert Mustacchi extern ctf_id_t ctf_max_id(ctf_file_t *); 237bc1f688bSRobert Mustacchi extern ulong_t ctf_nr_syms(ctf_file_t *); 238bc1f688bSRobert Mustacchi 2397c478bd9Sstevel@tonic-gate extern int ctf_func_info(ctf_file_t *, ulong_t, ctf_funcinfo_t *); 240bc1f688bSRobert Mustacchi extern int ctf_func_info_by_id(ctf_file_t *, ctf_id_t, ctf_funcinfo_t *); 2417c478bd9Sstevel@tonic-gate extern int ctf_func_args(ctf_file_t *, ulong_t, uint_t, ctf_id_t *); 242bc1f688bSRobert Mustacchi extern int ctf_func_args_by_id(ctf_file_t *, ctf_id_t, uint_t, ctf_id_t *); 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_lookup_by_name(ctf_file_t *, const char *); 2457c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_lookup_by_symbol(ctf_file_t *, ulong_t); 2467c478bd9Sstevel@tonic-gate 247bc1f688bSRobert Mustacchi extern char *ctf_symbol_name(ctf_file_t *, ulong_t, char *, size_t); 248bc1f688bSRobert Mustacchi 2497c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_type_resolve(ctf_file_t *, ctf_id_t); 2507c478bd9Sstevel@tonic-gate extern ssize_t ctf_type_lname(ctf_file_t *, ctf_id_t, char *, size_t); 2517c478bd9Sstevel@tonic-gate extern char *ctf_type_name(ctf_file_t *, ctf_id_t, char *, size_t); 252a386cc11SRobert Mustacchi extern char *ctf_type_qname(ctf_file_t *, ctf_id_t, char *, size_t, 253a386cc11SRobert Mustacchi const char *); 254bc1f688bSRobert Mustacchi extern char *ctf_type_cname(ctf_file_t *, ctf_id_t, char *, size_t, 255bc1f688bSRobert Mustacchi const char *); 2567c478bd9Sstevel@tonic-gate extern ssize_t ctf_type_size(ctf_file_t *, ctf_id_t); 2577c478bd9Sstevel@tonic-gate extern ssize_t ctf_type_align(ctf_file_t *, ctf_id_t); 2587c478bd9Sstevel@tonic-gate extern int ctf_type_kind(ctf_file_t *, ctf_id_t); 259bc1f688bSRobert Mustacchi extern const char *ctf_kind_name(ctf_file_t *, int); 2607c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_type_reference(ctf_file_t *, ctf_id_t); 2617c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_type_pointer(ctf_file_t *, ctf_id_t); 2627c478bd9Sstevel@tonic-gate extern int ctf_type_encoding(ctf_file_t *, ctf_id_t, ctf_encoding_t *); 2637c478bd9Sstevel@tonic-gate extern int ctf_type_visit(ctf_file_t *, ctf_id_t, ctf_visit_f *, void *); 2647c478bd9Sstevel@tonic-gate extern int ctf_type_cmp(ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t); 2657c478bd9Sstevel@tonic-gate extern int ctf_type_compat(ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t); 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate extern int ctf_member_info(ctf_file_t *, ctf_id_t, const char *, 2687c478bd9Sstevel@tonic-gate ctf_membinfo_t *); 2697c478bd9Sstevel@tonic-gate extern int ctf_array_info(ctf_file_t *, ctf_id_t, ctf_arinfo_t *); 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate extern const char *ctf_enum_name(ctf_file_t *, ctf_id_t, int); 2727c478bd9Sstevel@tonic-gate extern int ctf_enum_value(ctf_file_t *, ctf_id_t, const char *, int *); 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate extern const char *ctf_label_topmost(ctf_file_t *); 2757c478bd9Sstevel@tonic-gate extern int ctf_label_info(ctf_file_t *, const char *, ctf_lblinfo_t *); 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate extern int ctf_member_iter(ctf_file_t *, ctf_id_t, ctf_member_f *, void *); 2787c478bd9Sstevel@tonic-gate extern int ctf_enum_iter(ctf_file_t *, ctf_id_t, ctf_enum_f *, void *); 279bc1f688bSRobert Mustacchi extern int ctf_type_iter(ctf_file_t *, boolean_t, ctf_type_f *, void *); 2807c478bd9Sstevel@tonic-gate extern int ctf_label_iter(ctf_file_t *, ctf_label_f *, void *); 281bc1f688bSRobert Mustacchi extern int ctf_function_iter(ctf_file_t *, ctf_function_f *, void *); 282bc1f688bSRobert Mustacchi extern int ctf_object_iter(ctf_file_t *, ctf_object_f *, void *); 283bc1f688bSRobert Mustacchi extern int ctf_string_iter(ctf_file_t *, ctf_string_f *, void *); 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_add_array(ctf_file_t *, uint_t, const ctf_arinfo_t *); 286bc1f688bSRobert Mustacchi extern ctf_id_t ctf_add_const(ctf_file_t *, uint_t, const char *, ctf_id_t); 287*fe2dc8bdSJohn Levon extern ctf_id_t ctf_add_enum(ctf_file_t *, uint_t, const char *, size_t); 2887c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_add_float(ctf_file_t *, uint_t, 2897c478bd9Sstevel@tonic-gate const char *, const ctf_encoding_t *); 2907c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_add_forward(ctf_file_t *, uint_t, const char *, uint_t); 291bc1f688bSRobert Mustacchi extern ctf_id_t ctf_add_funcptr(ctf_file_t *, uint_t, const ctf_funcinfo_t *, 292bc1f688bSRobert Mustacchi const ctf_id_t *); 2937c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_add_integer(ctf_file_t *, uint_t, 2947c478bd9Sstevel@tonic-gate const char *, const ctf_encoding_t *); 295bc1f688bSRobert Mustacchi extern ctf_id_t ctf_add_pointer(ctf_file_t *, uint_t, const char *, ctf_id_t); 2967c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_add_type(ctf_file_t *, ctf_file_t *, ctf_id_t); 2977c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_add_typedef(ctf_file_t *, uint_t, const char *, ctf_id_t); 298bc1f688bSRobert Mustacchi extern ctf_id_t ctf_add_restrict(ctf_file_t *, uint_t, const char *, ctf_id_t); 2997c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_add_struct(ctf_file_t *, uint_t, const char *); 3007c478bd9Sstevel@tonic-gate extern ctf_id_t ctf_add_union(ctf_file_t *, uint_t, const char *); 301bc1f688bSRobert Mustacchi extern ctf_id_t ctf_add_volatile(ctf_file_t *, uint_t, const char *, ctf_id_t); 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate extern int ctf_add_enumerator(ctf_file_t *, ctf_id_t, const char *, int); 304bc1f688bSRobert Mustacchi extern int ctf_add_member(ctf_file_t *, ctf_id_t, const char *, ctf_id_t, 305bc1f688bSRobert Mustacchi ulong_t); 306bc1f688bSRobert Mustacchi 307bc1f688bSRobert Mustacchi 308bc1f688bSRobert Mustacchi extern int ctf_add_function(ctf_file_t *, ulong_t, const ctf_funcinfo_t *, 309bc1f688bSRobert Mustacchi const ctf_id_t *); 310bc1f688bSRobert Mustacchi extern int ctf_add_object(ctf_file_t *, ulong_t, ctf_id_t); 311bc1f688bSRobert Mustacchi extern int ctf_add_label(ctf_file_t *, const char *, ctf_id_t, uint_t); 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate extern int ctf_set_array(ctf_file_t *, ctf_id_t, const ctf_arinfo_t *); 314bc1f688bSRobert Mustacchi extern int ctf_set_root(ctf_file_t *, ctf_id_t, const boolean_t); 315bc1f688bSRobert Mustacchi extern int ctf_set_size(ctf_file_t *, ctf_id_t, const ulong_t); 3167c478bd9Sstevel@tonic-gate 3170a47c91cSRobert Mustacchi extern int ctf_delete_type(ctf_file_t *, ctf_id_t); 3180a47c91cSRobert Mustacchi 3197c478bd9Sstevel@tonic-gate extern int ctf_update(ctf_file_t *); 3207c478bd9Sstevel@tonic-gate extern int ctf_discard(ctf_file_t *); 3217c478bd9Sstevel@tonic-gate extern int ctf_write(ctf_file_t *, int); 322bc1f688bSRobert Mustacchi extern void ctf_dataptr(ctf_file_t *, const void **, size_t *); 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate #ifdef _KERNEL 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate struct module; 3277c478bd9Sstevel@tonic-gate extern ctf_file_t *ctf_modopen(struct module *, int *); 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate #endif 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3327c478bd9Sstevel@tonic-gate } 3337c478bd9Sstevel@tonic-gate #endif 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate #endif /* _CTF_API_H */ 336