X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=include%2Flttng%2Flttng.h;h=c5be66128b60da0cc76c5972a095a5ccbd8a4f79;hp=ac7c435044d47a481bb1c29c081b039e75115127;hb=b31610f2294a6a827fa2d0d19d71199567db8dc5;hpb=f05b5f07dd61554a2fcdc5a09d4d80cadf478a51 diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index ac7c43504..c5be66128 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -5,208 +5,162 @@ * * Copyright (C) 2011 - David Goulet * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _LTTNG_H -#define _LTTNG_H - -#include -#include -#include - -/* Default unix group name for tracing. */ -#define LTTNG_DEFAULT_TRACING_GROUP "tracing" - -/* Environment variable to set session daemon binary path. */ -#define LTTNG_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH" - -/* Default trace output directory name */ -#define LTTNG_DEFAULT_TRACE_DIR_NAME "lttng-traces" - -/* - * Event symbol length. Copied from LTTng kernel ABI. - */ -#define LTTNG_SYMBOL_NAME_LEN 128 - -/* - * Every lttng_event_* structure both apply to kernel event and user-space - * event. + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. * - * Every lttng_kernel_* is copied from the LTTng kernel ABI. + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -enum lttng_event_type { - LTTNG_EVENT_TRACEPOINT, - LTTNG_EVENT_KPROBE, - LTTNG_EVENT_FUNCTION, -}; +#ifndef LTTNG_H +#define LTTNG_H -/* - * LTTng consumer mode - */ -enum lttng_event_output { - /* Using splice(2) */ - LTTNG_EVENT_SPLICE = 0, - /* Using mmap(2) */ - LTTNG_EVENT_MMAP = 1, -}; +/* Error codes that can be returned by API calls */ +#include -/* Kernel context possible type */ -enum lttng_kernel_context_type { - LTTNG_KERNEL_CONTEXT_PID = 0, - LTTNG_KERNEL_CONTEXT_PERF_COUNTER = 1, - LTTNG_KERNEL_CONTEXT_COMM = 2, - LTTNG_KERNEL_CONTEXT_PRIO = 3, - LTTNG_KERNEL_CONTEXT_NICE = 4, - LTTNG_KERNEL_CONTEXT_VPID = 5, - LTTNG_KERNEL_CONTEXT_TID = 6, - LTTNG_KERNEL_CONTEXT_VTID = 7, - LTTNG_KERNEL_CONTEXT_PPID = 8, - LTTNG_KERNEL_CONTEXT_VPPID = 9, -}; +/* Include every LTTng ABI/API available. */ +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif -/* Perf counter attributes */ -struct lttng_kernel_perf_counter_ctx { - uint32_t type; - uint64_t config; - char name[LTTNG_SYMBOL_NAME_LEN]; +enum lttng_calibrate_type { + LTTNG_CALIBRATE_FUNCTION = 0, }; -/* Event/Channel context */ -struct lttng_kernel_context { - enum lttng_kernel_context_type ctx; - union { - struct lttng_kernel_perf_counter_ctx perf_counter; - } u; +/* Machine interface output type */ +enum lttng_mi_output_type { + LTTNG_MI_XML = 1 /* XML output */ }; -/* - * Kernel Kprobe. Either addr is used or symbol_name and offset. - */ -struct lttng_kernel_kprobe_attr { - uint64_t addr; +#define LTTNG_CALIBRATE_PADDING1 16 +struct lttng_calibrate { + enum lttng_calibrate_type type; - uint64_t offset; - char symbol_name[LTTNG_SYMBOL_NAME_LEN]; + char padding[LTTNG_CALIBRATE_PADDING1]; }; /* - * Function tracer + * Check if a session daemon is alive. + * + * Return 1 if alive or 0 if not. On error, returns a negative negative LTTng + * error code. */ -struct lttng_event_function_attr { - char symbol_name[LTTNG_SYMBOL_NAME_LEN]; -}; +extern int lttng_session_daemon_alive(void); /* - * Generic lttng event + * Set the tracing group for the *current* flow of execution. + * + * On success, returns 0 else a negative LTTng error code. */ -struct lttng_event { - char name[LTTNG_SYMBOL_NAME_LEN]; - enum lttng_event_type type; - /* Per event type configuration */ - union { - struct lttng_kernel_kprobe_attr kprobe; - struct lttng_event_function_attr ftrace; - } attr; -}; +extern int lttng_set_tracing_group(const char *name); /* - * Tracer channel attributes. For both kernel and user-space. + * This call registers an "outside consumer" for a session and an lttng domain. + * No consumer will be spawned and all fds/commands will go through the socket + * path given (socket_path). + * + * NOTE that this is not recommended unless you absolutely know what you are + * doing. + * + * Return 0 on success else a negative LTTng error code. */ -struct lttng_channel_attr { - int overwrite; /* 1: overwrite, 0: discard */ - uint64_t subbuf_size; /* bytes */ - uint64_t num_subbuf; /* power of 2 */ - unsigned int switch_timer_interval; /* usec */ - unsigned int read_timer_interval; /* usec */ - enum lttng_event_output output; /* splice, mmap */ -}; +extern int lttng_register_consumer(struct lttng_handle *handle, + const char *socket_path); /* - * Channel information structure. For both kernel and user-space. + * Start tracing for *all* domain(s) in the session. + * + * Return 0 on success else a negative LTTng error code. */ -struct lttng_channel { - char name[NAME_MAX]; - struct lttng_channel_attr attr; -}; +extern int lttng_start_tracing(const char *session_name); /* - * Basic session information. + * Stop tracing for *all* domain(s) in the session. * - * This is an 'output data' meaning that it only comes *from* the session - * daemon *to* the lttng client. It's basically a 'human' representation of - * tracing entities (here a session). + * This call will wait for data availability for each domain of the session so + * this can take an abritrary amount of time. However, when returning you have + * the guarantee that the data is ready to be read and analyze. Use the + * _no_wait call below to avoid this behavior. + * + * The session_name can't be NULL. + * + * Return 0 on success else a negative LTTng error code. */ -struct lttng_session { - char name[NAME_MAX]; - /* The path where traces are written */ - char path[PATH_MAX]; -}; +extern int lttng_stop_tracing(const char *session_name); /* - * Session daemon control + * Behave exactly like lttng_stop_tracing but does not wait for data + * availability. */ -extern int lttng_connect_sessiond(void); - -extern int lttng_create_session(char *name, char *path); - -extern int lttng_destroy_session(char *name); - -extern int lttng_disconnect_sessiond(void); +extern int lttng_stop_tracing_no_wait(const char *session_name); /* - * Return a "lttng_session" array. Caller must free(3) the returned data. + * Calibrate LTTng overhead. + * + * The chan and handle params can not be NULL. + * + * Return 0 on success else a negative LTTng error code. */ -extern int lttng_list_sessions(struct lttng_session **sessions); - -extern int lttng_session_daemon_alive(void); - -/* Set tracing group for the current execution */ -extern int lttng_set_tracing_group(const char *name); - -extern void lttng_set_session_name(char *name); - -extern const char *lttng_get_readable_code(int code); - -extern int lttng_start_tracing(char *session_name); - -extern int lttng_stop_tracing(char *session_name); +extern int lttng_calibrate(struct lttng_handle *handle, + struct lttng_calibrate *calibrate); /* - * LTTng Kernel tracer control + * Set URL for a consumer for a session and domain. + * + * Both data and control URL must be defined. If both URLs are the same, only + * the control URL is used even for network streaming. + * + * Default port are 5342 and 5343 respectively for control and data which uses + * the TCP protocol. + * + * URL format: proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH] + * + * Possible protocols are: + * > file://... + * Local filesystem full path. + * + * > net[6]://... + * This will use the default network transport layer which is TCP for both + * control (PORT1) and data port (PORT2). + * + * > tcp[6]://... + * TCP only streaming. For this one, both data and control URL must be given. + * + * Return 0 on success else a negative LTTng error code. */ -extern int lttng_kernel_add_context(struct lttng_kernel_context *ctx, - char *event_name, char *channel_name); - -extern int lttng_kernel_create_channel(struct lttng_channel *chan); - -extern int lttng_kernel_enable_event(struct lttng_event *ev, char *channel_name); - -extern int lttng_kernel_enable_channel(char *name); - -extern int lttng_kernel_disable_event(char *name, char *channel_name); - -extern int lttng_kernel_disable_channel(char *name); - -extern int lttng_kernel_list_events(char **event_list); +extern int lttng_set_consumer_url(struct lttng_handle *handle, + const char *control_url, const char *data_url); /* - * LTTng User-space tracer control + * For a given session name, this call checks if the data is ready to be read + * or is still being extracted by the consumer(s) (pending) hence not ready to + * be used by any readers. + * + * Return 0 if there is _no_ data pending in the buffers thus having a + * guarantee that the data can be read safely. Else, return 1 if there is still + * traced data is pending. On error, a negative value is returned and readable + * by lttng_strerror(). */ +extern int lttng_data_pending(const char *session_name); -//extern int lttng_ust_list_traceable_apps(pid_t **pids); +#ifdef __cplusplus +} +#endif -#endif /* _LTTNG_H */ +#endif /* LTTNG_H */