Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <lgustavo@codesourcery.com>
To: Nicolas Blanc <nicolas.blanc@intel.com>
Cc: gdb-patches@sourceware.org, Hafiz_Abid@mentor.com,
	palves@redhat.com,  tromey@redhat.com, eliz@gnu.org,
	yao@codesourcery.com, dje@google.com
Subject: Re: [patch v9 4/5] 'add-symbol-file' should update the current target sections.
Date: Tue, 18 Jun 2013 17:29:00 -0000	[thread overview]
Message-ID: <51C098A9.1090202@codesourcery.com> (raw)
In-Reply-To: <1371566833-4713-5-git-send-email-nicolas.blanc@intel.com>

On 06/18/2013 11:47 AM, Nicolas Blanc wrote:
> 2013-17-06  Nicolas Blanc  <nicolas.blanc@intel.com>
>
> 	* symfile.c (add_target_sections_of_objfile): New function.
> 	(add_symbol_file_command): Update the current target sections.
> 	(symfile_free_objfile): New function.
> 	(_initialize_symfile): Attach observer for free_objfile.
>
> Signed-off-by: Nicolas Blanc <nicolas.blanc@intel.com>
> ---
>   gdb/symfile.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 files changed, 67 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/symfile.c b/gdb/symfile.c
> index f7ad268..33d0eda 100644
> --- a/gdb/symfile.c
> +++ b/gdb/symfile.c
> @@ -57,6 +57,7 @@
>   #include "stack.h"
>   #include "gdb_bfd.h"
>   #include "cli/cli-utils.h"
> +#include "target.h"
>
>   #include <sys/types.h>
>   #include <fcntl.h>
> @@ -2162,6 +2163,52 @@ print_transfer_performance (struct ui_file *stream,
>     ui_out_text (uiout, ".\n");
>   }
>
> +/* Add the sections of OBJFILE to the current set of target sections.  */
> +
> +static void
> +add_target_sections_of_objfile (struct objfile* objfile)

struct objfile *objfile?

> +{
> +  struct target_section_table *table = current_target_sections;
> +  struct obj_section *osect;
> +  int space;
> +  unsigned count = 0;
> +  struct target_section* ts;
> +
> +  if (objfile == NULL)
> +    return;
> +
> +  /* Compute the number of sections to add.  */
> +  ALL_OBJFILE_OSECTIONS (objfile, osect)
> +  {

Identation off.

> +    if (bfd_get_section_size (osect->the_bfd_section) == 0)
> +      continue;
> +    count++;
> +  }
> +
> +  if (count == 0)
> +    return;
> +
> +  space = resize_section_table (table, count);
> +
> +  ts = table->sections + space;
> +
> +  ALL_OBJFILE_OSECTIONS (objfile, osect)
> +  {

Identation off.

> +    if (bfd_get_section_size (osect->the_bfd_section) == 0)
> +      continue;
> +
> +    gdb_assert (ts < table->sections + space + count);
> +
> +    ts->addr = obj_section_addr (osect);
> +    ts->endaddr = obj_section_endaddr (osect);
> +    ts->the_bfd_section = osect->the_bfd_section;
> +    ts->key = (void*) objfile;
> +    ts->bfd = objfile->obfd;
> +
> +    ts++;
> +  }
> +}
> +
>   /* This function allows the addition of incrementally linked object files.
>      It does not modify any state in the target, only in the debugger.  */
>   /* Note: ezannoni 2000-04-13 This function/command used to have a
> @@ -2185,6 +2232,7 @@ add_symbol_file_command (char *args, int from_tty)
>     int expecting_sec_name = 0;
>     int expecting_sec_addr = 0;
>     char **argv;
> +  struct objfile *objf;
>
>     struct sect_opt
>     {
> @@ -2320,8 +2368,10 @@ add_symbol_file_command (char *args, int from_tty)
>     if (from_tty && (!query ("%s", "")))
>       error (_("Not confirmed."));
>
> -  symbol_file_add (filename, from_tty ? SYMFILE_VERBOSE : 0,
> -                   section_addrs, flags);
> +  objf = symbol_file_add (filename, from_tty ? SYMFILE_VERBOSE : 0,
> +			  section_addrs, flags);
> +
> +  add_target_sections_of_objfile (objf);
>
>     /* Getting new symbols may change our opinion about what is
>        frameless.  */
> @@ -3798,11 +3848,26 @@ symfile_find_segment_sections (struct objfile *objfile)
>     free_symfile_segment_data (data);
>   }
>
> +/* Listen for free_objfile events.  */
> +
> +static void
> +symfile_free_objfile (struct objfile *objfile)
> +{
> +  if (objfile == NULL)
> +    return;
> +
> +  /* Remove the target sections of user-added objfiles.  */
> +  if (objfile->flags & OBJF_USERLOADED && objfile->obfd)
> +    remove_target_sections ((void*)objfile, objfile->obfd);
> +}
> +
>   void
>   _initialize_symfile (void)
>   {
>     struct cmd_list_element *c;
>
> +  observer_attach_free_objfile (symfile_free_objfile);
> +
>     c = add_cmd ("symbol-file", class_files, symbol_file_command, _("\
>   Load symbol table from executable file FILE.\n\
>   The `file' command can also load symbol tables, as well as setting the file\n\
>

The rest looks good to me.


      reply	other threads:[~2013-06-18 17:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 14:47 [patch v9 0/5] remove-symbol-file Nicolas Blanc
2013-06-18 14:47 ` [patch v9 3/5] Documentation for the remove-symbol-file command Nicolas Blanc
2013-06-18 16:23   ` Eli Zaretskii
2013-06-18 14:47 ` [patch v9 5/5] Test 'info files' after 'add-symbol-file' and 'remove-symbol-file' Nicolas Blanc
2013-06-18 17:53   ` Luis Machado
2013-06-18 14:47 ` [patch v9 2/5] Test adding and removing a symbol file at runtime Nicolas Blanc
2013-06-18 17:28   ` Luis Machado
2013-06-18 14:47 ` [patch v9 1/5] New remove-symbol-file command Nicolas Blanc
2013-06-18 17:26   ` Luis Machado
2013-06-19 12:23     ` Blanc, Nicolas
2013-06-19 13:07       ` Luis Machado
2013-06-18 15:04 ` [patch v9 4/5] 'add-symbol-file' should update the current target sections Nicolas Blanc
2013-06-18 17:29   ` Luis Machado [this message]

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=51C098A9.1090202@codesourcery.com \
    --to=lgustavo@codesourcery.com \
    --cc=Hafiz_Abid@mentor.com \
    --cc=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=nicolas.blanc@intel.com \
    --cc=palves@redhat.com \
    --cc=tromey@redhat.com \
    --cc=yao@codesourcery.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