From: Simon Marchi <simon.marchi@polymtl.ca>
To: John Baldwin <jhb@freebsd.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] Look for separate debug files in debug directories under a sysroot.
Date: Sat, 26 Jan 2019 05:17:00 -0000 [thread overview]
Message-ID: <14397d0976052cba984ffbe8e0a54e37@polymtl.ca> (raw)
In-Reply-To: <efae43ea34de8dfb49dca937f8d0e65cbcde4d5d.1548205042.git.jhb@FreeBSD.org>
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
next prev parent reply other threads:[~2019-01-26 5:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-23 1:04 [PATCH 0/2] Some fixes for debug files and sysroots John Baldwin
2019-01-23 1:04 ` [PATCH 2/2] Trim trailing directory separators from new sysroots John Baldwin
2019-01-26 19:10 ` Simon Marchi
2019-01-28 20:41 ` John Baldwin
2019-01-23 1:04 ` [PATCH 1/2] Look for separate debug files in debug directories under a sysroot John Baldwin
2019-01-26 5:17 ` Simon Marchi [this message]
2019-01-26 17:12 ` Simon Marchi
2019-01-28 18:53 ` John Baldwin
2019-02-22 20:51 ` Simon Marchi
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=14397d0976052cba984ffbe8e0a54e37@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=jhb@freebsd.org \
/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