ctf.h revision dfd08267d2958ae1cd559dd7dc2f36bf5461648d
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _CTF_H
#define _CTF_H
#ifndef VBOX
# pragma ident "%Z%%M% %I% %E% SMI"
#endif
#ifndef VBOX
#else
# include "VBoxDTraceTypes.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* CTF - Compact ANSI-C Type Format
*
* This file format can be used to compactly represent the information needed
* by a debugger to interpret the ANSI-C types used by a given program.
* Traditionally, this kind of information is generated by the compiler when
* invoked with the -g flag and is stored in "stabs" strings or in the more
* modern DWARF format. CTF provides a representation of only the information
* that is relevant to debugging a complex, optimized C program such as the
* operating system kernel in a form that is significantly more compact than
* the equivalent stabs or DWARF representation. The format is data-model
* independent, so consumers do not need different code depending on whether
* they are 32-bit or 64-bit programs. CTF assumes that a standard ELF symbol
* table is available for use in the debugger, and uses the structure and data
* of the symbol table to avoid storing redundant information. The CTF data
* may be compressed on disk or in memory, indicated by a bit in the header.
* CTF may be interpreted in a raw disk file, or it may be stored in an ELF
* section, typically named .SUNW_ctf. Data structures are aligned so that
* a raw CTF file or CTF ELF section may be manipulated using mmap(2).
*
* The CTF file or section itself has the following structure:
*
* +--------+--------+---------+----------+-------+--------+
* | file | type | data | function | data | string |
* | header | labels | objects | info | types | table |
* +--------+--------+---------+----------+-------+--------+
*
* The file header stores a magic number and version information, encoding
* flags, and the byte offset of each of the sections relative to the end of the
* header itself. If the CTF data has been uniquified against another set of
* CTF data, a reference to that data also appears in the the header. This
* reference is the name of the label corresponding to the types uniquified
* against.
*
* Following the header is a list of labels, used to group the types included in
* the data types section. Each label is accompanied by a type ID i. A given
* label refers to the group of types whose IDs are in the range [0, i].
*
* Data object and function records are stored in the same order as they appear
* in the corresponding symbol table, except that symbols marked SHN_UNDEF are
* not stored and symbols that have no type data are padded out with zeroes.
* For each data object, the type ID (a small integer) is recorded. For each
* function, the type ID of the return type and argument types is recorded.
*
* The data types section is a list of variable size records that represent each
* type, in order by their ID. The types themselves form a directed graph,
* where each node may contain one or more outgoing edges to other type nodes,
* denoted by their ID.
*
* Strings are recorded as a string table ID (0 or 1) and a byte offset into the
* string table. String table 0 is the internal CTF string table. String table
* 1 is the external string table, which is the string table associated with the
* ELF symbol table for this object. CTF does not record any strings that are
* already in the symbol table, and the CTF string table does not contain any
* duplicated strings.
*
* If the CTF data has been merged with another parent CTF object, some outgoing
* edges may refer to type nodes that exist in another CTF object. The debugger
* and libctf library are responsible for connecting the appropriate objects
* together so that the full set of types can be explored and manipulated.
*/
/* See ctf_type_t */
#define CTF_MAX_LSIZE UINT64_MAX
typedef struct ctf_preamble {
typedef struct ctf_header {
} ctf_header_t;
#ifdef CTF_OLD_VERSIONS
typedef struct ctf_header_v1 {
#endif /* CTF_OLD_VERSIONS */
/* data format version number */
#define CTF_VERSION_1 1
#define CTF_VERSION_2 2
typedef struct ctf_lblent {
} ctf_lblent_t;
typedef struct ctf_stype {
union {
} _u;
} ctf_stype_t;
/*
* type sizes, measured in bytes, come in two flavors. 99% of them fit within
* (USHRT_MAX - 1), and thus can be stored in the ctt_size member of a
* ctf_stype_t. The maximum value for these sizes is CTF_MAX_SIZE. The sizes
* larger than CTF_MAX_SIZE must be stored in the ctt_lsize member of a
* ctf_type_t. Use of this member is indicated by the presence of
* CTF_LSIZE_SENT in ctt_size.
*/
typedef struct ctf_type {
union {
} _u;
} ctf_type_t;
/*
* The following macros compose and decompose values for ctt_info and
* ctt_name, as well as other structures that contain name references.
*
* ------------------------
* ctt_info: | kind | isroot | vlen |
* ------------------------
* 15 11 10 9 0
*
* kind = CTF_INFO_KIND(c.ctt_info); <-- CTF_K_* value (see below)
* vlen = CTF_INFO_VLEN(c.ctt_info); <-- length of variable data list
*
* stid = CTF_NAME_STID(c.ctt_name); <-- string table id number (0 or 1)
* offset = CTF_NAME_OFFSET(c.ctt_name); <-- string table byte offset
*
* c.ctt_info = CTF_TYPE_INFO(kind, vlen);
* c.ctt_name = CTF_TYPE_NAME(stid, offset);
*/
#define CTF_PARENT_SHIFT 15
#define CTF_STRTAB_0 0 /* symbolic define for string table id 0 */
#define CTF_TYPE_LSIZE(cttp) \
#ifdef CTF_OLD_VERSIONS
#endif /* CTF_OLD_VERSIONS */
/*
* Values for CTF_TYPE_KIND(). If the kind has an associated data list,
* CTF_INFO_VLEN() will extract the number of elements in the list, and
* the type of each element is shown in the comments below.
*/
#define CTF_K_UNKNOWN 0 /* unknown type (used for padding) */
/* list of argument types (ushort_t's) */
/*
* Values for ctt_type when kind is CTF_K_INTEGER. The flags, offset in bits,
* and size in bits are encoded as a single word using the following macros.
*/
/*
* Values for ctt_type when kind is CTF_K_FLOAT. The encoding, offset in bits,
* and size in bits are encoded as a single word using the following macros.
*/
typedef struct ctf_array {
} ctf_array_t;
/*
* Most structure members have bit offsets that can be expressed using a
* short. Some don't. ctf_member_t is used for structs which cannot
* contain any of these large offsets, whereas ctf_lmember_t is used in the
* latter case. If ctt_size for a given struct is >= 8192 bytes, all members
* will be stored as type ctf_lmember_t.
*/
#define CTF_LSTRUCT_THRESH 8192
typedef struct ctf_member {
} ctf_member_t;
typedef struct ctf_lmember {
#define CTF_LMEM_OFFSET(ctlmp) \
typedef struct ctf_enum {
int cte_value; /* value associated with this name */
} ctf_enum_t;
#ifdef __cplusplus
}
#endif
#endif /* _CTF_H */