From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120793 invoked by alias); 6 Sep 2017 18:41:08 -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 120581 invoked by uid 89); 6 Sep 2017 18:41:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_STOCKGEN,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=curiosity, H*M:7d1a X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Sep 2017 18:41:07 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4AC55CE for ; Wed, 6 Sep 2017 18:41:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D4AC55CE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=keiths@redhat.com Received: from valrhona.uglyboxes.com (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 503105D760; Wed, 6 Sep 2017 18:41:05 +0000 (UTC) Subject: Re: [PATCH 1/2] Fix "list ambiguous_variable" To: Pedro Alves , gdb-patches@sourceware.org References: <1504550858-27936-1-git-send-email-palves@redhat.com> <1504550858-27936-2-git-send-email-palves@redhat.com> From: Keith Seitz Message-ID: Date: Wed, 06 Sep 2017 18:41:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1504550858-27936-2-git-send-email-palves@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00163.txt.bz2 On 09/04/2017 11:47 AM, Pedro Alves wrote: > The "list" command allows specifying the name of variables as > argument, not just functions, so that users can type "list > a_global_variable". > > That support is a broken when it comes to ambiguous locations though. Very nice! FWIW, I have only one trivial nit (below). Keith PS. Out of curiosity, I hacked up a test program with multiple symbols named "ambiguous," both functions and variables. Well done! (gdb) set listsize 3 (gdb) list ambiguous file: "amb1.c", line number: 5, symbol: "ambiguous" 4 5 static int ambiguous = 0; 6 file: "amb2.c", line number: 3, symbol: "ambiguous" 2 ambiguous (void) 3 { 4 return 0; file: "amb3.c", line number: 3, symbol: "ambiguous" 2 ambiguous (void) 3 { 4 return 0; file: "amb4.c", line number: 1, symbol: "ambiguous" 1 static int ambiguous = 0; 2 3 int > diff --git a/gdb/linespec.c b/gdb/linespec.c > index 4801808..d72d19d 100644 > --- a/gdb/linespec.c > +++ b/gdb/linespec.c > @@ -4318,35 +4318,45 @@ minsym_found (struct linespec_state *self, struct objfile *objfile, > CORE_ADDR pc; > struct symtab_and_line sal; > > - sal = find_pc_sect_line (MSYMBOL_VALUE_ADDRESS (objfile, msymbol), > - (struct obj_section *) 0, 0); > - sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol); > + if (msymbol_is_text (msymbol)) > + { > + sal = find_pc_sect_line (MSYMBOL_VALUE_ADDRESS (objfile, msymbol), > + (struct obj_section *) 0, 0); > + sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol); > > - /* The minimal symbol might point to a function descriptor; > - resolve it to the actual code address instead. */ > - pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc, ¤t_target); > - if (pc != sal.pc) > - sal = find_pc_sect_line (pc, NULL, 0); > + /* The minimal symbol might point to a function descriptor; > + resolve it to the actual code address instead. */ > + pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc, ¤t_target); This line exceeds the 80-char line length limit. > + if (pc != sal.pc) > + sal = find_pc_sect_line (pc, NULL, 0); > > - if (self->funfirstline) > - { > - if (sal.symtab != NULL > - && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab)) > - || SYMTAB_LANGUAGE (sal.symtab) == language_asm)) > + if (self->funfirstline) > { > - /* If gdbarch_convert_from_func_ptr_addr does not apply then > - sal.SECTION, sal.LINE&co. will stay correct from above. > - If gdbarch_convert_from_func_ptr_addr applies then > - sal.SECTION is cleared from above and sal.LINE&co. will > - stay correct from the last find_pc_sect_line above. */ > - sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol); > - sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc, > - ¤t_target); > - if (gdbarch_skip_entrypoint_p (gdbarch)) > - sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc); > + if (sal.symtab != NULL > + && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab)) > + || SYMTAB_LANGUAGE (sal.symtab) == language_asm)) > + { > + /* If gdbarch_convert_from_func_ptr_addr does not apply then > + sal.SECTION, sal.LINE&co. will stay correct from above. > + If gdbarch_convert_from_func_ptr_addr applies then > + sal.SECTION is cleared from above and sal.LINE&co. will > + stay correct from the last find_pc_sect_line above. */ > + sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol); > + sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc, > + ¤t_target); > + if (gdbarch_skip_entrypoint_p (gdbarch)) > + sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc); > + } > + else > + skip_prologue_sal (&sal); > } > - else > - skip_prologue_sal (&sal); > + } > + else > + { > + sal.objfile = objfile; > + sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol); > + sal.pspace = current_program_space; > + sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol); > } > > if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc))