Lines Matching full:self

21     def __init__(self, file_path, MonitorType, extra_params={}):  argument
24 self.monitor_type = self.monitor_types.get(MonitorType)
25 if self.monitor_type is None:
28 self.monitor_type = MonitorType
29 self.__fill_rv_templates_dir()
30 self.main_c = self.__read_file(self.monitor_templates_dir + "main.c")
31 self.trace_h = self.__read_file(self.monitor_templates_dir + "trace.h")
32 self.kconfig = self.__read_file(self.monitor_templates_dir + "Kconfig")
33 self.enum_suffix = "_%s" % self.name
34 self.description = extra_params.get("description", self.name) or "auto-generated"
35 self.auto_patch = extra_params.get("auto_patch")
36 if self.auto_patch:
37 self.__fill_rv_kernel_dir()
39 def __fill_rv_templates_dir(self): argument
41 if os.path.exists(self.monitor_templates_dir):
50 self.monitor_templates_dir = kernel_path
54 self.monitor_templates_dir = "/usr/share/dot2/dot2k_templates/"
59 def __fill_rv_kernel_dir(self): argument
62 if os.path.exists(self.rv_dir):
66 kernel_path = os.path.join("../..", self.rv_dir)
69 self.rv_dir = kernel_path
75 kernel_path = os.path.join("/lib/modules/%s/build" % platform.release(), self.rv_dir)
80 self.rv_dir = kernel_path
85 def __read_file(self, path): argument
96 def __buff_to_string(self, buff): argument
105 def fill_monitor_type(self): argument
106 return self.monitor_type.upper()
108 def fill_tracepoint_handlers_skel(self): argument
110 for event in self.events:
114 if self.is_start_event(event):
117 elif self.is_start_run_event(event):
120 if self.monitor_type == "per_task":
122 buff.append("\tda_%s_%s(p, %s%s);" % (handle, self.name, event, self.enum_suffix));
124 buff.append("\tda_%s_%s(%s%s);" % (handle, self.name, event, self.enum_suffix));
127 return self.__buff_to_string(buff)
129 def fill_tracepoint_attach_probe(self): argument
131 for event in self.events:
132 …f.append("\trv_attach_trace_probe(\"%s\", /* XXX: tracepoint */, handle_%s);" % (self.name, event))
133 return self.__buff_to_string(buff)
135 def fill_tracepoint_detach_helper(self): argument
137 for event in self.events:
138 …f.append("\trv_detach_trace_probe(\"%s\", /* XXX: tracepoint */, handle_%s);" % (self.name, event))
139 return self.__buff_to_string(buff)
141 def fill_main_c(self): argument
142 main_c = self.main_c
143 monitor_type = self.fill_monitor_type()
144 min_type = self.get_minimun_type()
145 nr_events = len(self.events)
146 tracepoint_handlers = self.fill_tracepoint_handlers_skel()
147 tracepoint_attach = self.fill_tracepoint_attach_probe()
148 tracepoint_detach = self.fill_tracepoint_detach_helper()
152 main_c = main_c.replace("%%MODEL_NAME%%", self.name)
157 main_c = main_c.replace("%%DESCRIPTION%%", self.description)
161 def fill_model_h_header(self): argument
164 buff.append(" * Automatically generated C representation of %s automaton" % (self.name))
172 def fill_model_h(self): argument
176 self.enum_states_def = "states_%s" % self.name
177 self.enum_events_def = "events_%s" % self.name
178 self.struct_automaton_def = "automaton_%s" % self.name
179 self.var_automaton_def = "automaton_%s" % self.name
181 buff = self.fill_model_h_header()
182 buff += self.format_model()
184 return self.__buff_to_string(buff)
186 def fill_monitor_class_type(self): argument
187 if self.monitor_type == "per_task":
191 def fill_monitor_class(self): argument
192 if self.monitor_type == "per_task":
196 def fill_tracepoint_args_skel(self, tp_type): argument
210 if self.monitor_type == "per_task":
216 return self.__buff_to_string(buff)
218 def fill_trace_h(self): argument
219 trace_h = self.trace_h
220 monitor_class = self.fill_monitor_class()
221 monitor_class_type = self.fill_monitor_class_type()
222 tracepoint_args_skel_event = self.fill_tracepoint_args_skel("event")
223 tracepoint_args_skel_error = self.fill_tracepoint_args_skel("error")
224 trace_h = trace_h.replace("%%MODEL_NAME%%", self.name)
225 trace_h = trace_h.replace("%%MODEL_NAME_UP%%", self.name.upper())
232 def fill_kconfig(self): argument
233 kconfig = self.kconfig
234 monitor_class_type = self.fill_monitor_class_type()
235 kconfig = kconfig.replace("%%MODEL_NAME%%", self.name)
236 kconfig = kconfig.replace("%%MODEL_NAME_UP%%", self.name.upper())
238 kconfig = kconfig.replace("%%DESCRIPTION%%", self.description)
241 def __patch_file(self, file, marker, line): argument
242 file_to_patch = os.path.join(self.rv_dir, file)
243 content = self.__read_file(file_to_patch)
245 self.__write_file(file_to_patch, content)
247 def fill_tracepoint_tooltip(self): argument
248 monitor_class_type = self.fill_monitor_class_type()
249 if self.auto_patch:
250 self.__patch_file("rv_trace.h",
252 "#include <monitors/%s/%s_trace.h>" % (self.name, self.name))
253 return " - Patching %s/rv_trace.h, double check the result" % self.rv_dir
258 """ % (self.rv_dir, monitor_class_type, self.name, self.name)
260 def fill_kconfig_tooltip(self): argument
261 if self.auto_patch:
262 self.__patch_file("Kconfig",
264 "source \"kernel/trace/rv/monitors/%s/Kconfig\"" % (self.name))
265 return " - Patching %s/Kconfig, double check the result" % self.rv_dir
270 """ % (self.rv_dir, self.name)
272 def fill_makefile_tooltip(self): argument
273 name = self.name
275 if self.auto_patch:
276 self.__patch_file("Makefile",
279 return " - Patching %s/Makefile, double check the result" % self.rv_dir
284 """ % (self.rv_dir, name_up, name, name)
286 def fill_monitor_tooltip(self): argument
287 if self.auto_patch:
288 return " - Monitor created in %s/monitors/%s" % (self.rv_dir, self. name)
289 … return " - Move %s/ to the kernel's monitor directory (%s/monitors)" % (self.name, self.rv_dir)
291 def __create_directory(self): argument
292 path = self.name
293 if self.auto_patch:
294 path = os.path.join(self.rv_dir, "monitors", path)
300 print("Fail creating the output dir: %s" % self.name)
302 def __write_file(self, file_name, content): argument
312 def __create_file(self, file_name, content): argument
313 path = "%s/%s" % (self.name, file_name)
314 if self.auto_patch:
315 path = os.path.join(self.rv_dir, "monitors", path)
316 self.__write_file(path, content)
318 def __get_main_name(self): argument
319 path = "%s/%s" % (self.name, "main.c")
324 def print_files(self): argument
325 main_c = self.fill_main_c()
326 model_h = self.fill_model_h()
328 self.__create_directory()
330 path = "%s.c" % self.name
331 self.__create_file(path, main_c)
333 path = "%s.h" % self.name
334 self.__create_file(path, model_h)
336 trace_h = self.fill_trace_h()
337 path = "%s_trace.h" % self.name
338 self.__create_file(path, trace_h)
340 kconfig = self.fill_kconfig()
341 self.__create_file("Kconfig", kconfig)