#ifndef _CTF_API_H
#define _CTF_API_H
#include <sys/types.h>
#include <sys/param.h>
#include <sys/elf.h>
#include <sys/ctf.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ctf_file ctf_file_t;
typedef long ctf_id_t;
#define ECTF_BASE 1000
enum {
ECTF_FMT = ECTF_BASE,
ECTF_ELFVERS,
ECTF_CTFVERS,
ECTF_ENDIAN,
ECTF_SYMTAB,
ECTF_SYMBAD,
ECTF_STRBAD,
ECTF_CORRUPT,
ECTF_NOCTFDATA,
ECTF_NOCTFBUF,
ECTF_NOSYMTAB,
ECTF_NOPARENT,
ECTF_DMODEL,
ECTF_MMAP,
ECTF_ZMISSING,
ECTF_ZINIT,
ECTF_ZALLOC,
ECTF_DECOMPRESS,
ECTF_STRTAB,
ECTF_BADNAME,
ECTF_BADID,
ECTF_NOTSOU,
ECTF_NOTENUM,
ECTF_NOTSUE,
ECTF_NOTINTFP,
ECTF_NOTARRAY,
ECTF_NOTREF,
ECTF_NAMELEN,
ECTF_NOTYPE,
ECTF_SYNTAX,
ECTF_NOTFUNC,
ECTF_NOFUNCDAT,
ECTF_NOTDATA,
ECTF_NOTYPEDAT,
ECTF_NOLABEL,
ECTF_NOLABELDATA,
ECTF_NOTSUP,
ECTF_NOENUMNAM,
ECTF_NOMEMBNAM,
ECTF_RDONLY,
ECTF_DTFULL,
ECTF_FULL,
ECTF_DUPMEMBER,
ECTF_CONFLICT,
ECTF_REFERENCED,
ECTF_NOTDYN,
ECTF_ELF,
ECTF_MCHILD,
ECTF_LABELEXISTS,
ECTF_LCONFLICT,
ECTF_ZLIB,
ECTF_CONVBKERR,
ECTF_CONVNOCSRC,
ECTF_CONVNODEBUG
};
typedef struct ctf_sect {
const char *cts_name;
ulong_t cts_type;
ulong_t cts_flags;
const void *cts_data;
size_t cts_size;
size_t cts_entsize;
off64_t cts_offset;
} ctf_sect_t;
typedef struct ctf_encoding {
uint_t cte_format;
uint_t cte_offset;
uint_t cte_bits;
} ctf_encoding_t;
typedef struct ctf_membinfo {
ctf_id_t ctm_type;
ulong_t ctm_offset;
} ctf_membinfo_t;
typedef struct ctf_arinfo {
ctf_id_t ctr_contents;
ctf_id_t ctr_index;
uint_t ctr_nelems;
} ctf_arinfo_t;
typedef struct ctf_funcinfo {
ctf_id_t ctc_return;
uint_t ctc_argc;
uint_t ctc_flags;
} ctf_funcinfo_t;
typedef struct ctf_lblinfo {
ctf_id_t ctb_typeidx;
} ctf_lblinfo_t;
#define CTF_FUNC_VARARG 0x1
#define CTF_ERR (-1L)
#define CTF_MODEL_ILP32 1
#define CTF_MODEL_LP64 2
#ifdef _LP64
#define CTF_MODEL_NATIVE CTF_MODEL_LP64
#else
#define CTF_MODEL_NATIVE CTF_MODEL_ILP32
#endif
#define CTF_ADD_NONROOT 0
#define CTF_ADD_ROOT 1
typedef int ctf_visit_f(const char *, ctf_id_t, ulong_t, int, void *);
typedef int ctf_member_f(const char *, ctf_id_t, ulong_t, void *);
typedef int ctf_enum_f(const char *, int, void *);
typedef int ctf_type_f(ctf_id_t, boolean_t, void *);
typedef int ctf_label_f(const char *, const ctf_lblinfo_t *, void *);
typedef int ctf_function_f(const char *, ulong_t, ctf_funcinfo_t *, void *);
typedef int ctf_object_f(const char *, ctf_id_t, ulong_t, void *);
typedef int ctf_string_f(const char *, void *);
extern ctf_file_t *ctf_bufopen(const ctf_sect_t *, const ctf_sect_t *,
const ctf_sect_t *, int *);
extern ctf_file_t *ctf_fdopen(int, int *);
extern ctf_file_t *ctf_open(const char *, int *);
extern ctf_file_t *ctf_create(int *);
extern ctf_file_t *ctf_fdcreate(int, int *);
extern ctf_file_t *ctf_dup(ctf_file_t *);
extern void ctf_close(ctf_file_t *);
extern ctf_file_t *ctf_parent_file(ctf_file_t *);
extern const char *ctf_parent_name(ctf_file_t *);
extern const char *ctf_parent_label(ctf_file_t *);
extern int ctf_import(ctf_file_t *, ctf_file_t *);
extern int ctf_setmodel(ctf_file_t *, int);
extern int ctf_getmodel(ctf_file_t *);
extern void ctf_setspecific(ctf_file_t *, void *);
extern void *ctf_getspecific(ctf_file_t *);
extern int ctf_errno(ctf_file_t *);
extern uint_t ctf_flags(ctf_file_t *);
extern const char *ctf_errmsg(int);
extern int ctf_version(int);
extern ctf_id_t ctf_max_id(ctf_file_t *);
extern ulong_t ctf_nr_syms(ctf_file_t *);
extern int ctf_func_info(ctf_file_t *, ulong_t, ctf_funcinfo_t *);
extern int ctf_func_info_by_id(ctf_file_t *, ctf_id_t, ctf_funcinfo_t *);
extern int ctf_func_args(ctf_file_t *, ulong_t, uint_t, ctf_id_t *);
extern int ctf_func_args_by_id(ctf_file_t *, ctf_id_t, uint_t, ctf_id_t *);
extern ctf_id_t ctf_lookup_by_name(ctf_file_t *, const char *);
extern ctf_id_t ctf_lookup_by_symbol(ctf_file_t *, ulong_t);
extern char *ctf_symbol_name(ctf_file_t *, ulong_t, char *, size_t);
extern ctf_id_t ctf_type_resolve(ctf_file_t *, ctf_id_t);
extern ssize_t ctf_type_lname(ctf_file_t *, ctf_id_t, char *, size_t);
extern char *ctf_type_name(ctf_file_t *, ctf_id_t, char *, size_t);
extern char *ctf_type_qname(ctf_file_t *, ctf_id_t, char *, size_t,
const char *);
extern char *ctf_type_cname(ctf_file_t *, ctf_id_t, char *, size_t,
const char *);
extern ssize_t ctf_type_size(ctf_file_t *, ctf_id_t);
extern ssize_t ctf_type_align(ctf_file_t *, ctf_id_t);
extern int ctf_type_kind(ctf_file_t *, ctf_id_t);
extern const char *ctf_kind_name(ctf_file_t *, int);
extern ctf_id_t ctf_type_reference(ctf_file_t *, ctf_id_t);
extern ctf_id_t ctf_type_pointer(ctf_file_t *, ctf_id_t);
extern int ctf_type_encoding(ctf_file_t *, ctf_id_t, ctf_encoding_t *);
extern int ctf_type_visit(ctf_file_t *, ctf_id_t, ctf_visit_f *, void *);
extern int ctf_type_cmp(ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t);
extern int ctf_type_compat(ctf_file_t *, ctf_id_t, ctf_file_t *, ctf_id_t);
extern int ctf_member_info(ctf_file_t *, ctf_id_t, const char *,
ctf_membinfo_t *);
extern int ctf_array_info(ctf_file_t *, ctf_id_t, ctf_arinfo_t *);
extern const char *ctf_enum_name(ctf_file_t *, ctf_id_t, int);
extern int ctf_enum_value(ctf_file_t *, ctf_id_t, const char *, int *);
extern const char *ctf_label_topmost(ctf_file_t *);
extern int ctf_label_info(ctf_file_t *, const char *, ctf_lblinfo_t *);
extern int ctf_member_iter(ctf_file_t *, ctf_id_t, ctf_member_f *, void *);
extern int ctf_enum_iter(ctf_file_t *, ctf_id_t, ctf_enum_f *, void *);
extern int ctf_type_iter(ctf_file_t *, boolean_t, ctf_type_f *, void *);
extern int ctf_label_iter(ctf_file_t *, ctf_label_f *, void *);
extern int ctf_function_iter(ctf_file_t *, ctf_function_f *, void *);
extern int ctf_object_iter(ctf_file_t *, ctf_object_f *, void *);
extern int ctf_string_iter(ctf_file_t *, ctf_string_f *, void *);
extern ctf_id_t ctf_add_array(ctf_file_t *, uint_t, const ctf_arinfo_t *);
extern ctf_id_t ctf_add_const(ctf_file_t *, uint_t, const char *, ctf_id_t);
extern ctf_id_t ctf_add_enum(ctf_file_t *, uint_t, const char *, size_t);
extern ctf_id_t ctf_add_float(ctf_file_t *, uint_t,
const char *, const ctf_encoding_t *);
extern ctf_id_t ctf_add_forward(ctf_file_t *, uint_t, const char *, uint_t);
extern ctf_id_t ctf_add_funcptr(ctf_file_t *, uint_t, const ctf_funcinfo_t *,
const ctf_id_t *);
extern ctf_id_t ctf_add_integer(ctf_file_t *, uint_t,
const char *, const ctf_encoding_t *);
extern ctf_id_t ctf_add_pointer(ctf_file_t *, uint_t, const char *, ctf_id_t);
extern ctf_id_t ctf_add_type(ctf_file_t *, ctf_file_t *, ctf_id_t);
extern ctf_id_t ctf_add_typedef(ctf_file_t *, uint_t, const char *, ctf_id_t);
extern ctf_id_t ctf_add_restrict(ctf_file_t *, uint_t, const char *, ctf_id_t);
extern ctf_id_t ctf_add_struct(ctf_file_t *, uint_t, const char *);
extern ctf_id_t ctf_add_union(ctf_file_t *, uint_t, const char *);
extern ctf_id_t ctf_add_volatile(ctf_file_t *, uint_t, const char *, ctf_id_t);
extern int ctf_add_enumerator(ctf_file_t *, ctf_id_t, const char *, int);
extern int ctf_add_member(ctf_file_t *, ctf_id_t, const char *, ctf_id_t,
ulong_t);
extern int ctf_add_function(ctf_file_t *, ulong_t, const ctf_funcinfo_t *,
const ctf_id_t *);
extern int ctf_add_object(ctf_file_t *, ulong_t, ctf_id_t);
extern int ctf_add_label(ctf_file_t *, const char *, ctf_id_t, uint_t);
extern int ctf_set_array(ctf_file_t *, ctf_id_t, const ctf_arinfo_t *);
extern int ctf_set_root(ctf_file_t *, ctf_id_t, const boolean_t);
extern int ctf_set_size(ctf_file_t *, ctf_id_t, const ulong_t);
extern int ctf_delete_type(ctf_file_t *, ctf_id_t);
extern int ctf_update(ctf_file_t *);
extern int ctf_discard(ctf_file_t *);
extern int ctf_write(ctf_file_t *, int);
extern void ctf_dataptr(ctf_file_t *, const void **, size_t *);
#ifdef _KERNEL
struct module;
extern ctf_file_t *ctf_modopen(struct module *, int *);
#endif
#ifdef __cplusplus
}
#endif
#endif