Dump object with "-d"
[ctfdump/.git] / ctf.h
CommitLineData
f8621c6a
MP
1/*
2 * Copyright (c) 2016 Martin Pieuchot <mpi@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/*
18 * CTF ``Compact ANSI-C Type Format'' ABI header file.
19 */
20
21struct ctf_header {
22 unsigned short cth_magic;
23 unsigned char cth_version;
24 unsigned char cth_flags;
25 unsigned int cth_parlabel;
26 unsigned int cth_parname;
27 unsigned int cth_lbloff;
28 unsigned int cth_objtoff;
29 unsigned int cth_funcoff;
30 unsigned int cth_typeoff;
31 unsigned int cth_stroff;
32 unsigned int cth_strlen;
33};
34
35#define CTF_F_COMPRESS (1 << 0) /* zlib compression */
36
37struct ctf_lblent {
38 unsigned int ctl_label;
39 unsigned int ctl_typeidx;
40};
41
42struct ctf_stype {
43 unsigned int cts_name;
44 unsigned short cts_info;
45 union {
46 unsigned short _size;
47 unsigned short _type;
48 } _ST;
49#define cts_size _ST._size
50#define cts_type _ST._type
51};
52
53struct ctf_array {
54 unsigned short cta_contents;
55 unsigned short cta_index;
56 unsigned int cta_nelems;
57};
58
59struct ctf_member {
60 unsigned int ctm_name;
61 unsigned short ctm_type;
62 unsigned short ctm_offset;
63};
64
65struct ctf_lmember {
66 struct ctf_member _ctlm_member;
67#define ctlm_name _ctlm_member.ctm_name
68#define ctlm_type _ctlm_member.ctlm_type
69#define ctlm_pad0 _ctlm_member.ctm_offset
70 unsigned int ctlm_offsethi;
71 unsigned int ctlm_offsetlo;
72};
73
74#define CTF_LSTRUCT_THRESH 8192
75
76struct ctf_enum {
77 unsigned int cte_name;
78 int cte_value;
79};
80
81#define CTF_MAGIC 0xcff1
82#define CTF_VERSION 2
83
84#define CTF_MAX_NAME 0x7fffffff
85#define CTF_STRTAB_0 0
86#define CTF_STRTAB_1 1
87
88/*
89 * Name reference macro.
90 */
91#define CTF_NAME_STID(n) ((n) >> 31)
92#define CTF_NAME_OFFSET(n) ((n) & CTF_MAX_NAME)