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: make gdb index work with dwz -m this implementation bumps the gdb index version number it would be possible to do it without a version bump, but perhaps only at some startup expense Date: Tue, 05 Jun 2012 15:28:00 -0000 [thread overview] Message-ID: <20120605152836.30728.qmail@sourceware.org> (raw) The branch, archer-tromey-dwz-multifile has been updated via 04b1a89dbe8be1c7781426e04d54d36b3c097733 (commit) via 90bac389e7112bd547ed6c6e5774d3e333244f8c (commit) from bab04ef9327d560904c75e7d4f302697f852effb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 04b1a89dbe8be1c7781426e04d54d36b3c097733 Author: Tom Tromey <tromey@redhat.com> Date: Tue Jun 5 09:21:49 2012 -0600 make gdb index work with dwz -m this implementation bumps the gdb index version number it would be possible to do it without a version bump, but perhaps only at some startup expense commit 90bac389e7112bd547ed6c6e5774d3e333244f8c Author: Tom Tromey <tromey@redhat.com> Date: Tue Jun 5 07:32:12 2012 -0600 allow index and multi-file at the same time clean up the coding style to match what was there before ----------------------------------------------------------------------- Summary of changes: gdb/cc-with-tweaks.sh | 21 +++++------ gdb/doc/gdb.texinfo | 21 ++++++++--- gdb/dwarf2read.c | 92 +++++++++++++++++++++++++++++++++++++----------- 3 files changed, 97 insertions(+), 37 deletions(-) First 500 lines of diff: diff --git a/gdb/cc-with-tweaks.sh b/gdb/cc-with-tweaks.sh index bd23c7d..dee9b49 100755 --- a/gdb/cc-with-tweaks.sh +++ b/gdb/cc-with-tweaks.sh @@ -39,7 +39,6 @@ # -m compress using dwz -m # -i make an index # If nothing is given, -i is assumed. -# For now, -i and -m are incompatible; if both are given, -m is ignored. myname=cc-with-tweaks.sh @@ -72,7 +71,7 @@ want_index=false want_dwz=false want_multi=false -while test $# -gt 0; do +while [ $# -gt 0 ]; do case "$1" in -z) want_dwz=true ;; -i) want_index=true ;; @@ -82,7 +81,7 @@ while test $# -gt 0; do shift done -if test "$want_index" = false && test "$want_dwz" = false && test "$want_multi" = false; then +if [ "$want_index" = false ] && [ "$want_dwz" = false ] && [ "$want_multi" = false ]; then want_index=true fi @@ -138,7 +137,14 @@ then exit 1 fi -if test "$want_index" = true; then +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=$? [ $rc != 0 ] && exit $rc @@ -156,12 +162,5 @@ if test "$want_index" = true; then [ $rc != 0 ] && exit $rc fi -if test "$want_dwz" = true; then - $DWZ "$output_file" > /dev/null 2>&1 -elif test "$want_multi" = true && test "$want_index" = false; 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 014cfd8..e46864a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -40115,16 +40115,23 @@ unless otherwise noted: @enumerate @item -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. +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. @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. @@ -40150,6 +40157,10 @@ 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 87eeac7..877c835 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2045,23 +2045,19 @@ extract_cu_value (const char *bytes, ULONGEST *result) return 1; } -/* Read the CU list from the mapped index, and use it to create all - the CU objects for this objfile. Return 0 if something went wrong, - 1 if everything went ok. */ +/* A helper for create_cus_from_index that handles a given list of + CUs. */ static int -create_cus_from_index (struct objfile *objfile, const gdb_byte *cu_list, - offset_type cu_list_elements) +create_cus_from_index_list (struct objfile *objfile, + const gdb_byte *cu_list, offset_type n_elements, + struct dwarf2_section_info *section, + int is_dwz, + int base_offset) { offset_type i; - dwarf2_per_objfile->n_comp_units = cu_list_elements / 2; - dwarf2_per_objfile->all_comp_units - = obstack_alloc (&objfile->objfile_obstack, - dwarf2_per_objfile->n_comp_units - * sizeof (struct dwarf2_per_cu_data *)); - - for (i = 0; i < cu_list_elements; i += 2) + for (i = 0; i < n_elements; i += 2) { struct dwarf2_per_cu_data *the_cu; ULONGEST offset, length; @@ -2076,15 +2072,45 @@ create_cus_from_index (struct objfile *objfile, const gdb_byte *cu_list, the_cu->offset.sect_off = offset; the_cu->length = length; the_cu->objfile = objfile; - the_cu->info_or_types_section = &dwarf2_per_objfile->info; + the_cu->info_or_types_section = section; the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwarf2_per_cu_quick_data); - dwarf2_per_objfile->all_comp_units[i / 2] = the_cu; + the_cu->is_dwz = is_dwz; + dwarf2_per_objfile->all_comp_units[base_offset + i / 2] = the_cu; } return 1; } +/* Read the CU list from the mapped index, and use it to create all + the CU objects for this objfile. Return 0 if something went wrong, + 1 if everything went ok. */ + +static int +create_cus_from_index (struct objfile *objfile, + const gdb_byte *cu_list, offset_type cu_list_elements, + const gdb_byte *dwz_list, offset_type dwz_elements) +{ + struct dwz_file *dwz; + + dwarf2_per_objfile->n_comp_units = (cu_list_elements + dwz_elements) / 2; + dwarf2_per_objfile->all_comp_units + = obstack_alloc (&objfile->objfile_obstack, + dwarf2_per_objfile->n_comp_units + * sizeof (struct dwarf2_per_cu_data *)); + + if (!create_cus_from_index_list (objfile, cu_list, cu_list_elements, + &dwarf2_per_objfile->info, 0, 0)) + return 0; + + if (dwz_elements == 0) + return 1; + + dwz = dwarf2_get_dwz_file (); + return create_cus_from_index_list (objfile, dwz_list, dwz_elements, + &dwz->info, 1, cu_list_elements / 2); +} + /* Create the signatured type hash table from the index. */ static int @@ -2284,8 +2310,10 @@ dwarf2_read_index (struct objfile *objfile) struct mapped_index *map; 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; @@ -2340,7 +2368,7 @@ dwarf2_read_index (struct objfile *objfile) } /* Indexes with higher version than the one supported by GDB may be no longer backward compatible. */ - if (version > 6) + if (version > 7) return 0; map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index); @@ -2355,6 +2383,15 @@ dwarf2_read_index (struct objfile *objfile) / 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])) @@ -2378,7 +2415,8 @@ dwarf2_read_index (struct objfile *objfile) if (map->symbol_table_slots == 0) return 0; - if (!create_cus_from_index (objfile, cu_list, cu_list_elements)) + if (!create_cus_from_index (objfile, cu_list, cu_list_elements, + dwz_cu_list, dwz_list_elements)) return 0; if (types_list_elements) @@ -17841,7 +17879,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, types_cu_list; + struct obstack cu_list, dwz_cu_list, types_cu_list; int i; FILE *out_file; struct mapped_symtab *symtab; @@ -17883,6 +17921,9 @@ 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); @@ -17915,6 +17956,7 @@ 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); @@ -17927,11 +17969,13 @@ 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 (&cu_list, val, 8); + obstack_grow (which_list, val, 8); store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, per_cu->length); - obstack_grow (&cu_list, val, 8); + obstack_grow (which_list, val, 8); } /* Dump the address map. */ @@ -17959,11 +18003,11 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir) obstack_init (&contents); make_cleanup_obstack_free (&contents); - size_of_contents = 6 * sizeof (offset_type); + size_of_contents = 7 * sizeof (offset_type); total_len = size_of_contents; /* The version number. */ - val = MAYBE_SWAP (6); + val = MAYBE_SWAP (7); obstack_grow (&contents, &val, sizeof (val)); /* The offset of the CU list from the start of the file. */ @@ -17971,6 +18015,11 @@ 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)); @@ -17995,6 +18044,7 @@ 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 15:28 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=20120605152836.30728.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).