From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 444C83858D3C for ; Sun, 14 Nov 2021 02:37:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 444C83858D3C Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 1AE2aTWc002493 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 13 Nov 2021 21:36:34 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 1AE2aTWc002493 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 6BAB41E813; Sat, 13 Nov 2021 21:36:29 -0500 (EST) Message-ID: Date: Sat, 13 Nov 2021 21:36:28 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH 2/3] gdb: Add soname to build-id mapping for corefiles Content-Language: en-US To: Aaron Merey , gdb-patches@sourceware.org Cc: tom@tromey.com, lsix@lancelotsix.com References: <20211110014755.532490-1-amerey@redhat.com> <20211110014755.532490-3-amerey@redhat.com> From: Simon Marchi In-Reply-To: <20211110014755.532490-3-amerey@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sun, 14 Nov 2021 02:36:29 +0000 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Nov 2021 02:37:39 -0000 > @@ -1183,8 +1201,23 @@ linux_read_core_file_mappings > descdata += addr_size; > char * filename = filenames; > filenames += strlen ((char *) filenames) + 1; > + const bfd_build_id *build_id = nullptr; > + auto vma_map_it = vma_map.find (start); > + > + /* Map filename to the build-id associated with this start vma, > + if such a build-id was found. Otherwise use the build-id > + already associated with this filename if it exists. */ > + if (vma_map_it != vma_map.end ()) > + filename_map[filename] = build_id = vma_map_it->second; Please avoid doing two assignments in one statement. > @@ -1586,6 +1587,40 @@ gdb_bfd_scan_elf_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr, > return 0; > } > > +/* See solib.h. */ > + > +gdb::optional > +gdb_bfd_read_elf_soname (struct bfd *bfd) > +{ > + gdb_assert (bfd != nullptr); > + > + gdb_bfd_ref_ptr abfd = gdb_bfd_open (bfd->filename, gnutarget); Can you explain why we are opening bfd->filename? Doesn't "abfd" represent the exact same thing than "bfd"? So why can't we use "bfd" directly to look up the soname? Simon