439 const gdb_byte *mac_ptr,
const gdb_byte *mac_end,
443 int section_is_gnu,
int section_is_dwz,
444 unsigned int offset_size,
447 gdb::optional<ULONGEST> str_offsets_base,
448 htab_t include_hash,
struct dwarf2_cu *cu)
451 enum dwarf_macro_record_type macinfo_type;
453 const gdb_byte *opcode_definitions[256];
456 &offset_size, section_is_gnu);
475 if (mac_ptr >= mac_end)
481 macinfo_type = (
enum dwarf_macro_record_type)
read_1_byte (abfd, mac_ptr);
487 DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
488 switch (macinfo_type)
495 case DW_MACRO_define:
497 case DW_MACRO_define_strp:
498 case DW_MACRO_undef_strp:
499 case DW_MACRO_define_sup:
500 case DW_MACRO_undef_sup:
502 unsigned int bytes_read;
508 mac_ptr += bytes_read;
510 if (macinfo_type == DW_MACRO_define
511 || macinfo_type == DW_MACRO_undef)
514 mac_ptr += bytes_read;
520 str_offset =
read_offset (abfd, mac_ptr, offset_size);
521 mac_ptr += offset_size;
523 if (macinfo_type == DW_MACRO_define_sup
524 || macinfo_type == DW_MACRO_undef_sup
538 is_define = (macinfo_type == DW_MACRO_define
539 || macinfo_type == DW_MACRO_define_strp
540 || macinfo_type == DW_MACRO_define_sup);
544 complaint (_(
"debug info with no main source gives macro %s "
546 is_define ? _(
"definition") : _(
"undefinition"),
550 if ((line == 0 && !at_commandline)
551 || (line != 0 && at_commandline))
552 complaint (_(
"debug info gives %s macro %s with %s line %d: %s"),
553 at_commandline ? _(
"command-line") : _(
"in-file"),
554 is_define ? _(
"definition") : _(
"undefinition"),
555 line == 0 ? _(
"zero") : _(
"non-zero"), line, body);
564 complaint (_(
"debug info gives %s invalid macro %s "
565 "without body (corrupted?) at line %d "
567 at_commandline ? _(
"command-line") : _(
"in-file"),
568 is_define ? _(
"definition") : _(
"undefinition"),
575 gdb_assert (macinfo_type == DW_MACRO_undef
576 || macinfo_type == DW_MACRO_undef_strp
577 || macinfo_type == DW_MACRO_undef_sup);
583 case DW_MACRO_define_strx:
584 case DW_MACRO_undef_strx:
586 unsigned int bytes_read;
589 mac_ptr += bytes_read;
591 mac_ptr += bytes_read;
594 if (!str_offsets_base.has_value ())
596 complaint (_(
"use of %s with unknown string offsets base "
598 (macinfo_type == DW_MACRO_define_strx
599 ?
"DW_MACRO_define_strx"
600 :
"DW_MACRO_undef_strx"),
606 const gdb_byte *info_ptr = (str_offsets_section->
buffer
608 + offset_index * offset_size);
610 const char *macinfo_str = (macinfo_type == DW_MACRO_define_strx ?
611 "DW_MACRO_define_strx" :
"DW_MACRO_undef_strx");
613 if (*str_offsets_base + offset_index * offset_size
614 >= str_offsets_section->
size)
616 complaint (_(
"%s pointing outside of .debug_str_offsets section "
621 ULONGEST str_offset =
read_offset (abfd, info_ptr, offset_size);
625 if (current_file ==
nullptr)
628 complaint (_(
"debug info with no main source gives macro %s "
630 macinfo_type == DW_MACRO_define_strx ? _(
"definition")
631 : _(
"undefinition"), line, body);
635 if (macinfo_type == DW_MACRO_define_strx)
642 case DW_MACRO_start_file:
644 unsigned int bytes_read;
648 mac_ptr += bytes_read;
650 mac_ptr += bytes_read;
652 if ((line == 0 && !at_commandline)
653 || (line != 0 && at_commandline))
654 complaint (_(
"debug info gives source %d included "
655 "from %s at %s line %d"),
656 file, at_commandline ? _(
"command-line") : _(
"file"),
657 line == 0 ? _(
"zero") : _(
"non-zero"), line);
671 case DW_MACRO_end_file:
673 complaint (_(
"macro debug info has an unmatched "
674 "`close_file' directive"));
691 enum dwarf_macro_record_type next_type;
699 if (mac_ptr >= mac_end)
708 = (
enum dwarf_macro_record_type)
read_1_byte (abfd,
711 complaint (_(
"no terminating 0-type entry for "
712 "macros in `.debug_macinfo' section"));
719 case DW_MACRO_import:
720 case DW_MACRO_import_sup:
724 bfd *include_bfd = abfd;
726 const gdb_byte *include_mac_end = mac_end;
727 int is_dwz = section_is_dwz;
728 const gdb_byte *new_mac_ptr;
731 mac_ptr += offset_size;
733 if (macinfo_type == DW_MACRO_import_sup)
740 include_section = &dwz->
macro;
742 include_mac_end = dwz->
macro.buffer + dwz->
macro.size;
746 new_mac_ptr = include_section->
buffer + offset;
747 slot = htab_find_slot (include_hash, new_mac_ptr, INSERT);
753 complaint (_(
"recursive DW_MACRO_import in "
754 ".debug_macro section"));
758 *slot = (
void *) new_mac_ptr;
761 new_mac_ptr, include_mac_end,
763 section_is_gnu, is_dwz, offset_size,
764 str_section, str_offsets_section,
765 str_offsets_base, include_hash, cu);
767 htab_remove_elt (include_hash, (
void *) new_mac_ptr);
772 case DW_MACINFO_vendor_ext:
775 unsigned int bytes_read;
780 mac_ptr += bytes_read;
782 mac_ptr += bytes_read;
791 mac_ptr, mac_end, abfd, offset_size,
798 }
while (macinfo_type != 0);
805 const struct line_header *lh,
unsigned int offset_size,
808 gdb::optional<ULONGEST> str_offsets_base,
809 int section_is_gnu,
struct dwarf2_cu *cu)
812 const gdb_byte *mac_ptr, *mac_end;
814 enum dwarf_macro_record_type macinfo_type;
815 const gdb_byte *opcode_definitions[256];
831 mac_ptr = section->
buffer + offset;
835 &offset_size, section_is_gnu);
845 if (mac_ptr >= mac_end)
853 macinfo_type = (
enum dwarf_macro_record_type)
read_1_byte (abfd, mac_ptr);
859 DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
860 switch (macinfo_type)
867 case DW_MACRO_define:
871 unsigned int bytes_read;
874 mac_ptr += bytes_read;
876 mac_ptr += bytes_read;
880 case DW_MACRO_start_file:
882 unsigned int bytes_read;
886 mac_ptr += bytes_read;
888 mac_ptr += bytes_read;
895 case DW_MACRO_end_file:
899 case DW_MACRO_define_strp:
900 case DW_MACRO_undef_strp:
901 case DW_MACRO_define_sup:
902 case DW_MACRO_undef_sup:
904 unsigned int bytes_read;
907 mac_ptr += bytes_read;
908 mac_ptr += offset_size;
911 case DW_MACRO_define_strx:
912 case DW_MACRO_undef_strx:
914 unsigned int bytes_read;
917 mac_ptr += bytes_read;
919 mac_ptr += bytes_read;
923 case DW_MACRO_import:
924 case DW_MACRO_import_sup:
928 mac_ptr += offset_size;
931 case DW_MACINFO_vendor_ext:
935 unsigned int bytes_read;
938 mac_ptr += bytes_read;
940 mac_ptr += bytes_read;
946 mac_ptr, mac_end, abfd, offset_size,
953 }
while (macinfo_type != 0 && current_file == NULL);
961 htab_up include_hash (htab_create_alloc (1, htab_hash_pointer,
964 mac_ptr = section->
buffer + offset;
965 slot = htab_find_slot (include_hash.get (), mac_ptr, INSERT);
966 *slot = (
void *) mac_ptr;
968 current_file, lh, section, section_is_gnu, 0,
969 offset_size, str_section, str_offsets_section,
970 str_offsets_base, include_hash.get (), cu);
static void dwarf_decode_macro_bytes(dwarf2_per_objfile *per_objfile, buildsym_compunit *builder, bfd *abfd, const gdb_byte *mac_ptr, const gdb_byte *mac_end, struct macro_source_file *current_file, const struct line_header *lh, const struct dwarf2_section_info *section, int section_is_gnu, int section_is_dwz, unsigned int offset_size, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, gdb::optional< ULONGEST > str_offsets_base, htab_t include_hash, struct dwarf2_cu *cu)
void dwarf_decode_macros(dwarf2_per_objfile *per_objfile, buildsym_compunit *builder, const dwarf2_section_info *section, const struct line_header *lh, unsigned int offset_size, unsigned int offset, struct dwarf2_section_info *str_section, struct dwarf2_section_info *str_offsets_section, gdb::optional< ULONGEST > str_offsets_base, int section_is_gnu, struct dwarf2_cu *cu)