public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [PATCH 4/4] move probes to be per-bfd
Date: Tue, 03 Dec 2013 20:37:00 -0000	[thread overview]
Message-ID: <1386100019-27379-5-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1386100019-27379-1-git-send-email-tromey@redhat.com>

This patch moves the probe data from the objfile to the per-BFD
object.  This lets the probes be shared between different inferiors
(and different objfiles when dlmopen is in use, should gdb ever handle
that).

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* elfread.c (probe_key): Change to bfd_data.
	(elf_get_probes, probe_key_free, _initialize_elfread): Probes are
	now per-BFD, not per-objfile.
	* stap-probe.c (stap_probe_destroy): Update comment.
	(handle_stap_probe): Allocate on the per-BFD obstack.
---
 gdb/ChangeLog    |  8 ++++++++
 gdb/elfread.c    | 26 +++++++++++++-------------
 gdb/stap-probe.c |  4 ++--
 3 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index dedecf2..1f28bc1 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -63,9 +63,9 @@ struct elfinfo
     asection *mdebugsect;	/* Section pointer for .mdebug section */
   };
 
-/* Per-objfile data for probe info.  */
+/* Per-BFD data for probe info.  */
 
-static const struct objfile_data *probe_key = NULL;
+static const struct bfd_data *probe_key = NULL;
 
 static void free_elfinfo (void *);
 
@@ -1488,12 +1488,12 @@ elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
 static VEC (probe_p) *
 elf_get_probes (struct objfile *objfile)
 {
-  VEC (probe_p) *probes_per_objfile;
+  VEC (probe_p) *probes_per_bfd;
 
   /* Have we parsed this objfile's probes already?  */
-  probes_per_objfile = objfile_data (objfile, probe_key);
+  probes_per_bfd = bfd_data (objfile->obfd, probe_key);
 
-  if (!probes_per_objfile)
+  if (!probes_per_bfd)
     {
       int ix;
       const struct probe_ops *probe_ops;
@@ -1502,25 +1502,25 @@ elf_get_probes (struct objfile *objfile)
 	 objfile.  */
       for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, probe_ops);
 	   ix++)
-	probe_ops->get_probes (&probes_per_objfile, objfile);
+	probe_ops->get_probes (&probes_per_bfd, objfile);
 
-      if (probes_per_objfile == NULL)
+      if (probes_per_bfd == NULL)
 	{
-	  VEC_reserve (probe_p, probes_per_objfile, 1);
-	  gdb_assert (probes_per_objfile != NULL);
+	  VEC_reserve (probe_p, probes_per_bfd, 1);
+	  gdb_assert (probes_per_bfd != NULL);
 	}
 
-      set_objfile_data (objfile, probe_key, probes_per_objfile);
+      set_bfd_data (objfile->obfd, probe_key, probes_per_bfd);
     }
 
-  return probes_per_objfile;
+  return probes_per_bfd;
 }
 
 /* Helper function used to free the space allocated for storing SystemTap
    probe information.  */
 
 static void
-probe_key_free (struct objfile *objfile, void *d)
+probe_key_free (bfd *abfd, void *d)
 {
   int ix;
   VEC (probe_p) *probes = d;
@@ -1606,7 +1606,7 @@ static const struct gnu_ifunc_fns elf_gnu_ifunc_fns =
 void
 _initialize_elfread (void)
 {
-  probe_key = register_objfile_data_with_cleanup (NULL, probe_key_free);
+  probe_key = register_bfd_data_with_cleanup (NULL, probe_key_free);
   add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns);
 
   elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 7f2d45d..fbc5724 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1142,7 +1142,7 @@ stap_compile_to_ax (struct probe *probe_generic, struct agent_expr *expr,
 }
 
 /* Destroy (free) the data related to PROBE.  PROBE memory itself is not feed
-   as it is allocated from OBJFILE_OBSTACK.  */
+   as it is allocated on an obstack.  */
 
 static void
 stap_probe_destroy (struct probe *probe_generic)
@@ -1348,7 +1348,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
   const char *probe_args = NULL;
   struct stap_probe *ret;
 
-  ret = obstack_alloc (&objfile->objfile_obstack, sizeof (*ret));
+  ret = obstack_alloc (&objfile->per_bfd->storage_obstack, sizeof (*ret));
   ret->p.pops = &stap_probe_ops;
   ret->p.arch = gdbarch;
 
-- 
1.8.1.4

  parent reply	other threads:[~2013-12-03 20:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 19:47 [PATCH 0/4] make probes independent of the program space Tom Tromey
2013-12-03 19:47 ` [PATCH 2/4] remove some sym_probe_fns methods Tom Tromey
2013-12-05 23:06   ` Sergio Durigan Junior
2013-12-06  2:25     ` Sergio Durigan Junior
2013-12-06 15:54       ` Tom Tromey
2013-12-06 17:26         ` Tom Tromey
2013-12-06 18:23           ` Sergio Durigan Junior
2013-12-03 19:47 ` [PATCH 3/4] change probes to be program-space-independent Tom Tromey
2013-12-17 11:08   ` Gary Benson
2013-12-03 19:47 ` [PATCH 1/4] comment fixes Tom Tromey
2013-12-03 20:37 ` Tom Tromey [this message]
2013-12-05 17:10 ` [PATCH 0/4] make probes independent of the program space Pedro Alves
2013-12-05 19:10   ` Tom Tromey

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=1386100019-27379-5-git-send-email-tromey@redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).