public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 4/4] Fix parameter-less template regression in new DWARF reader
Date: Tue, 17 Jan 2023 13:09:44 -0500	[thread overview]
Message-ID: <df430f61-e778-6d22-3baf-fb27a1952d06@simark.ca> (raw)
In-Reply-To: <20230110183338.2623088-5-tromey@adacore.com>

On 1/10/23 13:33, Tom Tromey via Gdb-patches wrote:
> PR c++/29896 points out a regression in the new DWARF reader.  It does
> not properly handle a case like "break fn", where "fn" is a template
> function.
> 
> This happens because the new index uses strncasecmp to compare.
> However, to make this work correctly, we need a custom function that
> ignores template parameters.
> 
> This patch adds a custom comparison function and fixes the bug.  A new
> test case is included.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29896

Starting with this patch, I get (using _GLIBCXX_DEBUG):

$83 = {void (void)} 0x555555556a82 <flubber<short, int, short, int, short>()>
(gdb) PASS: gdb.cp/cpexprs-debug-types.exp: print flubber<short, int, short, int, short>
print policy1::function
/usr/include/c++/11/bits/stl_algo.h:2105:
In function:
    _FIter std::upper_bound(_FIter, _FIter, const _Tp&, _Compare) [with
    _FIter = gnu_debug::_Safe_iterator<gnu_cxx::
    normal_iterator<cooked_index_entry**, std::vector<cooked_index_entry*,
    std::allocator<cooked_index_entry*> > >, std::
    debug::vector<cooked_index_entry*>, std::random_access_iterator_tag>;
    _Tp = std::cxx11::basic_string<char>; _Compare =
    cooked_index::find(const string&, bool)::<lambda(const string&, const
    cooked_index_entry*)>]

Error: elements in iterator range [first, last) are not partitioned by the
predicate __comp and value __val.

Objects involved in the operation:
    iterator "first" @ 0x7ffcb7cf5430 {
      type = gnu_cxx::normal_iterator<cooked_index_entry**, std::vector<cooked_index_entry*, std::allocator<cooked_index_entry*> > > (mutable iterator);
      state = dereferenceable (start-of-sequence);
      references sequence with type 'std::debug::vector<cooked_index_entry*, std::allocator<cooked_index_entry*> >' @ 0x611000098758
    }
    iterator "last" @ 0x7ffcb7cf5480 {
      type = gnu_cxx::normal_iterator<cooked_index_entry**, std::vector<cooked_index_entry*, std::allocator<cooked_index_entry*> > > (mutable iterator);
      state = past-the-end;
      references sequence with type 'std::debug::vector<cooked_index_entry*, std::allocator<cooked_index_entry*> >' @ 0x611000098758
    }


Fatal signal: Aborted
----- Backtrace -----
0x560e18f13e2f gdb_internal_backtrace_1
        /home/smarchi/src/binutils-gdb/gdb/bt-utils.c:122
0x560e18f14325 _Z22gdb_internal_backtracev
        /home/smarchi/src/binutils-gdb/gdb/bt-utils.c:168
0x560e19b71251 handle_fatal_signal
        /home/smarchi/src/binutils-gdb/gdb/event-top.c:956
0x7f0ac36a251f ???
0x7f0ac36f6a7c ???
0x7f0ac36a2475 ???
0x7f0ac36887f2 ???
0x7f0ac4069240 ???
0x560e1956f665 upper_bound<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<cooked_index_entry**, std::__cxx1998::vector<cooked_index_entry*, std::allocator<cooked_index_entry*> > >, std::__debug::vector<cooked_index_entry*>, std::random_access_iterator_tag>, std::__cxx11::basic_string<char>, cooked_index::find(const string&, bool)::<lambda(const string&, const cooked_index_entry*)> >
        /usr/include/c++/11/bits/stl_algo.h:2105
0x560e1956bd41 _ZN12cooked_index4findERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb
        /home/smarchi/src/binutils-gdb/gdb/dwarf2/cooked-index.c:376
0x560e1956d664 _ZN19cooked_index_vector4findERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb
        /home/smarchi/src/binutils-gdb/gdb/dwarf2/cooked-index.c:421
0x560e198a9748 _ZN22cooked_index_functions23expand_symtabs_matchingEP7objfileN3gdb13function_viewIFbPKcbEEEPK16lookup_name_infoNS3_IFbS5_EEENS3_IFbP15compunit_symtabEEE10enum_flagsI24block_search_flag_valuesE11domain_enum13search_domain
        /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:18747
0x560e1adc12c6 _ZN7objfile13lookup_symbolE10block_enumPKc11domain_enum
        /home/smarchi/src/binutils-gdb/gdb/symfile-debug.c:276
