|
1 /* |
|
2 |
|
3 Copyright (C) 2000,2002,2004 Silicon Graphics, Inc. All Rights Reserved. |
|
4 |
|
5 This program is free software; you can redistribute it and/or modify it |
|
6 under the terms of version 2.1 of the GNU Lesser General Public License |
|
7 as published by the Free Software Foundation. |
|
8 |
|
9 This program is distributed in the hope that it would be useful, but |
|
10 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
12 |
|
13 Further, this software is distributed without any warranty that it is |
|
14 free of the rightful claim of any third person regarding infringement |
|
15 or the like. Any license provided herein, whether implied or |
|
16 otherwise, applies only to this software file. Patent licenses, if |
|
17 any, provided herein do not apply to combinations of this program with |
|
18 other software, or any other product whatsoever. |
|
19 |
|
20 You should have received a copy of the GNU Lesser General Public |
|
21 License along with this program; if not, write the Free Software |
|
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, |
|
23 USA. |
|
24 |
|
25 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, |
|
26 Mountain View, CA 94043, or: |
|
27 |
|
28 http://www.sgi.com |
|
29 |
|
30 For further information regarding this notice, see: |
|
31 |
|
32 http://oss.sgi.com/projects/GenInfo/NoticeExplan |
|
33 |
|
34 */ |
|
35 |
|
36 |
|
37 |
|
38 #include "config.h" |
|
39 #include "libdwarfdefs.h" |
|
40 #ifdef HAVE_ELF_H |
|
41 #include <elf.h> |
|
42 #endif |
|
43 |
|
44 #include <stdio.h> |
|
45 #include <sys/stat.h> |
|
46 #include <sys/types.h> |
|
47 #include <stdlib.h> |
|
48 #include "pro_incl.h" |
|
49 |
|
50 extern char *_dwarf_errmsgs[]; |
|
51 |
|
52 /* |
|
53 This function performs error handling as described in the |
|
54 libdwarf consumer document section 3. Dbg is the Dwarf_P_debug |
|
55 structure being processed. Error is a pointer to the pointer |
|
56 to the error descriptor that will be returned. Errval is an |
|
57 error code listed in dwarf_error.h. |
|
58 */ |
|
59 void |
|
60 _dwarf_p_error(Dwarf_P_Debug dbg, |
|
61 Dwarf_Error * error, Dwarf_Word errval) |
|
62 { |
|
63 Dwarf_Error errptr; |
|
64 |
|
65 /* Allow NULL dbg on entry, since sometimes that can happen and we |
|
66 want to report the upper-level error, not this one. */ |
|
67 if ((Dwarf_Sword) errval < 0) |
|
68 printf("ERROR VALUE: %ld - %s\n", |
|
69 (long) errval, _dwarf_errmsgs[-errval - 1]); |
|
70 if (error != NULL) { |
|
71 errptr = (Dwarf_Error) |
|
72 _dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_Error_s)); |
|
73 if (errptr == NULL) { |
|
74 fprintf(stderr, |
|
75 "Could not allocate Dwarf_Error structure\n"); |
|
76 abort(); |
|
77 } |
|
78 errptr->er_errval = (Dwarf_Sword) errval; |
|
79 *error = errptr; |
|
80 return; |
|
81 } |
|
82 |
|
83 if (dbg != NULL && dbg->de_errhand != NULL) { |
|
84 errptr = (Dwarf_Error) |
|
85 _dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_Error_s)); |
|
86 if (errptr == NULL) { |
|
87 fprintf(stderr, |
|
88 "Could not allocate Dwarf_Error structure\n"); |
|
89 abort(); |
|
90 } |
|
91 errptr->er_errval = (Dwarf_Sword) errval; |
|
92 dbg->de_errhand(errptr, dbg->de_errarg); |
|
93 return; |
|
94 } |
|
95 |
|
96 abort(); |
|
97 } |