code cleanups
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Wed, 2 Sep 2009 14:42:49 +0000 (10:42 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Wed, 2 Sep 2009 14:42:49 +0000 (10:42 -0400)
13 files changed:
libust/channels.c
libust/marker-control.c
libust/marker.c
libust/relay.c
libust/relay.h
libust/serialize.c
libust/tracepoint.c
libust/tracer.c
libustcmd/ustcmd.c
libustcomm/ustcomm.c
libustcomm/ustcomm.h
share/kernelcompat.h
ust/ust.c

index 76b951773893b000585d897497cddb1f6372677c..10ab587cb6ca969ad5669333e40b6cce75319de6 100644 (file)
@@ -31,6 +31,7 @@
 #include "kernelcompat.h"
 #include "channels.h"
 #include "usterr.h"
+#include "marker.h"
 
 /*
  * ltt_channel_mutex may be nested inside the LTT trace mutex.
index bb51bb7202738c9e3d90c5f3e052fa58a46384a7..f064316186055fac620d5ee6a2dc61a892b2ddb8 100644 (file)
@@ -31,6 +31,8 @@
 //ust// #include <linux/mutex.h>
 //ust// #include <linux/seq_file.h>
 //ust// #include <linux/slab.h>
+#include <ctype.h>
+
 #include "kernelcompat.h"
 //#include "list.h"
 #include "tracer.h"
@@ -85,6 +87,7 @@ static struct ltt_available_probe *get_probe_from_name(const char *pname)
                return NULL;
 }
 
+/* (unused)
 static char *skip_spaces(char *buf)
 {
        while (*buf != '\0' && isspace(*buf))
@@ -106,6 +109,7 @@ static void get_marker_string(char *buf, char **start,
        *end = skip_nonspaces(*start);
        **end = '\0';
 }
+*/
 
 int ltt_probe_register(struct ltt_available_probe *pdata)
 {
@@ -131,7 +135,6 @@ end:
        mutex_unlock(&probes_mutex);
        return ret;
 }
-EXPORT_SYMBOL_GPL(ltt_probe_register);
 
 /*
  * Called when a probe does not want to be called anymore.
@@ -157,7 +160,6 @@ end:
        mutex_unlock(&probes_mutex);
        return ret;
 }
-EXPORT_SYMBOL_GPL(ltt_probe_unregister);
 
 /*
  * Connect marker "mname" to probe "pname".
@@ -203,7 +205,6 @@ end:
        ltt_unlock_traces();
        return ret;
 }
-EXPORT_SYMBOL_GPL(ltt_marker_connect);
 
 /*
  * Disconnect marker "mname", probe "pname".
@@ -243,7 +244,6 @@ end:
        mutex_unlock(&probes_mutex);
        return ret;
 }
-EXPORT_SYMBOL_GPL(ltt_marker_disconnect);
 
 /*
  * function handling proc entry write.
@@ -435,7 +435,7 @@ void __attribute__((constructor)) init_marker_control(void)
 }
 //ust// module_init(marker_control_init);
 
-static void __exit marker_control_exit(void)
+static void __attribute__((destructor)) marker_control_exit(void)
 {
        int ret;
 
index 33c500af1b931728b4ad1d3027d1532aa0d3e20c..ff3de64855e7c72e8394e02832484bf710ee7b39 100644 (file)
@@ -53,6 +53,9 @@ static const int marker_debug;
  */
 static DEFINE_MUTEX(markers_mutex);
 
+static LIST_HEAD(libs);
+
+
 void lock_markers(void)
 {
        mutex_lock(&markers_mutex);
@@ -631,9 +634,9 @@ static int set_marker(struct marker_entry *entry, struct marker *elem,
  */
 static void disable_marker(struct marker *elem)
 {
-       int ret;
-
-       /* leave "call" as is. It is known statically. */
+//ust//        int ret;
+//ust//
+//ust//        /* leave "call" as is. It is known statically. */
 //ust//        if (elem->tp_name && _imv_read(elem->state)) {
 //ust//                WARN_ON(!elem->tp_cb);
 //ust//                /*
@@ -703,6 +706,18 @@ void marker_update_probe_range(struct marker *begin,
        mutex_unlock(&markers_mutex);
 }
 
+static void lib_update_markers(void)
+{
+       struct lib *lib;
+
+       /* FIXME: we should probably take a mutex here on libs */
+//ust//        mutex_lock(&module_mutex);
+       list_for_each_entry(lib, &libs, list)
+               marker_update_probe_range(lib->markers_start,
+                               lib->markers_start + lib->markers_count);
+//ust//        mutex_unlock(&module_mutex);
+}
+
 /*
  * Update probes, removing the faulty probes.
  *
@@ -1056,6 +1071,33 @@ void *marker_get_private_data(const char *channel, const char *name,
 
 //ust//#ifdef CONFIG_MODULES
 
+/*
+ * Returns 0 if current not found.
+ * Returns 1 if current found.
+ */
+int lib_get_iter_markers(struct marker_iter *iter)
+{
+       struct lib *iter_lib;
+       int found = 0;
+
+//ust//        mutex_lock(&module_mutex);
+       list_for_each_entry(iter_lib, &libs, list) {
+               if (iter_lib < iter->lib)
+                       continue;
+               else if (iter_lib > iter->lib)
+                       iter->marker = NULL;
+               found = marker_get_iter_range(&iter->marker,
+                       iter_lib->markers_start,
+                       iter_lib->markers_start + iter_lib->markers_count);
+               if (found) {
+                       iter->lib = iter_lib;
+                       break;
+               }
+       }
+//ust//        mutex_unlock(&module_mutex);
+       return found;
+}
+
 /**
  * marker_get_iter_range - Get a next marker iterator given a range.
  * @marker: current markers (in), next marker (out)
@@ -1436,47 +1478,6 @@ void ltt_dump_marker_state(struct ltt_trace_struct *trace)
 }
 //ust// EXPORT_SYMBOL_GPL(ltt_dump_marker_state);
 
-
-static LIST_HEAD(libs);
-
-/*
- * Returns 0 if current not found.
- * Returns 1 if current found.
- */
-int lib_get_iter_markers(struct marker_iter *iter)
-{
-       struct lib *iter_lib;
-       int found = 0;
-
-//ust//        mutex_lock(&module_mutex);
-       list_for_each_entry(iter_lib, &libs, list) {
-               if (iter_lib < iter->lib)
-                       continue;
-               else if (iter_lib > iter->lib)
-                       iter->marker = NULL;
-               found = marker_get_iter_range(&iter->marker,
-                       iter_lib->markers_start,
-                       iter_lib->markers_start + iter_lib->markers_count);
-               if (found) {
-                       iter->lib = iter_lib;
-                       break;
-               }
-       }
-//ust//        mutex_unlock(&module_mutex);
-       return found;
-}
-
-void lib_update_markers(void)
-{
-       struct lib *lib;
-
-//ust//        mutex_lock(&module_mutex);
-       list_for_each_entry(lib, &libs, list)
-               marker_update_probe_range(lib->markers_start,
-                               lib->markers_start + lib->markers_count);
-//ust//        mutex_unlock(&module_mutex);
-}
-
 static void (*new_marker_cb)(struct marker *) = NULL;
 
 void marker_set_new_marker_cb(void (*cb)(struct marker *))
index 27794f9e5e2070358d2658b1ab0fa86336d56fc9..1235a9a7cd481a17dd5dd9adc3bebed76e879826 100644 (file)
@@ -182,7 +182,7 @@ static void relay_destroy_channel(struct kref *kref)
 static void relay_destroy_buf(struct rchan_buf *buf)
 {
        struct rchan *chan = buf->chan;
-       struct buf_page *buf_page, *n;
+//ust//        struct buf_page *buf_page;
        int result;
 
        result = munmap(buf->buf_data, buf->buf_size);
@@ -222,21 +222,21 @@ static void relay_remove_buf(struct kref *kref)
 /*
  * create_buf_file_create() default callback.  Does nothing.
  */
-static struct dentry *create_buf_file_default_callback(const char *filename,
-                                                      struct dentry *parent,
-                                                      int mode,
-                                                      struct rchan_buf *buf)
-{
-       return NULL;
-}
+//ust// static struct dentry *create_buf_file_default_callback(const char *filename,
+//ust//                                                       struct dentry *parent,
+//ust//                                                       int mode,
+//ust//                                                       struct rchan_buf *buf)
+//ust// {
+//ust//        return NULL;
+//ust// }
 
-/*
- * remove_buf_file() default callback.  Does nothing.
- */
-static int remove_buf_file_default_callback(struct dentry *dentry)
-{
-       return -EINVAL;
-}
+//ust// /*
+//ust//  * remove_buf_file() default callback.  Does nothing.
+//ust//  */
+//ust// static int remove_buf_file_default_callback(struct dentry *dentry)
+//ust// {
+//ust//        return -EINVAL;
+//ust// }
 
 /**
  *     wakeup_readers - wake up readers waiting on a channel
@@ -277,7 +277,7 @@ static void __relay_reset(struct rchan_buf *buf, unsigned int init)
 static struct rchan_buf *relay_open_buf(struct rchan *chan)
 {
        struct rchan_buf *buf = NULL;
-       struct dentry *dentry;
+//ust//        struct dentry *dentry;
 //ust//        char *tmpname;
 
 //ust//        tmpname = kzalloc(NAME_MAX + 1, GFP_KERNEL);
@@ -304,12 +304,12 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan)
 
        goto free_name;
 
-free_buf:
+//ust//free_buf:
        relay_destroy_buf(buf);
        buf = NULL;
 free_name:
 //ust//        kfree(tmpname);
-end:
+//ust//end:
        return buf;
 }
 
@@ -406,7 +406,7 @@ struct rchan *ltt_relay_open(const char *base_filename,
                         size_t n_subbufs,
                         void *private_data)
 {
-       unsigned int i;
+//ust//        unsigned int i;
        struct rchan *chan;
 //ust//        if (!base_filename)
 //ust//                return NULL;
@@ -462,7 +462,7 @@ struct rchan *ltt_relay_open(const char *base_filename,
  */
 void ltt_relay_close(struct rchan *chan)
 {
-       unsigned int i;
+//ust//        unsigned int i;
 
        if (!chan)
                return;
@@ -929,16 +929,16 @@ static struct dentry *ltt_create_buf_file_callback(struct rchan_buf *buf)
        return NULL;
 }
 
-static int ltt_remove_buf_file_callback(struct rchan_buf *buf)
-{
-//ust//        struct rchan_buf *buf = dentry->d_inode->i_private;
-       struct ltt_channel_struct *ltt_chan = buf->chan->private_data;
-
-//ust//        debugfs_remove(dentry);
-       ltt_relay_destroy_buffer(ltt_chan);
-
-       return 0;
-}
+//ust// static int ltt_remove_buf_file_callback(struct rchan_buf *buf)
+//ust// {
+//ust// //ust//        struct rchan_buf *buf = dentry->d_inode->i_private;
+//ust//        struct ltt_channel_struct *ltt_chan = buf->chan->private_data;
+//ust// 
+//ust// //ust//        debugfs_remove(dentry);
+//ust//        ltt_relay_destroy_buffer(ltt_chan);
+//ust// 
+//ust//        return 0;
+//ust// }
 
 /*
  * Wake writers :
@@ -1694,7 +1694,7 @@ static void ltt_relay_async_wakeup_chan(struct ltt_channel_struct *ltt_channel)
 static void ltt_relay_finish_buffer(struct ltt_channel_struct *ltt_channel)
 {
        struct rchan *rchan = ltt_channel->trans_channel_data;
-       int result;
+//     int result;
 
        if (rchan->buf) {
                struct ltt_channel_buf_struct *ltt_buf = ltt_channel->buf;
@@ -1714,7 +1714,7 @@ static void ltt_relay_finish_buffer(struct ltt_channel_struct *ltt_channel)
 
 static void ltt_relay_finish_channel(struct ltt_channel_struct *ltt_channel)
 {
-       unsigned int i;
+//ust//        unsigned int i;
 
 //ust//        for_each_possible_cpu(i)
                ltt_relay_finish_buffer(ltt_channel);
@@ -2481,7 +2481,7 @@ void __attribute__((constructor)) init_ustrelay_transport(void)
        }
 }
 
-static void __exit ltt_relay_exit(void)
+static void __attribute__((destructor)) ltt_relay_exit(void)
 {
 //ust//        printk(KERN_INFO "LTT : ltt-relay exit\n");
 
index ba7c1d63aa2d10c35349bf2d86b70e9000228e04..ba536d700672af24dbf9d316f9edc7895f02147f 100644 (file)
@@ -381,4 +381,9 @@ int ltt_do_put_subbuf(struct rchan_buf *buf, struct ltt_channel_buf_struct *ltt_
 
 void init_ustrelay_transport(void);
 
+/*static*/ /* inline */ notrace void ltt_commit_slot(
+               struct ltt_channel_struct *ltt_channel,
+               void **transport_data, long buf_offset,
+               size_t data_size, size_t slot_size);
+
 #endif /* _LINUX_LTT_RELAY_H */
index 72e161d5587f31bd99afe2935367ace7cfb216d1..238bd257aebefff6861eaa231786410460b2f8f6 100644 (file)
@@ -554,7 +554,6 @@ notrace size_t ltt_serialize_data(struct rchan_buf *buf, size_t buf_offset,
        }
        return buf_offset;
 }
-EXPORT_SYMBOL_GPL(ltt_serialize_data);
 
 /*
  * Calculate data size
@@ -696,7 +695,6 @@ notrace void ltt_vtrace(const struct marker *mdata, void *probe_data,
        ltt_nesting--;
        rcu_read_unlock(); //ust// rcu_read_unlock_sched_notrace();
 }
-EXPORT_SYMBOL_GPL(ltt_vtrace);
 
 notrace void ltt_trace(const struct marker *mdata, void *probe_data,
                       void *call_data, const char *fmt, ...)
@@ -707,7 +705,6 @@ notrace void ltt_trace(const struct marker *mdata, void *probe_data,
        ltt_vtrace(mdata, probe_data, call_data, fmt, &args);
        va_end(args);
 }
-EXPORT_SYMBOL_GPL(ltt_trace);
 
 //ust// MODULE_LICENSE("GPL");
 //ust// MODULE_AUTHOR("Mathieu Desnoyers");
index d6b09737a8cd052096e31465ea90573753db8d7e..ee335adfbf20e827c326574fc02d1b99e5ec1661 100644 (file)
@@ -311,6 +311,17 @@ void tracepoint_update_probe_range(struct tracepoint *begin,
        mutex_unlock(&tracepoints_mutex);
 }
 
+static void lib_update_tracepoints(void)
+{
+       struct tracepoint_lib *lib;
+
+//ust//        mutex_lock(&module_mutex);
+       list_for_each_entry(lib, &libs, list)
+               tracepoint_update_probe_range(lib->tracepoints_start,
+                               lib->tracepoints_start + lib->tracepoints_count);
+//ust//        mutex_unlock(&module_mutex);
+}
+
 /*
  * Update probes, removing the faulty probes.
  */
@@ -496,6 +507,33 @@ void tracepoint_probe_update_all(void)
 }
 //ust// EXPORT_SYMBOL_GPL(tracepoint_probe_update_all);
 
+/*
+ * Returns 0 if current not found.
+ * Returns 1 if current found.
+ */
+int lib_get_iter_tracepoints(struct tracepoint_iter *iter)
+{
+       struct tracepoint_lib *iter_lib;
+       int found = 0;
+
+//ust//        mutex_lock(&module_mutex);
+       list_for_each_entry(iter_lib, &libs, list) {
+               if (iter_lib < iter->lib)
+                       continue;
+               else if (iter_lib > iter->lib)
+                       iter->tracepoint = NULL;
+               found = tracepoint_get_iter_range(&iter->tracepoint,
+                       iter_lib->tracepoints_start,
+                       iter_lib->tracepoints_start + iter_lib->tracepoints_count);
+               if (found) {
+                       iter->lib = iter_lib;
+                       break;
+               }
+       }
+//ust//        mutex_unlock(&module_mutex);
+       return found;
+}
+
 /**
  * tracepoint_get_iter_range - Get a next tracepoint iterator given a range.
  * @tracepoint: current tracepoints (in), next tracepoint (out)
@@ -532,7 +570,7 @@ static void tracepoint_get_iter(struct tracepoint_iter *iter)
 //ust//        }
        /* tracepoints in libs. */
        found = lib_get_iter_tracepoints(iter);
-end:
+//ust// end:
        if (!found)
                tracepoint_iter_reset(iter);
 }
@@ -600,44 +638,6 @@ void tracepoint_iter_reset(struct tracepoint_iter *iter)
 
 //ust// #endif /* CONFIG_MODULES */
 
-/*
- * Returns 0 if current not found.
- * Returns 1 if current found.
- */
-int lib_get_iter_tracepoints(struct tracepoint_iter *iter)
-{
-       struct tracepoint_lib *iter_lib;
-       int found = 0;
-
-//ust//        mutex_lock(&module_mutex);
-       list_for_each_entry(iter_lib, &libs, list) {
-               if (iter_lib < iter->lib)
-                       continue;
-               else if (iter_lib > iter->lib)
-                       iter->tracepoint = NULL;
-               found = marker_get_iter_range(&iter->tracepoint,
-                       iter_lib->tracepoints_start,
-                       iter_lib->tracepoints_start + iter_lib->tracepoints_count);
-               if (found) {
-                       iter->lib = iter_lib;
-                       break;
-               }
-       }
-//ust//        mutex_unlock(&module_mutex);
-       return found;
-}
-
-void lib_update_tracepoints(void)
-{
-       struct tracepoint_lib *lib;
-
-//ust//        mutex_lock(&module_mutex);
-       list_for_each_entry(lib, &libs, list)
-               tracepoint_update_probe_range(lib->tracepoints_start,
-                               lib->tracepoints_start + lib->tracepoints_count);
-//ust//        mutex_unlock(&module_mutex);
-}
-
 static void (*new_tracepoint_cb)(struct tracepoint *) = NULL;
 
 void tracepoint_set_new_tracepoint_cb(void (*cb)(struct tracepoint *))
index 9c7e557aa050bc4a13f02a8cd2ecb6b51f8c63b0..bb8c7697f38d8c9b4bb7f31a9936b41a0790e01a 100644 (file)
@@ -374,9 +374,9 @@ struct ltt_trace_struct *_ltt_trace_find_setup(const char *trace_name)
  */
 void ltt_release_transport(struct kref *kref)
 {
-       struct ltt_trace_struct *trace = container_of(kref,
-                       struct ltt_trace_struct, ltt_transport_kref);
-//ust//        trace->ops->remove_dirs(trace);
+//ust//        struct ltt_trace_struct *trace = container_of(kref,
+//ust//                        struct ltt_trace_struct, ltt_transport_kref);
+//ust//        trace->ops->remove_dirs(trace);
 }
 //ust// EXPORT_SYMBOL_GPL(ltt_release_transport);
 
@@ -682,7 +682,7 @@ int ltt_trace_alloc(const char *trace_name)
        int err = 0;
        struct ltt_trace_struct *trace;
        unsigned int subbuf_size, subbuf_cnt;
-       unsigned long flags;
+//ust//        unsigned long flags;
        int chan;
        const char *channel_name;
 
@@ -768,7 +768,7 @@ create_channel_error:
                if (trace->channels[chan].active)
                        trace->ops->remove_channel(&trace->channels[chan]);
 
-dirs_error:
+//ust// dirs_error:
 //ust//        module_put(trace->transport->owner);
 transport_error:
 //ust//        put_trace_clock();
@@ -783,28 +783,28 @@ traces_error:
  * We will make a new ltt_control based on debugfs, and control each channel's
  * buffer.
  */
-static int ltt_trace_create(const char *trace_name, const char *trace_type,
-               enum trace_mode mode,
-               unsigned int subbuf_size_low, unsigned int n_subbufs_low,
-               unsigned int subbuf_size_med, unsigned int n_subbufs_med,
-               unsigned int subbuf_size_high, unsigned int n_subbufs_high)
-{
-       int err = 0;
-
-       err = ltt_trace_setup(trace_name);
-       if (IS_ERR_VALUE(err))
-               return err;
-
-       err = ltt_trace_set_type(trace_name, trace_type);
-       if (IS_ERR_VALUE(err))
-               return err;
-
-       err = ltt_trace_alloc(trace_name);
-       if (IS_ERR_VALUE(err))
-               return err;
-
-       return err;
-}
+//ust// static int ltt_trace_create(const char *trace_name, const char *trace_type,
+//ust//                enum trace_mode mode,
+//ust//                unsigned int subbuf_size_low, unsigned int n_subbufs_low,
+//ust//                unsigned int subbuf_size_med, unsigned int n_subbufs_med,
+//ust//                unsigned int subbuf_size_high, unsigned int n_subbufs_high)
+//ust// {
+//ust//        int err = 0;
+//ust// 
+//ust//        err = ltt_trace_setup(trace_name);
+//ust//        if (IS_ERR_VALUE(err))
+//ust//                return err;
+//ust// 
+//ust//        err = ltt_trace_set_type(trace_name, trace_type);
+//ust//        if (IS_ERR_VALUE(err))
+//ust//                return err;
+//ust// 
+//ust//        err = ltt_trace_alloc(trace_name);
+//ust//        if (IS_ERR_VALUE(err))
+//ust//                return err;
+//ust// 
+//ust//        return err;
+//ust// }
 
 /* Must be called while sure that trace is in the list. */
 static int _ltt_trace_destroy(struct ltt_trace_struct  *trace)
@@ -946,7 +946,7 @@ static int _ltt_trace_start(struct ltt_trace_struct *trace)
        return err;
 
        /* error handling */
-get_ltt_run_filter_error:
+//ust// get_ltt_run_filter_error:
 traces_error:
        return err;
 }
@@ -1113,7 +1113,7 @@ int ltt_filter_control(enum ltt_filter_control_msg msg, const char *trace_name)
        }
 //ust//        module_put(ltt_filter_control_owner);
 
