From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50637 invoked by alias); 9 Jan 2018 09:46:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 50625 invoked by uid 89); 9 Jan 2018 09:46:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=hate, morning, Administrator, our X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Jan 2018 09:46:31 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 424AC117130; Tue, 9 Jan 2018 04:46:30 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Xxn5DahTtCKA; Tue, 9 Jan 2018 04:46:30 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id CCDD1116D3C; Tue, 9 Jan 2018 04:46:29 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 7A4918304F; Tue, 9 Jan 2018 13:46:25 +0400 (+04) Date: Tue, 09 Jan 2018 09:46:00 -0000 From: Joel Brobecker To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: Fix gdb.ada/bp_c_mixed_case.exp (PR gdb/22670) (Re: [PATCH 3/3] Add new gdb.ada/bp_c_mixed_case testcase for PR gdb/22670) Message-ID: <20180109094625.7udsip4v23i4d5no@adacore.com> References: <1515054953-81012-1-git-send-email-brobecker@adacore.com> <1515054953-81012-4-git-send-email-brobecker@adacore.com> <20180108035724.gac5u77znunzhho3@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SW-Source: 2018-01/txt/msg00172.txt.bz2 > > I am wondering why minimal symbols are involved in this case, > > considering that the C file was build with debugging information. > > Shouldn't we be getting the function's address from the partial/full > > symtabs instead? > > AFAIK, GDB always worked this way for linespecs, even before my C++ > wildmatching patches -- we collect symbols from both debug info and > minsyms, and coalesce them by address to avoid duplicates > (linespec.c:add_matching_symbols_to_info). That's true. What surprises me is that, before your patch, we were finding no symbol at all. So we were failing the lookup both with minimal symbols, and within the partial/full symtab. Your patch, IIUC, handles the lookup at the minimal symbol level, which is indeed a good thing. But shouldn't we also be finding that same symbol through the partial/full symtab search? I have a feeling that your minimal symbol patch might be hiding a bug in the search for the symbol, at least from the linespec module. I did a bit of debugging this morning, first with the following snapshot, which is shortly before the wild-matching patch series: commit b346cb961f729e2955391513a5b05eaf02b308ea Author: GDB Administrator Date: Wed Nov 8 00:00:20 2017 +0000 The function iterate_over_all_matching_symtabs finds the function in the bar.c's partial symtab because the matching function is... [&] (const char *symbol_name) { return symbol_name_cmp (symbol_name, name) == 0; }, ... where name, in this case is "MixedCaseFunc" -- The "<>" has been stripped. They got stripped by linespec.c::find_linespec_symbols when it took that name and converted it to a lookup name via: if (state->language->la_language == language_ada) { /* In Ada, the symbol lookups are performed using the encoded name rather than the demangled name. */ ada_lookup_storage = ada_name_for_lookup (name); lookup_name = ada_lookup_storage.c_str (); } else { lookup_name = demangle_for_lookup (name, state->language->la_language, demangle_storage); } In the newer version, find_linespec_symbols gets passed the lookup_name directly, and that lookup_name is now "". Those extra "<...>" are what eventually gets in the way when we compare this lookup_name against the partial's symbols name (in default_symbol_name_matcher, which does an strncmp_iw_with_mode comparison, IIUC). The call to find_linespec_symbols comes from linespace_parse_basic, which has: /* Try looking it up as a function/method. */ find_linespec_symbols (PARSER_STATE (parser), PARSER_RESULT (parser)->file_symtabs, name, PARSER_EXPLICIT (parser)->func_name_match_type, &symbols, &minimal_symbols); I really hate to be stopping the investigation at this point, as I feel I am onto something, but I am running out of time for today. The part where I am not sure yet is whether we should be transforming "name" into a "lookup_name" before calling find_linespec_symbols, or whether we should be handling the angle brackets during the symbol comparison... Or something else entirely! This is still all fairly new to me... Note that I was thinkg we would need to be stripping the executable for us to demonstrate an error, but in fact, this is what happens if I use "print" instead of "break": (gdb) p $1 = {} 0x4024dc With the snapshot prior to the patch series, GDB knows that MixedCaseFunc is a function without parameters, and the expression above means calling it. As I was debugging without having started the inferior, I got the following (expected) error: (gdb) print You can't do that without a process to debug. in the bp_c_mixed_case.exp, we should see GDB telling us that we stopped on our MixedCaseFunc breakpoint while evaluating a function call... Does this make some kind of sense to you? I can get back to this for more digging again tomorrow. Thanks! -- Joel