rdwarf 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +28 -0
  6. data/README.md +39 -0
  7. data/Rakefile +8 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/ext/rdwarf/depend +5 -0
  11. data/ext/rdwarf/extconf.rb +29 -0
  12. data/ext/rdwarf/libdwarf/CHANGES +102 -0
  13. data/ext/rdwarf/libdwarf/CODINGSTYLE +71 -0
  14. data/ext/rdwarf/libdwarf/COPYING +28 -0
  15. data/ext/rdwarf/libdwarf/ChangeLog +619 -0
  16. data/ext/rdwarf/libdwarf/ChangeLog2006 +835 -0
  17. data/ext/rdwarf/libdwarf/ChangeLog2007 +217 -0
  18. data/ext/rdwarf/libdwarf/ChangeLog2008 +263 -0
  19. data/ext/rdwarf/libdwarf/ChangeLog2009 +348 -0
  20. data/ext/rdwarf/libdwarf/ChangeLog2010 +175 -0
  21. data/ext/rdwarf/libdwarf/ChangeLog2011 +297 -0
  22. data/ext/rdwarf/libdwarf/ChangeLog2012 +131 -0
  23. data/ext/rdwarf/libdwarf/ChangeLog2013 +238 -0
  24. data/ext/rdwarf/libdwarf/ChangeLog2014 +399 -0
  25. data/ext/rdwarf/libdwarf/LGPL.txt +504 -0
  26. data/ext/rdwarf/libdwarf/LIBDWARFCOPYRIGHT +40 -0
  27. data/ext/rdwarf/libdwarf/Makefile.in +220 -0
  28. data/ext/rdwarf/libdwarf/NEWS +535 -0
  29. data/ext/rdwarf/libdwarf/README +235 -0
  30. data/ext/rdwarf/libdwarf/checkexamples.c +1179 -0
  31. data/ext/rdwarf/libdwarf/cmplrs/dwarf_addr_finder.h +55 -0
  32. data/ext/rdwarf/libdwarf/common.c +62 -0
  33. data/ext/rdwarf/libdwarf/common.h +38 -0
  34. data/ext/rdwarf/libdwarf/config.h.in +146 -0
  35. data/ext/rdwarf/libdwarf/configure +5581 -0
  36. data/ext/rdwarf/libdwarf/configure.in +167 -0
  37. data/ext/rdwarf/libdwarf/dw-linetableheader.txt +39 -0
  38. data/ext/rdwarf/libdwarf/dwarf.h +1342 -0
  39. data/ext/rdwarf/libdwarf/dwarf_abbrev.c +291 -0
  40. data/ext/rdwarf/libdwarf/dwarf_abbrev.h +45 -0
  41. data/ext/rdwarf/libdwarf/dwarf_addr_finder.c +676 -0
  42. data/ext/rdwarf/libdwarf/dwarf_alloc.c +685 -0
  43. data/ext/rdwarf/libdwarf/dwarf_alloc.h +38 -0
  44. data/ext/rdwarf/libdwarf/dwarf_arange.c +595 -0
  45. data/ext/rdwarf/libdwarf/dwarf_arange.h +62 -0
  46. data/ext/rdwarf/libdwarf/dwarf_base_types.h +157 -0
  47. data/ext/rdwarf/libdwarf/dwarf_die_deliv.c +1802 -0
  48. data/ext/rdwarf/libdwarf/dwarf_die_deliv.h +46 -0
  49. data/ext/rdwarf/libdwarf/dwarf_elf_access.c +1348 -0
  50. data/ext/rdwarf/libdwarf/dwarf_elf_access.h +46 -0
  51. data/ext/rdwarf/libdwarf/dwarf_error.c +492 -0
  52. data/ext/rdwarf/libdwarf/dwarf_error.h +53 -0
  53. data/ext/rdwarf/libdwarf/dwarf_form.c +1302 -0
  54. data/ext/rdwarf/libdwarf/dwarf_frame.c +2454 -0
  55. data/ext/rdwarf/libdwarf/dwarf_frame.h +418 -0
  56. data/ext/rdwarf/libdwarf/dwarf_frame2.c +1533 -0
  57. data/ext/rdwarf/libdwarf/dwarf_frame3.c +282 -0
  58. data/ext/rdwarf/libdwarf/dwarf_funcs.c +123 -0
  59. data/ext/rdwarf/libdwarf/dwarf_funcs.h +33 -0
  60. data/ext/rdwarf/libdwarf/dwarf_gdbindex.c +520 -0
  61. data/ext/rdwarf/libdwarf/dwarf_gdbindex.h +97 -0
  62. data/ext/rdwarf/libdwarf/dwarf_global.c +612 -0
  63. data/ext/rdwarf/libdwarf/dwarf_global.h +117 -0
  64. data/ext/rdwarf/libdwarf/dwarf_harmless.c +228 -0
  65. data/ext/rdwarf/libdwarf/dwarf_harmless.h +31 -0
  66. data/ext/rdwarf/libdwarf/dwarf_incl.h +61 -0
  67. data/ext/rdwarf/libdwarf/dwarf_init_finish.c +1263 -0
  68. data/ext/rdwarf/libdwarf/dwarf_leb.c +159 -0
  69. data/ext/rdwarf/libdwarf/dwarf_line.c +1822 -0
  70. data/ext/rdwarf/libdwarf/dwarf_line.h +446 -0
  71. data/ext/rdwarf/libdwarf/dwarf_line2.c +98 -0
  72. data/ext/rdwarf/libdwarf/dwarf_line_table_reader_common.c +1583 -0
  73. data/ext/rdwarf/libdwarf/dwarf_loc.c +1525 -0
  74. data/ext/rdwarf/libdwarf/dwarf_loc.h +149 -0
  75. data/ext/rdwarf/libdwarf/dwarf_loc2.c +833 -0
  76. data/ext/rdwarf/libdwarf/dwarf_macro.c +479 -0
  77. data/ext/rdwarf/libdwarf/dwarf_macro.h +35 -0
  78. data/ext/rdwarf/libdwarf/dwarf_opaque.h +778 -0
  79. data/ext/rdwarf/libdwarf/dwarf_original_elf_init.c +219 -0
  80. data/ext/rdwarf/libdwarf/dwarf_print_lines.c +631 -0
  81. data/ext/rdwarf/libdwarf/dwarf_pubtypes.c +132 -0
  82. data/ext/rdwarf/libdwarf/dwarf_query.c +1594 -0
  83. data/ext/rdwarf/libdwarf/dwarf_ranges.c +194 -0
  84. data/ext/rdwarf/libdwarf/dwarf_reloc_arm.h +308 -0
  85. data/ext/rdwarf/libdwarf/dwarf_reloc_mips.h +117 -0
  86. data/ext/rdwarf/libdwarf/dwarf_reloc_ppc.h +242 -0
  87. data/ext/rdwarf/libdwarf/dwarf_reloc_ppc64.h +272 -0
  88. data/ext/rdwarf/libdwarf/dwarf_reloc_x86_64.h +127 -0
  89. data/ext/rdwarf/libdwarf/dwarf_sort_line.c +665 -0
  90. data/ext/rdwarf/libdwarf/dwarf_string.c +82 -0
  91. data/ext/rdwarf/libdwarf/dwarf_stubs.c +38 -0
  92. data/ext/rdwarf/libdwarf/dwarf_tied.c +423 -0
  93. data/ext/rdwarf/libdwarf/dwarf_tsearch.h +125 -0
  94. data/ext/rdwarf/libdwarf/dwarf_tsearchhash.c +675 -0
  95. data/ext/rdwarf/libdwarf/dwarf_types.c +121 -0
  96. data/ext/rdwarf/libdwarf/dwarf_types.h +32 -0
  97. data/ext/rdwarf/libdwarf/dwarf_util.c +913 -0
  98. data/ext/rdwarf/libdwarf/dwarf_util.h +324 -0
  99. data/ext/rdwarf/libdwarf/dwarf_vars.c +125 -0
  100. data/ext/rdwarf/libdwarf/dwarf_vars.h +29 -0
  101. data/ext/rdwarf/libdwarf/dwarf_weaks.c +123 -0
  102. data/ext/rdwarf/libdwarf/dwarf_weaks.h +29 -0
  103. data/ext/rdwarf/libdwarf/dwarf_xu_index.c +579 -0
  104. data/ext/rdwarf/libdwarf/dwarf_xu_index.h +68 -0
  105. data/ext/rdwarf/libdwarf/dwgetopt.c +181 -0
  106. data/ext/rdwarf/libdwarf/dwgetopt.h +51 -0
  107. data/ext/rdwarf/libdwarf/gennames.c +531 -0
  108. data/ext/rdwarf/libdwarf/install.sh +119 -0
  109. data/ext/rdwarf/libdwarf/libdwarf.h.in +3746 -0
  110. data/ext/rdwarf/libdwarf/libdwarf2.1.mm +9805 -0
  111. data/ext/rdwarf/libdwarf/libdwarf2.1.pdf +0 -0
  112. data/ext/rdwarf/libdwarf/libdwarf2p.1.mm +2807 -0
  113. data/ext/rdwarf/libdwarf/libdwarf2p.1.pdf +0 -0
  114. data/ext/rdwarf/libdwarf/libdwarfdefs.h +81 -0
  115. data/ext/rdwarf/libdwarf/malloc_check.c +327 -0
  116. data/ext/rdwarf/libdwarf/malloc_check.h +52 -0
  117. data/ext/rdwarf/libdwarf/mips_extensions.mm +1266 -0
  118. data/ext/rdwarf/libdwarf/mips_extensions.pdf +0 -0
  119. data/ext/rdwarf/libdwarf/pro_alloc.c +179 -0
  120. data/ext/rdwarf/libdwarf/pro_alloc.h +33 -0
  121. data/ext/rdwarf/libdwarf/pro_arange.c +310 -0
  122. data/ext/rdwarf/libdwarf/pro_arange.h +51 -0
  123. data/ext/rdwarf/libdwarf/pro_die.c +431 -0
  124. data/ext/rdwarf/libdwarf/pro_die.h +59 -0
  125. data/ext/rdwarf/libdwarf/pro_encode_nm.c +108 -0
  126. data/ext/rdwarf/libdwarf/pro_encode_nm.h +39 -0
  127. data/ext/rdwarf/libdwarf/pro_error.c +96 -0
  128. data/ext/rdwarf/libdwarf/pro_error.h +43 -0
  129. data/ext/rdwarf/libdwarf/pro_expr.c +575 -0
  130. data/ext/rdwarf/libdwarf/pro_expr.h +36 -0
  131. data/ext/rdwarf/libdwarf/pro_finish.c +45 -0
  132. data/ext/rdwarf/libdwarf/pro_forms.c +1271 -0
  133. data/ext/rdwarf/libdwarf/pro_frame.c +572 -0
  134. data/ext/rdwarf/libdwarf/pro_frame.h +120 -0
  135. data/ext/rdwarf/libdwarf/pro_funcs.c +50 -0
  136. data/ext/rdwarf/libdwarf/pro_incl.h +91 -0
  137. data/ext/rdwarf/libdwarf/pro_init.c +327 -0
  138. data/ext/rdwarf/libdwarf/pro_line.c +373 -0
  139. data/ext/rdwarf/libdwarf/pro_line.h +112 -0
  140. data/ext/rdwarf/libdwarf/pro_macinfo.c +457 -0
  141. data/ext/rdwarf/libdwarf/pro_macinfo.h +31 -0
  142. data/ext/rdwarf/libdwarf/pro_opaque.h +513 -0
  143. data/ext/rdwarf/libdwarf/pro_pubnames.c +60 -0
  144. data/ext/rdwarf/libdwarf/pro_reloc.c +253 -0
  145. data/ext/rdwarf/libdwarf/pro_reloc.h +38 -0
  146. data/ext/rdwarf/libdwarf/pro_reloc_stream.c +256 -0
  147. data/ext/rdwarf/libdwarf/pro_reloc_stream.h +52 -0
  148. data/ext/rdwarf/libdwarf/pro_reloc_symbolic.c +245 -0
  149. data/ext/rdwarf/libdwarf/pro_reloc_symbolic.h +45 -0
  150. data/ext/rdwarf/libdwarf/pro_section.c +2233 -0
  151. data/ext/rdwarf/libdwarf/pro_section.h +100 -0
  152. data/ext/rdwarf/libdwarf/pro_types.c +274 -0
  153. data/ext/rdwarf/libdwarf/pro_types.h +34 -0
  154. data/ext/rdwarf/libdwarf/pro_util.h +38 -0
  155. data/ext/rdwarf/libdwarf/pro_vars.c +52 -0
  156. data/ext/rdwarf/libdwarf/pro_weaks.c +51 -0
  157. data/ext/rdwarf/rdwarf.c +765 -0
  158. data/ext/rdwarf/rdwarf.h +52 -0
  159. data/ext/rdwarf/rdwarf_names_gen.rb +109 -0
  160. data/lib/rdwarf.rb +181 -0
  161. data/lib/rdwarf/version.rb +3 -0
  162. data/rdwarf.gemspec +30 -0
  163. metadata +251 -0
