Lines Matching refs:self

21     def __init__(self, file_path, MonitorType, extra_params={}):  argument
22 self.container = extra_params.get("container")
23 self.parent = extra_params.get("parent")
24 self.__fill_rv_templates_dir()
26 if self.container:
31 if self.parent:
33 self.name = extra_params.get("model_name")
34 self.events = []
35 self.states = []
36 self.main_c = self.__read_file(self.monitor_templates_dir + "main_container.c")
37 self.main_h = self.__read_file(self.monitor_templates_dir + "main_container.h")
41 self.monitor_type = self.monitor_types.get(MonitorType)
42 if self.monitor_type is None:
44 self.monitor_type = MonitorType
45 self.main_c = self.__read_file(self.monitor_templates_dir + "main.c")
46 self.trace_h = self.__read_file(self.monitor_templates_dir + "trace.h")
47 self.kconfig = self.__read_file(self.monitor_templates_dir + "Kconfig")
48 self.enum_suffix = "_%s" % self.name
49 self.description = extra_params.get("description", self.name) or "auto-generated"
50 self.auto_patch = extra_params.get("auto_patch")
51 if self.auto_patch:
52 self.__fill_rv_kernel_dir()
54 def __fill_rv_templates_dir(self): argument
56 if os.path.exists(self.monitor_templates_dir):
65 self.monitor_templates_dir = kernel_path
69 self.monitor_templates_dir = "/usr/share/dot2/dot2k_templates/"
74 def __fill_rv_kernel_dir(self): argument
77 if os.path.exists(self.rv_dir):
81 kernel_path = os.path.join("../..", self.rv_dir)
84 self.rv_dir = kernel_path
90 kernel_path = os.path.join("/lib/modules/%s/build" % platform.release(), self.rv_dir)
95 self.rv_dir = kernel_path
100 def __read_file(self, path): argument
111 def __buff_to_string(self, buff): argument
120 def fill_monitor_type(self): argument
121 return self.monitor_type.upper()
123 def fill_parent(self): argument
124 return "&rv_%s" % self.parent if self.parent else "NULL"
126 def fill_include_parent(self): argument
127 if self.parent:
128 return "#include <monitors/%s/%s.h>\n" % (self.parent, self.parent)
131 def fill_tracepoint_handlers_skel(self): argument
133 for event in self.events:
137 if self.is_start_event(event):
140 elif self.is_start_run_event(event):
143 if self.monitor_type == "per_task":
145 buff.append("\tda_%s_%s(p, %s%s);" % (handle, self.name, event, self.enum_suffix));
147 buff.append("\tda_%s_%s(%s%s);" % (handle, self.name, event, self.enum_suffix));
150 return self.__buff_to_string(buff)
152 def fill_tracepoint_attach_probe(self): argument
154 for event in self.events:
155 …f.append("\trv_attach_trace_probe(\"%s\", /* XXX: tracepoint */, handle_%s);" % (self.name, event))
156 return self.__buff_to_string(buff)
158 def fill_tracepoint_detach_helper(self): argument
160 for event in self.events:
161 …f.append("\trv_detach_trace_probe(\"%s\", /* XXX: tracepoint */, handle_%s);" % (self.name, event))
162 return self.__buff_to_string(buff)
164 def fill_main_c(self): argument
165 main_c = self.main_c
166 monitor_type = self.fill_monitor_type()
167 min_type = self.get_minimun_type()
168 nr_events = len(self.events)
169 tracepoint_handlers = self.fill_tracepoint_handlers_skel()
170 tracepoint_attach = self.fill_tracepoint_attach_probe()
171 tracepoint_detach = self.fill_tracepoint_detach_helper()
172 parent = self.fill_parent()
173 parent_include = self.fill_include_parent()
177 main_c = main_c.replace("%%MODEL_NAME%%", self.name)
182 main_c = main_c.replace("%%DESCRIPTION%%", self.description)
188 def fill_model_h_header(self): argument
192 buff.append(" * Automatically generated C representation of %s automaton" % (self.name))
200 def fill_model_h(self): argument
204 self.enum_states_def = "states_%s" % self.name
205 self.enum_events_def = "events_%s" % self.name
206 self.struct_automaton_def = "automaton_%s" % self.name
207 self.var_automaton_def = "automaton_%s" % self.name
209 buff = self.fill_model_h_header()
210 buff += self.format_model()
212 return self.__buff_to_string(buff)
214 def fill_monitor_class_type(self): argument
215 if self.monitor_type == "per_task":
219 def fill_monitor_class(self): argument
220 if self.monitor_type == "per_task":
224 def fill_tracepoint_args_skel(self, tp_type): argument
238 if self.monitor_type == "per_task":
244 return self.__buff_to_string(buff)
246 def fill_monitor_deps(self): argument
249 if self.parent:
250 buff.append(" depends on RV_MON_%s" % self.parent.upper())
252 return self.__buff_to_string(buff)
254 def fill_trace_h(self): argument
255 trace_h = self.trace_h
256 monitor_class = self.fill_monitor_class()
257 monitor_class_type = self.fill_monitor_class_type()
258 tracepoint_args_skel_event = self.fill_tracepoint_args_skel("event")
259 tracepoint_args_skel_error = self.fill_tracepoint_args_skel("error")
260 trace_h = trace_h.replace("%%MODEL_NAME%%", self.name)
261 trace_h = trace_h.replace("%%MODEL_NAME_UP%%", self.name.upper())
268 def fill_kconfig(self): argument
269 kconfig = self.kconfig
270 monitor_class_type = self.fill_monitor_class_type()
271 monitor_deps = self.fill_monitor_deps()
272 kconfig = kconfig.replace("%%MODEL_NAME%%", self.name)
273 kconfig = kconfig.replace("%%MODEL_NAME_UP%%", self.name.upper())
275 kconfig = kconfig.replace("%%DESCRIPTION%%", self.description)
279 def fill_main_container_h(self): argument
280 main_h = self.main_h
281 main_h = main_h.replace("%%MODEL_NAME%%", self.name)
284 def __patch_file(self, file, marker, line): argument
285 file_to_patch = os.path.join(self.rv_dir, file)
286 content = self.__read_file(file_to_patch)
288 self.__write_file(file_to_patch, content)
290 def fill_tracepoint_tooltip(self): argument
291 monitor_class_type = self.fill_monitor_class_type()
292 if self.auto_patch:
293 self.__patch_file("rv_trace.h",
295 "#include <monitors/%s/%s_trace.h>" % (self.name, self.name))
296 return " - Patching %s/rv_trace.h, double check the result" % self.rv_dir
301 """ % (self.rv_dir, monitor_class_type, self.name, self.name)
303 def fill_kconfig_tooltip(self): argument
304 if self.auto_patch:
305 self.__patch_file("Kconfig",
307 "source \"kernel/trace/rv/monitors/%s/Kconfig\"" % (self.name))
308 return " - Patching %s/Kconfig, double check the result" % self.rv_dir
313 """ % (self.rv_dir, self.name)
315 def fill_makefile_tooltip(self): argument
316 name = self.name
318 if self.auto_patch:
319 self.__patch_file("Makefile",
322 return " - Patching %s/Makefile, double check the result" % self.rv_dir
327 """ % (self.rv_dir, name_up, name, name)
329 def fill_monitor_tooltip(self): argument
330 if self.auto_patch:
331 return " - Monitor created in %s/monitors/%s" % (self.rv_dir, self. name)
332 … return " - Move %s/ to the kernel's monitor directory (%s/monitors)" % (self.name, self.rv_dir)
334 def __create_directory(self): argument
335 path = self.name
336 if self.auto_patch:
337 path = os.path.join(self.rv_dir, "monitors", path)
343 print("Fail creating the output dir: %s" % self.name)
345 def __write_file(self, file_name, content): argument
355 def __create_file(self, file_name, content): argument
356 path = "%s/%s" % (self.name, file_name)
357 if self.auto_patch:
358 path = os.path.join(self.rv_dir, "monitors", path)
359 self.__write_file(path, content)
361 def __get_main_name(self): argument
362 path = "%s/%s" % (self.name, "main.c")
367 def print_files(self): argument
368 main_c = self.fill_main_c()
370 self.__create_directory()
372 path = "%s.c" % self.name
373 self.__create_file(path, main_c)
375 if self.container:
376 main_h = self.fill_main_container_h()
377 path = "%s.h" % self.name
378 self.__create_file(path, main_h)
380 model_h = self.fill_model_h()
381 path = "%s.h" % self.name
382 self.__create_file(path, model_h)
384 trace_h = self.fill_trace_h()
385 path = "%s_trace.h" % self.name
386 self.__create_file(path, trace_h)
388 kconfig = self.fill_kconfig()
389 self.__create_file("Kconfig", kconfig)