ctf_impl.h revision e083a0c2c99cea982dcf8e12ec3452cc575b5663
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _CTF_IMPL_H
#define _CTF_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#ifdef _KERNEL
#define isspace(c) \
((c) == ' ' || (c) == '\t' || (c) == '\n' || \
(c) == '\r' || (c) == '\f' || (c) == '\v')
#define MAP_FAILED ((void *)-1)
#else /* _KERNEL */
#include <strings.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <limits.h>
#include <ctype.h>
#endif /* _KERNEL */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ctf_helem {
} ctf_helem_t;
typedef struct ctf_hash {
} ctf_hash_t;
typedef struct ctf_strs {
const char *cts_strs; /* base address of string table */
} ctf_strs_t;
typedef struct ctf_dmodel {
const char *ctd_name; /* data model name */
int ctd_code; /* data model code */
} ctf_dmodel_t;
typedef struct ctf_lookup {
const char *ctl_prefix; /* string prefix for this lookup */
} ctf_lookup_t;
typedef struct ctf_fileops {
typedef struct ctf_list {
} ctf_list_t;
typedef enum {
typedef struct ctf_decl_node {
typedef struct ctf_decl {
char *cd_buf; /* buffer for output */
char *cd_ptr; /* buffer location */
char *cd_end; /* buffer limit */
int cd_err; /* saved error value */
} ctf_decl_t;
typedef struct ctf_dmdef {
char *dmd_name; /* name of this member */
int dmd_value; /* value of this member (for enum) */
} ctf_dmdef_t;
typedef struct ctf_dtdef {
char *dtd_name; /* name associated with definition (if any) */
union {
} dtd_u;
} ctf_dtdef_t;
typedef struct ctf_bundle {
} ctf_bundle_t;
/*
* The ctf_file is the structure used to represent a CTF container to library
* clients, who see it only as an opaque pointer. Modifications can therefore
* be made freely to this structure without regard to client versioning. The
*
* NOTE: ctf_update() requires that everything inside of ctf_file either be an
* immediate value, a pointer to dynamically allocated data *outside* of the
* ctf_file itself, or a pointer to statically allocated data. If you add a
* pointer to ctf_file that points to something within the ctf_file itself,
* you must make corresponding changes to ctf_update().
*/
struct ctf_file {
const char *ctf_parlabel; /* label in parent container (if any) */
const char *ctf_parname; /* basename of parent (if any) */
int ctf_errno; /* error code for most recent error */
int ctf_version; /* CTF data version */
void *ctf_specific; /* data for ctf_get/setspecific */
};
#define LCTF_INDEX_TO_TYPEPTR(fp, i) \
enum {
ECTF_ELFVERS, /* ELF version is more recent than libctf */
ECTF_CTFVERS, /* CTF version is more recent than libctf */
ECTF_ENDIAN, /* data is different endian-ness than lib */
ECTF_SYMTAB, /* symbol table uses invalid entry size */
ECTF_SYMBAD, /* symbol table data buffer invalid */
ECTF_STRBAD, /* string table data buffer invalid */
ECTF_CORRUPT, /* file data corruption detected */
ECTF_NOCTFDATA, /* ELF file does not contain CTF data */
ECTF_NOCTFBUF, /* buffer does not contain CTF data */
ECTF_NOSYMTAB, /* symbol table data is not available */
ECTF_NOPARENT, /* parent CTF container is not available */
ECTF_DMODEL, /* data model mismatch */
ECTF_MMAP, /* failed to mmap a data section */
ECTF_ZMISSING, /* decompression library not installed */
ECTF_ZINIT, /* failed to initialize decompression library */
ECTF_ZALLOC, /* failed to allocate decompression buffer */
ECTF_DECOMPRESS, /* failed to decompress CTF data */
ECTF_STRTAB, /* string table for this string is missing */
ECTF_BADNAME, /* string offset is corrupt w.r.t. strtab */
ECTF_BADID, /* invalid type ID number */
ECTF_NOTSOU, /* type is not a struct or union */
ECTF_NOTENUM, /* type is not an enum */
ECTF_NOTSUE, /* type is not a struct, union, or enum */
ECTF_NOTINTFP, /* type is not an integer or float */
ECTF_NOTARRAY, /* type is not an array */
ECTF_NOTREF, /* type does not reference another type */
ECTF_NAMELEN, /* buffer is too small to hold type name */
ECTF_NOTYPE, /* no type found corresponding to name */
ECTF_SYNTAX, /* syntax error in type name */
ECTF_NOTFUNC, /* symtab entry does not refer to a function */
ECTF_NOFUNCDAT, /* no func info available for function */
ECTF_NOTDATA, /* symtab entry does not refer to a data obj */
ECTF_NOTYPEDAT, /* no type info available for object */
ECTF_NOLABEL, /* no label found corresponding to name */
ECTF_NOLABELDATA, /* file does not contain any labels */
ECTF_NOTSUP, /* feature not supported */
ECTF_NOENUMNAM, /* enum element name not found */
ECTF_NOMEMBNAM, /* member name not found */
ECTF_RDONLY, /* CTF container is read-only */
ECTF_DTFULL, /* CTF type is full (no more members allowed) */
ECTF_FULL, /* CTF container is full */
ECTF_DUPMEMBER, /* duplicate member name definition */
ECTF_CONFLICT /* conflicting type definition present */
};
const char *, size_t);
extern void ctf_hash_destroy(ctf_hash_t *);
extern void ctf_list_append(ctf_list_t *, void *);
extern void ctf_list_prepend(ctf_list_t *, void *);
extern void ctf_list_delete(ctf_list_t *, void *);
extern void ctf_decl_fini(ctf_decl_t *);
extern void ctf_decl_sprintf(ctf_decl_t *, const char *, ...);
extern ctf_file_t *ctf_set_open_errno(int *, int);
extern long ctf_set_errno(ctf_file_t *, int);
extern const void *ctf_sect_mmap(ctf_sect_t *, int);
extern void ctf_sect_munmap(const ctf_sect_t *);
extern void *ctf_data_alloc(size_t);
extern void ctf_data_free(void *, size_t);
extern void ctf_data_protect(void *, size_t);
extern char *ctf_strdup(const char *);
extern const char *ctf_strerror(int);
extern void ctf_dprintf(const char *, ...);
extern void *ctf_zopen(int *);
extern const char _CTF_SECTION[]; /* name of CTF ELF section */
extern const char _CTF_NULLSTR[]; /* empty string */
extern int _libctf_version; /* library client version */
extern int _libctf_debug; /* debugging messages enabled */
#ifdef __cplusplus
}
#endif
#endif /* _CTF_IMPL_H */