From: compudj Date: Thu, 29 May 2003 13:09:04 +0000 (+0000) Subject: Preliminary add of header files X-Git-Tag: v0.12.20~3477 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c5d7751725d232472b13a57fdef39a2906abafe2;p=lttv.git Preliminary add of header files git-svn-id: http://ltt.polymtl.ca/svn@12 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/attribute.h b/ltt/branches/poly/lttv/attribute.h new file mode 100644 index 00000000..b831dce5 --- /dev/null +++ b/ltt/branches/poly/lttv/attribute.h @@ -0,0 +1,181 @@ +#ifndef ATTRIBUTE_H +#define ATTRIBUTE_H + + +#include +#include + +/* Attributes are used to store any value identified by a key. They are + typically used to store state information or accumulated statistics for + some object. Each value is accessed through a multi-component key, which + resembles hierarchical pathnames in filesystems. + + The attributes may store integers, doubles or time values, in which case + the values are created upon first access of a key and with a default + value of 0. Pointer values are also available with a default value of NULL + and must thus be set explicitely to user managed (statically or dynamically + allocated) memory. */ + + +typedef guint32 lttv_string_id; + +typedef GArray _lttv_key; + +typedef _lttv_key lttv_key; + +typedef struct timespec lttv_time; + + +typedef struct _lttv_attributes { + GHashTable *ints; + GHashTable *times; + GHashTable *doubles; + GHashTable *pointers; +} lttv_attributes; + + +/* A unique integer identifier represents each different string + used as a key component. A single copy of each different string is + stored but its usage count is incremented each time the corresponding id + is returned by lttv_string_id_from_string. The usage count is decremented + each time an id is released. */ + +lttv_string_id lttv_string_id_from_string(const char *s); + +void lttv_string_id_release(lttv_string_id i); + +const char *lttv_string_id_to_string(lttv_string_id i); + + +/* Keys are created and subsequently filled with key components */ + +lttv_key *lttv_key_new(); + +void lttv_key_destroy(lttv_key *k); + +/* macro to access/replace a the i th component of key k */ + +#define lttv_key_index(k,i) _lttv_key_index(k,i) + + +/* Append a new component */ + +void lttv_key_append(lttv_key *k, lttv_string_id i); + + +/* Number of components in a key */ + +unsigned int lttv_key_number(lttv_key *k); + + +/* It is also possible to create a key directly from a pathname, + key components separated by /, (e.g., "/hooks/options/before"). */ + +lttv_key *lttv_key_new_pathname(const char *pathname); + + +/* Create a new set of attributes */ + +lttv_attributes *lttv_attributes_new(); + + +/* Destroy the set of attributes including all the memory allocated + internally for it (copies of keys, and integer, double and time + values...). */ + +void lttv_attributes_destroy(lttv_attributes *a); + + +/* Total number of attributes in a lttv_attributes. */ + +unsigned int lttv_attributes_number(lttv_attributes *a); + + +/* Obtain a pointer to the value of the corresponding type associated with + the specified key. New values are created on demand with 0 as initial + value. These values are freed when the attributes set is destroyed. */ + +int *lttv_attributes_get_integer(lttv_attributes *a, lttv_key *k); + +lttv_time *lttv_attributes_get_time(lttv_attributes *a, lttv_key *k); + +double *lttv_attributes_get_double(lttv_attributes *a, lttv_key *k); + + +/* Set or get the pointer value associated with the specified key. + NULL is returned if no pointer was set for the key. */ + +void *lttv_attributes_get_pointer(lttv_attributes *a, lttv_key *k); + +void lttv_attributes_set_pointer(lttv_attributes *a, lttv_key *k, void *p); + +void *lttv_attributes_get_pointer_pathname(lttv_attributes *a, char *pn); + +void lttv_attributes_set_pointer_pathname(lttv_attributes *a,char *pn,void *p); + + +typedef int (*lttv_key_select)(lttv_key *in, lttv_key *out, void *user_data); + +typedef enum _lttv_key_select_action +{ LTTV_KEEP, LTTV_KEEP_EQUAL, LTTV_KEEP_SMALLER, LTTV_KEEP_GREATER, LTTV_IGNORE +} lttv_key_select_action; + +typedef struct _lttv_key_select_spec_data +{ + unsigned length; + lttv_key_select_action *spec; + lttv_key *match; +} lttv_key_select_spec_data; + +int lttv_key_select_spec(lttv_key *in, lttv_key *out, void *user_data); + +lttv_attributes *lttv_attributes_select(lttv_attributes *a, lttv_key_select f, + void *user_data); + + +/* Sometimes the attributes must be accessed in bulk, sorted in different + ways. For this purpose they may be converted to arrays and sorted + multiple times. The keys used in the array belong to the lttv_attributes + object from which the array was obtained and are freed when it is + destroyed. Each element in the array is an lttv_attribute, a structure + containing the key, the value type, and a union containing a value of + that type. Multiple attributes with equal keys may be possible in some + implementations if their type differs. */ + + +typedef enum _lttv_attribute_type +{ LTTV_INTEGER, LTTV_TIME, LTTV_DOUBLE, LTTV_POINTER } +lttv_attribute_type; + +typedef union _lttv_value_any +{ int i; + lttv_time t; + double d; + void *p; +} lttv_value_any; + +typedef struct _lttv_attribute { + lttv_key *key; + lttv_attribute_type t; + lttv_value_any v; +} lttv_attribute; + + +/* User defined function used to compare keys in the sort. It returns + a negative value if a < b, 0 if a = b, and a positive if a > b. */ + +typedef int (*lttv_key_compare)(lttv_key *a, lttv_key *b, void *user_data); + +int lttv_key_compare_priority(lttv_key *a, lttv_key *b, void *compare_data); + + +/* Obtain all the attributes in an array */ + +lttv_attribute *lttv_attributes_array_get(lttv_attributes *a); + +lttv_attribute *lttv_attribute_array_destroy(lttv_attribute *a); + +void lttv_attribute_array_sort(lttv_attribute *a, unsigned size, + lttv_key_compare f, void *user_data); + +#endif // ATTRIBUTE_H diff --git a/ltt/branches/poly/lttv/hook.h b/ltt/branches/poly/lttv/hook.h new file mode 100644 index 00000000..71a0a139 --- /dev/null +++ b/ltt/branches/poly/lttv/hook.h @@ -0,0 +1,43 @@ +#ifndef HOOK_H +#define HOOK_H + +#include + +/* A hook is a function to call with the supplied hook data, and with + call site specific data (e.g., hooks for events are called with a + pointer to the current event). */ + +typedef void (*lttv_hook)(void *hook_data, void *call_data); + + +/* A list of hooks allows registering hooks to be called later. */ + +typedef GArray _lttv_hooks; +typedef _lttv_hooks lttv_hooks; + +lttv_hooks *lttv_hooks_new(); + +void lttv_hooks_destroy(lttv_hooks *h); + +void lttv_hooks_add(lttv_hooks *h, lttv_hook f, void *hook_data); + +void lttv_hooks_call(lttv_hooks *h, void *call_data); + + +/* Sometimes different hooks need to be called based on the case. The + case is represented by an unsigned integer id and may represent different + event types, for instance. */ + +typedef GPtrArray _lttv_hooks_by_id; +typedef _lttv_hooks_by_id lttv_hooks_by_id; + +lttv_hooks_by_id *lttv_hooks_by_id_new(); + +void lttv_hooks_by_id_destroy(lttv_hooks_by_id *h); + +void lttv_hooks_by_id_add(lttv_hooks_by_id *h, lttv_hook f, void *hook_data, + unsigned int id); + +void lttv_hooks_by_id_call(lttv_hooks_by_id *h, void *call_data, unsigned int id); + +#endif // HOOK_H diff --git a/ltt/branches/poly/lttv/lttv.h b/ltt/branches/poly/lttv/lttv.h new file mode 100644 index 00000000..27a94d0d --- /dev/null +++ b/ltt/branches/poly/lttv/lttv.h @@ -0,0 +1,82 @@ +#ifndef LTTV_H +#define LTTV_H + + +#include +#include +#include +#include +/* Initial draft by Michel Dagenais May 2003 + * Reworked by Mathieu Desnoyers, May 2003 + */ + +/* The modules in the visualizer communicate with the main module and + with each other through attributes. There is a global set of attributes as + well as attributes attached to each trace set, trace and tracefile. */ + +lttv_attributes *lttv_global_attributes(); + + +/* Modules are allowed to define new command line options. + + Each option has a long name (--long_name), a short one character + name (-c), a descriptive text, the argument type, and a + pointer to where the argument value will be stored. For an option of + type LTTV_OPT_NONE, the argument is a boolean value set to true when the + option is present. */ + +/* Those are already in option.h, cause conflict */ +//typedef enum _lttv_option_type +//{LTTV_OPT_NONE, LTTV_OPT_STRING, LTTV_OPT_INT, LTTV_OPT_LONG } +//lttv_option_type; + + +//void lttv_option_add(char *long_name, char char_name, char *description, +// lttv_option_type t, void *p); + + + +/* A number of global attributes are initialized before modules are + loaded, for example hooks lists. More global attributes are defined + in individual mudules to store information or to communicate with other + modules (GUI windows, menus...). + + The hooks lists (lttv_hooks) are initialized in the main module and may be + used by other modules. Each corresponds to a specific location in the main + module processing loop. The attribute key and typical usage for each + is indicated. + + /hooks/options/before + Good place to define new command line options to be parsed. + + /hooks/options/after + Read the values set by the command line options. + + /hooks/trace_set/before + Before any analysis. + + /hooks/trace_set/after + After all traces were analyzed. + + /hooks/trace/before + Before each trace. + + /hooks/trace/after + After each trace. + + /hooks/tracefile/before + Before each tracefile. + + /hooks/tracefile/after + After each tracefile. + + /hooks/event + Called for each event + + /hooks/event_id + This attribute contains an lttv_hooks_by_id, where the hooks for each + id are to be called when an event of the associated type are found. + +*/ + +#endif // LTTV_H diff --git a/ltt/branches/poly/lttv/mainWinAPI.h b/ltt/branches/poly/lttv/mainWinAPI.h new file mode 100644 index 00000000..739c09a6 --- /dev/null +++ b/ltt/branches/poly/lttv/mainWinAPI.h @@ -0,0 +1,261 @@ +/** + * Main window (main module) is the place to contain and display viewers. + * Viewers (lttv modules) interacter with main window though API of the + * main window and hooks of itself. + * This header file should be included in each graphic module. + */ + +#include +#include +#include + +/** + * Function to register a view constructor so that main window can generate + * a toolbar item for the viewer in order to generate a new instance easily. + * It will be called by init function of the module. + * @param pixmap, pixmap shown on the toolbar item. + * @param tooltip, tooltip of the toolbar item. + * @view_constructor, constructor of the viewer. + */ + +void ToolbarItemReg(GdkPixmap *pixmap, char *tooltip, void *view_constructor); + + +/** + * Function to unregister the viewer's constructor, release the space + * occupied by pixmap, tooltip and constructor of the viewer. + * It will be called when a module is unloaded. + * @param view_constructor, constructor of the viewer which is used as + * a reference to find out where the pixmap and tooltip are. + */ + +void ToolbarItemUnreg(void *view_constructor); + + +/** + * Function to register a view constructor so that main window can generate + * a menu item for the viewer in order to generate a new instance easily. + * It will be called by init function of the module. + * @param menu_path, path of the menu item. + * @param menu_text, text of the menu item. + * @view_constructor, constructor of the viewer. + */ + +void MenuItemReg(char *menu_path, char *menu_text, void *view_constructor); + + +/** + * Function to unregister the viewer's constructor, release the space + * occupied by menu_path, menu_text and constructor of the viewer. + * It will be called when a module is unloaded. + * @param view_constructor, constructor of the viewer which is used as + * a reference to find out where the menu_path and menu_text are. + */ + +void MenuItemUnreg(void *view_constructor); + + +/** + * Attach a viewer to the current tab. + * It will be called in the constructor of the viewer. + * @param main_win, the main window the viewer belongs to. + * @param viewer, viewer to be attached to the current tab + */ + +void AttachViewer(MainWindow *main_win, GtkWidget *viewer); + + +/* ?? Maybe we do not need this function, when a widget is destoried, + * it will be removed automatically from its container + */ + +/** + * Detach a viewer from the current tab. + * It will be called in the destructor of the viewer. + * @param main_win, the main window the viewer belongs to. + * @param viewer, viewer to be detached from the current tab. + */ + +void DetachViewer(MainWindow *main_win, GtkWidget *viewer); + + +/** + * Update the status bar whenever something changed in the viewer. + * @param main_win, the main window the viewer belongs to. + * @param info, the message which will be shown in the status bar. + */ + +void UpdateStatus(MainWindow *main_win, char *info); + + +/** + * Function to get the current time interval of the current tab. + * It will be called by a viewer's hook function to update the + * time interval of the viewer and also be called by the constructor + * of the viewer. + * @param main_win, the main window the viewer belongs to. + * @param time_interval, a pointer where time interval will be stored. + */ + +void GetTimeInterval(MainWindow *main_win, TimeInterval *time_interval); + + +/** + * Function to set the time interval of the current tab. + * It will be called by a viewer's signal handle associated with + * the move_slider signal + * @param main_win, the main window the viewer belongs to. + * @param time_interval, a pointer where time interval is stored. + */ + +void SetTimeInterval(MainWindow *main_win, TimeInterval *time_interval); + + +/** + * Function to get the current time/event of the current tab. + * It will be called by a viewer's hook function to update the + * current time/event of the viewer. + * @param main_win, the main window the viewer belongs to. + * @param ltt_time, a pointer where time will be stored. + */ + +void GetCurrentTime(MainWindow *main_win, ltt_time *time); + + +/** + * Function to set the current time/event of the current tab. + * It will be called by a viewer's signal handle associated with + * the button-release-event signal + * @param main_win, the main window the viewer belongs to. + * @param ltt_time, a pointer where time is stored. + */ + +void SetCurrentTime(MainWindow *main_win, ltt_time *time); + + +/** + * Function to get the traceset from the current tab. + * It will be called by the constructor of the viewer and also be + * called by a hook funtion of the viewer to update its traceset. + * @param main_win, the main window the viewer belongs to. + * @param traceset, a pointer to a traceset. + */ + +void GetTraceset(MainWindow *main_win, Traceset *traceset); + + +/** + * Function to get the filter of the current tab. + * It will be called by the constructor of the viewer and also be + * called by a hook funtion of the viewer to update its filter. + * @param main_win, the main window the viewer belongs to. + * @param filter, a pointer to a filter. + */ + +void GetFilter(MainWindow *main_win, Filter *filter); + + +/** + * Function to register a hook function for a viewer to set/update its + * time interval. + * It will be called by the constructor of the viewer. + * @param hook, hook function of the viewer. + * @param hook_data, hook data associated with the hook function. + * @param main_win, the main window the viewer belongs to. + */ + +void RegUpdateTimeInterval(lttv_hook *hook, TimeInterval *hook_data, + MainWindow * main_win); + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update the time interval of the viewer. + * It will be called by the destructor of the viewer. + * @param hook, hook function of the viewer. + * @param hook_data, hook data associated with the hook function. + * @param main_win, the main window the viewer belongs to. + */ + +void UnregUpdateTimeInterval(lttv_hook *hook, TimeInterval *hook_data, + MainWindow * main_win); + + +/** + * Function to register a hook function for a viewer to set/update its + * traceset. + * It will be called by the constructor of the viewer. + * @param hook, hook function of the viewer. + * @param hook_data, hook data associated with the hook function. + * @param main_win, the main window the viewer belongs to. + */ + +void RegUpdateTraceset(lttv_hook *hook, Traceset *hook_data, + MainWindow * main_win); + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update the traceset of the viewer. + * It will be called by the destructor of the viewer. + * @param hook, hook function of the viewer. + * @param hook_data, hook data associated with the hook function. + * @param main_win, the main window the viewer belongs to. + */ + +void UnregUpdateTraceset(lttv_hook *hook, Traceset *hook_data, + MainWindow * main_win); + + +/** + * Function to register a hook function for a viewer to set/update its + * filter. + * It will be called by the constructor of the viewer. + * @param hook, hook function of the viewer. + * @param hook_data, hook data associated with the hook function. + * @param main_win, the main window the viewer belongs to. + */ + +void RegUpdateFilter(lttv_hook *hook, Filter *hook_data, + MainWindow *main_win); + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update the filter of the viewer. + * It will be called by the destructor of the viewer. + * @param hook, hook function of the viewer. + * @param hook_data, hook data associated with the hook function. + * @param main_win, the main window the viewer belongs to. + */ + +void UnregUpdateFilter(lttv_hook *hook, Filter *hook_data, + MainWindow * main_win); + + +/** + * Function to register a hook function for a viewer to set/update its + * current time. + * It will be called by the constructor of the viewer. + * @param hook, hook function of the viewer. + * @param hook_data, hook data associated with the hook function. + * @param main_win, the main window the viewer belongs to. + */ + +void RegUpdateCurrentTime(lttv_hook *hook, ltt_time *hook_data, + MainWindow *main_win); + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update the current time of the viewer. + * It will be called by the destructor of the viewer. + * @param hook, hook function of the viewer. + * @param hook_data, hook data associated with the hook function. + * @param main_win, the main window the viewer belongs to. + */ + +void UnregUpdateCurrentTime(lttv_hook *hook, ltt_time *hook_data, + MainWindow * main_win); + + diff --git a/ltt/branches/poly/lttv/module.h b/ltt/branches/poly/lttv/module.h new file mode 100644 index 00000000..5d1c3bae --- /dev/null +++ b/ltt/branches/poly/lttv/module.h @@ -0,0 +1,83 @@ +#ifndef MODULES_H +#define MODULES_H + +#include + +/* lttv modules are shared object files, to be loaded dynamically, which + interact with the main module to provide additional capabilities. They + typically register hooks to be called at various places, read and add + global or trace attributes, and add menu items and tabbed windows to the + graphical user interface. Both the hooks lists and the menus and windows + are accessed as global attributes. */ + + +/* Each lttv module must define a function named "init" with + the following signature. The init function may itself load pre-requisite + modules using lttv_module_load. + + It should also define a function named "destroy", which free the + resources reserved during execution. + + Most modules will not use the command line arguments passed as init + arguments. It is easier to simply register command line options + to be parsed by the main module. However, some modules + may require an "early access" to these arguments, for example a embedded + python interpreter module which needs to know the modules written in + python to load. */ + +/* Initial draft by Michel Dagenais May 2003 + * Reworked by Mathieu Desnoyers, May 2003 + */ + +/* index_standalone is the index of the module in the modulesStanalone array. + * If the module is only loaded "DEPENDANT", index is -1. + */ + +typedef struct lttv_module_info_ { + GModule *module; + char *name; + char *directory; + char *pathname; + guint ref_count; + gint index_standalone; +} lttv_module_info; + +/* Loading type of modules : + * STANDALONE : the program takes care of unloading the moduels + * DEPENDANT : The module that load this module is required to unload + * it in it's destroy function. + */ + +typedef enum _loadtype +{ STANDALONE, DEPENDANT +} loadtype; + +typedef void (*lttv_module_load_init)(int argc, char **argv) ; + + +/* Load (if not already loaded) the named module. The init function of the + module is executed upon loading. */ + +lttv_module_info *lttv_module_load(const char *name, int argc, char **argv,loadtype); + + + +/* Unload (if already loaded) the named module. The destroy function of the + module is executed before unloading. */ + +typedef void (*lttv_module_unload_destroy)() ; + +int lttv_module_unload_pathname(const char *pathname,loadtype) ; + +int lttv_module_unload_name(const char *name,loadtype) ; + +int lttv_module_unload(lttv_module_info *moduleInfo,loadtype); + +/* Unload all the modules */ +void lttv_module_unload_all(); + +/* Additional module search paths may be defined. */ + +void lttv_module_path_add(const char *name); + +#endif // MODULES_H diff --git a/ltt/branches/poly/lttv/option.h b/ltt/branches/poly/lttv/option.h new file mode 100644 index 00000000..73563d3d --- /dev/null +++ b/ltt/branches/poly/lttv/option.h @@ -0,0 +1,28 @@ +#ifndef OPTION_H +#define OPTION_H + +/* Options parsing mechanism */ + +/* Define a new command line option with a long name (--long_name), a short + one character name (-c), a descriptive text, the argument type, and a + pointer to where the argument value will be stored. For an option of + type LTTV_OPT_NONE, the argument is a boolean value set to true when the + option is present. */ + +/* Initial draft by Michel Dagenais May 2003 + * Reworked by Mathieu Desnoyers, May 2003 + */ + +typedef enum _lttv_option_type +{LTTV_OPT_NONE, LTTV_OPT_STRING, LTTV_OPT_INT, LTTV_OPT_LONG } +lttv_option_type; + +typedef void (*lttv_option_hook)(void *hook_data); + +void lttv_option_add(char *long_name, char char_name, char *description, + char *argDescription, lttv_option_type t, void *p, + lttv_option_hook h, void *hook_data); + + + +#endif // OPTION_H diff --git a/ltt/branches/poly/lttv/trace.h b/ltt/branches/poly/lttv/trace.h new file mode 100644 index 00000000..bbe6c497 --- /dev/null +++ b/ltt/branches/poly/lttv/trace.h @@ -0,0 +1,78 @@ +#ifndef TRACE_H +#define TRACE_H + +/* A trace is a sequence of events gathered in the same tracing session. The + events may be stored in several tracefiles in the same directory. + A trace set is defined when several traces are to be analyzed together, + possibly to study the interactions between events in the different traces. +*/ + +typedef struct _lttv_trace_set lttv_trace_set; + +typedef struct _lttv_trace lttv_trace; + +typedef struct _lttv_tracefile lttv_tracefile; + + +/* Trace sets may be added to, removed from and their content listed. */ + +lttv_trace_set *lttv_trace_set_new(); + +lttv_trace_set *lttv_trace_set_destroy(lttv_trace_set *s); + +void lttv_trace_set_add(lttv_trace_set *s, lttv_trace *t); + +unsigned lttv_trace_set_number(lttv_trace_set *s); + +lttv_trace *lttv_trace_set_get(lttv_trace_set *s, unsigned i); + +lttv_trace *lttv_trace_set_remove(lttv_trace_set *s, unsigned i); + + +/* A trace is identified by the pathname of its containing directory */ + +lttv_trace *lttv_trace_open(char *pathname); + +int lttv_trace_close(lttv_trace *t); + +char *lttv_trace_name(lttv_trace *t); + + +/* A trace typically contains one tracefile with important events + (for all CPUs), and one tracefile with ordinary events per cpu. + The tracefiles in a trace may be enumerated for each category + (all cpu and per cpu). The total number of tracefiles and of CPUs + may also be obtained. */ + +unsigned int lttv_trace_tracefile_number(lttv_trace *t); + +unsigned int lttv_trace_cpu_number(lttv_trace *t); + +unsigned int lttv_trace_tracefile_number_per_cpu(lttv_trace *t); + +unsigned int lttv_trace_tracefile_number_all_cpu(lttv_trace *t); + +lttv_tracefile *lttv_trace_tracefile_get_per_cpu(lttv_trace *t, unsigned i); + +lttv_tracefile *lttv_trace_tracefile_get_all_cpu(lttv_trace *t, unsigned i); + + +/* A set of attributes is attached to each trace set, trace and tracefile + to store user defined data as needed. */ + +lttv_attributes *lttv_trace_set_attributes(lttv_trace_set *s); + +lttv_attributes *lttv_trace_attributes(lttv_trace *t); + +lttv_attributes *lttv_tracefile_attributes(lttv_tracefile *tf); + + +/* The underlying ltt_tracefile, from which events may be read, is accessible. + The tracefile name is also available. */ + +lttv_tracefile *lttv_tracefile_ltt_tracefile(lttv_tracefile *tf); + +char *lttv_tracefile_name(lttv_tracefile *tf); + +#endif // TRACE_H +