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 /* The main program maintains a few central data structures and relies
23 on modules for the rest. These data structures may be accessed by modules
24 through an exported API */
26 static LttvIAttribute
*attributes
;
42 static void lttv_module_option(void *hook_data
);
44 static void lttv_module_path_option(void *hook_data
);
46 static void lttv_help(void);
48 /* Since everything is done in modules, the main program only takes care
49 of the infrastructure. */
51 int main(int argc
, char **argv
) {
53 LttvAttributeValue value
;
56 g_mem_set_vtable(glib_mem_profiler_table
);
57 g_message("Memory summary before main");
62 //g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS);
64 attributes
= LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
));
66 before_options
= lttv_hooks_new();
67 after_options
= lttv_hooks_new();
68 before_main
= lttv_hooks_new();
69 after_main
= lttv_hooks_new();
71 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/options/before",
72 LTTV_POINTER
, &value
));
73 *(value
.v_pointer
) = before_options
;
74 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/options/after",
75 LTTV_POINTER
, &value
));
76 *(value
.v_pointer
) = after_options
;
77 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
78 LTTV_POINTER
, &value
));
79 *(value
.v_pointer
) = before_main
;
80 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/after",
81 LTTV_POINTER
, &value
));
82 *(value
.v_pointer
) = after_main
;
85 /* Initialize the command line options processing */
87 lttv_option_init(argc
,argv
);
88 lttv_module_init(argc
,argv
);
89 lttv_state_init(argc
,argv
);
91 /* Initialize the module loading */
93 lttv_module_path_add("/usr/lib/lttv/plugins");
95 /* Add some built-in options */
97 lttv_option_add("module",'m', "load a module", "name of module to load",
98 LTTV_OPT_STRING
, &a_module
, lttv_module_option
, NULL
);
100 lttv_option_add("modules-path", 'L',
101 "add a directory to the module search path",
102 "directory to add to the path", LTTV_OPT_STRING
, &a_module_path
,
103 lttv_module_path_option
, NULL
);
105 lttv_option_add("help",'h', "basic help", "none",
106 LTTV_OPT_NONE
, NULL
, lttv_help
, NULL
);
109 lttv_hooks_call(before_options
, NULL
);
110 lttv_option_parse(argc
, argv
);
111 lttv_hooks_call(after_options
, NULL
);
113 lttv_hooks_call(before_main
, NULL
);
114 lttv_hooks_call(after_main
, NULL
);
116 lttv_state_destroy();
117 lttv_module_destroy();
118 lttv_option_destroy();
120 lttv_hooks_destroy(before_options
);
121 lttv_hooks_destroy(after_options
);
122 lttv_hooks_destroy(before_main
);
123 lttv_hooks_destroy(after_main
);
124 g_object_unref(attributes
);
127 g_message("Memory summary after main");
133 LttvAttribute
*lttv_global_attributes()
135 return (LttvAttribute
*)attributes
;
139 void lttv_module_option(void *hook_data
)
141 lttv_module_load(a_module
,a_argc
,a_argv
);
145 void lttv_module_path_option(void *hook_data
)
147 lttv_module_path_add(a_module_path
);
152 printf("Linux Trace Toolkit Visualizer\n");
154 lttv_option_show_help();
This page took 0.031307 seconds and 4 git commands to generate.