1*fae548d3Szrj /* Error table.
2*fae548d3Szrj Copyright (C) 2019-2020 Free Software Foundation, Inc.
3*fae548d3Szrj
4*fae548d3Szrj This file is part of libctf.
5*fae548d3Szrj
6*fae548d3Szrj libctf is free software; you can redistribute it and/or modify it under
7*fae548d3Szrj the terms of the GNU General Public License as published by the Free
8*fae548d3Szrj Software Foundation; either version 3, or (at your option) any later
9*fae548d3Szrj version.
10*fae548d3Szrj
11*fae548d3Szrj This program is distributed in the hope that it will be useful, but
12*fae548d3Szrj WITHOUT ANY WARRANTY; without even the implied warranty of
13*fae548d3Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14*fae548d3Szrj See the GNU General Public License for more details.
15*fae548d3Szrj
16*fae548d3Szrj You should have received a copy of the GNU General Public License
17*fae548d3Szrj along with this program; see the file COPYING. If not see
18*fae548d3Szrj <http://www.gnu.org/licenses/>. */
19*fae548d3Szrj
20*fae548d3Szrj #include <ctf-impl.h>
21*fae548d3Szrj
22*fae548d3Szrj static const char *const _ctf_errlist[] = {
23*fae548d3Szrj "File is not in CTF or ELF format", /* ECTF_FMT */
24*fae548d3Szrj "BFD error", /* ECTF_BFDERR */
25*fae548d3Szrj "File uses more recent CTF version than libctf", /* ECTF_CTFVERS */
26*fae548d3Szrj "Ambiguous BFD target", /* ECTF_BFD_AMBIGUOUS */
27*fae548d3Szrj "Symbol table uses invalid entry size", /* ECTF_SYMTAB */
28*fae548d3Szrj "Symbol table data buffer is not valid", /* ECTF_SYMBAD */
29*fae548d3Szrj "String table data buffer is not valid", /* ECTF_STRBAD */
30*fae548d3Szrj "File data structure corruption detected", /* ECTF_CORRUPT */
31*fae548d3Szrj "File does not contain CTF data", /* ECTF_NOCTFDATA */
32*fae548d3Szrj "Buffer does not contain CTF data", /* ECTF_NOCTFBUF */
33*fae548d3Szrj "Symbol table information is not available", /* ECTF_NOSYMTAB */
34*fae548d3Szrj "Type information is in parent and unavailable", /* ECTF_NOPARENT */
35*fae548d3Szrj "Cannot import types with different data model", /* ECTF_DMODEL */
36*fae548d3Szrj "File added to link too late", /* ECTF_LINKADDEDLATE */
37*fae548d3Szrj "Failed to allocate (de)compression buffer", /* ECTF_ZALLOC */
38*fae548d3Szrj "Failed to decompress CTF data", /* ECTF_DECOMPRESS */
39*fae548d3Szrj "External string table is not available", /* ECTF_STRTAB */
40*fae548d3Szrj "String name offset is corrupt", /* ECTF_BADNAME */
41*fae548d3Szrj "Invalid type identifier", /* ECTF_BADID */
42*fae548d3Szrj "Type is not a struct or union", /* ECTF_NOTSOU */
43*fae548d3Szrj "Type is not an enum", /* ECTF_NOTENUM */
44*fae548d3Szrj "Type is not a struct, union, or enum", /* ECTF_NOTSUE */
45*fae548d3Szrj "Type is not an integer, float, or enum", /* ECTF_NOTINTFP */
46*fae548d3Szrj "Type is not an array", /* ECTF_NOTARRAY */
47*fae548d3Szrj "Type does not reference another type", /* ECTF_NOTREF */
48*fae548d3Szrj "Input buffer is too small for type name", /* ECTF_NAMELEN */
49*fae548d3Szrj "No type information available for that name", /* ECTF_NOTYPE */
50*fae548d3Szrj "Syntax error in type name", /* ECTF_SYNTAX */
51*fae548d3Szrj "Symbol table entry or type is not a function", /* ECTF_NOTFUNC */
52*fae548d3Szrj "No function information available for symbol", /* ECTF_NOFUNCDAT */
53*fae548d3Szrj "Symbol table entry is not a data object", /* ECTF_NOTDATA */
54*fae548d3Szrj "No type information available for symbol", /* ECTF_NOTYPEDAT */
55*fae548d3Szrj "No label information available for that name", /* ECTF_NOLABEL */
56*fae548d3Szrj "File does not contain any labels", /* ECTF_NOLABELDATA */
57*fae548d3Szrj "Feature not supported", /* ECTF_NOTSUP */
58*fae548d3Szrj "Invalid enum element name", /* ECTF_NOENUMNAM */
59*fae548d3Szrj "Invalid member name", /* ECTF_NOMEMBNAM */
60*fae548d3Szrj "CTF container is read-only", /* ECTF_RDONLY */
61*fae548d3Szrj "Limit on number of dynamic type members reached", /* ECTF_DTFULL */
62*fae548d3Szrj "Limit on number of dynamic types reached", /* ECTF_FULL */
63*fae548d3Szrj "Duplicate member or variable name", /* ECTF_DUPLICATE */
64*fae548d3Szrj "Conflicting type is already defined", /* ECTF_CONFLICT */
65*fae548d3Szrj "Attempt to roll back past a ctf_update", /* ECTF_OVERROLLBACK */
66*fae548d3Szrj "Failed to compress CTF data", /* ECTF_COMPRESS */
67*fae548d3Szrj "Failed to create CTF archive", /* ECTF_ARCREATE */
68*fae548d3Szrj "Name not found in CTF archive", /* ECTF_ARNNAME */
69*fae548d3Szrj "Overflow of type bitness or offset in slice", /* ECTF_SLICEOVERFLOW */
70*fae548d3Szrj "Unknown section number in dump", /* ECTF_DUMPSECTUNKNOWN */
71*fae548d3Szrj "Section changed in middle of dump", /* ECTF_DUMPSECTCHANGED */
72*fae548d3Szrj "Feature not yet implemented", /* ECTF_NOTYET */
73*fae548d3Szrj "Internal error in link", /* ECTF_INTERNAL */
74*fae548d3Szrj "Type not representable in CTF" /* ECTF_NONREPRESENTABLE */
75*fae548d3Szrj };
76*fae548d3Szrj
77*fae548d3Szrj static const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]);
78*fae548d3Szrj
79*fae548d3Szrj const char *
ctf_errmsg(int error)80*fae548d3Szrj ctf_errmsg (int error)
81*fae548d3Szrj {
82*fae548d3Szrj const char *str;
83*fae548d3Szrj
84*fae548d3Szrj if (error >= ECTF_BASE && (error - ECTF_BASE) < _ctf_nerr)
85*fae548d3Szrj str = _ctf_errlist[error - ECTF_BASE];
86*fae548d3Szrj else
87*fae548d3Szrj str = ctf_strerror (error);
88*fae548d3Szrj
89*fae548d3Szrj return (str ? str : "Unknown error");
90*fae548d3Szrj }
91*fae548d3Szrj
92*fae548d3Szrj int
ctf_errno(ctf_file_t * fp)93*fae548d3Szrj ctf_errno (ctf_file_t * fp)
94*fae548d3Szrj {
95*fae548d3Szrj return fp->ctf_errno;
96*fae548d3Szrj }
97