#ifndef _CTF_API_H
#define _CTF_API_H
#pragma ident "@(#)ctf_api.h 1.4 05/06/08 SMI"
#include <sys/types.h>
#include <sys/param.h>
#if defined(__LP64__)
#if !defined(_LP64)
#define _LP64
#endif
#else
#if !defined(_ILP32)
#define _ILP32
#endif
#endif
#ifdef KERNEL
#ifndef _KERNEL
#define _KERNEL
#endif
#endif
#if defined(__BIG_ENDIAN__)
#if !defined(_BIG_ENDIAN)
#define _BIG_ENDIAN
#endif
#elif defined(__LITTLE_ENDIAN__)
#if !defined(_LITTLE_ENDIAN)
#define _LITTLE_ENDIAN
#endif
#else
#error Unknown endian-ness
#endif
#include "elf.h"
#include "ctf.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ctf_file ctf_file_t;
typedef long ctf_id_t;
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, void *);
typedef int ctf_label_f(const char *, const ctf_lblinfo_t *, 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 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 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 const char *ctf_errmsg(int);
extern int ctf_version(int);
extern int ctf_func_info(ctf_file_t *, ulong_t, ctf_funcinfo_t *);
extern int ctf_func_args(ctf_file_t *, ulong_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 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 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 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_type_printf_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 *, ctf_type_f *, void *);
extern int ctf_label_iter(ctf_file_t *, ctf_label_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, ctf_id_t);
extern ctf_id_t ctf_add_enum(ctf_file_t *, uint_t, const char *);
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_function(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, 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, 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, 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);
extern int ctf_set_array(ctf_file_t *, ctf_id_t, const ctf_arinfo_t *);
extern int ctf_update(ctf_file_t *);
extern int ctf_discard(ctf_file_t *);
extern int ctf_write(ctf_file_t *, int);
#ifdef _KERNEL
struct module;
extern ctf_file_t *ctf_modopen(struct module *, int *);
#endif
#ifdef __cplusplus
}
#endif
#endif