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,51 @@
|
|
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
|
+
|
28
|
+
/*
|
29
|
+
If ag_end_symbol_index is zero,
|
30
|
+
ag_length must be known and non-zero.
|
31
|
+
|
32
|
+
Deals with length being known costant or fr
|
33
|
+
assembler output, not known.
|
34
|
+
*/
|
35
|
+
|
36
|
+
struct Dwarf_P_Arange_s {
|
37
|
+
Dwarf_Addr ag_begin_address; /* known address or for
|
38
|
+
symbolic assem output,
|
39
|
+
offset of symbol */
|
40
|
+
Dwarf_Addr ag_length; /* zero or address or offset */
|
41
|
+
Dwarf_Unsigned ag_symbol_index;
|
42
|
+
|
43
|
+
Dwarf_P_Arange ag_next;
|
44
|
+
|
45
|
+
Dwarf_Unsigned ag_end_symbol_index; /* zero or index/id of end
|
46
|
+
symbol */
|
47
|
+
Dwarf_Addr ag_end_symbol_offset; /* known address or for
|
48
|
+
symbolic assem output,
|
49
|
+
offset of end symbol */
|
50
|
+
|
51
|
+
};
|
@@ -0,0 +1,431 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
4
|
+
Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
|
5
|
+
Portions Copyright 2011 David Anderson. All Rights Reserved.
|
6
|
+
|
7
|
+
This program is free software; you can redistribute it and/or modify it
|
8
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
9
|
+
as published by the Free Software Foundation.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it would be useful, but
|
12
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
|
15
|
+
Further, this software is distributed without any warranty that it is
|
16
|
+
free of the rightful claim of any third person regarding infringement
|
17
|
+
or the like. Any license provided herein, whether implied or
|
18
|
+
otherwise, applies only to this software file. Patent licenses, if
|
19
|
+
any, provided herein do not apply to combinations of this program with
|
20
|
+
other software, or any other product whatsoever.
|
21
|
+
|
22
|
+
You should have received a copy of the GNU Lesser General Public
|
23
|
+
License along with this program; if not, write the Free Software
|
24
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
25
|
+
USA.
|
26
|
+
|
27
|
+
*/
|
28
|
+
|
29
|
+
#include "config.h"
|
30
|
+
#include "libdwarfdefs.h"
|
31
|
+
#include <stdio.h>
|
32
|
+
#include <string.h>
|
33
|
+
#include "pro_incl.h"
|
34
|
+
#include "pro_die.h"
|
35
|
+
|
36
|
+
#ifndef R_MIPS_NONE
|
37
|
+
#define R_MIPS_NONE 0
|
38
|
+
#endif
|
39
|
+
|
40
|
+
/* adds an attribute to a die */
|
41
|
+
void _dwarf_pro_add_at_to_die(Dwarf_P_Die die, Dwarf_P_Attribute attr);
|
42
|
+
|
43
|
+
/* This function creates a new die.
|
44
|
+
tag: tag of the new die to be created
|
45
|
+
parent,child,left,right: specify neighbors of the new die. Only
|
46
|
+
one of these may be non-null */
|
47
|
+
Dwarf_P_Die
|
48
|
+
dwarf_new_die(Dwarf_P_Debug dbg,
|
49
|
+
Dwarf_Tag tag,
|
50
|
+
Dwarf_P_Die parent,
|
51
|
+
Dwarf_P_Die child,
|
52
|
+
Dwarf_P_Die left, Dwarf_P_Die right, Dwarf_Error * error)
|
53
|
+
{
|
54
|
+
Dwarf_P_Die ret_die = 0;
|
55
|
+
|
56
|
+
Dwarf_P_Die new_die = (Dwarf_P_Die)
|
57
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Die_s));
|
58
|
+
if (new_die == NULL) {
|
59
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_DIE_ALLOC,
|
60
|
+
(Dwarf_P_Die) DW_DLV_BADADDR);
|
61
|
+
}
|
62
|
+
new_die->di_parent = NULL;
|
63
|
+
new_die->di_left = NULL;
|
64
|
+
new_die->di_right = NULL;
|
65
|
+
new_die->di_child = NULL;
|
66
|
+
new_die->di_last_child = NULL;
|
67
|
+
new_die->di_tag = tag;
|
68
|
+
new_die->di_dbg = dbg;
|
69
|
+
new_die->di_marker = 0;
|
70
|
+
ret_die =
|
71
|
+
dwarf_die_link(new_die, parent, child, left, right, error);
|
72
|
+
return ret_die;
|
73
|
+
}
|
74
|
+
|
75
|
+
/* This function links up a die to specified neighbors
|
76
|
+
parent,child,left,right: specify neighbors of the new die. Only
|
77
|
+
one of these may be non-null */
|
78
|
+
Dwarf_P_Die
|
79
|
+
dwarf_die_link(Dwarf_P_Die new_die,
|
80
|
+
Dwarf_P_Die parent,
|
81
|
+
Dwarf_P_Die child,
|
82
|
+
Dwarf_P_Die left, Dwarf_P_Die right, Dwarf_Error * error)
|
83
|
+
{
|
84
|
+
/* Count the # of non null neighbors. */
|
85
|
+
int n_nulls = 0;
|
86
|
+
|
87
|
+
if (parent != NULL) {
|
88
|
+
n_nulls++;
|
89
|
+
if (new_die->di_parent != NULL) {
|
90
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_LINK_LOOP,
|
91
|
+
(Dwarf_P_Die) DW_DLV_BADADDR);
|
92
|
+
}
|
93
|
+
new_die->di_parent = parent;
|
94
|
+
if (parent->di_child) {
|
95
|
+
|
96
|
+
/* di_last_child identifies the last sibling, the
|
97
|
+
die we want to attach new_die to. */
|
98
|
+
/* ASSERT: if di_child is set so is di_last_child. */
|
99
|
+
Dwarf_P_Die former_lastchild = parent->di_last_child;
|
100
|
+
parent->di_last_child = new_die;
|
101
|
+
/* Attach to the new die to end of the sibling list. */
|
102
|
+
former_lastchild->di_right = new_die;
|
103
|
+
new_die->di_left = former_lastchild;
|
104
|
+
} else {
|
105
|
+
parent->di_child = new_die;
|
106
|
+
parent->di_last_child = new_die;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
if (child != NULL) {
|
110
|
+
n_nulls++;
|
111
|
+
new_die->di_child = child;
|
112
|
+
new_die->di_last_child = child;
|
113
|
+
if (child->di_parent) {
|
114
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_PARENT_EXISTS,
|
115
|
+
(Dwarf_P_Die) DW_DLV_BADADDR);
|
116
|
+
} else {
|
117
|
+
child->di_parent = new_die;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
if (left != NULL) {
|
121
|
+
n_nulls++;
|
122
|
+
new_die->di_left = left;
|
123
|
+
if (left->di_right) {
|
124
|
+
/* There's already a right sibling of left,
|
125
|
+
insert the new die in the list. */
|
126
|
+
new_die->di_right = left->di_right;
|
127
|
+
left->di_right->di_left = new_die;
|
128
|
+
}
|
129
|
+
left->di_right = new_die;
|
130
|
+
if (new_die->di_parent) {
|
131
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_PARENT_EXISTS,
|
132
|
+
(Dwarf_P_Die) DW_DLV_BADADDR);
|
133
|
+
} else {
|
134
|
+
new_die->di_parent = left->di_parent;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
if (right != NULL) {
|
138
|
+
n_nulls++;
|
139
|
+
new_die->di_right = right;
|
140
|
+
if (right->di_left) {
|
141
|
+
/* There is already a left sibling of the right die,
|
142
|
+
insert the new die in the list. */
|
143
|
+
new_die->di_left = right->di_left;
|
144
|
+
right->di_left->di_right = new_die;
|
145
|
+
}
|
146
|
+
right->di_left = new_die;
|
147
|
+
if (new_die->di_parent) {
|
148
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_PARENT_EXISTS,
|
149
|
+
(Dwarf_P_Die) DW_DLV_BADADDR);
|
150
|
+
} else {
|
151
|
+
new_die->di_parent = right->di_parent;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
if (n_nulls > 1) {
|
155
|
+
/* Multiple neighbors! error! */
|
156
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_EXTRA_NEIGHBORS,
|
157
|
+
(Dwarf_P_Die) DW_DLV_BADADDR);
|
158
|
+
}
|
159
|
+
return new_die;
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
Dwarf_Unsigned
|
164
|
+
dwarf_add_die_marker(Dwarf_P_Debug dbg,
|
165
|
+
Dwarf_P_Die die,
|
166
|
+
Dwarf_Unsigned marker,
|
167
|
+
Dwarf_Error * error)
|
168
|
+
{
|
169
|
+
if (die == NULL) {
|
170
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_DIE_NULL, DW_DLV_NOCOUNT);
|
171
|
+
}
|
172
|
+
die->di_marker = marker;
|
173
|
+
return 0;
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
Dwarf_Unsigned
|
178
|
+
dwarf_get_die_marker(Dwarf_P_Debug dbg,
|
179
|
+
Dwarf_P_Die die,
|
180
|
+
Dwarf_Unsigned * marker,
|
181
|
+
Dwarf_Error * error)
|
182
|
+
{
|
183
|
+
if (die == NULL) {
|
184
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_DIE_NULL, DW_DLV_NOCOUNT);
|
185
|
+
}
|
186
|
+
*marker = die->di_marker;
|
187
|
+
return 0;
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
/*----------------------------------------------------------------------------
|
192
|
+
This function adds a die to dbg struct. It should be called using
|
193
|
+
the root of all the dies.
|
194
|
+
-----------------------------------------------------------------------------*/
|
195
|
+
Dwarf_Unsigned
|
196
|
+
dwarf_add_die_to_debug(Dwarf_P_Debug dbg,
|
197
|
+
Dwarf_P_Die first_die, Dwarf_Error * error)
|
198
|
+
{
|
199
|
+
if (first_die == NULL) {
|
200
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_DIE_NULL, DW_DLV_NOCOUNT);
|
201
|
+
}
|
202
|
+
if (first_die->di_tag != DW_TAG_compile_unit) {
|
203
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_WRONG_TAG, DW_DLV_NOCOUNT);
|
204
|
+
}
|
205
|
+
dbg->de_dies = first_die;
|
206
|
+
return 0;
|
207
|
+
}
|
208
|
+
|
209
|
+
int
|
210
|
+
_dwarf_pro_add_AT_stmt_list(Dwarf_P_Debug dbg,
|
211
|
+
Dwarf_P_Die first_die, Dwarf_Error * error)
|
212
|
+
{
|
213
|
+
Dwarf_P_Attribute new_attr;
|
214
|
+
int uwordb_size = dbg->de_offset_size;
|
215
|
+
|
216
|
+
/* Add AT_stmt_list attribute */
|
217
|
+
new_attr = (Dwarf_P_Attribute)
|
218
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
219
|
+
if (new_attr == NULL) {
|
220
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_ATTR_ALLOC, DW_DLV_NOCOUNT);
|
221
|
+
}
|
222
|
+
|
223
|
+
new_attr->ar_attribute = DW_AT_stmt_list;
|
224
|
+
new_attr->ar_attribute_form = dbg->de_ar_data_attribute_form;
|
225
|
+
new_attr->ar_rel_type = dbg->de_offset_reloc;
|
226
|
+
|
227
|
+
new_attr->ar_nbytes = uwordb_size;
|
228
|
+
new_attr->ar_next = NULL;
|
229
|
+
new_attr->ar_reloc_len = uwordb_size;
|
230
|
+
new_attr->ar_data = (char *)
|
231
|
+
_dwarf_p_get_alloc(dbg, uwordb_size);
|
232
|
+
if (new_attr->ar_data == NULL) {
|
233
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_ADDR_ALLOC, DW_DLV_NOCOUNT);
|
234
|
+
}
|
235
|
+
{
|
236
|
+
Dwarf_Unsigned du = 0;
|
237
|
+
|
238
|
+
WRITE_UNALIGNED(dbg, (void *) new_attr->ar_data,
|
239
|
+
(const void *) &du, sizeof(du), uwordb_size);
|
240
|
+
}
|
241
|
+
|
242
|
+
_dwarf_pro_add_at_to_die(first_die, new_attr);
|
243
|
+
return 0;
|
244
|
+
}
|
245
|
+
|
246
|
+
/*-----------------------------------------------------------------------------
|
247
|
+
Add AT_name attribute to die
|
248
|
+
------------------------------------------------------------------------------*/
|
249
|
+
Dwarf_P_Attribute
|
250
|
+
dwarf_add_AT_name(Dwarf_P_Die die, char *name, Dwarf_Error * error)
|
251
|
+
{
|
252
|
+
Dwarf_P_Attribute new_attr;
|
253
|
+
|
254
|
+
if (die == NULL) {
|
255
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_DIE_NULL,
|
256
|
+
(Dwarf_P_Attribute) DW_DLV_BADADDR);
|
257
|
+
}
|
258
|
+
new_attr = (Dwarf_P_Attribute)
|
259
|
+
_dwarf_p_get_alloc(die->di_dbg,sizeof(struct Dwarf_P_Attribute_s));
|
260
|
+
if (new_attr == NULL) {
|
261
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_ATTR_ALLOC,
|
262
|
+
(Dwarf_P_Attribute) DW_DLV_BADADDR);
|
263
|
+
}
|
264
|
+
|
265
|
+
/* fill in the information */
|
266
|
+
new_attr->ar_attribute = DW_AT_name;
|
267
|
+
/* assume that form is string, no debug_str yet */
|
268
|
+
new_attr->ar_attribute_form = DW_FORM_string;
|
269
|
+
new_attr->ar_nbytes = strlen(name) + 1;
|
270
|
+
new_attr->ar_next = NULL;
|
271
|
+
new_attr->ar_reloc_len = 0;
|
272
|
+
new_attr->ar_data = (char *)
|
273
|
+
_dwarf_p_get_alloc(die->di_dbg, strlen(name)+1);
|
274
|
+
if (new_attr->ar_data == NULL) {
|
275
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_STRING_ALLOC,
|
276
|
+
(Dwarf_P_Attribute) DW_DLV_BADADDR);
|
277
|
+
}
|
278
|
+
strcpy(new_attr->ar_data, name);
|
279
|
+
|
280
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
281
|
+
|
282
|
+
/* add attribute to the die */
|
283
|
+
_dwarf_pro_add_at_to_die(die, new_attr);
|
284
|
+
return new_attr;
|
285
|
+
}
|
286
|
+
|
287
|
+
|
288
|
+
/*-----------------------------------------------------------------------------
|
289
|
+
Add AT_comp_dir attribute to die
|
290
|
+
------------------------------------------------------------------------------*/
|
291
|
+
Dwarf_P_Attribute
|
292
|
+
dwarf_add_AT_comp_dir(Dwarf_P_Die ownerdie,
|
293
|
+
char *current_working_directory,
|
294
|
+
Dwarf_Error * error)
|
295
|
+
{
|
296
|
+
Dwarf_P_Attribute new_attr;
|
297
|
+
|
298
|
+
if (ownerdie == NULL) {
|
299
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_DIE_NULL,
|
300
|
+
(Dwarf_P_Attribute) DW_DLV_BADADDR);
|
301
|
+
}
|
302
|
+
new_attr = (Dwarf_P_Attribute)
|
303
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg,
|
304
|
+
sizeof(struct Dwarf_P_Attribute_s));
|
305
|
+
if (new_attr == NULL) {
|
306
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_ATTR_ALLOC,
|
307
|
+
(Dwarf_P_Attribute) DW_DLV_BADADDR);
|
308
|
+
}
|
309
|
+
|
310
|
+
/* fill in the information */
|
311
|
+
new_attr->ar_attribute = DW_AT_comp_dir;
|
312
|
+
/* assume that form is string, no debug_str yet */
|
313
|
+
new_attr->ar_attribute_form = DW_FORM_string;
|
314
|
+
new_attr->ar_nbytes = strlen(current_working_directory) + 1;
|
315
|
+
new_attr->ar_next = NULL;
|
316
|
+
new_attr->ar_reloc_len = 0;
|
317
|
+
new_attr->ar_data = (char *)
|
318
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg,
|
319
|
+
strlen(current_working_directory)+1);
|
320
|
+
if (new_attr->ar_data == NULL) {
|
321
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_STRING_ALLOC,
|
322
|
+
(Dwarf_P_Attribute) DW_DLV_BADADDR);
|
323
|
+
}
|
324
|
+
strcpy(new_attr->ar_data, current_working_directory);
|
325
|
+
|
326
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
327
|
+
|
328
|
+
/* add attribute to the die */
|
329
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
330
|
+
return new_attr;
|
331
|
+
}
|
332
|
+
|
333
|
+
int
|
334
|
+
_dwarf_pro_add_AT_fde(Dwarf_P_Debug dbg,
|
335
|
+
Dwarf_P_Die die,
|
336
|
+
Dwarf_Unsigned offset, Dwarf_Error * error)
|
337
|
+
{
|
338
|
+
Dwarf_P_Attribute new_attr;
|
339
|
+
int uwordb_size = dbg->de_offset_size;
|
340
|
+
|
341
|
+
if (die == NULL) {
|
342
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_DIE_NULL, -1);
|
343
|
+
}
|
344
|
+
new_attr = (Dwarf_P_Attribute)
|
345
|
+
_dwarf_p_get_alloc(dbg,sizeof(struct Dwarf_P_Attribute_s));
|
346
|
+
if (new_attr == NULL) {
|
347
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_ATTR_ALLOC, -1);
|
348
|
+
}
|
349
|
+
|
350
|
+
/* fill in the information */
|
351
|
+
new_attr->ar_attribute = DW_AT_MIPS_fde;
|
352
|
+
new_attr->ar_attribute_form = dbg->de_ar_data_attribute_form;;
|
353
|
+
new_attr->ar_rel_type = dbg->de_offset_reloc;
|
354
|
+
new_attr->ar_nbytes = uwordb_size;
|
355
|
+
new_attr->ar_next = NULL;
|
356
|
+
new_attr->ar_reloc_len = uwordb_size;
|
357
|
+
new_attr->ar_data = (char *)
|
358
|
+
_dwarf_p_get_alloc(dbg, uwordb_size);
|
359
|
+
if (new_attr->ar_data == NULL) {
|
360
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_ADDR_ALLOC, DW_DLV_NOCOUNT);
|
361
|
+
}
|
362
|
+
{
|
363
|
+
Dwarf_Unsigned du = offset;
|
364
|
+
|
365
|
+
WRITE_UNALIGNED(dbg, (void *) new_attr->ar_data,
|
366
|
+
(const void *) &du, sizeof(du), uwordb_size);
|
367
|
+
}
|
368
|
+
|
369
|
+
_dwarf_pro_add_at_to_die(die, new_attr);
|
370
|
+
|
371
|
+
return 0;
|
372
|
+
}
|
373
|
+
|
374
|
+
int
|
375
|
+
_dwarf_pro_add_AT_macro_info(Dwarf_P_Debug dbg,
|
376
|
+
Dwarf_P_Die die,
|
377
|
+
Dwarf_Unsigned offset, Dwarf_Error * error)
|
378
|
+
{
|
379
|
+
Dwarf_P_Attribute new_attr;
|
380
|
+
int uwordb_size = dbg->de_offset_size;
|
381
|
+
|
382
|
+
if (die == NULL) {
|
383
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_DIE_NULL, -1);
|
384
|
+
}
|
385
|
+
new_attr = (Dwarf_P_Attribute)
|
386
|
+
_dwarf_p_get_alloc(dbg,sizeof(struct Dwarf_P_Attribute_s));
|
387
|
+
if (new_attr == NULL) {
|
388
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_ATTR_ALLOC, -1);
|
389
|
+
}
|
390
|
+
|
391
|
+
/* fill in the information */
|
392
|
+
new_attr->ar_attribute = DW_AT_macro_info;
|
393
|
+
new_attr->ar_attribute_form = dbg->de_ar_data_attribute_form;
|
394
|
+
new_attr->ar_rel_type = dbg->de_offset_reloc;
|
395
|
+
|
396
|
+
new_attr->ar_nbytes = uwordb_size;
|
397
|
+
new_attr->ar_next = NULL;
|
398
|
+
new_attr->ar_reloc_len = uwordb_size;
|
399
|
+
new_attr->ar_data = (char *)
|
400
|
+
_dwarf_p_get_alloc(dbg, uwordb_size);
|
401
|
+
if (new_attr->ar_data == NULL) {
|
402
|
+
DWARF_P_DBG_ERROR(NULL, DW_DLE_ADDR_ALLOC, DW_DLV_NOCOUNT);
|
403
|
+
}
|
404
|
+
{
|
405
|
+
Dwarf_Unsigned du = offset;
|
406
|
+
|
407
|
+
WRITE_UNALIGNED(dbg, (void *) new_attr->ar_data,
|
408
|
+
(const void *) &du, sizeof(du), uwordb_size);
|
409
|
+
}
|
410
|
+
|
411
|
+
_dwarf_pro_add_at_to_die(die, new_attr);
|
412
|
+
|
413
|
+
return 0;
|
414
|
+
}
|
415
|
+
|
416
|
+
|
417
|
+
/* Updates the list of attributes on this Dwarf_P_Die
|
418
|
+
*/
|
419
|
+
void
|
420
|
+
_dwarf_pro_add_at_to_die(Dwarf_P_Die die, Dwarf_P_Attribute attr)
|
421
|
+
{
|
422
|
+
if (die->di_last_attr) {
|
423
|
+
/* Inserts new attr at the end */
|
424
|
+
die->di_last_attr->ar_next = attr;
|
425
|
+
die->di_last_attr = attr;
|
426
|
+
die->di_n_attr++;
|
427
|
+
} else {
|
428
|
+
die->di_n_attr = 1;
|
429
|
+
die->di_attrs = die->di_last_attr = attr;
|
430
|
+
}
|
431
|
+
}
|