header usage fix
[lttv.git] / ltt / branches / poly / lttv / main.c
1
2 #include "lttv.h"
3 #include "trace.h"
4 #include "attribute.h"
5 #include "hook.h"
6 #include "option.h"
7 #include "module.h"
8
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 */
12
13 /* Extensible array of popt command line options. Modules add options as
14 they are loaded and initialized. */
15
16
17 static lttv_attributes *attributes_global;
18
19 static lttv_hooks
20 *hooks_init_after,
21 *hooks_program_before,
22 *hooks_program_main,
23 *hooks_program_after;
24
25 // trace sets has to be put one in each new window_traceset
26 static lttv_trace_set *traces;
27
28 static char *aModule, *aPath, *aTrace;
29
30 static int aArgc;
31
32 static char **aArgv;
33
34 static void lttv_module_option(void *hook_data);
35
36 static void lttv_module_path_option(void *hook_data);
37
38 static void lttv_trace_option(void *hook_data);
39
40 #ifdef MEMDEBUG
41 extern struct GMemVTable *glib_mem_profiler_table;
42 #endif
43
44 /* Since everything is done in modules, the main program only takes care
45 of the infrastructure. */
46
47 int main(int argc, char **argv) {
48
49 aArgc = argc;
50 aArgv = argv;
51
52 #ifdef MEMDEBUG
53 g_mem_set_vtable(glib_mem_profiler_table);
54 g_message("Memory summary before main");
55 g_mem_profile();
56 #endif
57
58 attributes_global = lttv_attributes_new();
59
60 // traces = lttv_trace_set_new();
61 // lttv_attributes_set_pointer_pathname(attributes_global, "trace_set/default", traces);
62
63 /* Initialize the hooks */
64
65 hooks_init_after = lttv_hooks_new();
66 lttv_attributes_set_pointer_pathname(attributes_global, "hooks/init/after",
67 hooks_init_after);
68
69
70 hooks_program_before = lttv_hooks_new();
71 lttv_attributes_set_pointer_pathname(attributes_global, "hooks/program/before",
72 hooks_program_before);
73
74 hooks_program_main = lttv_hooks_new();
75 lttv_attributes_set_pointer_pathname(attributes_global, "hooks/program/main",
76 hooks_program_main);
77
78 hooks_program_after = lttv_hooks_new();
79 lttv_attributes_set_pointer_pathname(attributes_global, "hooks/program/after",
80 hooks_program_after);
81
82 /* Initialize the command line options processing */
83
84 lttv_option_init(argc,argv);
85 lttv_module_init(argc,argv);
86 // FIXME lttv_analyse_init(argc,argv);
87
88 /* Initialize the module loading */
89
90 lttv_module_path_add("/usr/lib/lttv/plugins");
91
92 /* Add some built-in options */
93
94 lttv_option_add("module",'m', "load a module", "name of module to load",
95 LTTV_OPT_STRING, &aModule, lttv_module_option, NULL);
96
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);
101
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);
106
107 lttv_hooks_call(hooks_init_after, NULL);
108
109 lttv_hooks_call(hooks_program_before, NULL);
110 lttv_hooks_call(hooks_program_main, NULL);
111 lttv_hooks_call(hooks_program_after, NULL);
112
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);
118
119 #ifdef MEMDEBUG
120 g_message("Memory summary after main");
121 g_mem_profile();
122 #endif
123
124
125 }
126
127 void lttv_module_option(void *hook_data)
128 {
129 lttv_module_load(aModule,aArgc,aArgv,STANDALONE);
130 }
131
132
133 void lttv_module_path_option(void *hook_data)
134 {
135 lttv_module_path_add(aPath);
136 }
137
138
139 void lttv_trace_option(void *hook_data)
140 {
141 // lttv_trace *trace;
142
143 // trace = lttv_trace_open(aTrace);
144 // if(trace == NULL) g_critical("cannot open trace %s", aTrace);
145 // lttv_trace_set_add(traces, trace);
146 }
147
This page took 0.031263 seconds and 4 git commands to generate.