de3c77096bf4dea8810692da3e1ce293371b235d
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);
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");
187 printf("Linux Trace Toolkit Visualizer\n");
189 lttv_option_show_help();
193 /* remove countEvents.c, add alias to init to allow static/dynamic loading
194 MODULE_INFO(name, init, destroy, { require} ). This info could be used
195 by module_load and as a constructor function when not a module
196 -> check constructor functions versus dynamic loading and init section
197 -> have a list of available modules builtin as default or mandatory */
This page took 0.033142 seconds and 4 git commands to generate.