callsite: extract instruction pointer from call sites
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Oct 2012 02:07:58 +0000 (22:07 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Oct 2012 02:07:58 +0000 (22:07 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/tracepoint-types.h
include/lttng/tracepoint.h
liblttng-ust/ltt-events.c
liblttng-ust/tracepoint.c

index 27500d40451535ada1e63c227e80c6a7bc291a0f..838446fa855509bcc4cbcdc832274397c0b71198 100644 (file)
@@ -32,11 +32,12 @@ struct tracepoint {
 
 #define TRACEPOINT_CALLSITE_PADDING    16
 struct tracepoint_callsite {
-       const struct tracepoint *tp;
+       const char *name;
        const char *func;
        const char *file;
+       void *ip;
        unsigned int lineno;
        char padding[TRACEPOINT_CALLSITE_PADDING];
-};
+} __attribute__((packed));
 
 #endif /* _LTTNG_TRACEPOINT_TYPES_H */
index 8086b648a2a4be8d9b7ed04cbe21977a3f039929..61d227d5ba2ca1c32e15042d3008d4bc569a0969 100644 (file)
@@ -220,25 +220,34 @@ struct tracepoint_callsite_dlopen tracepoint_callsite_dlopen
 int __tracepoint_callsite_registered
        __attribute__((weak, visibility("hidden")));
 
+#if (CAA_BITS_PER_LONG == 64)
+#define __TP_ASM_PTR   ".quad "
+#else
+#define __TP_ASM_PTR   ".long "
+#endif
+
 /*
  * Note: to allow PIC code, we need to allow the linker to update the pointers
  * in the __tracepoints_callsite_ptrs section.
  * Therefore, this section is _not_ const (read-only).
  */
 #define TRACEPOINT_CALLSITE(_provider, _name)                                  \
-       static struct tracepoint_callsite                                       \
-               __tracepoint_callsite_##_provider##___##_name                   \
-               __attribute__((section("__tracepoint_callsite"))) =             \
-               {                                                               \
-                       .tp = &__tracepoint_##_provider##___##_name,            \
-                       .func = __func__,                                       \
-                       .file = __FILE__,                                       \
-                       .lineno = __LINE__,                                     \
-               };                                                              \
-       static struct tracepoint_callsite *                                     \
-               __tracepoint_callsite_ptr_##_provider##___##_name               \
-               __attribute__((used, section("__tracepoint_callsite_ptrs"))) =  \
-                       &__tracepoint_callsite_##_provider##___##_name
+do {                                                                           \
+       asm volatile (  ".pushsection __tracepoint_callsite, \"aw\"\n\t"        \
+                       "1:\n\t"                                                \
+                       __TP_ASM_PTR "%c0, %c1, %c2, 2f\n\t"                    \
+                       ".int %c3\n\t"                                          \
+                       ".space 16\n\t" /* padding */                           \
+                       ".popsection\n\t"                                       \
+                       ".pushsection __tracepoint_callsite_ptrs, \"aw\"\n\t"   \
+                       __TP_ASM_PTR "1b\n\t"                                   \
+                       ".popsection\n\t"                                       \
+                       "2:\n\t"                                                \
+               : : "i" (#_provider ":" #_name),                                \
+                       "i" (__func__),                                         \
+                       "i" (__FILE__),                                         \
+                       "i" (__LINE__));                                        \
+} while (0)
 
 /*
  * These weak symbols, the constructor, and destructor take care of
index 2109b8c21823a868bf49396fdb5d9fce29cc5343..6b9170a03ed63b0feb5f680c41cedd2b728d4345 100644 (file)
@@ -1016,11 +1016,13 @@ int _ltt_callsite_metadata_statedump(struct ltt_session *session,
                "callsite {\n"
                "       name = \"%s\";\n"
                "       func = \"%s\";\n"
+               "       ip = %p;\n"
                "       file = \"%s\";\n"
                "       line = %u;\n"
                "};\n\n",
-               callsite->tp_cs->tp->name,
+               callsite->tp_cs->name,
                callsite->tp_cs->func,
+               callsite->tp_cs->ip,
                callsite->tp_cs->file,
                callsite->tp_cs->lineno);
        if (ret)
index 3abed871be7c8bc6ef68cd018dc49feceaf52075..6585daa848551cc03cac333f3e03cd8ffba78bf9 100644 (file)
@@ -736,9 +736,10 @@ int tracepoint_register_lib_callsite(struct tracepoint_callsite * const *tp_star
                for (i = 0; i < tp_count; i++) {
                        if (!tp_start[i])       /* Check for dummy */
                                continue;
-                       DBG("registered callsite for tracepoint \"%s\" at %s@%s:%u",
-                               tp_start[i]->tp->name,
+                       DBG("registered callsite for tracepoint \"%s\" at %s@%p:%s:%u",
+                               tp_start[i]->name,
                                tp_start[i]->func,
+                               tp_start[i]->ip,
                                tp_start[i]->file,
                                tp_start[i]->lineno);
                        real_count++;
This page took 0.02889 seconds and 4 git commands to generate.