9 /* The main program maintains a few central data structures and relies
10 on modules for the rest. These data structures may be accessed by modules
11 through an exported API */
13 /* Extensible array of popt command line options. Modules add options as
14 they are loaded and initialized. */
17 static lttv_attributes
*attributes_global
;
21 *hooks_program_before
,
25 // trace sets has to be put one in each new window_traceset
26 static lttv_trace_set
*traces
;
28 static char *aModule
, *aPath
, *aTrace
;
34 static void lttv_module_option(void *hook_data
);
36 static void lttv_module_path_option(void *hook_data
);
38 static void lttv_trace_option(void *hook_data
);
41 extern struct GMemVTable
*glib_mem_profiler_table
;
44 /* Since everything is done in modules, the main program only takes care
45 of the infrastructure. */
47 int main(int argc
, char **argv
) {
53 g_mem_set_vtable(glib_mem_profiler_table
);
54 g_message("Memory summary before main");
58 attributes_global
= lttv_attributes_new();
60 // traces = lttv_trace_set_new();
61 // lttv_attributes_set_pointer_pathname(attributes_global, "trace_set/default", traces);
63 /* Initialize the hooks */
65 hooks_init_after
= lttv_hooks_new();
66 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/init/after",
70 hooks_program_before
= lttv_hooks_new();
71 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/before",
72 hooks_program_before
);
74 hooks_program_main
= lttv_hooks_new();
75 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/main",
78 hooks_program_after
= lttv_hooks_new();
79 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/after",
82 /* Initialize the command line options processing */
84 lttv_option_init(argc
,argv
);
85 lttv_module_init(argc
,argv
);
86 // FIXME lttv_analyse_init(argc,argv);
88 /* Initialize the module loading */
90 lttv_module_path_add("/usr/lib/lttv/plugins");
92 /* Add some built-in options */
94 lttv_option_add("module",'m', "load a module", "name of module to load",
95 LTTV_OPT_STRING
, &aModule
, lttv_module_option
, NULL
);
97 lttv_option_add("modules-path", 'L',
98 "add a directory to the module search path",
99 "directory to add to the path", LTTV_OPT_STRING
, &aPath
,
100 lttv_module_path_option
, NULL
);
102 lttv_option_add("trace", 't',
103 "add a trace to the trace set to analyse",
104 "pathname of the directory containing the trace",
105 LTTV_OPT_STRING
, &aTrace
, lttv_trace_option
, NULL
);
107 lttv_hooks_call(hooks_init_after
, NULL
);
109 lttv_hooks_call(hooks_program_before
, NULL
);
110 lttv_hooks_call(hooks_program_main
, NULL
);
111 lttv_hooks_call(hooks_program_after
, NULL
);
113 /* Finalize the command line options processing */
114 lttv_module_destroy();
115 lttv_option_destroy();
116 // FIXME lttv_analyse_destroy();
117 lttv_attributes_destroy(attributes_global
);
120 g_message("Memory summary after main");
127 lttv_attributes
*lttv_global_attributes()
129 return attributes_global
;
133 void lttv_module_option(void *hook_data
)
135 lttv_module_load(aModule
,aArgc
,aArgv
,STANDALONE
);
139 void lttv_module_path_option(void *hook_data
)
141 lttv_module_path_add(aPath
);
145 void lttv_trace_option(void *hook_data
)
147 // lttv_trace *trace;
149 // trace = lttv_trace_open(aTrace);
150 // if(trace == NULL) g_critical("cannot open trace %s", aTrace);
151 // lttv_trace_set_add(traces, trace);
This page took 0.031265 seconds and 4 git commands to generate.