From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27372 invoked by alias); 8 Jan 2017 17:14:53 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 27354 invoked by uid 9674); 8 Jan 2017 17:14:52 -0000 Date: Sun, 08 Jan 2017 17:14:00 -0000 Message-ID: <20170108171452.27320.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] users/jkratoch/dwarf5readelf-indexcxx-debugnames: Merge branch 'readelf-indexcxx' into readelf-indexcxx-debugnames X-Git-Refname: refs/heads/users/jkratoch/dwarf5readelf-indexcxx-debugnames X-Git-Reftype: branch X-Git-Oldrev: ec55f88e5cd29bb9555047ed5986dfb88635cb4a X-Git-Newrev: 3957561029ae9cf78a9c49d2d2ffd3d3a851f0c3 X-SW-Source: 2017-q1/txt/msg00018.txt.bz2 List-Id: The branch, users/jkratoch/dwarf5readelf-indexcxx-debugnames has been updated via 3957561029ae9cf78a9c49d2d2ffd3d3a851f0c3 (commit) via 1e6c233542e6ebe2cc73462915fabcf5ac965a74 (commit) via 8955e1475d36a84b6f8e47c86bfb1ddd4a00346d (commit) via 29c2d15aad8dc2970384cdbd5a449cecd64798fc (commit) via f5e6296e2194add209b546ad49039753a10242f5 (commit) via 2efa21564b81bd6d8a7ee23c2868a4bd6749b11c (commit) via 580271f16638f582525b000fd687fa96f9f285ba (commit) via 431e5de3f224e94fb0d061edb3a56d8e3c3f4403 (commit) from ec55f88e5cd29bb9555047ed5986dfb88635cb4a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 3957561029ae9cf78a9c49d2d2ffd3d3a851f0c3 Merge: 29c2d15 1e6c233 Author: Jan Kratochvil Date: Sun Jan 8 18:13:38 2017 +0100 Merge branch 'readelf-indexcxx' into readelf-indexcxx-debugnames commit 29c2d15aad8dc2970384cdbd5a449cecd64798fc Author: Jan Kratochvil Date: Sun Jan 8 16:45:25 2017 +0100 . commit 580271f16638f582525b000fd687fa96f9f285ba Author: Jan Kratochvil Date: Sat Jan 7 22:51:39 2017 +0100 . ----------------------------------------------------------------------- Summary of changes: bfd/elf64-s390.c | 12 +++ bfd/version.h | 2 +- binutils/dwarf.c | 39 +++++++--- gdb/ChangeLog | 4 + gdb/d-exp.y | 9 +-- gdb/dwarf2read.c | 128 +++++++++++++++++++++----------- gdb/testsuite/ChangeLog | 4 + gdb/testsuite/gdb.dlang/debug-expr.exp | 40 ++++++++++ 8 files changed, 176 insertions(+), 62 deletions(-) create mode 100644 gdb/testsuite/gdb.dlang/debug-expr.exp First 500 lines of diff: diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index bbfcd2e..edc9b86 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -2701,6 +2701,18 @@ elf_s390_relocate_section (bfd *output_bfd, case R_390_PC32: case R_390_PC32DBL: case R_390_PC64: + if (h != NULL + && bfd_link_pie (info) + && !h->def_regular) + { + _bfd_error_handler (_("%B: `%s' non-PLT reloc for symbol defined " + "in shared library and accessed " + "from executable " + "(rebuild file with -fPIC ?)"), + input_bfd, h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } /* The target of these relocs are instruction operands residing in read-only sections. We cannot emit a runtime reloc for it. */ diff --git a/bfd/version.h b/bfd/version.h index f2b6007..589838e 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -1,4 +1,4 @@ -#define BFD_VERSION_DATE 20170107 +#define BFD_VERSION_DATE 20170108 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ #define REPORT_BUGS_TO @report_bugs_to@ diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 75af30d..15bc131 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -7025,22 +7025,37 @@ display_debug_names (struct dwarf_section *section, void *file) ? ((const uint64_t *) name_table_entry_offsets)[namei] : ((const uint32_t *) name_table_entry_offsets)[namei]); - printf ("[%3u] %s:", namei, fetch_indirect_string (string_offset)); + printf ("[%3u] #%08x %s:", namei, hash_table_hashes[namei], + fetch_indirect_string (string_offset)); unsigned char *entryptr = entry_pool + entry_offset; - unsigned tagno; - for (tagno = 0;; tagno++) + // We need to scan first whether there is a single or multiple + // entries. TAGNO is -2 for the first entry, it is -1 for the + // initial tag read of the second entry, then it becomes 0 for the + // first entry for real printing etc. + int tagno = -2; + dwarf_vma second_abbrev_tag; + for (;;) { unsigned int bytes_read; const dwarf_vma abbrev_tag = read_uleb128 (entryptr, &bytes_read, unit_end); entryptr += bytes_read; + if (tagno == -1) + { + second_abbrev_tag = abbrev_tag; + tagno = 0; + entryptr = entry_pool + entry_offset; + continue; + } if (abbrev_tag == 0) break; - printf ("%c<%lu>", (tagno == 0 ? ' ' : '\n'), - (unsigned long) abbrev_tag); - + if (tagno >= 0) + printf ("%s<%lu>", + (tagno == 0 && second_abbrev_tag == 0 ? " " : "\n\t"), + (unsigned long) abbrev_tag); + const struct abbrev_lookup_entry *entry; for (entry = abbrev_lookup; entry < abbrev_lookup + abbrev_lookup_used; @@ -7059,7 +7074,8 @@ display_debug_names (struct dwarf_section *section, void *file) const dwarf_vma dwarf_tag = read_uleb128 (abbrevptr, &bytes_read, abbrev_table_end); abbrevptr += bytes_read; - printf (" %s", get_TAG_name (dwarf_tag)); + if (tagno >= 0) + printf (" %s", get_TAG_name (dwarf_tag)); for (;;) { const dwarf_vma index = read_uleb128 (abbrevptr, &bytes_read, @@ -7071,15 +7087,18 @@ display_debug_names (struct dwarf_section *section, void *file) if (index == 0 && form == 0) break; - printf (" %s", get_IDX_name (index)); + if (tagno >= 0) + printf (" %s", get_IDX_name (index)); entryptr = read_and_display_attr_value (0, form, entryptr, unit_end, 0, 0, offset_size, dwarf_version, NULL, - 0, NULL, NULL, '='); + (tagno < 0), NULL, + NULL, '='); } + ++tagno; } - if (tagno == 0) + if (tagno <= 0) printf (_(" ")); putchar ('\n'); } diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fec9974..7f16a5f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2017-01-08 Iain Buclaw + + * d-exp.y (CastExpression): Emit UNOP_CAST_TYPE. + 2017-01-06 Yao Qi * x86-linux-nat.h: Include gdb_proc_service.h. diff --git a/gdb/d-exp.y b/gdb/d-exp.y index 077e645..b526575 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -321,15 +321,12 @@ UnaryExpression: CastExpression: CAST_KEYWORD '(' TypeExp ')' UnaryExpression - { write_exp_elt_opcode (pstate, UNOP_CAST); - write_exp_elt_type (pstate, $3); - write_exp_elt_opcode (pstate, UNOP_CAST); } + { write_exp_elt_opcode (pstate, UNOP_CAST_TYPE); } /* C style cast is illegal D, but is still recognised in the grammar, so we keep this around for convenience. */ | '(' TypeExp ')' UnaryExpression - { write_exp_elt_opcode (pstate, UNOP_CAST); - write_exp_elt_type (pstate, $2); - write_exp_elt_opcode (pstate, UNOP_CAST); } + { write_exp_elt_opcode (pstate, UNOP_CAST_TYPE); } + ; PowExpression: diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index b65813a..32ab341 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -77,6 +77,7 @@ #include #include #include +#include typedef struct symbol *symbolp; DEF_VEC_P (symbolp); @@ -22827,6 +22828,7 @@ public: { return !strcmp (cstr, other.cstr); } + operator const char * () const { return cstr; } }; namespace std { @@ -23197,19 +23199,21 @@ public: class IndexKey { public: - int tag; - bool is_static; - IndexKey (int tag_, bool is_static_):tag(tag_), is_static (is_static_) {} + const int dwarf_tag; + const bool is_static; + IndexKey (int dwarf_tag_, bool is_static_) + :dwarf_tag (dwarf_tag_), is_static (is_static_) + {} bool operator == (const IndexKey &other) const { - return tag == other.tag && is_static == other.is_static; + return dwarf_tag == other.dwarf_tag && is_static == other.is_static; } }; namespace std { template<> struct hash { size_t operator() (const IndexKey &key) const { - return (std::hash() (key.tag) << 1) | key.is_static; + return (std::hash() (key.dwarf_tag) << 1) | key.is_static; } }; } @@ -23217,17 +23221,35 @@ namespace std { class DebugNamesNameTable { private: - class Name + class Param { public: - const char *name; - int tag, cu_index; + int dwarf_tag, cu_index; bool is_static; - Name(const char *name_, int tag_, int cu_index_, bool is_static_) - :name(name_), tag(tag_), cu_index(cu_index_), is_static (is_static_) + Param (int dwarf_tag_, int cu_index_, bool is_static_) + :dwarf_tag (dwarf_tag_), cu_index (cu_index_), is_static (is_static_) {} + bool operator < (const Param &other) const + { +#define X(n) \ + do \ + { \ + if (n < other.n) \ + return true; \ + if (n > other.n) \ + return false; \ + } \ + while (0) + X (dwarf_tag); + X (is_static); + X (cu_index); +#undef X + return false; + } }; - std::unordered_multimap hash_to_name; + std::unordered_map> name_to_param_set; + std::unordered_multimap hash_to_nameit; std::vector bucket_table; std::vector hash_table; class OffsetVec @@ -23345,58 +23367,74 @@ public: void insert (const partial_symbol *psym, int cu_index, bool is_static) { - const int tag (psymbol_tag (psym)); - if (!tag) + const int dwarf_tag (psymbol_tag (psym)); + if (!dwarf_tag) return; - const char *name (SYMBOL_SEARCH_NAME (psym)); - const uint32_t hash - (djb_hash (reinterpret_cast (name))); - hash_to_name.emplace (hash, Name (name, psymbol_tag (psym), cu_index, - is_static)); + const char *const name (SYMBOL_SEARCH_NAME (psym)); + const auto insertpair (name_to_param_set.emplace (CstrView (name), + std::set ())); + if (insertpair.second) + { + const unsigned char *const nameuc = + reinterpret_cast (name); + hash_to_nameit.emplace (djb_hash (nameuc), insertpair.first); + } + std::set ¶m_set (insertpair.first->second); + param_set.emplace (Param (dwarf_tag, cu_index, is_static)); } void build () { gdb_assert (bucket_table.empty ()); + gdb_assert (name_to_param_set.size () == hash_to_nameit.size ()); + const size_t name_count (name_to_param_set.size ()); bucket_table.resize - (std::pow (2, std::ceil (std::log2 (hash_to_name.size () * 4 / 3)))); - hash_table.reserve (hash_to_name.size ()); - name_table_string_offs.reserve (hash_to_name.size ()); - name_table_entry_offs.reserve (hash_to_name.size ()); - for (const auto &it:hash_to_name) + (std::pow (2, std::ceil (std::log2 (name_count * 4 / 3)))); + hash_table.reserve (name_count); + name_table_string_offs.reserve (name_count); + name_table_entry_offs.reserve (name_count); + for (const auto &it:hash_to_nameit) { const uint32_t hash (it.first); - const Name &name (it.second); + const auto nameit (it.second); uint32_t &bucket_slot (bucket_table[hash % bucket_table.size ()]); // The hashes array is indexed starting at 1. if (!bucket_slot) bucket_slot = hash_table.size () + 1; hash_table.push_back (hash); - name_table_string_offs.push_back (debugstrlookup.lookup (name.name)); + const CstrView &name (nameit->first); + const std::set ¶m_set (nameit->second); + name_table_string_offs.push_back (debugstrlookup.lookup (name)); name_table_entry_offs.push_back (entry_pool.size ()); - int &idx (indexkey_to_idx[IndexKey (name.tag, name.is_static)]); - if (!idx) { - idx = idx_next++; - // DW_TAG_* numerical value is used also as the value of the index tag. - abbrev_table.add_unsigned_leb128 (idx); - abbrev_table.add_unsigned_leb128 (name.tag); - abbrev_table.add_unsigned_leb128 (DW_IDX_compile_unit); - abbrev_table.add_unsigned_leb128 (DW_FORM_udata); - abbrev_table.add_unsigned_leb128 (name.is_static - ? DW_IDX_GNU_static - : DW_IDX_GNU_external); - abbrev_table.add_unsigned_leb128 (DW_FORM_flag_present); - // Terminate attributes list. - abbrev_table.add_unsigned_leb128 (0); - abbrev_table.add_unsigned_leb128 (0); - } - // DW_TAG_* numerical value is used also as the value of the index tag. - entry_pool.add_unsigned_leb128 (idx); - entry_pool.add_unsigned_leb128 (name.cu_index); + gdb_assert (!param_set.empty()); + for (const Param ¶m:param_set) + { + int &idx (indexkey_to_idx[IndexKey (param.dwarf_tag, + param.is_static)]); + if (!idx) { + idx = idx_next++; + // DW_TAG_* numerical value is used also as the value of + // the index tag. + abbrev_table.add_unsigned_leb128 (idx); + abbrev_table.add_unsigned_leb128 (param.dwarf_tag); + abbrev_table.add_unsigned_leb128 (DW_IDX_compile_unit); + abbrev_table.add_unsigned_leb128 (DW_FORM_udata); + abbrev_table.add_unsigned_leb128 (param.is_static + ? DW_IDX_GNU_static + : DW_IDX_GNU_external); + abbrev_table.add_unsigned_leb128 (DW_FORM_flag_present); + // Terminate attributes list. + abbrev_table.add_unsigned_leb128 (0); + abbrev_table.add_unsigned_leb128 (0); + } + // DW_TAG_* numerical value is used also as the value of the index tag. + entry_pool.add_unsigned_leb128 (idx); + entry_pool.add_unsigned_leb128 (param.cu_index); + } // Terminate the list of CUs. entry_pool.add_unsigned_leb128 (0); } - gdb_assert (hash_table.size () == hash_to_name.size ()); + gdb_assert (hash_table.size () == name_count); // Terminate tags list. abbrev_table.add_unsigned_leb128 (0); } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index d12072b..8a03282 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-01-08 Iain Buclaw + + * gdb.dlang/debug-expr.exp: New file. + 2016-12-23 Luis Machado Fix test names for the following files: diff --git a/gdb/testsuite/gdb.dlang/debug-expr.exp b/gdb/testsuite/gdb.dlang/debug-expr.exp new file mode 100644 index 0000000..d62dcc6 --- /dev/null +++ b/gdb/testsuite/gdb.dlang/debug-expr.exp @@ -0,0 +1,40 @@ +# Copyright 2017 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test "set debug expr 1" on d expressions. + +if { [skip_d_tests] } { return -1 } + +gdb_start +gdb_test_no_output "set language d" +gdb_test_no_output "set debug expression 1" + +# Test whether the expression debug machinery accepts the expression. + +proc test_debug_expr { cmd output } { + global gdb_prompt + + gdb_test_multiple $cmd "" { + -re ".*Invalid expression.*\r\n$gdb_prompt $" { + fail $cmd + } + -re ".*\[\r\n\]$output\r\n$gdb_prompt $" { + pass $cmd + } + } +} + +# This caused gdb to segfault. +test_debug_expr "print *(int*)(0)" "Cannot access memory at address 0x0" hooks/post-receive -- Repository for Project Archer.