public inbox for archer-commits@sourceware.org help / color / mirror / Atom feed
From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-tromey-dwz-multifile: read the .gdb_index section in the .dwz file and use it Date: Tue, 05 Jun 2012 18:19:00 -0000 [thread overview] Message-ID: <20120605181859.14457.qmail@sourceware.org> (raw) The branch, archer-tromey-dwz-multifile has been updated via ee8d9d8801288fb677620e6bfe6e3df888605e81 (commit) via 81d35f07943ff68f6feabbf7d676c43b7285b898 (commit) via 4458edafaedbea4f5234f43a4fa3c48d23750804 (commit) from 04b1a89dbe8be1c7781426e04d54d36b3c097733 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit ee8d9d8801288fb677620e6bfe6e3df888605e81 Author: Tom Tromey <tromey@redhat.com> Date: Tue Jun 5 12:17:50 2012 -0600 read the .gdb_index section in the .dwz file and use it the new plan is to put a minimal .gdb_index into the .dwz file it will contain the CU list but not really anything else (however it uses the same format as the existing .gdb_index) commit 81d35f07943ff68f6feabbf7d676c43b7285b898 Author: Tom Tromey <tromey@redhat.com> Date: Tue Jun 5 12:12:26 2012 -0600 run dwz after creating the index commit 4458edafaedbea4f5234f43a4fa3c48d23750804 Author: Tom Tromey <tromey@redhat.com> Date: Tue Jun 5 11:21:03 2012 -0600 revert the previous patch to handle dwz -m in the index Jakub and I agreed on a different way to handle the index for dwz -m. Instead we'll have a .gdb_index in the dwz file that holds a CU list, with most other things being empty ----------------------------------------------------------------------- Summary of changes: gdb/cc-with-tweaks.sh | 14 ++-- gdb/doc/gdb.texinfo | 21 ++----- gdb/dwarf2read.c | 153 +++++++++++++++++++++++++++++++------------------ 3 files changed, 108 insertions(+), 80 deletions(-) First 500 lines of diff: diff --git a/gdb/cc-with-tweaks.sh b/gdb/cc-with-tweaks.sh index dee9b49..719432a 100755 --- a/gdb/cc-with-tweaks.sh +++ b/gdb/cc-with-tweaks.sh @@ -137,13 +137,6 @@ then exit 1 fi -if [ "$want_dwz" = true ]; then - $DWZ "$output_file" > /dev/null 2>&1 -elif [ "$want_multi" = true ]; then - cp $output_file ${output_file}.alt - $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null 2>&1 -fi - if [ "$want_index" = true ]; then $GDB --batch-silent -nx -ex "file $output_file" -ex "save gdb-index $output_dir" rc=$? @@ -162,5 +155,12 @@ if [ "$want_index" = true ]; then [ $rc != 0 ] && exit $rc fi +if [ "$want_dwz" = true ]; then + $DWZ "$output_file" > /dev/null 2>&1 +elif [ "$want_multi" = true ]; then + cp $output_file ${output_file}.alt + $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null 2>&1 +fi + rm -f "$index_file" exit $rc diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e46864a..014cfd8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -40115,23 +40115,16 @@ unless otherwise noted: @enumerate @item -The version number, currently 7. Versions 1, 2 and 3 are obsolete. -Version 4 uses a different hashing function from versions 5 through 7. -Version 6 includes symbols for inlined functions, whereas versions 4 -and 5 do not. Version 7 supports debuginfo in separate @file{.dwz} -files (FIXME: need a reference here). @value{GDBN} will only read -version 4 and 5 indices if the @code{--use-deprecated-index-sections} -option is used. +The version number, currently 6. Versions 1, 2 and 3 are obsolete. +Version 4 uses a different hashing function from versions 5 and 6. +Version 6 includes symbols for inlined functions, whereas versions +4 and 5 do not. @value{GDBN} will only read version 4 and 5 indices +if the @code{--use-deprecated-index-sections} option is used. @item The offset, from the start of the file, of the CU list. @item -The offset, from the start of the file, of the @file{.dwz} CU list. -Note that this area can be empty, in which case this offset will be -equal to the next offset. This field first appeared in version 7. - -@item The offset, from the start of the file, of the types CU list. Note that this area can be empty, in which case this offset will be equal to the next offset. @@ -40157,10 +40150,6 @@ conceptually CUs and type CUs form a single list for the purposes of CU indices. @item -The @file{.dwz} CU list. This is handled in the same way as the CU -list. This section first appeared in version 7. - -@item The types CU list. This is a sequence of triplets of 64-bit little-endian values. In a triplet, the first value is the CU offset, the second value is the type offset in the CU, and the third value is diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 877c835..cbb5d20 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -584,6 +584,7 @@ struct dwz_file struct dwarf2_section_info info; struct dwarf2_section_info str; struct dwarf2_section_info macro; + struct dwarf2_section_info gdb_index; /* The dwz's BFD. */ bfd *dwz_bfd; @@ -1783,6 +1784,11 @@ locate_dwz_sections (bfd *abfd, asection *sectp, void *arg) dwz_file->macro.asection = sectp; dwz_file->macro.size = bfd_get_section_size (sectp); } + else if (section_is_p (sectp->name, &dwarf2_elf_names.gdb_index)) + { + dwz_file->gdb_index.asection = sectp; + dwz_file->gdb_index.size = bfd_get_section_size (sectp); + } } /* Open the separate '.dwz' debug file, if needed. Error if the file @@ -2300,35 +2306,44 @@ find_slot_in_mapped_hash (struct mapped_index *index, const char *name, } } -/* Read the index file. If everything went ok, initialize the "quick" - elements of all the CUs and return 1. Otherwise, return 0. */ +/* A helper function that reads the .gdb_index from SECTION and fills + in MAP. FILENAME is the name of the file containing the section; + it is used for error reporting. DEPRECATED_OK is nonzero if it is + ok to use deprecated sections. + + CU_LIST, CU_LIST_ELEMENTS, TYPES_LIST, and TYPES_LIST_ELEMENTS are + out parameters that are filled in with information about the CU and + TU lists in the section. + + Returns 1 if all went well, 0 otherwise. */ static int -dwarf2_read_index (struct objfile *objfile) +read_index_from_section (struct objfile *objfile, + const char *filename, + int deprecated_ok, + struct dwarf2_section_info *section, + struct mapped_index *map, + const gdb_byte **cu_list, + offset_type *cu_list_elements, + const gdb_byte **types_list, + offset_type *types_list_elements) { char *addr; - struct mapped_index *map; + offset_type version; offset_type *metadata; - const gdb_byte *cu_list; - const gdb_byte *dwz_cu_list = NULL; - const gdb_byte *types_list = NULL; - offset_type version, cu_list_elements; - offset_type dwz_list_elements = 0; - offset_type types_list_elements = 0; int i; - if (dwarf2_section_empty_p (&dwarf2_per_objfile->gdb_index)) + if (dwarf2_section_empty_p (section)) return 0; /* Older elfutils strip versions could keep the section in the main executable while splitting it for the separate debug info file. */ - if ((bfd_get_file_flags (dwarf2_per_objfile->gdb_index.asection) - & SEC_HAS_CONTENTS) == 0) + if ((bfd_get_file_flags (section->asection) & SEC_HAS_CONTENTS) == 0) return 0; - dwarf2_read_section (objfile, &dwarf2_per_objfile->gdb_index); + dwarf2_read_section (objfile, section); - addr = dwarf2_per_objfile->gdb_index.buffer; + addr = section->buffer; /* Version check. */ version = MAYBE_SWAP (*(offset_type *) addr); /* Versions earlier than 3 emitted every copy of a psymbol. This @@ -2341,7 +2356,7 @@ dwarf2_read_index (struct objfile *objfile) if (!warning_printed) { warning (_("Skipping obsolete .gdb_index section in %s."), - objfile->name); + filename); warning_printed = 1; } return 0; @@ -2354,48 +2369,38 @@ dwarf2_read_index (struct objfile *objfile) set breakpoints on inlined functions by name, so we ignore these indices unless the --use-deprecated-index-sections command line option was supplied. */ - if (version < 6 && !use_deprecated_index_sections) + if (version < 6 && !deprecated_ok) { static int warning_printed = 0; if (!warning_printed) { warning (_("Skipping deprecated .gdb_index section in %s, pass " "--use-deprecated-index-sections to use them anyway"), - objfile->name); + filename); warning_printed = 1; } return 0; } /* Indexes with higher version than the one supported by GDB may be no longer backward compatible. */ - if (version > 7) + if (version > 6) return 0; - map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index); map->version = version; - map->total_size = dwarf2_per_objfile->gdb_index.size; + map->total_size = section->size; metadata = (offset_type *) (addr + sizeof (offset_type)); i = 0; - cu_list = addr + MAYBE_SWAP (metadata[i]); - cu_list_elements = ((MAYBE_SWAP (metadata[i + 1]) - MAYBE_SWAP (metadata[i])) - / 8); + *cu_list = addr + MAYBE_SWAP (metadata[i]); + *cu_list_elements = ((MAYBE_SWAP (metadata[i + 1]) - MAYBE_SWAP (metadata[i])) + / 8); ++i; - if (version >= 7) - { - dwz_cu_list = addr + MAYBE_SWAP (metadata[i]); - dwz_list_elements = ((MAYBE_SWAP (metadata[i + 1]) - - MAYBE_SWAP (metadata[i])) - / 8); - ++i; - } - - types_list = addr + MAYBE_SWAP (metadata[i]); - types_list_elements = ((MAYBE_SWAP (metadata[i + 1]) - - MAYBE_SWAP (metadata[i])) - / 8); + *types_list = addr + MAYBE_SWAP (metadata[i]); + *types_list_elements = ((MAYBE_SWAP (metadata[i + 1]) + - MAYBE_SWAP (metadata[i])) + / 8); ++i; map->address_table = addr + MAYBE_SWAP (metadata[i]); @@ -2411,12 +2416,55 @@ dwarf2_read_index (struct objfile *objfile) map->constant_pool = addr + MAYBE_SWAP (metadata[i]); + return 1; +} + + +/* Read the index file. If everything went ok, initialize the "quick" + elements of all the CUs and return 1. Otherwise, return 0. */ + +static int +dwarf2_read_index (struct objfile *objfile) +{ + struct mapped_index local_map, *map; + const gdb_byte *cu_list, *types_list, *dwz_list = NULL; + offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0; + + if (!read_index_from_section (objfile, objfile->name, + use_deprecated_index_sections, + &dwarf2_per_objfile->gdb_index, &local_map, + &cu_list, &cu_list_elements, + &types_list, &types_list_elements)) + return 0; + /* Don't use the index if it's empty. */ - if (map->symbol_table_slots == 0) + if (local_map.symbol_table_slots == 0) return 0; + /* If there is a .dwz file, read it so we can get its CU list as + well. */ + if (bfd_get_section_by_name (objfile->obfd, ".gnu_debugaltlink") != NULL) + { + struct dwz_file *dwz = dwarf2_get_dwz_file (); + struct mapped_index dwz_map; + const gdb_byte *dwz_types_ignore; + offset_type dwz_types_elements_ignore; + + if (!read_index_from_section (objfile, bfd_get_filename (dwz->dwz_bfd), + 1, + &dwz->gdb_index, &dwz_map, + &dwz_list, &dwz_list_elements, + &dwz_types_ignore, + &dwz_types_elements_ignore)) + { + warning (_("could not read '.gdb_index' section from %s; skipping"), + bfd_get_filename (dwz->dwz_bfd)); + return 0; + } + } + if (!create_cus_from_index (objfile, cu_list, cu_list_elements, - dwz_cu_list, dwz_list_elements)) + dwz_list, dwz_list_elements)) return 0; if (types_list_elements) @@ -2437,7 +2485,10 @@ dwarf2_read_index (struct objfile *objfile) return 0; } - create_addrmap_from_index (objfile, map); + create_addrmap_from_index (objfile, &local_map); + + map = obstack_alloc (&objfile->objfile_obstack, sizeof (struct mapped_index)); + *map = local_map; dwarf2_per_objfile->index_table = map; dwarf2_per_objfile->using_index = 1; @@ -17879,7 +17930,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir) struct cleanup *cleanup; char *filename, *cleanup_filename; struct obstack contents, addr_obstack, constant_pool, symtab_obstack; - struct obstack cu_list, dwz_cu_list, types_cu_list; + struct obstack cu_list, types_cu_list; int i; FILE *out_file; struct mapped_symtab *symtab; @@ -17921,9 +17972,6 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir) obstack_init (&cu_list); make_cleanup_obstack_free (&cu_list); - obstack_init (&dwz_cu_list); - make_cleanup_obstack_free (&dwz_cu_list); - obstack_init (&types_cu_list); make_cleanup_obstack_free (&types_cu_list); @@ -17956,7 +18004,6 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir) gdb_byte val[8]; struct psymtab_cu_index_map *map; void **slot; - struct obstack *which_list; if (psymtab->user == NULL) recursively_write_psymbols (objfile, psymtab, symtab, psyms_seen, i); @@ -17969,13 +18016,11 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir) gdb_assert (*slot == NULL); *slot = map; - which_list = per_cu->is_dwz ? &dwz_cu_list : &cu_list; - store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, per_cu->offset.sect_off); - obstack_grow (which_list, val, 8); + obstack_grow (&cu_list, val, 8); store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, per_cu->length); - obstack_grow (which_list, val, 8); + obstack_grow (&cu_list, val, 8); } /* Dump the address map. */ @@ -18003,11 +18048,11 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir) obstack_init (&contents); make_cleanup_obstack_free (&contents); - size_of_contents = 7 * sizeof (offset_type); + size_of_contents = 6 * sizeof (offset_type); total_len = size_of_contents; /* The version number. */ - val = MAYBE_SWAP (7); + val = MAYBE_SWAP (6); obstack_grow (&contents, &val, sizeof (val)); /* The offset of the CU list from the start of the file. */ @@ -18015,11 +18060,6 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir) obstack_grow (&contents, &val, sizeof (val)); total_len += obstack_object_size (&cu_list); - /* The offset of the .dwz CU list from the start of the file. */ - val = MAYBE_SWAP (total_len); - obstack_grow (&contents, &val, sizeof (val)); - total_len += obstack_object_size (&dwz_cu_list); - /* The offset of the types CU list from the start of the file. */ val = MAYBE_SWAP (total_len); obstack_grow (&contents, &val, sizeof (val)); @@ -18044,7 +18084,6 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir) write_obstack (out_file, &contents); write_obstack (out_file, &cu_list); - write_obstack (out_file, &dwz_cu_list); write_obstack (out_file, &types_cu_list); write_obstack (out_file, &addr_obstack); write_obstack (out_file, &symtab_obstack); hooks/post-receive -- Repository for Project Archer.
reply other threads:[~2012-06-05 18:19 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20120605181859.14457.qmail@sourceware.org \ --to=tromey@sourceware.org \ --cc=archer-commits@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).