5fc5abb6cf4861642ba8af70bd5a9563022ddfe9
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>
11 void lttv_option_init(int argc
, char **argv
);
12 void lttv_option_destroy();
14 void lttv_module_init(int argc
, char **argv
);
15 void lttv_module_destroy();
17 void lttv_state_init(int argc
, char **argv
);
18 void lttv_state_destroy();
20 /* The main program maintains a few central data structures and relies
21 on modules for the rest. These data structures may be accessed by modules
22 through an exported API */
24 static LttvIAttribute
*attributes
;
40 static void lttv_module_option(void *hook_data
);
42 static void lttv_module_path_option(void *hook_data
);
45 extern struct GMemVTable
*glib_mem_profiler_table
;
49 /* Since everything is done in modules, the main program only takes care
50 of the infrastructure. */
52 int main(int argc
, char **argv
) {
54 LttvAttributeValue value
;
57 g_mem_set_vtable(glib_mem_profiler_table
);
58 g_message("Memory summary before main");
62 attributes
= LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
));
64 before_options
= lttv_hooks_new();
65 after_options
= lttv_hooks_new();
66 before_main
= lttv_hooks_new();
67 after_main
= lttv_hooks_new();
69 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/options/before",
70 LTTV_POINTER
, &value
));
71 *(value
.v_pointer
) = before_options
;
72 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/options/after",
73 LTTV_POINTER
, &value
));
74 *(value
.v_pointer
) = after_options
;
75 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
76 LTTV_POINTER
, &value
));
77 *(value
.v_pointer
) = before_main
;
78 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/after",
79 LTTV_POINTER
, &value
));
80 *(value
.v_pointer
) = after_main
;
83 /* Initialize the command line options processing */
85 lttv_option_init(argc
,argv
);
86 lttv_module_init(argc
,argv
);
87 lttv_state_init(argc
,argv
);
89 /* Initialize the module loading */
91 lttv_module_path_add("/usr/lib/lttv/plugins");
93 /* Add some built-in options */
95 lttv_option_add("module",'m', "load a module", "name of module to load",
96 LTTV_OPT_STRING
, &a_module
, lttv_module_option
, NULL
);
98 lttv_option_add("modules-path", 'L',
99 "add a directory to the module search path",
100 "directory to add to the path", LTTV_OPT_STRING
, &a_module_path
,
101 lttv_module_path_option
, NULL
);
103 lttv_hooks_call(before_options
, NULL
);
104 lttv_option_parse(argc
, argv
);
105 lttv_hooks_call(after_options
, NULL
);
107 lttv_hooks_call(before_main
, NULL
);
108 lttv_hooks_call(after_main
, NULL
);
110 lttv_state_destroy();
111 lttv_module_destroy();
112 lttv_option_destroy();
114 lttv_hooks_destroy(before_options
);
115 lttv_hooks_destroy(after_options
);
116 lttv_hooks_destroy(before_main
);
117 lttv_hooks_destroy(after_main
);
118 g_object_unref(attributes
);
121 g_message("Memory summary after main");
127 LttvAttribute
*lttv_global_attributes()
129 return (LttvAttribute
*)attributes
;
133 void lttv_module_option(void *hook_data
)
135 lttv_module_load(a_module
,a_argc
,a_argv
);
139 void lttv_module_path_option(void *hook_data
)
141 lttv_module_path_add(a_module_path
);
This page took 0.055122 seconds and 3 git commands to generate.