3 #include <lttv/module.h>
5 #include <lttv/iattribute.h>
6 #include <lttv/attribute.h>
7 #include <lttv/option.h>
8 #include <lttv/traceset.h>
13 void lttv_option_init(int argc
, char **argv
);
14 void lttv_option_destroy();
16 void lttv_module_init(int argc
, char **argv
);
17 void lttv_module_destroy();
19 void lttv_state_init(int argc
, char **argv
);
20 void lttv_state_destroy();
22 void lttv_stats_init(int argc
, char **argv
);
23 void lttv_stats_destroy();
25 /* The main program maintains a few central data structures and relies
26 on modules for the rest. These data structures may be accessed by modules
27 through an exported API */
29 static LttvIAttribute
*attributes
;
49 static void lttv_module_option(void *hook_data
);
51 static void lttv_module_path_option(void *hook_data
);
53 static void lttv_verbose(void *hook_data
);
55 static void lttv_debug(void *hook_data
);
57 static void lttv_help(void *hook_data
);
59 /* Since everything is done in modules, the main program only takes care
60 of the infrastructure. */
62 int main(int argc
, char **argv
) {
64 LttvAttributeValue value
;
67 g_mem_set_vtable(glib_mem_profiler_table
);
68 g_message("Memory summary before main");
73 //g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS);
75 attributes
= LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
));
77 before_options
= lttv_hooks_new();
78 after_options
= lttv_hooks_new();
79 before_main
= lttv_hooks_new();
80 after_main
= lttv_hooks_new();
82 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/options/before",
83 LTTV_POINTER
, &value
));
84 *(value
.v_pointer
) = before_options
;
85 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/options/after",
86 LTTV_POINTER
, &value
));
87 *(value
.v_pointer
) = after_options
;
88 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
89 LTTV_POINTER
, &value
));
90 *(value
.v_pointer
) = before_main
;
91 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/after",
92 LTTV_POINTER
, &value
));
93 *(value
.v_pointer
) = after_main
;
96 /* Initialize the command line options processing */
100 lttv_option_init(argc
,argv
);
101 lttv_module_init(argc
,argv
);
102 lttv_state_init(argc
,argv
);
103 lttv_stats_init(argc
,argv
);
105 /* Initialize the module loading */
107 lttv_module_path_add("/usr/lib/lttv/plugins");
109 /* Add some built-in options */
111 lttv_option_add("module",'m', "load a module", "name of module to load",
112 LTTV_OPT_STRING
, &a_module
, lttv_module_option
, NULL
);
114 lttv_option_add("modules-path", 'L',
115 "add a directory to the module search path",
116 "directory to add to the path", LTTV_OPT_STRING
, &a_module_path
,
117 lttv_module_path_option
, NULL
);
119 lttv_option_add("help",'h', "basic help", "none",
120 LTTV_OPT_NONE
, NULL
, lttv_help
, NULL
);
123 lttv_option_add("verbose",'v', "print information messages", "none",
124 LTTV_OPT_NONE
, NULL
, lttv_verbose
, NULL
);
127 lttv_option_add("debug",'d', "print debugging messages", "none",
128 LTTV_OPT_NONE
, NULL
, lttv_debug
, NULL
);
131 lttv_hooks_call(before_options
, NULL
);
132 lttv_option_parse(argc
, argv
);
133 lttv_hooks_call(after_options
, NULL
);
135 lttv_hooks_call(before_main
, NULL
);
136 lttv_hooks_call(after_main
, NULL
);
138 lttv_stats_destroy();
139 lttv_state_destroy();
140 lttv_module_destroy();
141 lttv_option_destroy();
143 lttv_hooks_destroy(before_options
);
144 lttv_hooks_destroy(after_options
);
145 lttv_hooks_destroy(before_main
);
146 lttv_hooks_destroy(after_main
);
147 g_object_unref(attributes
);
150 g_message("Memory summary after main");
156 LttvAttribute
*lttv_global_attributes()
158 return (LttvAttribute
*)attributes
;
162 void lttv_module_option(void *hook_data
)
164 lttv_module_load(a_module
,a_argc
,a_argv
);
168 void lttv_module_path_option(void *hook_data
)
170 lttv_module_path_add(a_module_path
);
173 void lttv_verbose(void *hook_data
)
175 g_log_set_handler(NULL
, G_LOG_LEVEL_INFO
, g_log_default_handler
, NULL
);
176 g_info("Logging set to include INFO level messages");
179 void lttv_debug(void *hook_data
)
181 g_log_set_handler(NULL
, G_LOG_LEVEL_DEBUG
, g_log_default_handler
, NULL
);
182 g_info("Logging set to include DEBUG level messages");
185 void lttv_help(void *hook_data
)
187 printf("Linux Trace Toolkit Visualizer\n");
189 lttv_option_show_help();
195 - Make it easier to change modules from builtin to externally loaded.
197 have: MODULE_INFO(name, init, destroy, { require} ) in each module.
198 Maintain the list of builtin modules and search these first (or
199 optionally last). Add the lib prefix if needed to avoid having to
200 specify libbatchAnalysis instead of batchAnalysis.
202 - Define formally traceset/trace in the GUI for the user and decide how
203 trace/traceset sharing goes in the application.
205 - Use appropriately the new functions in time.h
207 - remove the separate tracefiles (control/per cpu) arrays/loops in context.
209 - split processTrace into context.c and processTrace.c
211 - check spelling conventions.
213 - get all the copyright notices.
215 - remove all the warnings.
217 - get all the .h files properly doxygen commented to produce useful documents.
219 - have an intro/architecture document.
221 - write a tutorial */
This page took 0.05938 seconds and 4 git commands to generate.