3 #include <lttv/module.h>
6 #include <lttv/attribute.h>
7 #include <lttv/option.h>
9 #include <lttv/traceSet.h>
11 #include <ltt/trace.h>
12 /* The main program maintains a few central data structures and relies
13 on modules for the rest. These data structures may be accessed by modules
14 through an exported API */
16 /* Extensible array of popt command line options. Modules add options as
17 they are loaded and initialized. */
20 static lttv_attributes
*attributes_global
;
24 *hooks_program_before
,
28 // trace sets has to be put one in each new window_traceset
29 static lttv_trace_set
*traces
;
31 static char *aModule
, *aPath
, *aTrace
;
37 static void lttv_module_option(void *hook_data
);
39 static void lttv_module_path_option(void *hook_data
);
41 static void lttv_trace_option(void *hook_data
);
44 extern struct GMemVTable
*glib_mem_profiler_table
;
47 /* Since everything is done in modules, the main program only takes care
48 of the infrastructure. */
50 int main(int argc
, char **argv
) {
56 g_mem_set_vtable(glib_mem_profiler_table
);
57 g_message("Memory summary before main");
61 attributes_global
= lttv_attributes_new();
63 // traces = lttv_trace_set_new();
64 // lttv_attributes_set_pointer_pathname(attributes_global, "trace_set/default", traces);
66 /* Initialize the hooks */
68 hooks_init_after
= lttv_hooks_new();
69 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/init/after",
73 hooks_program_before
= lttv_hooks_new();
74 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/before",
75 hooks_program_before
);
77 hooks_program_main
= lttv_hooks_new();
78 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/main",
81 hooks_program_after
= lttv_hooks_new();
82 lttv_attributes_set_pointer_pathname(attributes_global
, "hooks/program/after",
85 /* Initialize the command line options processing */
87 lttv_option_init(argc
,argv
);
88 lttv_module_init(argc
,argv
);
89 // FIXME lttv_analyse_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
, &aModule
, 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
, &aPath
,
103 lttv_module_path_option
, NULL
);
105 lttv_option_add("trace", 't',
106 "add a trace to the trace set to analyse",
107 "pathname of the directory containing the trace",
108 LTTV_OPT_STRING
, &aTrace
, lttv_trace_option
, NULL
);
110 lttv_hooks_call(hooks_init_after
, NULL
);
112 lttv_hooks_call(hooks_program_before
, NULL
);
113 lttv_hooks_call(hooks_program_main
, NULL
);
114 lttv_hooks_call(hooks_program_after
, NULL
);
116 /* Finalize the command line options processing */
117 lttv_module_destroy();
118 lttv_option_destroy();
119 // FIXME lttv_analyse_destroy();
120 lttv_attributes_destroy(attributes_global
);
123 g_message("Memory summary after main");
130 lttv_attributes
*lttv_global_attributes()
132 return attributes_global
;
136 void lttv_module_option(void *hook_data
)
138 lttv_module_load(aModule
,aArgc
,aArgv
,STANDALONE
);
142 void lttv_module_path_option(void *hook_data
)
144 lttv_module_path_add(aPath
);
148 void lttv_trace_option(void *hook_data
)
150 // lttv_trace *trace;
152 // trace = lttv_trace_open(aTrace);
153 // if(trace == NULL) g_critical("cannot open trace %s", aTrace);
154 // lttv_trace_set_add(traces, trace);
This page took 0.033388 seconds and 4 git commands to generate.