X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=include%2Flttng%2Flttng.h;h=448bd9fdcf944f432a757a7622286a3c3323bdaf;hp=39a6cbdad383241ad0adf93744d1833bbc8a7b5f;hb=e6ddca715d6dedb6ee25fe4392a6e1f9626b2544;hpb=1df4dedd9ed4253a944a1623bb40047ba599e0c4 diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 39a6cbdad..448bd9fdc 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -1,4 +1,8 @@ /* + * lttng.h + * + * Linux Trace Toolkit Control Library Header File + * * Copyright (C) 2011 - David Goulet * * This program is free software; you can redistribute it and/or @@ -16,74 +20,193 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _LIBLTTNGCTL_H -#define _LIBLTTNGCTL_H +#ifndef _LTTNG_H +#define _LTTNG_H -#include +#include #include -#include +#include + +/* Default unix group name for tracing. */ +#define LTTNG_DEFAULT_TRACING_GROUP "tracing" -/* Default unix group name for 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 DEFAULT_TRACING_GROUP "tracing" +#define LTTNG_SYMBOL_NAME_LEN 128 -/* Environment variable to set session daemon - * binary path. +/* + * Every lttng_event_* structure both apply to kernel event and user-space + * event. + * + * Every lttng_kernel_* is copied from the LTTng kernel ABI. */ -#define LTTNG_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH" -/* UUID string length (including \0) */ -#define UUID_STR_LEN 37 -/* UUID short string version length (including \0) */ -#define UUID_SHORT_STR_LEN 9 +enum lttng_event_type { + LTTNG_EVENT_TRACEPOINT, + LTTNG_EVENT_KPROBE, + LTTNG_EVENT_FUNCTION, +}; -/* Trace type for lttng_trace. +/* + * LTTng consumer mode */ -enum lttng_trace_type { - KERNEL, USERSPACE, +enum lttng_event_output { + /* Using splice(2) */ + LTTNG_EVENT_SPLICE = 0, + /* Using mmap(2) */ + LTTNG_EVENT_MMAP = 1, +}; + +/* 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, +}; + +/* Perf counter attributes */ +struct lttng_kernel_perf_counter_ctx { + uint32_t type; + uint64_t config; + char name[LTTNG_SYMBOL_NAME_LEN]; }; -/* Simple structure representing a session. +/* Event/Channel context */ +struct lttng_kernel_context { + enum lttng_kernel_context_type ctx; + union { + struct lttng_kernel_perf_counter_ctx perf_counter; + } u; +}; + +/* + * Either addr is used or symbol_name and offset. */ -struct lttng_session { +struct lttng_event_kprobe_attr { + uint64_t addr; + + uint64_t offset; + char symbol_name[LTTNG_SYMBOL_NAME_LEN]; +}; + +/* + * Function tracer + */ +struct lttng_event_function_attr { + char symbol_name[LTTNG_SYMBOL_NAME_LEN]; +}; + +/* + * Generic lttng event + */ +struct lttng_event { + char name[LTTNG_SYMBOL_NAME_LEN]; + enum lttng_event_type type; + /* Per event type configuration */ + union { + struct lttng_event_kprobe_attr kprobe; + struct lttng_event_function_attr ftrace; + } attr; +}; + +/* + * Tracer channel attributes. For both kernel and user-space. + */ +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 */ +}; + +/* + * Channel information structure. For both kernel and user-space. + */ +struct lttng_channel { char name[NAME_MAX]; - uuid_t uuid; + struct lttng_channel_attr attr; }; -/* Simple trace representation. +/* + * Basic session information. + * + * 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). */ -struct lttng_trace { +struct lttng_session { char name[NAME_MAX]; - pid_t pid; - enum lttng_trace_type type; + /* The path where traces are written */ + char path[PATH_MAX]; }; -extern int lttng_create_session(char *name, uuid_t *session_id); -extern int lttng_destroy_session(uuid_t *uuid); +/* + * Session daemon control + */ 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); + +/* + * Return a "lttng_session" array. Caller must free(3) the returned data. + */ +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 int lttng_check_session_daemon(void); + +extern void lttng_set_session_name(char *name); + extern const char *lttng_get_readable_code(int code); -extern int lttng_ust_list_apps(pid_t **pids); -extern int lttng_list_sessions(struct lttng_session **sessions); -extern int lttng_list_traces(uuid_t *uuid, struct lttng_trace **traces); -extern void lttng_set_current_session_uuid(uuid_t *uuid); -extern int lttng_ust_create_trace(pid_t pid); -extern int lttng_ust_start_trace(pid_t pid); -extern int lttng_ust_stop_trace(pid_t pid); + +extern int lttng_start_tracing(char *session_name); + +extern int lttng_stop_tracing(char *session_name); /* - * Kernel tracer control + * LTTng Kernel tracer control */ -extern int lttng_kernel_enable_event(char *event_name); -extern int lttng_kernel_disable_event(char *event_name); -extern int lttng_kernel_create_session(void); -extern int lttng_kernel_start_tracing(void); -extern int lttng_kernel_stop_tracing(void); -extern int lttng_kernel_create_channel(int overwrite, - uint64_t subbuf_size, uint64_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval); - -#endif /* _LIBLTTNGCTL_H */ +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); + +/* + * LTTng User-space tracer control + */ + +//extern int lttng_ust_list_traceable_apps(pid_t **pids); + +#endif /* _LTTNG_H */