1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
/* $OpenBSD: db_ctf.h,v 1.1 2016/09/16 19:13:17 jasper Exp $ */
/*
* Copyright (c) 2016 Martin Pieuchot <mpi@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _DDB_DB_CTF_H_
#define _DDB_DB_CTF_H_
/*
* CTF ``Compact ANSI-C Type Format'' ABI header file.
*/
struct ctf_header {
unsigned short cth_magic;
unsigned char cth_version;
unsigned char cth_flags;
unsigned int cth_parlabel;
unsigned int cth_parname;
unsigned int cth_lbloff;
unsigned int cth_objtoff;
unsigned int cth_funcoff;
unsigned int cth_typeoff;
unsigned int cth_stroff;
unsigned int cth_strlen;
};
#define CTF_F_COMPRESS (1 << 0) /* zlib compression */
struct ctf_lblent {
unsigned int ctl_label;
unsigned int ctl_typeidx;
};
struct ctf_stype {
unsigned int cts_name;
unsigned short cts_info;
union {
unsigned short _size;
unsigned short _type;
} _ST;
#define cts_size _ST._size
#define cts_type _ST._type
};
struct ctf_type {
struct ctf_stype _ctt_stype;
#define ctt_name _ctt_stype.cts_name
#define ctt_info _ctt_stype.cts_info
#define ctt_size _ctt_stype.cts_size
#define ctt_type _ctt_stype.cts_type
unsigned int ctt_lsizehi;
unsigned int ctt_lsizelo;
};
struct ctf_array {
unsigned short cta_contents;
unsigned short cta_index;
unsigned int cta_nelems;
};
struct ctf_member {
unsigned int ctm_name;
unsigned short ctm_type;
unsigned short ctm_offset;
};
struct ctf_lmember {
struct ctf_member _ctlm_member;
#define ctlm_name _ctlm_member.ctm_name
#define ctlm_type _ctlm_member.ctm_type
#define ctlm_pad0 _ctlm_member.ctm_offset
unsigned int ctlm_offsethi;
unsigned int ctlm_offsetlo;
};
#define CTF_LSTRUCT_THRESH 8192
struct ctf_enum {
unsigned int cte_name;
int cte_value;
};
#define CTF_MAGIC 0xcff1
#define CTF_VERSION 2
#define CTF_MAX_NAME 0x7fffffff
#define CTF_MAX_VLEN 0x03ff
#define CTF_MAX_SIZE 0xfffe
#define CTF_STRTAB_0 0
#define CTF_STRTAB_1 1
/*
* Info macro.
*/
#define CTF_INFO_VLEN(i) (((i) & CTF_MAX_VLEN))
#define CTF_INFO_ISROOT(i) (((i) & 0x0400) >> 10)
#define CTF_INFO_KIND(i) (((i) & 0xf800) >> 11)
#define CTF_K_UNKNOWN 0
#define CTF_K_INTEGER 1
#define CTF_K_FLOAT 2
#define CTF_K_POINTER 3
#define CTF_K_ARRAY 4
#define CTF_K_FUNCTION 5
#define CTF_K_STRUCT 6
#define CTF_K_UNION 7
#define CTF_K_ENUM 8
#define CTF_K_FORWARD 9
#define CTF_K_TYPEDEF 10
#define CTF_K_VOLATILE 11
#define CTF_K_CONST 12
#define CTF_K_RESTRICT 13
#define CTF_K_MAX 31
/*
* Integer/Float Encoding macro.
*/
#define _CTF_ENCODING(e) (((e) & 0xff000000) >> 24)
#define _CTF_OFFSET(e) (((e) & 0x00ff0000) >> 16)
#define _CTF_BITS(e) (((e) & 0x0000ffff))
#define CTF_INT_ENCODING(e) _CTF_ENCODING(e)
#define CTF_INT_SIGNED (1 << 0)
#define CTF_INT_CHAR (1 << 1)
#define CTF_INT_BOOL (1 << 2)
#define CTF_INT_VARARGS (1 << 3)
#define CTF_INT_OFFSET(e) _CTF_OFFSET(e)
#define CTF_INT_BITS(e) _CTF_BITS(e)
#define CTF_FP_ENCODING(e) _CTF_ENCODING(e)
#define CTF_FP_SINGLE 1
#define CTF_FP_DOUBLE 2
#define CTF_FP_CPLX 3
#define CTF_FP_DCPLX 4
#define CTF_FP_LDCPLX 5
#define CTF_FP_LDOUBLE 6
#define CTF_FP_INTRVL 7
#define CTF_FP_DINTRVL 8
#define CTF_FP_LDINTRVL 9
#define CTF_FP_IMAGRY 10
#define CTF_FP_DIMAGRY 11
#define CTF_FP_LDIMAGRY 12
#define CTF_FP_OFFSET(e) _CTF_OFFSET(e)
#define CTF_FP_BITS(e) _CTF_BITS(e)
/*
* Name reference macro.
*/
#define CTF_NAME_STID(n) ((n) >> 31)
#define CTF_NAME_OFFSET(n) ((n) & CTF_MAX_NAME)
/*
* Type macro.
*/
#define CTF_SIZE_TO_LSIZE_HI(s) ((uint32_t)((uint64_t)(s) >> 32))
#define CTF_SIZE_TO_LSIZE_LO(s) ((uint32_t)(s))
#define CTF_TYPE_LSIZE(t) \
(((uint64_t)(t)->ctt_lsizehi) << 32 | (t)->ctt_lsizelo)
/*
* Member macro.
*/
#define CTF_LMEM_OFFSET(m) \
(((uint64_t)(m)->ctlm_offsethi) << 32 | (m)->ctlm_offsetlo)
#endif /* _DDB_DB_CTF_H_ */
|