|
Packit |
c04fcb |
#ifndef _LTTNG_UST_COMM_H
|
|
Packit |
c04fcb |
#define _LTTNG_UST_COMM_H
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
|
|
Packit |
c04fcb |
* Julien Desfossez <julien.desfossez@polymtl.ca>
|
|
Packit |
c04fcb |
* Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* This library is free software; you can redistribute it and/or
|
|
Packit |
c04fcb |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
c04fcb |
* License as published by the Free Software Foundation; only
|
|
Packit |
c04fcb |
* version 2.1 of the License.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
c04fcb |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
c04fcb |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
c04fcb |
* Lesser General Public License for more details.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
c04fcb |
* License along with this library; if not, write to the Free Software
|
|
Packit |
c04fcb |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* This header is meant for liblttng and libust internal use ONLY.
|
|
Packit |
c04fcb |
* These declarations should NOT be considered stable API.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#include <limits.h>
|
|
Packit |
c04fcb |
#include <unistd.h>
|
|
Packit |
c04fcb |
#include <lttng/ust-abi.h>
|
|
Packit |
c04fcb |
#include <lttng/ust-error.h>
|
|
Packit |
c04fcb |
#include <lttng/ust-compiler.h>
|
|
Packit |
c04fcb |
#include <lttng/ust-ctl.h>
|
|
Packit |
c04fcb |
#include <config.h>
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Default timeout the application waits for the sessiond to send its
|
|
Packit |
c04fcb |
* "register done" command. Can be overridden with the environment
|
|
Packit |
c04fcb |
* variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
|
|
Packit |
c04fcb |
* found, the application proceeds directly without any delay.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS CONFIG_LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#define LTTNG_DEFAULT_RUNDIR LTTNG_SYSTEM_RUNDIR
|
|
Packit |
c04fcb |
#define LTTNG_DEFAULT_HOME_RUNDIR ".lttng"
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/* Queue size of listen(2) */
|
|
Packit |
c04fcb |
#define LTTNG_UST_COMM_MAX_LISTEN 10
|
|
Packit |
c04fcb |
#define LTTNG_UST_COMM_REG_MSG_PADDING 64
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
struct lttng_event_field;
|
|
Packit |
c04fcb |
struct lttng_ctx_field;
|
|
Packit |
c04fcb |
struct lttng_enum_entry;
|
|
Packit |
c04fcb |
struct lttng_integer_type;
|
|
Packit |
c04fcb |
struct lttng_session;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
struct ustctl_reg_msg {
|
|
Packit |
c04fcb |
uint32_t magic;
|
|
Packit |
c04fcb |
uint32_t major;
|
|
Packit |
c04fcb |
uint32_t minor;
|
|
Packit |
c04fcb |
uint32_t pid;
|
|
Packit |
c04fcb |
uint32_t ppid;
|
|
Packit |
c04fcb |
uint32_t uid;
|
|
Packit |
c04fcb |
uint32_t gid;
|
|
Packit |
c04fcb |
uint32_t bits_per_long;
|
|
Packit |
c04fcb |
uint32_t uint8_t_alignment;
|
|
Packit |
c04fcb |
uint32_t uint16_t_alignment;
|
|
Packit |
c04fcb |
uint32_t uint32_t_alignment;
|
|
Packit |
c04fcb |
uint32_t uint64_t_alignment;
|
|
Packit |
c04fcb |
uint32_t long_alignment;
|
|
Packit |
c04fcb |
uint32_t socket_type; /* enum ustctl_socket_type */
|
|
Packit |
c04fcb |
char name[LTTNG_UST_ABI_PROCNAME_LEN]; /* process name */
|
|
Packit |
c04fcb |
char padding[LTTNG_UST_COMM_REG_MSG_PADDING];
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Data structure for the commands sent from sessiond to UST.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
#define USTCOMM_MSG_PADDING1 32
|
|
Packit |
c04fcb |
#define USTCOMM_MSG_PADDING2 32
|
|
Packit |
c04fcb |
struct ustcomm_ust_msg {
|
|
Packit |
c04fcb |
uint32_t handle;
|
|
Packit |
c04fcb |
uint32_t cmd;
|
|
Packit |
c04fcb |
char padding[USTCOMM_MSG_PADDING1];
|
|
Packit |
c04fcb |
union {
|
|
Packit |
c04fcb |
struct lttng_ust_channel channel;
|
|
Packit |
c04fcb |
struct lttng_ust_stream stream;
|
|
Packit |
c04fcb |
struct lttng_ust_event event;
|
|
Packit |
c04fcb |
struct lttng_ust_context context;
|
|
Packit |
c04fcb |
struct lttng_ust_tracer_version version;
|
|
Packit |
c04fcb |
struct lttng_ust_tracepoint_iter tracepoint;
|
|
Packit |
c04fcb |
struct {
|
|
Packit |
c04fcb |
uint32_t data_size; /* following filter data */
|
|
Packit |
c04fcb |
uint32_t reloc_offset;
|
|
Packit |
c04fcb |
uint64_t seqnum;
|
|
Packit |
c04fcb |
} LTTNG_PACKED filter;
|
|
Packit |
c04fcb |
struct {
|
|
Packit |
c04fcb |
uint32_t count; /* how many names follow */
|
|
Packit |
c04fcb |
} LTTNG_PACKED exclusion;
|
|
Packit |
c04fcb |
char padding[USTCOMM_MSG_PADDING2];
|
|
Packit |
c04fcb |
} u;
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Data structure for the response from UST to the session daemon.
|
|
Packit |
c04fcb |
* cmd_type is sent back in the reply for validation.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
#define USTCOMM_REPLY_PADDING1 32
|
|
Packit |
c04fcb |
#define USTCOMM_REPLY_PADDING2 32
|
|
Packit |
c04fcb |
struct ustcomm_ust_reply {
|
|
Packit |
c04fcb |
uint32_t handle;
|
|
Packit |
c04fcb |
uint32_t cmd;
|
|
Packit |
c04fcb |
int32_t ret_code; /* enum ustcomm_return_code */
|
|
Packit |
c04fcb |
uint32_t ret_val; /* return value */
|
|
Packit |
c04fcb |
char padding[USTCOMM_REPLY_PADDING1];
|
|
Packit |
c04fcb |
union {
|
|
Packit |
c04fcb |
struct {
|
|
Packit |
c04fcb |
uint64_t memory_map_size;
|
|
Packit |
c04fcb |
} LTTNG_PACKED channel;
|
|
Packit |
c04fcb |
struct {
|
|
Packit |
c04fcb |
uint64_t memory_map_size;
|
|
Packit |
c04fcb |
} LTTNG_PACKED stream;
|
|
Packit |
c04fcb |
struct lttng_ust_tracer_version version;
|
|
Packit |
c04fcb |
struct lttng_ust_tracepoint_iter tracepoint;
|
|
Packit |
c04fcb |
char padding[USTCOMM_REPLY_PADDING2];
|
|
Packit |
c04fcb |
} u;
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
struct ustcomm_notify_hdr {
|
|
Packit |
c04fcb |
uint32_t notify_cmd;
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#define USTCOMM_NOTIFY_EVENT_MSG_PADDING 32
|
|
Packit |
c04fcb |
struct ustcomm_notify_event_msg {
|
|
Packit |
c04fcb |
uint32_t session_objd;
|
|
Packit |
c04fcb |
uint32_t channel_objd;
|
|
Packit |
c04fcb |
char event_name[LTTNG_UST_SYM_NAME_LEN];
|
|
Packit |
c04fcb |
int32_t loglevel;
|
|
Packit |
c04fcb |
uint32_t signature_len;
|
|
Packit |
c04fcb |
uint32_t fields_len;
|
|
Packit |
c04fcb |
uint32_t model_emf_uri_len;
|
|
Packit |
c04fcb |
char padding[USTCOMM_NOTIFY_EVENT_MSG_PADDING];
|
|
Packit |
c04fcb |
/* followed by signature, fields, and model_emf_uri */
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 32
|
|
Packit |
c04fcb |
struct ustcomm_notify_event_reply {
|
|
Packit |
c04fcb |
int32_t ret_code; /* 0: ok, negative: error code */
|
|
Packit |
c04fcb |
uint32_t event_id;
|
|
Packit |
c04fcb |
char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#define USTCOMM_NOTIFY_ENUM_MSG_PADDING 32
|
|
Packit |
c04fcb |
struct ustcomm_notify_enum_msg {
|
|
Packit |
c04fcb |
uint32_t session_objd;
|
|
Packit |
c04fcb |
char enum_name[LTTNG_UST_SYM_NAME_LEN];
|
|
Packit |
c04fcb |
uint32_t entries_len;
|
|
Packit |
c04fcb |
char padding[USTCOMM_NOTIFY_ENUM_MSG_PADDING];
|
|
Packit |
c04fcb |
/* followed by enum entries */
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 32
|
|
Packit |
c04fcb |
struct ustcomm_notify_enum_reply {
|
|
Packit |
c04fcb |
int32_t ret_code; /* 0: ok, negative: error code */
|
|
Packit |
c04fcb |
uint64_t enum_id;
|
|
Packit |
c04fcb |
char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#define USTCOMM_NOTIFY_CHANNEL_MSG_PADDING 32
|
|
Packit |
c04fcb |
struct ustcomm_notify_channel_msg {
|
|
Packit |
c04fcb |
uint32_t session_objd;
|
|
Packit |
c04fcb |
uint32_t channel_objd;
|
|
Packit |
c04fcb |
uint32_t ctx_fields_len;
|
|
Packit |
c04fcb |
char padding[USTCOMM_NOTIFY_CHANNEL_MSG_PADDING];
|
|
Packit |
c04fcb |
/* followed by context fields */
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#define USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING 32
|
|
Packit |
c04fcb |
struct ustcomm_notify_channel_reply {
|
|
Packit |
c04fcb |
int32_t ret_code; /* 0: ok, negative: error code */
|
|
Packit |
c04fcb |
uint32_t chan_id;
|
|
Packit |
c04fcb |
uint32_t header_type; /* enum ustctl_channel_header */
|
|
Packit |
c04fcb |
char padding[USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING];
|
|
Packit |
c04fcb |
} LTTNG_PACKED;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* LTTNG_UST_TRACEPOINT_FIELD_LIST reply is followed by a
|
|
Packit |
c04fcb |
* struct lttng_ust_field_iter field.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
extern int ustcomm_create_unix_sock(const char *pathname);
|
|
Packit |
c04fcb |
extern int ustcomm_connect_unix_sock(const char *pathname);
|
|
Packit |
c04fcb |
extern int ustcomm_accept_unix_sock(int sock);
|
|
Packit |
c04fcb |
extern int ustcomm_listen_unix_sock(int sock);
|
|
Packit |
c04fcb |
extern int ustcomm_close_unix_sock(int sock);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
extern ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len);
|
|
Packit |
c04fcb |
extern ssize_t ustcomm_send_unix_sock(int sock, const void *buf, size_t len);
|
|
Packit |
c04fcb |
extern ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd);
|
|
Packit |
c04fcb |
extern ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
extern const char *ustcomm_get_readable_code(int code);
|
|
Packit |
c04fcb |
extern int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum);
|
|
Packit |
c04fcb |
extern int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
|
|
Packit |
c04fcb |
uint32_t expected_handle, uint32_t expected_cmd);
|
|
Packit |
c04fcb |
extern int ustcomm_send_app_cmd(int sock,
|
|
Packit |
c04fcb |
struct ustcomm_ust_msg *lum,
|
|
Packit |
c04fcb |
struct ustcomm_ust_reply *lur);
|
|
Packit |
c04fcb |
int ustcomm_recv_fd(int sock);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
ssize_t ustcomm_recv_channel_from_sessiond(int sock,
|
|
Packit |
c04fcb |
void **chan_data, uint64_t len, int *wakeup_fd);
|
|
Packit |
c04fcb |
int ustcomm_recv_stream_from_sessiond(int sock,
|
|
Packit |
c04fcb |
uint64_t *memory_map_size,
|
|
Packit |
c04fcb |
int *shm_fd, int *wakeup_fd);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Returns 0 on success, negative error value on error.
|
|
Packit |
c04fcb |
* Returns -EPIPE or -ECONNRESET if other end has hung up.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
int ustcomm_send_reg_msg(int sock,
|
|
Packit |
c04fcb |
enum ustctl_socket_type type,
|
|
Packit |
c04fcb |
uint32_t bits_per_long,
|
|
Packit |
c04fcb |
uint32_t uint8_t_alignment,
|
|
Packit |
c04fcb |
uint32_t uint16_t_alignment,
|
|
Packit |
c04fcb |
uint32_t uint32_t_alignment,
|
|
Packit |
c04fcb |
uint32_t uint64_t_alignment,
|
|
Packit |
c04fcb |
uint32_t long_alignment);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Returns 0 on success, negative error value on error.
|
|
Packit |
c04fcb |
* Returns -EPIPE or -ECONNRESET if other end has hung up.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
int ustcomm_register_event(int sock,
|
|
Packit |
c04fcb |
struct lttng_session *session,
|
|
Packit |
c04fcb |
int session_objd, /* session descriptor */
|
|
Packit |
c04fcb |
int channel_objd, /* channel descriptor */
|
|
Packit |
c04fcb |
const char *event_name, /* event name (input) */
|
|
Packit |
c04fcb |
int loglevel,
|
|
Packit |
c04fcb |
const char *signature, /* event signature (input) */
|
|
Packit |
c04fcb |
size_t nr_fields, /* fields */
|
|
Packit |
c04fcb |
const struct lttng_event_field *fields,
|
|
Packit |
c04fcb |
const char *model_emf_uri,
|
|
Packit |
c04fcb |
uint32_t *id); /* event id (output) */
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Returns 0 on success, negative error value on error.
|
|
Packit |
c04fcb |
* Returns -EPIPE or -ECONNRESET if other end has hung up.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
int ustcomm_register_enum(int sock,
|
|
Packit |
c04fcb |
int session_objd, /* session descriptor */
|
|
Packit |
c04fcb |
const char *enum_name, /* enum name (input) */
|
|
Packit |
c04fcb |
size_t nr_entries, /* entries */
|
|
Packit |
c04fcb |
const struct lttng_enum_entry *entries,
|
|
Packit |
c04fcb |
uint64_t *id); /* enum id (output) */
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Returns 0 on success, negative error value on error.
|
|
Packit |
c04fcb |
* Returns -EPIPE or -ECONNRESET if other end has hung up.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
int ustcomm_register_channel(int sock,
|
|
Packit |
c04fcb |
struct lttng_session *session,
|
|
Packit |
c04fcb |
int session_objd, /* session descriptor */
|
|
Packit |
c04fcb |
int channel_objd, /* channel descriptor */
|
|
Packit |
c04fcb |
size_t nr_ctx_fields,
|
|
Packit |
c04fcb |
const struct lttng_ctx_field *ctx_fields,
|
|
Packit |
c04fcb |
uint32_t *chan_id, /* channel id (output) */
|
|
Packit |
c04fcb |
int *header_type); /* header type (output) */
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec);
|
|
Packit |
c04fcb |
int ustcomm_setsockopt_snd_timeout(int sock, unsigned int msec);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
#endif /* _LTTNG_UST_COMM_H */
|