void gc_register_finalizer(void*); /* Tag a pointer for finalization */
void gc_finalize(void*, void*); /* Finalize a pointer, implemented in the generated code. */
+void object_destroy_callback(void*, void*); /* call into an object finalizer to record some traces. */
#endif
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE
-#include "traces.h"
+#include "nit.common.h"
+
+void object_destroy_callback(void *obj, void *cd){
+ tracepoint(Nit_Compiler, Object_Destroy, (char*)((val*)(obj))->type->name, (uintptr_t)obj);
+}
#define _TRACES_H
#include <lttng/tracepoint.h>
+#include <gc.h>
TRACEPOINT_EVENT(
- Nit_Compiler,
- Object_Instance,
- TP_ARGS(
- char*, object_class_arg,
- int, object_id_arg
- ),
- TP_FIELDS(
- ctf_string(object_class, object_class_arg)
- ctf_integer(int, object_id, object_id_arg)
- )
+ Nit_Compiler,
+ Object_Instance,
+ TP_ARGS(
+ char*, object_class_arg,
+ int, object_id_arg
+ ),
+ TP_FIELDS(
+ ctf_string(object_class, object_class_arg)
+ ctf_integer(int, object_id, object_id_arg)
+ )
+)
+
+TRACEPOINT_EVENT(
+ Nit_Compiler,
+ Object_Destroy,
+ TP_ARGS(
+ char*, object_class_arg,
+ int, object_id_arg
+ ),
+ TP_FIELDS(
+ ctf_string(object_class, object_class_arg)
+ ctf_integer(int, object_id, object_id_arg)
+ )
)
#endif
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<sessions>
+ <session>
+ <name>Nit_Compiler</name>
+ <domains>
+ <domain>
+ <type>UST</type>
+ <buffer_type>PER_UID</buffer_type>
+ <channels>
+ <channel>
+ <name>blocking-channel</name>
+ <enabled>true</enabled>
+ <overwrite_mode>DISCARD</overwrite_mode>
+ <subbuffer_size>524288</subbuffer_size>
+ <subbuffer_count>4</subbuffer_count>
+ <switch_timer_interval>0</switch_timer_interval>
+ <read_timer_interval>0</read_timer_interval>
+ <output_type>MMAP</output_type>
+ <blocking_timeout>0</blocking_timeout>
+ <monitor_timer_interval>1000000</monitor_timer_interval>
+ <tracefile_size>0</tracefile_size>
+ <tracefile_count>0</tracefile_count>
+ <live_timer_interval>0</live_timer_interval>
+ <events>
+ <event>
+ <name>Nit_Compiler:Object_Instance</name>
+ <enabled>true</enabled>
+ <type>TRACEPOINT</type>
+ <loglevel_type>ALL</loglevel_type>
+ </event>
+ <event>
+ <name>Nit_Compiler:Object_Destroy</name>
+ <enabled>true</enabled>
+ <type>TRACEPOINT</type>
+ <loglevel_type>ALL</loglevel_type>
+ </event>
+ </events>
+ <contexts/>
+ </channel>
+ </channels>
+ <trackers/>
+ </domain>
+ <domain>
+ <type>JUL</type>
+ <buffer_type>PER_UID</buffer_type>
+ <channels/>
+ </domain>
+ <domain>
+ <type>LOG4J</type>
+ <buffer_type>PER_UID</buffer_type>
+ <channels/>
+ </domain>
+ <domain>
+ <type>PYTHON</type>
+ <buffer_type>PER_UID</buffer_type>
+ <channels/>
+ </domain>
+ </domains>
+ <started>false</started>
+ <output>
+ <consumer_output>
+ <enabled>true</enabled>
+ <destination>
+ <path>Put your path here !</path>
+ </destination>
+ </consumer_output>
+ </output>
+ </session>
+</sessions>
### `--trace`
Compile with lttng's instrumentation.
-Currently add a lttng trace provider and add tracepoint into object instances.
+Currently add a lttng trace provider and add tracepoint into object instances and destructions.
+
+The lttng nit/misc/Nit_Compiler.lttng file is a template that you can use instead of configure channels by yourself. You have to configure the path of the destination tracefile. <destination> <path> "your path" </path> </destination>
+
+To create a channel with template :
+ lttng-sessiond --daemonize
+ lttng load -i=~/nit/misc/Nit_Compiler.lttng Nit_Compiler
+To create a channel without template :
+ lttng create session_name
+ lttng enable-event --userspace Nit_Compiler:Object_Instance
+ lttng enable-event --userspace Nit_Compiler:Object_Destroy
+To record some traces :
+ lttng start
+ --> run your program
+ lttng stop
+To read some traces :
+ babeltrace ~/session_name
+To destroy your current tracing session :
+ lttng destroy
## COMPILATION MODES
var alloc = v.nit_alloc("sizeof(struct instance) + {attrs.length}*sizeof(nitattribute_t)", mclass.full_name)
v.add("{res} = {alloc};")
end
- if modelbuilder.toolcontext.opt_trace.value then v.add("tracepoint(Nit_Compiler, Object_Instance,\"{mtype}\", (intptr_t)self);")
+ if modelbuilder.toolcontext.opt_trace.value then
+ v.add("tracepoint(Nit_Compiler, Object_Instance,\"{mtype}\", (uintptr_t)self);")
+ v.add("GC_register_finalizer(self, object_destroy_callback, NULL, NULL, NULL);")
+ end
v.add("{res}->type = type;")
hardening_live_type(v, "type")
v.require_declaration("class_{c_name}")