public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-sergiodj-stap: Adding functions that will retrieve probe info from the object file.
@ 2011-02-09 17:13 sergiodj
0 siblings, 0 replies; only message in thread
From: sergiodj @ 2011-02-09 17:13 UTC (permalink / raw)
To: archer-commits
The branch, archer-sergiodj-stap has been updated
via c2d7923ce7d90d98869311ecd522cb1254ebac2f (commit)
from 8f983a4ac87f3898954d71d8965d41707ba791c9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit c2d7923ce7d90d98869311ecd522cb1254ebac2f
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Wed Feb 9 15:11:35 2011 -0200
Adding functions that will retrieve probe info from the object file.
These functions are not ready yet.
-----------------------------------------------------------------------
Summary of changes:
bfd/elf-bfd.h | 9 +++++
bfd/elf.c | 37 ++++++++++++++++++++
gdb/stap-probe.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
gdb/stap-probe.h | 4 +-
4 files changed, 148 insertions(+), 2 deletions(-)
First 500 lines of diff:
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index cc83588..4d5efe0 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1473,6 +1473,13 @@ enum
Tag_compatibility = 32
};
+struct sdt_note
+{
+ struct sdt_note *next;
+ bfd_size_type size;
+ bfd_byte data[1];
+};
+
/* Some private data is stashed away for future use using the tdata pointer
in the bfd structure. */
@@ -1630,6 +1637,8 @@ struct elf_obj_tdata
bfd_size_type build_id_size;
bfd_byte *build_id;
+ struct sdt_note *sdt_note_head;
+
/* True if the bfd contains symbols that have the STT_GNU_IFUNC
symbol type. Used to set the osabi field in the ELF header
structure. */
diff --git a/bfd/elf.c b/bfd/elf.c
index de0ab61..c4959da 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8396,6 +8396,37 @@ elfobj_grok_gnu_note (bfd *abfd, Elf_Internal_Note *note)
}
}
+#define SDT_NOTE_TYPE 3
+
+static bfd_boolean
+elfobj_grok_stapsdt_note_1 (bfd *abfd, Elf_Internal_Note *note)
+{
+ struct sdt_note *cur =
+ (struct sdt_note *) bfd_alloc (abfd, sizeof (struct sdt_note)
+ + note->descsz);
+
+ cur->next = (struct sdt_note *) (elf_tdata (abfd))->sdt_note_head;
+ cur->size = (bfd_size_type) note->descsz;
+ memcpy (cur->data, note->descdata, note->descsz);
+
+ elf_tdata (abfd)->sdt_note_head = cur;
+
+ return TRUE;
+}
+
+static bfd_boolean
+elfobj_grok_stapsdt_note (bfd *abfd, Elf_Internal_Note *note)
+{
+ switch (note->type)
+ {
+ case SDT_NOTE_TYPE:
+ return elfobj_grok_stapsdt_note_1 (abfd, note);
+
+ default:
+ return TRUE;
+ }
+}
+
static bfd_boolean
elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp)
{
@@ -9169,6 +9200,12 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset)
if (! elfobj_grok_gnu_note (abfd, &in))
return FALSE;
}
+ else if (in.namesz == sizeof "stapsdt"
+ && strcmp (in.namedata, "stapsdt") == 0)
+ {
+ if (! elfobj_grok_stapsdt_note (abfd, &in))
+ return FALSE;
+ }
break;
}
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 81398ff..f0411c6 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -27,6 +27,7 @@
#include "command.h"
#include "filenames.h"
#include "value.h"
+#include "bfd/elf-bfd.h"
#include <ctype.h>
@@ -413,6 +414,105 @@ compute_marker_arg (struct gdbarch *arch, struct internalvar *ivar,
error (_("Unimplemented"));
}
+static void
+handle_probe (struct sdt_note *el, struct stap_probe *ret, bfd *obfd)
+{
+}
+
+struct stap_probe *
+get_stap_probes (struct objfile *objfile, int *num_probes)
+{
+#if 0
+ /* Array containing all the systemtap markers from the objfile. */
+// struct stap_marker *objprobes;
+ struct obj_section *iter, *probe_section;
+
+ Elf_Internal_Shdr **elf_shdrs, *probe_shdr;
+ unsigned int num_secs;
+ /* Initial section address. */
+ bfd_vma base = (bfd_vma) -1;
+#endif
+ struct stap_probe *ret = NULL;
+ bfd *obfd = objfile->obfd;
+ struct sdt_note *iter;
+ int i;
+
+ *num_probes = 0;
+
+ if (! elf_tdata (obfd)->sdt_note_head)
+ /* There isn't any probe here. */
+ return NULL;
+
+ /* Allocating space for probe info. */
+ for (iter = elf_tdata (obfd)->sdt_note_head; iter; iter = iter->next, ++*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);
+
+#if 0
+ /* Maybe this part isn't needed since we end up traversing the list of
+ sections anyway below. */
+ probe_section = NULL;
+ ALL_OBJFILE_OSECTIONS (objfile, iter)
+ if (strncmp (STAP_PROBE_SECTION, iter->the_bfd_section->name,
+ strlen (STAP_PROBE_SECTION)) == 0)
+ {
+ probe_section = iter;
+ break;
+ }
+
+ if (!probe_section)
+ /* No probes in this objfile. */
+ return NULL;
+ /* -- end of maybe-uneeded part. -- */
+
+ elf_shdrs = elf_elfsections (obfd);
+ if (!elf_shdrs)
+ /* No sections were returned. We cannot parse the objfile. */
+ return NULL;
+
+ num_secs = elf_numsections (obfd);
+// elf_shdrs = elf_elfsections (probe_section->the_bfd_section->owner);
+// num_secs = elf_numsections (probe_section->the_bfd_section->owner);
+
+ probe_shdr = NULL;
+ for (i = 0; i < num_secs; i++)
+ {
+ switch (elf_shdrs[i]->sh_type)
+ {
+ case SHT_NOTE:
+ if (!(elf_shdrs[i]->sh_flags & SHF_ALLOC))
+ {
+ }
+ break;
+ case SHT_PROGBITS:
+ if (base == (bfd_vma) -1
+ && (elf_shdrs[i]->sh_flags & SHF_ALLOC)
+ && elf_shdrs[i]->sh_name
+ && !strcmp (bfd_elf_string_from_elf_section (obfd,
+ elf_shdrs[i]->sh_link,
+ elf_shdrs[i]->sh_name),
+ STAP_BASE_SECTION))
+ base = elf_shdrs[i]->sh_addr;
+ break;
+ }
+ }
+#endif
+#if 0
+ /* FIXME: There must be a better way for this. */
+ if (strncmp (STAP_PROBE_SECTION, elf_shdrs[i]->bfd_section->name,
+ strlen (STAP_PROBE_SECTION)) == 0)
+ {
+ probe_shdr = elf_shdrs[i];
+ break;
+ }
+#endif
+
+ return ret;
+}
+
\f
void
diff --git a/gdb/stap-probe.h b/gdb/stap-probe.h
index 394e891..e9d9b1e 100644
--- a/gdb/stap-probe.h
+++ b/gdb/stap-probe.h
@@ -43,7 +43,7 @@ extern struct symtabs_and_lines parse_stap_probe (char **argptr);
/* Try to map the probe section of OBJFILE and parse it. Return NULL
if there are no probes, otherwise return an array of probes with
*NUM_PROBES as an out parameter. */
-/*extern struct stap_probe *get_stap_probes (struct objfile *objfile,
- int *num_probes);*/
+extern struct stap_probe *get_stap_probes (struct objfile *objfile,
+ int *num_probes);
#endif /* !defined (STAP_PROBE_H) */
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-02-09 17:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-09 17:13 [SCM] archer-sergiodj-stap: Adding functions that will retrieve probe info from the object file 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).