Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Pedro Alves <palves@redhat.com>, Tom Tromey <tromey@redhat.com>,
	gdb-patches@sourceware.org
Subject: Re: RFC for: "Re: Regression for gdb.fortran/library-module.exp [Re: [RFA] choose symbol from given block's objfile first.]"
Date: Tue, 29 May 2012 15:44:00 -0000	[thread overview]
Message-ID: <20120529154436.GO5492@adacore.com> (raw)
In-Reply-To: <20120528161200.GA19230@host2.jankratochvil.net>

> Just the MAINLINE exception is not enough, it still regresses GDB:

OK, I see what you mean, now.

> before your patches (and therefore matching GDB the inferior behavior):
> 11
> $1 = 1
> $2 = 1
> 22
> $1 = 2
> $2 = 2

On x86-windows, the two programs alway return the same value: 12,
which means that the global variables remain distinct, and localized
to each DLL.  It's not a surprise, it's the same test I've made before.
Just to be thorough, I defined a third instance of global variable v,
this time in 50.c (the main body), and change the return value to
also add the value of this global:

    $ cat 50.c
    int v = 100;

    extern int f (void);
    extern int g (void);

    int main (void) {
      return 10 * f () + g () + v;
    }

This time, the return value is always 112. Again, no surprise.

> But '"context" objfile first' is incompatible with SVR4.  The behavior
> apparently has to be target specific.

OK, I think we should be able to modify my patch to add a new
gdbarch attribute, unset by default, which we will set on all
Windows arches. Then, the iterator can query that gdbarch attribute
to decide whether to ignore the "context" objfile or not.

The following implementation for iterate_over_objfiles_in_search_order
should work; WDYT?

    void
    iterate_over_objfiles_in_search_order
      (iterate_over_objfiles_in_search_order_cb cb,
       void *cb_data,
       struct objfile *context_objfile)
    {
      int stop = 0;
      struct objfile *objfile;

      if (context_objfile
          && gdbarch_dso_global_vars_distinct_p
               (get_objfile_arch (context_objfile)))
        {
          /* Global variables defined with the same name in multiple
             object files get merged into one single entity.  Favouring
             the context objfile in this case would be wrong, as we might
             end up picking the wrong location.  */
          context_objfile = NULL;
        }

      if (context_objfile)
        {
          stop = cb (context_objfile, cb_data);
          if (stop)
            return;
        }

      ALL_OBJFILES (objfile)
        {
          if (objfile != context_objfile)
            {
              stop = cb (objfile, cb_data);
              if (stop)
                return;
            }
        }
    }

(untested)

The thing I am worried about is the design of the gdbarch part,
because I don't think I master all the elements across platforms.
But I suppose that this is only of relative importance, as we can
refine it as we go.

Thanks,
-- 
Joel


  reply	other threads:[~2012-05-29 15:44 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
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 [this message]
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=20120529154436.GO5492@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=palves@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