| OLD | NEW |
| 1 /* Support for printing C++ values for GDB, the GNU debugger. | 1 /* Support for printing C++ values for GDB, the GNU debugger. |
| 2 | 2 |
| 3 Copyright (C) 1986, 1988-1989, 1991-1997, 2000-2003, 2005-2012 Free | 3 Copyright (C) 1986, 1988-1989, 1991-1997, 2000-2003, 2005-2012 Free |
| 4 Software Foundation, Inc. | 4 Software Foundation, Inc. |
| 5 | 5 |
| 6 This file is part of GDB. | 6 This file is part of GDB. |
| 7 | 7 |
| 8 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
| 9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
| 10 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 /* GCC versions after 2.4.5 use this. */ | 92 /* GCC versions after 2.4.5 use this. */ |
| 93 const char vtbl_ptr_name[] = "__vtbl_ptr_type"; | 93 const char vtbl_ptr_name[] = "__vtbl_ptr_type"; |
| 94 | 94 |
| 95 /* Return truth value for assertion that TYPE is of the type | 95 /* Return truth value for assertion that TYPE is of the type |
| 96 "pointer to virtual function". */ | 96 "pointer to virtual function". */ |
| 97 | 97 |
| 98 int | 98 int |
| 99 cp_is_vtbl_ptr_type (struct type *type) | 99 cp_is_vtbl_ptr_type (struct type *type) |
| 100 { | 100 { |
| 101 char *typename = type_name_no_tag (type); | 101 const char *typename = type_name_no_tag (type); |
| 102 | 102 |
| 103 return (typename != NULL && !strcmp (typename, vtbl_ptr_name)); | 103 return (typename != NULL && !strcmp (typename, vtbl_ptr_name)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 /* Return truth value for the assertion that TYPE is of the type | 106 /* Return truth value for the assertion that TYPE is of the type |
| 107 "pointer to virtual function table". */ | 107 "pointer to virtual function table". */ |
| 108 | 108 |
| 109 int | 109 int |
| 110 cp_is_vtbl_member (struct type *type) | 110 cp_is_vtbl_member (struct type *type) |
| 111 { | 111 { |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 fprintf_filtered (stream, | 351 fprintf_filtered (stream, |
| 352 _("<error reading variable: %s>"), | 352 _("<error reading variable: %s>"), |
| 353 ex.message); | 353 ex.message); |
| 354 else if (v == NULL) | 354 else if (v == NULL) |
| 355 val_print_optimized_out (stream); | 355 val_print_optimized_out (stream); |
| 356 else | 356 else |
| 357 cp_print_static_field (TYPE_FIELD_TYPE (type, i), | 357 cp_print_static_field (TYPE_FIELD_TYPE (type, i), |
| 358 v, stream, recurse + 1, | 358 v, stream, recurse + 1, |
| 359 options); | 359 options); |
| 360 } | 360 } |
| 361 else if (i == TYPE_VPTR_FIELDNO (type)) |
| 362 { |
| 363 int i_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8; |
| 364 struct type *i_type = TYPE_FIELD_TYPE (type, i); |
| 365 |
| 366 if (valprint_check_validity (stream, i_type, i_offset, val)) |
| 367 { |
| 368 CORE_ADDR addr; |
| 369 |
| 370 addr = extract_typed_address (valaddr + i_offset, i_type); |
| 371 print_function_pointer_address (options, |
| 372 get_type_arch (type), |
| 373 addr, stream); |
| 374 } |
| 375 } |
| 361 else | 376 else |
| 362 { | 377 { |
| 363 struct value_print_options opts = *options; | 378 struct value_print_options opts = *options; |
| 364 | 379 |
| 365 opts.deref_ref = 0; | 380 opts.deref_ref = 0; |
| 366 val_print (TYPE_FIELD_TYPE (type, i), | 381 val_print (TYPE_FIELD_TYPE (type, i), |
| 367 valaddr, | 382 valaddr, |
| 368 offset + TYPE_FIELD_BITPOS (type, i) / 8, | 383 offset + TYPE_FIELD_BITPOS (type, i) / 8, |
| 369 address, | 384 address, |
| 370 stream, recurse + 1, val, &opts, | 385 stream, recurse + 1, val, &opts, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 returns. */ | 503 returns. */ |
| 489 /* Bump up the high-water mark. Now alpha is omega. */ | 504 /* Bump up the high-water mark. Now alpha is omega. */ |
| 490 obstack_finish (&dont_print_vb_obstack); | 505 obstack_finish (&dont_print_vb_obstack); |
| 491 } | 506 } |
| 492 | 507 |
| 493 for (i = 0; i < n_baseclasses; i++) | 508 for (i = 0; i < n_baseclasses; i++) |
| 494 { | 509 { |
| 495 int boffset = 0; | 510 int boffset = 0; |
| 496 int skip; | 511 int skip; |
| 497 struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); | 512 struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); |
| 498 char *basename = TYPE_NAME (baseclass); | 513 const char *basename = TYPE_NAME (baseclass); |
| 499 const gdb_byte *base_valaddr = NULL; | 514 const gdb_byte *base_valaddr = NULL; |
| 500 const struct value *base_val = NULL; | 515 const struct value *base_val = NULL; |
| 501 volatile struct gdb_exception ex; | 516 volatile struct gdb_exception ex; |
| 502 | 517 |
| 503 if (BASETYPE_VIA_VIRTUAL (type, i)) | 518 if (BASETYPE_VIA_VIRTUAL (type, i)) |
| 504 { | 519 { |
| 505 struct type **first_dont_print | 520 struct type **first_dont_print |
| 506 = (struct type **) obstack_base (&dont_print_vb_obstack); | 521 = (struct type **) obstack_base (&dont_print_vb_obstack); |
| 507 | 522 |
| 508 int j = (struct type **) | 523 int j = (struct type **) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 532 | 547 |
| 533 if (BASETYPE_VIA_VIRTUAL (type, i)) | 548 if (BASETYPE_VIA_VIRTUAL (type, i)) |
| 534 { | 549 { |
| 535 /* The virtual base class pointer might have been | 550 /* The virtual base class pointer might have been |
| 536 clobbered by the user program. Make sure that it | 551 clobbered by the user program. Make sure that it |
| 537 still points to a valid memory location. */ | 552 still points to a valid memory location. */ |
| 538 | 553 |
| 539 if ((boffset + offset) < 0 | 554 if ((boffset + offset) < 0 |
| 540 || (boffset + offset) >= TYPE_LENGTH (real_type)) | 555 || (boffset + offset) >= TYPE_LENGTH (real_type)) |
| 541 { | 556 { |
| 542 » » /* FIXME (alloca): unsafe if baseclass is really | 557 » » gdb_byte *buf; |
| 543 » » really large. */ | 558 » » struct cleanup *back_to; |
| 544 » » gdb_byte *buf = alloca (TYPE_LENGTH (baseclass)); | 559 |
| 560 » » buf = xmalloc (TYPE_LENGTH (baseclass)); |
| 561 » » back_to = make_cleanup (xfree, buf); |
| 545 | 562 |
| 546 if (target_read_memory (address + boffset, buf, | 563 if (target_read_memory (address + boffset, buf, |
| 547 TYPE_LENGTH (baseclass)) != 0) | 564 TYPE_LENGTH (baseclass)) != 0) |
| 548 skip = 1; | 565 skip = 1; |
| 549 base_val = value_from_contents_and_address (baseclass, | 566 base_val = value_from_contents_and_address (baseclass, |
| 550 buf, | 567 buf, |
| 551 address + boffset)
; | 568 address + boffset)
; |
| 552 thisoffset = 0; | 569 thisoffset = 0; |
| 553 boffset = 0; | 570 boffset = 0; |
| 554 thistype = baseclass; | 571 thistype = baseclass; |
| 555 base_valaddr = value_contents_for_printing_const (base_val); | 572 base_valaddr = value_contents_for_printing_const (base_val); |
| 573 do_cleanups (back_to); |
| 556 } | 574 } |
| 557 else | 575 else |
| 558 { | 576 { |
| 559 base_valaddr = valaddr; | 577 base_valaddr = valaddr; |
| 560 base_val = val; | 578 base_val = val; |
| 561 } | 579 } |
| 562 } | 580 } |
| 563 else | 581 else |
| 564 { | 582 { |
| 565 base_valaddr = valaddr; | 583 base_valaddr = valaddr; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 if (val == -1) | 805 if (val == -1) |
| 788 { | 806 { |
| 789 fprintf_filtered (stream, "NULL"); | 807 fprintf_filtered (stream, "NULL"); |
| 790 return; | 808 return; |
| 791 } | 809 } |
| 792 | 810 |
| 793 cp_find_class_member (&domain, &fieldno, val << 3); | 811 cp_find_class_member (&domain, &fieldno, val << 3); |
| 794 | 812 |
| 795 if (domain != NULL) | 813 if (domain != NULL) |
| 796 { | 814 { |
| 797 char *name; | 815 const char *name; |
| 798 | 816 |
| 799 fputs_filtered (prefix, stream); | 817 fputs_filtered (prefix, stream); |
| 800 name = type_name_no_tag (domain); | 818 name = type_name_no_tag (domain); |
| 801 if (name) | 819 if (name) |
| 802 fputs_filtered (name, stream); | 820 fputs_filtered (name, stream); |
| 803 else | 821 else |
| 804 c_type_print_base (domain, stream, 0, 0); | 822 c_type_print_base (domain, stream, 0, 0); |
| 805 fprintf_filtered (stream, "::"); | 823 fprintf_filtered (stream, "::"); |
| 806 fputs_filtered (TYPE_FIELD_NAME (domain, fieldno), stream); | 824 fputs_filtered (TYPE_FIELD_NAME (domain, fieldno), stream); |
| 807 } | 825 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 837 show_objectprint, | 855 show_objectprint, |
| 838 &setprintlist, &showprintlist); | 856 &setprintlist, &showprintlist); |
| 839 | 857 |
| 840 obstack_begin (&dont_print_stat_array_obstack, | 858 obstack_begin (&dont_print_stat_array_obstack, |
| 841 32 * sizeof (struct type *)); | 859 32 * sizeof (struct type *)); |
| 842 obstack_begin (&dont_print_statmem_obstack, | 860 obstack_begin (&dont_print_statmem_obstack, |
| 843 32 * sizeof (CORE_ADDR)); | 861 32 * sizeof (CORE_ADDR)); |
| 844 obstack_begin (&dont_print_vb_obstack, | 862 obstack_begin (&dont_print_vb_obstack, |
| 845 32 * sizeof (struct type *)); | 863 32 * sizeof (struct type *)); |
| 846 } | 864 } |
| OLD | NEW |