e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync/*
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * CDDL HEADER START
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync *
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * The contents of this file are subject to the terms of the
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Common Development and Distribution License, Version 1.0 only
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * (the "License"). You may not use this file except in compliance
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * with the License.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync *
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * or http://www.opensolaris.org/os/licensing.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * See the License for the specific language governing permissions
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * and limitations under the License.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync *
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * When distributing Covered Code, include this CDDL HEADER in each
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * If applicable, add the following below this CDDL HEADER, with the
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * fields enclosed by brackets "[]" replaced with your own identifying
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync *
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * CDDL HEADER END
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync/*
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Use is subject to license terms.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync
d11c725a6a076f607c240f98ff03ca3166b581c9vboxsync#ifndef VBOX
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync#pragma ident "%Z%%M% %I% %E% SMI"
d11c725a6a076f607c240f98ff03ca3166b581c9vboxsync#endif
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync#include <ctf_impl.h>
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncstatic const char *const _ctf_errlist[] = {
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "File is not in CTF or ELF format", /* ECTF_FMT */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "File uses more recent ELF version than libctf", /* ECTF_ELFVERS */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "File uses more recent CTF version than libctf", /* ECTF_CTFVERS */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "File is a different endian-ness than libctf", /* ECTF_ENDIAN */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Symbol table uses invalid entry size", /* ECTF_SYMTAB */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Symbol table data buffer is not valid", /* ECTF_SYMBAD */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "String table data buffer is not valid", /* ECTF_STRBAD */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "File data structure corruption detected", /* ECTF_CORRUPT */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "File does not contain CTF data", /* ECTF_NOCTFDATA */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Buffer does not contain CTF data", /* ECTF_NOCTFBUF */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Symbol table information is not available", /* ECTF_NOSYMTAB */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Type information is in parent and unavailable", /* ECTF_NOPARENT */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Cannot import types with different data model", /* ECTF_DMODEL */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Failed to mmap a needed data section", /* ECTF_MMAP */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Decompression package SUNWzlib not installed", /* ECTF_ZMISSING */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Failed to initialize decompression library", /* ECTF_ZINIT */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Failed to allocate decompression buffer", /* ECTF_ZALLOC */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Failed to decompress CTF data", /* ECTF_DECOMPRESS */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "External string table is not available", /* ECTF_STRTAB */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "String name offset is corrupt", /* ECTF_BADNAME */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Invalid type identifier", /* ECTF_BADID */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Type is not a struct or union", /* ECTF_NOTSOU */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Type is not an enum", /* ECTF_NOTENUM */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Type is not a struct, union, or enum", /* ECTF_NOTSUE */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Type is not an integer or float", /* ECTF_NOTINTFP */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Type is not an array", /* ECTF_NOTARRAY */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Type does not reference another type", /* ECTF_NOTREF */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Input buffer is too small for type name", /* ECTF_NAMELEN */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "No type information available for that name", /* ECTF_NOTYPE */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Syntax error in type name", /* ECTF_SYNTAX */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Symbol table entry is not a function", /* ECTF_NOTFUNC */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "No function information available for symbol", /* ECTF_NOFUNCDAT */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Symbol table entry is not a data object", /* ECTF_NOTDATA */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "No type information available for symbol", /* ECTF_NOTYPEDAT */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "No label information available for that name", /* ECTF_NOLABEL */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "File does not contain any labels", /* ECTF_NOLABELDATA */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Feature not supported", /* ECTF_NOTSUP */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Invalid enum element name", /* ECTF_NOENUMNAM */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Invalid member name", /* ECTF_NOMEMBNAM */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "CTF container is read-only", /* ECTF_RDONLY */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Limit on number of dynamic type members reached", /* ECTF_DTFULL */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Limit on number of dynamic types reached", /* ECTF_FULL */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Duplicate member name definition", /* ECTF_DUPMEMBER */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "Conflicting type is already defined", /* ECTF_CONFLICT */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync};
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncstatic const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncconst char *
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncctf_errmsg(int error)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync{
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync const char *str;
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync if (error >= ECTF_BASE && (error - ECTF_BASE) < _ctf_nerr)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync str = _ctf_errlist[error - ECTF_BASE];
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync else
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync str = ctf_strerror(error);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync return (str ? str : "Unknown error");
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync}
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncint
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncctf_errno(ctf_file_t *fp)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync{
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync return (fp->ctf_errno);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync}