GNU Binutils with patches for OS216
修订版 | 78d4d2c538dd7975f0f130b2df842c4858c01fd3 (tree) |
---|---|
时间 | 2017-02-21 04:53:19 |
作者 | Jan Kratochvil <jan.kratochvil@redh...> |
Commiter | Jan Kratochvil |
Code cleanup: Split create_debug_types_hash_table
DWARF-5 moved .debug_types into .debug_info and so the types reading code needs
to be reused more (in a future patch).
gdb/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c (create_debug_type_hash_table): New function from
create_debug_types_hash_table.
(create_debug_types_hash_table): Call create_debug_type_hash_table.
(create_all_type_units, open_and_init_dwo_file): Update
create_debug_types_hash_table callers.
@@ -1,3 +1,11 @@ | ||
1 | +2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com> | |
2 | + | |
3 | + * dwarf2read.c (create_debug_type_hash_table): New function from | |
4 | + create_debug_types_hash_table. | |
5 | + (create_debug_types_hash_table): Call create_debug_type_hash_table. | |
6 | + (create_all_type_units, open_and_init_dwo_file): Update | |
7 | + create_debug_types_hash_table callers. | |
8 | + | |
1 | 9 | 2017-02-20 Sergio Durigan Junior <sergiodj@redhat.com> |
2 | 10 | |
3 | 11 | PR gdb/16188 |
@@ -4605,27 +4605,17 @@ add_signatured_type_cu_to_table (void **slot, void *datum) | ||
4605 | 4605 | return 1; |
4606 | 4606 | } |
4607 | 4607 | |
4608 | -/* Create the hash table of all entries in the .debug_types | |
4609 | - (or .debug_types.dwo) section(s). | |
4610 | - If reading a DWO file, then DWO_FILE is a pointer to the DWO file object, | |
4611 | - otherwise it is NULL. | |
4608 | +/* A helper for create_debug_types_hash_table. Read types from SECTION | |
4609 | + and fill them into TYPES_HTAB. */ | |
4612 | 4610 | |
4613 | - The result is a pointer to the hash table or NULL if there are no types. | |
4614 | - | |
4615 | - Note: This function processes DWO files only, not DWP files. */ | |
4616 | - | |
4617 | -static htab_t | |
4618 | -create_debug_types_hash_table (struct dwo_file *dwo_file, | |
4619 | - VEC (dwarf2_section_info_def) *types) | |
4611 | +static void | |
4612 | +create_debug_type_hash_table (struct dwo_file *dwo_file, | |
4613 | + dwarf2_section_info *section, htab_t &types_htab) | |
4620 | 4614 | { |
4621 | 4615 | struct objfile *objfile = dwarf2_per_objfile->objfile; |
4622 | - htab_t types_htab = NULL; | |
4623 | - int ix; | |
4624 | - struct dwarf2_section_info *section; | |
4625 | 4616 | struct dwarf2_section_info *abbrev_section; |
4626 | - | |
4627 | - if (VEC_empty (dwarf2_section_info_def, types)) | |
4628 | - return NULL; | |
4617 | + bfd *abfd; | |
4618 | + const gdb_byte *info_ptr, *end_ptr; | |
4629 | 4619 | |
4630 | 4620 | abbrev_section = (dwo_file != NULL |
4631 | 4621 | ? &dwo_file->sections.abbrev |
@@ -4636,136 +4626,152 @@ create_debug_types_hash_table (struct dwo_file *dwo_file, | ||
4636 | 4626 | dwo_file ? ".dwo" : "", |
4637 | 4627 | get_section_file_name (abbrev_section)); |
4638 | 4628 | |
4639 | - for (ix = 0; | |
4640 | - VEC_iterate (dwarf2_section_info_def, types, ix, section); | |
4641 | - ++ix) | |
4642 | - { | |
4643 | - bfd *abfd; | |
4644 | - const gdb_byte *info_ptr, *end_ptr; | |
4629 | + dwarf2_read_section (objfile, section); | |
4630 | + info_ptr = section->buffer; | |
4645 | 4631 | |
4646 | - dwarf2_read_section (objfile, section); | |
4647 | - info_ptr = section->buffer; | |
4632 | + if (info_ptr == NULL) | |
4633 | + return; | |
4648 | 4634 | |
4649 | - if (info_ptr == NULL) | |
4650 | - continue; | |
4635 | + /* We can't set abfd until now because the section may be empty or | |
4636 | + not present, in which case the bfd is unknown. */ | |
4637 | + abfd = get_section_bfd_owner (section); | |
4651 | 4638 | |
4652 | - /* We can't set abfd until now because the section may be empty or | |
4653 | - not present, in which case the bfd is unknown. */ | |
4654 | - abfd = get_section_bfd_owner (section); | |
4639 | + /* We don't use init_cutu_and_read_dies_simple, or some such, here | |
4640 | + because we don't need to read any dies: the signature is in the | |
4641 | + header. */ | |
4655 | 4642 | |
4656 | - /* We don't use init_cutu_and_read_dies_simple, or some such, here | |
4657 | - because we don't need to read any dies: the signature is in the | |
4658 | - header. */ | |
4643 | + end_ptr = info_ptr + section->size; | |
4644 | + while (info_ptr < end_ptr) | |
4645 | + { | |
4646 | + sect_offset offset; | |
4647 | + cu_offset type_offset_in_tu; | |
4648 | + ULONGEST signature; | |
4649 | + struct signatured_type *sig_type; | |
4650 | + struct dwo_unit *dwo_tu; | |
4651 | + void **slot; | |
4652 | + const gdb_byte *ptr = info_ptr; | |
4653 | + struct comp_unit_head header; | |
4654 | + unsigned int length; | |
4659 | 4655 | |
4660 | - end_ptr = info_ptr + section->size; | |
4661 | - while (info_ptr < end_ptr) | |
4662 | - { | |
4663 | - sect_offset offset; | |
4664 | - cu_offset type_offset_in_tu; | |
4665 | - ULONGEST signature; | |
4666 | - struct signatured_type *sig_type; | |
4667 | - struct dwo_unit *dwo_tu; | |
4668 | - void **slot; | |
4669 | - const gdb_byte *ptr = info_ptr; | |
4670 | - struct comp_unit_head header; | |
4671 | - unsigned int length; | |
4656 | + offset.sect_off = ptr - section->buffer; | |
4672 | 4657 | |
4673 | - offset.sect_off = ptr - section->buffer; | |
4658 | + /* We need to read the type's signature in order to build the hash | |
4659 | + table, but we don't need anything else just yet. */ | |
4674 | 4660 | |
4675 | - /* We need to read the type's signature in order to build the hash | |
4676 | - table, but we don't need anything else just yet. */ | |
4661 | + ptr = read_and_check_type_unit_head (&header, section, | |
4662 | + abbrev_section, ptr, | |
4663 | + &signature, &type_offset_in_tu); | |
4677 | 4664 | |
4678 | - ptr = read_and_check_type_unit_head (&header, section, | |
4679 | - abbrev_section, ptr, | |
4680 | - &signature, &type_offset_in_tu); | |
4665 | + length = get_cu_length (&header); | |
4681 | 4666 | |
4682 | - length = get_cu_length (&header); | |
4667 | + /* Skip dummy type units. */ | |
4668 | + if (ptr >= info_ptr + length | |
4669 | + || peek_abbrev_code (abfd, ptr) == 0) | |
4670 | + { | |
4671 | + info_ptr += length; | |
4672 | + continue; | |
4673 | + } | |
4683 | 4674 | |
4684 | - /* Skip dummy type units. */ | |
4685 | - if (ptr >= info_ptr + length | |
4686 | - || peek_abbrev_code (abfd, ptr) == 0) | |
4687 | - { | |
4688 | - info_ptr += length; | |
4689 | - continue; | |
4690 | - } | |
4675 | + if (types_htab == NULL) | |
4676 | + { | |
4677 | + if (dwo_file) | |
4678 | + types_htab = allocate_dwo_unit_table (objfile); | |
4679 | + else | |
4680 | + types_htab = allocate_signatured_type_table (objfile); | |
4681 | + } | |
4691 | 4682 | |
4692 | - if (types_htab == NULL) | |
4693 | - { | |
4694 | - if (dwo_file) | |
4695 | - types_htab = allocate_dwo_unit_table (objfile); | |
4696 | - else | |
4697 | - types_htab = allocate_signatured_type_table (objfile); | |
4698 | - } | |
4683 | + if (dwo_file) | |
4684 | + { | |
4685 | + sig_type = NULL; | |
4686 | + dwo_tu = OBSTACK_ZALLOC (&objfile->objfile_obstack, | |
4687 | + struct dwo_unit); | |
4688 | + dwo_tu->dwo_file = dwo_file; | |
4689 | + dwo_tu->signature = signature; | |
4690 | + dwo_tu->type_offset_in_tu = type_offset_in_tu; | |
4691 | + dwo_tu->section = section; | |
4692 | + dwo_tu->offset = offset; | |
4693 | + dwo_tu->length = length; | |
4694 | + } | |
4695 | + else | |
4696 | + { | |
4697 | + /* N.B.: type_offset is not usable if this type uses a DWO file. | |
4698 | + The real type_offset is in the DWO file. */ | |
4699 | + dwo_tu = NULL; | |
4700 | + sig_type = OBSTACK_ZALLOC (&objfile->objfile_obstack, | |
4701 | + struct signatured_type); | |
4702 | + sig_type->signature = signature; | |
4703 | + sig_type->type_offset_in_tu = type_offset_in_tu; | |
4704 | + sig_type->per_cu.objfile = objfile; | |
4705 | + sig_type->per_cu.is_debug_types = 1; | |
4706 | + sig_type->per_cu.section = section; | |
4707 | + sig_type->per_cu.offset = offset; | |
4708 | + sig_type->per_cu.length = length; | |
4709 | + } | |
4710 | + | |
4711 | + slot = htab_find_slot (types_htab, | |
4712 | + dwo_file ? (void*) dwo_tu : (void *) sig_type, | |
4713 | + INSERT); | |
4714 | + gdb_assert (slot != NULL); | |
4715 | + if (*slot != NULL) | |
4716 | + { | |
4717 | + sect_offset dup_offset; | |
4699 | 4718 | |
4700 | 4719 | if (dwo_file) |
4701 | 4720 | { |
4702 | - sig_type = NULL; | |
4703 | - dwo_tu = OBSTACK_ZALLOC (&objfile->objfile_obstack, | |
4704 | - struct dwo_unit); | |
4705 | - dwo_tu->dwo_file = dwo_file; | |
4706 | - dwo_tu->signature = signature; | |
4707 | - dwo_tu->type_offset_in_tu = type_offset_in_tu; | |
4708 | - dwo_tu->section = section; | |
4709 | - dwo_tu->offset = offset; | |
4710 | - dwo_tu->length = length; | |
4721 | + const struct dwo_unit *dup_tu | |
4722 | + = (const struct dwo_unit *) *slot; | |
4723 | + | |
4724 | + dup_offset = dup_tu->offset; | |
4711 | 4725 | } |
4712 | 4726 | else |
4713 | 4727 | { |
4714 | - /* N.B.: type_offset is not usable if this type uses a DWO file. | |
4715 | - The real type_offset is in the DWO file. */ | |
4716 | - dwo_tu = NULL; | |
4717 | - sig_type = OBSTACK_ZALLOC (&objfile->objfile_obstack, | |
4718 | - struct signatured_type); | |
4719 | - sig_type->signature = signature; | |
4720 | - sig_type->type_offset_in_tu = type_offset_in_tu; | |
4721 | - sig_type->per_cu.objfile = objfile; | |
4722 | - sig_type->per_cu.is_debug_types = 1; | |
4723 | - sig_type->per_cu.section = section; | |
4724 | - sig_type->per_cu.offset = offset; | |
4725 | - sig_type->per_cu.length = length; | |
4728 | + const struct signatured_type *dup_tu | |
4729 | + = (const struct signatured_type *) *slot; | |
4730 | + | |
4731 | + dup_offset = dup_tu->per_cu.offset; | |
4726 | 4732 | } |
4727 | 4733 | |
4728 | - slot = htab_find_slot (types_htab, | |
4729 | - dwo_file ? (void*) dwo_tu : (void *) sig_type, | |
4730 | - INSERT); | |
4731 | - gdb_assert (slot != NULL); | |
4732 | - if (*slot != NULL) | |
4733 | - { | |
4734 | - sect_offset dup_offset; | |
4734 | + complaint (&symfile_complaints, | |
4735 | + _("debug type entry at offset 0x%x is duplicate to" | |
4736 | + " the entry at offset 0x%x, signature %s"), | |
4737 | + offset.sect_off, dup_offset.sect_off, | |
4738 | + hex_string (signature)); | |
4739 | + } | |
4740 | + *slot = dwo_file ? (void *) dwo_tu : (void *) sig_type; | |
4735 | 4741 | |
4736 | - if (dwo_file) | |
4737 | - { | |
4738 | - const struct dwo_unit *dup_tu | |
4739 | - = (const struct dwo_unit *) *slot; | |
4742 | + if (dwarf_read_debug > 1) | |
4743 | + fprintf_unfiltered (gdb_stdlog, " offset 0x%x, signature %s\n", | |
4744 | + offset.sect_off, | |
4745 | + hex_string (signature)); | |
4740 | 4746 | |
4741 | - dup_offset = dup_tu->offset; | |
4742 | - } | |
4743 | - else | |
4744 | - { | |
4745 | - const struct signatured_type *dup_tu | |
4746 | - = (const struct signatured_type *) *slot; | |
4747 | + info_ptr += length; | |
4748 | + } | |
4749 | +} | |
4747 | 4750 | |
4748 | - dup_offset = dup_tu->per_cu.offset; | |
4749 | - } | |
4751 | +/* Create the hash table of all entries in the .debug_types | |
4752 | + (or .debug_types.dwo) section(s). | |
4753 | + If reading a DWO file, then DWO_FILE is a pointer to the DWO file object, | |
4754 | + otherwise it is NULL. | |
4750 | 4755 | |
4751 | - complaint (&symfile_complaints, | |
4752 | - _("debug type entry at offset 0x%x is duplicate to" | |
4753 | - " the entry at offset 0x%x, signature %s"), | |
4754 | - offset.sect_off, dup_offset.sect_off, | |
4755 | - hex_string (signature)); | |
4756 | - } | |
4757 | - *slot = dwo_file ? (void *) dwo_tu : (void *) sig_type; | |
4756 | + The result is a pointer to the hash table or NULL if there are no types. | |
4758 | 4757 | |
4759 | - if (dwarf_read_debug > 1) | |
4760 | - fprintf_unfiltered (gdb_stdlog, " offset 0x%x, signature %s\n", | |
4761 | - offset.sect_off, | |
4762 | - hex_string (signature)); | |
4758 | + Note: This function processes DWO files only, not DWP files. */ | |
4763 | 4759 | |
4764 | - info_ptr += length; | |
4765 | - } | |
4766 | - } | |
4760 | +static void | |
4761 | +create_debug_types_hash_table (struct dwo_file *dwo_file, | |
4762 | + VEC (dwarf2_section_info_def) *types, | |
4763 | + htab_t &types_htab) | |
4764 | +{ | |
4765 | + int ix; | |
4766 | + struct dwarf2_section_info *section; | |
4767 | + | |
4768 | + if (VEC_empty (dwarf2_section_info_def, types)) | |
4769 | + return; | |
4767 | 4770 | |
4768 | - return types_htab; | |
4771 | + for (ix = 0; | |
4772 | + VEC_iterate (dwarf2_section_info_def, types, ix, section); | |
4773 | + ++ix) | |
4774 | + create_debug_type_hash_table (dwo_file, section, types_htab); | |
4769 | 4775 | } |
4770 | 4776 | |
4771 | 4777 | /* Create the hash table of all entries in the .debug_types section, |
@@ -4776,10 +4782,10 @@ create_debug_types_hash_table (struct dwo_file *dwo_file, | ||
4776 | 4782 | static int |
4777 | 4783 | create_all_type_units (struct objfile *objfile) |
4778 | 4784 | { |
4779 | - htab_t types_htab; | |
4785 | + htab_t types_htab = NULL; | |
4780 | 4786 | struct signatured_type **iter; |
4781 | 4787 | |
4782 | - types_htab = create_debug_types_hash_table (NULL, dwarf2_per_objfile->types); | |
4788 | + create_debug_types_hash_table (NULL, dwarf2_per_objfile->types, types_htab); | |
4783 | 4789 | if (types_htab == NULL) |
4784 | 4790 | { |
4785 | 4791 | dwarf2_per_objfile->signatured_types = NULL; |
@@ -10615,8 +10621,8 @@ open_and_init_dwo_file (struct dwarf2_per_cu_data *per_cu, | ||
10615 | 10621 | |
10616 | 10622 | dwo_file->cu = create_dwo_cu (dwo_file); |
10617 | 10623 | |
10618 | - dwo_file->tus = create_debug_types_hash_table (dwo_file, | |
10619 | - dwo_file->sections.types); | |
10624 | + create_debug_types_hash_table (dwo_file, dwo_file->sections.types, | |
10625 | + dwo_file->tus); | |
10620 | 10626 | |
10621 | 10627 | discard_cleanups (cleanups); |
10622 | 10628 |