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.
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,82 @@
1
+ /*
2
+
3
+ Copyright (C) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
4
+ Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved.
5
+
6
+ This program is free software; you can redistribute it and/or modify it
7
+ under the terms of version 2.1 of the GNU Lesser General Public License
8
+ as published by the Free Software Foundation.
9
+
10
+ This program is distributed in the hope that it would be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+
14
+ Further, this software is distributed without any warranty that it is
15
+ free of the rightful claim of any third person regarding infringement
16
+ or the like. Any license provided herein, whether implied or
17
+ otherwise, applies only to this software file. Patent licenses, if
18
+ any, provided herein do not apply to combinations of this program with
19
+ other software, or any other product whatsoever.
20
+
21
+ You should have received a copy of the GNU Lesser General Public
22
+ License along with this program; if not, write the Free Software
23
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
24
+ USA.
25
+
26
+ */
27
+
28
+ #include "config.h"
29
+ #include "dwarf_incl.h"
30
+
31
+ int
32
+ dwarf_get_str(Dwarf_Debug dbg,
33
+ Dwarf_Off offset,
34
+ char **string,
35
+ Dwarf_Signed * returned_str_len, Dwarf_Error * error)
36
+ {
37
+ int res = DW_DLV_ERROR;
38
+ void *secptr = 0;
39
+ void *begin = 0;
40
+ void *end = 0;
41
+
42
+ if (dbg == NULL) {
43
+ _dwarf_error(NULL, error, DW_DLE_DBG_NULL);
44
+ return (DW_DLV_ERROR);
45
+ }
46
+
47
+ if (offset == dbg->de_debug_str.dss_size) {
48
+ /* Normal (if we've iterated thru the set of strings using
49
+ dwarf_get_str and are at the end). */
50
+ return DW_DLV_NO_ENTRY;
51
+ }
52
+ if (offset > dbg->de_debug_str.dss_size) {
53
+ _dwarf_error(dbg, error, DW_DLE_DEBUG_STR_OFFSET_BAD);
54
+ return (DW_DLV_ERROR);
55
+ }
56
+
57
+ if (string == NULL) {
58
+ _dwarf_error(dbg, error, DW_DLE_STRING_PTR_NULL);
59
+ return (DW_DLV_ERROR);
60
+ }
61
+
62
+ res = _dwarf_load_section(dbg, &dbg->de_debug_str,error);
63
+ if (res != DW_DLV_OK) {
64
+ return res;
65
+ }
66
+ if (!dbg->de_debug_str.dss_size) {
67
+ return (DW_DLV_NO_ENTRY);
68
+ }
69
+ secptr =dbg->de_debug_str.dss_data;
70
+ begin = (char *)secptr + offset;
71
+ end = (char *)secptr + dbg->de_debug_str.dss_size;
72
+
73
+ res = _dwarf_check_string_valid(dbg,secptr,begin,end,error);
74
+ if (res != DW_DLV_OK) {
75
+ return res;
76
+ }
77
+
78
+ *string = (char *) begin;
79
+ *returned_str_len = strlen(*string);
80
+ return DW_DLV_OK;
81
+ }
82
+
@@ -0,0 +1,38 @@
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 "dwarf_incl.h"
30
+ #include <stdio.h>
31
+
32
+ /*ARGSUSED*/ int
33
+ dwarf_nextglob(Dwarf_Debug dbg,
34
+ Dwarf_Global glob,
35
+ Dwarf_Global * returned_nextglob, Dwarf_Error * error)
36
+ {
37
+ return (DW_DLV_NO_ENTRY);
38
+ }
@@ -0,0 +1,423 @@
1
+ /*
2
+
3
+ Copyright (C) 2015-2015 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
+ #include "config.h"
28
+ #include "dwarf_incl.h"
29
+ #include "dwarf_tsearch.h"
30
+ #include <stdlib.h> /* for free(). */
31
+ #include <stdio.h> /* For debugging. */
32
+
33
+ #define TRUE 1
34
+ #define FALSE 0
35
+
36
+ #define HASHSEARCH
37
+
38
+ #ifdef HASHSEARCH
39
+ /* Only needed for hash based search in a tsearch style. */
40
+ #define INITTREE(x,y) x = dwarf_initialize_search_hash(&(x),(y),0)
41
+ #else
42
+ #define INITTREE(x,y)
43
+ #endif /* HASHSEARCH */
44
+
45
+
46
+
47
+ /* Contexts are in a list in a dbg and
48
+ do not move once established.
49
+ So saving one is ok. as long as the dbg
50
+ exists. */
51
+ struct Dwarf_Tied_Entry_s {
52
+ Dwarf_Sig8 dt_key;
53
+ Dwarf_CU_Context dt_context;
54
+ };
55
+
56
+ void
57
+ _dwarf_dumpsig(const char *msg, Dwarf_Sig8 *sig,int lineno)
58
+ {
59
+ const char *sigv = 0;
60
+ unsigned u = 0;
61
+
62
+ printf("%s 0x",msg);
63
+ sigv = &sig->signature[0];
64
+ for (u = 0; u < 8; u++) {
65
+ printf("%02x",0xff&sigv[u]);
66
+ }
67
+ printf(" line %d\n",lineno);
68
+ }
69
+
70
+ static void *
71
+ tied_make_entry(Dwarf_Sig8 *key, Dwarf_CU_Context val)
72
+ {
73
+ struct Dwarf_Tied_Entry_s *e = 0;
74
+ e = calloc(1,sizeof(struct Dwarf_Tied_Entry_s));
75
+ if(e) {
76
+ e->dt_key = *key;
77
+ e->dt_context = val;
78
+ }
79
+ return e;
80
+ }
81
+
82
+
83
+ /* Tied data Key is Dwarf_Sig8.
84
+ A hash needed because we are using a hash search
85
+ here. Would not be needed for the other tree searchs
86
+ like balanced trees.. */
87
+ static unsigned long
88
+ tied_data_hashfunc(const void *keyp)
89
+ {
90
+ const struct Dwarf_Tied_Entry_s * enp = keyp;
91
+ unsigned long hashv = 0;
92
+ /* Just take some of the 8 bytes of the signature. */
93
+ memcpy(&hashv,enp->dt_key.signature,sizeof(hashv));
94
+ return hashv;
95
+ }
96
+
97
+ static int
98
+ tied_compare_function(const void *l, const void *r)
99
+ {
100
+ const struct Dwarf_Tied_Entry_s * lp = l;
101
+ const struct Dwarf_Tied_Entry_s * rp = r;
102
+ const char *lcp = (const char *)&lp->dt_key.signature;
103
+ const char *rcp = (const char *)&rp->dt_key.signature;
104
+ const char *lcpend = lcp + sizeof(Dwarf_Sig8);
105
+
106
+ for(; lcp < lcpend; ++lcp,++rcp) {
107
+ if (*lcp < *rcp) {
108
+ return -1;
109
+ } else if (*lcp > *rcp) {
110
+ return 1;
111
+ }
112
+ }
113
+ /* match. */
114
+ return 0;
115
+ }
116
+
117
+
118
+ void
119
+ _dwarf_tied_destroy_free_node(void*nodep)
120
+ {
121
+ struct Dwarf_Tied_Entry_s * enp = nodep;
122
+ free(enp);
123
+ return;
124
+ }
125
+
126
+ #ifndef TESTING
127
+
128
+ /* This presumes only we are reading the debug_info
129
+ CUs from tieddbg. That is a reasonable
130
+ requirement, one hopes. */
131
+ static int
132
+ _dwarf_loop_reading_debug_info_for_cu(
133
+ Dwarf_Debug tieddbg,
134
+ Dwarf_Sig8 sig,
135
+ Dwarf_Error *error)
136
+ {
137
+ unsigned loop_count = 0;
138
+ /* We will not find tied signatures
139
+ for .debug_addr (or line tables) in .debug_types.
140
+ it seems. Those signatures point from
141
+ 'normal' to 'dwo/dwp' */
142
+ int is_info = TRUE;
143
+ Dwarf_CU_Context startingcontext = 0;
144
+ Dwarf_Unsigned next_cu_offset = 0;
145
+
146
+ startingcontext = tieddbg->de_info_reading.de_cu_context;
147
+
148
+ if (startingcontext) {
149
+ next_cu_offset =
150
+ startingcontext->cc_debug_offset +
151
+ startingcontext->cc_length +
152
+ startingcontext->cc_length_size +
153
+ startingcontext->cc_extension_size;
154
+ }
155
+
156
+ for (;;++loop_count) {
157
+ int sres = DW_DLV_OK;
158
+ Dwarf_Half cu_type = 0;
159
+ Dwarf_CU_Context latestcontext = 0;
160
+ Dwarf_Unsigned cu_header_length = 0;
161
+ Dwarf_Unsigned abbrev_offset = 0;
162
+ Dwarf_Half version_stamp = 0;
163
+ Dwarf_Half address_size = 0;
164
+ Dwarf_Half extension_size = 0;
165
+ Dwarf_Half length_size = 0;
166
+ Dwarf_Sig8 signature;
167
+ Dwarf_Bool has_signature = FALSE;
168
+ Dwarf_Unsigned typeoffset = 0;
169
+
170
+
171
+ memset(&signature,0,sizeof(signature));
172
+ sres = _dwarf_next_cu_header_internal(tieddbg,
173
+ is_info,
174
+ &cu_header_length, &version_stamp,
175
+ &abbrev_offset, &address_size,
176
+ &length_size,&extension_size,
177
+ &signature, &has_signature,
178
+ &typeoffset,
179
+ &next_cu_offset,
180
+ &cu_type, error);
181
+ if (sres == DW_DLV_NO_ENTRY) {
182
+ break;
183
+ }
184
+
185
+ latestcontext = tieddbg->de_info_reading.de_cu_context;
186
+
187
+ if (has_signature) {
188
+ void *retval = 0;
189
+ Dwarf_Sig8 consign =
190
+ latestcontext->cc_type_signature;
191
+ void *entry =
192
+ tied_make_entry(&consign,latestcontext);
193
+
194
+ if (!entry) {
195
+ return DW_DLV_NO_ENTRY;
196
+ }
197
+ /* Insert this signature and context. */
198
+ retval = dwarf_tsearch(entry,
199
+ &tieddbg->de_tied_data.td_tied_search,
200
+ tied_compare_function);
201
+ if (!retval) {
202
+ /* FAILED might be out of memory.*/
203
+ return DW_DLV_NO_ENTRY;
204
+ }
205
+ #if 0
206
+ /* This could be a compiler error. But
207
+ let us not decide? FIXME */
208
+ if (!latestcontext->cc_addr_base_present) {
209
+ }
210
+ #endif
211
+ return DW_DLV_OK;
212
+ }
213
+ }
214
+ return DW_DLV_NO_ENTRY;
215
+ }
216
+
217
+
218
+ /* If out of memory just return DW_DLV_NO_ENTRY.
219
+ */
220
+ int
221
+ _dwarf_search_for_signature(Dwarf_Debug tieddbg,
222
+ Dwarf_Sig8 sig,
223
+ Dwarf_CU_Context *context_out,
224
+ Dwarf_Error *error)
225
+ {
226
+
227
+ void *entry2 = 0;
228
+ struct Dwarf_Tied_Entry_s entry;
229
+ struct Dwarf_Tied_Data_s * tied = &tieddbg->de_tied_data;
230
+ int res = 0;
231
+
232
+ if (!tied->td_tied_search) {
233
+ dwarf_initialize_search_hash(&tied->td_tied_search,
234
+ tied_data_hashfunc,0);
235
+ if (!tied->td_tied_search) {
236
+ return DW_DLV_NO_ENTRY;
237
+ }
238
+ }
239
+ entry.dt_key = sig;
240
+ entry.dt_context = 0;
241
+ entry2 = dwarf_tfind(&entry,
242
+ &tied->td_tied_search,
243
+ tied_compare_function);
244
+ if (entry2) {
245
+ struct Dwarf_Tied_Entry_s *e2 =
246
+ *(struct Dwarf_Tied_Entry_s **)entry2;
247
+ *context_out = e2->dt_context;
248
+ return DW_DLV_OK;
249
+ }
250
+
251
+ /* We assume the caller is NOT doing
252
+ info section read operations
253
+ on the tieddbg. */
254
+ res = _dwarf_loop_reading_debug_info_for_cu(
255
+ tieddbg,sig,error);
256
+ if (res == DW_DLV_ERROR) {
257
+ return res;
258
+ }
259
+
260
+ entry2 = dwarf_tfind(&entry,
261
+ &tied->td_tied_search,
262
+ tied_compare_function);
263
+ if (entry2) {
264
+ struct Dwarf_Tied_Entry_s *e2 =
265
+ *(struct Dwarf_Tied_Entry_s **)entry2;
266
+ *context_out = e2->dt_context;
267
+ return DW_DLV_OK;
268
+ }
269
+ return DW_DLV_NO_ENTRY;
270
+ }
271
+ #endif /* ndef TESTING */
272
+
273
+
274
+ #ifdef TESTING
275
+
276
+ struct test_data_s {
277
+ const char action;
278
+ unsigned long val;
279
+ } testdata[] = {
280
+ {'a', 0x33c8},
281
+ {'a', 0x34d8},
282
+ {'a', 0x35c8},
283
+ {'a', 0x3640},
284
+ {'a', 0x3820},
285
+ {'a', 0x38d0},
286
+ {'a', 0x3958},
287
+ {'a', 0x39e8},
288
+ {'a', 0x3a78},
289
+ {'a', 0x3b08},
290
+ {'a', 0x3b98},
291
+ {'a', 0x3c28},
292
+ {'a', 0x3cb8},
293
+ {'d', 0x3c28},
294
+ {'a', 0x3d48},
295
+ {'d', 0x3cb8},
296
+ {'a', 0x3dd8},
297
+ {'d', 0x3d48},
298
+ {'a', 0x3e68},
299
+ {'d', 0x3dd8},
300
+ {'a', 0x3ef8},
301
+ {'a', 0x3f88},
302
+ {'d', 0x3e68},
303
+ {'a', 0x4018},
304
+ {'d', 0x3ef8},
305
+ {0,0}
306
+ };
307
+
308
+
309
+ struct Dwarf_Tied_Entry_s *
310
+ makeentry(unsigned long instance, unsigned ct)
311
+ {
312
+ Dwarf_Sig8 s8;
313
+ Dwarf_CU_Context context = 0;
314
+ memset(&s8,0,sizeof(s8));
315
+ struct Dwarf_Tied_Entry_s * entry = 0;
316
+
317
+ /* Silly, but just a test...*/
318
+ memcpy(&s8,&instance,sizeof(instance));
319
+ context = (Dwarf_CU_Context)instance;
320
+
321
+ entry = (struct Dwarf_Tied_Entry_s *)
322
+ tied_make_entry(&s8,context);
323
+ if (!entry) {
324
+ printf("Out of memory in test! %u\n",ct);
325
+ exit(1);
326
+ }
327
+ return entry;
328
+ }
329
+
330
+ static int
331
+ insone(void**tree,unsigned long instance, unsigned ct)
332
+ {
333
+ struct Dwarf_Tied_Entry_s * entry = 0;
334
+ void *retval = 0;
335
+
336
+ entry = makeentry(instance, ct);
337
+ retval = dwarf_tsearch(entry,tree, tied_compare_function);
338
+
339
+ if(retval == 0) {
340
+ printf("FAIL ENOMEM in search on rec %u adr 0x%lu,"
341
+ " error in insone\n",
342
+ ct,(unsigned long)instance);
343
+ exit(1);
344
+ } else {
345
+ struct Dwarf_Tied_Entry_s *re = 0;
346
+ re = *(struct Dwarf_Tied_Entry_s **)retval;
347
+ if(re != entry) {
348
+ /* Found existing, error. */
349
+ printf("insertone rec %u addr 0x%lu found record"
350
+ " preexisting, error\n",
351
+ ct,(unsigned long)instance);
352
+ _dwarf_tied_destroy_free_node(entry);
353
+ exit(1);
354
+ } else {
355
+ /* inserted new entry, make sure present. */
356
+ struct Dwarf_Tied_Entry_s * entry2 = 0;
357
+ entry2 = makeentry(instance,ct);
358
+ retval = dwarf_tfind(entry2,tree,
359
+ tied_compare_function);
360
+ _dwarf_tied_destroy_free_node(entry2);
361
+ if(!retval) {
362
+ printf("insertonebypointer record %d addr 0x%lu "
363
+ "failed to add as desired,"
364
+ " error\n",
365
+ ct,(unsigned long)instance);
366
+ exit(1);
367
+ }
368
+ }
369
+ }
370
+ return 0;
371
+ }
372
+
373
+ static int
374
+ delone(void**tree,unsigned long instance, unsigned ct)
375
+ {
376
+ struct Dwarf_Tied_Entry_s * entry = 0;
377
+ void *r = 0;
378
+
379
+
380
+ entry = makeentry(instance, ct);
381
+ r = dwarf_tfind(entry,(void *const*)tree,
382
+ tied_compare_function);
383
+ if (r) {
384
+ struct Dwarf_Tied_Entry_s *re3 =
385
+ *(struct Dwarf_Tied_Entry_s **)r;
386
+ re3 = *(struct Dwarf_Tied_Entry_s **)r;
387
+ dwarf_tdelete(entry,tree,tied_compare_function);
388
+ _dwarf_tied_destroy_free_node(entry);
389
+ _dwarf_tied_destroy_free_node(re3);
390
+ } else {
391
+ printf("delone could not find rec %u ! error! addr"
392
+ " 0x%lx\n",
393
+ ct,(unsigned long)instance);
394
+ exit(1) ;
395
+ }
396
+ return 0;
397
+
398
+ }
399
+
400
+ int main()
401
+ {
402
+ void *tied_data = 0;
403
+ unsigned u = 0;
404
+ int res;
405
+
406
+ INITTREE(tied_data,tied_data_hashfunc);
407
+ for ( ; testdata[u].action; ++u) {
408
+ char action = testdata[u].action;
409
+ unsigned long v = testdata[u].val;
410
+ if (action == 'a') {
411
+ insone(&tied_data,v,u);
412
+ } else if (action == 'd') {
413
+ delone(&tied_data,v,u);
414
+ } else {
415
+ printf("FAIL testtied on action %u, "
416
+ "not a or d\n",action);
417
+ exit(1);
418
+ }
419
+ }
420
+ printf("PASS tsearch works for Dwarf_Tied_Entry_s.\n");
421
+ return 0;
422
+ }
423
+ #endif