*/
#include <stdarg.h>
-//ust// #include <linux/ctype.h>
-//ust// #include <linux/string.h>
-//ust// #include <linux/module.h>
-//ust// #include <linux/ltt-tracer.h>
#include <string.h>
#include <stdint.h>
+#include <stdio.h>
#include <ust/kernelcompat.h>
#define _LGPL_SOURCE
#include <urcu-bp.h>
#include <urcu/rculist.h>
-#include "relay.h"
+#include "buffers.h"
#include "tracer.h"
//#include "list.h"
#include "usterr.h"
return fmt;
}
-static inline size_t serialize_trace_data(struct rchan_buf *buf,
+static inline size_t serialize_trace_data(struct ust_buffer *buf,
size_t buf_offset,
char trace_size, enum ltt_type trace_type,
char c_size, enum ltt_type c_type,
tmp.v_string.s = "<NULL>";
tmp.v_string.len = strlen(tmp.v_string.s)+1;
if (buf)
- ltt_relay_write(buf, buf_offset, tmp.v_string.s,
+ ust_buffers_write(buf, buf_offset, tmp.v_string.s,
tmp.v_string.len);
buf_offset += tmp.v_string.len;
goto copydone;
switch (trace_size) {
case 1:
if (c_size == 8)
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(uint8_t[]){ (uint8_t)tmp.v_uint64 },
sizeof(uint8_t));
else
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(uint8_t[]){ (uint8_t)tmp.v_ulong },
sizeof(uint8_t));
break;
case 2:
if (c_size == 8)
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(uint16_t[]){ (uint16_t)tmp.v_uint64 },
sizeof(uint16_t));
else
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(uint16_t[]){ (uint16_t)tmp.v_ulong },
sizeof(uint16_t));
break;
case 4:
if (c_size == 8)
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(uint32_t[]){ (uint32_t)tmp.v_uint64 },
sizeof(uint32_t));
else
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(uint32_t[]){ (uint32_t)tmp.v_ulong },
sizeof(uint32_t));
break;
* c_size cannot be other than 8 here because
* trace_size > 4.
*/
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(uint64_t[]){ (uint64_t)tmp.v_uint64 },
sizeof(uint64_t));
break;
if (buf) {
switch (trace_type) {
case LTT_TYPE_SIGNED_INT:
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(int64_t[]){ (int64_t)tmp.v_ulong },
sizeof(int64_t));
break;
case LTT_TYPE_UNSIGNED_INT:
- ltt_relay_write(buf, buf_offset,
+ ust_buffers_write(buf, buf_offset,
(uint64_t[]){ (uint64_t)tmp.v_ulong },
sizeof(uint64_t));
break;
return buf_offset;
}
-notrace size_t ltt_serialize_data(struct rchan_buf *buf, size_t buf_offset,
+static notrace void skip_space(const char **ps)
+{
+ while(**ps == ' ')
+ (*ps)++;
+}
+
+static notrace void copy_token(char **out, const char **in)
+{
+ while(**in != ' ' && **in != '\0') {
+ **out = **in;
+ (*out)++;
+ (*in)++;
+ }
+}
+
+/* serialize_to_text
+ *
+ * Given a format string and a va_list of arguments, convert them to a
+ * human-readable string.
+ *
+ * @outbuf: the buffer to output the string to
+ * @bufsize: the max size that can be used in outbuf
+ * @fmt: the marker format string
+ * @ap: a va_list that contains the arguments corresponding to fmt
+ *
+ * Return value: the number of chars that have been put in outbuf, excluding
+ * the final \0, or, if the buffer was too small, the number of chars that
+ * would have been written in outbuf if it had been large enough.
+ *
+ * outbuf may be NULL. The return value may then be used be allocate an
+ * appropriate outbuf.
+ *
+ */
+
+notrace
+int serialize_to_text(char *outbuf, int bufsize, const char *fmt, va_list ap)
+{
+ int fmt_len = strlen(fmt);
+ char *new_fmt = alloca(fmt_len + 1);
+ const char *orig_fmt_p = fmt;
+ char *new_fmt_p = new_fmt;
+ char false_buf;
+ int result;
+ enum { none, cfmt, tracefmt, argname } prev_token = none;
+
+ while(*orig_fmt_p != '\0') {
+ if(*orig_fmt_p == '%') {
+ prev_token = cfmt;
+ copy_token(&new_fmt_p, &orig_fmt_p);
+ }
+ else if(*orig_fmt_p == '#') {
+ prev_token = tracefmt;
+ do {
+ orig_fmt_p++;
+ } while(*orig_fmt_p != ' ' && *orig_fmt_p != '\0');
+ }
+ else if(*orig_fmt_p == ' ') {
+ if(prev_token == argname) {
+ *new_fmt_p = '=';
+ new_fmt_p++;
+ }
+ else if(prev_token == cfmt) {
+ *new_fmt_p = ' ';
+ new_fmt_p++;
+ }
+
+ skip_space(&orig_fmt_p);
+ }
+ else {
+ prev_token = argname;
+ copy_token(&new_fmt_p, &orig_fmt_p);
+ }
+ }
+
+ *new_fmt_p = '\0';
+
+ if(outbuf == NULL) {
+ /* use this false_buffer for compatibility with pre-C99 */
+ outbuf = &false_buf;
+ bufsize = 1;
+ }
+ result = vsnprintf(outbuf, bufsize, new_fmt, ap);
+
+ return result;
+}
+
+notrace size_t ltt_serialize_data(struct ust_buffer *buf, size_t buf_offset,
struct ltt_serialize_closure *closure,
void *serialize_private, int *largest_align,
const char *fmt, va_list *args)
}
static notrace
-void ltt_write_event_data(struct rchan_buf *buf, size_t buf_offset,
+void ltt_write_event_data(struct ust_buffer *buf, size_t buf_offset,
struct ltt_serialize_closure *closure,
void *serialize_private, int largest_align,
const char *fmt, va_list *args)
uint16_t eID;
size_t data_size, slot_size;
unsigned int chan_index;
- struct ltt_channel_struct *channel;
+ struct ust_channel *channel;
struct ltt_trace_struct *trace, *dest_trace = NULL;
- struct rchan_buf *buf;
+ struct ust_buffer *buf;
void *transport_data;
u64 tsc;
long buf_offset;
va_copy(args_copy, *args);
/* FIXME : could probably encapsulate transport better. */
//ust// buf = ((struct rchan *)channel->trans_channel_data)->buf[cpu];
- buf = ((struct rchan *)channel->trans_channel_data)->buf;
+ buf = channel->buf;
/* Out-of-order write : header and data */
buf_offset = ltt_write_event_header(trace,
- channel, buf, buf_offset,
+ buf, buf_offset,
eID, data_size, tsc, rflags);
ltt_write_event_data(buf, buf_offset, &closure,
serialize_private,