This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] fix PR gdb/19914
- From: Yunlian Jiang <yunlian at google dot com>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 21 Apr 2016 13:04:39 -0700
- Subject: Re: [PATCH] fix PR gdb/19914
- Authentication-results: sourceware.org; auth=none
- References: <94eb2c0b782e20fcd6053001135e at google dot com> <CAMsPy2vh5ovQUe_vuBJ1bJU4V1r5RUA4_f5+pEN9w_jhNqFuuw at mail dot gmail dot com>
ping?
On Wed, Apr 13, 2016 at 11:18 AM, Yunlian Jiang <yunlian@google.com> wrote:
> I have a updated one. It uses separate_debug_objfile_backlink to get
> the real dwp file name if it is a debug file.
>
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -10835,13 +10835,28 @@ open_and_init_dwp_file (void)
> {
> struct objfile *objfile = dwarf2_per_objfile->objfile;
> struct dwp_file *dwp_file;
> + char *dwp_base_name;
> char *dwp_name;
> bfd *dbfd;
> struct cleanup *cleanups;
>
> /* Try to find first .dwp for the binary file before any symbolic links
> resolving. */
> +
> + /* If the objfile is a debug file, find the name of the real binary
> + file and get the name of dwp file from there. */
> + if (objfile->separate_debug_objfile_backlink)
> + {
> + dwp_base_name = xstrprintf ("%s.dwp",
> + lbasename (objfile->separate_debug_objfile_backlink->original_name));
> + }
> + else
> + dwp_base_name = xstrprintf ("%s.dwp", lbasename (objfile->original_name));
> + dwp_name = xstrprintf ("%s%s%s", ldirname(objfile->original_name),
> + SLASH_STRING, dwp_base_name);
> +
> dwp_name = xstrprintf ("%s.dwp", objfile->original_name);
> + cleanups = make_cleanup (xfree, dwp_base_name);
> cleanups = make_cleanup (xfree, dwp_name);
>
> dbfd = open_dwp_file (dwp_name);
>
> On Fri, Apr 8, 2016 at 3:54 PM, Doug Evans <dje@google.com> wrote:
>> Yunlian Jiang writes:
>> > Hi.
>> >
>> > This tries to fix PR gdb/19914. When the object file is not
>> > a binary but a .debug file, the function to try to find the .dwp
>> > file in the debug directory does not work. This one tries to solve
>> > this problem.
>> >
>> > 2016-04-05 Yunlian Jiang <yunlian@google.com>
>> > * gdb/dwarf2read.c: Try to find .dwp for .debug
>> >
>> >
>> > diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
>> > index dcd49e3..551376a 100644
>> > --- a/gdb/dwarf2read.c
>> > +++ b/gdb/dwarf2read.c
>> > @@ -10854,6 +10854,18 @@ open_and_init_dwp_file (void)
>> > dbfd = open_dwp_file (dwp_name);
>> > }
>> >
>> > + if (dbfd == NULL && strlen(dwp_name) > 10)
>> > + {
>> > + /* Try to find .dwp for the debug file. */
>> > + if (!strcmp(dwp_name + strlen(dwp_name) - 10, ".debug.dwp"))
>> > + {
>> > + dwp_name[strlen(dwp_name) - 10] = '\0';
>> > + dwp_name = xstrprintf ("%s.dwp", dwp_name);
>> > + make_cleanup (xfree, dwp_name);
>> > + dbfd = open_dwp_file (dwp_name);
>> > + }
>> > + }
>> > +
>> > if (dbfd == NULL)
>> > {
>> > if (dwarf_read_debug)
>>
>> Hi.
>>
>> I've looked at this a little bit.
>> I don't have time for a complete review at the moment,
>> but one thing I'm wondering about is whether this extra
>> test should go in open_dwp_file instead.
>>
>> Plus, while we're making the assumption that the separate debug
>> file ends with ".debug" that's not necessarily true.
>> Not sure we can do better, but one thought is to look in
>> separate_debug_objfile_backlink and use that.