b588e42910e3db6df84f8b2ded10215f11297970
3 #include <lttv/module.h>
5 #include <lttv/attribute.h>
6 #include <lttv/option.h>
7 #include <lttv/traceset.h>
10 void lttv_option_init(int argc
, char **argv
);
11 void lttv_option_destroy();
13 void lttv_module_init(int argc
, char **argv
);
14 void lttv_module_destroy();
16 /* The main program maintains a few central data structures and relies
17 on modules for the rest. These data structures may be accessed by modules
18 through an exported API */
20 static LttvIAttributes
*attributes
;
36 static void lttv_module_option(void *hook_data
);
38 static void lttv_module_path_option(void *hook_data
);
41 extern struct GMemVTable
*glib_mem_profiler_table
;
45 /* Since everything is done in modules, the main program only takes care
46 of the infrastructure. */
48 int main(int argc
, char **argv
) {
50 LttvAttributeValue
*value
;
53 g_mem_set_vtable(glib_mem_profiler_table
);
54 g_message("Memory summary before main");
58 attributes
= LTTV_IATTRIBUTES(g_object_new(LTTV_ATTRIBUTES_TYPE
));
60 before_options
= lttv_hooks_new();
61 after_options
= lttv_hooks_new();
62 before_main
= lttv_hooks_new();
63 after_main
= lttv_hooks_new();
65 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/options/before",
66 LTTV_POINTER
, &value
));
67 *(value
->v_pointer
) = before_options
;
68 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/options/after",
69 LTTV_POINTER
, &value
));
70 *(value
->v_pointer
) = after_options
;
71 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
72 LTTV_POINTER
, &value
));
73 *(value
->v_pointer
) = before_main
;
74 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/after",
75 LTTV_POINTER
, &value
));
76 *(value
->v_pointer
) = after_main
;
79 /* Initialize the command line options processing */
81 lttv_option_init(argc
,argv
);
82 lttv_module_init(argc
,argv
);
84 /* Initialize the module loading */
86 lttv_module_path_add("/usr/lib/lttv/plugins");
88 /* Add some built-in options */
90 lttv_option_add("module",'m', "load a module", "name of module to load",
91 LTTV_OPT_STRING
, &aModule
, lttv_module_option
, NULL
);
93 lttv_option_add("modules-path", 'L',
94 "add a directory to the module search path",
95 "directory to add to the path", LTTV_OPT_STRING
, &aModulePath
,
96 lttv_module_path_option
, NULL
);
98 lttv_hooks_call(before_options
, NULL
);
99 lttv_hooks_call(after_options
, NULL
);
100 lttv_hooks_call(before_main
, NULL
);
101 lttv_hooks_call(after_main
, NULL
);
103 lttv_module_destroy();
104 lttv_option_destroy();
106 lttv_hooks_destroy(before_options
);
107 lttv_hooks_destroy(after_options
);
108 lttv_hooks_destroy(before_main
);
109 lttv_hooks_destroy(after_main
);
110 g_object_unref(attributes
);
113 g_message("Memory summary after main");
119 lttv_attributes
*lttv_global_attributes()
125 void lttv_module_option(void *hook_data
)
127 lttv_module_load(a_module
,a_argc
,a_argv
);
131 void lttv_module_path_option(void *hook_data
)
133 lttv_module_path_add(a_path
);
This page took 0.036083 seconds and 4 git commands to generate.