Debian Codegraph @

src/bin/dwarfdump/print_llex_codes.c

raw
1 /*
2 Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
3 Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
4 Portions Copyright 2009-2018 SN Systems Ltd. All rights reserved.
5 Portions Copyright 2007-2020 David Anderson. All rights reserved.
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of version 2 of the GNU General
9 Public License as published by the Free Software Foundation.
10
11 This program is distributed in the hope that it would be
12 useful, but WITHOUT ANY WARRANTY; without even the implied
13 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE.
15
16 Further, this software is distributed without any warranty
17 that it is free of the rightful claim of any third person
18 regarding infringement or the like. Any license provided
19 herein, whether implied or otherwise, applies only to this
20 software file. Patent licenses, if any, provided herein
21 do not apply to combinations of this program with other
22 software, or any other product whatsoever.
23
24 You should have received a copy of the GNU General Public
25 License along with this program; if not, write the Free
26 Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
27 Boston MA 02110-1301, USA.
28 */
29
30 /* SGI has moved from the Crittenden Lane address. */
31
32 #include <config.h>
33 #include <stdio.h> /* FILE decl for dd_esb.h, printf etc */
34
35 #include "dwarf.h"
36 #include "libdwarf.h"
37 #include "libdwarf_private.h"
38 #include "dd_defined_types.h"
39 #include "dd_checkutil.h"
40 #include "dd_glflags.h"
41 #include "dd_globals.h"
42 #include "dd_naming.h"
43 #include "dd_esb.h" /* For flexible string buffer. */
44 #include "dd_esb_using_functions.h"
45 #include "dd_sanitized.h"
46 #include "dd_helpertree.h"
47 #include "dd_tag_common.h"
48
49 /* Prints locentry descriptions for DW_LKIND_GNU_exp_list */
50
51 int
52 print_llex_linecodes(
53 Dwarf_Bool checking,
54 const char * tagname,
55 const char * attrname,
56 unsigned int llent,
57 Dwarf_Small lle_value,
58 Dwarf_Addr base_address,
59 Dwarf_Addr rawlopc,
60 Dwarf_Addr rawhipc,
61 Dwarf_Bool debug_addr_unavailable,
62 Dwarf_Addr lopc,
63 Dwarf_Addr hipc,
64 Dwarf_Unsigned locdesc_offset,
65 struct esb_s * esbp,
66 Dwarf_Bool * bError)
67 {
68 if (debug_addr_unavailable) {
69 *bError = TRUE;
70 }
71 switch(lle_value) {
72 case DW_LLEX_base_address_selection_entry:
73 if (debug_addr_unavailable) {
74 esb_append_printf_u(esbp,
75 "<DW_LLEX_base_address_selection_entry : 0x%"
76 DW_PR_XZEROS DW_PR_DUx
77 " .debug_addr not available>",rawhipc);
78 } else {
79 if (glflags.verbose) {
80 esb_append_printf_u(esbp,
81 "<index to debug_addr : 0x%"
82 DW_PR_XZEROS DW_PR_DUx ">",
83 rawhipc);
84 esb_append_printf_i(esbp, "\n [%2d]",llent);
85 }
86 esb_append_printf_u(esbp,
87 "< new base address 0x%"
88 DW_PR_XZEROS DW_PR_DUx
89 ">", hipc);
90 }
91 break;
92 case DW_LLEX_end_of_list_entry:
93 /* Nothing to do. */
94 esb_append(esbp,"<end-of-list>");
95 break;
96 case DW_LLEX_start_length_entry:
97 if (debug_addr_unavailable) {
98 esb_append_printf_u(esbp,
99 "<DW_LLEX_start_lenth_entry : 0x%"
100 DW_PR_XZEROS DW_PR_DUx
101 " .debug_addr not available>",rawlopc);
102 esb_append_printf_u(esbp,
103 "< length : 0x%"
104 DW_PR_XZEROS DW_PR_DUx ">",rawhipc);
105 } else {
106 if (glflags.verbose) {
107 esb_append_printf_u(esbp,
108 "<start index to debug_addr : 0x%"
109 DW_PR_XZEROS DW_PR_DUx
110 ,rawlopc);
111 esb_append_printf_u(esbp,
112 " length: 0x%"
113 DW_PR_XZEROS DW_PR_DUx
114 ">",rawhipc);
115 esb_append_printf_i(esbp, "\n [%2d]",llent);
116 }
117 esb_append_printf_u(esbp,
118 "< start-addr 0x%"
119 DW_PR_XZEROS DW_PR_DUx ,
120 lopc);
121 esb_append_printf_u(esbp,
122 " endaddr 0x%"
123 DW_PR_XZEROS DW_PR_DUx
124 ">",hipc);
125 }
126 if (checking && !debug_addr_unavailable) {
127 loc_error_check(
128 tagname,attrname,
129 lopc,
130 rawlopc,
131 hipc, rawhipc, locdesc_offset,
132 base_address,
133 bError);
134 }
135 break;
136 case DW_LLEX_offset_pair_entry:
137 if (debug_addr_unavailable) {
138 esb_append_printf_u(esbp,
139 "<DW_LLEX_offset_pair_entry : 0x%"
140 DW_PR_XZEROS DW_PR_DUx,rawlopc);
141 esb_append_printf_u(esbp,
142 " 0x%"
143 DW_PR_XZEROS DW_PR_DUx
144 " no .debug_addr available>",rawhipc);
145 } else {
146 if (glflags.verbose) {
147 esb_append_printf_u(esbp,
148 "< offset pair low-off : 0x%"
149 DW_PR_XZEROS DW_PR_DUx,rawlopc);
150 esb_append_printf_u(esbp,
151 " high-off 0x%"
152 DW_PR_XZEROS DW_PR_DUx ">",rawhipc);
153 esb_append_printf_i(esbp, "\n [%2d]",llent);
154 }
155 esb_append_printf_u(esbp,
156 "< loaddr 0x%"
157 DW_PR_XZEROS DW_PR_DUx,lopc);
158 esb_append_printf_u(esbp,
159 " hiaddr 0x%"
160 DW_PR_XZEROS DW_PR_DUx
161 ">",hipc);
162 }
163 if (checking && !debug_addr_unavailable) {
164 loc_error_check(
165 tagname,attrname,
166 lopc,
167 rawlopc,
168 hipc, rawhipc, locdesc_offset,
169 base_address,
170 bError);
171 }
172 break;
173 case DW_LLEX_start_end_entry:
174 if (debug_addr_unavailable) {
175 esb_append_printf_u(esbp,
176 "<DW_LLEX_start_end_entry : 0x%"
177 DW_PR_XZEROS DW_PR_DUx,rawlopc);
178 esb_append_printf_u(esbp,
179 " high-index 0x%"
180 DW_PR_XZEROS DW_PR_DUx
181 " .debug_addr not available>",hipc);
182 } else {
183 if (glflags.verbose) {
184 esb_append_printf_u(esbp,
185 "<DW_LLEX_start_end_entry : 0x%"
186 DW_PR_XZEROS DW_PR_DUx,rawlopc);
187 esb_append_printf_u(esbp,
188 " 0x%"
189 DW_PR_XZEROS DW_PR_DUx
190 " .debug_addr not available>",rawhipc);
191 esb_append_printf_i(esbp, "\n [%2d]",llent);
192 }
193 esb_append_printf_u(esbp,
194 "< lowaddr : 0x%"
195 DW_PR_XZEROS DW_PR_DUx,lopc);
196 esb_append_printf_u(esbp,
197 " highaddr 0x%"
198 DW_PR_XZEROS DW_PR_DUx
199 ">",hipc);
200
201 }
202 if (checking && !debug_addr_unavailable) {
203 loc_error_check(
204 tagname,attrname,
205 lopc,
206 rawlopc,
207 hipc, rawhipc, locdesc_offset,
208 base_address,
209 bError);
210 }
211 break;
212 default: {
213 struct esb_s unexp;
214
215 esb_constructor(&unexp);
216 esb_append_printf_u(&unexp,
217 "ERROR: Unexpected LLEX code 0x%x",
218 lle_value);
219 print_error_and_continue(esb_get_string(&unexp),
220 DW_DLV_OK, 0);
221 esb_destructor(&unexp);
222 *bError = TRUE;
223 }
224 break;
225 }
226 return DW_DLV_OK;
227 }