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