From: compudj Date: Sat, 30 Jul 2005 00:10:28 +0000 (+0000) Subject: libltt : size + n subbufs + align options X-Git-Tag: v0.12.20~2499 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fde1a29ab6228b04060220d2b2d4fb9c3b032a50;p=lttv.git libltt : size + n subbufs + align options git-svn-id: http://ltt.polymtl.ca/svn@990 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/libltt/libltt.c b/ltt/branches/poly/libltt/libltt.c index 5363f843..72eabd70 100644 --- a/ltt/branches/poly/libltt/libltt.c +++ b/ltt/branches/poly/libltt/libltt.c @@ -292,7 +292,7 @@ int lttctl_destroy_handle(struct lttctl_handle *h) int lttctl_create_trace(const struct lttctl_handle *h, - char *name, enum trace_mode mode) + char *name, enum trace_mode mode, unsigned subbuf_size, unsigned n_subbufs) { int err; @@ -315,7 +315,9 @@ int lttctl_create_trace(const struct lttctl_handle *h, strncpy(req.msg.trace_name, name, NAME_MAX); req.msg.op = OP_CREATE; - req.msg.args.mode = mode; + req.msg.args.new_trace.mode = mode; + req.msg.args.new_trace.subbuf_size = subbuf_size; + req.msg.args.new_trace.n_subbufs = n_subbufs; err = lttctl_netlink_sendto(h, (void *)&req, req.nlh.nlmsg_len); if(err < 0) goto senderr; @@ -468,3 +470,48 @@ senderr: lttctl_perror("Stop Trace Error"); return err; } + + +int lttctl_align(const struct lttctl_handle *h, + char *name, unsigned alignment) +{ + struct { + struct nlmsghdr nlh; + lttctl_peer_msg_t msg; + } req; + struct { + struct nlmsghdr nlh; + struct nlmsgerr nlerr; + lttctl_peer_msg_t msg; + } ack; + int err; + + memset(&req, 0, sizeof(req)); + req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(lttctl_peer_msg_t)); + req.nlh.nlmsg_flags = NLM_F_REQUEST; + req.nlh.nlmsg_type = LTTCTLM_CONTROL; + req.nlh.nlmsg_pid = h->local.nl_pid; + + strncpy(req.msg.trace_name, name, NAME_MAX); + req.msg.op = OP_ALIGN; + req.msg.args.alignment = alignment; + + err = lttctl_netlink_sendto(h, (void *)&req, req.nlh.nlmsg_len); + if(err < 0) goto senderr; + + err = lttctl_netlink_recvfrom(h, (void*)&ack, sizeof(ack), 0); + if(err < 0) goto senderr; + + err = ack.nlerr.error; + if(err != 0) { + errno = err; + lttctl_perror("Align Trace Error"); + return -1; + } + + return 0; + +senderr: + lttctl_perror("Align Trace Error"); + return err; +} diff --git a/ltt/branches/poly/libltt/libltt.h b/ltt/branches/poly/libltt/libltt.h index 68281a2c..06a40f24 100644 --- a/ltt/branches/poly/libltt/libltt.h +++ b/ltt/branches/poly/libltt/libltt.h @@ -37,6 +37,7 @@ enum trace_op { OP_DESTROY, OP_START, OP_STOP, + OP_ALIGN, OP_NONE }; @@ -45,6 +46,19 @@ enum trace_mode { LTT_TRACE_FLIGHT }; +typedef struct lttctl_peer_msg { + char trace_name[NAME_MAX]; + enum trace_op op; + union { + struct { + enum trace_mode mode; + unsigned subbuf_size; + unsigned n_subbufs; + } new_trace; + unsigned alignment; + } args; +} lttctl_peer_msg_t; + struct lttctl_handle { @@ -54,14 +68,6 @@ struct lttctl_handle struct sockaddr_nl peer; }; -typedef struct lttctl_peer_msg { - char trace_name[NAME_MAX]; - enum trace_op op; - union { - enum trace_mode mode; - } args; -} lttctl_peer_msg_t; - typedef struct lttctl_resp_msg { int err; } lttctl_resp_msg_t; @@ -71,8 +77,8 @@ struct lttctl_handle *lttctl_create_handle(void); int lttctl_destroy_handle(struct lttctl_handle *h); -int lttctl_create_trace(const struct lttctl_handle * handle, - char *name, enum trace_mode mode); +int lttctl_create_trace(const struct lttctl_handle *h, + char *name, enum trace_mode mode, unsigned subbuf_size, unsigned n_subbufs); int lttctl_destroy_trace(const struct lttctl_handle *handle, char *name);