From: Pierre-Marc Fournier Date: Wed, 2 Sep 2009 14:42:49 +0000 (-0400) Subject: code cleanups X-Git-Tag: v0.1~159 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=772030fed323e388da467735cf4b5e8781acb710;p=ust.git code cleanups --- diff --git a/libust/channels.c b/libust/channels.c index 76b9517..10ab587 100644 --- a/libust/channels.c +++ b/libust/channels.c @@ -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. diff --git a/libust/marker-control.c b/libust/marker-control.c index bb51bb7..f064316 100644 --- a/libust/marker-control.c +++ b/libust/marker-control.c @@ -31,6 +31,8 @@ //ust// #include //ust// #include //ust// #include +#include + #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; diff --git a/libust/marker.c b/libust/marker.c index 33c500a..ff3de64 100644 --- a/libust/marker.c +++ b/libust/marker.c @@ -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 *)) diff --git a/libust/relay.c b/libust/relay.c index 27794f9..1235a9a 100644 --- a/libust/relay.c +++ b/libust/relay.c @@ -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"); diff --git a/libust/relay.h b/libust/relay.h index ba7c1d6..ba536d7 100644 --- a/libust/relay.h +++ b/libust/relay.h @@ -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 */ diff --git a/libust/serialize.c b/libust/serialize.c index 72e161d..238bd25 100644 --- a/libust/serialize.c +++ b/libust/serialize.c @@ -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"); diff --git a/libust/tracepoint.c b/libust/tracepoint.c index d6b0973..ee335ad 100644 --- a/libust/tracepoint.c +++ b/libust/tracepoint.c @@ -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 *)) diff --git a/libust/tracer.c b/libust/tracer.c index 9c7e557..bb8c769 100644 --- a/libust/tracer.c +++ b/libust/tracer.c @@ -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; diff --git a/libustcmd/ustcmd.c b/libustcmd/ustcmd.c index 9d0d116..223280c 100644 --- a/libustcmd/ustcmd.c +++ b/libustcmd/ustcmd.c @@ -23,14 +23,14 @@ #include #include #include -# #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; } diff --git a/libustcomm/ustcomm.c b/libustcomm/ustcomm.c index f326358..e8199b3 100644 --- a/libustcomm/ustcomm.c +++ b/libustcomm/ustcomm.c @@ -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; diff --git a/libustcomm/ustcomm.h b/libustcomm/ustcomm.h index fed2335..9dc84bd 100644 --- a/libustcomm/ustcomm.h +++ b/libustcomm/ustcomm.h @@ -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); diff --git a/share/kernelcompat.h b/share/kernelcompat.h index fada46f..b0c77e0 100644 --- a/share/kernelcompat.h +++ b/share/kernelcompat.h @@ -92,8 +92,6 @@ static inline long IS_ERR(const void *ptr) /* ATTRIBUTES */ #define ____cacheline_aligned -#define __init -#define __exit /* MATH */ diff --git a/ust/ust.c b/ust/ust.c index d572973..d891665 100644 --- 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;