This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb.base/print-file-var.exp false PASS [Re: [RFA] choose symbol from given block's objfile first.]


On Fri, May 18, 2012 at 06:10:08PM +0200, Jan Kratochvil wrote:
> On Wed, 09 May 2012 23:48:56 +0200, Joel Brobecker wrote:
> > +++ b/gdb/testsuite/gdb.base/print-file-var-lib1.c
> [..]
> > +int this_version_id = 104;
> > +
> > +int
> > +get_version_1 (void)
> > +{
> > +  return this_version_id;
> > +}
> [...]
> > +++ b/gdb/testsuite/gdb.base/print-file-var-lib2.c
> [...]
> > +int this_version_id = 203;
> > +
> > +int
> > +get_version_2 (void)
> > +{
> > +  return this_version_id;
> > +}
> [...]
> > +++ b/gdb/testsuite/gdb.base/print-file-var-main.c
> [...]
> > +int
> > +main (void)
> > +{
> > +  if (get_version_1 () != 104)
> > +    return 1;
> > +  if (get_version_2 () != 104)
> > +    return 2;
> > +  return 0;
> > +}
> [...]
> > +++ b/gdb/testsuite/gdb.base/print-file-var.exp
> [...]
> > +gdb_test "print 'print-file-var-lib1.c'::this_version_id" \
> > +         " = 104"
> > +
> > +gdb_test "print 'print-file-var-lib2.c'::this_version_id" \
> > +         " = 203"
> 
> This testcase proves GDB behaves incorrectly - if the code sees 104 in both
> cases then GDB should also print 104 in both cases.  I am curious why did you
> check it in when you have proven yourself the regression.

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.

My mistake, I was expecting get_version_2 in this example to return
203, not 104. But I see now that, on my Linux machine, it does return
104.  On the other hand, on Windows, with the same code, the function
returns 203.  So the code is not portable.

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.

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.

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.

-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]