From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: Regression for gdb.fortran/library-module.exp [Re: [RFA] choose symbol from given block's objfile first.]
Date: Mon, 14 May 2012 14:39:00 -0000 [thread overview]
Message-ID: <20120514143927.GB10253@adacore.com> (raw)
In-Reply-To: <20120511072606.GA25458@host2.jankratochvil.net>
> Running gdb/testsuite/gdb.fortran/library-module.exp ...
> -PASS: gdb.fortran/library-module.exp: print var_i in lib
> +FAIL: gdb.fortran/library-module.exp: print var_i in lib
> -PASS: gdb.fortran/library-module.exp: print var_i in main
> +FAIL: gdb.fortran/library-module.exp: print var_i in main
Jan and I discussed this briefly on IRC, and here is what's happening.
The `lib' unit, which is compiled into a shared library, defines
a global named var_i. The main subprogram makes a reference to
that variable. What happens in our case is something that Jan called
copy-relocation. Quoting Jan:
From the naive programmer's point of view there is
single variable. But sure technically there are two
copies of that variable, due to copy-relocation. The
variable located in the .so file is dead and GDB must
not use it. But GDB has some bugs in it. Just
Looking at the debugging information, we indeed see 2 definitions
for that global variable:
. The first one is of course the global variable defined in
the `lib' module:
<1><d6>: Abbrev Number: 3 (DW_TAG_variable)
<d7> DW_AT_name : var_i
<df> DW_AT_MIPS_linkage_name: __lib__var_i
<ec> DW_AT_type : <0xfb>
<f0> DW_AT_external : 1
<f1> DW_AT_location : 9 byte block: 3 f8 8 20 0 0 0 0 0 (DW_OP_addr: 2008f8)
. And then the second instance, which is defined as an external
variable, but within the scope of the main subprogram (that's
the `<2>' on the first line:
<2><c9>: Abbrev Number: 3 (DW_TAG_variable)
<ca> DW_AT_name : var_i
<d2> DW_AT_MIPS_linkage_name: __lib__var_i
<df> DW_AT_type : <0x106>
<e3> DW_AT_external : 1
<e4> DW_AT_declaration : 1
There is no DW_AT_location for the second one, so I assume we go
through the minimal symbol table to get its actual address.
The Fortran implementation is taking advantage of the fact that
the executable is always going to be the first objfile being searched
by ALL_OBJFILES. My patch breaks that assumption. Jan also seems to
think that we may have the same sort of issue with C++ but we do not
have a reproducer.
I had some time to think this over during the weekend, and only see
two solutions:
(1) Back my patch out, which I think would be a real shame;
(2) Conditionalize my patch on the current language. If the current
language is Fortran, then loop over the objfiles as before.
I am a little unhappy about adding a reference to the current
language, but I don't see a way to infer any meaningful
language from the data we have in lookup_symbol_global (we have
the objfile's global block, and a domain_enum).
There is an intermediate solution, which is to always search the
main objfile first, and then the current DSO, and then the rest.
I think that'd be getting a little too complicated to explain to
the average user...
Thoughts?
--
Joel
next prev parent reply other threads:[~2012-05-14 14:39 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-07 22:43 [RFC] choose symbol from given block's objfile first Joel Brobecker
2012-05-08 17:19 ` Tom Tromey
2012-05-09 19:05 ` [RFA] " Joel Brobecker
2012-05-09 19:08 ` Joel Brobecker
2012-05-09 20:15 ` Tom Tromey
2012-05-09 20:40 ` Joel Brobecker
2012-05-09 20:57 ` Tom Tromey
2012-05-09 21:06 ` Joel Brobecker
2012-05-10 13:42 ` Tom Tromey
2012-05-10 16:27 ` checked in: " Joel Brobecker
2012-05-10 17:19 ` Joel Brobecker
2012-05-09 21:48 ` Joel Brobecker
2012-05-09 21:49 ` Joel Brobecker
2012-05-18 16:10 ` gdb.base/print-file-var.exp false PASS [Re: [RFA] choose symbol from given block's objfile first.] Jan Kratochvil
2012-05-18 17:17 ` Joel Brobecker
2012-05-18 17:37 ` Jan Kratochvil
2012-05-09 20:08 ` [RFA] choose symbol from given block's objfile first Tom Tromey
2012-05-11 7:26 ` Regression for gdb.fortran/library-module.exp [Re: [RFA] choose symbol from given block's objfile first.] Jan Kratochvil
2012-05-11 12:25 ` Joel Brobecker
2012-05-14 14:39 ` Joel Brobecker [this message]
2012-05-14 14:52 ` Jan Kratochvil
2012-05-14 15:06 ` Joel Brobecker
2012-05-14 15:15 ` Jan Kratochvil
2012-05-14 16:57 ` Joel Brobecker
2012-05-14 17:05 ` Jan Kratochvil
2012-05-14 17:49 ` Pedro Alves
2012-05-14 17:59 ` Joel Brobecker
2012-05-14 18:07 ` Jan Kratochvil
2012-05-15 13:09 ` Joel Brobecker
2012-05-16 19:57 ` RFC for: "Re: Regression for gdb.fortran/library-module.exp [Re: [RFA] choose symbol from given block's objfile first.]" Joel Brobecker
2012-05-18 17:46 ` Jan Kratochvil
2012-05-28 14:27 ` Joel Brobecker
2012-05-28 16:12 ` Jan Kratochvil
2012-05-29 15:44 ` Joel Brobecker
2012-05-29 15:49 ` Joel Brobecker
2012-05-29 15:56 ` Jan Kratochvil
2012-05-29 16:02 ` Joel Brobecker
2012-05-29 16:12 ` Jan Kratochvil
2012-05-29 16:31 ` Pedro Alves
2012-05-10 14:14 ` [RFC] choose symbol from given block's objfile first Pedro Alves
2012-05-10 14:32 ` Tom Tromey
2012-05-10 14:50 ` Matt Rice
2012-05-10 15:07 ` Pedro Alves
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=20120514143927.GB10253@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=tromey@redhat.com \
/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