-get_module_error:
+//ust// get_module_error:
 trace_error:
        ltt_unlock_traces();
        return err;
index 9d0d116042a1a6a4d4f783834b24d2d827a3df67..223280cc238201130166b94f3399e447913b21c4 100644 (file)
 #include <fcntl.h>
 #include <string.h>
 #include <dirent.h>
-#
 
 #include "ustcomm.h"
 #include "ustcmd.h"
 
 #define _GNU_SOURCE
 
-pid_t* ustcmd_get_online_pids(void) {
+pid_t* ustcmd_get_online_pids(void)
+{
        struct dirent* dirent;
        DIR* dir;
        unsigned int ret_size = 1 * sizeof(pid_t), i = 0;
@@ -42,7 +42,7 @@ pid_t* ustcmd_get_online_pids(void) {
 
        pid_t* ret = (pid_t*) malloc(ret_size);
 
-       while (dirent = readdir(dir)) {
+       while ((dirent = readdir(dir))) {
                if (!strcmp(dirent->d_name, ".") ||
                        !strcmp(dirent->d_name, "..")) {
 
@@ -108,10 +108,12 @@ int ustcmd_set_marker_state(const char* mn, int state, pid_t pid)
  * @param pid  Traced process ID
  * @return     0 if successful, or error USTCMD_ERR_GEN
  */
-int ustcmd_destroy_trace(pid_t pid) {
-       int tres;
+int ustcmd_destroy_trace(pid_t pid)
+{
+       int result;
 
-       if (tres = ustcmd_shoot("destroy", pid, NULL)) {
+       result = ustcmd_shoot("destroy", pid, NULL);
+       if (result) {
                return USTCMD_ERR_GEN;
        }
 
@@ -124,10 +126,12 @@ int ustcmd_destroy_trace(pid_t pid) {
  * @param pid  Traced process ID
  * @return     0 if successful, or error USTCMD_ERR_GEN
  */
-int ustcmd_setup_and_start(pid_t pid) {
-       int tres;
+int ustcmd_setup_and_start(pid_t pid)
+{
+       int result;
 
-       if (tres = ustcmd_shoot("start", pid, NULL)) {
+       result = ustcmd_shoot("start", pid, NULL);
+       if (result) {
                return USTCMD_ERR_GEN;
        }
 
@@ -140,10 +144,12 @@ int ustcmd_setup_and_start(pid_t pid) {
  * @param pid  Traced process ID
  * @return     0 if successful, or error USTCMD_ERR_GEN
  */
-int ustcmd_start_trace(pid_t pid) {
-       int tres;
+int ustcmd_start_trace(pid_t pid)
+{
+       int result;
 
-       if (tres = ustcmd_shoot("trace_start", pid, NULL)) {
+       result = ustcmd_shoot("trace_start", pid, NULL);
+       if (result) {
                return USTCMD_ERR_GEN;
        }
 
@@ -156,10 +162,12 @@ int ustcmd_start_trace(pid_t pid) {
  * @param pid  Traced process ID
  * @return     0 if successful, or error USTCMD_ERR_GEN
  */
-int ustcmd_stop_trace(pid_t pid) {
-       int tres;
+int ustcmd_stop_trace(pid_t pid)
+{
+       int result;
 
-       if (tres = ustcmd_shoot("trace_stop", pid, NULL)) {
+       result = ustcmd_shoot("trace_stop", pid, NULL);
+       if (result) {
                return USTCMD_ERR_GEN;
        }
 
@@ -172,7 +180,8 @@ int ustcmd_stop_trace(pid_t pid) {
  * @param str  String to search in
  * @return     Total newlines count
  */
-unsigned int ustcmd_count_nl(const char* str) {
+unsigned int ustcmd_count_nl(const char* str)
+{
        unsigned int i = 0, tot = 0;
 
        while (str[i] != '\0') {
@@ -191,7 +200,8 @@ unsigned int ustcmd_count_nl(const char* str) {
  * @param cmsf CMSF array to free
  * @return     0 if successful, or error USTCMD_ERR_ARG
  */
-int ustcmd_free_cmsf(struct USTcmd_cmsf* cmsf) {
+int ustcmd_free_cmsf(struct USTcmd_cmsf* cmsf)
+{
        if (cmsf == NULL) {
                return USTCMD_ERR_ARG;
        }
@@ -216,7 +226,8 @@ int ustcmd_free_cmsf(struct USTcmd_cmsf* cmsf) {
  * @param pid  Targeted PID
  * @return     0 if successful, or errors {USTCMD_ERR_ARG, USTCMD_ERR_GEN}
  */
-int ustcmd_get_cmsf(struct USTcmd_cmsf** cmsf, const pid_t pid) {
+int ustcmd_get_cmsf(struct USTcmd_cmsf** cmsf, const pid_t pid)
+{
        char* big_str = NULL;
        int result;
        struct USTcmd_cmsf* tmp_cmsf = NULL;
@@ -278,7 +289,11 @@ int ustcmd_get_cmsf(struct USTcmd_cmsf** cmsf, const pid_t pid) {
  *             be NULL if no reply is needed for the given command).
  * @return     0 if successful, or errors {USTCMD_ERR_ARG, USTCMD_ERR_CONN}
  */
-int ustcmd_shoot(const char* cmd, const pid_t pid, char** reply) {
+
+int ustcmd_shoot(const char* cmd, const pid_t pid, char** reply)
+{
+       struct ustcomm_connection conn;
+
        if (cmd == NULL) {
                return USTCMD_ERR_ARG;
        }
index f3263582cd0f7a6b33497aec1b7befbebd74ea07..e8199b3aaf5c6b70eadb2bd2fb01083684ae9c36 100644 (file)
@@ -417,7 +417,7 @@ static int init_named_socket(char *name, char **path_out)
        return -1;
 }
 
-int ustcomm_send_request(struct ustcomm_connection *conn, char *req, char **reply)
+int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply)
 {
        int result;
 
index fed2335904d90b5038efbcf1a64e2b47057290ca..9dc84bdcc9cf1dacc3c868d22223b6df42f05bbb 100644 (file)
@@ -67,7 +67,7 @@ int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle);
 int ustcomm_init_ustd(struct ustcomm_ustd *handle);
 
 int ustcomm_connect_app(pid_t pid, struct ustcomm_connection *conn);
-int ustcomm_send_request(struct ustcomm_connection *conn, char *req, char **reply);
+int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply);
 int ustcomm_send_reply(struct ustcomm_server *server, char *msg, struct ustcomm_source *src);
 
 int nth_token_is(char *str, char *token, int tok_no);
index fada46f06f448b00538ea9f66883f9fcd9dd52bc..b0c77e0972a66f8d03235494f4e5be72fcbc281a 100644 (file)
@@ -92,8 +92,6 @@ static inline long IS_ERR(const void *ptr)
 /* ATTRIBUTES */
 
 #define ____cacheline_aligned
-#define __init
-#define __exit
 
 /* MATH */
 
index d572973acd540dbb1c1b00db3bdb7addfe25f3be..d8916653ad1722b00bfec8df45a40e1bc5c8a7d1 100644 (file)
--- a/ust/ust.c
+++ b/ust/ust.c
@@ -142,7 +142,7 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
                }
        }
 
-       if(argc - optind > 0 && opts->cmd != GET_ONLINE_PIDS) {
+       if (argc - optind > 0 && opts->cmd != GET_ONLINE_PIDS) {
                int i;
                int pididx=0;
                opts->pids = malloc((argc-optind+1) * sizeof(pid_t));
@@ -153,13 +153,57 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
                opts->pids[pididx] = -1;
        }
 
+       if (opts->cmd == ENABLE_MARKER || opts->cmd == DISABLE_MARKER) {
+               if (opts->regex_state = regcomp(&opts->preg, opts->regex, 0)) {
+                       fprintf(stderr, "Invalid regular expression.\n");
+               }
+       }
+
        return 0;
 }
 
+static void regex_change_m_state(struct ust_opts* opts, pid_t pid) {
+       struct USTcmd_cmsf* cmsf = NULL;
+       unsigned int i = 0;
+       int e = (opts->cmd == ENABLE_MARKER);
+
+       if (opts->regex_state != 0) {
+               return;
+       }
+
+       if (ustcmd_get_cmsf(&cmsf, pid)) {
+               fprintf(stderr, "error while trying to get markers for PID "
+                       "%u\n", (unsigned int) pid);
+               return;
+       }
+       while (cmsf[i].channel != NULL) {
+               char* mc;
+               asprintf(&mc, "%s/%s", cmsf[i].channel, cmsf[i].marker);
+               if (regexec(&opts->preg, mc, 0, NULL, 0) == 0) {
+                       /* We got a match! */
+                       if (ustcmd_set_marker_state(mc,
+                       e ? USTCMD_MS_ON : USTCMD_MS_OFF, pid)) {
+                               fprintf(stderr,
+                                       "error while trying to %sable marker"
+                                       "\"%s\" for PID %u\n",
+                                       e ? "en" : "dis", mc,
+                                       (unsigned int) pid);
+                       } else {
+                               printf("sucessfully %sabled marker "
+                                       "\"%s\" for PID %u\n",
+                                       e ? "en" : "dis", mc,
+                                       (unsigned int) pid);
+                       }
+               }
+               free(mc);
+               ++i;
+       }
+       ustcmd_free_cmsf(cmsf);
+}
+
 int main(int argc, char *argv[])
 {
        pid_t *pidit;
-       //char *msg = argv[2];
        struct ustcomm_connection conn;
        int result;
        struct ust_opts opts;
This page took 0.03742 seconds and 4 git commands to generate.