|
1 /* |
|
2 Copyright (C) 2000,2004,2005 Silicon Graphics, Inc. All Rights Reserved. |
|
3 Portions Copyright (C) 2007 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 of the GNU General Public License as |
|
7 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 General Public License along |
|
21 with this program; if not, write the Free Software Foundation, Inc., 51 |
|
22 Franklin Street - Fifth Floor, Boston MA 02110-1301, USA. |
|
23 |
|
24 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, |
|
25 Mountain View, CA 94043, or: |
|
26 |
|
27 http://www.sgi.com |
|
28 |
|
29 For further information regarding this notice, see: |
|
30 |
|
31 http://oss.sgi.com/projects/GenInfo/NoticeExplan |
|
32 |
|
33 |
|
34 |
|
35 $Header: /plroot/cmplrs.src/v7.4.5m/.RCS/PL/dwarfdump/RCS/globals.h,v 1.25 2006/04/17 00:09:56 davea Exp $ */ |
|
36 |
|
37 #ifndef globals_INCLUDED |
|
38 #define globals_INCLUDED |
|
39 |
|
40 #include "config.h" |
|
41 #if (!defined(HAVE_RAW_LIBELF_OK) && defined(HAVE_LIBELF_OFF64_OK) ) |
|
42 /* At a certain point libelf.h requires _GNU_SOURCE. |
|
43 here we assume the criteria in configure determine that |
|
44 usefully. |
|
45 */ |
|
46 #define _GNU_SOURCE 1 |
|
47 #endif |
|
48 |
|
49 |
|
50 /* We want __uint32_t and __uint64_t and __int32_t __int64_t |
|
51 properly defined but not duplicated, since duplicate typedefs |
|
52 are not legal C. |
|
53 */ |
|
54 /* |
|
55 HAVE___UINT32_T |
|
56 HAVE___UINT64_T will be set by configure if |
|
57 our 4 types are predefined in compiler |
|
58 */ |
|
59 |
|
60 |
|
61 #if (!defined(HAVE___UINT32_T)) && defined(HAVE_SGIDEFS_H) |
|
62 #include <sgidefs.h> /* sgidefs.h defines them */ |
|
63 #define HAVE___UINT32_T 1 |
|
64 #define HAVE___UINT64_T 1 |
|
65 #endif |
|
66 |
|
67 |
|
68 |
|
69 #if (!defined(HAVE___UINT32_T)) && defined(HAVE_SYS_TYPES_H) && defined(HAVE___UINT32_T_IN_SYS_TYPES_H) |
|
70 # include <sys/types.h> |
|
71 /* we assume __[u]int32_t and __[u]int64_t defined |
|
72 since __uint32_t defined in the sys/types.h in use */ |
|
73 #define HAVE___UINT32_T 1 |
|
74 #define HAVE___UINT64_T 1 |
|
75 #endif |
|
76 |
|
77 #ifndef HAVE___UINT32_T |
|
78 typedef int __int32_t; |
|
79 typedef unsigned __uint32_t; |
|
80 #define HAVE___UINT32_T 1 |
|
81 #endif |
|
82 #ifndef HAVE___UINT64_T |
|
83 typedef long long __int64_t; |
|
84 typedef unsigned long long __uint64_t; |
|
85 #define HAVE___UINT64_T 1 |
|
86 #endif |
|
87 |
|
88 |
|
89 #include <stdio.h> |
|
90 #include <stdlib.h> |
|
91 #include <string.h> |
|
92 #ifdef HAVE_ELF_H |
|
93 #include <elf.h> |
|
94 #endif |
|
95 #ifdef HAVE_LIBELF_H |
|
96 #include <libelf.h> |
|
97 #else |
|
98 #ifdef HAVE_LIBELF_LIBELF_H |
|
99 #include <libelf/libelf.h> |
|
100 #endif |
|
101 #endif |
|
102 #include <dwarf.h> |
|
103 #include <libdwarf.h> |
|
104 |
|
105 typedef char * string; |
|
106 typedef int boolean; |
|
107 #ifndef FALSE |
|
108 #define FALSE 0 |
|
109 #endif |
|
110 #ifndef TRUE |
|
111 #define TRUE 1 |
|
112 #endif |
|
113 |
|
114 /* size of attrib_buffer, defined in print_die.c */ |
|
115 #define ATTRIB_BUFSIZ 999 |
|
116 |
|
117 typedef struct { |
|
118 int checks; |
|
119 int errors; |
|
120 } Dwarf_Check_Result; |
|
121 |
|
122 extern int verbose; |
|
123 extern boolean dense; |
|
124 extern boolean ellipsis; |
|
125 extern boolean dst_format; |
|
126 extern boolean use_mips_regnames; |
|
127 extern boolean show_global_offsets; |
|
128 |
|
129 extern boolean check_pubname_attr; |
|
130 extern boolean check_attr_tag; |
|
131 extern boolean check_tag_tree; |
|
132 extern boolean check_type_offset; |
|
133 |
|
134 extern Dwarf_Check_Result abbrev_code_result; |
|
135 extern Dwarf_Check_Result pubname_attr_result; |
|
136 extern Dwarf_Check_Result reloc_offset_result; |
|
137 extern Dwarf_Check_Result attr_tag_result; |
|
138 extern Dwarf_Check_Result tag_tree_result; |
|
139 extern Dwarf_Check_Result type_offset_result; |
|
140 |
|
141 extern boolean info_flag; |
|
142 extern boolean use_old_dwarf_loclist; |
|
143 |
|
144 extern char cu_name[ ]; |
|
145 extern boolean cu_name_flag; |
|
146 extern Dwarf_Unsigned cu_offset; |
|
147 extern Dwarf_Off fde_offset_for_cu_low; |
|
148 extern Dwarf_Off fde_offset_for_cu_high; |
|
149 |
|
150 |
|
151 extern int check_error; |
|
152 extern Dwarf_Error err; |
|
153 extern void print_error (Dwarf_Debug dbg, string msg,int res, Dwarf_Error err); |
|
154 |
|
155 extern void print_line_numbers_this_cu (Dwarf_Debug dbg, Dwarf_Die in_die); |
|
156 struct dwconf_s; |
|
157 extern void print_frames (Dwarf_Debug dbg, int print_debug_frame, |
|
158 int print_eh_frame,struct dwconf_s *); |
|
159 extern void print_pubnames (Dwarf_Debug dbg); |
|
160 extern void print_macinfo (Dwarf_Debug dbg); |
|
161 extern void print_locs (Dwarf_Debug dbg); |
|
162 extern void print_abbrevs (Dwarf_Debug dbg); |
|
163 extern void print_strings (Dwarf_Debug dbg); |
|
164 extern void print_aranges (Dwarf_Debug dbg); |
|
165 extern void print_relocinfo (Dwarf_Debug dbg); |
|
166 extern void print_static_funcs(Dwarf_Debug dbg); |
|
167 extern void print_static_vars(Dwarf_Debug dbg); |
|
168 enum type_type_e {SGI_TYPENAME, DWARF_PUBTYPES} ; |
|
169 extern void print_types(Dwarf_Debug dbg,enum type_type_e type_type); |
|
170 extern void print_weaknames(Dwarf_Debug dbg); |
|
171 extern void print_exception_tables(Dwarf_Debug dbg); |
|
172 extern string get_fde_proc_name(Dwarf_Debug dbg, Dwarf_Addr low_pc); |
|
173 extern void print_die_and_children( |
|
174 Dwarf_Debug dbg, |
|
175 Dwarf_Die in_die, |
|
176 char **srcfiles, |
|
177 Dwarf_Signed cnt); |
|
178 extern void print_one_die( |
|
179 Dwarf_Debug dbg, |
|
180 Dwarf_Die die, |
|
181 boolean print_information, |
|
182 char **srcfiles, |
|
183 Dwarf_Signed cnt); |
|
184 |
|
185 #define DWARF_CHECK_ERROR(str) {\ |
|
186 printf("*** DWARF CHECK: %s ***\n", str);\ |
|
187 check_error ++; \ |
|
188 } |
|
189 |
|
190 #define DWARF_CHECK_ERROR2(str1, str2) {\ |
|
191 printf("*** DWARF CHECK: %s: %s ***\n", str1, str2);\ |
|
192 check_error ++; \ |
|
193 } |
|
194 |
|
195 #define DWARF_CHECK_ERROR3(str1, str2,strexpl) {\ |
|
196 printf("*** DWARF CHECK: %s -> %s: %s ***\n", str1, str2,strexpl);\ |
|
197 check_error ++; \ |
|
198 } |
|
199 |
|
200 struct esb_s; |
|
201 extern Dwarf_Die current_cu_die_for_print_frames; /* This is |
|
202 an awful hack, making this public. But it enables |
|
203 cleaning up (doing all dealloc needed). */ |
|
204 extern void printreg(Dwarf_Signed reg,struct dwconf_s *config_data); |
|
205 extern void print_frame_inst_bytes(Dwarf_Debug dbg, |
|
206 Dwarf_Ptr cie_init_inst, Dwarf_Signed len, |
|
207 Dwarf_Signed data_alignment_factor, |
|
208 int code_alignment_factor, Dwarf_Half addr_size, |
|
209 struct dwconf_s *config_data); |
|
210 |
|
211 |
|
212 extern Dwarf_Unsigned local_dwarf_decode_u_leb128(unsigned char *leb128, |
|
213 unsigned int *leb128_length); |
|
214 |
|
215 extern Dwarf_Signed local_dwarf_decode_s_leb128(unsigned char *leb128, |
|
216 unsigned int *leb128_length); |
|
217 |
|
218 extern void dump_block(char *prefix, char *data, Dwarf_Signed len); |
|
219 |
|
220 int |
|
221 dwarfdump_print_one_locdesc(Dwarf_Debug dbg, |
|
222 Dwarf_Locdesc * llbuf, |
|
223 int skip_locdesc_header, |
|
224 struct esb_s *string_out); |
|
225 void clean_up_die_esb(); |
|
226 void clean_up_syms_malloc_data(); |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 #endif /* globals_INCLUDED */ |