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: [PATCH 3/3] move the "main" data into the per-BFD object


On Mon, Jan 6, 2014 at 9:11 AM, Tom Tromey <tromey@redhat.com> wrote:
> This adds the "main"-related data into the per-BFD.  This is needed
> because once symbol sharing across objfiles is complete, computing the
> main name as a side effect of symbol reading will no longer work --
> the symbols simply won't be re-read.
>
> After this change, set_main_name is only used by the main_name
> machinery itself, so this patch makes it static.
>
> 2014-01-06  Tom Tromey  <tromey@redhat.com>
>
>         * dbxread.c (process_one_symbol): Use set_objfile_main_name.
>         * dwarf2read.c (read_partial_die): Use set_objfile_main_name.
>         * objfiles.c (get_objfile_bfd_data): Initialize language_of_main.
>         (set_objfile_main_name): New function.
>         * objfiles.h (struct objfile_per_bfd_storage) <name_of_main,
>         language_of_main>: New fields.
>         (set_objfile_main_name): Declare.
>         * symtab.c (find_main_name): Loop over objfiles to find the main
>         name and language.
>         (set_main_name): Now static.
>         * symtab.h (set_main_name): Don't declare.
> [...]
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -5057,7 +5057,7 @@ main_info_cleanup (struct program_space *pspace, void *data)
>    xfree (info);
>  }
>
> -void
> +static void
>  set_main_name (const char *name, enum language lang)
>  {
>    struct main_info *info = get_main_info ();
> @@ -5082,6 +5082,17 @@ static void
>  find_main_name (void)
>  {
>    const char *new_main_name;
> +  struct objfile *objfile;
> +
> +  ALL_OBJFILES (objfile)
> +  {
> +    if (objfile->per_bfd->name_of_main != NULL)
> +      {
> +       set_main_name (objfile->per_bfd->name_of_main,
> +                      objfile->per_bfd->language_of_main);
> +       return;
> +      }
> +  }
>
>    /* Try to see if the main procedure is in Ada.  */
>    /* FIXME: brobecker/2005-03-07: Another way of doing this would

Hi.

[setting aside a day when there are multiple main names,]
Seems like there ought to be an invariant that there is only one main name.
I ask because it's not clear this invariant is enforced (or if it is
it's too subtle) and thus what if this loop finds the wrong one?


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