|
1 /* |
|
2 |
|
3 Copyright (C) 2000,2002,2004,2005 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 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, |
|
26 Mountain View, CA 94043, or: |
|
27 |
|
28 http://www.sgi.com |
|
29 |
|
30 For further information regarding this notice, see: |
|
31 |
|
32 http://oss.sgi.com/projects/GenInfo/NoticeExplan |
|
33 |
|
34 */ |
|
35 |
|
36 /* Reads DWARF3 .debug_pubtypes section. */ |
|
37 |
|
38 |
|
39 #include "config.h" |
|
40 #include "dwarf_incl.h" |
|
41 #include <stdio.h> |
|
42 #include "dwarf_types.h" |
|
43 #include "dwarf_global.h" |
|
44 |
|
45 int |
|
46 dwarf_get_pubtypes(Dwarf_Debug dbg, |
|
47 Dwarf_Type ** types, |
|
48 Dwarf_Signed * ret_type_count, Dwarf_Error * error) |
|
49 { |
|
50 int res; |
|
51 |
|
52 res = |
|
53 _dwarf_load_section(dbg, |
|
54 dbg->de_debug_pubtypes_index, |
|
55 &dbg->de_debug_pubtypes, error); |
|
56 if (res != DW_DLV_OK) { |
|
57 return res; |
|
58 } |
|
59 |
|
60 return _dwarf_internal_get_pubnames_like_data(dbg, dbg->de_debug_pubtypes, dbg->de_debug_pubtypes_size, (Dwarf_Global **) types, /* type |
|
61 punning, |
|
62 Dwarf_Type |
|
63 is never |
|
64 a |
|
65 completed |
|
66 type */ |
|
67 ret_type_count, error, DW_DLA_PUBTYPES_CONTEXT, DW_DLA_GLOBAL, /* We |
|
68 don't |
|
69 have |
|
70 DW_DLA_PUBTYPES, |
|
71 so use |
|
72 DW_DLA_GLOBAL. */ |
|
73 DW_DLE_DEBUG_PUBTYPES_LENGTH_BAD, |
|
74 DW_DLE_DEBUG_PUBTYPES_VERSION_ERROR); |
|
75 } |
|
76 |
|
77 /* Deallocating fully requires deallocating the list |
|
78 and all entries. But some internal data is |
|
79 not exposed, so we need a function with internal knowledge. |
|
80 */ |
|
81 |
|
82 void |
|
83 dwarf_pubtypes_dealloc(Dwarf_Debug dbg, Dwarf_Type * dwgl, |
|
84 Dwarf_Signed count) |
|
85 { |
|
86 _dwarf_internal_globals_dealloc(dbg, (Dwarf_Global *) dwgl, count, DW_DLA_PUBTYPES_CONTEXT, DW_DLA_GLOBAL, /* We |
|
87 don't |
|
88 have |
|
89 DW_DLA_PUBTYPES, |
|
90 so use |
|
91 DW_DLA_GLOBAL. */ |
|
92 DW_DLA_LIST); |
|
93 return; |
|
94 } |
|
95 |
|
96 |
|
97 |
|
98 int |
|
99 dwarf_pubtypename(Dwarf_Type type_in, char **ret_name, |
|
100 Dwarf_Error * error) |
|
101 { |
|
102 Dwarf_Global type = (Dwarf_Global) type_in; |
|
103 |
|
104 if (type == NULL) { |
|
105 _dwarf_error(NULL, error, DW_DLE_TYPE_NULL); |
|
106 return (DW_DLV_ERROR); |
|
107 } |
|
108 |
|
109 *ret_name = (char *) (type->gl_name); |
|
110 return DW_DLV_OK; |
|
111 } |
|
112 |
|
113 |
|
114 int |
|
115 dwarf_pubtype_type_die_offset(Dwarf_Type type_in, |
|
116 Dwarf_Off * ret_offset, |
|
117 Dwarf_Error * error) |
|
118 { |
|
119 Dwarf_Global type = (Dwarf_Global) type_in; |
|
120 |
|
121 return dwarf_global_die_offset(type, ret_offset, error); |
|
122 } |
|
123 |
|
124 |
|
125 int |
|
126 dwarf_pubtype_cu_offset(Dwarf_Type type_in, |
|
127 Dwarf_Off * ret_offset, Dwarf_Error * error) |
|
128 { |
|
129 Dwarf_Global type = (Dwarf_Global) type_in; |
|
130 |
|
131 return dwarf_global_cu_offset(type, ret_offset, error); |
|
132 |
|
133 } |
|
134 |
|
135 |
|
136 int |
|
137 dwarf_pubtype_name_offsets(Dwarf_Type type_in, |
|
138 char **returned_name, |
|
139 Dwarf_Off * die_offset, |
|
140 Dwarf_Off * cu_die_offset, |
|
141 Dwarf_Error * error) |
|
142 { |
|
143 Dwarf_Global type = (Dwarf_Global) type_in; |
|
144 |
|
145 return dwarf_global_name_offsets(type, |
|
146 returned_name, |
|
147 die_offset, cu_die_offset, error); |
|
148 } |