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,446 @@
1
+ /*
2
+ Copyright (C) 2000, 2004, 2006 Silicon Graphics, Inc. All Rights Reserved.
3
+ Portions Copyright (C) 2009-2015 David Anderson. All Rights Reserved.
4
+ Portions Copyright (C) 2010-2012 SN Systems Ltd. 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
+
29
+
30
+ #define DW_EXTENDED_OPCODE 0
31
+
32
+ /*
33
+ This is used as the starting value for an algorithm
34
+ to get the minimum difference between 2 values.
35
+ UINT_MAX is used as our approximation to infinity.
36
+ */
37
+ #define MAX_LINE_DIFF UINT_MAX
38
+
39
+ /* This is for a sanity check on line
40
+ table extended opcodes.
41
+ It is entirely arbitrary, and 100 is surely too small if
42
+ someone was inserting strings in the opcode. */
43
+ #define DW_LNE_LEN_MAX 100
44
+
45
+
46
+ /*
47
+ This structure is used to build a list of all the
48
+ files that are used in the current compilation unit.
49
+ All of the fields execpt fi_next have meanings that
50
+ are obvious from section 6.2.4 of the Libdwarf Doc.
51
+ Because of DW_LNE_define_file we
52
+ make this a list, not an array.
53
+ */
54
+ struct Dwarf_File_Entry_s {
55
+ struct Dwarf_File_Entry_s *fi_next;
56
+
57
+ /* Points to string naming the file. */
58
+ Dwarf_Small *fi_file_name;
59
+
60
+ /* Index into the list of directories of the directory in which
61
+ this file exits. */
62
+ Dwarf_Sword fi_dir_index;
63
+
64
+ /* Time of last modification of the file. */
65
+ Dwarf_Unsigned fi_time_last_mod;
66
+
67
+ /* Length in bytes of the file. */
68
+ Dwarf_Unsigned fi_file_length;
69
+ };
70
+
71
+ /* Part of two-level line tables support. */
72
+ struct Dwarf_Subprog_Entry_s {
73
+ Dwarf_Small *ds_subprog_name;
74
+ Dwarf_Unsigned ds_decl_file;
75
+ Dwarf_Unsigned ds_decl_line;
76
+ };
77
+
78
+ typedef struct Dwarf_Subprog_Entry_s *Dwarf_Subprog_Entry;
79
+
80
+
81
+ /*
82
+ This structure provides the context in which the fields of
83
+ a Dwarf_Line structure are interpreted. They come from the
84
+ statement program prologue. **Updated by dwarf_srclines in
85
+ dwarf_line.c.
86
+
87
+ lc_magic will be DW_CONTEXT_MAGIC unless there is a serious
88
+ programming error somewhere.
89
+ It's set zero when a Line_Context is deallocated.
90
+ Any other value indicates there is bug somewhere.
91
+ */
92
+ #define DW_CONTEXT_MAGIC 0xd00d1111
93
+ struct Dwarf_Line_Context_s {
94
+ unsigned lc_magic;
95
+
96
+ /* lc_new_style_access is non-zero if this was allocated
97
+ via a dwarf_srclines_b() call or equivalent.
98
+ Otherwise this is 0. */
99
+ unsigned char lc_new_style_access;
100
+
101
+ /* The section offset (in .debug_line
102
+ or .debug_line.dwo of the line table */
103
+ Dwarf_Unsigned lc_section_offset;
104
+
105
+ /* 2 for DWARF2, 3 for DWARF3, 4 for DWARF4, 5 for DWARF5.
106
+ 0xf006 for experimental two-level line tables. */
107
+ Dwarf_Half lc_version_number;
108
+
109
+ /* Total length of the line data for this CU */
110
+ Dwarf_Unsigned lc_total_length;
111
+
112
+ /* Length of the initial length field itself. */
113
+ Dwarf_Half lc_length_field_length;
114
+
115
+ /* address size and segment sizefields new in DWARF5 header. */
116
+ Dwarf_Small lc_address_size;
117
+ Dwarf_Small lc_segment_selector_size;
118
+
119
+ Dwarf_Unsigned lc_prologue_length;
120
+ Dwarf_Unsigned lc_actuals_table_offset;
121
+ Dwarf_Unsigned lc_logicals_table_offset;
122
+ Dwarf_Small lc_minimum_instruction_length;
123
+
124
+ /* Start and end of this CU line area. pf_line_ptr_start +
125
+ pf_total_length + pf_length_field_length == pf_line_ptr_end.
126
+ Meaning lc_line_ptr_start is before the length info. */
127
+ Dwarf_Small *lc_line_ptr_start;
128
+ Dwarf_Small *lc_line_ptr_end;
129
+ /* Start of the lines themselves. */
130
+ Dwarf_Small *lc_line_ptr_lines;
131
+
132
+ /* Used to check that decoding of the line prologue is done right. */
133
+ Dwarf_Small *lc_line_prologue_start;
134
+
135
+ Dwarf_Small lc_default_is_stmt;
136
+ Dwarf_Ubyte lc_maximum_ops_per_instruction; /*DWARF5*/
137
+ Dwarf_Sbyte lc_line_base;
138
+ Dwarf_Small lc_line_range;
139
+
140
+ /* Highest std opcode (+1). */
141
+ Dwarf_Small lc_opcode_base;
142
+ /* pf_opcode_base -1 entries (each a count, normally the value of
143
+ each entry is 0 or 1). */
144
+ Dwarf_Small *lc_opcode_length_table;
145
+
146
+ /* The number to treat as standard ops. This is a special
147
+ accomodation of gcc using the new standard opcodes but not
148
+ updating the version number. It's legal dwarf2, but much better
149
+ for the user to understand as dwarf3 when 'it looks ok'. */
150
+ Dwarf_Bool lc_std_op_count;
151
+
152
+ /* Points to a singly-linked list of entries providing info about source files
153
+ for the current set of Dwarf_Line structures.
154
+ The initial entry on the list is 'file 1' per DWARF rules.
155
+ And so on. lc_last_entry points at the last entry
156
+ in the list (so we can easily expand the list).
157
+ It's a list (not a table) since we may encounter
158
+ DW_LNE_define_file entries. */
159
+ Dwarf_File_Entry lc_file_entries;
160
+ Dwarf_File_Entry lc_last_entry;
161
+ /* Count of number of source files for this set of Dwarf_Line
162
+ structures. */
163
+ Dwarf_Sword lc_file_entry_count;
164
+
165
+
166
+ /* Points to the portion of .debug_line section that
167
+ contains a list of strings naming the included
168
+ directories. Do not free().
169
+ An array of pointers to strings. */
170
+ Dwarf_Small **lc_include_directories;
171
+ /* Count of the number of included directories. */
172
+ Dwarf_Sword lc_include_directories_count;
173
+
174
+
175
+ /* Points to an array of subprogram entries.
176
+ With Two level line tables this may be non-zero.
177
+ An array of Dwarf_Subprogram_Entry_s structs. */
178
+ Dwarf_Subprog_Entry lc_subprogs;
179
+
180
+ /* Count of the number of subprogram entries
181
+ With Two level line tables this may be non-zero. */
182
+ Dwarf_Sword lc_subprogs_count;
183
+
184
+ /* Count of the number of lines for this cu. */
185
+ Dwarf_Sword lc_line_count;
186
+
187
+ /* Points to name of compilation directory.
188
+ That string is in a .debug section so
189
+ do not free this. */
190
+ Dwarf_Small *lc_compilation_directory;
191
+
192
+ Dwarf_Debug lc_dbg;
193
+
194
+ /* zero table count is skeleton, or just missing names.
195
+ 1 is standard table.
196
+ 2 means two-level table (experimantal)
197
+ Other is a bug somewhere. */
198
+ Dwarf_Small lc_table_count;
199
+ Dwarf_Bool lc_is_single_table;
200
+
201
+ /* For standard line tables the logicals are
202
+ the only tables and linecount_actuals is 0. */
203
+ Dwarf_Line *lc_linebuf_logicals;
204
+ Dwarf_Signed lc_linecount_logicals;
205
+
206
+ /* Non-zero only if two-level table with actuals */
207
+ Dwarf_Line *lc_linebuf_actuals;
208
+ Dwarf_Signed lc_linecount_actuals;
209
+
210
+ };
211
+
212
+
213
+
214
+ /* The line table set of registers.
215
+ The state machine state variables.
216
+ Using names from the DWARF documentation
217
+ but preceded by lr_. */
218
+ struct Dwarf_Line_Registers_s {
219
+ Dwarf_Addr lr_address; /* DWARF2 */
220
+ Dwarf_Word lr_file ; /* DWARF2 */
221
+ Dwarf_Word lr_line ; /* DWARF2 */
222
+ Dwarf_Word lr_column ; /* DWARF2 */
223
+ Dwarf_Bool lr_is_stmt; /* DWARF2 */
224
+ Dwarf_Bool lr_basic_block; /* DWARF2 */
225
+ Dwarf_Bool lr_end_sequence; /* DWARF2 */
226
+ Dwarf_Bool lr_prologue_end; /* DWARF3 */
227
+ Dwarf_Bool lr_epilogue_begin; /* DWARF3 */
228
+ Dwarf_Small lr_isa; /* DWARF3 */
229
+ Dwarf_Unsigned lr_op_index; /* DWARF4, operation within VLIW instruction. */
230
+ Dwarf_Unsigned lr_discriminator; /* DWARF4 */
231
+ Dwarf_Unsigned lr_call_context; /* EXPERIMENTAL */
232
+ Dwarf_Unsigned lr_subprogram; /* EXPERIMENTAL */
233
+ };
234
+ typedef struct Dwarf_Line_Registers_s *Dwarf_Line_Registers;
235
+ void _dwarf_set_line_table_regs_default_values(Dwarf_Line_Registers regs,
236
+ Dwarf_Bool is_stmt);
237
+
238
+
239
+
240
+ /*
241
+ This structure defines a row of the line table.
242
+ All of the fields except li_offset have the exact
243
+ same meaning that is defined in Section 6.2.2
244
+ of the Libdwarf Document.
245
+
246
+ li_offset is used by _dwarf_addr_finder() which is called
247
+ by rqs(1), an sgi utility for 'moving' shared libraries
248
+ as if the static linker (ld) had linked the shared library
249
+ at the newly-specified address. Most libdwarf-using
250
+ apps will ignore li_offset and _dwarf_addr_finder().
251
+
252
+ */
253
+ struct Dwarf_Line_s {
254
+ Dwarf_Addr li_address; /* pc value of machine instr */
255
+ union addr_or_line_s {
256
+ struct li_inner_s {
257
+ /* New as of DWARF4 */
258
+ Dwarf_Unsigned li_discriminator;
259
+
260
+ /* int identifying src file
261
+ li_file is a number 1-N, indexing into a conceptual
262
+ source file table as described in dwarf2/3 spec line
263
+ table doc. (see Dwarf_File_Entry lc_file_entries; and
264
+ Dwarf_Sword lc_file_entry_count;) */
265
+ Dwarf_Sword li_file;
266
+
267
+ /* In single-level table is line number in source file. 1-N
268
+ In logicals table is not used.
269
+ In actuals table is index into logicals table. 1-N*/
270
+ Dwarf_Sword li_line;
271
+
272
+ Dwarf_Half li_column; /* source file column number 1-N */
273
+ Dwarf_Small li_isa; /* New as of DWARF4. */
274
+
275
+ /* Two-level line tables.
276
+ Is index from logicals table
277
+ into logicals table. 1-N */
278
+ Dwarf_Unsigned li_call_context;
279
+
280
+ /* Two-level line tables.
281
+ is index into subprograms table. 1-N */
282
+ Dwarf_Unsigned li_subprogram;
283
+
284
+ /* To save space, use bit flags. */
285
+ /* indicate start of stmt */
286
+ unsigned char li_is_stmt:1;
287
+
288
+ /* indicate start basic block */
289
+ unsigned char li_basic_block:1;
290
+
291
+ /* first post sequence instr */
292
+ unsigned char li_end_sequence:1;
293
+
294
+ unsigned char li_prologue_end:1;
295
+ unsigned char li_epilogue_begin:1;
296
+
297
+ /* Mark a line record as being DW_LNS_set_address. */
298
+ unsigned char li_is_addr_set:1;
299
+ } li_l_data;
300
+ #ifdef __sgi /* SGI IRIX ONLY */
301
+ Dwarf_Off li_offset; /* for SGI IRIX rqs only*/
302
+ #endif /* __sgi */
303
+ } li_addr_line;
304
+ Dwarf_Line_Context li_context; /* assoc Dwarf_Line_Context_s */
305
+
306
+ /* Set only on the actuals table of a two-level line table.
307
+ Assists in the dealloc code.
308
+ */
309
+ Dwarf_Bool li_is_actuals_table;
310
+ };
311
+
312
+
313
+ int _dwarf_line_address_offsets(Dwarf_Debug dbg,
314
+ Dwarf_Die die,
315
+ Dwarf_Addr ** addrs,
316
+ Dwarf_Off ** offs,
317
+ Dwarf_Unsigned * returncount,
318
+ Dwarf_Error * err);
319
+ int _dwarf_internal_srclines(Dwarf_Die die,
320
+ Dwarf_Bool old_interface,
321
+ Dwarf_Unsigned * version,
322
+ Dwarf_Small * table_count,
323
+ Dwarf_Line_Context *line_context,
324
+ Dwarf_Line ** linebuf,
325
+ Dwarf_Signed * count,
326
+ Dwarf_Line ** linebuf_actuals,
327
+ Dwarf_Signed * count_actuals,
328
+ Dwarf_Bool doaddrs,
329
+ Dwarf_Bool dolines,
330
+ Dwarf_Error * error);
331
+
332
+ /* The LOP, WHAT_IS_OPCODE stuff is here so it can
333
+ be reused in 3 places. Seemed hard to keep
334
+ the 3 places the same without an inline func or
335
+ a macro.
336
+
337
+ Handling the line section where the header and the
338
+ file being processed do not match (unusual, but
339
+ planned for in the design of .debug_line)
340
+ is too tricky to recode this several times and keep
341
+ it right.
342
+
343
+ As it is the code starting up line-reading is duplicated
344
+ and that is just wrong to do. FIXME!
345
+ */
346
+ #define LOP_EXTENDED 1
347
+ #define LOP_DISCARD 2
348
+ #define LOP_STANDARD 3
349
+ #define LOP_SPECIAL 4
350
+
351
+ #define WHAT_IS_OPCODE(type,opcode,base,opcode_length,line_ptr,highest_std) \
352
+ if ((opcode) < (base)) { \
353
+ /* we know we must treat as a standard op \
354
+ or a special case. */ \
355
+ if ((opcode) == DW_EXTENDED_OPCODE) { \
356
+ type = LOP_EXTENDED; \
357
+ } else if (((highest_std)+1) >= (base)) { \
358
+ /* == Standard case: compile of \
359
+ dwarf_line.c and object \
360
+ have same standard op codes set. \
361
+ == Special case: compile of dwarf_line.c \
362
+ has things in standard op codes list \
363
+ in dwarf.h header not \
364
+ in the object: handle this as a standard \
365
+ op code in switch below. \
366
+ The header special ops overlap the \
367
+ object standard ops. \
368
+ The new standard op codes will not \
369
+ appear in the object. */ \
370
+ type = LOP_STANDARD; \
371
+ } else { \
372
+ /* These are standard opcodes in the object \
373
+ ** that were not defined in the header \
374
+ ** at the time dwarf_line.c \
375
+ ** was compiled. Provides the ability of \
376
+ ** out-of-date dwarf reader to read newer \
377
+ ** line table data transparently. \
378
+ */ \
379
+ type = LOP_DISCARD; \
380
+ } \
381
+ } else { \
382
+ /* Is a special op code. */ \
383
+ type = LOP_SPECIAL; \
384
+ }
385
+
386
+ /* The following is from the dwarf definition of 'ubyte'
387
+ and is specifically mentioned in section 6.2.5.1, page 54
388
+ of the Rev 2.0.0 dwarf specification.
389
+ */
390
+
391
+ #define MAX_LINE_OP_CODE 255
392
+
393
+
394
+ # if 0
395
+ /* The following structs (Line_Table_File_Entry_s,Dwarf_Line_Context_s)
396
+ and functions allow refactoring common code into a single
397
+ reader routine.
398
+ */
399
+ Not used once Prefix struct folded into line context struct.
400
+ /* There can be zero of more of these needed for 1 line prologue. */
401
+ struct Line_Table_File_Entry_s {
402
+ Dwarf_Small *lte_filename;
403
+ Dwarf_Unsigned lte_directory_index;
404
+ Dwarf_Unsigned lte_last_modification_time;
405
+ Dwarf_Unsigned lte_length_of_file;
406
+ };
407
+ #endif
408
+
409
+
410
+ /* Operand counts per standard operand.
411
+ The initial zero is for DW_LNS_copy.
412
+ This is an economical way to verify we understand the table
413
+ of standard-opcode-lengths in the line table prologue. */
414
+ #define STANDARD_OPERAND_COUNT_DWARF2 9
415
+ #define STANDARD_OPERAND_COUNT_DWARF3 12
416
+ /* For two-level line tables, we have three additional standard opcodes. */
417
+ #define STANDARD_OPERAND_COUNT_TWO_LEVEL 15
418
+
419
+ void _dwarf_print_header_issue(Dwarf_Debug dbg,
420
+ const char *specific_msg,
421
+ Dwarf_Small *data_start,
422
+ int *err_count_out);
423
+ int _dwarf_decode_line_string_form(Dwarf_Debug dbg,
424
+ Dwarf_Unsigned form,
425
+ Dwarf_Unsigned offset_size,
426
+ Dwarf_Small **line_ptr,
427
+ Dwarf_Small *line_ptr_end,
428
+ char **return_str,
429
+ Dwarf_Error * error);
430
+ int _dwarf_decode_line_udata_form(Dwarf_Debug dbg,
431
+ Dwarf_Unsigned form,
432
+ Dwarf_Small **line_ptr,
433
+ Dwarf_Unsigned *return_val,
434
+ Dwarf_Error * error);
435
+
436
+ void _dwarf_update_chain_list( Dwarf_Chain chain_line,
437
+ Dwarf_Chain *head_chain, Dwarf_Chain *curr_chain);
438
+ void _dwarf_free_chain_entries(Dwarf_Debug dbg,Dwarf_Chain head,int count);
439
+
440
+ int _dwarf_line_context_constructor(Dwarf_Debug dbg, void *m);
441
+ void _dwarf_line_context_destructor(void *m);
442
+
443
+ void _dwarf_print_line_context_record(Dwarf_Debug dbg,
444
+ Dwarf_Line_Context line_context);
445
+ void _dwarf_context_src_files_destroy(Dwarf_Line_Context context);
446
+ int _dwarf_add_to_files_list(Dwarf_Line_Context context, Dwarf_File_Entry fe);
@@ -0,0 +1,98 @@
1
+ /*
2
+
3
+ Copyright (C) 2000,2002,2004,2005,2006 Silicon Graphics, Inc. All Rights Reserved.
4
+ Portions Copyright 2008-2011 David Anderson, Inc. 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
+ /* This source file used for SGI-IRIX rqs processing.
29
+ Unused otherwise.
30
+ */
31
+
32
+ #include "config.h"
33
+ #include "dwarf_incl.h"
34
+ #include <stdio.h>
35
+ #include "dwarf_line.h"
36
+
37
+ #ifdef __sgi /* SGI IRIX ONLY */
38
+ /* Return DW_DLV_OK or, if error,
39
+ DW_DLV_ERROR.
40
+
41
+ Thru pointers, return 2 arrays and a count
42
+ for rqs (IRIX run-time linker).
43
+ ONLY meant for SGI IRIX */
44
+ int
45
+ _dwarf_line_address_offsets(Dwarf_Debug dbg,
46
+ Dwarf_Die die,
47
+ Dwarf_Addr ** addrs,
48
+ Dwarf_Off ** offs,
49
+ Dwarf_Unsigned * returncount,
50
+ Dwarf_Error * err)
51
+ {
52
+ Dwarf_Addr *laddrs;
53
+ Dwarf_Off *loffsets;
54
+ Dwarf_Signed lcount;
55
+ Dwarf_Signed i;
56
+ int res;
57
+ Dwarf_Line *linebuf;
58
+
59
+ res = _dwarf_internal_srclines(die, /* version= */ NULL,
60
+ &linebuf, &lcount,
61
+ /* actuals= */ NULL, /* actualscount= */ NULL,
62
+ /* addrlist= */ true,
63
+ /* linelist= */ false,
64
+ err);
65
+ if (res != DW_DLV_OK) {
66
+ return res;
67
+ }
68
+ laddrs = (Dwarf_Addr *)
69
+ _dwarf_get_alloc(dbg, DW_DLA_ADDR, lcount);
70
+ if (laddrs == NULL) {
71
+ dwarf_srclines_dealloc(dbg, linebuf, lcount);
72
+ _dwarf_error(dbg, err, DW_DLE_ALLOC_FAIL);
73
+ return (DW_DLV_ERROR);
74
+ }
75
+ loffsets = (Dwarf_Off *)
76
+ _dwarf_get_alloc(dbg, DW_DLA_ADDR, lcount);
77
+ if (loffsets == NULL) {
78
+ dwarf_srclines_dealloc(dbg, linebuf, lcount);
79
+ /* We already allocated what laddrs points at, so we'e better
80
+ deallocate that space since we are not going to return the
81
+ pointer to the caller. */
82
+ dwarf_dealloc(dbg, laddrs, DW_DLA_ADDR);
83
+ _dwarf_error(dbg, err, DW_DLE_ALLOC_FAIL);
84
+ return (DW_DLV_ERROR);
85
+ }
86
+
87
+ for (i = 0; i < lcount; i++) {
88
+ laddrs[i] = linebuf[i]->li_address;
89
+ loffsets[i] = linebuf[i]->li_addr_line.li_offset;
90
+ }
91
+ dwarf_srclines_dealloc(dbg, linebuf, lcount);
92
+ *returncount = lcount;
93
+ *offs = loffsets;
94
+ *addrs = laddrs;
95
+ return DW_DLV_OK;
96
+ }
97
+ #endif /* __sgi */
98
+