1178525Sjb/* 2178525Sjb * CDDL HEADER START 3178525Sjb * 4178525Sjb * The contents of this file are subject to the terms of the 5178525Sjb * Common Development and Distribution License, Version 1.0 only 6178525Sjb * (the "License"). You may not use this file except in compliance 7178525Sjb * with the License. 8178525Sjb * 9178525Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10178525Sjb * or http://www.opensolaris.org/os/licensing. 11178525Sjb * See the License for the specific language governing permissions 12178525Sjb * and limitations under the License. 13178525Sjb * 14178525Sjb * When distributing Covered Code, include this CDDL HEADER in each 15178525Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16178525Sjb * If applicable, add the following below this CDDL HEADER, with the 17178525Sjb * fields enclosed by brackets "[]" replaced with your own identifying 18178525Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 19178525Sjb * 20178525Sjb * CDDL HEADER END 21178525Sjb */ 22178525Sjb/* 23178525Sjb * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24178525Sjb * Use is subject to license terms. 25178525Sjb */ 26254744Sdelphij/* 27254744Sdelphij * Copyright (c) 2012, Joyent, Inc. 28254744Sdelphij */ 29178525Sjb 30178525Sjb#include <ctf_impl.h> 31178525Sjb 32178525Sjbstatic const char *const _ctf_errlist[] = { 33178525Sjb "File is not in CTF or ELF format", /* ECTF_FMT */ 34178525Sjb "File uses more recent ELF version than libctf", /* ECTF_ELFVERS */ 35178525Sjb "File uses more recent CTF version than libctf", /* ECTF_CTFVERS */ 36178525Sjb "File is a different endian-ness than libctf", /* ECTF_ENDIAN */ 37178525Sjb "Symbol table uses invalid entry size", /* ECTF_SYMTAB */ 38178525Sjb "Symbol table data buffer is not valid", /* ECTF_SYMBAD */ 39178525Sjb "String table data buffer is not valid", /* ECTF_STRBAD */ 40178525Sjb "File data structure corruption detected", /* ECTF_CORRUPT */ 41178525Sjb "File does not contain CTF data", /* ECTF_NOCTFDATA */ 42178525Sjb "Buffer does not contain CTF data", /* ECTF_NOCTFBUF */ 43178525Sjb "Symbol table information is not available", /* ECTF_NOSYMTAB */ 44178525Sjb "Type information is in parent and unavailable", /* ECTF_NOPARENT */ 45178525Sjb "Cannot import types with different data model", /* ECTF_DMODEL */ 46178525Sjb "Failed to mmap a needed data section", /* ECTF_MMAP */ 47178525Sjb "Decompression package SUNWzlib not installed", /* ECTF_ZMISSING */ 48178525Sjb "Failed to initialize decompression library", /* ECTF_ZINIT */ 49178525Sjb "Failed to allocate decompression buffer", /* ECTF_ZALLOC */ 50178525Sjb "Failed to decompress CTF data", /* ECTF_DECOMPRESS */ 51178525Sjb "External string table is not available", /* ECTF_STRTAB */ 52178525Sjb "String name offset is corrupt", /* ECTF_BADNAME */ 53178525Sjb "Invalid type identifier", /* ECTF_BADID */ 54178525Sjb "Type is not a struct or union", /* ECTF_NOTSOU */ 55178525Sjb "Type is not an enum", /* ECTF_NOTENUM */ 56178525Sjb "Type is not a struct, union, or enum", /* ECTF_NOTSUE */ 57178525Sjb "Type is not an integer or float", /* ECTF_NOTINTFP */ 58178525Sjb "Type is not an array", /* ECTF_NOTARRAY */ 59178525Sjb "Type does not reference another type", /* ECTF_NOTREF */ 60178525Sjb "Input buffer is too small for type name", /* ECTF_NAMELEN */ 61178525Sjb "No type information available for that name", /* ECTF_NOTYPE */ 62178525Sjb "Syntax error in type name", /* ECTF_SYNTAX */ 63178525Sjb "Symbol table entry is not a function", /* ECTF_NOTFUNC */ 64178525Sjb "No function information available for symbol", /* ECTF_NOFUNCDAT */ 65178525Sjb "Symbol table entry is not a data object", /* ECTF_NOTDATA */ 66178525Sjb "No type information available for symbol", /* ECTF_NOTYPEDAT */ 67178525Sjb "No label information available for that name", /* ECTF_NOLABEL */ 68178525Sjb "File does not contain any labels", /* ECTF_NOLABELDATA */ 69178525Sjb "Feature not supported", /* ECTF_NOTSUP */ 70178525Sjb "Invalid enum element name", /* ECTF_NOENUMNAM */ 71178525Sjb "Invalid member name", /* ECTF_NOMEMBNAM */ 72178525Sjb "CTF container is read-only", /* ECTF_RDONLY */ 73178525Sjb "Limit on number of dynamic type members reached", /* ECTF_DTFULL */ 74178525Sjb "Limit on number of dynamic types reached", /* ECTF_FULL */ 75178525Sjb "Duplicate member name definition", /* ECTF_DUPMEMBER */ 76178525Sjb "Conflicting type is already defined", /* ECTF_CONFLICT */ 77254744Sdelphij "Type has outstanding references", /* ECTF_REFERENCED */ 78254744Sdelphij "Type is not a dynamic type" /* ECTF_NOTDYN */ 79178525Sjb}; 80178525Sjb 81178525Sjbstatic const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]); 82178525Sjb 83178525Sjbconst char * 84178525Sjbctf_errmsg(int error) 85178525Sjb{ 86178525Sjb const char *str; 87178525Sjb 88178525Sjb if (error >= ECTF_BASE && (error - ECTF_BASE) < _ctf_nerr) 89178525Sjb str = _ctf_errlist[error - ECTF_BASE]; 90178525Sjb else 91178525Sjb str = ctf_strerror(error); 92178525Sjb 93178525Sjb return (str ? str : "Unknown error"); 94178525Sjb} 95178525Sjb 96178525Sjbint 97178525Sjbctf_errno(ctf_file_t *fp) 98178525Sjb{ 99178525Sjb return (fp->ctf_errno); 100178525Sjb} 101