Updated MSpec submodule to 528e64de
[rbx.git] / shotgun / lib / dtrace_probes.c
blobe20f074bc205591604b987507cba94495a8cfaf5
1 #include "shotgun/lib/shotgun.h"
2 #include "shotgun/lib/cpu.h"
3 #include "shotgun/lib/tuple.h"
4 #include "shotgun/lib/module.h"
5 #include "shotgun/lib/class.h"
6 #include "shotgun/lib/hash.h"
7 #include "shotgun/lib/lookuptable.h"
8 #include "shotgun/lib/methctx.h"
9 #include "shotgun/lib/array.h"
10 #include "shotgun/lib/string.h"
11 #include "shotgun/lib/symbol.h"
12 #include "shotgun/lib/machine.h"
13 #include "shotgun/lib/bytearray.h"
14 #include "shotgun/lib/fixnum.h"
15 #include "shotgun/lib/sendsite.h"
16 #include "shotgun/lib/subtend/ffi.h"
17 #include "shotgun/lib/subtend/nmc.h"
19 #if CONFIG_ENABLE_DTRACE
20 #include "shotgun/lib/dtrace_probes.h"
23 * Function entry/exit probe implementations
26 void dtrace_function_primitive_entry(STATE, cpu c, const struct message *msg) {
27 const char *module_name = msg->module == Qnil ? "<unknown>" : rbs_symbol_to_cstring(state, module_get_name(msg->module));
28 const char *method_name = rbs_symbol_to_cstring(state, msg->name);
30 cpu_flush_ip(c);
32 int line_number; const char *filename;
33 _source_location(&line_number, &filename);
35 RUBINIUS_FUNCTION_PRIMITIVE_ENTRY((char*)module_name, (char*)method_name, (char*)filename, line_number);
38 void dtrace_function_primitive_return(STATE, cpu c, const struct message *msg) {
39 const char *module_name = msg->module == Qnil ? "<unknown>" : rbs_symbol_to_cstring(state, module_get_name(msg->module));
40 const char *method_name = rbs_symbol_to_cstring(state, msg->name);
42 cpu_flush_ip(c);
44 int line_number; const char *filename;
45 _source_location(&line_number, &filename);
47 RUBINIUS_FUNCTION_PRIMITIVE_RETURN((char*)module_name, (char*)method_name, (char*)filename, line_number);
50 void dtrace_function_entry(STATE, cpu c, const struct message *msg) {
51 const char *module_name = msg->module == Qnil ? "<unknown>" : rbs_symbol_to_cstring(state, module_get_name(msg->module));
52 const char *method_name = rbs_symbol_to_cstring(state, msg->name);
54 cpu_flush_ip(c);
56 if (!NIL_P(c->active_context)) {
57 int line_number; const char *filename;
58 _source_location(&line_number, &filename);
60 RUBINIUS_FUNCTION_ENTRY((char*)module_name, (char*)method_name, (char*)filename, line_number);
61 } else {
62 RUBINIUS_FUNCTION_ENTRY((char*)module_name, (char*)method_name, (char*)"-", 0); // in cases where there's no active context, ie. bootup
66 void dtrace_function_return(STATE, cpu c) {
67 OBJECT module = cpu_current_module(state, c);
69 const char *module_name = (module == Qnil) ? "<unknown>" : rbs_symbol_to_cstring(state, module_get_name(module));
70 const char *method_name = rbs_symbol_to_cstring(state, cmethod_get_name(cpu_current_method(state, c)));
72 cpu_flush_ip(c);
74 int line_number; const char *filename;
75 _source_location(&line_number, &filename);
77 RUBINIUS_FUNCTION_RETURN((char*)module_name, (char*)method_name, (char*)filename, line_number);
82 * Memory/GC probe implementations
85 void dtrace_gc_begin(STATE) {
86 // Young generation stats
87 int young_allocated = baker_gc_memory_allocated(state->om->gc);
88 int young_in_use = baker_gc_memory_in_use(state->om->gc);
89 int young_obj_count = baker_gc_used(state->om->gc);
91 // Mature generations stats
93 RUBINIUS_GC_BEGIN(young_allocated, young_in_use, young_obj_count);
95 baker_gc_reset_used(state->om->gc);
98 void dtrace_gc_end(STATE) {
99 // Young generation stats
100 int young_allocated = baker_gc_memory_allocated(state->om->gc);
101 int young_in_use = baker_gc_memory_in_use(state->om->gc);
102 int young_obj_count = baker_gc_used(state->om->gc);
104 // Mature generations stats
106 RUBINIUS_GC_END(young_allocated, young_in_use, young_obj_count);
109 void object_create_start(OBJECT cls) {
110 RUBINIUS_OBJECT_CREATE_START((char*)_inspect(cls), (char*)"unknown.rb", 1);
113 void object_create_done(OBJECT cls) {
114 RUBINIUS_OBJECT_CREATE_DONE((char*)_inspect(cls), (char*)"unknown.rb", 1);
117 #endif