1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <ctf_impl.h>
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate static const char *const _ctf_errlist[] = {
32*0Sstevel@tonic-gate "File is not in CTF or ELF format", /* ECTF_FMT */
33*0Sstevel@tonic-gate "File uses more recent ELF version than libctf", /* ECTF_ELFVERS */
34*0Sstevel@tonic-gate "File uses more recent CTF version than libctf", /* ECTF_CTFVERS */
35*0Sstevel@tonic-gate "File is a different endian-ness than libctf", /* ECTF_ENDIAN */
36*0Sstevel@tonic-gate "Symbol table uses invalid entry size", /* ECTF_SYMTAB */
37*0Sstevel@tonic-gate "Symbol table data buffer is not valid", /* ECTF_SYMBAD */
38*0Sstevel@tonic-gate "String table data buffer is not valid", /* ECTF_STRBAD */
39*0Sstevel@tonic-gate "File data structure corruption detected", /* ECTF_CORRUPT */
40*0Sstevel@tonic-gate "File does not contain CTF data", /* ECTF_NOCTFDATA */
41*0Sstevel@tonic-gate "Buffer does not contain CTF data", /* ECTF_NOCTFBUF */
42*0Sstevel@tonic-gate "Symbol table information is not available", /* ECTF_NOSYMTAB */
43*0Sstevel@tonic-gate "Type information is in parent and unavailable", /* ECTF_NOPARENT */
44*0Sstevel@tonic-gate "Cannot import types with different data model", /* ECTF_DMODEL */
45*0Sstevel@tonic-gate "Failed to mmap a needed data section", /* ECTF_MMAP */
46*0Sstevel@tonic-gate "Decompression package SUNWzlib not installed", /* ECTF_ZMISSING */
47*0Sstevel@tonic-gate "Failed to initialize decompression library", /* ECTF_ZINIT */
48*0Sstevel@tonic-gate "Failed to allocate decompression buffer", /* ECTF_ZALLOC */
49*0Sstevel@tonic-gate "Failed to decompress CTF data", /* ECTF_DECOMPRESS */
50*0Sstevel@tonic-gate "External string table is not available", /* ECTF_STRTAB */
51*0Sstevel@tonic-gate "String name offset is corrupt", /* ECTF_BADNAME */
52*0Sstevel@tonic-gate "Invalid type identifier", /* ECTF_BADID */
53*0Sstevel@tonic-gate "Type is not a struct or union", /* ECTF_NOTSOU */
54*0Sstevel@tonic-gate "Type is not an enum", /* ECTF_NOTENUM */
55*0Sstevel@tonic-gate "Type is not a struct, union, or enum", /* ECTF_NOTSUE */
56*0Sstevel@tonic-gate "Type is not an integer or float", /* ECTF_NOTINTFP */
57*0Sstevel@tonic-gate "Type is not an array", /* ECTF_NOTARRAY */
58*0Sstevel@tonic-gate "Type does not reference another type", /* ECTF_NOTREF */
59*0Sstevel@tonic-gate "Input buffer is too small for type name", /* ECTF_NAMELEN */
60*0Sstevel@tonic-gate "No type information available for that name", /* ECTF_NOTYPE */
61*0Sstevel@tonic-gate "Syntax error in type name", /* ECTF_SYNTAX */
62*0Sstevel@tonic-gate "Symbol table entry is not a function", /* ECTF_NOTFUNC */
63*0Sstevel@tonic-gate "No function information available for symbol", /* ECTF_NOFUNCDAT */
64*0Sstevel@tonic-gate "Symbol table entry is not a data object", /* ECTF_NOTDATA */
65*0Sstevel@tonic-gate "No type information available for symbol", /* ECTF_NOTYPEDAT */
66*0Sstevel@tonic-gate "No label information available for that name", /* ECTF_NOLABEL */
67*0Sstevel@tonic-gate "File does not contain any labels", /* ECTF_NOLABELDATA */
68*0Sstevel@tonic-gate "Feature not supported", /* ECTF_NOTSUP */
69*0Sstevel@tonic-gate "Invalid enum element name", /* ECTF_NOENUMNAM */
70*0Sstevel@tonic-gate "Invalid member name", /* ECTF_NOMEMBNAM */
71*0Sstevel@tonic-gate "CTF container is read-only", /* ECTF_RDONLY */
72*0Sstevel@tonic-gate "Limit on number of dynamic type members reached", /* ECTF_DTFULL */
73*0Sstevel@tonic-gate "Limit on number of dynamic types reached", /* ECTF_FULL */
74*0Sstevel@tonic-gate "Duplicate member name definition", /* ECTF_DUPMEMBER */
75*0Sstevel@tonic-gate "Conflicting type is already defined", /* ECTF_CONFLICT */
76*0Sstevel@tonic-gate };
77*0Sstevel@tonic-gate
78*0Sstevel@tonic-gate static const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]);
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gate const char *
ctf_errmsg(int error)81*0Sstevel@tonic-gate ctf_errmsg(int error)
82*0Sstevel@tonic-gate {
83*0Sstevel@tonic-gate const char *str;
84*0Sstevel@tonic-gate
85*0Sstevel@tonic-gate if (error >= ECTF_BASE && (error - ECTF_BASE) < _ctf_nerr)
86*0Sstevel@tonic-gate str = _ctf_errlist[error - ECTF_BASE];
87*0Sstevel@tonic-gate else
88*0Sstevel@tonic-gate str = ctf_strerror(error);
89*0Sstevel@tonic-gate
90*0Sstevel@tonic-gate return (str ? str : "Unknown error");
91*0Sstevel@tonic-gate }
92*0Sstevel@tonic-gate
93*0Sstevel@tonic-gate int
ctf_errno(ctf_file_t * fp)94*0Sstevel@tonic-gate ctf_errno(ctf_file_t *fp)
95*0Sstevel@tonic-gate {
96*0Sstevel@tonic-gate return (fp->ctf_errno);
97*0Sstevel@tonic-gate }
98