libctf: error handling
[deliverable/binutils-gdb.git] / include / ctf-api.h
1 /* Public API to libctf.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3
4 This file is part of libctf.
5
6 libctf is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not see
18 <http://www.gnu.org/licenses/>. */
19
20 /* This header file defines the interfaces available from the CTF debugger
21 library, libctf. This API can be used by a debugger to operate on data in
22 the Compact ANSI-C Type Format (CTF). */
23
24 #ifndef _CTF_API_H
25 #define _CTF_API_H
26
27 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <ctf.h>
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /* Clients can open one or more CTF containers and obtain a pointer to an
37 opaque ctf_file_t. Types are identified by an opaque ctf_id_t token.
38 They can also open or create read-only archives of CTF containers in a
39 ctf_archive_t.
40
41 These opaque definitions allow libctf to evolve without breaking clients. */
42
43 typedef struct ctf_file ctf_file_t;
44 typedef struct ctf_archive_internal ctf_archive_t;
45 typedef long ctf_id_t;
46
47 /* Functions that return integer status or a ctf_id_t use the following value
48 to indicate failure. ctf_errno() can be used to obtain an error code. */
49 #define CTF_ERR (-1L)
50
51 #define ECTF_BASE 1000 /* Base value for libctf errnos. */
52
53
54 enum
55 {
56 ECTF_FMT = ECTF_BASE, /* File is not in CTF or ELF format. */
57 ECTF_BFDERR, /* BFD error. */
58 ECTF_CTFVERS, /* CTF version is more recent than libctf. */
59 ECTF_BFD_AMBIGUOUS, /* Ambiguous BFD target. */
60 ECTF_SYMTAB, /* Symbol table uses invalid entry size. */
61 ECTF_SYMBAD, /* Symbol table data buffer invalid. */
62 ECTF_STRBAD, /* String table data buffer invalid. */
63 ECTF_CORRUPT, /* File data corruption detected. */
64 ECTF_NOCTFDATA, /* ELF file does not contain CTF data. */
65 ECTF_NOCTFBUF, /* Buffer does not contain CTF data. */
66 ECTF_NOSYMTAB, /* Symbol table data is not available. */
67 ECTF_NOPARENT, /* Parent CTF container is not available. */
68 ECTF_DMODEL, /* Data model mismatch. */
69 ECTF_UNUSED, /* Unused error. */
70 ECTF_ZALLOC, /* Failed to allocate (de)compression buffer. */
71 ECTF_DECOMPRESS, /* Failed to decompress CTF data. */
72 ECTF_STRTAB, /* String table for this string is missing. */
73 ECTF_BADNAME, /* String offset is corrupt w.r.t. strtab. */
74 ECTF_BADID, /* Invalid type ID number. */
75 ECTF_NOTSOU, /* Type is not a struct or union. */
76 ECTF_NOTENUM, /* Type is not an enum. */
77 ECTF_NOTSUE, /* Type is not a struct, union, or enum. */
78 ECTF_NOTINTFP, /* Type is not an integer, float, or enum. */
79 ECTF_NOTARRAY, /* Type is not an array. */
80 ECTF_NOTREF, /* Type does not reference another type. */
81 ECTF_NAMELEN, /* Buffer is too small to hold type name. */
82 ECTF_NOTYPE, /* No type found corresponding to name. */
83 ECTF_SYNTAX, /* Syntax error in type name. */
84 ECTF_NOTFUNC, /* Symtab entry does not refer to a function. */
85 ECTF_NOFUNCDAT, /* No func info available for function. */
86 ECTF_NOTDATA, /* Symtab entry does not refer to a data obj. */
87 ECTF_NOTYPEDAT, /* No type info available for object. */
88 ECTF_NOLABEL, /* No label found corresponding to name. */
89 ECTF_NOLABELDATA, /* File does not contain any labels. */
90 ECTF_NOTSUP, /* Feature not supported. */
91 ECTF_NOENUMNAM, /* Enum element name not found. */
92 ECTF_NOMEMBNAM, /* Member name not found. */
93 ECTF_RDONLY, /* CTF container is read-only. */
94 ECTF_DTFULL, /* CTF type is full (no more members allowed). */
95 ECTF_FULL, /* CTF container is full. */
96 ECTF_DUPLICATE, /* Duplicate member or variable name. */
97 ECTF_CONFLICT, /* Conflicting type definition present. */
98 ECTF_OVERROLLBACK, /* Attempt to roll back past a ctf_update. */
99 ECTF_COMPRESS, /* Failed to compress CTF data. */
100 ECTF_ARCREATE, /* Error creating CTF archive. */
101 ECTF_ARNNAME, /* Name not found in CTF archive. */
102 ECTF_SLICEOVERFLOW, /* Overflow of type bitness or offset in slice. */
103 ECTF_DUMPSECTUNKNOWN, /* Unknown section number in dump. */
104 ECTF_DUMPSECTCHANGED /* Section changed in middle of dump. */
105 };
106
107 /* The CTF data model is inferred to be the caller's data model or the data
108 model of the given object, unless ctf_setmodel() is explicitly called. */
109 #define CTF_MODEL_ILP32 1 /* Object data model is ILP32. */
110 #define CTF_MODEL_LP64 2 /* Object data model is LP64. */
111 #ifdef _LP64
112 # define CTF_MODEL_NATIVE CTF_MODEL_LP64
113 #else
114 # define CTF_MODEL_NATIVE CTF_MODEL_ILP32
115 #endif
116
117 /* Dynamic CTF containers can be created using ctf_create(). The ctf_add_*
118 routines can be used to add new definitions to the dynamic container.
119 New types are labeled as root or non-root to determine whether they are
120 visible at the top-level program scope when subsequently doing a lookup. */
121
122 #define CTF_ADD_NONROOT 0 /* Type only visible in nested scope. */
123 #define CTF_ADD_ROOT 1 /* Type visible at top-level scope. */
124
125 extern int ctf_errno (ctf_file_t *);
126 extern const char *ctf_errmsg (int);
127
128 extern void ctf_setdebug (int debug);
129 extern int ctf_getdebug (void);
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* _CTF_API_H */
This page took 0.03687 seconds and 4 git commands to generate.