add destruction traces, add lttng channel configuration file, resolve the signed...
authorolivierschirm <olive.schirm@gmail.com>
Thu, 17 May 2018 13:14:24 +0000 (09:14 -0400)
committerolivierschirm <olive.schirm@gmail.com>
Mon, 28 May 2018 22:32:49 +0000 (18:32 -0400)
add some infomations in nitc man page

Signed-off-by: olivierschirm <olive.schirm@gmail.com>

clib/gc_chooser.h
clib/traces.c
clib/traces.h
misc/Nit_Compiler.lttng [new file with mode: 0644]
share/man/nitc.md
src/compiler/separate_compiler.nit

index 255e07a..882d310 100644 (file)
@@ -22,5 +22,6 @@ void initialize_gc_option(void); /* Select the wanted GC using envvar `NIT_GC_OP
 
 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
index 4b01642..9e3c3ad 100644 (file)
@@ -1,4 +1,8 @@
 #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);
+}
index 1b88f68..b34af65 100644 (file)
@@ -8,18 +8,32 @@
 #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
diff --git a/misc/Nit_Compiler.lttng b/misc/Nit_Compiler.lttng
new file mode 100644 (file)
index 0000000..b21d50a
--- /dev/null
@@ -0,0 +1,69 @@
+<?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>
index d29a131..eff6232 100644 (file)
@@ -249,7 +249,25 @@ For more debugging-related options, see also `--hardening` and `NIT_GC_OPTION`
 ### `--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
 
index a587c59..15b6f05 100644 (file)
@@ -982,7 +982,10 @@ class SeparateCompiler
                                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}")