|
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 |
|
37 |
|
38 #include "config.h" |
|
39 #include "dwarf_incl.h" |
|
40 #include <stdio.h> |
|
41 #include "dwarf_vars.h" |
|
42 #include "dwarf_global.h" |
|
43 |
|
44 int |
|
45 dwarf_get_vars(Dwarf_Debug dbg, |
|
46 Dwarf_Var ** vars, |
|
47 Dwarf_Signed * ret_var_count, Dwarf_Error * error) |
|
48 { |
|
49 int res; |
|
50 |
|
51 res = |
|
52 _dwarf_load_section(dbg, |
|
53 dbg->de_debug_varnames_index, |
|
54 &dbg->de_debug_varnames, error); |
|
55 if (res != DW_DLV_OK) { |
|
56 return res; |
|
57 } |
|
58 |
|
59 return _dwarf_internal_get_pubnames_like_data(dbg, dbg->de_debug_varnames, dbg->de_debug_varnames_size, (Dwarf_Global **) vars, /* type |
|
60 punning, |
|
61 Dwarf_Type |
|
62 is never a |
|
63 completed |
|
64 type */ |
|
65 ret_var_count, |
|
66 error, |
|
67 DW_DLA_VAR_CONTEXT, |
|
68 DW_DLA_VAR, |
|
69 DW_DLE_DEBUG_VARNAMES_LENGTH_BAD, |
|
70 DW_DLE_DEBUG_VARNAMES_VERSION_ERROR); |
|
71 } |
|
72 |
|
73 /* Deallocating fully requires deallocating the list |
|
74 and all entries. But some internal data is |
|
75 not exposed, so we need a function with internal knowledge. |
|
76 */ |
|
77 |
|
78 void |
|
79 dwarf_vars_dealloc(Dwarf_Debug dbg, Dwarf_Var * dwgl, |
|
80 Dwarf_Signed count) |
|
81 { |
|
82 _dwarf_internal_globals_dealloc(dbg, (Dwarf_Global *) dwgl, |
|
83 count, |
|
84 DW_DLA_VAR_CONTEXT, |
|
85 DW_DLA_VAR, DW_DLA_LIST); |
|
86 return; |
|
87 } |
|
88 |
|
89 |
|
90 int |
|
91 dwarf_varname(Dwarf_Var var_in, char **ret_varname, Dwarf_Error * error) |
|
92 { |
|
93 Dwarf_Global var = (Dwarf_Global) var_in; |
|
94 |
|
95 if (var == NULL) { |
|
96 _dwarf_error(NULL, error, DW_DLE_VAR_NULL); |
|
97 return (DW_DLV_ERROR); |
|
98 } |
|
99 |
|
100 *ret_varname = (char *) (var->gl_name); |
|
101 return DW_DLV_OK; |
|
102 } |
|
103 |
|
104 |
|
105 int |
|
106 dwarf_var_die_offset(Dwarf_Var var_in, |
|
107 Dwarf_Off * returned_offset, Dwarf_Error * error) |
|
108 { |
|
109 Dwarf_Global var = (Dwarf_Global) var_in; |
|
110 |
|
111 return dwarf_global_die_offset(var, returned_offset, error); |
|
112 |
|
113 } |
|
114 |
|
115 |
|
116 int |
|
117 dwarf_var_cu_offset(Dwarf_Var var_in, |
|
118 Dwarf_Off * returned_offset, Dwarf_Error * error) |
|
119 { |
|
120 Dwarf_Global var = (Dwarf_Global) var_in; |
|
121 |
|
122 return dwarf_global_cu_offset(var, returned_offset, error); |
|
123 } |
|
124 |
|
125 |
|
126 int |
|
127 dwarf_var_name_offsets(Dwarf_Var var_in, |
|
128 char **returned_name, |
|
129 Dwarf_Off * die_offset, |
|
130 Dwarf_Off * cu_offset, Dwarf_Error * error) |
|
131 { |
|
132 Dwarf_Global var = (Dwarf_Global) var_in; |
|
133 |
|
134 return |
|
135 dwarf_global_name_offsets(var, |
|
136 returned_name, die_offset, cu_offset, |
|
137 error); |
|
138 } |