public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-sergiodj-stap: Correctly calculating the probe address (and semaphore address) by applying a base offset to it.
@ 2011-02-10 18:32 sergiodj
  0 siblings, 0 replies; only message in thread
From: sergiodj @ 2011-02-10 18:32 UTC (permalink / raw)
  To: archer-commits

The branch, archer-sergiodj-stap has been updated
       via  1b16efd7055bbe6ff5029ecc36df9b8a04704799 (commit)
      from  9f776ea7da35f9d2e9ca84c512cfffda2c0d230c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 1b16efd7055bbe6ff5029ecc36df9b8a04704799
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Thu Feb 10 16:31:16 2011 -0200

    Correctly calculating the probe address (and semaphore address) by
    applying a base offset to it.

-----------------------------------------------------------------------

Summary of changes:
 gdb/elfread.c |   36 +++++++++++++++++++++++++++++++++---
 1 files changed, 33 insertions(+), 3 deletions(-)

First 500 lines of diff:
diff --git a/gdb/elfread.c b/gdb/elfread.c
index d654067..c9efdda 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1052,10 +1052,11 @@ elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
 }
 
 static void
-handle_probe (struct sdt_note *el, struct stap_probe *ret, bfd *abfd)
+handle_probe (struct sdt_note *el, struct stap_probe *ret, bfd *abfd,
+	      CORE_ADDR base)
 {
   int size = bfd_get_arch_size (abfd) / 8;
-  CORE_ADDR off;
+  CORE_ADDR base_ref;
 
   /* Provider and the name of the probe.  */
   ret->provider = (const char *) &el->data[3 * size];
@@ -1068,8 +1069,13 @@ handle_probe (struct sdt_note *el, struct stap_probe *ret, bfd *abfd)
 
   /* Retrieving the probe's address.  */
   ret->address = ((CORE_ADDR *) el->data)[0];
+  base_ref = ((CORE_ADDR *) el->data)[1];
   ret->sem_addr = ((CORE_ADDR *) el->data)[2];
 
+  ret->address += base - base_ref;
+  if (ret->sem_addr)
+    ret->sem_addr += base - base_ref;
+
   /* Arguments.  */
   ret->args = memchr (ret->name, '\0',
 		      (unsigned long *) el->data
@@ -1081,11 +1087,35 @@ handle_probe (struct sdt_note *el, struct stap_probe *ret, bfd *abfd)
 	      == el->data + el->size - 1);
 }
 
+#define STAP_BASE_SECTION_NAME ".stapsdt.base"
+
+static void
+get_base_address_1 (bfd *abfd, asection *sect, void *obj)
+{
+  bfd_vma *base = (bfd_vma *) obj;
+
+  if (*base == (bfd_vma) -1
+      && (sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
+      && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
+    *base = sect->vma;
+}
+
+static bfd_vma
+get_base_address (bfd *obfd)
+{
+  bfd_vma base = (bfd_vma) -1;
+
+  bfd_map_over_sections (obfd, get_base_address_1, (void *) &base);
+
+  return base;
+}
+
 static const struct stap_probe *
 elf_get_probes (struct objfile *objfile, int *num_probes)
 {
   struct stap_probe *ret = NULL;
   bfd *obfd = objfile->obfd;
+  bfd_vma base = get_base_address (obfd);
   struct sdt_note *iter;
   int i;
 
@@ -1101,7 +1131,7 @@ elf_get_probes (struct objfile *objfile, int *num_probes)
   ret = xmalloc (*num_probes * sizeof (struct stap_probe));
 
   for (iter = elf_tdata (obfd)->sdt_note_head, i = 0; iter; iter = iter->next, i++)
-    handle_probe (iter, &ret[i], obfd);
+    handle_probe (iter, &ret[i], obfd, base);
 
   return ret;
 }


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-02-10 18:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-10 18:32 [SCM] archer-sergiodj-stap: Correctly calculating the probe address (and semaphore address) by applying a base offset to it sergiodj

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).