xref: /illumos-gate/usr/src/lib/libdwarf/common/dwarf_error.h (revision 7b34a9a5df26271af0da06974fc361c468cd48d3)
1 /*
2 
3   Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved.
4   Portions Copyright (C) 2011 David Anderson. All Rights Reserved.
5 
6   This program is free software; you can redistribute it and/or modify it
7   under the terms of version 2.1 of the GNU Lesser General Public License
8   as published by the Free Software Foundation.
9 
10   This program is distributed in the hope that it would be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14   Further, this software is distributed without any warranty that it is
15   free of the rightful claim of any third person regarding infringement
16   or the like.  Any license provided herein, whether implied or
17   otherwise, applies only to this software file.  Patent licenses, if
18   any, provided herein do not apply to combinations of this program with
19   other software, or any other product whatsoever.
20 
21   You should have received a copy of the GNU Lesser General Public
22   License along with this program; if not, write the Free Software
23   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
24   USA.
25 
26 */
27 
28 #ifndef DWARF_ERROR_H
29 #define DWARF_ERROR_H
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33 
34 void _dwarf_error(Dwarf_Debug dbg, Dwarf_Error * error,
35     Dwarf_Signed errval);
36 void _dwarf_error_string(Dwarf_Debug dbg, Dwarf_Error * error,
37     Dwarf_Signed errval, char *msg);
38 
39 #define DE_STANDARD 0 /* Normal alloc attached to dbg. */
40 #define DE_STATIC 1   /* Using global static var */
41 #define DE_MALLOC 2   /* Using malloc space */
42 struct Dwarf_Error_s {
43     Dwarf_Signed er_errval;
44     void       * er_msg;
45 
46     /*  If non-zero the Dwarf_Error_s struct is not malloc'd.
47         To aid when malloc returns NULL.
48         If zero a normal dwarf_dealloc will work.
49         er_static_alloc only accessed by dwarf_alloc.c.
50 
51         If er_static_alloc is 1 in a Dwarf_Error_s
52         struct (set by libdwarf) and client code accidentally
53         turns that 0 to zero through a wild
54         pointer reference (the field is hidden
55         from clients...) then chaos will
56         eventually follow.
57     */
58     int er_static_alloc;
59 };
60 extern struct Dwarf_Error_s _dwarf_failsafe_error;
61 
62 #ifdef __cplusplus
63 }
64 #endif /* __cplusplus */
65 #endif /* DWARF_ERROR_H */
66