| 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 |
| 50 |
DWARF5 DW_LKIND_loclists */ |
| 51 |
|
| 52 |
int |
| 53 |
print_debug_loclists_linecodes(Dwarf_Bool checking, |
| 54 |
const char * tagname, |
| 55 |
const char *attrname, |
| 56 |
unsigned int llent, |
| 57 |
Dwarf_Small lle_value, |
| 58 |
Dwarf_Unsigned lle_byte_count, |
| 59 |
Dwarf_Addr base_address, |
| 60 |
Dwarf_Addr rawlopc, |
| 61 |
Dwarf_Addr rawhipc, |
| 62 |
Dwarf_Bool debug_addr_unavailable, |
| 63 |
Dwarf_Addr lopc, |
| 64 |
Dwarf_Addr hipc, |
| 65 |
Dwarf_Unsigned locdesc_offset, |
| 66 |
struct esb_s * esbp, |
| 67 |
Dwarf_Bool * bError) |
| 68 |
{ |
| 69 |
/* Once most committed FIXME remove this and let |
| 70 |
lenght print */ |
| 71 |
(void)lle_byte_count; |
| 72 |
if (debug_addr_unavailable) { |
| 73 |
*bError = TRUE; |
| 74 |
} |
| 75 |
switch(lle_value) { |
| 76 |
case DW_LLE_base_address: |
| 77 |
/* debug_addr_unavailable is not applicable here. */ |
| 78 |
esb_append_printf_u(esbp, |
| 79 |
"<new base address 0x%" |
| 80 |
DW_PR_XZEROS DW_PR_DUx |
| 81 |
">", lopc); |
| 82 |
/* ASSERT: *lopc = rawlopc */ |
| 83 |
break; |
| 84 |
case DW_LLE_base_addressx: |
| 85 |
if (debug_addr_unavailable) { |
| 86 |
esb_append_printf_u(esbp, |
| 87 |
"<DW_LLE_base_addressx 0x%" |
| 88 |
DW_PR_XZEROS DW_PR_DUx |
| 89 |
" no .debug_addr found>",rawlopc); |
| 90 |
} else { |
| 91 |
if (glflags.verbose) { |
| 92 |
esb_append_printf_u(esbp, |
| 93 |
"<DW_LLE_base_addressx 0x%" |
| 94 |
DW_PR_XZEROS DW_PR_DUx ,rawlopc); |
| 95 |
esb_append_printf_i(esbp, "\n [%2d]",llent); |
| 96 |
} |
| 97 |
esb_append_printf_u(esbp, |
| 98 |
"<new base address 0x%" |
| 99 |
DW_PR_XZEROS DW_PR_DUx |
| 100 |
">", lopc); |
| 101 |
} |
| 102 |
break; |
| 103 |
case DW_LLE_end_of_list: |
| 104 |
/* Nothing to do. */ |
| 105 |
esb_append(esbp,"<end-of-list>"); |
| 106 |
break; |
| 107 |
case DW_LLE_start_length: |
| 108 |
if (glflags.verbose) { |
| 109 |
esb_append_printf_u(esbp, |
| 110 |
"<DW_LLE_start_length 0x%" |
| 111 |
DW_PR_XZEROS DW_PR_DUx ,rawlopc); |
| 112 |
esb_append_printf_u(esbp, |
| 113 |
" 0x%" |
| 114 |
DW_PR_XZEROS DW_PR_DUx ,rawhipc); |
| 115 |
esb_append_printf_i(esbp, "\n [%2d]",llent); |
| 116 |
} |
| 117 |
esb_append_printf_u(esbp, |
| 118 |
"<start,end 0x%" |
| 119 |
DW_PR_XZEROS DW_PR_DUx ,lopc); |
| 120 |
esb_append_printf_u(esbp, |
| 121 |
" 0x%" |
| 122 |
DW_PR_XZEROS DW_PR_DUx |
| 123 |
">",hipc); |
| 124 |
if (checking && !debug_addr_unavailable) { |
| 125 |
loc_error_check(tagname,attrname, |
| 126 |
lopc, rawlopc, |
| 127 |
hipc, rawhipc, locdesc_offset, base_address, |
| 128 |
bError); |
| 129 |
} |
| 130 |
break; |
| 131 |
case DW_LLE_startx_length: |
| 132 |
if (debug_addr_unavailable) { |
| 133 |
esb_append_printf_u(esbp, |
| 134 |
"<DW_LLE_startx_length 0x%" |
| 135 |
DW_PR_XZEROS DW_PR_DUx |
| 136 |
,rawlopc); |
| 137 |
esb_append_printf_u(esbp, |
| 138 |
" 0x%" |
| 139 |
DW_PR_XZEROS DW_PR_DUx |
| 140 |
" no .debug_addr found>",rawhipc); |
| 141 |
} else { |
| 142 |
if (glflags.verbose) { |
| 143 |
esb_append_printf_u(esbp, |
| 144 |
"<DW_LLE_startx_length 0x%" |
| 145 |
DW_PR_XZEROS DW_PR_DUx |
| 146 |
,rawlopc); |
| 147 |
esb_append_printf_u(esbp, |
| 148 |
" 0x%" |
| 149 |
DW_PR_XZEROS DW_PR_DUx |
| 150 |
">",rawhipc); |
| 151 |
esb_append_printf_i(esbp, "\n [%2d]",llent); |
| 152 |
} |
| 153 |
esb_append_printf_u(esbp, |
| 154 |
"<start,end 0x%" |
| 155 |
DW_PR_XZEROS DW_PR_DUx,lopc); |
| 156 |
esb_append_printf_u(esbp, |
| 157 |
" 0x%" |
| 158 |
DW_PR_XZEROS DW_PR_DUx |
| 159 |
">",hipc); |
| 160 |
} |
| 161 |
if (checking && !debug_addr_unavailable) { |
| 162 |
loc_error_check(tagname,attrname, |
| 163 |
lopc, rawlopc, |
| 164 |
hipc, rawhipc, locdesc_offset, base_address, |
| 165 |
bError); |
| 166 |
} |
| 167 |
break; |
| 168 |
case DW_LLE_offset_pair: |
| 169 |
/* debug_addr_unavailable does apply becase |
| 170 |
that might cause base address to be invalid. */ |
| 171 |
if (debug_addr_unavailable) { |
| 172 |
esb_append_printf_u(esbp, |
| 173 |
"<DW_LLE_offset_pair 0x%" |
| 174 |
DW_PR_XZEROS DW_PR_DUx |
| 175 |
,rawlopc); |
| 176 |
esb_append_printf_u(esbp, |
| 177 |
" 0x%" |
| 178 |
DW_PR_XZEROS DW_PR_DUx |
| 179 |
" no .debug_addr found>",rawhipc); |
| 180 |
} else { |
| 181 |
if (glflags.verbose) { |
| 182 |
esb_append_printf_u(esbp, |
| 183 |
"<DW_LLE_offset_pair 0x%" |
| 184 |
DW_PR_XZEROS DW_PR_DUx |
| 185 |
,rawlopc); |
| 186 |
esb_append_printf_u(esbp, |
| 187 |
" 0x%" |
| 188 |
DW_PR_XZEROS DW_PR_DUx |
| 189 |
">",rawhipc); |
| 190 |
esb_append_printf_i(esbp, "\n [%2d]",llent); |
| 191 |
} |
| 192 |
esb_append_printf_u(esbp, |
| 193 |
"<start,end 0x%" |
| 194 |
DW_PR_XZEROS DW_PR_DUx,lopc); |
| 195 |
esb_append_printf_u(esbp, |
| 196 |
" 0x%" |
| 197 |
DW_PR_XZEROS DW_PR_DUx |
| 198 |
">",hipc); |
| 199 |
} |
| 200 |
if (checking && !debug_addr_unavailable) { |
| 201 |
loc_error_check(tagname,attrname, |
| 202 |
lopc, rawlopc, |
| 203 |
hipc, rawhipc, locdesc_offset, base_address, |
| 204 |
bError); |
| 205 |
} |
| 206 |
break; |
| 207 |
case DW_LLE_start_end: |
| 208 |
/* debug_addr_unavailable does not apply here */ |
| 209 |
esb_append_printf_u(esbp, |
| 210 |
"<start,end 0x%" |
| 211 |
DW_PR_XZEROS DW_PR_DUx,lopc); |
| 212 |
esb_append_printf_u(esbp, |
| 213 |
" 0x%" |
| 214 |
DW_PR_XZEROS DW_PR_DUx |
| 215 |
">",hipc); |
| 216 |
if (checking && !debug_addr_unavailable) { |
| 217 |
loc_error_check(tagname,attrname, |
| 218 |
lopc, rawlopc, |
| 219 |
hipc, rawhipc, locdesc_offset, base_address, |
| 220 |
bError); |
| 221 |
} |
| 222 |
break; |
| 223 |
case DW_LLE_startx_endx: |
| 224 |
if (debug_addr_unavailable) { |
| 225 |
esb_append_printf_u(esbp, |
| 226 |
"<DW_LLE_startx_endx 0x%" |
| 227 |
DW_PR_XZEROS DW_PR_DUx |
| 228 |
,rawlopc); |
| 229 |
esb_append_printf_u(esbp, |
| 230 |
" 0x%" |
| 231 |
DW_PR_XZEROS DW_PR_DUx |
| 232 |
" no .debug_addr found>",rawhipc); |
| 233 |
} else { |
| 234 |
if (glflags.verbose) { |
| 235 |
esb_append_printf_u(esbp, |
| 236 |
"<DW_LLE_startx_endx 0x%" |
| 237 |
DW_PR_XZEROS DW_PR_DUx |
| 238 |
,rawlopc); |
| 239 |
esb_append_printf_u(esbp, |
| 240 |
" 0x%" |
| 241 |
DW_PR_XZEROS DW_PR_DUx |
| 242 |
">",rawhipc); |
| 243 |
esb_append_printf_i(esbp, "\n [%2d]",llent); |
| 244 |
} |
| 245 |
esb_append_printf_u(esbp, |
| 246 |
"<start,end 0x%" |
| 247 |
DW_PR_XZEROS DW_PR_DUx,lopc); |
| 248 |
esb_append_printf_u(esbp, |
| 249 |
" 0x%" |
| 250 |
DW_PR_XZEROS DW_PR_DUx |
| 251 |
">",hipc); |
| 252 |
} |
| 253 |
if (checking && !debug_addr_unavailable) { |
| 254 |
loc_error_check(tagname,attrname, |
| 255 |
lopc, rawlopc, |
| 256 |
hipc, rawhipc, locdesc_offset, base_address, |
| 257 |
bError); |
| 258 |
} |
| 259 |
break; |
| 260 |
default: { |
| 261 |
struct esb_s unexp; |
| 262 |
|
| 263 |
esb_constructor(&unexp); |
| 264 |
esb_append_printf_u(&unexp, |
| 265 |
"ERROR: Unexpected LLE code 0x%x", |
| 266 |
lle_value); |
| 267 |
print_error_and_continue( |
| 268 |
esb_get_string(&unexp), |
| 269 |
DW_DLV_OK, 0); |
| 270 |
esb_destructor(&unexp); |
| 271 |
} |
| 272 |
break; |
| 273 |
} |
| 274 |
#if 0 |
| 275 |
esb_append_printf_u(esbp," length: %u",lle_byte_count); |
| 276 |
#endif |
| 277 |
return DW_DLV_OK; |
| 278 |
} |