markers: save marker location in struct marker
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 27 Oct 2009 21:33:04 +0000 (17:33 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 27 Oct 2009 22:35:28 +0000 (18:35 -0400)
This is for gdb static tracepoints.

libust/marker.c
libust/marker.h
libust/tracectl.c

index 315294764cf73c8b405ac5f2ba30c807c37c2f2b..8b120195677690186839884ab5cfbb940546bef7 100644 (file)
@@ -43,6 +43,8 @@
 
 extern struct marker __start___markers[] __attribute__((visibility("hidden")));
 extern struct marker __stop___markers[] __attribute__((visibility("hidden")));
+extern struct marker_addr __start___marker_addr[] __attribute__((visibility("hidden")));
+extern struct marker_addr __stop___marker_addr[] __attribute__((visibility("hidden")));
 
 /* Set to 1 to enable marker debug output */
 static const int marker_debug;
@@ -1496,15 +1498,22 @@ static void new_markers(struct marker *start, struct marker *end)
        }
 }
 
-int marker_register_lib(struct marker *markers_start, int markers_count)
+int marker_register_lib(struct marker *markers_start, struct marker_addr *marker_addr_start, int markers_count)
 {
        struct lib *pl;
+       struct marker_addr *addr;
 
        pl = (struct lib *) malloc(sizeof(struct lib));
 
        pl->markers_start = markers_start;
+       pl->markers_addr_start = marker_addr_start;
        pl->markers_count = markers_count;
 
+       lock_markers();
+       for(addr = marker_addr_start; addr < marker_addr_start + markers_count; addr++)
+               addr->marker->location = addr->addr;
+       unlock_markers();
+
        /* FIXME: maybe protect this with its own mutex? */
        lock_markers();
        list_add(&pl->list, &libs);
@@ -1533,8 +1542,8 @@ static int initialized = 0;
 void __attribute__((constructor)) init_markers(void)
 {
        if(!initialized) {
-               marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker));
-               DBG("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers);
+               marker_register_lib(__start___markers, __start___marker_addr, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker));
+               //DBG("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers);
                initialized = 1;
        }
 }
index 5fe50a9f4d2e32891c154a8e9b57c153a63b504e..246d174e67caca18597a684dd6a2eda881a6dbbf 100644 (file)
@@ -31,6 +31,7 @@
 #include "kernelcompat.h"
 #include <kcompat/list.h>
 #include "localerr.h"
+#include "registers.h"
 
 //ust// struct module;
 //ust// struct task_struct;
@@ -74,6 +75,7 @@ struct marker {
        struct marker_probe_closure *multi;
        const char *tp_name;    /* Optional tracepoint name */
        void *tp_cb;            /* Optional tracepoint callback */
+       void *location;         /* Address of marker in code */
 } __attribute__((aligned(8)));
 
 #define CONFIG_MARKERS
@@ -91,7 +93,16 @@ struct marker {
                                                sizeof(#name)],         \
                  0, 0, 0, 0, marker_probe_cb,                          \
                  { __mark_empty_function, NULL},                       \
-                 NULL, tp_name_str, tp_cb }
+                 NULL, tp_name_str, tp_cb };                           \
+               asm (".section __marker_addr,\"aw\",@progbits\n\t"      \
+                      _ASM_PTR "%c[marker_struct], (1f)\n\t"           \
+                      ".previous\n\t"                                  \
+                      "\n\t"                                           \
+                      "1:\n\t"                                         \
+                       :: [marker_struct] "i" (&__mark_##channel##_##name));\
+               save_registers(&regs)
+
+
 
 #define DEFINE_MARKER(channel, name, format)                           \
                _DEFINE_MARKER(channel, name, NULL, NULL, format)
@@ -287,24 +298,30 @@ extern int is_marker_enabled(const char *channel, const char *name);
 //ust// }
 //ust// #endif
 
+struct marker_addr {
+       struct marker *marker;
+       void *addr;
+};
 
 struct lib {
        struct marker *markers_start;
+       struct marker_addr *markers_addr_start;
        int markers_count;
        struct list_head list;
 };
 
-extern int marker_register_lib(struct marker *markers_start,
-                              int markers_count);
-
-#define MARKER_LIB                                                     \
-extern struct marker __start___markers[] __attribute__((visibility("hidden")));        \
-extern struct marker __stop___markers[] __attribute__((visibility("hidden")));         \
-                                                                                       \
-static void __attribute__((constructor)) __markers__init(void)                                 \
-{                                                                                      \
-       DBG("next registration in "__FILE__"\n");\
-       marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker));\
+extern int marker_register_lib(struct marker *markers_start, struct marker_addr *marker_addr_start, int markers_count);
+
+#define MARKER_LIB                                                                             \
+extern struct marker __start___markers[] __attribute__((visibility("hidden")));                        \
+extern struct marker __stop___markers[] __attribute__((visibility("hidden")));                 \
+extern struct marker_addr __start___marker_addr[] __attribute__((visibility("hidden")));       \
+extern struct marker_addr __stop___marker_addr[] __attribute__((visibility("hidden")));                \
+                                                                                               \
+static void __attribute__((constructor)) __markers__init(void)                                 \
+{                                                                                              \
+       DBG("next registration in "__FILE__"\n");                                               \
+       marker_register_lib(__start___markers, __start___marker_addr, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker)); \
 }
 
 extern void marker_set_new_marker_cb(void (*cb)(struct marker *));
index d4cd5942d7bed35cc0663445c6f3c713aa0a62bf..ed902574987cfa4cefceb7f53ea352dca787f35f 100644 (file)
@@ -117,7 +117,7 @@ static void print_markers(FILE *fp)
        marker_iter_start(&iter);
 
        while(iter.marker) {
-               fprintf(fp, "marker: %s/%s %d \"%s\"\n", iter.marker->channel, iter.marker->name, (int)imv_read(iter.marker->state), iter.marker->format);
+               fprintf(fp, "marker: %s/%s %d \"%s\" %p\n", iter.marker->channel, iter.marker->name, (int)imv_read(iter.marker->state), iter.marker->format, iter.marker->location);
                marker_iter_next(&iter);
        }
        unlock_markers();
@@ -837,7 +837,7 @@ static void auto_probe_connect(struct marker *m)
        if(result && result != -EEXIST)
                ERR("ltt_marker_connect (marker = %s/%s, errno = %d)", m->channel, m->name, -result);
 
-       DBG("auto connected marker %s %s to probe default", m->channel, m->name);
+       DBG("auto connected marker %s (addr: %p) %s to probe default", m->channel, m, m->name);
 
 }
 
This page took 0.028309 seconds and 4 git commands to generate.