rdwarf 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +28 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/ext/rdwarf/depend +5 -0
- data/ext/rdwarf/extconf.rb +29 -0
- data/ext/rdwarf/libdwarf/CHANGES +102 -0
- data/ext/rdwarf/libdwarf/CODINGSTYLE +71 -0
- data/ext/rdwarf/libdwarf/COPYING +28 -0
- data/ext/rdwarf/libdwarf/ChangeLog +619 -0
- data/ext/rdwarf/libdwarf/ChangeLog2006 +835 -0
- data/ext/rdwarf/libdwarf/ChangeLog2007 +217 -0
- data/ext/rdwarf/libdwarf/ChangeLog2008 +263 -0
- data/ext/rdwarf/libdwarf/ChangeLog2009 +348 -0
- data/ext/rdwarf/libdwarf/ChangeLog2010 +175 -0
- data/ext/rdwarf/libdwarf/ChangeLog2011 +297 -0
- data/ext/rdwarf/libdwarf/ChangeLog2012 +131 -0
- data/ext/rdwarf/libdwarf/ChangeLog2013 +238 -0
- data/ext/rdwarf/libdwarf/ChangeLog2014 +399 -0
- data/ext/rdwarf/libdwarf/LGPL.txt +504 -0
- data/ext/rdwarf/libdwarf/LIBDWARFCOPYRIGHT +40 -0
- data/ext/rdwarf/libdwarf/Makefile.in +220 -0
- data/ext/rdwarf/libdwarf/NEWS +535 -0
- data/ext/rdwarf/libdwarf/README +235 -0
- data/ext/rdwarf/libdwarf/checkexamples.c +1179 -0
- data/ext/rdwarf/libdwarf/cmplrs/dwarf_addr_finder.h +55 -0
- data/ext/rdwarf/libdwarf/common.c +62 -0
- data/ext/rdwarf/libdwarf/common.h +38 -0
- data/ext/rdwarf/libdwarf/config.h.in +146 -0
- data/ext/rdwarf/libdwarf/configure +5581 -0
- data/ext/rdwarf/libdwarf/configure.in +167 -0
- data/ext/rdwarf/libdwarf/dw-linetableheader.txt +39 -0
- data/ext/rdwarf/libdwarf/dwarf.h +1342 -0
- data/ext/rdwarf/libdwarf/dwarf_abbrev.c +291 -0
- data/ext/rdwarf/libdwarf/dwarf_abbrev.h +45 -0
- data/ext/rdwarf/libdwarf/dwarf_addr_finder.c +676 -0
- data/ext/rdwarf/libdwarf/dwarf_alloc.c +685 -0
- data/ext/rdwarf/libdwarf/dwarf_alloc.h +38 -0
- data/ext/rdwarf/libdwarf/dwarf_arange.c +595 -0
- data/ext/rdwarf/libdwarf/dwarf_arange.h +62 -0
- data/ext/rdwarf/libdwarf/dwarf_base_types.h +157 -0
- data/ext/rdwarf/libdwarf/dwarf_die_deliv.c +1802 -0
- data/ext/rdwarf/libdwarf/dwarf_die_deliv.h +46 -0
- data/ext/rdwarf/libdwarf/dwarf_elf_access.c +1348 -0
- data/ext/rdwarf/libdwarf/dwarf_elf_access.h +46 -0
- data/ext/rdwarf/libdwarf/dwarf_error.c +492 -0
- data/ext/rdwarf/libdwarf/dwarf_error.h +53 -0
- data/ext/rdwarf/libdwarf/dwarf_form.c +1302 -0
- data/ext/rdwarf/libdwarf/dwarf_frame.c +2454 -0
- data/ext/rdwarf/libdwarf/dwarf_frame.h +418 -0
- data/ext/rdwarf/libdwarf/dwarf_frame2.c +1533 -0
- data/ext/rdwarf/libdwarf/dwarf_frame3.c +282 -0
- data/ext/rdwarf/libdwarf/dwarf_funcs.c +123 -0
- data/ext/rdwarf/libdwarf/dwarf_funcs.h +33 -0
- data/ext/rdwarf/libdwarf/dwarf_gdbindex.c +520 -0
- data/ext/rdwarf/libdwarf/dwarf_gdbindex.h +97 -0
- data/ext/rdwarf/libdwarf/dwarf_global.c +612 -0
- data/ext/rdwarf/libdwarf/dwarf_global.h +117 -0
- data/ext/rdwarf/libdwarf/dwarf_harmless.c +228 -0
- data/ext/rdwarf/libdwarf/dwarf_harmless.h +31 -0
- data/ext/rdwarf/libdwarf/dwarf_incl.h +61 -0
- data/ext/rdwarf/libdwarf/dwarf_init_finish.c +1263 -0
- data/ext/rdwarf/libdwarf/dwarf_leb.c +159 -0
- data/ext/rdwarf/libdwarf/dwarf_line.c +1822 -0
- data/ext/rdwarf/libdwarf/dwarf_line.h +446 -0
- data/ext/rdwarf/libdwarf/dwarf_line2.c +98 -0
- data/ext/rdwarf/libdwarf/dwarf_line_table_reader_common.c +1583 -0
- data/ext/rdwarf/libdwarf/dwarf_loc.c +1525 -0
- data/ext/rdwarf/libdwarf/dwarf_loc.h +149 -0
- data/ext/rdwarf/libdwarf/dwarf_loc2.c +833 -0
- data/ext/rdwarf/libdwarf/dwarf_macro.c +479 -0
- data/ext/rdwarf/libdwarf/dwarf_macro.h +35 -0
- data/ext/rdwarf/libdwarf/dwarf_opaque.h +778 -0
- data/ext/rdwarf/libdwarf/dwarf_original_elf_init.c +219 -0
- data/ext/rdwarf/libdwarf/dwarf_print_lines.c +631 -0
- data/ext/rdwarf/libdwarf/dwarf_pubtypes.c +132 -0
- data/ext/rdwarf/libdwarf/dwarf_query.c +1594 -0
- data/ext/rdwarf/libdwarf/dwarf_ranges.c +194 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_arm.h +308 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_mips.h +117 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_ppc.h +242 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_ppc64.h +272 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_x86_64.h +127 -0
- data/ext/rdwarf/libdwarf/dwarf_sort_line.c +665 -0
- data/ext/rdwarf/libdwarf/dwarf_string.c +82 -0
- data/ext/rdwarf/libdwarf/dwarf_stubs.c +38 -0
- data/ext/rdwarf/libdwarf/dwarf_tied.c +423 -0
- data/ext/rdwarf/libdwarf/dwarf_tsearch.h +125 -0
- data/ext/rdwarf/libdwarf/dwarf_tsearchhash.c +675 -0
- data/ext/rdwarf/libdwarf/dwarf_types.c +121 -0
- data/ext/rdwarf/libdwarf/dwarf_types.h +32 -0
- data/ext/rdwarf/libdwarf/dwarf_util.c +913 -0
- data/ext/rdwarf/libdwarf/dwarf_util.h +324 -0
- data/ext/rdwarf/libdwarf/dwarf_vars.c +125 -0
- data/ext/rdwarf/libdwarf/dwarf_vars.h +29 -0
- data/ext/rdwarf/libdwarf/dwarf_weaks.c +123 -0
- data/ext/rdwarf/libdwarf/dwarf_weaks.h +29 -0
- data/ext/rdwarf/libdwarf/dwarf_xu_index.c +579 -0
- data/ext/rdwarf/libdwarf/dwarf_xu_index.h +68 -0
- data/ext/rdwarf/libdwarf/dwgetopt.c +181 -0
- data/ext/rdwarf/libdwarf/dwgetopt.h +51 -0
- data/ext/rdwarf/libdwarf/gennames.c +531 -0
- data/ext/rdwarf/libdwarf/install.sh +119 -0
- data/ext/rdwarf/libdwarf/libdwarf.h.in +3746 -0
- data/ext/rdwarf/libdwarf/libdwarf2.1.mm +9805 -0
- data/ext/rdwarf/libdwarf/libdwarf2.1.pdf +0 -0
- data/ext/rdwarf/libdwarf/libdwarf2p.1.mm +2807 -0
- data/ext/rdwarf/libdwarf/libdwarf2p.1.pdf +0 -0
- data/ext/rdwarf/libdwarf/libdwarfdefs.h +81 -0
- data/ext/rdwarf/libdwarf/malloc_check.c +327 -0
- data/ext/rdwarf/libdwarf/malloc_check.h +52 -0
- data/ext/rdwarf/libdwarf/mips_extensions.mm +1266 -0
- data/ext/rdwarf/libdwarf/mips_extensions.pdf +0 -0
- data/ext/rdwarf/libdwarf/pro_alloc.c +179 -0
- data/ext/rdwarf/libdwarf/pro_alloc.h +33 -0
- data/ext/rdwarf/libdwarf/pro_arange.c +310 -0
- data/ext/rdwarf/libdwarf/pro_arange.h +51 -0
- data/ext/rdwarf/libdwarf/pro_die.c +431 -0
- data/ext/rdwarf/libdwarf/pro_die.h +59 -0
- data/ext/rdwarf/libdwarf/pro_encode_nm.c +108 -0
- data/ext/rdwarf/libdwarf/pro_encode_nm.h +39 -0
- data/ext/rdwarf/libdwarf/pro_error.c +96 -0
- data/ext/rdwarf/libdwarf/pro_error.h +43 -0
- data/ext/rdwarf/libdwarf/pro_expr.c +575 -0
- data/ext/rdwarf/libdwarf/pro_expr.h +36 -0
- data/ext/rdwarf/libdwarf/pro_finish.c +45 -0
- data/ext/rdwarf/libdwarf/pro_forms.c +1271 -0
- data/ext/rdwarf/libdwarf/pro_frame.c +572 -0
- data/ext/rdwarf/libdwarf/pro_frame.h +120 -0
- data/ext/rdwarf/libdwarf/pro_funcs.c +50 -0
- data/ext/rdwarf/libdwarf/pro_incl.h +91 -0
- data/ext/rdwarf/libdwarf/pro_init.c +327 -0
- data/ext/rdwarf/libdwarf/pro_line.c +373 -0
- data/ext/rdwarf/libdwarf/pro_line.h +112 -0
- data/ext/rdwarf/libdwarf/pro_macinfo.c +457 -0
- data/ext/rdwarf/libdwarf/pro_macinfo.h +31 -0
- data/ext/rdwarf/libdwarf/pro_opaque.h +513 -0
- data/ext/rdwarf/libdwarf/pro_pubnames.c +60 -0
- data/ext/rdwarf/libdwarf/pro_reloc.c +253 -0
- data/ext/rdwarf/libdwarf/pro_reloc.h +38 -0
- data/ext/rdwarf/libdwarf/pro_reloc_stream.c +256 -0
- data/ext/rdwarf/libdwarf/pro_reloc_stream.h +52 -0
- data/ext/rdwarf/libdwarf/pro_reloc_symbolic.c +245 -0
- data/ext/rdwarf/libdwarf/pro_reloc_symbolic.h +45 -0
- data/ext/rdwarf/libdwarf/pro_section.c +2233 -0
- data/ext/rdwarf/libdwarf/pro_section.h +100 -0
- data/ext/rdwarf/libdwarf/pro_types.c +274 -0
- data/ext/rdwarf/libdwarf/pro_types.h +34 -0
- data/ext/rdwarf/libdwarf/pro_util.h +38 -0
- data/ext/rdwarf/libdwarf/pro_vars.c +52 -0
- data/ext/rdwarf/libdwarf/pro_weaks.c +51 -0
- data/ext/rdwarf/rdwarf.c +765 -0
- data/ext/rdwarf/rdwarf.h +52 -0
- data/ext/rdwarf/rdwarf_names_gen.rb +109 -0
- data/lib/rdwarf.rb +181 -0
- data/lib/rdwarf/version.rb +3 -0
- data/rdwarf.gemspec +30 -0
- metadata +251 -0
@@ -0,0 +1,685 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
|
3
|
+
Portions Copyright (C) 2007-2011 David Anderson. 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
|
+
*/
|
26
|
+
|
27
|
+
#undef DEBUG
|
28
|
+
|
29
|
+
#include "config.h"
|
30
|
+
#include "dwarf_incl.h"
|
31
|
+
#include <sys/types.h>
|
32
|
+
|
33
|
+
#include <stdlib.h>
|
34
|
+
#include <stdio.h>
|
35
|
+
|
36
|
+
/* These files are included to get the sizes
|
37
|
+
of structs for malloc.
|
38
|
+
*/
|
39
|
+
#include "dwarf_line.h"
|
40
|
+
#include "dwarf_global.h"
|
41
|
+
#include "dwarf_arange.h"
|
42
|
+
#include "dwarf_abbrev.h"
|
43
|
+
#include "dwarf_die_deliv.h"
|
44
|
+
#include "dwarf_frame.h"
|
45
|
+
#include "dwarf_loc.h"
|
46
|
+
#include "dwarf_funcs.h"
|
47
|
+
#include "dwarf_types.h"
|
48
|
+
#include "dwarf_vars.h"
|
49
|
+
#include "dwarf_weaks.h"
|
50
|
+
#include "dwarf_harmless.h"
|
51
|
+
#include "dwarf_tsearch.h"
|
52
|
+
#include "dwarf_gdbindex.h"
|
53
|
+
#include "dwarf_xu_index.h"
|
54
|
+
|
55
|
+
#define TRUE 1
|
56
|
+
#define FALSE 0
|
57
|
+
/* Some allocations are simple some not. These reduce
|
58
|
+
the issue of determining which sort of thing to a simple
|
59
|
+
test. See ia_multiply_count
|
60
|
+
Usually when MULTIPLY_NO is set the count
|
61
|
+
is 1, so MULTIPY_CT would work as well. */
|
62
|
+
#define MULTIPLY_NO 0
|
63
|
+
#define MULTIPLY_CT 1
|
64
|
+
#define MULTIPLY_SP 2
|
65
|
+
/* This translates into de_alloc_hdr into a per-instance size
|
66
|
+
and allows room for a constructor/destructor pointer.
|
67
|
+
Rearranging the DW_DLA values would break binary compatibility
|
68
|
+
so that is not an option.
|
69
|
+
*/
|
70
|
+
struct ial_s {
|
71
|
+
/* In bytes, one struct instance. */
|
72
|
+
short ia_struct_size;
|
73
|
+
|
74
|
+
/* Not a count, but a MULTIPLY{_NO,_CT,_SP} value. */
|
75
|
+
short ia_multiply_count;
|
76
|
+
|
77
|
+
/* When we really need a constructor/destructor
|
78
|
+
these make applying such quite simple. */
|
79
|
+
int (*specialconstructor) (Dwarf_Debug, void *);
|
80
|
+
void (*specialdestructor) (void *);
|
81
|
+
};
|
82
|
+
|
83
|
+
/* Used as a way to return meaningful errors when
|
84
|
+
the malloc arena is exhausted (when malloc returns NULL).
|
85
|
+
Not normally used.
|
86
|
+
New in December 2014.*/
|
87
|
+
struct Dwarf_Error_s _dwarf_failsafe_error = {
|
88
|
+
DW_DLE_FAILSAFE_ERRVAL,
|
89
|
+
1
|
90
|
+
};
|
91
|
+
|
92
|
+
|
93
|
+
/* To do destructors we need some extra data in every
|
94
|
+
_dwarf_get_alloc situation. */
|
95
|
+
/* Here is the extra we malloc for a prefix. */
|
96
|
+
struct reserve_size_s {
|
97
|
+
void *dummy_rsv1;
|
98
|
+
void *dummy_rsv2;
|
99
|
+
};
|
100
|
+
/* Here is how we use the extra prefix area. */
|
101
|
+
struct reserve_data_s {
|
102
|
+
void *rd_dbg;
|
103
|
+
unsigned short rd_length;
|
104
|
+
unsigned short rd_type;
|
105
|
+
};
|
106
|
+
#define DW_RESERVE sizeof(struct reserve_size_s)
|
107
|
+
|
108
|
+
|
109
|
+
static const
|
110
|
+
struct ial_s alloc_instance_basics[ALLOC_AREA_INDEX_TABLE_MAX] = {
|
111
|
+
{ 1,MULTIPLY_NO, 0, 0}, /* 0 none */
|
112
|
+
{ 1,MULTIPLY_CT, 0, 0}, /* 1 DW_DLA_STRING */
|
113
|
+
{ sizeof(Dwarf_Loc),MULTIPLY_NO, 0, 0} ,/* 2 DW_DLA_LOC */
|
114
|
+
{ sizeof(Dwarf_Locdesc),MULTIPLY_NO, 0, 0} , /* 3 DW_DLA_LOCDESC */
|
115
|
+
{ 1,MULTIPLY_NO, 0, 0} , /* not used *//* 4 DW_DLA_ELLIST */
|
116
|
+
{ 1,MULTIPLY_NO, 0, 0} , /* not used *//* 5 DW_DLA_BOUNDS */
|
117
|
+
{ sizeof(Dwarf_Block),MULTIPLY_NO, 0, 0} , /* 6 DW_DLA_BLOCK */
|
118
|
+
|
119
|
+
/* the actual dwarf_debug structure */ /* 7 DW_DLA_DEBUG */
|
120
|
+
{ 1,MULTIPLY_NO, 0, 0} ,
|
121
|
+
|
122
|
+
{sizeof(struct Dwarf_Die_s),MULTIPLY_NO, 0, 0},/* 8 DW_DLA_DIE */
|
123
|
+
{sizeof(struct Dwarf_Line_s),MULTIPLY_NO, 0, 0},/* 9 DW_DLA_LINE */
|
124
|
+
|
125
|
+
/* 10 DW_DLA_ATTR */
|
126
|
+
{sizeof(struct Dwarf_Attribute_s),MULTIPLY_NO, 0, 0},
|
127
|
+
|
128
|
+
{1,MULTIPLY_NO, 0, 0}, /* not used */ /* 11 DW_DLA_TYPE */
|
129
|
+
{1,MULTIPLY_NO, 0, 0}, /* not used */ /* 12 DW_DLA_SUBSCR */
|
130
|
+
|
131
|
+
/* 13 DW_DLA_GLOBAL */
|
132
|
+
{sizeof(struct Dwarf_Global_s),MULTIPLY_NO, 0, 0},
|
133
|
+
|
134
|
+
/* 14 DW_DLA_ERROR */
|
135
|
+
{sizeof(struct Dwarf_Error_s),MULTIPLY_NO, 0, 0},
|
136
|
+
|
137
|
+
{sizeof(Dwarf_Ptr),MULTIPLY_CT, 0, 0}, /* 15 DW_DLA_LIST */
|
138
|
+
{1,MULTIPLY_NO, 0, 0}, /* not used *//* 16 DW_DLA_LINEBUF */
|
139
|
+
|
140
|
+
/* 17 DW_DLA_ARANGE */
|
141
|
+
{sizeof(struct Dwarf_Arange_s),MULTIPLY_NO, 0, 0},
|
142
|
+
|
143
|
+
/* 18 DW_DLA_ABBREV */
|
144
|
+
{sizeof(struct Dwarf_Abbrev_s),MULTIPLY_NO, 0, 0},
|
145
|
+
|
146
|
+
/* 19 DW_DLA_FRAME_OP */
|
147
|
+
{sizeof(Dwarf_Frame_Op),MULTIPLY_NO, 0, 0} ,
|
148
|
+
|
149
|
+
/* 20 DW_DLA_CIE */
|
150
|
+
{sizeof(struct Dwarf_Cie_s),MULTIPLY_NO, 0, 0},
|
151
|
+
|
152
|
+
{sizeof(struct Dwarf_Fde_s),MULTIPLY_NO, 0, 0},/* 21 DW_DLA_FDE */
|
153
|
+
{sizeof(Dwarf_Loc),MULTIPLY_CT, 0, 0}, /* 22 DW_DLA_LOC_BLOCK */
|
154
|
+
{sizeof(Dwarf_Frame_Op),MULTIPLY_CT, 0, 0}, /* 23 DW_DLA_FRAME_BLOCK */
|
155
|
+
|
156
|
+
/* 24 DW_DLA_FUNC UNUSED */
|
157
|
+
{sizeof(struct Dwarf_Global_s),MULTIPLY_NO, 0, 0},
|
158
|
+
|
159
|
+
/* 25 DW_DLA_TYPENAME UNUSED */
|
160
|
+
{sizeof(struct Dwarf_Global_s),MULTIPLY_NO, 0, 0},
|
161
|
+
|
162
|
+
/* 26 DW_DLA_VAR UNUSED */
|
163
|
+
{sizeof(struct Dwarf_Global_s),MULTIPLY_NO, 0, 0},
|
164
|
+
|
165
|
+
/* 27 DW_DLA_WEAK UNUSED */
|
166
|
+
{sizeof(struct Dwarf_Global_s),MULTIPLY_NO, 0, 0},
|
167
|
+
|
168
|
+
{1,MULTIPLY_SP, 0, 0}, /* 28 DW_DLA_ADDR */
|
169
|
+
{sizeof(Dwarf_Ranges),MULTIPLY_CT, 0,0 }, /* 29 DW_DLA_RANGES */
|
170
|
+
|
171
|
+
/* The following DW_DLA data types
|
172
|
+
are known only inside libdwarf. */
|
173
|
+
|
174
|
+
/* 30 DW_DLA_ABBREV_LIST */
|
175
|
+
{ sizeof(struct Dwarf_Abbrev_List_s),MULTIPLY_NO, 0, 0},
|
176
|
+
|
177
|
+
/* 31 DW_DLA_CHAIN */
|
178
|
+
{sizeof(struct Dwarf_Chain_s),MULTIPLY_NO, 0, 0},
|
179
|
+
|
180
|
+
/* 32 DW_DLA_CU_CONTEXT */
|
181
|
+
{sizeof(struct Dwarf_CU_Context_s),MULTIPLY_NO, 0, 0},
|
182
|
+
|
183
|
+
{sizeof(struct Dwarf_Frame_s),MULTIPLY_NO,
|
184
|
+
_dwarf_frame_constructor,
|
185
|
+
_dwarf_frame_destructor}, /* 33 DW_DLA_FRAME */
|
186
|
+
|
187
|
+
/* 34 DW_DLA_GLOBAL_CONTEXT */
|
188
|
+
{sizeof(struct Dwarf_Global_Context_s),MULTIPLY_NO, 0, 0},
|
189
|
+
|
190
|
+
/* 35 DW_DLA_FILE_ENTRY */
|
191
|
+
{sizeof(struct Dwarf_File_Entry_s),MULTIPLY_NO, 0, 0},
|
192
|
+
|
193
|
+
/* 36 DW_DLA_LINE_CONTEXT */
|
194
|
+
{sizeof(struct Dwarf_Line_Context_s),MULTIPLY_NO,
|
195
|
+
_dwarf_line_context_constructor,
|
196
|
+
_dwarf_line_context_destructor},
|
197
|
+
|
198
|
+
/* 37 DW_DLA_LOC_CHAIN */
|
199
|
+
{sizeof(struct Dwarf_Loc_Chain_s),MULTIPLY_NO, 0, 0},
|
200
|
+
|
201
|
+
/* 38 0x26 DW_DLA_HASH_TABLE */
|
202
|
+
{sizeof(struct Dwarf_Hash_Table_s),MULTIPLY_NO, 0, 0},
|
203
|
+
|
204
|
+
/* The following really use Global struct: used to be unique struct
|
205
|
+
per type, but now merged (11/99). The opaque types
|
206
|
+
are visible in the interface. The types for
|
207
|
+
DW_DLA_FUNC, DW_DLA_TYPENAME, DW_DLA_VAR, DW_DLA_WEAK also use
|
208
|
+
the global types. */
|
209
|
+
|
210
|
+
/* 39 0x27 DW_DLA_FUNC_CONTEXT */
|
211
|
+
{sizeof(struct Dwarf_Global_Context_s),MULTIPLY_NO, 0, 0},
|
212
|
+
|
213
|
+
/* 40 0x28 DW_DLA_TYPENAME_CONTEXT */
|
214
|
+
{sizeof(struct Dwarf_Global_Context_s),MULTIPLY_NO, 0, 0},
|
215
|
+
|
216
|
+
/* 41 0x29 DW_DLA_VAR_CONTEXT */
|
217
|
+
{sizeof(struct Dwarf_Global_Context_s),MULTIPLY_NO, 0, 0},
|
218
|
+
|
219
|
+
/* 42 0x2a DW_DLA_WEAK_CONTEXT */
|
220
|
+
{sizeof(struct Dwarf_Global_Context_s),MULTIPLY_NO, 0, 0},
|
221
|
+
|
222
|
+
/* 43 0x2b DW_DLA_PUBTYPES_CONTEXT DWARF3 */
|
223
|
+
{sizeof(struct Dwarf_Global_Context_s),MULTIPLY_NO, 0, 0},
|
224
|
+
|
225
|
+
/* 44 0x2c DW_DLA_HASH_TABLE_ENTRY */
|
226
|
+
{sizeof(struct Dwarf_Hash_Table_Entry_s),MULTIPLY_CT,0,0 },
|
227
|
+
/* 0x2d - 0x2f, reserved for future internal use. */
|
228
|
+
|
229
|
+
/* 45 0x2d DW_DLA_FISSION_PERCU */
|
230
|
+
{sizeof(struct Dwarf_Fission_Per_CU_s),MULTIPLY_CT, 0, 0},
|
231
|
+
|
232
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
233
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
234
|
+
/* 0x30-0x36 reserved for future internal use. */
|
235
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
236
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
237
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
238
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
239
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
240
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
241
|
+
{sizeof(int),MULTIPLY_NO, 0, 0}, /* reserved for future internal types*/
|
242
|
+
|
243
|
+
/* now, we have types that are public. */
|
244
|
+
/* 0x37 55. New in June 2014. Gdb. */
|
245
|
+
{sizeof(struct Dwarf_Gdbindex_s),MULTIPLY_NO, 0, 0},
|
246
|
+
|
247
|
+
/* 0x38 56. New in July 2014. DWARF5 DebugFission dwp file sections
|
248
|
+
.debug_cu_index and .debug_tu_index . */
|
249
|
+
{sizeof(struct Dwarf_Xu_Index_Header_s),MULTIPLY_NO, 0, 0},
|
250
|
+
|
251
|
+
/* These required by new features in DWARF5. Also usable
|
252
|
+
for DWARF2,3,4. */
|
253
|
+
/* 57 DW_DLA_LOC_BLOCK_C */
|
254
|
+
{sizeof(struct Dwarf_Loc_c_s),MULTIPLY_CT, 0, 0},
|
255
|
+
/* 58 DW_DLA_LOCDESC_C */
|
256
|
+
{sizeof(struct Dwarf_Locdesc_c_s),MULTIPLY_CT, 0, 0},
|
257
|
+
/* 59 DW_DLA_LOC_HEAD_C */
|
258
|
+
{sizeof(struct Dwarf_Loc_Head_c_s),MULTIPLY_NO, 0, 0},
|
259
|
+
};
|
260
|
+
|
261
|
+
/* We are simply using the incoming pointer as the key-pointer.
|
262
|
+
*/
|
263
|
+
typedef unsigned long VALTYPE;
|
264
|
+
|
265
|
+
static unsigned long
|
266
|
+
simple_value_hashfunc(const void *keyp)
|
267
|
+
{
|
268
|
+
VALTYPE up = (VALTYPE )keyp;
|
269
|
+
return up;
|
270
|
+
}
|
271
|
+
/* We did alloc something but not a fixed-length thing.
|
272
|
+
Instead, it starts with some special data we noted.
|
273
|
+
The incoming pointer is to the caller data, we
|
274
|
+
destruct based on caller, but find the special
|
275
|
+
extra data in a prefix area. */
|
276
|
+
static void
|
277
|
+
tdestroy_free_node(void *nodep)
|
278
|
+
{
|
279
|
+
char * m = (char *)nodep;
|
280
|
+
char * malloc_addr = m - DW_RESERVE;
|
281
|
+
struct reserve_data_s * reserve =(struct reserve_data_s *)malloc_addr;
|
282
|
+
unsigned type = reserve->rd_type;
|
283
|
+
if (type >= ALLOC_AREA_INDEX_TABLE_MAX) {
|
284
|
+
/* Internal error, corrupted data. */
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
if(!reserve->rd_dbg) {
|
288
|
+
/* Unused (corrupted?) node in the tree.
|
289
|
+
Should never happen. */
|
290
|
+
return;
|
291
|
+
}
|
292
|
+
if(!reserve->rd_type) {
|
293
|
+
/* Unused (corrupted?) node in the tree.
|
294
|
+
Should never happen. */
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
if (alloc_instance_basics[type].specialdestructor) {
|
298
|
+
alloc_instance_basics[type].specialdestructor(m);
|
299
|
+
}
|
300
|
+
free(malloc_addr);
|
301
|
+
}
|
302
|
+
|
303
|
+
/* The sort of hash table entries result in very simple helper functions. */
|
304
|
+
static int
|
305
|
+
simple_compare_function(const void *l, const void *r)
|
306
|
+
{
|
307
|
+
VALTYPE lp = (VALTYPE)l;
|
308
|
+
VALTYPE rp = (VALTYPE)r;
|
309
|
+
if(lp < rp) {
|
310
|
+
return -1;
|
311
|
+
}
|
312
|
+
if(lp > rp) {
|
313
|
+
return 1;
|
314
|
+
}
|
315
|
+
return 0;
|
316
|
+
}
|
317
|
+
|
318
|
+
/* This function returns a pointer to a region
|
319
|
+
of memory. For alloc_types that are not
|
320
|
+
strings or lists of pointers, only 1 struct
|
321
|
+
can be requested at a time. This is indicated
|
322
|
+
by an input count of 1. For strings, count
|
323
|
+
equals the length of the string it will
|
324
|
+
contain, i.e it the length of the string
|
325
|
+
plus 1 for the terminating null. For lists
|
326
|
+
of pointers, count is equal to the number of
|
327
|
+
pointers. For DW_DLA_FRAME_BLOCK, DW_DLA_RANGES, and
|
328
|
+
DW_DLA_LOC_BLOCK allocation types also, count
|
329
|
+
is the count of the number of structs needed.
|
330
|
+
|
331
|
+
This function cannot be used to allocate a
|
332
|
+
Dwarf_Debug_s struct. */
|
333
|
+
|
334
|
+
char *
|
335
|
+
_dwarf_get_alloc(Dwarf_Debug dbg,
|
336
|
+
Dwarf_Small alloc_type, Dwarf_Unsigned count)
|
337
|
+
{
|
338
|
+
char * alloc_mem = 0;
|
339
|
+
Dwarf_Signed basesize = 0;
|
340
|
+
Dwarf_Signed size = 0;
|
341
|
+
unsigned int type = alloc_type;
|
342
|
+
short action = 0;
|
343
|
+
|
344
|
+
if (dbg == NULL) {
|
345
|
+
return (NULL);
|
346
|
+
}
|
347
|
+
if (type >= ALLOC_AREA_INDEX_TABLE_MAX) {
|
348
|
+
/* internal error */
|
349
|
+
return NULL;
|
350
|
+
}
|
351
|
+
basesize = alloc_instance_basics[alloc_type].ia_struct_size;
|
352
|
+
action = alloc_instance_basics[alloc_type].ia_multiply_count;
|
353
|
+
if(action == MULTIPLY_NO) {
|
354
|
+
/* Usually count is 1, but do not assume it. */
|
355
|
+
size = basesize;
|
356
|
+
} else if (action == MULTIPLY_CT) {
|
357
|
+
size = basesize * count;
|
358
|
+
} else {
|
359
|
+
/* MULTIPLY_SP */
|
360
|
+
/* DW_DLA_ADDR.. count * largest size */
|
361
|
+
size = count *
|
362
|
+
(sizeof(Dwarf_Addr) > sizeof(Dwarf_Off) ?
|
363
|
+
sizeof(Dwarf_Addr) : sizeof(Dwarf_Off));
|
364
|
+
}
|
365
|
+
size += DW_RESERVE;
|
366
|
+
alloc_mem = malloc(size);
|
367
|
+
if (!alloc_mem) {
|
368
|
+
return NULL;
|
369
|
+
}
|
370
|
+
{
|
371
|
+
char * ret_mem = alloc_mem + DW_RESERVE;
|
372
|
+
void *key = ret_mem;
|
373
|
+
struct reserve_data_s *r = (struct reserve_data_s*)alloc_mem;
|
374
|
+
void *result = 0;
|
375
|
+
|
376
|
+
memset(alloc_mem, 0, size);
|
377
|
+
/* We are not actually using rd_dbg, we are using rd_type. */
|
378
|
+
r->rd_dbg = dbg;
|
379
|
+
r->rd_type = alloc_type;
|
380
|
+
r->rd_length = size;
|
381
|
+
if (alloc_instance_basics[type].specialconstructor) {
|
382
|
+
int res =
|
383
|
+
alloc_instance_basics[type].specialconstructor(dbg, ret_mem);
|
384
|
+
if (res != DW_DLV_OK) {
|
385
|
+
/* We leak what we allocated in _dwarf_find_memory when
|
386
|
+
constructor fails. */
|
387
|
+
return NULL;
|
388
|
+
}
|
389
|
+
}
|
390
|
+
result = dwarf_tsearch((void *)key,
|
391
|
+
&dbg->de_alloc_tree,simple_compare_function);
|
392
|
+
if(!result) {
|
393
|
+
/* Something badly wrong. Out of memory.
|
394
|
+
pretend all is well. */
|
395
|
+
}
|
396
|
+
return (ret_mem);
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
400
|
+
/* This was once a long list of tests using dss_data
|
401
|
+
and dss_size to see if 'space' was inside a debug section.
|
402
|
+
This tfind approach removes that maintenance headache. */
|
403
|
+
static int
|
404
|
+
string_is_in_debug_section(Dwarf_Debug dbg,void * space)
|
405
|
+
{
|
406
|
+
/* See dwarf_line.c dwarf_srcfiles()
|
407
|
+
for one way we can wind up with
|
408
|
+
a DW_DLA_STRING string that may or may not be malloc-ed
|
409
|
+
by _dwarf_get_alloc().
|
410
|
+
|
411
|
+
dwarf_formstring(), for example, returns strings
|
412
|
+
which point into .debug_info or .debug_types but
|
413
|
+
dwarf_dealloc is never supposed to be applied
|
414
|
+
to strings dwarf_formstring() returns!
|
415
|
+
|
416
|
+
Lots of calls returning strings
|
417
|
+
have always been documented as requiring
|
418
|
+
dwarf_dealloc(...DW_DLA_STRING) when the code
|
419
|
+
just returns a pointer to a portion of a loaded section!
|
420
|
+
It is too late to change the documentation. */
|
421
|
+
|
422
|
+
void *result = 0;
|
423
|
+
result = dwarf_tfind((void *)space,
|
424
|
+
&dbg->de_alloc_tree,simple_compare_function);
|
425
|
+
if(!result) {
|
426
|
+
/* Not in the tree, so not malloc-ed
|
427
|
+
Nothing to delete. */
|
428
|
+
return TRUE;
|
429
|
+
}
|
430
|
+
/* We found the address in the tree, so it is NOT
|
431
|
+
part of .debug_info or any other dwarf section,
|
432
|
+
but is space malloc-d in _dwarf_get_alloc(). */
|
433
|
+
return FALSE;
|
434
|
+
}
|
435
|
+
|
436
|
+
/*
|
437
|
+
This function is used to deallocate a region of memory
|
438
|
+
that was obtained by a call to _dwarf_get_alloc. Note
|
439
|
+
that though dwarf_dealloc() is a public function,
|
440
|
+
_dwarf_get_alloc() isn't.
|
441
|
+
|
442
|
+
For lists, typically arrays of pointers, it is assumed
|
443
|
+
that the space was allocated by a direct call to malloc,
|
444
|
+
and so a straight free() is done. This is also the case
|
445
|
+
for variable length blocks such as DW_DLA_FRAME_BLOCK
|
446
|
+
and DW_DLA_LOC_BLOCK and DW_DLA_RANGES.
|
447
|
+
|
448
|
+
For strings, the pointer might point to a string in
|
449
|
+
.debug_info or .debug_string. After this is checked,
|
450
|
+
and if found not to be the case, a free() is done,
|
451
|
+
again on the assumption that a malloc was used to
|
452
|
+
obtain the space.
|
453
|
+
|
454
|
+
This function does not return anything.
|
455
|
+
*/
|
456
|
+
void
|
457
|
+
dwarf_dealloc(Dwarf_Debug dbg,
|
458
|
+
Dwarf_Ptr space, Dwarf_Unsigned alloc_type)
|
459
|
+
{
|
460
|
+
unsigned int type = 0;
|
461
|
+
char * malloc_addr = 0;
|
462
|
+
struct reserve_data_s * r = 0;
|
463
|
+
|
464
|
+
if (space == NULL) {
|
465
|
+
return;
|
466
|
+
}
|
467
|
+
type = alloc_type;
|
468
|
+
malloc_addr = (char *)space - DW_RESERVE;
|
469
|
+
r =(struct reserve_data_s *)malloc_addr;
|
470
|
+
if(dbg != r->rd_dbg) {
|
471
|
+
/* Something is badly wrong. Better to leak than
|
472
|
+
to crash. */
|
473
|
+
return;
|
474
|
+
}
|
475
|
+
if (alloc_type == DW_DLA_ERROR) {
|
476
|
+
Dwarf_Error ep = (Dwarf_Error)space;
|
477
|
+
if (ep->er_static_alloc) {
|
478
|
+
/* This is special, malloc arena
|
479
|
+
was exhausted and there is nothing to delete, really.
|
480
|
+
Set er_errval to signal that the space was dealloc'd. */
|
481
|
+
ep->er_errval = DW_DLE_FAILSAFE_ERRVAL;
|
482
|
+
return;
|
483
|
+
}
|
484
|
+
}
|
485
|
+
if (dbg == NULL) {
|
486
|
+
/* App error, or an app that failed to succeed in a
|
487
|
+
dwarf_init() call. */
|
488
|
+
return;
|
489
|
+
}
|
490
|
+
if (type >= ALLOC_AREA_INDEX_TABLE_MAX) {
|
491
|
+
/* internal or user app error */
|
492
|
+
return;
|
493
|
+
}
|
494
|
+
|
495
|
+
|
496
|
+
if (type == DW_DLA_STRING && string_is_in_debug_section(dbg,space)) {
|
497
|
+
/* A string pointer may point into .debug_info or .debug_string etc.
|
498
|
+
So must not be freed. And strings have no need of a
|
499
|
+
specialdestructor().
|
500
|
+
Mostly a historical mistake here. */
|
501
|
+
return;
|
502
|
+
}
|
503
|
+
|
504
|
+
if (alloc_instance_basics[type].specialdestructor) {
|
505
|
+
alloc_instance_basics[type].specialdestructor(space);
|
506
|
+
}
|
507
|
+
{
|
508
|
+
/* The 'space' pointer we get points after the reserve space.
|
509
|
+
The key and address to free are just a few bytes before
|
510
|
+
'space'. */
|
511
|
+
void *key = space;
|
512
|
+
dwarf_tdelete(key,&dbg->de_alloc_tree,simple_compare_function);
|
513
|
+
/* If dwarf_tdelete returns NULL it might mean
|
514
|
+
a) tree is empty.
|
515
|
+
b) If hashsearch, then a single chain might now be empty,
|
516
|
+
so we do not know of a 'parent node'.
|
517
|
+
c) We did not find that key, we did nothing.
|
518
|
+
|
519
|
+
In any case, we simply don't worry about it.
|
520
|
+
Not Supposed To Happen. */
|
521
|
+
|
522
|
+
free(malloc_addr);
|
523
|
+
return;
|
524
|
+
}
|
525
|
+
}
|
526
|
+
|
527
|
+
|
528
|
+
/*
|
529
|
+
Allocates space for a Dwarf_Debug_s struct,
|
530
|
+
since one does not exist.
|
531
|
+
*/
|
532
|
+
Dwarf_Debug
|
533
|
+
_dwarf_get_debug(void)
|
534
|
+
{
|
535
|
+
Dwarf_Debug dbg;
|
536
|
+
|
537
|
+
dbg = (Dwarf_Debug) malloc(sizeof(struct Dwarf_Debug_s));
|
538
|
+
if (dbg == NULL) {
|
539
|
+
return (NULL);
|
540
|
+
}
|
541
|
+
memset(dbg, 0, sizeof(struct Dwarf_Debug_s));
|
542
|
+
/* Set up for a dwarf_tsearch hash table */
|
543
|
+
|
544
|
+
dwarf_initialize_search_hash(&dbg->de_alloc_tree,simple_value_hashfunc,0);
|
545
|
+
|
546
|
+
|
547
|
+
return (dbg);
|
548
|
+
}
|
549
|
+
|
550
|
+
/*
|
551
|
+
This function prints out the statistics
|
552
|
+
collected on allocation of memory chunks.
|
553
|
+
No longer used.
|
554
|
+
*/
|
555
|
+
void
|
556
|
+
dwarf_print_memory_stats(Dwarf_Debug dbg)
|
557
|
+
{
|
558
|
+
}
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
/* In the 'rela' relocation case we might have malloc'd
|
563
|
+
space to ensure it is read-write. In that case, free the space. */
|
564
|
+
static void
|
565
|
+
rela_free(struct Dwarf_Section_s * sec)
|
566
|
+
{
|
567
|
+
if (sec->dss_data_was_malloc) {
|
568
|
+
free(sec->dss_data);
|
569
|
+
}
|
570
|
+
sec->dss_data = 0;
|
571
|
+
sec->dss_data_was_malloc = 0;
|
572
|
+
}
|
573
|
+
|
574
|
+
static void
|
575
|
+
freecontextlist(Dwarf_Debug dbg, Dwarf_Debug_InfoTypes dis)
|
576
|
+
{
|
577
|
+
Dwarf_CU_Context context = 0;
|
578
|
+
Dwarf_CU_Context nextcontext = 0;
|
579
|
+
for (context = dis->de_cu_context_list;
|
580
|
+
context; context = nextcontext) {
|
581
|
+
Dwarf_Hash_Table hash_table = context->cc_abbrev_hash_table;
|
582
|
+
_dwarf_free_abbrev_hash_table_contents(dbg,hash_table);
|
583
|
+
nextcontext = context->cc_next;
|
584
|
+
dwarf_dealloc(dbg, hash_table, DW_DLA_HASH_TABLE);
|
585
|
+
context->cc_abbrev_hash_table = 0;
|
586
|
+
dwarf_dealloc(dbg, context, DW_DLA_CU_CONTEXT);
|
587
|
+
}
|
588
|
+
dis->de_cu_context_list = 0;
|
589
|
+
}
|
590
|
+
|
591
|
+
/*
|
592
|
+
Used to free all space allocated for this Dwarf_Debug.
|
593
|
+
The caller should assume that the Dwarf_Debug pointer
|
594
|
+
itself is no longer valid upon return from this function.
|
595
|
+
|
596
|
+
In case of difficulty, this function simply returns quietly.
|
597
|
+
*/
|
598
|
+
int
|
599
|
+
_dwarf_free_all_of_one_debug(Dwarf_Debug dbg)
|
600
|
+
{
|
601
|
+
if (dbg == NULL) {
|
602
|
+
return (DW_DLV_ERROR);
|
603
|
+
}
|
604
|
+
|
605
|
+
/* To do complete validation that we have no surprising missing or
|
606
|
+
erroneous deallocs it is advisable to do the dwarf_deallocs here
|
607
|
+
that are not things the user can otherwise request.
|
608
|
+
Housecleaning. */
|
609
|
+
if (dbg->de_cu_hashindex_data) {
|
610
|
+
dwarf_xu_header_free(dbg->de_cu_hashindex_data);
|
611
|
+
dbg->de_cu_hashindex_data = 0;
|
612
|
+
}
|
613
|
+
if (dbg->de_tu_hashindex_data) {
|
614
|
+
dwarf_xu_header_free(dbg->de_tu_hashindex_data);
|
615
|
+
dbg->de_tu_hashindex_data = 0;
|
616
|
+
}
|
617
|
+
|
618
|
+
freecontextlist(dbg,&dbg->de_info_reading);
|
619
|
+
freecontextlist(dbg,&dbg->de_types_reading);
|
620
|
+
|
621
|
+
/* Housecleaning done. Now really free all the space. */
|
622
|
+
rela_free(&dbg->de_debug_info);
|
623
|
+
rela_free(&dbg->de_debug_types);
|
624
|
+
rela_free(&dbg->de_debug_abbrev);
|
625
|
+
rela_free(&dbg->de_debug_line);
|
626
|
+
rela_free(&dbg->de_debug_line_str);
|
627
|
+
rela_free(&dbg->de_debug_loc);
|
628
|
+
rela_free(&dbg->de_debug_aranges);
|
629
|
+
rela_free(&dbg->de_debug_macinfo);
|
630
|
+
rela_free(&dbg->de_debug_macro);
|
631
|
+
rela_free(&dbg->de_debug_names);
|
632
|
+
rela_free(&dbg->de_debug_pubnames);
|
633
|
+
rela_free(&dbg->de_debug_str);
|
634
|
+
rela_free(&dbg->de_debug_sup);
|
635
|
+
rela_free(&dbg->de_debug_frame);
|
636
|
+
rela_free(&dbg->de_debug_frame_eh_gnu);
|
637
|
+
rela_free(&dbg->de_debug_pubtypes);
|
638
|
+
rela_free(&dbg->de_debug_funcnames);
|
639
|
+
rela_free(&dbg->de_debug_typenames);
|
640
|
+
rela_free(&dbg->de_debug_varnames);
|
641
|
+
rela_free(&dbg->de_debug_weaknames);
|
642
|
+
rela_free(&dbg->de_debug_ranges);
|
643
|
+
rela_free(&dbg->de_debug_str_offsets);
|
644
|
+
rela_free(&dbg->de_debug_addr);
|
645
|
+
rela_free(&dbg->de_debug_gdbindex);
|
646
|
+
rela_free(&dbg->de_debug_cu_index);
|
647
|
+
rela_free(&dbg->de_debug_tu_index);
|
648
|
+
dwarf_harmless_cleanout(&dbg->de_harmless_errors);
|
649
|
+
|
650
|
+
if (dbg->de_printf_callback.dp_buffer &&
|
651
|
+
!dbg->de_printf_callback.dp_buffer_user_provided ) {
|
652
|
+
free(dbg->de_printf_callback.dp_buffer);
|
653
|
+
}
|
654
|
+
|
655
|
+
dwarf_tdestroy(dbg->de_alloc_tree,tdestroy_free_node);
|
656
|
+
dbg->de_alloc_tree = 0;
|
657
|
+
if (dbg->de_tied_data.td_tied_search) {
|
658
|
+
dwarf_tdestroy(dbg->de_tied_data.td_tied_search,
|
659
|
+
_dwarf_tied_destroy_free_node);
|
660
|
+
dbg->de_tied_data.td_tied_search = 0;
|
661
|
+
}
|
662
|
+
memset(dbg, 0, sizeof(*dbg)); /* Prevent accidental use later. */
|
663
|
+
free(dbg);
|
664
|
+
return (DW_DLV_OK);
|
665
|
+
}
|
666
|
+
/* A special case: we have no dbg, no alloc header etc.
|
667
|
+
So create something out of thin air that we can recognize
|
668
|
+
in dwarf_dealloc.
|
669
|
+
Something with the prefix (prefix space hidden from caller).
|
670
|
+
|
671
|
+
Only applies to DW_DLA_ERROR, and making up an error record.
|
672
|
+
The allocated space simply leaks.
|
673
|
+
*/
|
674
|
+
struct Dwarf_Error_s *
|
675
|
+
_dwarf_special_no_dbg_error_malloc(void)
|
676
|
+
{
|
677
|
+
/* The union unused things are to guarantee proper alignment */
|
678
|
+
char *mem = malloc(sizeof(struct Dwarf_Error_s));
|
679
|
+
if (mem == 0) {
|
680
|
+
return 0;
|
681
|
+
}
|
682
|
+
memset(mem, 0, sizeof(struct Dwarf_Error_s));
|
683
|
+
return (struct Dwarf_Error_s *) mem;
|
684
|
+
}
|
685
|
+
|