1 /* Error table. 2 Copyright (C) 2019-2020 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 #include <ctf-impl.h> 21 22 static const char *const _ctf_errlist[] = { 23 "File is not in CTF or ELF format", /* ECTF_FMT */ 24 "BFD error", /* ECTF_BFDERR */ 25 "File uses more recent CTF version than libctf", /* ECTF_CTFVERS */ 26 "Ambiguous BFD target", /* ECTF_BFD_AMBIGUOUS */ 27 "Symbol table uses invalid entry size", /* ECTF_SYMTAB */ 28 "Symbol table data buffer is not valid", /* ECTF_SYMBAD */ 29 "String table data buffer is not valid", /* ECTF_STRBAD */ 30 "File data structure corruption detected", /* ECTF_CORRUPT */ 31 "File does not contain CTF data", /* ECTF_NOCTFDATA */ 32 "Buffer does not contain CTF data", /* ECTF_NOCTFBUF */ 33 "Symbol table information is not available", /* ECTF_NOSYMTAB */ 34 "Type information is in parent and unavailable", /* ECTF_NOPARENT */ 35 "Cannot import types with different data model", /* ECTF_DMODEL */ 36 "File added to link too late", /* ECTF_LINKADDEDLATE */ 37 "Failed to allocate (de)compression buffer", /* ECTF_ZALLOC */ 38 "Failed to decompress CTF data", /* ECTF_DECOMPRESS */ 39 "External string table is not available", /* ECTF_STRTAB */ 40 "String name offset is corrupt", /* ECTF_BADNAME */ 41 "Invalid type identifier", /* ECTF_BADID */ 42 "Type is not a struct or union", /* ECTF_NOTSOU */ 43 "Type is not an enum", /* ECTF_NOTENUM */ 44 "Type is not a struct, union, or enum", /* ECTF_NOTSUE */ 45 "Type is not an integer, float, or enum", /* ECTF_NOTINTFP */ 46 "Type is not an array", /* ECTF_NOTARRAY */ 47 "Type does not reference another type", /* ECTF_NOTREF */ 48 "Input buffer is too small for type name", /* ECTF_NAMELEN */ 49 "No type information available for that name", /* ECTF_NOTYPE */ 50 "Syntax error in type name", /* ECTF_SYNTAX */ 51 "Symbol table entry or type is not a function", /* ECTF_NOTFUNC */ 52 "No function information available for symbol", /* ECTF_NOFUNCDAT */ 53 "Symbol table entry is not a data object", /* ECTF_NOTDATA */ 54 "No type information available for symbol", /* ECTF_NOTYPEDAT */ 55 "No label information available for that name", /* ECTF_NOLABEL */ 56 "File does not contain any labels", /* ECTF_NOLABELDATA */ 57 "Feature not supported", /* ECTF_NOTSUP */ 58 "Invalid enum element name", /* ECTF_NOENUMNAM */ 59 "Invalid member name", /* ECTF_NOMEMBNAM */ 60 "CTF container is read-only", /* ECTF_RDONLY */ 61 "Limit on number of dynamic type members reached", /* ECTF_DTFULL */ 62 "Limit on number of dynamic types reached", /* ECTF_FULL */ 63 "Duplicate member or variable name", /* ECTF_DUPLICATE */ 64 "Conflicting type is already defined", /* ECTF_CONFLICT */ 65 "Attempt to roll back past a ctf_update", /* ECTF_OVERROLLBACK */ 66 "Failed to compress CTF data", /* ECTF_COMPRESS */ 67 "Failed to create CTF archive", /* ECTF_ARCREATE */ 68 "Name not found in CTF archive", /* ECTF_ARNNAME */ 69 "Overflow of type bitness or offset in slice", /* ECTF_SLICEOVERFLOW */ 70 "Unknown section number in dump", /* ECTF_DUMPSECTUNKNOWN */ 71 "Section changed in middle of dump", /* ECTF_DUMPSECTCHANGED */ 72 "Feature not yet implemented", /* ECTF_NOTYET */ 73 "Internal error in link", /* ECTF_INTERNAL */ 74 "Type not representable in CTF" /* ECTF_NONREPRESENTABLE */ 75 }; 76 77 static const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]); 78 79 const char * 80 ctf_errmsg (int error) 81 { 82 const char *str; 83 84 if (error >= ECTF_BASE && (error - ECTF_BASE) < _ctf_nerr) 85 str = _ctf_errlist[error - ECTF_BASE]; 86 else 87 str = ctf_strerror (error); 88 89 return (str ? str : "Unknown error"); 90 } 91 92 int 93 ctf_errno (ctf_file_t * fp) 94 { 95 return fp->ctf_errno; 96 } 97