00001 /* 00002 * Copyright 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000,2002,2004 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2.1 of the GNU Lesser General Public License 00011 as published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU Lesser General Public 00025 License along with this program; if not, write the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00027 USA. 00028 00029 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, 00030 Mountain View, CA 94043, or: 00031 00032 http://www.sgi.com 00033 00034 For further information regarding this notice, see: 00035 00036 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00037 00038 */ 00039 00040 00041 00042 #include "config.h" 00043 #include "libdwarfdefs.h" 00044 #ifdef HAVE_ELF_H 00045 #include <elf.h> 00046 #endif 00047 00048 #include <stdio.h> 00049 #include <sys/stat.h> 00050 #include <sys/types.h> 00051 #include <stdlib.h> 00052 #include "pro_incl.h" 00053 00054 extern char *_dwarf_errmsgs[]; 00055 00056 /* 00057 This function performs error handling as described in the 00058 libdwarf consumer document section 3. Dbg is the Dwarf_P_debug 00059 structure being processed. Error is a pointer to the pointer 00060 to the error descriptor that will be returned. Errval is an 00061 error code listed in dwarf_error.h. 00062 */ 00063 void 00064 _dwarf_p_error(Dwarf_P_Debug dbg, 00065 Dwarf_Error * error, Dwarf_Word errval) 00066 { 00067 Dwarf_Error errptr; 00068 00069 /* Allow NULL dbg on entry, since sometimes that can happen and we 00070 want to report the upper-level error, not this one. */ 00071 if ((Dwarf_Sword) errval < 0) 00072 printf("ERROR VALUE: %ld - %s\n", 00073 (long) errval, _dwarf_errmsgs[-errval - 1]); 00074 if (error != NULL) { 00075 errptr = (Dwarf_Error) 00076 _dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_Error_s)); 00077 if (errptr == NULL) { 00078 fprintf(stderr, 00079 "Could not allocate Dwarf_Error structure\n"); 00080 abort(); 00081 } 00082 errptr->er_errval = (Dwarf_Sword) errval; 00083 *error = errptr; 00084 return; 00085 } 00086 00087 if (dbg != NULL && dbg->de_errhand != NULL) { 00088 errptr = (Dwarf_Error) 00089 _dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_Error_s)); 00090 if (errptr == NULL) { 00091 fprintf(stderr, 00092 "Could not allocate Dwarf_Error structure\n"); 00093 abort(); 00094 } 00095 errptr->er_errval = (Dwarf_Sword) errval; 00096 dbg->de_errhand(errptr, dbg->de_errarg); 00097 return; 00098 } 00099 00100 abort(); 00101 }
1.5.6