From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: gdb.base/print-file-var.exp false PASS [Re: [RFA] choose symbol from given block's objfile first.]
Date: Fri, 18 May 2012 17:37:00 -0000 [thread overview]
Message-ID: <20120518173642.GA12978@host2.jankratochvil.net> (raw)
In-Reply-To: <20120518171708.GM10253@adacore.com>
On Fri, 18 May 2012 19:17:08 +0200, Joel Brobecker wrote:
> I really don't know how to read your last sentence, and I am going to
> pretend you did not write it. Please correct me if I misunderstood
> what you are trying to imply.
I think it is clear that if GDB commands prints value X of variable Y then the
inferior program (either running standalone or under GDB) should also evaluate
variable Y as value X.
$ gdb.base/print-file-var-main ;echo $?
0
Therefore inferior sees 'print-file-var-lib2.c'::this_version_id as 104
> > > + if (get_version_2 () != 104)
> > > + return 2;
as otherwise the executable would return 2 (and not 0).
But GDB PASSes if 'print-file-var-lib2.c'::this_version_id is read as 203.
I do not understand this discrepancy between print-file-var.exp and
print-file-var-main.c.
> On the other hand, on Windows, with the same code, the function
> returns 203. So the code is not portable.
I did not remember the MS-Windows platform behavior (Pedro has stated it).
In such case this program returns code 2 (and not 0) on MS-Windows?
> I wonder how things are working on GNU/Linux, because the two shared
> libraries are linked independently, and then the main executable
> does not reference the global variable at all.
As the libraries are build with -fPIC they use .got references:
0000000000000670 <get_version_1>:
[...]
674: 48 8b 05 95 02 20 00 mov 0x200295(%rip),%rax # 200910 <_DYNAMIC+0x1e0>
67b: 8b 00 mov (%rax),%eax
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[22] .data PROGBITS 0000000000200950 000950 000004 00 WA 0 0 4
[20] .got PROGBITS 0000000000200900 000900 000030 08 WA 0 0 8
Relocation section '.rela.dyn' at offset 0x450 contains 9 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000200910 0000000d00000006 R_X86_64_GLOB_DAT 0000000000200950 this_version_id + 0
- in .got
Symbol table '.dynsym' contains 14 entries:
Num: Value Size Type Bind Vis Ndx Name
13: 0000000000200950 4 OBJECT GLOBAL DEFAULT 22 this_version_id
- in .data
And therefore for the first library ld.so resolves the .got reference into
itself but for the second library the .got reference points to the first library's variable.
> I don't know what to do. I can remove the testcase entirely, or
> we can test the target and adjust the expected output based on
> that.
I think it depends how complete/good fix ends up checked in GDB.
> This is still not going to help with the GDB side of things. But
> I don't think that this is a regression. I don't think we have any
> way of knowing which instance of the variable to pick.
This check-in regressed the C example from:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40040
cat >clib.c <<EOH
int var = 1;
int func (void) { return var; }
EOH
cat >cmain.c <<EOH
extern int var; extern int func (void); int main (void) {
var = 2;
return var == func () ? 0 : 1; }
EOH
C="gcc -Wall -g"; $C -o clib.so -shared -fPIC clib.c; $C -o cmain cmain.c ./clib.so
gdb ./cmain
(gdb) b func
(gdb) run
Breakpoint 1, func () at clib.c:6
6 return var;
(gdb) p var
before - matches inferior:
$1 = 2
current - does not match inferior:
$1 = 1
Thanks,
Jan
next prev parent reply other threads:[~2012-05-18 17:37 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 [this message]
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
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=20120518173642.GA12978@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--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