Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: Pedro Alves <palves@redhat.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v3 3/3] btrace, vdso: add vdso target sections
Date: Mon, 02 Jun 2014 12:41:00 -0000	[thread overview]
Message-ID: <A78C989F6D9628469189715575E55B230C182CFC@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <53876874.3080503@redhat.com>

> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Thursday, May 29, 2014 7:04 PM


> Hmm, wait, nothing is removing the vdso symbols target sections, like ever,
> not even when the process dies, isn't it?  I guess that's it.

Yes, that seems to be it.

Target sections are typically owned by an so_list object and are removed
when the so_list object is removed.

Symfile target sections are owned by an objfile object and are removed
in a free_objfile observer in symfile.c.  That observer only removes target
sections for OBJF_USERLOADED objfiles, though.

The vdso target sections are owned by the vdso BFD and are never removed.

When I change symfile_add_from_memory to create target sections like this:

	add_target_sections_of_objfile (objf);

and further drop the restriction to only remove OBJF_USERLOADED objfiles in
symfile_free_objfile, the test passes.

diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index b29421e..ef48f7d 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -92,7 +92,6 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
   struct section_addr_info *sai;
   unsigned int i;
   struct cleanup *cleanup;
-  struct target_section *sections, *sections_end, *tsec;
 
   if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
     error (_("add-symbol-file-from-memory not supported for this target"));
@@ -132,22 +131,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
                                   from_tty ? SYMFILE_VERBOSE : 0,
                                    sai, OBJF_SHARED, NULL);
 
-  sections = NULL;
-  sections_end = NULL;
-
-  if (build_section_table (nbfd, &sections, &sections_end) == 0)
-    {
-      make_cleanup (xfree, sections);
-
-      /* Adjust the target section addresses by the load address.  */
-      for (tsec = sections; tsec != sections_end; ++tsec)
-       {
-         tsec->addr += loadbase;
-         tsec->endaddr += loadbase;
-       }
-
-      add_target_sections (&nbfd, sections, sections_end);
-    }
+  add_target_sections_of_objfile (objf);
 
   /* This might change our ideas about frames already looked at.  */
   reinit_frame_cache ();
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 64a83c6..caa0722 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3893,7 +3893,7 @@ static void
 symfile_free_objfile (struct objfile *objfile)
 {
   /* Remove the target sections of user-added objfiles.  */
-  if (objfile != 0 && objfile->flags & OBJF_USERLOADED)
+  if (objfile != NULL)
     remove_target_sections ((void *) objfile);
 }

Alternatively, I could add another OBJF_ flag and another free_objfile observer
to also remove the symfile-from-memory target sections.

Regards,
Markus.

Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052


  parent reply	other threads:[~2014-06-02 12:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21  7:01 [PATCH v3 1/3] btrace: control memory access during replay Markus Metzger
2014-05-21  7:01 ` [PATCH v3 3/3] btrace, vdso: add vdso target sections Markus Metzger
2014-05-21  9:55   ` Pedro Alves
2014-05-29 16:54   ` Pedro Alves
2014-05-29 17:03     ` Pedro Alves
2014-06-02  8:20       ` Metzger, Markus T
2014-06-02  9:43         ` Metzger, Markus T
2014-06-02 12:41       ` Metzger, Markus T [this message]
2014-06-04 12:37         ` Metzger, Markus T
2014-05-21  7:02 ` [PATCH v3 2/3] test, gcore: move capture_command_output into lib/gdb.exp Markus Metzger
2014-05-21  9:55   ` Pedro Alves
2014-05-21  9:55 ` [PATCH v3 1/3] btrace: control memory access during replay 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=A78C989F6D9628469189715575E55B230C182CFC@IRSMSX104.ger.corp.intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@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