rdwarf 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2014-2014 David Anderson. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it and/or modify it
|
|
6
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
|
7
|
+
as published by the Free Software Foundation.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it would be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
|
|
13
|
+
Further, this software is distributed without any warranty that it is
|
|
14
|
+
free of the rightful claim of any third person regarding infringement
|
|
15
|
+
or the like. Any license provided herein, whether implied or
|
|
16
|
+
otherwise, applies only to this software file. Patent licenses, if
|
|
17
|
+
any, provided herein do not apply to combinations of this program with
|
|
18
|
+
other software, or any other product whatsoever.
|
|
19
|
+
|
|
20
|
+
You should have received a copy of the GNU Lesser General Public
|
|
21
|
+
License along with this program; if not, write the Free Software
|
|
22
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
|
23
|
+
USA.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/* The following is based on
|
|
31
|
+
The gdb online documentation at
|
|
32
|
+
https://sourceware.org/gdb/onlinedocs/gdb/
|
|
33
|
+
Appendix J, ".gdb_index section format".
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/* These are the two types .gdb_index uses.
|
|
38
|
+
the offset_type (32 bits) and other fields
|
|
39
|
+
defined 64 bits. We use our own Dwarf_Unsigned
|
|
40
|
+
for all the interfaces, these are just for reading
|
|
41
|
+
the section data.
|
|
42
|
+
|
|
43
|
+
The section data is defined to be in little-endian regardless of
|
|
44
|
+
the target machine.
|
|
45
|
+
We use our host endianness in all interfaces.
|
|
46
|
+
|
|
47
|
+
We simply assume unsigned int is 32 bits FIXME.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
typedef __uint32_t gdbindex_offset_type;
|
|
51
|
+
typedef Dwarf_Unsigned gdbindex_64;
|
|
52
|
+
|
|
53
|
+
enum gdbindex_type_e {
|
|
54
|
+
git_unknown,
|
|
55
|
+
git_std,
|
|
56
|
+
git_address,
|
|
57
|
+
git_cuvec,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
struct Dwarf_Gdbindex_array_instance_s {
|
|
61
|
+
Dwarf_Small * dg_base;
|
|
62
|
+
Dwarf_Unsigned dg_count;
|
|
63
|
+
/* the in_object struct size. */
|
|
64
|
+
Dwarf_Unsigned dg_entry_length;
|
|
65
|
+
/* The size of a single field in the in-object struct */
|
|
66
|
+
int dg_fieldlen;
|
|
67
|
+
/* The address_area type is a bit irregular. */
|
|
68
|
+
enum gdbindex_type_e dg_type;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
struct Dwarf_Gdbindex_s {
|
|
72
|
+
Dwarf_Debug gi_dbg;
|
|
73
|
+
Dwarf_Small * gi_section_data;
|
|
74
|
+
Dwarf_Unsigned gi_section_length;
|
|
75
|
+
|
|
76
|
+
Dwarf_Unsigned gi_version;
|
|
77
|
+
Dwarf_Unsigned gi_cu_list_offset;
|
|
78
|
+
Dwarf_Unsigned gi_types_cu_list_offset;
|
|
79
|
+
Dwarf_Unsigned gi_address_area_offset;
|
|
80
|
+
Dwarf_Unsigned gi_symbol_table_offset;
|
|
81
|
+
Dwarf_Unsigned gi_constant_pool_offset;
|
|
82
|
+
struct Dwarf_Gdbindex_array_instance_s gi_culisthdr;
|
|
83
|
+
struct Dwarf_Gdbindex_array_instance_s gi_typesculisthdr;
|
|
84
|
+
struct Dwarf_Gdbindex_array_instance_s gi_addressareahdr;
|
|
85
|
+
struct Dwarf_Gdbindex_array_instance_s gi_symboltablehdr;
|
|
86
|
+
struct Dwarf_Gdbindex_array_instance_s gi_cuvectorhdr;
|
|
87
|
+
|
|
88
|
+
Dwarf_Small * gi_string_pool;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
|
|
4
|
+
Portions Copyright (C) 2007-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_global.h"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
#ifdef __sgi /* __sgi should only be defined for IRIX/MIPS. */
|
|
35
|
+
/* The 'fixup' here intended for IRIX targets only.
|
|
36
|
+
With a 2+GB Elf64 IRIX executable (under 4GB in size),
|
|
37
|
+
some DIE offsets wrongly
|
|
38
|
+
got the 32bit upper bit sign extended. For the cu-header
|
|
39
|
+
offset in the .debug_pubnames section and in the
|
|
40
|
+
.debug_aranges section.
|
|
41
|
+
the 'varp' here is a pointer to an offset into .debug_info.
|
|
42
|
+
We fix up the offset here if it seems advisable..
|
|
43
|
+
|
|
44
|
+
As of June 2005 we have identified a series of mistakes
|
|
45
|
+
in ldx64 that can cause this (64 bit values getting passed
|
|
46
|
+
thru 32-bit signed knothole).
|
|
47
|
+
*/
|
|
48
|
+
void
|
|
49
|
+
_dwarf_fix_up_offset_irix(Dwarf_Debug dbg,
|
|
50
|
+
Dwarf_Unsigned * varp, char *caller_site_name)
|
|
51
|
+
{
|
|
52
|
+
|
|
53
|
+
Dwarf_Unsigned var = *varp;
|
|
54
|
+
|
|
55
|
+
#define UPPER33 0xffffffff80000000LL
|
|
56
|
+
#define LOWER32 0xffffffffLL
|
|
57
|
+
/* Restrict the hack to the known case. Upper 32 bits erroneously
|
|
58
|
+
sign extended from lower 32 upper bit. */
|
|
59
|
+
if ((var & UPPER33) == UPPER33) {
|
|
60
|
+
var &= LOWER32;
|
|
61
|
+
/* Apply the fix. Dreadful hack. */
|
|
62
|
+
*varp = var;
|
|
63
|
+
}
|
|
64
|
+
#undef UPPER33
|
|
65
|
+
#undef LOWER32
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
#endif /* __sgi */
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
int
|
|
72
|
+
dwarf_get_globals(Dwarf_Debug dbg,
|
|
73
|
+
Dwarf_Global ** globals,
|
|
74
|
+
Dwarf_Signed * return_count, Dwarf_Error * error)
|
|
75
|
+
{
|
|
76
|
+
int res = _dwarf_load_section(dbg, &dbg->de_debug_pubnames,error);
|
|
77
|
+
if (res != DW_DLV_OK) {
|
|
78
|
+
return res = 0;
|
|
79
|
+
}
|
|
80
|
+
if (!dbg->de_debug_pubnames.dss_size) {
|
|
81
|
+
return (DW_DLV_NO_ENTRY);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
return _dwarf_internal_get_pubnames_like_data(dbg,
|
|
86
|
+
dbg->de_debug_pubnames.dss_data,
|
|
87
|
+
dbg->de_debug_pubnames.dss_size,
|
|
88
|
+
globals,
|
|
89
|
+
return_count,
|
|
90
|
+
error,
|
|
91
|
+
DW_DLA_GLOBAL_CONTEXT,
|
|
92
|
+
DW_DLA_GLOBAL,
|
|
93
|
+
DW_DLE_PUBNAMES_LENGTH_BAD,
|
|
94
|
+
DW_DLE_PUBNAMES_VERSION_ERROR);
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Deallocating fully requires deallocating the list
|
|
99
|
+
and all entries. But some internal data is
|
|
100
|
+
not exposed, so we need a function with internal knowledge.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
void
|
|
104
|
+
dwarf_globals_dealloc(Dwarf_Debug dbg, Dwarf_Global * dwgl,
|
|
105
|
+
Dwarf_Signed count)
|
|
106
|
+
{
|
|
107
|
+
_dwarf_internal_globals_dealloc(dbg, dwgl,
|
|
108
|
+
count,
|
|
109
|
+
DW_DLA_GLOBAL_CONTEXT,
|
|
110
|
+
DW_DLA_GLOBAL, DW_DLA_LIST);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
void
|
|
115
|
+
_dwarf_internal_globals_dealloc(Dwarf_Debug dbg, Dwarf_Global * dwgl,
|
|
116
|
+
Dwarf_Signed count,
|
|
117
|
+
int context_code,
|
|
118
|
+
int global_code, int list_code)
|
|
119
|
+
{
|
|
120
|
+
Dwarf_Signed i;
|
|
121
|
+
struct Dwarf_Global_Context_s *gcp = 0;
|
|
122
|
+
struct Dwarf_Global_Context_s *lastgcp = 0;
|
|
123
|
+
|
|
124
|
+
for (i = 0; i < count; i++) {
|
|
125
|
+
Dwarf_Global dgb = dwgl[i];
|
|
126
|
+
|
|
127
|
+
gcp = dgb->gl_context;
|
|
128
|
+
|
|
129
|
+
if (lastgcp != gcp) {
|
|
130
|
+
lastgcp = gcp;
|
|
131
|
+
dwarf_dealloc(dbg, gcp, context_code);
|
|
132
|
+
}
|
|
133
|
+
dwarf_dealloc(dbg, dgb, global_code);
|
|
134
|
+
}
|
|
135
|
+
dwarf_dealloc(dbg, dwgl, list_code);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
/* Sweeps the complete section. */
|
|
141
|
+
int
|
|
142
|
+
_dwarf_internal_get_pubnames_like_data(Dwarf_Debug dbg,
|
|
143
|
+
Dwarf_Small * section_data_ptr,
|
|
144
|
+
Dwarf_Unsigned section_length,
|
|
145
|
+
Dwarf_Global ** globals,
|
|
146
|
+
Dwarf_Signed * return_count,
|
|
147
|
+
Dwarf_Error * error,
|
|
148
|
+
int context_code,
|
|
149
|
+
int global_code,
|
|
150
|
+
int length_err_num,
|
|
151
|
+
int version_err_num)
|
|
152
|
+
{
|
|
153
|
+
Dwarf_Small *pubnames_like_ptr = 0;
|
|
154
|
+
Dwarf_Small *section_end_ptr = section_data_ptr +section_length;
|
|
155
|
+
|
|
156
|
+
/* Points to the context for the current set of global names, and
|
|
157
|
+
contains information to identify the compilation-unit that the
|
|
158
|
+
set refers to. */
|
|
159
|
+
Dwarf_Global_Context pubnames_context = 0;
|
|
160
|
+
|
|
161
|
+
Dwarf_Half version = 0;
|
|
162
|
+
|
|
163
|
+
/* Offset from the start of compilation-unit for the current
|
|
164
|
+
global. */
|
|
165
|
+
Dwarf_Off die_offset_in_cu = 0;
|
|
166
|
+
|
|
167
|
+
Dwarf_Unsigned global_count = 0;
|
|
168
|
+
|
|
169
|
+
/* Points to the current global read. */
|
|
170
|
+
Dwarf_Global global = 0;
|
|
171
|
+
|
|
172
|
+
/* Used to chain the Dwarf_Global_s structs for creating contiguous
|
|
173
|
+
list of pointers to the structs. */
|
|
174
|
+
Dwarf_Chain curr_chain = 0;
|
|
175
|
+
Dwarf_Chain prev_chain = 0;
|
|
176
|
+
Dwarf_Chain head_chain = 0;
|
|
177
|
+
|
|
178
|
+
/* Points to contiguous block of Dwarf_Global's to be returned. */
|
|
179
|
+
Dwarf_Global *ret_globals = 0;
|
|
180
|
+
|
|
181
|
+
/* Temporary counter. */
|
|
182
|
+
Dwarf_Unsigned i = 0;
|
|
183
|
+
|
|
184
|
+
if (dbg == NULL) {
|
|
185
|
+
_dwarf_error(NULL, error, DW_DLE_DBG_NULL);
|
|
186
|
+
return (DW_DLV_ERROR);
|
|
187
|
+
}
|
|
188
|
+
/* We will eventually need the .debug_info data. Load it now. */
|
|
189
|
+
if (!dbg->de_debug_info.dss_data) {
|
|
190
|
+
int res = _dwarf_load_debug_info(dbg, error);
|
|
191
|
+
|
|
192
|
+
if (res != DW_DLV_OK) {
|
|
193
|
+
return res;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (section_data_ptr == NULL) {
|
|
197
|
+
return (DW_DLV_NO_ENTRY);
|
|
198
|
+
}
|
|
199
|
+
pubnames_like_ptr = section_data_ptr;
|
|
200
|
+
do {
|
|
201
|
+
Dwarf_Unsigned length = 0;
|
|
202
|
+
int local_extension_size = 0;
|
|
203
|
+
int local_length_size = 0;
|
|
204
|
+
|
|
205
|
+
/* Some compilers emit padding at the end of each cu's area.
|
|
206
|
+
pubnames_ptr_past_end_cu records the true area end for the
|
|
207
|
+
pubnames(like) content of a cu.
|
|
208
|
+
Essentially the length in the header and the 0
|
|
209
|
+
terminator of the data are redundant information. The
|
|
210
|
+
dwarf2/3 spec does not mention what to do if the length is
|
|
211
|
+
past the 0 terminator. So we take any bytes left after the 0
|
|
212
|
+
as padding and ignore them. */
|
|
213
|
+
Dwarf_Small *pubnames_ptr_past_end_cu = 0;
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
pubnames_context = (Dwarf_Global_Context)
|
|
217
|
+
_dwarf_get_alloc(dbg, context_code, 1);
|
|
218
|
+
if (pubnames_context == NULL) {
|
|
219
|
+
_dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
220
|
+
return (DW_DLV_ERROR);
|
|
221
|
+
}
|
|
222
|
+
/* READ_AREA_LENGTH updates pubnames_like_ptr for consumed
|
|
223
|
+
bytes. */
|
|
224
|
+
READ_AREA_LENGTH(dbg, length, Dwarf_Unsigned,
|
|
225
|
+
pubnames_like_ptr, local_length_size,
|
|
226
|
+
local_extension_size);
|
|
227
|
+
pubnames_context->pu_length_size = local_length_size;
|
|
228
|
+
pubnames_context->pu_extension_size = local_extension_size;
|
|
229
|
+
pubnames_context->pu_dbg = dbg;
|
|
230
|
+
|
|
231
|
+
pubnames_ptr_past_end_cu = pubnames_like_ptr + length;
|
|
232
|
+
|
|
233
|
+
READ_UNALIGNED(dbg, version, Dwarf_Half,
|
|
234
|
+
pubnames_like_ptr, sizeof(Dwarf_Half));
|
|
235
|
+
pubnames_like_ptr += sizeof(Dwarf_Half);
|
|
236
|
+
/* ASSERT: DW_PUBNAMES_VERSION2 == DW_PUBTYPES_VERSION2 */
|
|
237
|
+
if (version != DW_PUBNAMES_VERSION2) {
|
|
238
|
+
_dwarf_error(dbg, error, version_err_num);
|
|
239
|
+
return (DW_DLV_ERROR);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Offset of CU header in debug section. */
|
|
243
|
+
READ_UNALIGNED(dbg, pubnames_context->pu_offset_of_cu_header,
|
|
244
|
+
Dwarf_Off, pubnames_like_ptr,
|
|
245
|
+
pubnames_context->pu_length_size);
|
|
246
|
+
pubnames_like_ptr += pubnames_context->pu_length_size;
|
|
247
|
+
|
|
248
|
+
FIX_UP_OFFSET_IRIX_BUG(dbg,
|
|
249
|
+
pubnames_context->pu_offset_of_cu_header,
|
|
250
|
+
"pubnames cu header offset");
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
READ_UNALIGNED(dbg, pubnames_context->pu_info_length,
|
|
254
|
+
Dwarf_Unsigned, pubnames_like_ptr,
|
|
255
|
+
pubnames_context->pu_length_size);
|
|
256
|
+
pubnames_like_ptr += pubnames_context->pu_length_size;
|
|
257
|
+
|
|
258
|
+
if (pubnames_like_ptr > (section_data_ptr + section_length)) {
|
|
259
|
+
_dwarf_error(dbg, error, length_err_num);
|
|
260
|
+
return (DW_DLV_ERROR);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* Read initial offset (of DIE within CU) of a pubname, final
|
|
264
|
+
entry is not a pair, just a zero offset. */
|
|
265
|
+
READ_UNALIGNED(dbg, die_offset_in_cu, Dwarf_Off,
|
|
266
|
+
pubnames_like_ptr,
|
|
267
|
+
pubnames_context->pu_length_size);
|
|
268
|
+
pubnames_like_ptr += pubnames_context->pu_length_size;
|
|
269
|
+
FIX_UP_OFFSET_IRIX_BUG(dbg,
|
|
270
|
+
die_offset_in_cu, "offset of die in cu");
|
|
271
|
+
|
|
272
|
+
/* Loop thru pairs. DIE off with CU followed by string. */
|
|
273
|
+
while (die_offset_in_cu != 0) {
|
|
274
|
+
int res;
|
|
275
|
+
|
|
276
|
+
/* Already read offset, pubnames_like_ptr now points to the
|
|
277
|
+
string. */
|
|
278
|
+
global =
|
|
279
|
+
(Dwarf_Global) _dwarf_get_alloc(dbg, global_code, 1);
|
|
280
|
+
if (global == NULL) {
|
|
281
|
+
_dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
282
|
+
return (DW_DLV_ERROR);
|
|
283
|
+
}
|
|
284
|
+
global_count++;
|
|
285
|
+
|
|
286
|
+
global->gl_context = pubnames_context;
|
|
287
|
+
|
|
288
|
+
global->gl_named_die_offset_within_cu = die_offset_in_cu;
|
|
289
|
+
|
|
290
|
+
global->gl_name = pubnames_like_ptr;
|
|
291
|
+
|
|
292
|
+
res = _dwarf_check_string_valid(dbg,section_data_ptr,
|
|
293
|
+
pubnames_like_ptr,section_end_ptr,error);
|
|
294
|
+
if (res != DW_DLV_OK) {
|
|
295
|
+
return res;
|
|
296
|
+
}
|
|
297
|
+
pubnames_like_ptr = pubnames_like_ptr +
|
|
298
|
+
strlen((char *) pubnames_like_ptr) + 1;
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
/* Finish off current entry chain */
|
|
302
|
+
curr_chain =
|
|
303
|
+
(Dwarf_Chain) _dwarf_get_alloc(dbg, DW_DLA_CHAIN, 1);
|
|
304
|
+
if (curr_chain == NULL) {
|
|
305
|
+
_dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
306
|
+
return (DW_DLV_ERROR);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/* Put current global on singly_linked list. */
|
|
310
|
+
curr_chain->ch_item = (Dwarf_Global) global;
|
|
311
|
+
|
|
312
|
+
if (head_chain == NULL)
|
|
313
|
+
head_chain = prev_chain = curr_chain;
|
|
314
|
+
else {
|
|
315
|
+
prev_chain->ch_next = curr_chain;
|
|
316
|
+
prev_chain = curr_chain;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/* Fead offset for the *next* entry */
|
|
320
|
+
READ_UNALIGNED(dbg, die_offset_in_cu, Dwarf_Off,
|
|
321
|
+
pubnames_like_ptr, pubnames_context->pu_length_size);
|
|
322
|
+
|
|
323
|
+
pubnames_like_ptr += pubnames_context->pu_length_size;
|
|
324
|
+
FIX_UP_OFFSET_IRIX_BUG(dbg,
|
|
325
|
+
die_offset_in_cu, "offset of next die in cu");
|
|
326
|
+
|
|
327
|
+
if (pubnames_like_ptr > (section_data_ptr + section_length)) {
|
|
328
|
+
_dwarf_error(dbg, error, length_err_num);
|
|
329
|
+
return (DW_DLV_ERROR);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/* ASSERT: die_offset_in_cu == 0 */
|
|
333
|
+
if (pubnames_like_ptr > pubnames_ptr_past_end_cu) {
|
|
334
|
+
/* This is some kind of error. This simply cannot happen.
|
|
335
|
+
The encoding is wrong or the length in the header for
|
|
336
|
+
this cu's contribution is wrong. */
|
|
337
|
+
_dwarf_error(dbg, error, length_err_num);
|
|
338
|
+
return (DW_DLV_ERROR);
|
|
339
|
+
}
|
|
340
|
+
/* If there is some kind of padding at the end of the section,
|
|
341
|
+
as emitted by some compilers, skip over that padding and
|
|
342
|
+
simply ignore the bytes thus passed-over. With most
|
|
343
|
+
compilers, pubnames_like_ptr == pubnames_ptr_past_end_cu at
|
|
344
|
+
this point */
|
|
345
|
+
pubnames_like_ptr = pubnames_ptr_past_end_cu;
|
|
346
|
+
|
|
347
|
+
} while (pubnames_like_ptr < (section_data_ptr + section_length));
|
|
348
|
+
|
|
349
|
+
/* Points to contiguous block of Dwarf_Global's. */
|
|
350
|
+
ret_globals = (Dwarf_Global *)
|
|
351
|
+
_dwarf_get_alloc(dbg, DW_DLA_LIST, global_count);
|
|
352
|
+
if (ret_globals == NULL) {
|
|
353
|
+
_dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
354
|
+
return (DW_DLV_ERROR);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/* Store pointers to Dwarf_Global_s structs in contiguous block,
|
|
358
|
+
and deallocate the chain. */
|
|
359
|
+
curr_chain = head_chain;
|
|
360
|
+
for (i = 0; i < global_count; i++) {
|
|
361
|
+
*(ret_globals + i) = curr_chain->ch_item;
|
|
362
|
+
prev_chain = curr_chain;
|
|
363
|
+
curr_chain = curr_chain->ch_next;
|
|
364
|
+
dwarf_dealloc(dbg, prev_chain, DW_DLA_CHAIN);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
*globals = ret_globals;
|
|
368
|
+
*return_count = (Dwarf_Signed) global_count;
|
|
369
|
+
return DW_DLV_OK;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
/* Given a pubnames entry (or other like section entry)
|
|
374
|
+
return thru the ret_name pointer
|
|
375
|
+
a pointer to the string which is the entry name. */
|
|
376
|
+
int
|
|
377
|
+
dwarf_globname(Dwarf_Global glob, char **ret_name, Dwarf_Error * error)
|
|
378
|
+
{
|
|
379
|
+
if (glob == NULL) {
|
|
380
|
+
_dwarf_error(NULL, error, DW_DLE_GLOBAL_NULL);
|
|
381
|
+
return (DW_DLV_ERROR);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
*ret_name = (char *) (glob->gl_name);
|
|
385
|
+
return DW_DLV_OK;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
/* Given a pubnames entry (or other like section entry)
|
|
390
|
+
return thru the ret_off pointer the
|
|
391
|
+
global offset of the DIE for this entry.
|
|
392
|
+
The global offset is the offset within the .debug_info
|
|
393
|
+
section as a whole. */
|
|
394
|
+
int
|
|
395
|
+
dwarf_global_die_offset(Dwarf_Global global,
|
|
396
|
+
Dwarf_Off * ret_off, Dwarf_Error * error)
|
|
397
|
+
{
|
|
398
|
+
if (global == NULL) {
|
|
399
|
+
_dwarf_error(NULL, error, DW_DLE_GLOBAL_NULL);
|
|
400
|
+
return (DW_DLV_ERROR);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (global->gl_context == NULL) {
|
|
404
|
+
_dwarf_error(NULL, error, DW_DLE_GLOBAL_CONTEXT_NULL);
|
|
405
|
+
return (DW_DLV_ERROR);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
*ret_off = (global->gl_named_die_offset_within_cu +
|
|
409
|
+
global->gl_context->pu_offset_of_cu_header);
|
|
410
|
+
return DW_DLV_OK;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/* Given a pubnames entry (or other like section entry)
|
|
414
|
+
return thru the ret_off pointer the
|
|
415
|
+
offset of the compilation unit header of the
|
|
416
|
+
compilation unit the global is part of.
|
|
417
|
+
|
|
418
|
+
In early versions of this, the value returned was
|
|
419
|
+
the offset of the compilation unit die, and
|
|
420
|
+
other cu-local die offsets were faked so adding this to
|
|
421
|
+
such a cu-local offset got a true section offset.
|
|
422
|
+
Now things do as they say (adding *cu_header_offset to
|
|
423
|
+
a cu-local offset gets the section offset). */
|
|
424
|
+
int
|
|
425
|
+
dwarf_global_cu_offset(Dwarf_Global global,
|
|
426
|
+
Dwarf_Off * cu_header_offset,
|
|
427
|
+
Dwarf_Error * error)
|
|
428
|
+
{
|
|
429
|
+
Dwarf_Global_Context con = 0;
|
|
430
|
+
|
|
431
|
+
if (global == NULL) {
|
|
432
|
+
_dwarf_error(NULL, error, DW_DLE_GLOBAL_NULL);
|
|
433
|
+
return (DW_DLV_ERROR);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
con = global->gl_context;
|
|
437
|
+
|
|
438
|
+
if (con == NULL) {
|
|
439
|
+
_dwarf_error(NULL, error, DW_DLE_GLOBAL_CONTEXT_NULL);
|
|
440
|
+
return (DW_DLV_ERROR);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/* In early libdwarf, this incorrectly returned the offset of the
|
|
444
|
+
CU DIE. Now correctly returns the header offset. */
|
|
445
|
+
*cu_header_offset = con->pu_offset_of_cu_header;
|
|
446
|
+
|
|
447
|
+
return DW_DLV_OK;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/*
|
|
451
|
+
Give back the pubnames entry (or any other like section)
|
|
452
|
+
name, symbol DIE offset, and the cu-DIE offset.
|
|
453
|
+
|
|
454
|
+
Various errors are possible.
|
|
455
|
+
|
|
456
|
+
The string pointer returned thru ret_name is not
|
|
457
|
+
dwarf_get_alloc()ed, so no dwarf_dealloc()
|
|
458
|
+
DW_DLA_STRING should be applied to it.
|
|
459
|
+
|
|
460
|
+
*/
|
|
461
|
+
int
|
|
462
|
+
dwarf_global_name_offsets(Dwarf_Global global,
|
|
463
|
+
char **ret_name,
|
|
464
|
+
Dwarf_Off * die_offset,
|
|
465
|
+
Dwarf_Off * cu_die_offset,
|
|
466
|
+
Dwarf_Error * error)
|
|
467
|
+
{
|
|
468
|
+
Dwarf_Global_Context con = 0;
|
|
469
|
+
Dwarf_Debug dbg = 0;
|
|
470
|
+
Dwarf_Off off = 0;
|
|
471
|
+
|
|
472
|
+
if (global == NULL) {
|
|
473
|
+
_dwarf_error(NULL, error, DW_DLE_GLOBAL_NULL);
|
|
474
|
+
return (DW_DLV_ERROR);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
con = global->gl_context;
|
|
478
|
+
|
|
479
|
+
if (con == NULL) {
|
|
480
|
+
_dwarf_error(NULL, error, DW_DLE_GLOBAL_CONTEXT_NULL);
|
|
481
|
+
return (DW_DLV_ERROR);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
off = con->pu_offset_of_cu_header;
|
|
485
|
+
/* The offset had better not be too close to the end. If it is,
|
|
486
|
+
_dwarf_length_of_cu_header() will step off the end and therefore
|
|
487
|
+
must not be used. 10 is a meaningless heuristic, but no CU
|
|
488
|
+
header is that small so it is safe. An erroneous offset is due
|
|
489
|
+
to a bug in the tool chain. A bug like this has been seen on
|
|
490
|
+
IRIX with MIPSpro 7.3.1.3 and an executable > 2GB in size and
|
|
491
|
+
with 2 million pubnames entries. */
|
|
492
|
+
#define MIN_CU_HDR_SIZE 10
|
|
493
|
+
dbg = con->pu_dbg;
|
|
494
|
+
if (dbg == NULL) {
|
|
495
|
+
_dwarf_error(NULL, error, DW_DLE_DBG_NULL);
|
|
496
|
+
return (DW_DLV_ERROR);
|
|
497
|
+
}
|
|
498
|
+
/* Cannot refer to debug_types */
|
|
499
|
+
if (dbg->de_debug_info.dss_size &&
|
|
500
|
+
((off + MIN_CU_HDR_SIZE) >= dbg->de_debug_info.dss_size)) {
|
|
501
|
+
_dwarf_error(NULL, error, DW_DLE_OFFSET_BAD);
|
|
502
|
+
return (DW_DLV_ERROR);
|
|
503
|
+
}
|
|
504
|
+
#undef MIN_CU_HDR_SIZE
|
|
505
|
+
if (die_offset != NULL) {
|
|
506
|
+
*die_offset = global->gl_named_die_offset_within_cu + off;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
*ret_name = (char *) global->gl_name;
|
|
510
|
+
|
|
511
|
+
if (cu_die_offset != NULL) {
|
|
512
|
+
/* Globals cannot refer to debug_types */
|
|
513
|
+
int res = _dwarf_load_debug_info(dbg, error);
|
|
514
|
+
|
|
515
|
+
if (res != DW_DLV_OK) {
|
|
516
|
+
return res;
|
|
517
|
+
}
|
|
518
|
+
/* The offset had better not be too close to the end. If it is,
|
|
519
|
+
_dwarf_length_of_cu_header() will step off the end and
|
|
520
|
+
therefore must not be used. 10 is a meaningless heuristic,
|
|
521
|
+
but no CU header is that small so it is safe. */
|
|
522
|
+
/* Globals cannot refer to debug_types */
|
|
523
|
+
if ((off + 10) >= dbg->de_debug_info.dss_size) {
|
|
524
|
+
_dwarf_error(NULL, error, DW_DLE_OFFSET_BAD);
|
|
525
|
+
return (DW_DLV_ERROR);
|
|
526
|
+
}
|
|
527
|
+
*cu_die_offset = off + _dwarf_length_of_cu_header(dbg, off,true);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
return DW_DLV_OK;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/* We have the offset to a CU header.
|
|
535
|
+
Return thru outFileOffset the offset of the CU DIE.
|
|
536
|
+
|
|
537
|
+
New June, 2001.
|
|
538
|
+
Used by SGI IRIX debuggers.
|
|
539
|
+
No error is possible.
|
|
540
|
+
|
|
541
|
+
See also dwarf_CU_dieoffset_given_die().
|
|
542
|
+
|
|
543
|
+
This is assumed to never apply to data in .debug_types, it
|
|
544
|
+
only refers to .debug_info.
|
|
545
|
+
|
|
546
|
+
*/
|
|
547
|
+
|
|
548
|
+
/* ARGSUSED */
|
|
549
|
+
int
|
|
550
|
+
dwarf_get_cu_die_offset_given_cu_header_offset(Dwarf_Debug dbg,
|
|
551
|
+
Dwarf_Off in_cu_header_offset,
|
|
552
|
+
Dwarf_Off * out_cu_die_offset,
|
|
553
|
+
Dwarf_Error * err)
|
|
554
|
+
{
|
|
555
|
+
Dwarf_Off len =
|
|
556
|
+
_dwarf_length_of_cu_header(dbg, in_cu_header_offset,true);
|
|
557
|
+
|
|
558
|
+
Dwarf_Off newoff = in_cu_header_offset + len;
|
|
559
|
+
|
|
560
|
+
*out_cu_die_offset = newoff;
|
|
561
|
+
return DW_DLV_OK;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/* The following version new in October 2011, does allow finding
|
|
565
|
+
the offset if one knows whether debug_info or debug_types.
|
|
566
|
+
|
|
567
|
+
However, it is not accurate in DWARF5 because
|
|
568
|
+
there are two different header lengths (CU and TU)
|
|
569
|
+
in DWARF5 .debug_info. In that case, pretend
|
|
570
|
+
that it's .debug_types (here) and pass is_info zero for
|
|
571
|
+
a TU (as if it was in .debug_types).
|
|
572
|
+
*/
|
|
573
|
+
int
|
|
574
|
+
dwarf_get_cu_die_offset_given_cu_header_offset_b(Dwarf_Debug dbg,
|
|
575
|
+
Dwarf_Off in_cu_header_offset,
|
|
576
|
+
Dwarf_Bool is_info,
|
|
577
|
+
Dwarf_Off * out_cu_die_offset,
|
|
578
|
+
Dwarf_Error * err)
|
|
579
|
+
{
|
|
580
|
+
Dwarf_Off len =
|
|
581
|
+
_dwarf_length_of_cu_header(dbg, in_cu_header_offset,is_info);
|
|
582
|
+
|
|
583
|
+
Dwarf_Off newoff = in_cu_header_offset + len;
|
|
584
|
+
|
|
585
|
+
*out_cu_die_offset = newoff;
|
|
586
|
+
return DW_DLV_OK;
|
|
587
|
+
}
|
|
588
|
+
/* dwarf_CU_dieoffset_given_die returns
|
|
589
|
+
the global debug_info section offset of the CU die
|
|
590
|
+
that is the CU containing the given (passed-in) die.
|
|
591
|
+
This information makes it possible for a consumer to
|
|
592
|
+
find and print context information for any die.
|
|
593
|
+
|
|
594
|
+
Use dwarf_offdie() passing in the offset this returns
|
|
595
|
+
to get a die pointer to the CU die. */
|
|
596
|
+
int
|
|
597
|
+
dwarf_CU_dieoffset_given_die(Dwarf_Die die,
|
|
598
|
+
Dwarf_Off* return_offset,
|
|
599
|
+
Dwarf_Error* error)
|
|
600
|
+
{
|
|
601
|
+
Dwarf_Off dieoff = 0;
|
|
602
|
+
Dwarf_CU_Context cucontext = 0;
|
|
603
|
+
|
|
604
|
+
CHECK_DIE(die, DW_DLV_ERROR);
|
|
605
|
+
cucontext = die->di_cu_context;
|
|
606
|
+
dieoff = cucontext->cc_debug_offset;
|
|
607
|
+
/* The following call cannot fail, so no error check. */
|
|
608
|
+
dwarf_get_cu_die_offset_given_cu_header_offset_b(
|
|
609
|
+
cucontext->cc_dbg, dieoff,
|
|
610
|
+
die->di_is_info, return_offset,error);
|
|
611
|
+
return DW_DLV_OK;
|
|
612
|
+
}
|