@@ -0,0 +1,324 @@
1
+ #ifndef DWARF_UTIL_H
2
+ #define DWARF_UTIL_H
3
+ /*
4
+
5
+ Copyright (C) 2000,2003,2004 Silicon Graphics, Inc. All Rights Reserved.
6
+ Portions Copyright (C) 2007-2012 David Anderson. All Rights Reserved.
7
+ Portions Copyright (C) 2010-2012 SN Systems Ltd. All Rights Reserved
8
+
9
+ This program is free software; you can redistribute it and/or modify it
10
+ under the terms of version 2.1 of the GNU Lesser General Public License
11
+ as published by the Free Software Foundation.
12
+
13
+ This program is distributed in the hope that it would be useful, but
14
+ WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
+
17
+ Further, this software is distributed without any warranty that it is
18
+ free of the rightful claim of any third person regarding infringement
19
+ or the like. Any license provided herein, whether implied or
20
+ otherwise, applies only to this software file. Patent licenses, if
21
+ any, provided herein do not apply to combinations of this program with
22
+ other software, or any other product whatsoever.
23
+
24
+ You should have received a copy of the GNU Lesser General Public
25
+ License along with this program; if not, write the Free Software
26
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
27
+ USA.
28
+
29
+ */
30
+
31
+ /*
32
+ Decodes unsigned leb128 encoded numbers.
33
+ Make sure ptr is a pointer to a 1-byte type.
34
+ In 2003 and earlier this was a hand-inlined
35
+ version of _dwarf_decode_u_leb128() which did
36
+ not work correctly if Dwarf_Word was 64 bits.
37
+ */
38
+ #define DECODE_LEB128_UWORD(ptr, value) \
39
+ do { \
40
+ Dwarf_Word uleblen; \
41
+ value = _dwarf_decode_u_leb128(ptr,&uleblen); \
42
+ ptr += uleblen; \
43
+ } while (0)
44
+
45
+ /*
46
+ Decodes signed leb128 encoded numbers.
47
+ Make sure ptr is a pointer to a 1-byte type.
48
+ In 2003 and earlier this was a hand-inlined
49
+ version of _dwarf_decode_s_leb128() which did
50
+ not work correctly if Dwarf_Word was 64 bits.
51
+
52
+ */
53
+ #define DECODE_LEB128_SWORD(ptr, value) \
54
+ do { \
55
+ Dwarf_Word sleblen; \
56
+ value = _dwarf_decode_s_leb128(ptr,&sleblen); \
57
+ ptr += sleblen; \
58
+ } while (0)
59
+
60
+
61
+ /*
62
+ Skips leb128_encoded numbers that are guaranteed
63
+ to be no more than 4 bytes long. Same for both
64
+ signed and unsigned numbers.
65
+ */
66
+ #define SKIP_LEB128_WORD(ptr) \
67
+ do { \
68
+ if ((*(ptr++) & 0x80) != 0) { \
69
+ if ((*(ptr++) & 0x80) != 0) { \
70
+ if ((*(ptr++) & 0x80) != 0) { \
71
+ if ((*(ptr++) & 0x80) != 0) { \
72
+ } \
73
+ } \
74
+ } \
75
+ } \
76
+ } while (0)
77
+
78
+
79
+ #define CHECK_DIE(die, error_ret_value) \
80
+ do { \
81
+ if (die == NULL) { \
82
+ _dwarf_error(NULL, error, DW_DLE_DIE_NULL); \
83
+ return(error_ret_value); \
84
+ } \
85
+ if (die->di_cu_context == NULL) { \
86
+ _dwarf_error(NULL, error, DW_DLE_DIE_NO_CU_CONTEXT); \
87
+ return(error_ret_value); \
88
+ } \
89
+ if (die->di_cu_context->cc_dbg == NULL) { \
90
+ _dwarf_error(NULL, error, DW_DLE_DBG_NULL); \
91
+ return(error_ret_value); \
92
+ } \
93
+ } while (0)
94
+
95
+
96
+ /*
97
+ Reads 'source' for 'length' bytes from unaligned addr.
98
+
99
+ Avoids any constant-in-conditional warnings and
100
+ avoids a test in the generated code (for non-const cases,
101
+ which are in the majority.)
102
+ Uses a temp to avoid the test.
103
+ The decl here should avoid any problem of size in the temp.
104
+ This code is ENDIAN DEPENDENT
105
+ The memcpy args are the endian issue.
106
+ */
107
+ typedef Dwarf_Unsigned BIGGEST_UINT;
108
+
109
+ #ifdef WORDS_BIGENDIAN
110
+ #define READ_UNALIGNED(dbg,dest,desttype, source, length) \
111
+ do { \
112
+ BIGGEST_UINT _ltmp = 0; \
113
+ dbg->de_copy_word( (((char *)(&_ltmp)) + sizeof(_ltmp) - length), \
114
+ source, length) ; \
115
+ dest = (desttype)_ltmp; \
116
+ } while (0)
117
+
118
+
119
+ /*
120
+ This macro sign-extends a variable depending on the length.
121
+ It fills the bytes between the size of the destination and
122
+ the length with appropriate padding.
123
+ This code is ENDIAN DEPENDENT but dependent only
124
+ on host endianness, not object file endianness.
125
+ The memcpy args are the issue.
126
+ */
127
+ #define SIGN_EXTEND(dest, length) \
128
+ do { \
129
+ if (*(Dwarf_Sbyte *)((char *)&dest + sizeof(dest) - length) < 0) { \
130
+ memcpy((char *)&dest, "\xff\xff\xff\xff\xff\xff\xff\xff", \
131
+ sizeof(dest) - length); \
132
+ } \
133
+ } while (0)
134
+ #else /* LITTLE ENDIAN */
135
+
136
+ #define READ_UNALIGNED(dbg,dest,desttype, source, length) \
137
+ do { \
138
+ BIGGEST_UINT _ltmp = 0; \
139
+ dbg->de_copy_word( (char *)(&_ltmp) , \
140
+ source, length) ; \
141
+ dest = (desttype)_ltmp; \
142
+ } while (0)
143
+
144
+
145
+ /*
146
+ This macro sign-extends a variable depending on the length.
147
+ It fills the bytes between the size of the destination and
148
+ the length with appropriate padding.
149
+ This code is ENDIAN DEPENDENT but dependent only
150
+ on host endianness, not object file endianness.
151
+ The memcpy args are the issue.
152
+ */
153
+ #define SIGN_EXTEND(dest, length) \
154
+ do { \
155
+ if (*(Dwarf_Sbyte *)((char *)&dest + (length-1)) < 0) { \
156
+ memcpy((char *)&dest+length, \
157
+ "\xff\xff\xff\xff\xff\xff\xff\xff", \
158
+ sizeof(dest) - length); \
159
+ } \
160
+ } while (0)
161
+
162
+ #endif /* ! LITTLE_ENDIAN */
163
+
164
+
165
+
166
+ /*
167
+ READ_AREA LENGTH reads the length (the older way
168
+ of pure 32 or 64 bit
169
+ or the dwarf v3 64bit-extension way)
170
+
171
+ It reads the bits from where rw_src_data_p points to
172
+ and updates the rw_src_data_p to point past what was just read.
173
+
174
+ It updates w_length_size (to the size of an offset, either 4 or 8)
175
+ and w_exten_size (set 0 unless this frame has the DWARF3
176
+ and later 64bit
177
+ extension, in which case w_exten_size is set to 4).
178
+
179
+ r_dbg is just the current dbg pointer.
180
+ w_target is the output length field.
181
+ r_targtype is the output type. Always Dwarf_Unsigned so far.
182
+
183
+ */
184
+ /* This one handles the v3 64bit extension
185
+ and 32bit (and SGI/MIPS fixed 64 bit via the
186
+ dwarf_init-set r_dbg->de_length_size)..
187
+ It does not recognize any but the one distingushed value
188
+ (the only one with defined meaning).
189
+ It assumes that no CU will have a length
190
+ 0xffffffxx (32bit length)
191
+ or
192
+ 0xffffffxx xxxxxxxx (64bit length)
193
+ which makes possible auto-detection of the extension.
194
+
195
+ This depends on knowing that only a non-zero length
196
+ is legitimate (AFAICT), and for IRIX non-standard -64
197
+ dwarf that the first 32 bits of the 64bit offset will be
198
+ zero (because the compiler could not handle a truly large
199
+ value as of Jan 2003 and because no app has that much debug
200
+ info anyway, at least not in the IRIX case).
201
+
202
+ At present not testing for '64bit elf' here as that
203
+ does not seem necessary (none of the 64bit length seems
204
+ appropriate unless it's ident[EI_CLASS] == ELFCLASS64).
205
+ */
206
+ #define READ_AREA_LENGTH(r_dbg,w_target,r_targtype, \
207
+ rw_src_data_p,w_length_size,w_exten_size) \
208
+ do { \
209
+ READ_UNALIGNED(r_dbg,w_target,r_targtype, \
210
+ rw_src_data_p, ORIGINAL_DWARF_OFFSET_SIZE); \
211
+ if (w_target == DISTINGUISHED_VALUE) { \
212
+ /* dwarf3 64bit extension */ \
213
+ w_length_size = DISTINGUISHED_VALUE_OFFSET_SIZE; \
214
+ rw_src_data_p += ORIGINAL_DWARF_OFFSET_SIZE; \
215
+ w_exten_size = ORIGINAL_DWARF_OFFSET_SIZE; \
216
+ READ_UNALIGNED(r_dbg,w_target,r_targtype, \
217
+ rw_src_data_p, DISTINGUISHED_VALUE_OFFSET_SIZE); \
218
+ rw_src_data_p += DISTINGUISHED_VALUE_OFFSET_SIZE; \
219
+ } else { \
220
+ if (w_target == 0 && r_dbg->de_big_endian_object) { \
221
+ /* Might be IRIX: We have to distinguish between */ \
222
+ /* 32-bit DWARF format and IRIX 64-bit DWARF format. */ \
223
+ if (r_dbg->de_length_size == 8) { \
224
+ /* IRIX 64 bit, big endian. This test */ \
225
+ /* is not a truly precise test, a precise test */ \
226
+ /* would check if the target was IRIX. */ \
227
+ READ_UNALIGNED(r_dbg,w_target,r_targtype, \
228
+ rw_src_data_p, DISTINGUISHED_VALUE_OFFSET_SIZE); \
229
+ w_length_size = DISTINGUISHED_VALUE_OFFSET_SIZE; \
230
+ rw_src_data_p += DISTINGUISHED_VALUE_OFFSET_SIZE; \
231
+ w_exten_size = 0; \
232
+ } else { \
233
+ /* 32 bit, big endian */ \
234
+ w_length_size = ORIGINAL_DWARF_OFFSET_SIZE; \
235
+ rw_src_data_p += w_length_size; \
236
+ w_exten_size = 0; \
237
+ } \
238
+ } else { \
239
+ /* Standard 32 bit dwarf2/dwarf3 */ \
240
+ w_exten_size = 0; \
241
+ w_length_size = ORIGINAL_DWARF_OFFSET_SIZE; \
242
+ rw_src_data_p += w_length_size; \
243
+ } \
244
+ } \
245
+ } while (0)
246
+
247
+ Dwarf_Unsigned
248
+ _dwarf_decode_u_leb128(Dwarf_Small * leb128,
249
+ Dwarf_Word * leb128_length);
250
+
251
+ Dwarf_Signed
252
+ _dwarf_decode_s_leb128(Dwarf_Small * leb128,
253
+ Dwarf_Word * leb128_length);
254
+
255
+ int
256
+ _dwarf_get_size_of_val(Dwarf_Debug dbg,
257
+ Dwarf_Unsigned form,
258
+ Dwarf_Half cu_version,
259
+ Dwarf_Half address_size,
260
+ Dwarf_Small * val_ptr,
261
+ int v_length_size,
262
+ Dwarf_Unsigned *size_out,
263
+ Dwarf_Error *error);
264
+
265
+ struct Dwarf_Hash_Table_Entry_s;
266
+ /* This single struct is the base for the hash table.
267
+ The intent is that once the total_abbrev_count across
268
+ all the entries is greater than 10*current_table_entry_count
269
+ one should build a new Dwarf_Hash_Table_Base_s, rehash
270
+ all the existing entries, and delete the old table and entries.
271
+ (10 is a heuristic, nothing magic about it, but once the
272
+ count gets to 30 or 40 times current_table_entry_count
273
+ things really slow down a lot. One (500MB) application had
274
+ 127000 abbreviations in one compilation unit)
275
+ The incoming 'code' is an abbrev number and those simply
276
+ increase linearly so the hashing is perfect always.
277
+ */
278
+ struct Dwarf_Hash_Table_s {
279
+ unsigned long tb_table_entry_count;
280
+ unsigned long tb_total_abbrev_count;
281
+ /* Each table entry is a list of abbreviations. */
282
+ struct Dwarf_Hash_Table_Entry_s *tb_entries;
283
+ };
284
+
285
+ /*
286
+ This struct is used to build a hash table for the
287
+ abbreviation codes for a compile-unit.
288
+ */
289
+ struct Dwarf_Hash_Table_Entry_s {
290
+ Dwarf_Abbrev_List at_head;
291
+ };
292
+
293
+
294
+
295
+ Dwarf_Abbrev_List
296
+ _dwarf_get_abbrev_for_code(Dwarf_CU_Context cu_context,
297
+ Dwarf_Unsigned code);
298
+
299
+
300
+ /* return 1 if string ends before 'endptr' else
301
+ ** return 0 meaning string is not properly terminated.
302
+ ** Presumption is the 'endptr' pts to end of some dwarf section data.
303
+ */
304
+ int _dwarf_check_string_valid(Dwarf_Debug dbg,void *areaptr,
305
+ void *startptr, void *endptr, Dwarf_Error *error);
306
+
307
+ Dwarf_Unsigned _dwarf_length_of_cu_header(Dwarf_Debug,
308
+ Dwarf_Unsigned offset,Dwarf_Bool dinfo);
309
+ Dwarf_Unsigned _dwarf_length_of_cu_header_simple(Dwarf_Debug,Dwarf_Bool dinfo);
310
+
311
+ int _dwarf_load_debug_info(Dwarf_Debug dbg, Dwarf_Error *error);
312
+ int _dwarf_load_debug_types(Dwarf_Debug dbg, Dwarf_Error *error);
313
+ void _dwarf_free_abbrev_hash_table_contents(Dwarf_Debug dbg,
314
+ struct Dwarf_Hash_Table_s* hash_table);
315
+ int _dwarf_get_address_size(Dwarf_Debug dbg, Dwarf_Die die);
316
+ int _dwarf_reference_outside_section(Dwarf_Die die,
317
+ Dwarf_Small * startaddr,
318
+ Dwarf_Small * pastend);
319
+ void _dwarf_error_mv_s_to_t(Dwarf_Debug dbgs,Dwarf_Error *errs,
320
+ Dwarf_Debug dbgt,Dwarf_Error *errt);
321
+
322
+
323
+
324
+ #endif /* DWARF_UTIL_H */
@@ -0,0 +1,125 @@
1
+ /*
2
+
3
+ Copyright (C) 2000,2002,2004,2005 Silicon Graphics, Inc. All Rights Reserved.
4
+ Portions Copyright (C) 2009-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
+ #include "config.h"
29
+ #include "dwarf_incl.h"
30
+ #include <stdio.h>
31
+ #include "dwarf_vars.h"
32
+ #include "dwarf_global.h"
33
+
34
+ int
35
+ dwarf_get_vars(Dwarf_Debug dbg,
36
+ Dwarf_Var ** vars,
37
+ Dwarf_Signed * ret_var_count, Dwarf_Error * error)
38
+ {
39
+ int res = _dwarf_load_section(dbg, &dbg->de_debug_varnames,error);
40
+ if (res != DW_DLV_OK) {
41
+ return res;
42
+ }
43
+ if (!dbg->de_debug_abbrev.dss_size) {
44
+ return (DW_DLV_NO_ENTRY);
45
+ }
46
+
47
+ return _dwarf_internal_get_pubnames_like_data(dbg,
48
+ dbg->de_debug_varnames.dss_data,
49
+ dbg->de_debug_varnames.dss_size,
50
+ (Dwarf_Global **) vars, /* Type punning for sections
51
+ with identical format. */
52
+ ret_var_count,
53
+ error,
54
+ DW_DLA_VAR_CONTEXT,
55
+ DW_DLA_VAR,
56
+ DW_DLE_DEBUG_VARNAMES_LENGTH_BAD,
57
+ DW_DLE_DEBUG_VARNAMES_VERSION_ERROR);
58
+ }
59
+
60
+ /* Deallocating fully requires deallocating the list
61
+ and all entries. But some internal data is
62
+ not exposed, so we need a function with internal knowledge.
63
+ */
64
+
65
+ void
66
+ dwarf_vars_dealloc(Dwarf_Debug dbg, Dwarf_Var * dwgl,
67
+ Dwarf_Signed count)
68
+ {
69
+ _dwarf_internal_globals_dealloc(dbg, (Dwarf_Global *) dwgl,
70
+ count,
71
+ DW_DLA_VAR_CONTEXT,
72
+ DW_DLA_VAR, DW_DLA_LIST);
73
+ return;
74
+ }
75
+
76
+
77
+ int
78
+ dwarf_varname(Dwarf_Var var_in, char **ret_varname, Dwarf_Error * error)
79
+ {
80
+ Dwarf_Global var = (Dwarf_Global) var_in;
81
+
82
+ if (var == NULL) {
83
+ _dwarf_error(NULL, error, DW_DLE_VAR_NULL);
84
+ return (DW_DLV_ERROR);
85
+ }
86
+
87
+ *ret_varname = (char *) (var->gl_name);
88
+ return DW_DLV_OK;
89
+ }
90
+
91
+
92
+ int
93
+ dwarf_var_die_offset(Dwarf_Var var_in,
94
+ Dwarf_Off * returned_offset, Dwarf_Error * error)
95
+ {
96
+ Dwarf_Global var = (Dwarf_Global) var_in;
97
+
98
+ return dwarf_global_die_offset(var, returned_offset, error);
99
+
100
+ }
101
+
102
+
103
+ int
104
+ dwarf_var_cu_offset(Dwarf_Var var_in,
105
+ Dwarf_Off * returned_offset, Dwarf_Error * error)
106
+ {
107
+ Dwarf_Global var = (Dwarf_Global) var_in;
108
+
109
+ return dwarf_global_cu_offset(var, returned_offset, error);
110
+ }
111
+
112
+
113
+ int
114
+ dwarf_var_name_offsets(Dwarf_Var var_in,
115
+ char **returned_name,
116
+ Dwarf_Off * die_offset,
117
+ Dwarf_Off * cu_offset, Dwarf_Error * error)
118
+ {
119
+ Dwarf_Global var = (Dwarf_Global) var_in;
120
+
121
+ return
122
+ dwarf_global_name_offsets(var,
123
+ returned_name, die_offset, cu_offset,
124
+ error);
125
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+
3
+ Copyright (C) 2000,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
+ */
26
+
27
+ typedef struct Dwarf_Var_Context_s *Dwarf_Var_Context;
28
+
29
+ /* struct never completed: see dwarf_global.h */