3 #include <lttv/module.h>
10 /* The main program maintains a few central data structures and relies
11 on modules for the rest. These data structures may be accessed by modules
12 through an exported API */
14 /* Extensible array of popt command line options. Modules add options as
15 they are loaded and initialized. */
18 static lttv_attributes
*attributes_global
;
22 *hooks_program_before
,
26 // trace sets has to be put one in each new window_traceset
27 static lttv_trace_set
*traces
;
29 static char *aModule
, *aPath
, *aTrace
;
35 static void lttv_module_option(void *hook_data
);
37 static void lttv_module_path_option(void *hook_data
);
39 static void lttv_trace_option(void *hook_data
);
42 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
) {
54 g_mem_set_vtable(glib_mem_profiler_table
);
55 g_message("Memory summary before main");
59 attributes_global
= lttv_attributes_new();
61 // traces = lttv_trace_set_new();
62 // lttv_attributes_set_pointer_pathname(attributes_global, "trace_set/default", traces);
64 /* Initialize the hooks */
66 hooks_init_after
= lttv_hooks_new();
67 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/init/after",
71 hooks_program_before
= lttv_hooks_new();
72 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/before",
73 hooks_program_before
);
75 hooks_program_main
= lttv_hooks_new();
76 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/main",
79 hooks_program_after
= lttv_hooks_new();
80 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/after",
83 /* Initialize the command line options processing */
85 lttv_option_init(argc
,argv
);
86 lttv_module_init(argc
,argv
);
87 // FIXME lttv_analyse_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
, &aModule
, 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
, &aPath
,
101 lttv_module_path_option
, NULL
);
103 lttv_option_add("trace", 't',
104 "add a trace to the trace set to analyse",
105 "pathname of the directory containing the trace",
106 LTTV_OPT_STRING
, &aTrace
, lttv_trace_option
, NULL
);
108 lttv_hooks_call(hooks_init_after
, NULL
);
110 lttv_hooks_call(hooks_program_before
, NULL
);
111 lttv_hooks_call(hooks_program_main
, NULL
);
112 lttv_hooks_call(hooks_program_after
, NULL
);
114 /* Finalize the command line options processing */
115 lttv_module_destroy();
116 lttv_option_destroy();
117 // FIXME lttv_analyse_destroy();
118 lttv_attributes_destroy(attributes_global
);
121 g_message("Memory summary after main");
128 lttv_attributes
*lttv_global_attributes()
130 return attributes_global
;
134 void lttv_module_option(void *hook_data
)
136 lttv_module_load(aModule
,aArgc
,aArgv
,STANDALONE
);
140 void lttv_module_path_option(void *hook_data
)
142 lttv_module_path_add(aPath
);
146 void lttv_trace_option(void *hook_data
)
148 // lttv_trace *trace;
150 // trace = lttv_trace_open(aTrace);
151 // if(trace == NULL) g_critical("cannot open trace %s", aTrace);
152 // lttv_trace_set_add(traces, trace);
This page took 0.031747 seconds and 4 git commands to generate.