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,373 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
4
|
+
Portions Copyright 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 "libdwarfdefs.h"
|
30
|
+
#include <stdio.h>
|
31
|
+
#include <string.h>
|
32
|
+
#ifdef HAVE_ELF_H
|
33
|
+
#include <elf.h>
|
34
|
+
#endif
|
35
|
+
#include "pro_incl.h"
|
36
|
+
#include "pro_line.h"
|
37
|
+
|
38
|
+
static
|
39
|
+
Dwarf_Unsigned _dwarf_pro_add_line_entry(Dwarf_P_Debug,
|
40
|
+
Dwarf_Unsigned file_index,
|
41
|
+
Dwarf_Addr code_address,
|
42
|
+
Dwarf_Unsigned symidx,
|
43
|
+
Dwarf_Unsigned line_no,
|
44
|
+
Dwarf_Signed col_no,
|
45
|
+
Dwarf_Bool is_stmt_begin,
|
46
|
+
Dwarf_Bool is_bb_begin,
|
47
|
+
Dwarf_Ubyte opc,
|
48
|
+
Dwarf_Bool isepilbeg,
|
49
|
+
Dwarf_Bool isprolend,
|
50
|
+
Dwarf_Unsigned isa,
|
51
|
+
Dwarf_Unsigned discriminator,
|
52
|
+
Dwarf_Error * error);
|
53
|
+
|
54
|
+
/* Add a entry to the line information section
|
55
|
+
file_index: index of file in file entries, obtained from
|
56
|
+
add_file_entry() call.
|
57
|
+
|
58
|
+
This function actually calls _dwarf_pro_add_line_entry(), with
|
59
|
+
an extra parameter, the opcode. Done so that interface calls
|
60
|
+
dwarf_lne_set_address() and dwarf_lne_end_sequence() can use
|
61
|
+
this internal routine. */
|
62
|
+
Dwarf_Unsigned
|
63
|
+
dwarf_add_line_entry_b(Dwarf_P_Debug dbg,
|
64
|
+
Dwarf_Unsigned file_index,
|
65
|
+
Dwarf_Addr code_address,
|
66
|
+
Dwarf_Unsigned line_no,
|
67
|
+
Dwarf_Signed col_no,
|
68
|
+
Dwarf_Bool is_stmt_begin,
|
69
|
+
Dwarf_Bool is_bb_begin,
|
70
|
+
Dwarf_Bool isepilbeg,
|
71
|
+
Dwarf_Bool isprolend,
|
72
|
+
Dwarf_Unsigned isa,
|
73
|
+
Dwarf_Unsigned discriminator,
|
74
|
+
Dwarf_Error * error)
|
75
|
+
{
|
76
|
+
Dwarf_Unsigned retval = 0;
|
77
|
+
Dwarf_Ubyte opc = 0;
|
78
|
+
Dwarf_Unsigned symidx = 0;
|
79
|
+
|
80
|
+
retval = _dwarf_pro_add_line_entry(dbg, file_index, code_address,
|
81
|
+
symidx,
|
82
|
+
line_no, col_no, is_stmt_begin,
|
83
|
+
is_bb_begin,
|
84
|
+
opc,
|
85
|
+
isepilbeg,isprolend,isa,discriminator, error);
|
86
|
+
return retval;
|
87
|
+
}
|
88
|
+
Dwarf_Unsigned
|
89
|
+
dwarf_add_line_entry(Dwarf_P_Debug dbg,
|
90
|
+
Dwarf_Unsigned file_index,
|
91
|
+
Dwarf_Addr code_address,
|
92
|
+
Dwarf_Unsigned line_no,
|
93
|
+
Dwarf_Signed col_no, /* Wrong, should be unsigned. */
|
94
|
+
Dwarf_Bool is_stmt_begin,
|
95
|
+
Dwarf_Bool is_bb_begin, Dwarf_Error * error)
|
96
|
+
{
|
97
|
+
Dwarf_Unsigned retval = 0;
|
98
|
+
Dwarf_Ubyte opc = 0;
|
99
|
+
Dwarf_Unsigned symidx = 0;
|
100
|
+
Dwarf_Bool isepilbeg = 0;
|
101
|
+
Dwarf_Bool isprolend = 0;
|
102
|
+
Dwarf_Unsigned isa = 0;
|
103
|
+
Dwarf_Unsigned discriminator = 0;
|
104
|
+
|
105
|
+
retval = _dwarf_pro_add_line_entry(dbg, file_index, code_address,
|
106
|
+
symidx,
|
107
|
+
line_no, col_no, is_stmt_begin,
|
108
|
+
is_bb_begin,
|
109
|
+
opc,
|
110
|
+
isepilbeg, isprolend, isa, discriminator,
|
111
|
+
error);
|
112
|
+
return retval;
|
113
|
+
}
|
114
|
+
|
115
|
+
void
|
116
|
+
_dwarf_init_default_line_header_vals(Dwarf_P_Debug dbg)
|
117
|
+
{
|
118
|
+
dbg->de_line_inits.pi_version = DW_LINE_VERSION2;
|
119
|
+
dbg->de_line_inits.pi_default_is_stmt = DEFAULT_IS_STMT;
|
120
|
+
dbg->de_line_inits.pi_minimum_instruction_length = MIN_INST_LENGTH;
|
121
|
+
dbg->de_line_inits.pi_maximum_operations_per_instruction = 1;
|
122
|
+
dbg->de_line_inits.pi_opcode_base = OPCODE_BASE;
|
123
|
+
dbg->de_line_inits.pi_line_base = LINE_BASE;
|
124
|
+
dbg->de_line_inits.pi_line_range = LINE_RANGE;
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
/* Ask to emit DW_LNE_set_address opcode explicitly. Used by be
|
129
|
+
to emit start of a new .text section, or to force a relocated
|
130
|
+
address into debug line information entry. */
|
131
|
+
Dwarf_Unsigned
|
132
|
+
dwarf_lne_set_address(Dwarf_P_Debug dbg,
|
133
|
+
Dwarf_Addr offs,
|
134
|
+
Dwarf_Unsigned symidx, Dwarf_Error * error)
|
135
|
+
{
|
136
|
+
Dwarf_Ubyte opc = 0;
|
137
|
+
Dwarf_Unsigned retval = 0;
|
138
|
+
Dwarf_Unsigned file_index = 0;
|
139
|
+
Dwarf_Unsigned line_no = 0;
|
140
|
+
Dwarf_Signed col_no = 0;
|
141
|
+
Dwarf_Bool is_stmt = 0;
|
142
|
+
Dwarf_Bool is_bb = 0;
|
143
|
+
Dwarf_Bool isepilbeg = 0;
|
144
|
+
Dwarf_Bool isprolend = 0;
|
145
|
+
Dwarf_Unsigned isa = 0;
|
146
|
+
Dwarf_Unsigned discriminator = 0;
|
147
|
+
|
148
|
+
|
149
|
+
opc = DW_LNE_set_address;
|
150
|
+
retval =
|
151
|
+
_dwarf_pro_add_line_entry(dbg, file_index, offs,
|
152
|
+
symidx,
|
153
|
+
line_no, col_no, is_stmt,
|
154
|
+
is_bb,
|
155
|
+
opc,
|
156
|
+
isepilbeg, isprolend, isa, discriminator,
|
157
|
+
error);
|
158
|
+
return retval;
|
159
|
+
}
|
160
|
+
|
161
|
+
/* Ask to emit end_seqence opcode. Used normally at the end of a
|
162
|
+
compilation unit. Can also be used in the middle if there
|
163
|
+
are gaps in the region described by the code address. */
|
164
|
+
Dwarf_Unsigned
|
165
|
+
dwarf_lne_end_sequence(Dwarf_P_Debug dbg,
|
166
|
+
Dwarf_Addr end_address, Dwarf_Error * error)
|
167
|
+
{
|
168
|
+
Dwarf_Ubyte opc = 0;
|
169
|
+
Dwarf_Unsigned retval = 0;
|
170
|
+
Dwarf_Unsigned file_index = 0;
|
171
|
+
Dwarf_Unsigned symidx = 0;
|
172
|
+
Dwarf_Unsigned line_no = 0;
|
173
|
+
Dwarf_Bool is_stmt = 0;
|
174
|
+
Dwarf_Bool is_bb = 0;
|
175
|
+
Dwarf_Signed col_no = 0;/* Wrong, should be unsigned. */
|
176
|
+
Dwarf_Bool isepilbeg = 0;
|
177
|
+
Dwarf_Bool isprolend = 0;
|
178
|
+
Dwarf_Unsigned isa = 0;
|
179
|
+
Dwarf_Unsigned discriminator = 0;
|
180
|
+
|
181
|
+
opc = DW_LNE_end_sequence;
|
182
|
+
retval =
|
183
|
+
_dwarf_pro_add_line_entry(dbg, file_index, end_address,
|
184
|
+
symidx,
|
185
|
+
line_no, col_no, is_stmt,
|
186
|
+
is_bb,
|
187
|
+
opc,
|
188
|
+
isepilbeg, isprolend, isa, discriminator,
|
189
|
+
error);
|
190
|
+
return retval;
|
191
|
+
}
|
192
|
+
|
193
|
+
/* Add an entry in the internal list of lines mantained by producer.
|
194
|
+
Opc indicates if an opcode needs to be generated, rather than just
|
195
|
+
an entry in the matrix. During opcodes generation time, these
|
196
|
+
opcodes will be used. */
|
197
|
+
static Dwarf_Unsigned
|
198
|
+
_dwarf_pro_add_line_entry(Dwarf_P_Debug dbg,
|
199
|
+
Dwarf_Unsigned file_index,
|
200
|
+
Dwarf_Addr code_address,
|
201
|
+
Dwarf_Unsigned symidx,
|
202
|
+
Dwarf_Unsigned line_no,
|
203
|
+
Dwarf_Signed col_no,
|
204
|
+
Dwarf_Bool is_stmt_begin,
|
205
|
+
Dwarf_Bool is_bb_begin,
|
206
|
+
Dwarf_Ubyte opc,
|
207
|
+
Dwarf_Bool isepilbeg,
|
208
|
+
Dwarf_Bool isprolend,
|
209
|
+
Dwarf_Unsigned isa,
|
210
|
+
Dwarf_Unsigned discriminator,
|
211
|
+
Dwarf_Error * error)
|
212
|
+
{
|
213
|
+
if (dbg->de_lines == NULL) {
|
214
|
+
dbg->de_lines = (Dwarf_P_Line)
|
215
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Line_s));
|
216
|
+
if (dbg->de_lines == NULL) {
|
217
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_LINE_ALLOC, DW_DLV_NOCOUNT);
|
218
|
+
}
|
219
|
+
dbg->de_last_line = dbg->de_lines;
|
220
|
+
_dwarf_pro_reg_init(dbg,dbg->de_lines);
|
221
|
+
|
222
|
+
} else {
|
223
|
+
dbg->de_last_line->dpl_next = (Dwarf_P_Line)
|
224
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Line_s));
|
225
|
+
if (dbg->de_last_line->dpl_next == NULL) {
|
226
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_LINE_ALLOC, DW_DLV_NOCOUNT);
|
227
|
+
}
|
228
|
+
dbg->de_last_line = dbg->de_last_line->dpl_next;
|
229
|
+
_dwarf_pro_reg_init(dbg,dbg->de_last_line);
|
230
|
+
}
|
231
|
+
dbg->de_last_line->dpl_address = code_address;
|
232
|
+
dbg->de_last_line->dpl_file = (unsigned long) file_index;
|
233
|
+
dbg->de_last_line->dpl_line = (unsigned long) line_no;
|
234
|
+
dbg->de_last_line->dpl_column = (unsigned long) col_no;
|
235
|
+
dbg->de_last_line->dpl_is_stmt = is_stmt_begin;
|
236
|
+
dbg->de_last_line->dpl_basic_block = is_bb_begin;
|
237
|
+
dbg->de_last_line->dpl_opc = opc;
|
238
|
+
dbg->de_last_line->dpl_r_symidx = symidx;
|
239
|
+
dbg->de_last_line->dpl_prologue_end = isprolend;
|
240
|
+
dbg->de_last_line->dpl_epilogue_begin = isepilbeg;
|
241
|
+
dbg->de_last_line->dpl_isa = isa;
|
242
|
+
dbg->de_last_line->dpl_discriminator = discriminator;
|
243
|
+
return (0);
|
244
|
+
}
|
245
|
+
|
246
|
+
/* Add a directory declaration to the debug_line section. Stored
|
247
|
+
in linked list. */
|
248
|
+
Dwarf_Unsigned
|
249
|
+
dwarf_add_directory_decl(Dwarf_P_Debug dbg,
|
250
|
+
char *name, Dwarf_Error * error)
|
251
|
+
{
|
252
|
+
if (dbg->de_inc_dirs == NULL) {
|
253
|
+
dbg->de_inc_dirs = (Dwarf_P_Inc_Dir)
|
254
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Inc_Dir_s));
|
255
|
+
if (dbg->de_inc_dirs == NULL) {
|
256
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_INCDIR_ALLOC, DW_DLV_NOCOUNT);
|
257
|
+
}
|
258
|
+
dbg->de_last_inc_dir = dbg->de_inc_dirs;
|
259
|
+
dbg->de_n_inc_dirs = 1;
|
260
|
+
} else {
|
261
|
+
dbg->de_last_inc_dir->did_next = (Dwarf_P_Inc_Dir)
|
262
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Inc_Dir_s));
|
263
|
+
if (dbg->de_last_inc_dir->did_next == NULL) {
|
264
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_INCDIR_ALLOC, DW_DLV_NOCOUNT);
|
265
|
+
}
|
266
|
+
dbg->de_last_inc_dir = dbg->de_last_inc_dir->did_next;
|
267
|
+
dbg->de_n_inc_dirs++;
|
268
|
+
}
|
269
|
+
dbg->de_last_inc_dir->did_name =
|
270
|
+
(char *) _dwarf_p_get_alloc(dbg, strlen(name) + 1);
|
271
|
+
if (dbg->de_last_inc_dir->did_name == NULL) {
|
272
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_STRING_ALLOC, DW_DLV_NOCOUNT);
|
273
|
+
}
|
274
|
+
strcpy(dbg->de_last_inc_dir->did_name, name);
|
275
|
+
dbg->de_last_inc_dir->did_next = NULL;
|
276
|
+
|
277
|
+
return dbg->de_n_inc_dirs;
|
278
|
+
}
|
279
|
+
|
280
|
+
/* Add a file entry declaration to the debug_line section. Stored
|
281
|
+
in linked list. The data is immediately encoded as leb128
|
282
|
+
and stored in Dwarf_P_F_Entry_s struct. */
|
283
|
+
Dwarf_Unsigned
|
284
|
+
dwarf_add_file_decl(Dwarf_P_Debug dbg,
|
285
|
+
char *name,
|
286
|
+
Dwarf_Unsigned dir_idx,
|
287
|
+
Dwarf_Unsigned time_mod,
|
288
|
+
Dwarf_Unsigned length, Dwarf_Error * error)
|
289
|
+
{
|
290
|
+
Dwarf_P_F_Entry cur;
|
291
|
+
char *ptr = 0;
|
292
|
+
int nbytes_idx, nbytes_time, nbytes_len;
|
293
|
+
char buffidx[ENCODE_SPACE_NEEDED];
|
294
|
+
char bufftime[ENCODE_SPACE_NEEDED];
|
295
|
+
char bufflen[ENCODE_SPACE_NEEDED];
|
296
|
+
int res = 0;
|
297
|
+
|
298
|
+
if (dbg->de_file_entries == NULL) {
|
299
|
+
dbg->de_file_entries = (Dwarf_P_F_Entry)
|
300
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_F_Entry_s));
|
301
|
+
if (dbg->de_file_entries == NULL) {
|
302
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_FILE_ENTRY_ALLOC,
|
303
|
+
DW_DLV_NOCOUNT);
|
304
|
+
}
|
305
|
+
cur = dbg->de_file_entries;
|
306
|
+
dbg->de_last_file_entry = cur;
|
307
|
+
dbg->de_n_file_entries = 1;
|
308
|
+
} else {
|
309
|
+
cur = dbg->de_last_file_entry;
|
310
|
+
cur->dfe_next = (Dwarf_P_F_Entry)
|
311
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_F_Entry_s));
|
312
|
+
if (cur->dfe_next == NULL) {
|
313
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_FILE_ENTRY_ALLOC,
|
314
|
+
DW_DLV_NOCOUNT);
|
315
|
+
}
|
316
|
+
cur = cur->dfe_next;
|
317
|
+
dbg->de_last_file_entry = cur;
|
318
|
+
dbg->de_n_file_entries++;
|
319
|
+
}
|
320
|
+
cur->dfe_name = (char *) _dwarf_p_get_alloc(dbg, strlen(name) + 1);
|
321
|
+
if (cur->dfe_name == NULL) {
|
322
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_ALLOC_FAIL, DW_DLV_NOCOUNT);
|
323
|
+
}
|
324
|
+
strcpy((char *) cur->dfe_name, name);
|
325
|
+
res = _dwarf_pro_encode_leb128_nm(dir_idx, &nbytes_idx,
|
326
|
+
buffidx, sizeof(buffidx));
|
327
|
+
if (res != DW_DLV_OK) {
|
328
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_ALLOC_FAIL, DW_DLV_NOCOUNT);
|
329
|
+
}
|
330
|
+
res = _dwarf_pro_encode_leb128_nm(time_mod, &nbytes_time,
|
331
|
+
bufftime, sizeof(bufftime));
|
332
|
+
if (res != DW_DLV_OK) {
|
333
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_ALLOC_FAIL, DW_DLV_NOCOUNT);
|
334
|
+
}
|
335
|
+
res = _dwarf_pro_encode_leb128_nm(length, &nbytes_len,
|
336
|
+
bufflen, sizeof(bufflen));
|
337
|
+
cur->dfe_args = (char *)
|
338
|
+
_dwarf_p_get_alloc(dbg, nbytes_idx + nbytes_time + nbytes_len);
|
339
|
+
if (cur->dfe_args == NULL) {
|
340
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_ALLOC_FAIL, DW_DLV_NOCOUNT);
|
341
|
+
}
|
342
|
+
ptr = cur->dfe_args;
|
343
|
+
memcpy((void *) ptr, buffidx, nbytes_idx);
|
344
|
+
ptr += nbytes_idx;
|
345
|
+
memcpy((void *) ptr, bufftime, nbytes_time);
|
346
|
+
ptr += nbytes_time;
|
347
|
+
memcpy((void *) ptr, bufflen, nbytes_len);
|
348
|
+
ptr += nbytes_len;
|
349
|
+
cur->dfe_nbytes = nbytes_idx + nbytes_time + nbytes_len;
|
350
|
+
cur->dfe_next = NULL;
|
351
|
+
|
352
|
+
return dbg->de_n_file_entries;
|
353
|
+
}
|
354
|
+
|
355
|
+
|
356
|
+
/* Initialize a row of the matrix for line numbers, meaning
|
357
|
+
initialize the struct corresponding to it */
|
358
|
+
void
|
359
|
+
_dwarf_pro_reg_init(Dwarf_P_Debug dbg, Dwarf_P_Line cur_line)
|
360
|
+
{
|
361
|
+
cur_line->dpl_address = 0;
|
362
|
+
cur_line->dpl_file = 1;
|
363
|
+
cur_line->dpl_line = 1;
|
364
|
+
cur_line->dpl_column = 0;
|
365
|
+
cur_line->dpl_is_stmt = dbg->de_line_inits.pi_default_is_stmt;
|
366
|
+
cur_line->dpl_basic_block = false;
|
367
|
+
cur_line->dpl_next = NULL;
|
368
|
+
cur_line->dpl_prologue_end = 0;
|
369
|
+
cur_line->dpl_epilogue_begin = 0;
|
370
|
+
cur_line->dpl_isa = 0;
|
371
|
+
cur_line->dpl_discriminator = 0;
|
372
|
+
cur_line->dpl_opc = 0;
|
373
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
4
|
+
Portions Copyright 2007-2010 Sun Microsystems, 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
|
+
|
29
|
+
#define DW_LINE_VERSION2 2
|
30
|
+
#define DW_LINE_VERSION3 3
|
31
|
+
#define DW_LINE_VERSION4 4
|
32
|
+
|
33
|
+
#if defined(__i386) || defined(__x86_64)
|
34
|
+
#define MIN_INST_LENGTH 1
|
35
|
+
#else
|
36
|
+
#define MIN_INST_LENGTH 4
|
37
|
+
#endif
|
38
|
+
#define DEFAULT_IS_STMT false
|
39
|
+
/* line base and range are temporarily defines.
|
40
|
+
They need to be calculated later */
|
41
|
+
#define LINE_BASE -1
|
42
|
+
#define LINE_RANGE 4
|
43
|
+
|
44
|
+
#define OPCODE_BASE 10 /* DWARF2. 13 in DWARF3, DWARF4 */
|
45
|
+
#define MAX_OPCODE 255
|
46
|
+
|
47
|
+
|
48
|
+
/* This struct is used to hold entries in the include directories
|
49
|
+
part of statement prologue. */
|
50
|
+
struct Dwarf_P_Inc_Dir_s {
|
51
|
+
char *did_name; /* name of directory */
|
52
|
+
Dwarf_P_Inc_Dir did_next;
|
53
|
+
};
|
54
|
+
|
55
|
+
|
56
|
+
/* This struct holds file entries for the statement prologue.
|
57
|
+
Defined in pro_line.h */
|
58
|
+
struct Dwarf_P_F_Entry_s {
|
59
|
+
char *dfe_name;
|
60
|
+
char *dfe_args; /* has dir index, time of modification,
|
61
|
+
length in bytes. Encodes as leb128 */
|
62
|
+
int dfe_nbytes; /* number of bytes in args */
|
63
|
+
Dwarf_P_F_Entry dfe_next;
|
64
|
+
};
|
65
|
+
|
66
|
+
|
67
|
+
/*
|
68
|
+
Struct holding line number information for each of the producer
|
69
|
+
line entries
|
70
|
+
*/
|
71
|
+
struct Dwarf_P_Line_s {
|
72
|
+
/* code address */
|
73
|
+
Dwarf_Addr dpl_address;
|
74
|
+
|
75
|
+
/* file index, index into file entry */
|
76
|
+
Dwarf_Word dpl_file;
|
77
|
+
|
78
|
+
/* line number */
|
79
|
+
Dwarf_Word dpl_line;
|
80
|
+
|
81
|
+
/* column number */
|
82
|
+
Dwarf_Word dpl_column;
|
83
|
+
|
84
|
+
/* whether its a beginning of a stmt */
|
85
|
+
Dwarf_Ubyte dpl_is_stmt;
|
86
|
+
|
87
|
+
/* whether its a beginning of basic blk */
|
88
|
+
Dwarf_Ubyte dpl_basic_block;
|
89
|
+
|
90
|
+
/* used to store opcodes set_address, and end_seq */
|
91
|
+
Dwarf_Ubyte dpl_opc;
|
92
|
+
|
93
|
+
/* Used only for relocations. Has index of symbol relative to
|
94
|
+
which relocation has to be done (the S part in S + A) */
|
95
|
+
Dwarf_Unsigned dpl_r_symidx;
|
96
|
+
|
97
|
+
Dwarf_P_Line dpl_next;
|
98
|
+
|
99
|
+
Dwarf_Ubyte dpl_prologue_end; /* DWARF3 */
|
100
|
+
Dwarf_Ubyte dpl_epilogue_begin; /* DWARF3 */
|
101
|
+
Dwarf_Unsigned dpl_isa; /* DWARF3 */
|
102
|
+
Dwarf_Unsigned dpl_discriminator; /* DWARF4 */
|
103
|
+
|
104
|
+
};
|
105
|
+
|
106
|
+
/*
|
107
|
+
to initialize state machine registers, definition in
|
108
|
+
pro_line.c
|
109
|
+
*/
|
110
|
+
void _dwarf_pro_reg_init(Dwarf_P_Debug dbg,Dwarf_P_Line);
|
111
|
+
|
112
|
+
void _dwarf_init_default_line_header_vals(Dwarf_P_Debug dbg);
|