0x560e1ae99109 lookup_symbol_via_quick_fns
        /home/smarchi/src/binutils-gdb/gdb/symtab.c:2414
0x560e1ae99c80 lookup_symbol_in_objfile
        /home/smarchi/src/binutils-gdb/gdb/symtab.c:2543
0x560e1ae9a10a operator()
        /home/smarchi/src/binutils-gdb/gdb/symtab.c:2589
0x560e1aecff72 operator()
        /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/function-view.h:305
0x560e1aed000c _FUN
        /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/function-view.h:299
0x560e1a5cb694 _ZNK3gdb13function_viewIFbP7objfileEEclES2_
        /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/function-view.h:289
0x560e1ac74071 svr4_iterate_over_objfiles_in_search_order
        /home/smarchi/src/binutils-gdb/gdb/solib-svr4.c:3456
0x560e18b8b7a1 _Z45gdbarch_iterate_over_objfiles_in_search_orderP7gdbarchN3gdb13function_viewIFbP7objfileEEES4_
        /home/smarchi/src/binutils-gdb/gdb/gdbarch.c:4981
0x560e1ae9a8b3 lookup_global_or_static_symbol
        /home/smarchi/src/binutils-gdb/gdb/symtab.c:2586
0x560e1ae9ade2 _Z20lookup_global_symbolPKcPK5block11domain_enum
        /home/smarchi/src/binutils-gdb/gdb/symtab.c:2641
0x560e193f3f86 cp_basic_lookup_symbol
        /home/smarchi/src/binutils-gdb/gdb/cp-namespace.c:155
0x560e193fba75 cp_lookup_nested_symbol_1
        /home/smarchi/src/binutils-gdb/gdb/cp-namespace.c:884
0x560e193fc85a _Z23cp_lookup_nested_symbolP4typePKcPK5block11domain_enum
        /home/smarchi/src/binutils-gdb/gdb/cp-namespace.c:975
0x560e1900fcb0 classify_inner_name
        /home/smarchi/src/binutils-gdb/gdb/c-exp.y:3172
0x560e1901136e c_yylex
        /home/smarchi/src/binutils-gdb/gdb/c-exp.y:3322
0x560e18fe729c _Z9c_yyparsev
        /home/smarchi/build/binutils-gdb/gdb/c-exp.c.tmp:2023
0x560e1901349a _Z7c_parseP12parser_state
        /home/smarchi/src/binutils-gdb/gdb/c-exp.y:3420
0x560e1a096ec5 _ZNK13language_defn6parserEP12parser_state
        /home/smarchi/src/binutils-gdb/gdb/language.c:618
0x560e1a637374 parse_exp_in_context
        /home/smarchi/src/binutils-gdb/gdb/parse.c:515
0x560e1a637b81 _Z16parse_expressionPKcP23innermost_block_trackerb
        /home/smarchi/src/binutils-gdb/gdb/parse.c:551
0x560e1a64ea7c process_print_command_args
        /home/smarchi/src/binutils-gdb/gdb/printcmd.c:1305
0x560e1a64ec7c print_command_1
        /home/smarchi/src/binutils-gdb/gdb/printcmd.c:1319
0x560e1a64fb18 print_command
        /home/smarchi/src/binutils-gdb/gdb/printcmd.c:1452

Simon

  parent reply	other threads:[~2023-01-17 18:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 18:33 [PATCH v2 0/4] Fix " Tom Tromey
2023-01-10 18:33 ` [PATCH v2 1/4] Avoid submitting empty tasks in parallel_for_each Tom Tromey
2023-01-14  6:03   ` Joel Brobecker
2023-01-10 18:33 ` [PATCH v2 2/4] Don't erase empty indices in DWARF reader Tom Tromey
2023-01-14  6:05   ` Joel Brobecker
2023-01-17 13:53     ` Tom Tromey
2023-01-10 18:33 ` [PATCH v2 3/4] Move hash_entry and eq_entry into cooked_index::do_finalize Tom Tromey
2023-01-14  6:06   ` Joel Brobecker
2023-01-10 18:33 ` [PATCH v2 4/4] Fix parameter-less template regression in new DWARF reader Tom Tromey
2023-01-14  6:11   ` Joel Brobecker
2023-01-17 13:54     ` Tom Tromey
2023-01-17 16:44     ` Tom de Vries
2023-01-17 18:46       ` Tom Tromey
2023-01-17 18:09   ` Simon Marchi [this message]
2023-01-17 19:39     ` Tom Tromey
2023-01-27  5:47       ` Simon Marchi
2023-01-27 10:15         ` Andrew Burgess
2023-01-27 14:30           ` Tom Tromey
2023-01-27 19:57             ` Tom Tromey

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=df430f61-e778-6d22-3baf-fb27a1952d06@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    /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: link
Be 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).