7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26 /*
27 * Copyright (c) 2015, Joyent, Inc.
28 */
29
30 #include <ctf_impl.h>
31
32 static const char *const _ctf_errlist[] = {
33 "File is not in CTF or ELF format", /* ECTF_FMT */
34 "File uses more recent ELF version than libctf", /* ECTF_ELFVERS */
35 "File uses more recent CTF version than libctf", /* ECTF_CTFVERS */
36 "File is a different endian-ness than libctf", /* ECTF_ENDIAN */
37 "Symbol table uses invalid entry size", /* ECTF_SYMTAB */
38 "Symbol table data buffer is not valid", /* ECTF_SYMBAD */
39 "String table data buffer is not valid", /* ECTF_STRBAD */
40 "File data structure corruption detected", /* ECTF_CORRUPT */
41 "File does not contain CTF data", /* ECTF_NOCTFDATA */
42 "Buffer does not contain CTF data", /* ECTF_NOCTFBUF */
43 "Symbol table information is not available", /* ECTF_NOSYMTAB */
44 "Type information is in parent and unavailable", /* ECTF_NOPARENT */
45 "Cannot import types with different data model", /* ECTF_DMODEL */
46 "Failed to mmap a needed data section", /* ECTF_MMAP */
47 "Decompression package SUNWzlib not installed", /* ECTF_ZMISSING */
66 "No type information available for symbol", /* ECTF_NOTYPEDAT */
67 "No label information available for that name", /* ECTF_NOLABEL */
68 "File does not contain any labels", /* ECTF_NOLABELDATA */
69 "Feature not supported", /* ECTF_NOTSUP */
70 "Invalid enum element name", /* ECTF_NOENUMNAM */
71 "Invalid member name", /* ECTF_NOMEMBNAM */
72 "CTF container is read-only", /* ECTF_RDONLY */
73 "Limit on number of dynamic type members reached", /* ECTF_DTFULL */
74 "Limit on number of dynamic types reached", /* ECTF_FULL */
75 "Duplicate member name definition", /* ECTF_DUPMEMBER */
76 "Conflicting type is already defined", /* ECTF_CONFLICT */
77 "Type has outstanding references", /* ECTF_REFERENCED */
78 "Type is not a dynamic type", /* ECTF_NOTDYN */
79 "Elf library failure", /* ECTF_ELF */
80 "Cannot merge child container", /* ECTF_MCHILD */
81 "Label already exists", /* ECTF_LABEL */
82 "Merged labels conflict", /* ECTF_LCONFLICT */
83 "Zlib library failure", /* ECTF_ZLIB */
84 "CTF conversion backend error", /* ECTF_CONVBKERR */
85 "No C source to convert from", /* ECTF_CONVNOCSRC */
86 "No applicable conversion backend" /* ECTF_NOCONVBKEND */
87 };
88
89 static const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]);
90
91 const char *
92 ctf_errmsg(int error)
93 {
94 const char *str;
95
96 if (error >= ECTF_BASE && (error - ECTF_BASE) < _ctf_nerr)
97 str = _ctf_errlist[error - ECTF_BASE];
98 else
99 str = ctf_strerror(error);
100
101 return (str ? str : "Unknown error");
102 }
103
104 int
105 ctf_errno(ctf_file_t *fp)
106 {
|
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26 /*
27 * Copyright (c) 2019, Joyent, Inc.
28 */
29
30 #include <ctf_impl.h>
31
32 static const char *const _ctf_errlist[] = {
33 "File is not in CTF or ELF format", /* ECTF_FMT */
34 "File uses more recent ELF version than libctf", /* ECTF_ELFVERS */
35 "File uses more recent CTF version than libctf", /* ECTF_CTFVERS */
36 "File is a different endian-ness than libctf", /* ECTF_ENDIAN */
37 "Symbol table uses invalid entry size", /* ECTF_SYMTAB */
38 "Symbol table data buffer is not valid", /* ECTF_SYMBAD */
39 "String table data buffer is not valid", /* ECTF_STRBAD */
40 "File data structure corruption detected", /* ECTF_CORRUPT */
41 "File does not contain CTF data", /* ECTF_NOCTFDATA */
42 "Buffer does not contain CTF data", /* ECTF_NOCTFBUF */
43 "Symbol table information is not available", /* ECTF_NOSYMTAB */
44 "Type information is in parent and unavailable", /* ECTF_NOPARENT */
45 "Cannot import types with different data model", /* ECTF_DMODEL */
46 "Failed to mmap a needed data section", /* ECTF_MMAP */
47 "Decompression package SUNWzlib not installed", /* ECTF_ZMISSING */
66 "No type information available for symbol", /* ECTF_NOTYPEDAT */
67 "No label information available for that name", /* ECTF_NOLABEL */
68 "File does not contain any labels", /* ECTF_NOLABELDATA */
69 "Feature not supported", /* ECTF_NOTSUP */
70 "Invalid enum element name", /* ECTF_NOENUMNAM */
71 "Invalid member name", /* ECTF_NOMEMBNAM */
72 "CTF container is read-only", /* ECTF_RDONLY */
73 "Limit on number of dynamic type members reached", /* ECTF_DTFULL */
74 "Limit on number of dynamic types reached", /* ECTF_FULL */
75 "Duplicate member name definition", /* ECTF_DUPMEMBER */
76 "Conflicting type is already defined", /* ECTF_CONFLICT */
77 "Type has outstanding references", /* ECTF_REFERENCED */
78 "Type is not a dynamic type", /* ECTF_NOTDYN */
79 "Elf library failure", /* ECTF_ELF */
80 "Cannot merge child container", /* ECTF_MCHILD */
81 "Label already exists", /* ECTF_LABEL */
82 "Merged labels conflict", /* ECTF_LCONFLICT */
83 "Zlib library failure", /* ECTF_ZLIB */
84 "CTF conversion backend error", /* ECTF_CONVBKERR */
85 "No C source to convert from", /* ECTF_CONVNOCSRC */
86 "No debug info found to convert from" /* ECTF_CONVNODEBUG */
87 };
88
89 static const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]);
90
91 const char *
92 ctf_errmsg(int error)
93 {
94 const char *str;
95
96 if (error >= ECTF_BASE && (error - ECTF_BASE) < _ctf_nerr)
97 str = _ctf_errlist[error - ECTF_BASE];
98 else
99 str = ctf_strerror(error);
100
101 return (str ? str : "Unknown error");
102 }
103
104 int
105 ctf_errno(ctf_file_t *fp)
106 {
|