| 1 | /* Convert a DWARF location expression to C |
| 2 | |
| 3 | Copyright (C) 2014-2020 Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of GDB. |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | #include "defs.h" |
| 21 | #include "dwarf2.h" |
| 22 | #include "dwarf2/expr.h" |
| 23 | #include "dwarf2/loc.h" |
| 24 | #include "dwarf2/read.h" |
| 25 | #include "ui-file.h" |
| 26 | #include "utils.h" |
| 27 | #include "compile-internal.h" |
| 28 | #include "compile-c.h" |
| 29 | #include "compile.h" |
| 30 | #include "block.h" |
| 31 | #include "dwarf2/frame.h" |
| 32 | #include "gdbsupport/gdb_vecs.h" |
| 33 | #include "value.h" |
| 34 | #include "gdbarch.h" |
| 35 | |
| 36 | \f |
| 37 | |
| 38 | /* Information about a given instruction. */ |
| 39 | |
| 40 | struct insn_info |
| 41 | { |
| 42 | /* Stack depth at entry. */ |
| 43 | |
| 44 | unsigned int depth; |
| 45 | |
| 46 | /* Whether this instruction has been visited. */ |
| 47 | |
| 48 | unsigned int visited : 1; |
| 49 | |
| 50 | /* Whether this instruction needs a label. */ |
| 51 | |
| 52 | unsigned int label : 1; |
| 53 | |
| 54 | /* Whether this instruction is DW_OP_GNU_push_tls_address or |
| 55 | DW_OP_form_tls_address. This is a hack until we can add a |
| 56 | feature to glibc to let us properly generate code for TLS. */ |
| 57 | |
| 58 | unsigned int is_tls : 1; |
| 59 | }; |
| 60 | |
| 61 | /* A helper function for compute_stack_depth that does the work. This |
| 62 | examines the DWARF expression starting from START and computes |
| 63 | stack effects. |
| 64 | |
| 65 | NEED_TEMPVAR is an out parameter which is set if this expression |
| 66 | needs a special temporary variable to be emitted (see the code |
| 67 | generator). |
| 68 | INFO is a vector of insn_info objects, indexed by offset from the |
| 69 | start of the DWARF expression. |
| 70 | TO_DO is a list of bytecodes which must be examined; it may be |
| 71 | added to by this function. |
| 72 | BYTE_ORDER and ADDR_SIZE describe this bytecode in the obvious way. |
| 73 | OP_PTR and OP_END are the bounds of the DWARF expression. */ |
| 74 | |
| 75 | static void |
| 76 | compute_stack_depth_worker (int start, int *need_tempvar, |
| 77 | std::vector<struct insn_info> *info, |
| 78 | std::vector<int> *to_do, |
| 79 | enum bfd_endian byte_order, unsigned int addr_size, |
| 80 | const gdb_byte *op_ptr, const gdb_byte *op_end) |
| 81 | { |
| 82 | const gdb_byte * const base = op_ptr; |
| 83 | int stack_depth; |
| 84 | |
| 85 | op_ptr += start; |
| 86 | gdb_assert ((*info)[start].visited); |
| 87 | stack_depth = (*info)[start].depth; |
| 88 | |
| 89 | while (op_ptr < op_end) |
| 90 | { |
| 91 | enum dwarf_location_atom op = (enum dwarf_location_atom) *op_ptr; |
| 92 | uint64_t reg; |
| 93 | int64_t offset; |
| 94 | int ndx = op_ptr - base; |
| 95 | |
| 96 | #define SET_CHECK_DEPTH(WHERE) \ |
| 97 | if ((*info)[WHERE].visited) \ |
| 98 | { \ |
| 99 | if ((*info)[WHERE].depth != stack_depth) \ |
| 100 | error (_("inconsistent stack depths")); \ |
| 101 | } \ |
| 102 | else \ |
| 103 | { \ |
| 104 | /* Stack depth not set, so set it. */ \ |
| 105 | (*info)[WHERE].visited = 1; \ |
| 106 | (*info)[WHERE].depth = stack_depth; \ |
| 107 | } |
| 108 | |
| 109 | SET_CHECK_DEPTH (ndx); |
| 110 | |
| 111 | ++op_ptr; |
| 112 | |
| 113 | switch (op) |
| 114 | { |
| 115 | case DW_OP_lit0: |
| 116 | case DW_OP_lit1: |
| 117 | case DW_OP_lit2: |
| 118 | case DW_OP_lit3: |
| 119 | case DW_OP_lit4: |
| 120 | case DW_OP_lit5: |
| 121 | case DW_OP_lit6: |
| 122 | case DW_OP_lit7: |
| 123 | case DW_OP_lit8: |
| 124 | case DW_OP_lit9: |
| 125 | case DW_OP_lit10: |
| 126 | case DW_OP_lit11: |
| 127 | case DW_OP_lit12: |
| 128 | case DW_OP_lit13: |
| 129 | case DW_OP_lit14: |
| 130 | case DW_OP_lit15: |
| 131 | case DW_OP_lit16: |
| 132 | case DW_OP_lit17: |
| 133 | case DW_OP_lit18: |
| 134 | case DW_OP_lit19: |
| 135 | case DW_OP_lit20: |
| 136 | case DW_OP_lit21: |
| 137 | case DW_OP_lit22: |
| 138 | case DW_OP_lit23: |
| 139 | case DW_OP_lit24: |
| 140 | case DW_OP_lit25: |
| 141 | case DW_OP_lit26: |
| 142 | case DW_OP_lit27: |
| 143 | case DW_OP_lit28: |
| 144 | case DW_OP_lit29: |
| 145 | case DW_OP_lit30: |
| 146 | case DW_OP_lit31: |
| 147 | ++stack_depth; |
| 148 | break; |
| 149 | |
| 150 | case DW_OP_addr: |
| 151 | op_ptr += addr_size; |
| 152 | ++stack_depth; |
| 153 | break; |
| 154 | |
| 155 | case DW_OP_const1u: |
| 156 | case DW_OP_const1s: |
| 157 | op_ptr += 1; |
| 158 | ++stack_depth; |
| 159 | break; |
| 160 | case DW_OP_const2u: |
| 161 | case DW_OP_const2s: |
| 162 | op_ptr += 2; |
| 163 | ++stack_depth; |
| 164 | break; |
| 165 | case DW_OP_const4u: |
| 166 | case DW_OP_const4s: |
| 167 | op_ptr += 4; |
| 168 | ++stack_depth; |
| 169 | break; |
| 170 | case DW_OP_const8u: |
| 171 | case DW_OP_const8s: |
| 172 | op_ptr += 8; |
| 173 | ++stack_depth; |
| 174 | break; |
| 175 | case DW_OP_constu: |
| 176 | case DW_OP_consts: |
| 177 | op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); |
| 178 | ++stack_depth; |
| 179 | break; |
| 180 | |
| 181 | case DW_OP_reg0: |
| 182 | case DW_OP_reg1: |
| 183 | case DW_OP_reg2: |
| 184 | case DW_OP_reg3: |
| 185 | case DW_OP_reg4: |
| 186 | case DW_OP_reg5: |
| 187 | case DW_OP_reg6: |
| 188 | case DW_OP_reg7: |
| 189 | case DW_OP_reg8: |
| 190 | case DW_OP_reg9: |
| 191 | case DW_OP_reg10: |
| 192 | case DW_OP_reg11: |
| 193 | case DW_OP_reg12: |
| 194 | case DW_OP_reg13: |
| 195 | case DW_OP_reg14: |
| 196 | case DW_OP_reg15: |
| 197 | case DW_OP_reg16: |
| 198 | case DW_OP_reg17: |
| 199 | case DW_OP_reg18: |
| 200 | case DW_OP_reg19: |
| 201 | case DW_OP_reg20: |
| 202 | case DW_OP_reg21: |
| 203 | case DW_OP_reg22: |
| 204 | case DW_OP_reg23: |
| 205 | case DW_OP_reg24: |
| 206 | case DW_OP_reg25: |
| 207 | case DW_OP_reg26: |
| 208 | case DW_OP_reg27: |
| 209 | case DW_OP_reg28: |
| 210 | case DW_OP_reg29: |
| 211 | case DW_OP_reg30: |
| 212 | case DW_OP_reg31: |
| 213 | ++stack_depth; |
| 214 | break; |
| 215 | |
| 216 | case DW_OP_regx: |
| 217 | op_ptr = safe_read_uleb128 (op_ptr, op_end, ®); |
| 218 | ++stack_depth; |
| 219 | break; |
| 220 | |
| 221 | case DW_OP_breg0: |
| 222 | case DW_OP_breg1: |
| 223 | case DW_OP_breg2: |
| 224 | case DW_OP_breg3: |
| 225 | case DW_OP_breg4: |
| 226 | case DW_OP_breg5: |
| 227 | case DW_OP_breg6: |
| 228 | case DW_OP_breg7: |
| 229 | case DW_OP_breg8: |
| 230 | case DW_OP_breg9: |
| 231 | case DW_OP_breg10: |
| 232 | case DW_OP_breg11: |
| 233 | case DW_OP_breg12: |
| 234 | case DW_OP_breg13: |
| 235 | case DW_OP_breg14: |
| 236 | case DW_OP_breg15: |
| 237 | case DW_OP_breg16: |
| 238 | case DW_OP_breg17: |
| 239 | case DW_OP_breg18: |
| 240 | case DW_OP_breg19: |
| 241 | case DW_OP_breg20: |
| 242 | case DW_OP_breg21: |
| 243 | case DW_OP_breg22: |
| 244 | case DW_OP_breg23: |
| 245 | case DW_OP_breg24: |
| 246 | case DW_OP_breg25: |
| 247 | case DW_OP_breg26: |
| 248 | case DW_OP_breg27: |
| 249 | case DW_OP_breg28: |
| 250 | case DW_OP_breg29: |
| 251 | case DW_OP_breg30: |
| 252 | case DW_OP_breg31: |
| 253 | op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); |
| 254 | ++stack_depth; |
| 255 | break; |
| 256 | case DW_OP_bregx: |
| 257 | { |
| 258 | op_ptr = safe_read_uleb128 (op_ptr, op_end, ®); |
| 259 | op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); |
| 260 | ++stack_depth; |
| 261 | } |
| 262 | break; |
| 263 | case DW_OP_fbreg: |
| 264 | op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); |
| 265 | ++stack_depth; |
| 266 | break; |
| 267 | |
| 268 | case DW_OP_dup: |
| 269 | ++stack_depth; |
| 270 | break; |
| 271 | |
| 272 | case DW_OP_drop: |
| 273 | --stack_depth; |
| 274 | break; |
| 275 | |
| 276 | case DW_OP_pick: |
| 277 | ++op_ptr; |
| 278 | ++stack_depth; |
| 279 | break; |
| 280 | |
| 281 | case DW_OP_rot: |
| 282 | case DW_OP_swap: |
| 283 | *need_tempvar = 1; |
| 284 | break; |
| 285 | |
| 286 | case DW_OP_over: |
| 287 | ++stack_depth; |
| 288 | break; |
| 289 | |
| 290 | case DW_OP_abs: |
| 291 | case DW_OP_neg: |
| 292 | case DW_OP_not: |
| 293 | case DW_OP_deref: |
| 294 | break; |
| 295 | |
| 296 | case DW_OP_deref_size: |
| 297 | ++op_ptr; |
| 298 | break; |
| 299 | |
| 300 | case DW_OP_plus_uconst: |
| 301 | op_ptr = safe_read_uleb128 (op_ptr, op_end, ®); |
| 302 | break; |
| 303 | |
| 304 | case DW_OP_div: |
| 305 | case DW_OP_shra: |
| 306 | case DW_OP_and: |
| 307 | case DW_OP_minus: |
| 308 | case DW_OP_mod: |
| 309 | case DW_OP_mul: |
| 310 | case DW_OP_or: |
| 311 | case DW_OP_plus: |
| 312 | case DW_OP_shl: |
| 313 | case DW_OP_shr: |
| 314 | case DW_OP_xor: |
| 315 | case DW_OP_le: |
| 316 | case DW_OP_ge: |
| 317 | case DW_OP_eq: |
| 318 | case DW_OP_lt: |
| 319 | case DW_OP_gt: |
| 320 | case DW_OP_ne: |
| 321 | --stack_depth; |
| 322 | break; |
| 323 | |
| 324 | case DW_OP_call_frame_cfa: |
| 325 | ++stack_depth; |
| 326 | break; |
| 327 | |
| 328 | case DW_OP_GNU_push_tls_address: |
| 329 | case DW_OP_form_tls_address: |
| 330 | (*info)[ndx].is_tls = 1; |
| 331 | break; |
| 332 | |
| 333 | case DW_OP_skip: |
| 334 | offset = extract_signed_integer (op_ptr, 2, byte_order); |
| 335 | op_ptr += 2; |
| 336 | offset = op_ptr + offset - base; |
| 337 | /* If the destination has not been seen yet, add it to the |
| 338 | to-do list. */ |
| 339 | if (!(*info)[offset].visited) |
| 340 | to_do->push_back (offset); |
| 341 | SET_CHECK_DEPTH (offset); |
| 342 | (*info)[offset].label = 1; |
| 343 | /* We're done with this line of code. */ |
| 344 | return; |
| 345 | |
| 346 | case DW_OP_bra: |
| 347 | offset = extract_signed_integer (op_ptr, 2, byte_order); |
| 348 | op_ptr += 2; |
| 349 | offset = op_ptr + offset - base; |
| 350 | --stack_depth; |
| 351 | /* If the destination has not been seen yet, add it to the |
| 352 | to-do list. */ |
| 353 | if (!(*info)[offset].visited) |
| 354 | to_do->push_back (offset); |
| 355 | SET_CHECK_DEPTH (offset); |
| 356 | (*info)[offset].label = 1; |
| 357 | break; |
| 358 | |
| 359 | case DW_OP_nop: |
| 360 | break; |
| 361 | |
| 362 | default: |
| 363 | error (_("unhandled DWARF op: %s"), get_DW_OP_name (op)); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | gdb_assert (op_ptr == op_end); |
| 368 | |
| 369 | #undef SET_CHECK_DEPTH |
| 370 | } |
| 371 | |
| 372 | /* Compute the maximum needed stack depth of a DWARF expression, and |
| 373 | some other information as well. |
| 374 | |
| 375 | BYTE_ORDER and ADDR_SIZE describe this bytecode in the obvious way. |
| 376 | NEED_TEMPVAR is an out parameter which is set if this expression |
| 377 | needs a special temporary variable to be emitted (see the code |
| 378 | generator). |
| 379 | IS_TLS is an out parameter which is set if this expression refers |
| 380 | to a TLS variable. |
| 381 | OP_PTR and OP_END are the bounds of the DWARF expression. |
| 382 | INITIAL_DEPTH is the initial depth of the DWARF expression stack. |
| 383 | INFO is an array of insn_info objects, indexed by offset from the |
| 384 | start of the DWARF expression. |
| 385 | |
| 386 | This returns the maximum stack depth. */ |
| 387 | |
| 388 | static int |
| 389 | compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size, |
| 390 | int *need_tempvar, int *is_tls, |
| 391 | const gdb_byte *op_ptr, const gdb_byte *op_end, |
| 392 | int initial_depth, |
| 393 | std::vector<struct insn_info> *info) |
| 394 | { |
| 395 | std::vector<int> to_do; |
| 396 | int stack_depth, i; |
| 397 | |
| 398 | info->resize (op_end - op_ptr); |
| 399 | |
| 400 | to_do.push_back (0); |
| 401 | (*info)[0].depth = initial_depth; |
| 402 | (*info)[0].visited = 1; |
| 403 | |
| 404 | while (!to_do.empty ()) |
| 405 | { |
| 406 | int ndx = to_do.back (); |
| 407 | to_do.pop_back (); |
| 408 | |
| 409 | compute_stack_depth_worker (ndx, need_tempvar, info, &to_do, |
| 410 | byte_order, addr_size, |
| 411 | op_ptr, op_end); |
| 412 | } |
| 413 | |
| 414 | stack_depth = 0; |
| 415 | *is_tls = 0; |
| 416 | for (i = 0; i < op_end - op_ptr; ++i) |
| 417 | { |
| 418 | if ((*info)[i].depth > stack_depth) |
| 419 | stack_depth = (*info)[i].depth; |
| 420 | if ((*info)[i].is_tls) |
| 421 | *is_tls = 1; |
| 422 | } |
| 423 | |
| 424 | return stack_depth + 1; |
| 425 | } |
| 426 | |
| 427 | \f |
| 428 | |
| 429 | #define GCC_UINTPTR "__gdb_uintptr" |
| 430 | #define GCC_INTPTR "__gdb_intptr" |
| 431 | |
| 432 | /* Emit code to push a constant. */ |
| 433 | |
| 434 | static void |
| 435 | push (int indent, string_file *stream, ULONGEST l) |
| 436 | { |
| 437 | fprintfi_filtered (indent, stream, |
| 438 | "__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n", |
| 439 | hex_string (l)); |
| 440 | } |
| 441 | |
| 442 | /* Emit code to push an arbitrary expression. This works like |
| 443 | printf. */ |
| 444 | |
| 445 | static void pushf (int indent, string_file *stream, const char *format, ...) |
| 446 | ATTRIBUTE_PRINTF (3, 4); |
| 447 | |
| 448 | static void |
| 449 | pushf (int indent, string_file *stream, const char *format, ...) |
| 450 | { |
| 451 | va_list args; |
| 452 | |
| 453 | fprintfi_filtered (indent, stream, "__gdb_stack[__gdb_tos + 1] = "); |
| 454 | va_start (args, format); |
| 455 | stream->vprintf (format, args); |
| 456 | va_end (args); |
| 457 | stream->puts (";\n"); |
| 458 | |
| 459 | fprintfi_filtered (indent, stream, "++__gdb_tos;\n"); |
| 460 | } |
| 461 | |
| 462 | /* Emit code for a unary expression -- one which operates in-place on |
| 463 | the top-of-stack. This works like printf. */ |
| 464 | |
| 465 | static void unary (int indent, string_file *stream, const char *format, ...) |
| 466 | ATTRIBUTE_PRINTF (3, 4); |
| 467 | |
| 468 | static void |
| 469 | unary (int indent, string_file *stream, const char *format, ...) |
| 470 | { |
| 471 | va_list args; |
| 472 | |
| 473 | fprintfi_filtered (indent, stream, "__gdb_stack[__gdb_tos] = "); |
| 474 | va_start (args, format); |
| 475 | stream->vprintf (format, args); |
| 476 | va_end (args); |
| 477 | stream->puts (";\n"); |
| 478 | } |
| 479 | |
| 480 | /* Emit code for a unary expression -- one which uses the top two |
| 481 | stack items, popping the topmost one. This works like printf. */ |
| 482 | static void binary (int indent, string_file *stream, const char *format, ...) |
| 483 | ATTRIBUTE_PRINTF (3, 4); |
| 484 | |
| 485 | static void |
| 486 | binary (int indent, string_file *stream, const char *format, ...) |
| 487 | { |
| 488 | va_list args; |
| 489 | |
| 490 | fprintfi_filtered (indent, stream, "__gdb_stack[__gdb_tos - 1] = "); |
| 491 | va_start (args, format); |
| 492 | stream->vprintf (format, args); |
| 493 | va_end (args); |
| 494 | stream->puts (";\n"); |
| 495 | fprintfi_filtered (indent, stream, "--__gdb_tos;\n"); |
| 496 | } |
| 497 | |
| 498 | /* Print the name of a label given its "SCOPE", an arbitrary integer |
| 499 | used for uniqueness, and its TARGET, the bytecode offset |
| 500 | corresponding to the label's point of definition. */ |
| 501 | |
| 502 | static void |
| 503 | print_label (string_file *stream, unsigned int scope, int target) |
| 504 | { |
| 505 | stream->printf ("__label_%u_%s", scope, pulongest (target)); |
| 506 | } |
| 507 | |
| 508 | /* Emit code that pushes a register's address on the stack. |
| 509 | REGISTERS_USED is an out parameter which is updated to note which |
| 510 | register was needed by this expression. */ |
| 511 | |
| 512 | static void |
| 513 | pushf_register_address (int indent, string_file *stream, |
| 514 | unsigned char *registers_used, |
| 515 | struct gdbarch *gdbarch, int regnum) |
| 516 | { |
| 517 | std::string regname = compile_register_name_mangled (gdbarch, regnum); |
| 518 | |
| 519 | registers_used[regnum] = 1; |
| 520 | pushf (indent, stream, |
| 521 | "(" GCC_UINTPTR ") &" COMPILE_I_SIMPLE_REGISTER_ARG_NAME "->%s", |
| 522 | regname.c_str ()); |
| 523 | } |
| 524 | |
| 525 | /* Emit code that pushes a register's value on the stack. |
| 526 | REGISTERS_USED is an out parameter which is updated to note which |
| 527 | register was needed by this expression. OFFSET is added to the |
| 528 | register's value before it is pushed. */ |
| 529 | |
| 530 | static void |
| 531 | pushf_register (int indent, string_file *stream, |
| 532 | unsigned char *registers_used, |
| 533 | struct gdbarch *gdbarch, int regnum, uint64_t offset) |
| 534 | { |
| 535 | std::string regname = compile_register_name_mangled (gdbarch, regnum); |
| 536 | |
| 537 | registers_used[regnum] = 1; |
| 538 | if (offset == 0) |
| 539 | pushf (indent, stream, COMPILE_I_SIMPLE_REGISTER_ARG_NAME "->%s", |
| 540 | regname.c_str ()); |
| 541 | else |
| 542 | pushf (indent, stream, |
| 543 | COMPILE_I_SIMPLE_REGISTER_ARG_NAME "->%s + (" GCC_UINTPTR ") %s", |
| 544 | regname.c_str (), hex_string (offset)); |
| 545 | } |
| 546 | |
| 547 | /* Compile a DWARF expression to C code. |
| 548 | |
| 549 | INDENT is the indentation level to use. |
| 550 | STREAM is the stream where the code should be written. |
| 551 | |
| 552 | TYPE_NAME names the type of the result of the DWARF expression. |
| 553 | For locations this is "void *" but for array bounds it will be an |
| 554 | integer type. |
| 555 | |
| 556 | RESULT_NAME is the name of a variable in the resulting C code. The |
| 557 | result of the expression will be assigned to this variable. |
| 558 | |
| 559 | SYM is the symbol corresponding to this expression. |
| 560 | PC is the location at which the expression is being evaluated. |
| 561 | ARCH is the architecture to use. |
| 562 | |
| 563 | REGISTERS_USED is an out parameter which is updated to note which |
| 564 | registers were needed by this expression. |
| 565 | |
| 566 | ADDR_SIZE is the DWARF address size to use. |
| 567 | |
| 568 | OPT_PTR and OP_END are the bounds of the DWARF expression. |
| 569 | |
| 570 | If non-NULL, INITIAL points to an initial value to write to the |
| 571 | stack. If NULL, no initial value is written. |
| 572 | |
| 573 | PER_CU is the per-CU object used for looking up various other |
| 574 | things. */ |
| 575 | |
| 576 | static void |
| 577 | do_compile_dwarf_expr_to_c (int indent, string_file *stream, |
| 578 | const char *type_name, |
| 579 | const char *result_name, |
| 580 | struct symbol *sym, CORE_ADDR pc, |
| 581 | struct gdbarch *arch, |
| 582 | unsigned char *registers_used, |
| 583 | unsigned int addr_size, |
| 584 | const gdb_byte *op_ptr, const gdb_byte *op_end, |
| 585 | CORE_ADDR *initial, |
| 586 | struct dwarf2_per_cu_data *per_cu) |
| 587 | { |
| 588 | /* We keep a counter so that labels and other objects we create have |
| 589 | unique names. */ |
| 590 | static unsigned int scope; |
| 591 | |
| 592 | enum bfd_endian byte_order = gdbarch_byte_order (arch); |
| 593 | const gdb_byte * const base = op_ptr; |
| 594 | int need_tempvar = 0; |
| 595 | int is_tls = 0; |
| 596 | std::vector<struct insn_info> info; |
| 597 | int stack_depth; |
| 598 | |
| 599 | ++scope; |
| 600 | |
| 601 | fprintfi_filtered (indent, stream, "__attribute__ ((unused)) %s %s;\n", |
| 602 | type_name, result_name); |
| 603 | fprintfi_filtered (indent, stream, "{\n"); |
| 604 | indent += 2; |
| 605 | |
| 606 | stack_depth = compute_stack_depth (byte_order, addr_size, |
| 607 | &need_tempvar, &is_tls, |
| 608 | op_ptr, op_end, initial != NULL, |
| 609 | &info); |
| 610 | |
| 611 | /* This is a hack until we can add a feature to glibc to let us |
| 612 | properly generate code for TLS. You might think we could emit |
| 613 | the address in the ordinary course of translating |
| 614 | DW_OP_GNU_push_tls_address, but since the operand appears on the |
| 615 | stack, it is relatively hard to find, and the idea of calling |
| 616 | target_translate_tls_address with OFFSET==0 and then adding the |
| 617 | offset by hand seemed too hackish. */ |
| 618 | if (is_tls) |
| 619 | { |
| 620 | struct frame_info *frame = get_selected_frame (NULL); |
| 621 | struct value *val; |
| 622 | |
| 623 | if (frame == NULL) |
| 624 | error (_("Symbol \"%s\" cannot be used because " |
| 625 | "there is no selected frame"), |
| 626 | sym->print_name ()); |
| 627 | |
| 628 | val = read_var_value (sym, NULL, frame); |
| 629 | if (VALUE_LVAL (val) != lval_memory) |
| 630 | error (_("Symbol \"%s\" cannot be used for compilation evaluation " |
| 631 | "as its address has not been found."), |
| 632 | sym->print_name ()); |
| 633 | |
| 634 | warning (_("Symbol \"%s\" is thread-local and currently can only " |
| 635 | "be referenced from the current thread in " |
| 636 | "compiled code."), |
| 637 | sym->print_name ()); |
| 638 | |
| 639 | fprintfi_filtered (indent, stream, "%s = %s;\n", |
| 640 | result_name, |
| 641 | core_addr_to_string (value_address (val))); |
| 642 | fprintfi_filtered (indent - 2, stream, "}\n"); |
| 643 | return; |
| 644 | } |
| 645 | |
| 646 | fprintfi_filtered (indent, stream, GCC_UINTPTR " __gdb_stack[%d];\n", |
| 647 | stack_depth); |
| 648 | |
| 649 | if (need_tempvar) |
| 650 | fprintfi_filtered (indent, stream, GCC_UINTPTR " __gdb_tmp;\n"); |
| 651 | fprintfi_filtered (indent, stream, "int __gdb_tos = -1;\n"); |
| 652 | |
| 653 | if (initial != NULL) |
| 654 | pushf (indent, stream, "%s", core_addr_to_string (*initial)); |
| 655 | |
| 656 | while (op_ptr < op_end) |
| 657 | { |
| 658 | enum dwarf_location_atom op = (enum dwarf_location_atom) *op_ptr; |
| 659 | uint64_t uoffset, reg; |
| 660 | int64_t offset; |
| 661 | |
| 662 | print_spaces (indent - 2, stream); |
| 663 | if (info[op_ptr - base].label) |
| 664 | { |
| 665 | print_label (stream, scope, op_ptr - base); |
| 666 | stream->puts (":;"); |
| 667 | } |
| 668 | stream->printf ("/* %s */\n", get_DW_OP_name (op)); |
| 669 | |
| 670 | /* This is handy for debugging the generated code: |
| 671 | fprintf_filtered (stream, "if (__gdb_tos != %d) abort ();\n", |
| 672 | (int) info[op_ptr - base].depth - 1); |
| 673 | */ |
| 674 | |
| 675 | ++op_ptr; |
| 676 | |
| 677 | switch (op) |
| 678 | { |
| 679 | case DW_OP_lit0: |
| 680 | case DW_OP_lit1: |
| 681 | case DW_OP_lit2: |
| 682 | case DW_OP_lit3: |
| 683 | case DW_OP_lit4: |
| 684 | case DW_OP_lit5: |
| 685 | case DW_OP_lit6: |
| 686 | case DW_OP_lit7: |
| 687 | case DW_OP_lit8: |
| 688 | case DW_OP_lit9: |
| 689 | case DW_OP_lit10: |
| 690 | case DW_OP_lit11: |
| 691 | case DW_OP_lit12: |
| 692 | case DW_OP_lit13: |
| 693 | case DW_OP_lit14: |
| 694 | case DW_OP_lit15: |
| 695 | case DW_OP_lit16: |
| 696 | case DW_OP_lit17: |
| 697 | case DW_OP_lit18: |
| 698 | case DW_OP_lit19: |
| 699 | case DW_OP_lit20: |
| 700 | case DW_OP_lit21: |
| 701 | case DW_OP_lit22: |
| 702 | case DW_OP_lit23: |
| 703 | case DW_OP_lit24: |
| 704 | case DW_OP_lit25: |
| 705 | case DW_OP_lit26: |
| 706 | case DW_OP_lit27: |
| 707 | case DW_OP_lit28: |
| 708 | case DW_OP_lit29: |
| 709 | case DW_OP_lit30: |
| 710 | case DW_OP_lit31: |
| 711 | push (indent, stream, op - DW_OP_lit0); |
| 712 | break; |
| 713 | |
| 714 | case DW_OP_addr: |
| 715 | uoffset = extract_unsigned_integer (op_ptr, addr_size, byte_order); |
| 716 | op_ptr += addr_size; |
| 717 | /* Some versions of GCC emit DW_OP_addr before |
| 718 | DW_OP_GNU_push_tls_address. In this case the value is an |
| 719 | index, not an address. We don't support things like |
| 720 | branching between the address and the TLS op. */ |
| 721 | if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address) |
| 722 | uoffset += per_cu->text_offset (); |
| 723 | push (indent, stream, uoffset); |
| 724 | break; |
| 725 | |
| 726 | case DW_OP_const1u: |
| 727 | push (indent, stream, |
| 728 | extract_unsigned_integer (op_ptr, 1, byte_order)); |
| 729 | op_ptr += 1; |
| 730 | break; |
| 731 | case DW_OP_const1s: |
| 732 | push (indent, stream, |
| 733 | extract_signed_integer (op_ptr, 1, byte_order)); |
| 734 | op_ptr += 1; |
| 735 | break; |
| 736 | case DW_OP_const2u: |
| 737 | push (indent, stream, |
| 738 | extract_unsigned_integer (op_ptr, 2, byte_order)); |
| 739 | op_ptr += 2; |
| 740 | break; |
| 741 | case DW_OP_const2s: |
| 742 | push (indent, stream, |
| 743 | extract_signed_integer (op_ptr, 2, byte_order)); |
| 744 | op_ptr += 2; |
| 745 | break; |
| 746 | case DW_OP_const4u: |
| 747 | push (indent, stream, |
| 748 | extract_unsigned_integer (op_ptr, 4, byte_order)); |
| 749 | op_ptr += 4; |
| 750 | break; |
| 751 | case DW_OP_const4s: |
| 752 | push (indent, stream, |
| 753 | extract_signed_integer (op_ptr, 4, byte_order)); |
| 754 | op_ptr += 4; |
| 755 | break; |
| 756 | case DW_OP_const8u: |
| 757 | push (indent, stream, |
| 758 | extract_unsigned_integer (op_ptr, 8, byte_order)); |
| 759 | op_ptr += 8; |
| 760 | break; |
| 761 | case DW_OP_const8s: |
| 762 | push (indent, stream, |
| 763 | extract_signed_integer (op_ptr, 8, byte_order)); |
| 764 | op_ptr += 8; |
| 765 | break; |
| 766 | case DW_OP_constu: |
| 767 | op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset); |
| 768 | push (indent, stream, uoffset); |
| 769 | break; |
| 770 | case DW_OP_consts: |
| 771 | op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); |
| 772 | push (indent, stream, offset); |
| 773 | break; |
| 774 | |
| 775 | case DW_OP_reg0: |
| 776 | case DW_OP_reg1: |
| 777 | case DW_OP_reg2: |
| 778 | case DW_OP_reg3: |
| 779 | case DW_OP_reg4: |
| 780 | case DW_OP_reg5: |
| 781 | case DW_OP_reg6: |
| 782 | case DW_OP_reg7: |
| 783 | case DW_OP_reg8: |
| 784 | case DW_OP_reg9: |
| 785 | case DW_OP_reg10: |
| 786 | case DW_OP_reg11: |
| 787 | case DW_OP_reg12: |
| 788 | case DW_OP_reg13: |
| 789 | case DW_OP_reg14: |
| 790 | case DW_OP_reg15: |
| 791 | case DW_OP_reg16: |
| 792 | case DW_OP_reg17: |
| 793 | case DW_OP_reg18: |
| 794 | case DW_OP_reg19: |
| 795 | case DW_OP_reg20: |
| 796 | case DW_OP_reg21: |
| 797 | case DW_OP_reg22: |
| 798 | case DW_OP_reg23: |
| 799 | case DW_OP_reg24: |
| 800 | case DW_OP_reg25: |
| 801 | case DW_OP_reg26: |
| 802 | case DW_OP_reg27: |
| 803 | case DW_OP_reg28: |
| 804 | case DW_OP_reg29: |
| 805 | case DW_OP_reg30: |
| 806 | case DW_OP_reg31: |
| 807 | dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx"); |
| 808 | pushf_register_address (indent, stream, registers_used, arch, |
| 809 | dwarf_reg_to_regnum_or_error |
| 810 | (arch, op - DW_OP_reg0)); |
| 811 | break; |
| 812 | |
| 813 | case DW_OP_regx: |
| 814 | op_ptr = safe_read_uleb128 (op_ptr, op_end, ®); |
| 815 | dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx"); |
| 816 | pushf_register_address (indent, stream, registers_used, arch, |
| 817 | dwarf_reg_to_regnum_or_error (arch, reg)); |
| 818 | break; |
| 819 | |
| 820 | case DW_OP_breg0: |
| 821 | case DW_OP_breg1: |
| 822 | case DW_OP_breg2: |
| 823 | case DW_OP_breg3: |
| 824 | case DW_OP_breg4: |
| 825 | case DW_OP_breg5: |
| 826 | case DW_OP_breg6: |
| 827 | case DW_OP_breg7: |
| 828 | case DW_OP_breg8: |
| 829 | case DW_OP_breg9: |
| 830 | case DW_OP_breg10: |
| 831 | case DW_OP_breg11: |
| 832 | case DW_OP_breg12: |
| 833 | case DW_OP_breg13: |
| 834 | case DW_OP_breg14: |
| 835 | case DW_OP_breg15: |
| 836 | case DW_OP_breg16: |
| 837 | case DW_OP_breg17: |
| 838 | case DW_OP_breg18: |
| 839 | case DW_OP_breg19: |
| 840 | case DW_OP_breg20: |
| 841 | case DW_OP_breg21: |
| 842 | case DW_OP_breg22: |
| 843 | case DW_OP_breg23: |
| 844 | case DW_OP_breg24: |
| 845 | case DW_OP_breg25: |
| 846 | case DW_OP_breg26: |
| 847 | case DW_OP_breg27: |
| 848 | case DW_OP_breg28: |
| 849 | case DW_OP_breg29: |
| 850 | case DW_OP_breg30: |
| 851 | case DW_OP_breg31: |
| 852 | op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); |
| 853 | pushf_register (indent, stream, registers_used, arch, |
| 854 | dwarf_reg_to_regnum_or_error (arch, |
| 855 | op - DW_OP_breg0), |
| 856 | offset); |
| 857 | break; |
| 858 | case DW_OP_bregx: |
| 859 | { |
| 860 | op_ptr = safe_read_uleb128 (op_ptr, op_end, ®); |
| 861 | op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); |
| 862 | pushf_register (indent, stream, registers_used, arch, |
| 863 | dwarf_reg_to_regnum_or_error (arch, reg), offset); |
| 864 | } |
| 865 | break; |
| 866 | case DW_OP_fbreg: |
| 867 | { |
| 868 | const gdb_byte *datastart; |
| 869 | size_t datalen; |
| 870 | const struct block *b; |
| 871 | struct symbol *framefunc; |
| 872 | char fb_name[50]; |
| 873 | |
| 874 | b = block_for_pc (pc); |
| 875 | |
| 876 | if (!b) |
| 877 | error (_("No block found for address")); |
| 878 | |
| 879 | framefunc = block_linkage_function (b); |
| 880 | |
| 881 | if (!framefunc) |
| 882 | error (_("No function found for block")); |
| 883 | |
| 884 | func_get_frame_base_dwarf_block (framefunc, pc, |
| 885 | &datastart, &datalen); |
| 886 | |
| 887 | op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset); |
| 888 | |
| 889 | /* Generate a unique-enough name, in case the frame base |
| 890 | is computed multiple times in this expression. */ |
| 891 | xsnprintf (fb_name, sizeof (fb_name), "__frame_base_%ld", |
| 892 | (long) (op_ptr - base)); |
| 893 | |
| 894 | do_compile_dwarf_expr_to_c (indent, stream, |
| 895 | GCC_UINTPTR, fb_name, |
| 896 | sym, pc, |
| 897 | arch, registers_used, addr_size, |
| 898 | datastart, datastart + datalen, |
| 899 | NULL, per_cu); |
| 900 | |
| 901 | pushf (indent, stream, "%s + %s", fb_name, hex_string (offset)); |
| 902 | } |
| 903 | break; |
| 904 | |
| 905 | case DW_OP_dup: |
| 906 | pushf (indent, stream, "__gdb_stack[__gdb_tos]"); |
| 907 | break; |
| 908 | |
| 909 | case DW_OP_drop: |
| 910 | fprintfi_filtered (indent, stream, "--__gdb_tos;\n"); |
| 911 | break; |
| 912 | |
| 913 | case DW_OP_pick: |
| 914 | offset = *op_ptr++; |
| 915 | pushf (indent, stream, "__gdb_stack[__gdb_tos - %s]", |
| 916 | plongest (offset)); |
| 917 | break; |
| 918 | |
| 919 | case DW_OP_swap: |
| 920 | fprintfi_filtered (indent, stream, |
| 921 | "__gdb_tmp = __gdb_stack[__gdb_tos - 1];\n"); |
| 922 | fprintfi_filtered (indent, stream, |
| 923 | "__gdb_stack[__gdb_tos - 1] = " |
| 924 | "__gdb_stack[__gdb_tos];\n"); |
| 925 | fprintfi_filtered (indent, stream, ("__gdb_stack[__gdb_tos] = " |
| 926 | "__gdb_tmp;\n")); |
| 927 | break; |
| 928 | |
| 929 | case DW_OP_over: |
| 930 | pushf (indent, stream, "__gdb_stack[__gdb_tos - 1]"); |
| 931 | break; |
| 932 | |
| 933 | case DW_OP_rot: |
| 934 | fprintfi_filtered (indent, stream, ("__gdb_tmp = " |
| 935 | "__gdb_stack[__gdb_tos];\n")); |
| 936 | fprintfi_filtered (indent, stream, |
| 937 | "__gdb_stack[__gdb_tos] = " |
| 938 | "__gdb_stack[__gdb_tos - 1];\n"); |
| 939 | fprintfi_filtered (indent, stream, |
| 940 | "__gdb_stack[__gdb_tos - 1] = " |
| 941 | "__gdb_stack[__gdb_tos -2];\n"); |
| 942 | fprintfi_filtered (indent, stream, "__gdb_stack[__gdb_tos - 2] = " |
| 943 | "__gdb_tmp;\n"); |
| 944 | break; |
| 945 | |
| 946 | case DW_OP_deref: |
| 947 | case DW_OP_deref_size: |
| 948 | { |
| 949 | int size; |
| 950 | const char *mode; |
| 951 | |
| 952 | if (op == DW_OP_deref_size) |
| 953 | size = *op_ptr++; |
| 954 | else |
| 955 | size = addr_size; |
| 956 | |
| 957 | mode = c_get_mode_for_size (size); |
| 958 | if (mode == NULL) |
| 959 | error (_("Unsupported size %d in %s"), |
| 960 | size, get_DW_OP_name (op)); |
| 961 | |
| 962 | /* Cast to a pointer of the desired type, then |
| 963 | dereference. */ |
| 964 | fprintfi_filtered (indent, stream, |
| 965 | "__gdb_stack[__gdb_tos] = " |
| 966 | "*((__gdb_int_%s *) " |
| 967 | "__gdb_stack[__gdb_tos]);\n", |
| 968 | mode); |
| 969 | } |
| 970 | break; |
| 971 | |
| 972 | case DW_OP_abs: |
| 973 | unary (indent, stream, |
| 974 | "((" GCC_INTPTR ") __gdb_stack[__gdb_tos]) < 0 ? " |
| 975 | "-__gdb_stack[__gdb_tos] : __gdb_stack[__gdb_tos]"); |
| 976 | break; |
| 977 | |
| 978 | case DW_OP_neg: |
| 979 | unary (indent, stream, "-__gdb_stack[__gdb_tos]"); |
| 980 | break; |
| 981 | |
| 982 | case DW_OP_not: |
| 983 | unary (indent, stream, "~__gdb_stack[__gdb_tos]"); |
| 984 | break; |
| 985 | |
| 986 | case DW_OP_plus_uconst: |
| 987 | op_ptr = safe_read_uleb128 (op_ptr, op_end, ®); |
| 988 | unary (indent, stream, "__gdb_stack[__gdb_tos] + %s", |
| 989 | hex_string (reg)); |
| 990 | break; |
| 991 | |
| 992 | case DW_OP_div: |
| 993 | binary (indent, stream, ("((" GCC_INTPTR |
| 994 | ") __gdb_stack[__gdb_tos-1]) / ((" |
| 995 | GCC_INTPTR ") __gdb_stack[__gdb_tos])")); |
| 996 | break; |
| 997 | |
| 998 | case DW_OP_shra: |
| 999 | binary (indent, stream, |
| 1000 | "((" GCC_INTPTR ") __gdb_stack[__gdb_tos-1]) >> " |
| 1001 | "__gdb_stack[__gdb_tos]"); |
| 1002 | break; |
| 1003 | |
| 1004 | #define BINARY(OP) \ |
| 1005 | binary (indent, stream, "%s", "__gdb_stack[__gdb_tos-1] " #OP \ |
| 1006 | " __gdb_stack[__gdb_tos]"); \ |
| 1007 | break |
| 1008 | |
| 1009 | case DW_OP_and: |
| 1010 | BINARY (&); |
| 1011 | case DW_OP_minus: |
| 1012 | BINARY (-); |
| 1013 | case DW_OP_mod: |
| 1014 | BINARY (%); |
| 1015 | case DW_OP_mul: |
| 1016 | BINARY (*); |
| 1017 | case DW_OP_or: |
| 1018 | BINARY (|); |
| 1019 | case DW_OP_plus: |
| 1020 | BINARY (+); |
| 1021 | case DW_OP_shl: |
| 1022 | BINARY (<<); |
| 1023 | case DW_OP_shr: |
| 1024 | BINARY (>>); |
| 1025 | case DW_OP_xor: |
| 1026 | BINARY (^); |
| 1027 | #undef BINARY |
| 1028 | |
| 1029 | #define COMPARE(OP) \ |
| 1030 | binary (indent, stream, \ |
| 1031 | "(((" GCC_INTPTR ") __gdb_stack[__gdb_tos-1]) " #OP \ |
| 1032 | " ((" GCC_INTPTR \ |
| 1033 | ") __gdb_stack[__gdb_tos]))"); \ |
| 1034 | break |
| 1035 | |
| 1036 | case DW_OP_le: |
| 1037 | COMPARE (<=); |
| 1038 | case DW_OP_ge: |
| 1039 | COMPARE (>=); |
| 1040 | case DW_OP_eq: |
| 1041 | COMPARE (==); |
| 1042 | case DW_OP_lt: |
| 1043 | COMPARE (<); |
| 1044 | case DW_OP_gt: |
| 1045 | COMPARE (>); |
| 1046 | case DW_OP_ne: |
| 1047 | COMPARE (!=); |
| 1048 | #undef COMPARE |
| 1049 | |
| 1050 | case DW_OP_call_frame_cfa: |
| 1051 | { |
| 1052 | int regnum; |
| 1053 | CORE_ADDR text_offset; |
| 1054 | LONGEST off; |
| 1055 | const gdb_byte *cfa_start, *cfa_end; |
| 1056 | |
| 1057 | if (dwarf2_fetch_cfa_info (arch, pc, per_cu, |
| 1058 | ®num, &off, |
| 1059 | &text_offset, &cfa_start, &cfa_end)) |
| 1060 | { |
| 1061 | /* Register. */ |
| 1062 | pushf_register (indent, stream, registers_used, arch, regnum, |
| 1063 | off); |
| 1064 | } |
| 1065 | else |
| 1066 | { |
| 1067 | /* Another expression. */ |
| 1068 | char cfa_name[50]; |
| 1069 | |
| 1070 | /* Generate a unique-enough name, in case the CFA is |
| 1071 | computed multiple times in this expression. */ |
| 1072 | xsnprintf (cfa_name, sizeof (cfa_name), |
| 1073 | "__cfa_%ld", (long) (op_ptr - base)); |
| 1074 | |
| 1075 | do_compile_dwarf_expr_to_c (indent, stream, |
| 1076 | GCC_UINTPTR, cfa_name, |
| 1077 | sym, pc, arch, registers_used, |
| 1078 | addr_size, |
| 1079 | cfa_start, cfa_end, |
| 1080 | &text_offset, per_cu); |
| 1081 | pushf (indent, stream, "%s", cfa_name); |
| 1082 | } |
| 1083 | } |
| 1084 | |
| 1085 | break; |
| 1086 | |
| 1087 | case DW_OP_skip: |
| 1088 | offset = extract_signed_integer (op_ptr, 2, byte_order); |
| 1089 | op_ptr += 2; |
| 1090 | fprintfi_filtered (indent, stream, "goto "); |
| 1091 | print_label (stream, scope, op_ptr + offset - base); |
| 1092 | stream->puts (";\n"); |
| 1093 | break; |
| 1094 | |
| 1095 | case DW_OP_bra: |
| 1096 | offset = extract_signed_integer (op_ptr, 2, byte_order); |
| 1097 | op_ptr += 2; |
| 1098 | fprintfi_filtered (indent, stream, |
| 1099 | "if ((( " GCC_INTPTR |
| 1100 | ") __gdb_stack[__gdb_tos--]) != 0) goto "); |
| 1101 | print_label (stream, scope, op_ptr + offset - base); |
| 1102 | stream->puts (";\n"); |
| 1103 | break; |
| 1104 | |
| 1105 | case DW_OP_nop: |
| 1106 | break; |
| 1107 | |
| 1108 | default: |
| 1109 | error (_("unhandled DWARF op: %s"), get_DW_OP_name (op)); |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | fprintfi_filtered (indent, stream, "%s = __gdb_stack[__gdb_tos];\n", |
| 1114 | result_name); |
| 1115 | fprintfi_filtered (indent - 2, stream, "}\n"); |
| 1116 | } |
| 1117 | |
| 1118 | /* See compile.h. */ |
| 1119 | |
| 1120 | void |
| 1121 | compile_dwarf_expr_to_c (string_file *stream, const char *result_name, |
| 1122 | struct symbol *sym, CORE_ADDR pc, |
| 1123 | struct gdbarch *arch, unsigned char *registers_used, |
| 1124 | unsigned int addr_size, |
| 1125 | const gdb_byte *op_ptr, const gdb_byte *op_end, |
| 1126 | struct dwarf2_per_cu_data *per_cu) |
| 1127 | { |
| 1128 | do_compile_dwarf_expr_to_c (2, stream, GCC_UINTPTR, result_name, sym, pc, |
| 1129 | arch, registers_used, addr_size, op_ptr, op_end, |
| 1130 | NULL, per_cu); |
| 1131 | } |
| 1132 | |
| 1133 | /* See compile.h. */ |
| 1134 | |
| 1135 | void |
| 1136 | compile_dwarf_bounds_to_c (string_file *stream, |
| 1137 | const char *result_name, |
| 1138 | const struct dynamic_prop *prop, |
| 1139 | struct symbol *sym, CORE_ADDR pc, |
| 1140 | struct gdbarch *arch, unsigned char *registers_used, |
| 1141 | unsigned int addr_size, |
| 1142 | const gdb_byte *op_ptr, const gdb_byte *op_end, |
| 1143 | struct dwarf2_per_cu_data *per_cu) |
| 1144 | { |
| 1145 | do_compile_dwarf_expr_to_c (2, stream, "unsigned long ", result_name, |
| 1146 | sym, pc, arch, registers_used, |
| 1147 | addr_size, op_ptr, op_end, NULL, per_cu); |
| 1148 | } |