From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 88434 invoked by alias); 26 Jan 2019 05:17:03 -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 88414 invoked by uid 89); 26 Jan 2019 05:17:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 26 Jan 2019 05:17:01 +0000 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 x0Q5Gs91010600 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 26 Jan 2019 00:16:59 -0500 Received: by simark.ca (Postfix, from userid 112) id B4E361E7BB; Sat, 26 Jan 2019 00:16:54 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id BAF451E50C; Sat, 26 Jan 2019 00:16:53 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 26 Jan 2019 05:17:00 -0000 From: Simon Marchi To: John Baldwin Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] Look for separate debug files in debug directories under a sysroot. In-Reply-To: References: Message-ID: <14397d0976052cba984ffbe8e0a54e37@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00559.txt.bz2 On 2019-01-22 20:03, John Baldwin wrote: > When an object file is present in a system root, GDB currently looks > for separate debug files under the global debugfile directories. For > example, if the sysroot is set to "/myroot" and hte global debugfile > directory is set to "/usr/lib/debug", GDB will look for a separate > debug file for "/myroot/lib/libc.so.7" in the following paths: > > /myroot/lib/libc.so.7.debug > /myroot/lib/.debug/libc.so.7.debug > /usr/lib/debug//myroot/lib/libc.so.7.debug > /usr/lib/debug/lib/libc.so.7.debug > > However, some system roots include a full system installation > including a nested global debugfile directory under the sysroot. This > patch adds an additional check to support such systems. In the > example above the additional path searched is: > > /myroot/usr/lib/debug/lib/libc.so.7.debug > > To try to preserve existing behavior as much as possible, this new > path is searched last for each global debugfile directory. I played with this a bit using a Raspbian sysroot. I think the behavior you propose makes sense, perhaps more than the current behavior (I would be curious to see a real-word case for that one). But anyway, keeping the old behavior and adding a new one is fine. It's rather cheap to check many possible locations, and since there's a crc check, there's very little chance of loading a wrong separate debug file. As discussed on IRC, we should probably add the same behavior for build-id-based separate debug files. > diff --git a/gdb/symfile.c b/gdb/symfile.c > index 7f800add8c..c6d2c7c537 100644 > --- a/gdb/symfile.c > +++ b/gdb/symfile.c > @@ -1465,6 +1465,25 @@ find_separate_debug_file (const char *dir, > if (separate_debug_file_exists (debugfile, crc32, objfile)) > return debugfile; > } > + > + /* If the file is in the sysroot, try using its base path in the > + sysroot's global debugfile directory. */ > + if (canon_dir != NULL > + && filename_ncmp (canon_dir, gdb_sysroot, > + strlen (gdb_sysroot)) == 0 > + && IS_DIR_SEPARATOR (canon_dir[strlen (gdb_sysroot)])) > + { Is there any reason to duplicate the if above? It looks to be the same as the previous check, so the new code could go in the existing if. > + debugfile = target_prefix ? "target:" : ""; > + debugfile += gdb_sysroot; > + debugfile += debugdir.get (); > + debugfile += (canon_dir + strlen (gdb_sysroot)); > + debugfile += "/"; > + debugfile += debuglink; > + > + if (separate_debug_file_exists (debugfile, crc32, objfile)) > + return debugfile; > + } > + Simon