diff --git a/History.txt b/History.txt index 381f153..e13914e 100644 --- a/History.txt +++ b/History.txt @@ -6,7 +6,7 @@ == 0.2.8 / 2009-07-23 - * Replace string-eval provider class creation + * Replace string-eval provider class creation * Fix GC bug with DOF data on Mac OSX (reported by ecin@copypastel.com) * Add each_probe_prog method to list probes enabled by a program * Fix conversion of 64 bit values in probe data (reported by ecin@copypastel.com) @@ -22,7 +22,7 @@ == 0.2.5 / 2008-06-14 - * Rework Dtrace::Provider to directly create USDT providers by + * Rework Dtrace::Provider to directly create USDT providers by generating DOF and stub functions. == 0.0.6 / 2008-02-17 @@ -32,7 +32,7 @@ == 0.0.5 / 2008-01-24 - * Add DtraceErrData and DtraceDropData for access to error + * Add DtraceErrData and DtraceDropData for access to error and drop information * Fix interaction with Ruby's GC @@ -43,8 +43,8 @@ == 0.0.3 / 2008-01-06 * Add a DtraceData class which consumers return, containing - the data returned from each probe firing, rather than - returning the raw records directly from DTrace. + the data returned from each probe firing, rather than + returning the raw records directly from DTrace. * Provide access to probe, CPU and flow information. * Allow creation and grabbing of processes. * Add an example script: a port of scsi.d. diff --git a/README.txt b/README.txt index b798387..44ec49d 100644 --- a/README.txt +++ b/README.txt @@ -9,7 +9,7 @@ Fork the repository on Github: http://github.com/chrisa/ruby-dtrace Rubyforge mailing list: http://rubyforge.org/mailman/listinfo/ruby-dtrace-users == FEATURES - + Consumer: * Access to the D API @@ -29,7 +29,7 @@ Consumer: see Dtrace require 'Dtrace' - t = Dtrace.new + t = Dtrace.new progtext = 'ruby$1:::function-entry{ @a[strjoin(strjoin(copyinstr(arg0),"."),copyinstr(arg1))] = count(); } END { printa(@a); }' prog = t.compile progtext prog.execute @@ -37,7 +37,7 @@ Consumer: see Dtrace t.go [...] - + c = DtraceConsumer.new(t) c.consume_once do |rec| # handle records @@ -54,11 +54,11 @@ Probes: see Dtrace::Provider Dtrace::Probe::Rubyprog.foo do |p| p.fire('fired!', 'again') - end + end Dtrace::Probe::Rubyprog.bar do |p| p.fire(42, 27) - end + end == REQUIREMENTS @@ -68,7 +68,7 @@ Probes: see Dtrace::Provider * For the probe API, a platform with DTrace support (as for the consumer API), with a 32 bit or 64 bit Ruby build - i386/x86_64, PowerPC (for OS X) and SPARC (for Solaris) are all supported. - + * root, or some/all of the dtrace privileges on Solaris: dtrace_user, dtrace_proc and dtrace_kernel. diff --git a/Rakefile b/Rakefile index 3efe198..40a7b6d 100644 --- a/Rakefile +++ b/Rakefile @@ -17,7 +17,7 @@ task :extensions do system("make") Dir.chdir('dof') system("ruby extconf.rb") - system("make") + system("make") Dir.chdir('../..') end @@ -26,42 +26,42 @@ task :clean_extensions do Dir.chdir('ext') system("make clean") Dir.chdir('dof') - system("make clean") + system("make clean") Dir.chdir('../..') end - + PKG_NAME = "ruby-dtrace" PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' PKG_VERSION = Dtrace::VERSION + PKG_BUILD PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" - + desc "Default task" task :default => [ :test ] - + desc "Build documentation" task :doc => [ :rdoc ] - + Rake::TestTask.new do |t| t.libs << "ext:lib" t.test_files = Dir["test/*.rb"] t.verbose = true end - + desc "Run code-coverage analysis using rcov" task :coverage do rm_rf "coverage" files = Dir["test/*.rb"] system "rcov --sort coverage -Iext:lib #{files.join(' ')}" end - + GEM_SPEC = eval(File.read("#{File.dirname(__FILE__)}/#{PKG_NAME}.gemspec")) - + Rake::GemPackageTask.new(GEM_SPEC) do |p| p.gem_spec = GEM_SPEC p.need_tar = true p.need_zip = true end - + desc "Build the RDoc API documentation" Rake::RDocTask.new do |rdoc| rdoc.rdoc_dir = "doc" diff --git a/ext/dof/constants.c b/ext/dof/constants.c index 3b6a034..b2ab58e 100644 --- a/ext/dof/constants.c +++ b/ext/dof/constants.c @@ -1,11 +1,11 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ #include "dof.h" -void +void _init_constants(VALUE dtrace_dof) { VALUE c = rb_define_module_under(dtrace_dof, "Constants"); diff --git a/ext/dof/dof.h b/ext/dof/dof.h index 56b9131..1159f99 100644 --- a/ext/dof/dof.h +++ b/ext/dof/dof.h @@ -1,4 +1,4 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ diff --git a/ext/dof/dof_api.c b/ext/dof/dof_api.c index 37acd72..93d745b 100644 --- a/ext/dof/dof_api.c +++ b/ext/dof/dof_api.c @@ -1,4 +1,4 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ @@ -17,7 +17,7 @@ void Init_dof_api() { VALUE dof = rb_define_class_under(dtrace, "Dof", rb_cObject); rb_define_singleton_method(dof, "loaddof", dof_loaddof, 2); // in dof_helper.c - + eDtraceDofException = rb_define_class_under(dof, "Exception", rb_eStandardError); cDtraceDofParser = rb_define_class_under(dof, "Parser", rb_cObject); diff --git a/ext/dof/dof_helper.c b/ext/dof/dof_helper.c index aff113c..3c2abd2 100644 --- a/ext/dof/dof_helper.c +++ b/ext/dof/dof_helper.c @@ -24,7 +24,7 @@ int _loaddof(int fd, dof_helper_t *dh) user_addr_t val = (user_addr_t)(unsigned long)ioctlData; ret = ioctl(fd, DTRACEHIOC_ADDDOF, &val); - + return ret; } @@ -66,7 +66,7 @@ VALUE dof_loaddof(VALUE self, VALUE dof_file, VALUE module_name) (void) snprintf(dh.dofhp_mod, sizeof (dh.dofhp_mod), RSTRING(module_name)->ptr); if ((fd = open(helper, O_RDWR)) < 0) { - rb_raise(eDtraceDofException, "failed to open helper device %s: %s", + rb_raise(eDtraceDofException, "failed to open helper device %s: %s", helper, strerror(errno)); return Qnil; } @@ -79,4 +79,4 @@ VALUE dof_loaddof(VALUE self, VALUE dof_file, VALUE module_name) return Qnil; } - + diff --git a/ext/dof/file.c b/ext/dof/file.c index f647599..f8a2342 100644 --- a/ext/dof/file.c +++ b/ext/dof/file.c @@ -1,4 +1,4 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ @@ -31,7 +31,7 @@ VALUE dof_file_alloc(VALUE klass) file->dof = NULL; file->len = 0; file->offset = 0; - + obj = Data_Wrap_Struct(klass, NULL, dof_file_free, file); return obj; } @@ -63,7 +63,7 @@ VALUE dof_file_append(VALUE self, VALUE data) (file->offset + RSTRING(data)->len), file->len); return Qnil; } - + memcpy((file->dof + file->offset), RSTRING(data)->ptr, RSTRING(data)->len); file->offset += RSTRING(data)->len; } @@ -86,5 +86,5 @@ VALUE dof_file_data(VALUE self) dof_file_t *file; Data_Get_Struct(self, dof_file_t, file); return rb_str_new(file->dof, file->offset); -} +} diff --git a/ext/dof/generator.c b/ext/dof/generator.c index fd58598..72ced0e 100644 --- a/ext/dof/generator.c +++ b/ext/dof/generator.c @@ -1,4 +1,4 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ diff --git a/ext/dof/header.c b/ext/dof/header.c index 436c18e..e992c4b 100644 --- a/ext/dof/header.c +++ b/ext/dof/header.c @@ -1,4 +1,4 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ @@ -35,9 +35,9 @@ VALUE dof_generate_header(VALUE self) { dof_version = DOF_VERSION; } #endif - + memset(&hdr, 0, sizeof(hdr)); - + hdr.dofh_ident[DOF_ID_MAG0] = DOF_MAG_MAG0; hdr.dofh_ident[DOF_ID_MAG1] = DOF_MAG_MAG1; hdr.dofh_ident[DOF_ID_MAG2] = DOF_MAG_MAG2; @@ -49,16 +49,16 @@ VALUE dof_generate_header(VALUE self) { hdr.dofh_ident[DOF_ID_DIFVERS] = DIF_VERSION; hdr.dofh_ident[DOF_ID_DIFIREG] = DIF_DIR_NREGS; hdr.dofh_ident[DOF_ID_DIFTREG] = DIF_DTR_NREGS; - + hdr.dofh_hdrsize = sizeof(dof_hdr_t); hdr.dofh_secsize = sizeof(dof_sec_t); - + secnum = FIX2INT(rb_iv_get(self, "@secnum")); hdr.dofh_secnum = secnum; hdr.dofh_loadsz = FIX2INT(rb_iv_get(self, "@loadsz")); hdr.dofh_filesz = FIX2INT(rb_iv_get(self, "@filesz")); - + hdrlen = (sizeof(dof_hdr_t) + secnum * sizeof(dof_sec_t)); rb_iv_set(self, "@hdrlen", INT2FIX(hdrlen)); hdr.dofh_secoff = sizeof(dof_hdr_t); @@ -74,6 +74,6 @@ VALUE dof_header_len(VALUE self) { secnum = FIX2INT(rb_iv_get(self, "@secnum")); hdrlen = (sizeof(dof_hdr_t) + secnum * sizeof(dof_sec_t)); - + return INT2FIX(hdrlen); } diff --git a/ext/dof/parser.c b/ext/dof/parser.c index 5071924..65b2917 100644 --- a/ext/dof/parser.c +++ b/ext/dof/parser.c @@ -1,4 +1,4 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ @@ -104,13 +104,13 @@ _dof_parse_string_table(VALUE self, char *dof, dof_sec_t *sec) VALUE strtab = rb_hash_new(); VALUE ctx = rb_cv_get(self, "@@ctx"); int i, bool = 0; - + for (i = 0; i < sec->dofs_size - 1; ++i) { if (*data) { if (bool) rb_hash_aset(strtab, INT2FIX(i), rb_str_new2(data)); bool = 0; - } + } else if (!bool) { bool = 1; } @@ -185,7 +185,7 @@ _dof_parse_dof_relodesc_t_array(VALUE self, char *dof, dof_sec_t *sec) relodesc_data = rb_hash_new(); rb_hash_aset(relodesc_data, ID2SYM(rb_intern("name")), rb_hash_aref(strtab, INT2FIX(relodesc.dofr_name))); - + switch(relodesc.dofr_type) { case DOF_RELO_NONE: rb_hash_aset(relodesc_data, ID2SYM(rb_intern("type")), rb_str_new2("none")); @@ -197,7 +197,7 @@ _dof_parse_dof_relodesc_t_array(VALUE self, char *dof, dof_sec_t *sec) rb_hash_aset(relodesc_data, ID2SYM(rb_intern("type")), rb_str_new2("unknown")); break; } - + rb_hash_aset(relodesc_data, ID2SYM(rb_intern("offset")), INT2FIX(relodesc.dofr_offset)); rb_hash_aset(relodesc_data, ID2SYM(rb_intern("data")), INT2FIX(relodesc.dofr_data)); @@ -231,7 +231,7 @@ _dof_parse_dof_attr_t(dof_attr_t attr) rb_hash_aset(attr_data, ID2SYM(rb_intern("name")), INT2FIX(DOF_ATTR_NAME(attr))); rb_hash_aset(attr_data, ID2SYM(rb_intern("data")), INT2FIX(DOF_ATTR_DATA(attr))); rb_hash_aset(attr_data, ID2SYM(rb_intern("class")), INT2FIX(DOF_ATTR_CLASS(attr))); - + return attr_data; } @@ -312,7 +312,7 @@ _dof_parse_utsname(VALUE self, char *dof, dof_sec_t *sec) char *data = (char *)(dof + sec->dofs_offset); memcpy(&uts, data, sizeof(uts)); - + rb_hash_aset(uts_data, ID2SYM(rb_intern("sysname")), rb_str_new2(uts.sysname)); rb_hash_aset(uts_data, ID2SYM(rb_intern("nodename")), rb_str_new2(uts.nodename)); rb_hash_aset(uts_data, ID2SYM(rb_intern("release")), rb_str_new2(uts.release)); @@ -358,9 +358,9 @@ VALUE dof_parse(VALUE self, VALUE rdof) return Qnil; } pos += dof_hdr.dofh_hdrsize; - + dof_data = rb_ary_new(); - + /* Walk section headers, parsing sections */ for (i = 0; i < dof_hdr.dofh_secnum; i++) { memcpy(&dof_sec, pos, sizeof(struct dof_sec)); @@ -396,10 +396,10 @@ VALUE dof_parse(VALUE self, VALUE rdof) break; case DOF_SECT_UTSNAME: sec = _dof_parse_utsname(self, dof, &dof_sec); - break; + break; case DOF_SECT_COMMENTS: sec = _dof_parse_comments(self, dof, &dof_sec); - break; + break; default: sec = _dof_parse_unknown(self, dof, &dof_sec); break; diff --git a/ext/dof/parser.h b/ext/dof/parser.h index ffc8102..fa28fe7 100644 --- a/ext/dof/parser.h +++ b/ext/dof/parser.h @@ -1,4 +1,4 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ diff --git a/ext/dof/section.c b/ext/dof/section.c index b68ec03..14b7b93 100644 --- a/ext/dof/section.c +++ b/ext/dof/section.c @@ -1,4 +1,4 @@ -/* +/* * Ruby-Dtrace * (c) 2008 Chris Andrews */ @@ -39,7 +39,7 @@ VALUE dof_generate_comments(VALUE self) { rb_raise(eDtraceDofException, "no comments in dof_generate_comments"); return Qnil; } - + Check_Type(comments, T_STRING); dof = rb_str_new(RSTRING(comments)->ptr, RSTRING(comments)->len + 1); @@ -52,13 +52,13 @@ VALUE dof_generate_probes(VALUE self) { VALUE probes = rb_iv_get(self, "@data"); VALUE probe; int i; - + if (NIL_P(probes) ) { rb_raise(eDtraceDofException, "no probes in dof_generate_probes"); return Qnil; } Check_Type(probes, T_ARRAY); - + dof = rb_str_new2(""); for (i = 0; i < rb_ary_len(probes); i++) { @@ -68,7 +68,7 @@ VALUE dof_generate_probes(VALUE self) { dof_probe_t p; memset(&p, 0, sizeof(p)); - + p.dofpr_addr = (uint64_t)NUM2LL(rb_hash_aref(probe, ID2SYM(rb_intern("addr")))); p.dofpr_func = (dof_stridx_t)FIX2INT(rb_hash_aref(probe, ID2SYM(rb_intern("func")))); p.dofpr_name = (dof_stridx_t)FIX2INT(rb_hash_aref(probe, ID2SYM(rb_intern("name")))); @@ -96,16 +96,16 @@ VALUE dof_generate_strtab(VALUE self) { VALUE strings = rb_iv_get(self, "@data"); VALUE string; int i; - + if (NIL_P(strings) ) { rb_raise(eDtraceDofException, "no strings in dof_generate_strtab"); return Qnil; } Check_Type(strings, T_ARRAY); - + dof = rb_str_new("", 0); rb_str_concat(dof, rb_str_new("\0", 1)); - + for (i = 0; i < rb_ary_len(strings); i++) { string = rb_ary_entry(strings, i); @@ -113,10 +113,10 @@ VALUE dof_generate_strtab(VALUE self) { rb_str_concat(dof, rb_str_new(RSTRING(string)->ptr, RSTRING(string)->len + 1)); } - + return dof; } - + /* :nodoc: */ VALUE dof_generate_utsname(VALUE self) { VALUE dof; @@ -126,7 +126,7 @@ VALUE dof_generate_utsname(VALUE self) { rb_raise(eDtraceDofException, "uname failed: %s", strerror(errno)); return Qnil; } - + dof = rb_str_new((const char *)&u, sizeof(struct utsname)); return dof; } @@ -138,15 +138,15 @@ VALUE dof_generate_prargs(VALUE self) { VALUE rarg; uint8_t arg; int i; - + if (NIL_P(args) ) { rb_raise(eDtraceDofException, "no args in dof_generate_prargs"); return Qnil; } Check_Type(args, T_ARRAY); - + dof = rb_str_new("", 0); - + for (i = 0; i < rb_ary_len(args); i++) { rarg = rb_ary_entry(args, i); Check_Type(rarg, T_FIXNUM); @@ -155,7 +155,7 @@ VALUE dof_generate_prargs(VALUE self) { rb_str_concat(dof, rb_str_new((char *)&arg, 1)); } } - + return dof; } @@ -166,22 +166,22 @@ VALUE dof_generate_proffs(VALUE self) { VALUE rarg; uint32_t arg; int i; - + if (NIL_P(args) ) { rb_raise(eDtraceDofException, "no args in dof_generate_proffs"); return Qnil; } Check_Type(args, T_ARRAY); - + dof = rb_str_new("", 0); - + for (i = 0; i < rb_ary_len(args); i++) { rarg = rb_ary_entry(args, i); Check_Type(rarg, T_FIXNUM); arg = FIX2INT(rarg); rb_str_concat(dof, rb_str_new((char *)&arg, 4)); } - + return dof; } @@ -192,22 +192,22 @@ VALUE dof_generate_prenoffs(VALUE self) { VALUE rarg; uint32_t arg; int i; - + if (NIL_P(args) ) { rb_raise(eDtraceDofException, "no args in dof_generate_prenoffs"); return Qnil; } Check_Type(args, T_ARRAY); - + dof = rb_str_new("", 0); - + for (i = 0; i < rb_ary_len(args); i++) { rarg = rb_ary_entry(args, i); Check_Type(rarg, T_FIXNUM); arg = FIX2INT(rarg); rb_str_concat(dof, rb_str_new((char *)&arg, 4)); } - + return dof; } @@ -232,13 +232,13 @@ VALUE dof_generate_provider(VALUE self) { VALUE dof; VALUE provider = rb_iv_get(self, "@data"); dof_provider_t p; - + if (NIL_P(provider) ) { rb_raise(eDtraceDofException, "no data in dof_generate_provider"); return Qnil; } Check_Type(provider, T_HASH); - + p.dofpv_strtab = (dof_secidx_t)FIX2INT(rb_hash_aref(provider, ID2SYM(rb_intern("strtab")))); p.dofpv_probes = (dof_secidx_t)FIX2INT(rb_hash_aref(provider, ID2SYM(rb_intern("probes")))); p.dofpv_prargs = (dof_secidx_t)FIX2INT(rb_hash_aref(provider, ID2SYM(rb_intern("prargs")))); @@ -250,7 +250,7 @@ VALUE dof_generate_provider(VALUE self) { p.dofpv_nameattr = _dof_generate_dof_attr_t(rb_hash_aref(provider, ID2SYM(rb_intern("nameattr")))); p.dofpv_argsattr = _dof_generate_dof_attr_t(rb_hash_aref(provider, ID2SYM(rb_intern("argsattr")))); p.dofpv_prenoffs = (dof_secidx_t)FIX2INT(rb_hash_aref(provider, ID2SYM(rb_intern("prenoffs")))); - + dof = rb_str_new((const char *)&p, sizeof(p)); return dof; } @@ -261,13 +261,13 @@ VALUE dof_generate_reltab(VALUE self) { VALUE relos = rb_iv_get(self, "@data"); VALUE relo; int i; - + if (NIL_P(relos) ) { rb_raise(eDtraceDofException, "no relos in dof_generate_reltab"); return Qnil; } Check_Type(relos, T_ARRAY); - + dof = rb_str_new2(""); for (i = 0; i < rb_ary_len(relos); i++) { @@ -277,12 +277,12 @@ VALUE dof_generate_reltab(VALUE self) { dof_relodesc_t r; memset(&r, 0, sizeof(r)); - + r.dofr_name = (dof_stridx_t)FIX2INT(rb_hash_aref(relo, ID2SYM(rb_intern("name")))); r.dofr_type = (uint32_t)FIX2INT(rb_hash_aref(relo, ID2SYM(rb_intern("type")))); r.dofr_offset = (uint64_t)FIX2INT(rb_hash_aref(relo, ID2SYM(rb_intern("offset")))); r.dofr_data = (uint64_t)FIX2INT(rb_hash_aref(relo, ID2SYM(rb_intern("data")))); - + VALUE r_dof = rb_str_new((const char *)&r, sizeof(r)); rb_str_concat(dof, r_dof); } @@ -295,17 +295,17 @@ VALUE dof_generate_relhdr(VALUE self) { VALUE dof; VALUE relhdr = rb_iv_get(self, "@data"); dof_relohdr_t r; - + if (NIL_P(relhdr) ) { rb_raise(eDtraceDofException, "no data in dof_generate_relhdr"); return Qnil; } Check_Type(relhdr, T_HASH); - + r.dofr_strtab = (dof_secidx_t)FIX2INT(rb_hash_aref(relhdr, ID2SYM(rb_intern("strtab")))); r.dofr_relsec = (dof_secidx_t)FIX2INT(rb_hash_aref(relhdr, ID2SYM(rb_intern("relsec")))); - r.dofr_tgtsec = (dof_secidx_t)FIX2INT(rb_hash_aref(relhdr, ID2SYM(rb_intern("tgtsec")))); - + r.dofr_tgtsec = (dof_secidx_t)FIX2INT(rb_hash_aref(relhdr, ID2SYM(rb_intern("tgtsec")))); + dof = rb_str_new((const char *)&r, sizeof(r)); return dof; } diff --git a/ext/dtrace_aggdata.c b/ext/dtrace_aggdata.c index 0b1c168..ce77fb9 100644 --- a/ext/dtrace_aggdata.c +++ b/ext/dtrace_aggdata.c @@ -35,7 +35,7 @@ VALUE dtraceaggdata_value(VALUE self) aggdata = bufdata->dtbda_aggdata; s = bufdata->dtbda_buffered; rec = bufdata->dtbda_recdesc; - + if (aggdata == NULL) { rb_raise(eDtraceException, "null aggdata"); return Qnil; @@ -58,7 +58,7 @@ VALUE dtraceaggdata_value(VALUE self) act = rec->dtrd_action; if (bufdata->dtbda_flags & DTRACE_BUFDATA_AGGKEY) { - + switch (act) { case DTRACEACT_STACK: case DTRACEACT_USTACK: @@ -75,10 +75,10 @@ VALUE dtraceaggdata_value(VALUE self) default: v = handle_bytedata((aggdata->dtada_data + rec->dtrd_offset), rec->dtrd_size); } - - + + } else if (bufdata->dtbda_flags & DTRACE_BUFDATA_AGGVAL) { - + normal = aggdata->dtada_normal; addr = aggdata->dtada_data + rec->dtrd_offset; @@ -139,4 +139,4 @@ VALUE dtraceaggdata_aggtype(VALUE self) return v; } - + diff --git a/ext/dtrace_api.c b/ext/dtrace_api.c index a617d6c..a9f5a99 100644 --- a/ext/dtrace_api.c +++ b/ext/dtrace_api.c @@ -75,37 +75,37 @@ void Init_dtrace_api() { rb_define_method(cDtraceProgram, "info", dtraceprogram_info, 0); // in dtrace_program.c cDtraceProgramInfo = rb_define_class_under(cDtrace, "ProgramInfo", rb_cObject); - rb_define_method(cDtraceProgramInfo, "initialize", dtraceprograminfo_init, 0); // in dtrace_programinfo.c + rb_define_method(cDtraceProgramInfo, "initialize", dtraceprograminfo_init, 0); // in dtrace_programinfo.c rb_define_method(cDtraceProgramInfo, "aggregates_count", dtraceprograminfo_aggregates_count, 0); // in dtrace_programinfo.c rb_define_method(cDtraceProgramInfo, "recgens_count", dtraceprograminfo_recgens_count, 0); // in dtrace_programinfo.c rb_define_method(cDtraceProgramInfo, "matches_count", dtraceprograminfo_matches_count, 0); // in dtrace_programinfo.c rb_define_method(cDtraceProgramInfo, "speculations_count", dtraceprograminfo_speculations_count, 0); // in dtrace_programinfo.c cDtraceAggData = rb_define_class_under(cDtrace, "AggData", rb_cObject); - rb_define_method(cDtraceAggData, "initialize", dtraceaggdata_init, 0); // in dtrace_aggdata.c + rb_define_method(cDtraceAggData, "initialize", dtraceaggdata_init, 0); // in dtrace_aggdata.c rb_define_method(cDtraceAggData, "value", dtraceaggdata_value, 0); // in dtrace_aggdata.c rb_define_method(cDtraceAggData, "aggtype", dtraceaggdata_aggtype, 0); // in dtrace_aggdata.c cDtraceRecDesc = rb_define_class_under(cDtrace, "RecDesc", rb_cObject); - rb_define_method(cDtraceRecDesc, "initialize", dtracerecdesc_init, 0); // in dtrace_recdesc.c - rb_define_method(cDtraceRecDesc, "action", dtracerecdesc_action, 0); // in dtrace_recdesc.c + rb_define_method(cDtraceRecDesc, "initialize", dtracerecdesc_init, 0); // in dtrace_recdesc.c + rb_define_method(cDtraceRecDesc, "action", dtracerecdesc_action, 0); // in dtrace_recdesc.c cDtraceDropData = rb_define_class_under(cDtrace, "DropData", rb_cObject); - rb_define_method(cDtraceDropData, "initialize", dtracedropdata_init, 0); // in dtrace_dropdata.c - rb_define_method(cDtraceDropData, "cpu", dtracedropdata_cpu, 0); // in dtrace_dropdata.c - rb_define_method(cDtraceDropData, "drops", dtracedropdata_drops, 0); // in dtrace_dropdata.c - rb_define_method(cDtraceDropData, "total", dtracedropdata_total, 0); // in dtrace_dropdata.c - rb_define_method(cDtraceDropData, "msg", dtracedropdata_msg, 0); // in dtrace_dropdata.c - rb_define_method(cDtraceDropData, "kind", dtracedropdata_kind, 0); // in dtrace_dropdata.c + rb_define_method(cDtraceDropData, "initialize", dtracedropdata_init, 0); // in dtrace_dropdata.c + rb_define_method(cDtraceDropData, "cpu", dtracedropdata_cpu, 0); // in dtrace_dropdata.c + rb_define_method(cDtraceDropData, "drops", dtracedropdata_drops, 0); // in dtrace_dropdata.c + rb_define_method(cDtraceDropData, "total", dtracedropdata_total, 0); // in dtrace_dropdata.c + rb_define_method(cDtraceDropData, "msg", dtracedropdata_msg, 0); // in dtrace_dropdata.c + rb_define_method(cDtraceDropData, "kind", dtracedropdata_kind, 0); // in dtrace_dropdata.c cDtraceErrData = rb_define_class_under(cDtrace, "ErrData", rb_cObject); - rb_define_method(cDtraceErrData, "initialize", dtraceerrdata_init, 0); // in dtrace_errdata.c - rb_define_method(cDtraceErrData, "cpu", dtraceerrdata_cpu, 0); // in dtrace_errdata.c - rb_define_method(cDtraceErrData, "action", dtraceerrdata_action, 0); // in dtrace_errdata.c - rb_define_method(cDtraceErrData, "offset", dtraceerrdata_offset, 0); // in dtrace_errdata.c - rb_define_method(cDtraceErrData, "fault", dtraceerrdata_fault, 0); // in dtrace_errdata.c - rb_define_method(cDtraceErrData, "addr", dtraceerrdata_addr, 0); // in dtrace_errdata.c - rb_define_method(cDtraceErrData, "msg", dtraceerrdata_msg, 0); // in dtrace_errdata.c + rb_define_method(cDtraceErrData, "initialize", dtraceerrdata_init, 0); // in dtrace_errdata.c + rb_define_method(cDtraceErrData, "cpu", dtraceerrdata_cpu, 0); // in dtrace_errdata.c + rb_define_method(cDtraceErrData, "action", dtraceerrdata_action, 0); // in dtrace_errdata.c + rb_define_method(cDtraceErrData, "offset", dtraceerrdata_offset, 0); // in dtrace_errdata.c + rb_define_method(cDtraceErrData, "fault", dtraceerrdata_fault, 0); // in dtrace_errdata.c + rb_define_method(cDtraceErrData, "addr", dtraceerrdata_addr, 0); // in dtrace_errdata.c + rb_define_method(cDtraceErrData, "msg", dtraceerrdata_msg, 0); // in dtrace_errdata.c cDtraceProbe = rb_define_class_under(cDtrace, "Probe", rb_cObject); rb_define_method(cDtraceProbe, "initialize", dtraceprobe_init, 1); // in dtrace_probe.c @@ -115,7 +115,7 @@ void Init_dtrace_api() { rb_define_method(cDtraceProbe, "probe_offset", dtraceprobe_probe_offset, 2); // in dtrace_probe.c rb_define_method(cDtraceProbe, "is_enabled_offset", dtraceprobe_is_enabled_offset, 1); // in dtrace_probe.c rb_define_alloc_func(cDtraceProbe, dtraceprobe_alloc); - + eDtraceException = rb_define_class_under(cDtrace, "Exception", rb_eStandardError); } diff --git a/ext/dtrace_api.h b/ext/dtrace_api.h index 465c67e..e017052 100644 --- a/ext/dtrace_api.h +++ b/ext/dtrace_api.h @@ -22,7 +22,7 @@ typedef struct dtrace_work_handlers { } dtrace_work_handlers_t; /* Used to keep a reference to a struct ps_prochandle and a reference - to the DTrace handle in a DtraceProcess object: we need to be able + to the DTrace handle in a DtraceProcess object: we need to be able to call dtrace_proc_release() when the DtraceProcess goes away, and that requires the DTrace handle. */ typedef struct dtrace_process { diff --git a/ext/dtrace_bufdata.c b/ext/dtrace_bufdata.c index 2d9957c..8642080 100644 --- a/ext/dtrace_bufdata.c +++ b/ext/dtrace_bufdata.c @@ -26,7 +26,7 @@ VALUE dtracebufdata_epid(VALUE self) dtrace_bufdata_t *bufdata; Data_Get_Struct(self, dtrace_bufdata_t, bufdata); - + if (bufdata->dtbda_probe) { return INT2FIX(bufdata->dtbda_probe->dtpda_edesc->dtepd_epid); } @@ -35,8 +35,8 @@ VALUE dtracebufdata_epid(VALUE self) } -/* - * Returns the DtraceProbe for the probe which generated this data +/* + * Returns the DtraceProbe for the probe which generated this data */ VALUE dtracebufdata_probe(VALUE self) { @@ -44,7 +44,7 @@ VALUE dtracebufdata_probe(VALUE self) VALUE dtraceprobe; Data_Get_Struct(self, dtrace_bufdata_t, bufdata); - + if (bufdata->dtbda_probe) { dtraceprobe = Data_Wrap_Struct(cDtraceProbe, 0, NULL, (dtrace_probedesc_t *)bufdata->dtbda_probe->dtpda_pdesc); return dtraceprobe; @@ -53,7 +53,7 @@ VALUE dtracebufdata_probe(VALUE self) return Qnil; } -/* +/* * Returns the record in this DtraceBufdata. Records are returned as * either DtraceRecords or DtraceStackRecords as appropriate for the * type of action. @@ -70,7 +70,7 @@ VALUE dtracebufdata_record(VALUE self) VALUE dtracerecdesc; Data_Get_Struct(self, dtrace_bufdata_t, bufdata); - + if (bufdata->dtbda_aggdata) { dtraceaggdata = Data_Wrap_Struct(cDtraceAggData, 0, NULL, (dtrace_bufdata_t *)bufdata); return dtraceaggdata; @@ -80,12 +80,12 @@ VALUE dtracebufdata_record(VALUE self) if (s == NULL) { return Qnil; } - + rec = bufdata->dtbda_recdesc; if (rec) { act = rec->dtrd_action; } - + switch (act) { case DTRACEACT_DIFEXPR: /* trace() action */ diff --git a/ext/dtrace_dropdata.c b/ext/dtrace_dropdata.c index 7f8254e..8cc1880 100644 --- a/ext/dtrace_dropdata.c +++ b/ext/dtrace_dropdata.c @@ -22,7 +22,7 @@ VALUE dtracedropdata_cpu(VALUE self) processorid_t cpu; Data_Get_Struct(self, dtrace_dropdata_t, data); - + if (data) { cpu = data->dtdda_cpu; return INT2FIX(cpu); @@ -38,7 +38,7 @@ VALUE dtracedropdata_drops(VALUE self) dtrace_dropdata_t *data; Data_Get_Struct(self, dtrace_dropdata_t, data); - + if (data) { return INT2FIX(data->dtdda_drops); } @@ -53,7 +53,7 @@ VALUE dtracedropdata_total(VALUE self) dtrace_dropdata_t *data; Data_Get_Struct(self, dtrace_dropdata_t, data); - + if (data) { return INT2FIX(data->dtdda_total); } @@ -67,9 +67,9 @@ VALUE dtracedropdata_total(VALUE self) VALUE dtracedropdata_msg(VALUE self) { dtrace_dropdata_t *data; - + Data_Get_Struct(self, dtrace_dropdata_t, data); - + if (data) { return rb_str_new2(data->dtdda_msg); } @@ -85,7 +85,7 @@ VALUE dtracedropdata_kind(VALUE self) VALUE kind; Data_Get_Struct(self, dtrace_dropdata_t, data); - + if (data) { switch (data->dtdda_kind) { case DTRACEDROP_PRINCIPAL: @@ -94,10 +94,10 @@ VALUE dtracedropdata_kind(VALUE self) case DTRACEDROP_AGGREGATION: kind = rb_str_new2("drop to aggregation buffer"); break; - case DTRACEDROP_DYNAMIC: + case DTRACEDROP_DYNAMIC: kind = rb_str_new2("dynamic drop"); break; - case DTRACEDROP_DYNRINSE: + case DTRACEDROP_DYNRINSE: kind = rb_str_new2("dyn drop due to rinsing"); break; case DTRACEDROP_DYNDIRTY: @@ -128,4 +128,4 @@ VALUE dtracedropdata_kind(VALUE self) return Qnil; } } - + diff --git a/ext/dtrace_errdata.c b/ext/dtrace_errdata.c index 6dacd3d..589f640 100644 --- a/ext/dtrace_errdata.c +++ b/ext/dtrace_errdata.c @@ -22,7 +22,7 @@ VALUE dtraceerrdata_cpu(VALUE self) processorid_t cpu; Data_Get_Struct(self, dtrace_errdata_t, data); - + if (data) { cpu = data->dteda_cpu; return INT2FIX(cpu); @@ -36,9 +36,9 @@ VALUE dtraceerrdata_cpu(VALUE self) VALUE dtraceerrdata_action(VALUE self) { dtrace_errdata_t *data; - + Data_Get_Struct(self, dtrace_errdata_t, data); - + if (data) { return INT2FIX(data->dteda_action); } @@ -51,9 +51,9 @@ VALUE dtraceerrdata_action(VALUE self) VALUE dtraceerrdata_offset(VALUE self) { dtrace_errdata_t *data; - + Data_Get_Struct(self, dtrace_errdata_t, data); - + if (data) { return INT2FIX(data->dteda_offset); } @@ -66,9 +66,9 @@ VALUE dtraceerrdata_offset(VALUE self) VALUE dtraceerrdata_fault(VALUE self) { dtrace_errdata_t *data; - + Data_Get_Struct(self, dtrace_errdata_t, data); - + if (data) { return INT2FIX(data->dteda_fault); } @@ -81,9 +81,9 @@ VALUE dtraceerrdata_fault(VALUE self) VALUE dtraceerrdata_addr(VALUE self) { dtrace_errdata_t *data; - + Data_Get_Struct(self, dtrace_errdata_t, data); - + if (data) { return INT2FIX(data->dteda_addr); } @@ -97,9 +97,9 @@ VALUE dtraceerrdata_addr(VALUE self) VALUE dtraceerrdata_msg(VALUE self) { dtrace_errdata_t *data; - + Data_Get_Struct(self, dtrace_errdata_t, data); - + if (data) { return rb_str_new2(data->dteda_msg); } diff --git a/ext/dtrace_hdl.c b/ext/dtrace_hdl.c index 1099ace..ff733f5 100644 --- a/ext/dtrace_hdl.c +++ b/ext/dtrace_hdl.c @@ -19,7 +19,7 @@ RUBY_EXTERN VALUE cDtraceErrData; static void dtrace_hdl_free(void *arg) { dtrace_handle_t *handle = (dtrace_handle_t *)arg; - + if (handle) { dtrace_close(handle->hdl); free(handle); @@ -45,14 +45,14 @@ VALUE dtrace_hdl_alloc(VALUE klass) dtrace_handle_t *handle; int err; VALUE obj; - + hdl = dtrace_open(DTRACE_VERSION, 0, &err); - + if (hdl) { /* - * Leopard's DTrace requires symbol resolution to be - * switched on explicitly - */ + * Leopard's DTrace requires symbol resolution to be + * switched on explicitly + */ #ifdef __APPLE__ (void) dtrace_setopt(hdl, "stacksymbols", "enabled"); #endif @@ -105,7 +105,7 @@ int _dtrace_next_probe(dtrace_hdl_t *hdl, const dtrace_probedesc_t *pdp, void *a } /* - * Yields each probe found on the system. + * Yields each probe found on the system. * (equivalent to dtrace -l) * * Each probe is represented by a DtraceProbe object @@ -121,7 +121,7 @@ VALUE dtrace_each_probe_all(VALUE self) } /* - * Yields each probe found on the system, matching against a + * Yields each probe found on the system, matching against a * partial name. * (equivalent to dtrace -l -n 'probe:::spec') * @@ -149,7 +149,7 @@ _dtrace_next_stmt(dtrace_hdl_t *hdl, dtrace_prog_t *program, dtrace_stmtdesc_t *stp, dtrace_ecbdesc_t **last) { dtrace_ecbdesc_t *edp = stp->dtsd_ecbdesc; - + if (edp == *last) return 0; @@ -158,13 +158,13 @@ _dtrace_next_stmt(dtrace_hdl_t *hdl, dtrace_prog_t *program, edp->dted_probe.dtpd_provider, edp->dted_probe.dtpd_mod, edp->dted_probe.dtpd_func, edp->dted_probe.dtpd_name, dtrace_errmsg(hdl, dtrace_errno(hdl))); - + } - + *last = edp; return 0; } - + /* * Yields each probe enabled by the given D program. * (equivalent to dtrace -n -s program.d) @@ -174,16 +174,16 @@ VALUE dtrace_each_probe_prog(VALUE self, VALUE program) dtrace_handle_t *handle; dtrace_prog_t *prog; dtrace_ecbdesc_t *last = NULL; - + Data_Get_Struct(self, dtrace_handle_t, handle); Data_Get_Struct(program, dtrace_prog_t, prog); - + (void) dtrace_stmt_iter(handle->hdl, prog, (dtrace_stmt_f *)_dtrace_next_stmt, &last); return Qnil; -} +} /* - * Compile a D program. + * Compile a D program. * * Arguments: * * The program text to compile @@ -212,7 +212,7 @@ VALUE dtrace_strcompile(int argc, VALUE *argv, VALUE self) rb_raise(eDtraceException, "alloc failed"); return Qnil; } - + for (i = 0; i < dtrace_argc; i++) { dtrace_argv[i + 1] = STR2CSTR(rb_ary_entry(dtrace_argv_array, i)); } @@ -222,7 +222,7 @@ VALUE dtrace_strcompile(int argc, VALUE *argv, VALUE self) Data_Get_Struct(self, dtrace_handle_t, handle); program = dtrace_program_strcompile(handle->hdl, STR2CSTR(dtrace_text), - DTRACE_PROBESPEC_NAME, DTRACE_C_PSPEC, + DTRACE_PROBESPEC_NAME, DTRACE_C_PSPEC, dtrace_argc, dtrace_argv); if (!program) { @@ -239,7 +239,7 @@ VALUE dtrace_strcompile(int argc, VALUE *argv, VALUE self) /* * Start tracing. Must be called once a program has been successfully * compiled and executed. - * + * * Raises a DtraceException on any error. */ VALUE dtrace_hdl_go(VALUE self) @@ -247,17 +247,17 @@ VALUE dtrace_hdl_go(VALUE self) dtrace_handle_t *handle; Data_Get_Struct(self, dtrace_handle_t, handle); - if (dtrace_go(handle->hdl) < 0) + if (dtrace_go(handle->hdl) < 0) rb_raise(eDtraceException, dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl))); - + return Qnil; } -/* +/* * Returns the status of the DTrace handle. * * Status values are defined as: - * + * * * 0 - none * * 1 - ok * * 4 - stopped @@ -268,17 +268,17 @@ VALUE dtrace_hdl_status(VALUE self) int status; Data_Get_Struct(self, dtrace_handle_t, handle); - if ((status = dtrace_status(handle->hdl)) < 0) + if ((status = dtrace_status(handle->hdl)) < 0) rb_raise(eDtraceException, dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl))); - + return INT2FIX(status); } -/* - * Set an option on the DTrace handle. - * +/* + * Set an option on the DTrace handle. + * * Options which may be set: - * + * * * aggsize * * bufsize */ @@ -296,13 +296,13 @@ VALUE dtrace_hdl_setopt(VALUE self, VALUE key, VALUE value) ret = dtrace_setopt(handle->hdl, STR2CSTR(key), STR2CSTR(value)); } - if (ret < 0) + if (ret < 0) rb_raise(eDtraceException, dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl))); - + return Qnil; } -/* Stop tracing. +/* Stop tracing. * * Must be called after go has been called to start tracing. */ @@ -311,13 +311,13 @@ VALUE dtrace_hdl_stop(VALUE self) dtrace_handle_t *handle; Data_Get_Struct(self, dtrace_handle_t, handle); - if (dtrace_stop(handle->hdl) < 0) + if (dtrace_stop(handle->hdl) < 0) rb_raise(eDtraceException, dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl))); - + return Qnil; } -/* +/* * Return the most recent DTrace error. */ VALUE dtrace_hdl_error(VALUE self) @@ -410,7 +410,7 @@ static int _buf_consumer(const dtrace_bufdata_t *bufdata, void *arg) /* * Process any data waiting from the D program. - * + * * Takes a Proc to which DtraceProbeData objects will be yielded, and * an optional second Proc to which DtraceRecDesc objects will be * yielded. @@ -423,7 +423,7 @@ VALUE dtrace_hdl_work(int argc, VALUE *argv, VALUE self) dtrace_work_handlers_t handlers; VALUE probe_consumer; VALUE rec_consumer; - + Data_Get_Struct(self, dtrace_handle_t, handle); /* handle args - probe_consumer_proc is mandatory, rec_consumer_proc @@ -448,7 +448,7 @@ VALUE dtrace_hdl_work(int argc, VALUE *argv, VALUE self) rb_raise(eDtraceException, (dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl)))); return INT2FIX(status); -} +} /* * Set up the buffered output handler for this handle. @@ -463,7 +463,7 @@ VALUE dtrace_hdl_buf_consumer(VALUE self, VALUE buf_consumer) /* attach the buffered output handler */ if (dtrace_handle_buffered(handle->hdl, &_buf_consumer, (void *)buf_consumer) == -1) { - rb_raise(eDtraceException, "failed to establish buffered handler: %s", + rb_raise(eDtraceException, "failed to establish buffered handler: %s", (dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl)))); } @@ -529,7 +529,7 @@ static int _err_consumer(const dtrace_errdata_t *errdata, void *arg) /* * Set up the err-record handler for this handle. Takes a block, which * will be called with any error records returned by DTrace, - * represented by DTraceErrData records. + * represented by DTraceErrData records. */ VALUE dtrace_hdl_err_consumer(VALUE self, VALUE err_consumer) { @@ -541,7 +541,7 @@ VALUE dtrace_hdl_err_consumer(VALUE self, VALUE err_consumer) rb_raise(eDtraceException, "too late to add error handler"); return Qnil; } - + /* to mark during GC */ handle->err = err_consumer; @@ -554,13 +554,13 @@ VALUE dtrace_hdl_err_consumer(VALUE self, VALUE err_consumer) return Qnil; } -/* +/* * Start a process which will be traced. The pid of the started * process will be available in D as $target. - * + * * Pass an array, where the first element is the full path to the * program to start, and subsequent elements are its arguments. - * + * * Returns a DtraceProcess object which is used to start the process * once tracing is set up. */ @@ -590,11 +590,11 @@ VALUE dtrace_hdl_createprocess(VALUE self, VALUE rb_argv) P = dtrace_proc_create(handle->hdl, argv[0], argv); free(argv); - + if (P == NULL) { rb_raise(eDtraceException, dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl))); } - + process = ALLOC(dtrace_process_t); if (!process) { rb_raise(eDtraceException, "alloc failed"); @@ -608,8 +608,8 @@ VALUE dtrace_hdl_createprocess(VALUE self, VALUE rb_argv) return dtraceprocess; } -/* - * Grab a currently-running process by pid. +/* + * Grab a currently-running process by pid. * * Returns a DtraceProcess object which is used to start the process * once tracing is set up. @@ -624,11 +624,11 @@ VALUE dtrace_hdl_grabprocess(VALUE self, VALUE pid) Data_Get_Struct(self, dtrace_handle_t, handle); P = dtrace_proc_grab(handle->hdl, FIX2INT(pid), 0); - + if (P == NULL) { rb_raise(eDtraceException, dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl))); } - + process = ALLOC(dtrace_process_t); if (!process) { rb_raise(eDtraceException, "alloc failed"); diff --git a/ext/dtrace_probedata.c b/ext/dtrace_probedata.c index f461001..de3aed1 100644 --- a/ext/dtrace_probedata.c +++ b/ext/dtrace_probedata.c @@ -46,7 +46,7 @@ static VALUE _handle_stack_record(dtrace_hdl_t *handle, caddr_t addr, const dtra stack = rb_ary_new(); for (i = 0; i < depth; i++) { - + switch (size) { case sizeof (uint32_t): pc = *((uint32_t *)addr); @@ -76,7 +76,7 @@ static VALUE _handle_stack_record(dtrace_hdl_t *handle, caddr_t addr, const dtra (void) snprintf(c, sizeof (c), "%s`%s", dts.dts_object, dts.dts_name); } - } + } else { if (dtrace_lookup_by_addr(handle, pc, NULL, &dts) == 0) { (void) snprintf(c, sizeof (c), "%s`0x%llx", @@ -104,8 +104,8 @@ VALUE dtraceprobedata_epid(VALUE self) return INT2FIX(data->dtpda_edesc->dtepd_epid); } -/* - * Returns the DtraceProbe for the probe which generated this data +/* + * Returns the DtraceProbe for the probe which generated this data */ VALUE dtraceprobedata_probe(VALUE self) { @@ -131,7 +131,7 @@ VALUE dtraceprobedata_cpu(VALUE self) processorid_t cpu; Data_Get_Struct(self, dtrace_probedata_t, data); - + if (data) { cpu = data->dtpda_cpu; return INT2FIX(cpu); @@ -167,7 +167,7 @@ VALUE dtraceprobedata_prefix(VALUE self) Data_Get_Struct(self, dtrace_probedata_t, data); prefix = data->dtpda_prefix; - if (prefix) + if (prefix) return rb_str_new2(prefix); else return Qnil; @@ -192,7 +192,7 @@ VALUE dtraceprobedata_flow(VALUE self) } } -/* +/* * Yields each record in this DtraceProbedata in turn. Records are * yielded as either DtraceRecords or DtraceStackRecords as * appropriate for the type of action. @@ -215,14 +215,14 @@ VALUE dtraceprobedata_each_record(VALUE self) Data_Get_Struct(dtrace, dtrace_handle_t, handle); eprobe = data->dtpda_edesc; - + for (i = 0; i < eprobe->dtepd_nrecs; i++) { v = 0; rec = &eprobe->dtepd_rec[i]; if (rec->dtrd_size > 0) { act = rec->dtrd_action; addr = data->dtpda_data + rec->dtrd_offset; - + switch (act) { case DTRACEACT_STACK: case DTRACEACT_USTACK: @@ -253,7 +253,7 @@ VALUE dtraceprobedata_each_record(VALUE self) break; } } - + if (v) { dtracerecord = rb_class_new_instance(0, NULL, rb_path2class("Dtrace::Record")); rb_iv_set(dtracerecord, "@value", v); diff --git a/ext/dtrace_program.c b/ext/dtrace_program.c index a7313b8..fde8e86 100644 --- a/ext/dtrace_program.c +++ b/ext/dtrace_program.c @@ -32,7 +32,7 @@ VALUE dtraceprogram_exec(VALUE self) Data_Get_Struct(self, dtrace_prog_t, prog); dtrace = rb_iv_get(self, "@handle"); Data_Get_Struct(dtrace, dtrace_handle_t, handle); - + proginfo = ALLOC(dtrace_proginfo_t); if (!proginfo) { rb_raise(eDtraceException, "alloc failed"); @@ -48,7 +48,7 @@ VALUE dtraceprogram_exec(VALUE self) if (ret < 0) rb_raise(eDtraceException, dtrace_errmsg(handle->hdl, dtrace_errno(handle->hdl))); - + return Qnil; } diff --git a/ext/dtrace_programinfo.c b/ext/dtrace_programinfo.c index 24b99b4..9873813 100644 --- a/ext/dtrace_programinfo.c +++ b/ext/dtrace_programinfo.c @@ -16,7 +16,7 @@ VALUE dtraceprograminfo_init(VALUE self) /* * Returns the number of aggregates associated with this program. */ -VALUE dtraceprograminfo_aggregates_count(VALUE self) +VALUE dtraceprograminfo_aggregates_count(VALUE self) { dtrace_proginfo_t *proginfo; diff --git a/ext/dtrace_recdesc.c b/ext/dtrace_recdesc.c index 782cc0e..3f21222 100644 --- a/ext/dtrace_recdesc.c +++ b/ext/dtrace_recdesc.c @@ -13,7 +13,7 @@ VALUE dtracerecdesc_init(VALUE self) return self; } -/* +/* * Returns the type of action which generated this recdesc. * (exit, printf, printa or "other" for all other actions). */ diff --git a/ext/dtrace_util.c b/ext/dtrace_util.c index 3cd4efc..c4fbca9 100644 --- a/ext/dtrace_util.c +++ b/ext/dtrace_util.c @@ -89,4 +89,4 @@ VALUE handle_bytedata(caddr_t addr, uint32_t nbytes) rb_ary_push(robj, INT2FIX(addr[i])); return (robj); -} +} diff --git a/ext/extconf.rb b/ext/extconf.rb index 7dee554..696b11c 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -54,7 +54,7 @@ begin mfile = open("Makefile", "ab") mfile.puts - + if apple_universal # create i386 .o and x86_64.o mfile.print "dtrace_probe_i386-darwin.o:\n\t$(CC) $(INCFLAGS) -arch i386 -o dtrace_probe_i386-darwin.o -c i386-darwin/dtrace_probe.c\n\n" diff --git a/ext/i386-darwin/dtrace_probe.c b/ext/i386-darwin/dtrace_probe.c index 94046ef..38618f4 100644 --- a/ext/i386-darwin/dtrace_probe.c +++ b/ext/i386-darwin/dtrace_probe.c @@ -15,7 +15,7 @@ RUBY_EXTERN VALUE eDtraceException; #define IS_ENABLED_FUNC_LEN 32 /* :nodoc: */ -VALUE +VALUE dtraceprobe_init(VALUE self, VALUE rargc) { dtrace_probe_t *probe; @@ -79,7 +79,7 @@ dtraceprobe_init(VALUE self, VALUE rargc) /* mov 0xN(%ebp),%eax */ *ip++ = OP_MOVL_EAX_U; *ip++ = OP_MOVL_EAX_L; - *ip++ = i + 8; + *ip++ = i + 8; /* mov %eax,N(%esp) */ *ip++ = OP_MOVL_ESP; if (i > 0) { @@ -92,7 +92,7 @@ dtraceprobe_init(VALUE self, VALUE rargc) *ip++ = 0x24; } } - + /* tracepoint */ *ip++ = 0x90; *ip++ = 0x0f; @@ -110,30 +110,30 @@ dtraceprobe_init(VALUE self, VALUE rargc) rb_raise(eDtraceException, "malloc failed: %s\n", strerror(errno)); return Qnil; } - + if ((mprotect((void *)probe->func, FUNC_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC)) < 0) { rb_raise(eDtraceException, "mprotect failed: %s\n", strerror(errno)); return Qnil; } - + if ((memcpy(probe->func, insns, FUNC_SIZE)) < 0) { rb_raise(eDtraceException, "memcpy failed: %s\n", strerror(errno)); return Qnil; - } - + } + return self; } VALUE dtraceprobe_free(void *arg) { dtrace_probe_t *probe = (dtrace_probe_t *)arg; - + if (probe) { free(probe->func); free(probe); } } - + VALUE dtraceprobe_alloc(VALUE klass) { VALUE obj; @@ -156,7 +156,7 @@ VALUE dtraceprobe_alloc(VALUE klass) VALUE dtraceprobe_addr(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return INT2FIX(probe->func); } @@ -168,7 +168,7 @@ VALUE dtraceprobe_addr(VALUE self) VALUE dtraceprobe_is_enabled(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return ((int)(*probe->func)()) ? Qtrue : Qfalse; } @@ -199,7 +199,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { break; } } - + func = (void (*)())(probe->func + IS_ENABLED_FUNC_LEN); switch (argc) { @@ -219,7 +219,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { (void)(*func)(argv[0], argv[1], argv[2], argv[3]); break; case 5: - (void)(*func)(argv[0], argv[1], argv[2], argv[3], + (void)(*func)(argv[0], argv[1], argv[2], argv[3], argv[4]); break; case 6: @@ -238,11 +238,11 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { rb_raise(eDtraceException, "probe argc max is 8"); break; } - + return Qnil; } -/* +/* * Returns the offset for this probe in the PROFFS section, based on * the location of the DOF, and the location of this probe. */ @@ -265,7 +265,7 @@ VALUE dtraceprobe_probe_offset(VALUE self, VALUE file_addr, VALUE argc) return INT2FIX((uint32_t)probe_addr - (uint32_t)FIX2UINT(file_addr) + offset); } -/* +/* * Returns the offset for this probe's is-enabled tracepoint in the * PRENOFFS section, based on the location of the DOF, and the * location of this probe. diff --git a/ext/i386-solaris/dtrace_probe.c b/ext/i386-solaris/dtrace_probe.c index 24bfda5..f00f05c 100644 --- a/ext/i386-solaris/dtrace_probe.c +++ b/ext/i386-solaris/dtrace_probe.c @@ -32,7 +32,7 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) 0x89, 0x45, 0xfc, 0x83, 0x7d, 0xfc, 0x00, 0x0f, 0x95, 0xc0, 0x0f, 0xb6, 0xc0, 0x89, 0x45, 0xfc, 0x8b, 0x45, - 0xfc, + 0xfc, 0xc9, 0xc3 }; @@ -54,11 +54,11 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) OP_PUSHL_EBP, OP_MOVL_ESP_EBP, OP_SUBL_N_ESP, 0x08, NULL }; - + uint8_t func_out[3] = { OP_LEAVE, OP_RET, NULL }; - + for (i = 0; func_in[i]; i++) *ip++ = func_in[i]; @@ -74,7 +74,7 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) *ip++ = OP_ADDL_ESP_U; *ip++ = OP_ADDL_ESP_L; *ip++ = argc * 4; - + for (i = 0; func_out[i]; i++) *ip++ = func_out[i]; @@ -84,29 +84,29 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) rb_raise(eDtraceException, "malloc failed: %s\n", strerror(errno)); return Qnil; } - + if ((mprotect((void *)probe->func, FUNC_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC)) < 0) { rb_raise(eDtraceException, "mprotect failed: %s\n", strerror(errno)); return Qnil; } - + if ((memcpy(probe->func, insns, FUNC_SIZE)) < 0) { rb_raise(eDtraceException, "memcpy failed: %s\n", strerror(errno)); return Qnil; - } - + } + return self; } VALUE dtraceprobe_free(void *arg) { dtrace_probe_t *probe = (dtrace_probe_t *)arg; - + if (probe) { free(probe); } } - + VALUE dtraceprobe_alloc(VALUE klass) { VALUE obj; @@ -126,7 +126,7 @@ VALUE dtraceprobe_alloc(VALUE klass) VALUE dtraceprobe_addr(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return INT2FIX(probe->func); } @@ -134,7 +134,7 @@ VALUE dtraceprobe_addr(VALUE self) VALUE dtraceprobe_is_enabled(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return ((int)(*probe->func)()) ? Qtrue : Qfalse; } @@ -161,7 +161,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { break; } } - + func = (void (*)())(probe->func + IS_ENABLED_FUNC_LEN); switch (argc) { @@ -181,7 +181,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { (void)(*func)(argv[0], argv[1], argv[2], argv[3]); break; case 5: - (void)(*func)(argv[0], argv[1], argv[2], argv[3], + (void)(*func)(argv[0], argv[1], argv[2], argv[3], argv[4]); break; case 6: @@ -200,7 +200,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { rb_raise(eDtraceException, "probe argc max is 8"); break; } - + return Qnil; } diff --git a/ext/powerpc-darwin/dtrace_probe.c b/ext/powerpc-darwin/dtrace_probe.c index c3e9334..20c4f60 100644 --- a/ext/powerpc-darwin/dtrace_probe.c +++ b/ext/powerpc-darwin/dtrace_probe.c @@ -39,19 +39,19 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* First initialise the is_enabled tracepoint */ uint8_t insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ - 0x7c, 0x3e, 0x0b, 0x78, + 0x7c, 0x3e, 0x0b, 0x78, /* li r0,0x0 */ 0x38, 0x00, 0x00, 0x00, /* or r3,r0,r0 */ - 0x7c, 0x03, 0x03, 0x78, + 0x7c, 0x03, 0x03, 0x78, /* lwz r1,0x0(r1) */ - 0x80, 0x21, 0x00, 0x00, + 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ 0x4e, 0x80, 0x00, 0x20 }; @@ -63,17 +63,17 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ - 0x7c, 0x3e, 0x0b, 0x78, + 0x7c, 0x3e, 0x0b, 0x78, /* lwz r1,0x0(r1) */ 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ - 0x4e, 0x80, 0x00, 0x20 + 0x4e, 0x80, 0x00, 0x20 }; install_insns(probe_insns, &insns[IS_ENABLED_FUNC_LEN], 6); } @@ -83,15 +83,15 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ 0x7c, 0x3e, 0x0b, 0x78, /* stw r3,0x48(r30) */ - 0x90, 0x7e, 0x00, 0x48, + 0x90, 0x7e, 0x00, 0x48, /* lwz r1,0x0(r1) */ - 0x80, 0x21, 0x00, 0x00, + 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ 0xbb, 0xc1, 0xff, 0xf8, /* blr */ @@ -105,19 +105,19 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ - 0x7c, 0x3e, 0x0b, 0x78, + 0x7c, 0x3e, 0x0b, 0x78, /* stw r3,0x48(r30) */ - 0x90, 0x7e, 0x00, 0x48, + 0x90, 0x7e, 0x00, 0x48, /* stw r4,0x4c(r30) */ - 0x90, 0x9e, 0x00, 0x4c, + 0x90, 0x9e, 0x00, 0x4c, /* lwz r1,0x0(r1) */ - 0x80, 0x21, 0x00, 0x00, + 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ 0x4e, 0x80, 0x00, 0x20 }; @@ -129,21 +129,21 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ 0x7c, 0x3e, 0x0b, 0x78, /* stw r3,0x48(r30) */ - 0x90, 0x7e, 0x00, 0x48, + 0x90, 0x7e, 0x00, 0x48, /* stw r4,0x4c(r30) */ - 0x90, 0x9e, 0x00, 0x4c, + 0x90, 0x9e, 0x00, 0x4c, /* stw r5,0x50(r30) */ - 0x90, 0xbe, 0x00, 0x50, + 0x90, 0xbe, 0x00, 0x50, /* lwz r1,0x0(r1) */ 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ 0x4e, 0x80, 0x00, 0x20 }; @@ -155,23 +155,23 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ 0x7c, 0x3e, 0x0b, 0x78, /* stw r3,0x48(r30) */ - 0x90, 0x7e, 0x00, 0x48, + 0x90, 0x7e, 0x00, 0x48, /* stw r4,0x4c(r30) */ - 0x90, 0x9e, 0x00, 0x4c, + 0x90, 0x9e, 0x00, 0x4c, /* stw r5,0x50(r30) */ - 0x90, 0xbe, 0x00, 0x50, + 0x90, 0xbe, 0x00, 0x50, /* stw r5,0x50(r30) */ 0x90, 0xde, 0x00, 0x54, /* lwz r1,0x0(r1) */ 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ 0x4e, 0x80, 0x00, 0x20 }; @@ -181,19 +181,19 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) case 5: { - uint8_t probe_insns[FUNC_SIZE] = { + uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ 0x7c, 0x3e, 0x0b, 0x78, /* stw r3,0x48(r30) */ - 0x90, 0x7e, 0x00, 0x48, + 0x90, 0x7e, 0x00, 0x48, /* stw r4,0x4c(r30) */ - 0x90, 0x9e, 0x00, 0x4c, + 0x90, 0x9e, 0x00, 0x4c, /* stw r5,0x50(r30) */ - 0x90, 0xbe, 0x00, 0x50, + 0x90, 0xbe, 0x00, 0x50, /* stw r6,0x54(r30) */ 0x90, 0xde, 0x00, 0x54, /* stw r7,0x58(r30) */ @@ -201,7 +201,7 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* lwz r1,0x0(r1) */ 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ 0x4e, 0x80, 0x00, 0x20 }; @@ -213,17 +213,17 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ 0x7c, 0x3e, 0x0b, 0x78, /* stw r3,0x48(r30) */ - 0x90, 0x7e, 0x00, 0x48, + 0x90, 0x7e, 0x00, 0x48, /* stw r4,0x4c(r30) */ - 0x90, 0x9e, 0x00, 0x4c, + 0x90, 0x9e, 0x00, 0x4c, /* stw r5,0x50(r30) */ - 0x90, 0xbe, 0x00, 0x50, + 0x90, 0xbe, 0x00, 0x50, /* stw r6,0x54(r30) */ 0x90, 0xde, 0x00, 0x54, /* stw r7,0x58(r30) */ @@ -233,7 +233,7 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* lwz r1,0x0(r1) */ 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ 0x4e, 0x80, 0x00, 0x20 }; @@ -245,17 +245,17 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ 0x7c, 0x3e, 0x0b, 0x78, /* stw r3,0x48(r30) */ - 0x90, 0x7e, 0x00, 0x48, + 0x90, 0x7e, 0x00, 0x48, /* stw r4,0x4c(r30) */ - 0x90, 0x9e, 0x00, 0x4c, + 0x90, 0x9e, 0x00, 0x4c, /* stw r5,0x50(r30) */ - 0x90, 0xbe, 0x00, 0x50, + 0x90, 0xbe, 0x00, 0x50, /* stw r6,0x54(r30) */ 0x90, 0xde, 0x00, 0x54, /* stw r7,0x58(r30) */ @@ -263,11 +263,11 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* stw r8,0x5c(r30) */ 0x91, 0x1e, 0x00, 0x5c, /* stw r9,0x60(r30) */ - 0x91, 0x3e, 0x00, 0x60, + 0x91, 0x3e, 0x00, 0x60, /* lwz r1,0x0(r1) */ 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ 0x4e, 0x80, 0x00, 0x20 }; @@ -279,17 +279,17 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* stmw r30,0xfff8(r1) */ - 0xbf, 0xc1, 0xff, 0xf8, + 0xbf, 0xc1, 0xff, 0xf8, /* stwu r1,0xffd0(r1) */ - 0x94, 0x21, 0xff, 0xd0, + 0x94, 0x21, 0xff, 0xd0, /* or r30,r1,r1 */ 0x7c, 0x3e, 0x0b, 0x78, /* stw r3,0x48(r30) */ - 0x90, 0x7e, 0x00, 0x48, + 0x90, 0x7e, 0x00, 0x48, /* stw r4,0x4c(r30) */ - 0x90, 0x9e, 0x00, 0x4c, + 0x90, 0x9e, 0x00, 0x4c, /* stw r5,0x50(r30) */ - 0x90, 0xbe, 0x00, 0x50, + 0x90, 0xbe, 0x00, 0x50, /* stw r6,0x54(r30) */ 0x90, 0xde, 0x00, 0x54, /* stw r7,0x58(r30) */ @@ -297,13 +297,13 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* stw r8,0x5c(r30) */ 0x91, 0x1e, 0x00, 0x5c, /* stw r9,0x60(r30) */ - 0x91, 0x3e, 0x00, 0x60, + 0x91, 0x3e, 0x00, 0x60, /* stw r10,0x64(r30) */ 0x91, 0x5e, 0x00, 0x64, /* lwz r1,0x0(r1) */ 0x80, 0x21, 0x00, 0x00, /* lmw r30,0xfff8(r1) */ - 0xbb, 0xc1, 0xff, 0xf8, + 0xbb, 0xc1, 0xff, 0xf8, /* blr */ 0x4e, 0x80, 0x00, 0x20 }; @@ -323,29 +323,29 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) rb_raise(eDtraceException, "malloc failed: %s\n", strerror(errno)); return Qnil; } - + if ((mprotect((void *)probe->func, FUNC_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC)) < 0) { rb_raise(eDtraceException, "mprotect failed: %s\n", strerror(errno)); return Qnil; } - + if ((memcpy(probe->func, insns, FUNC_SIZE)) < 0) { rb_raise(eDtraceException, "memcpy failed: %s\n", strerror(errno)); return Qnil; - } - + } + return self; } VALUE dtraceprobe_free(void *arg) { dtrace_probe_t *probe = (dtrace_probe_t *)arg; - + if (probe) { free(probe); } } - + VALUE dtraceprobe_alloc(VALUE klass) { VALUE obj; @@ -365,7 +365,7 @@ VALUE dtraceprobe_alloc(VALUE klass) VALUE dtraceprobe_addr(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return INT2FIX(probe->func); } @@ -373,7 +373,7 @@ VALUE dtraceprobe_addr(VALUE self) VALUE dtraceprobe_is_enabled(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return ((int)(*probe->func)()) ? Qtrue : Qfalse; } @@ -400,7 +400,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { break; } } - + func = (void (*)())(probe->func + IS_ENABLED_FUNC_LEN); switch (argc) { @@ -420,7 +420,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { (void)(*func)(argv[0], argv[1], argv[2], argv[3]); break; case 5: - (void)(*func)(argv[0], argv[1], argv[2], argv[3], + (void)(*func)(argv[0], argv[1], argv[2], argv[3], argv[4]); break; case 6: @@ -439,12 +439,12 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { rb_raise(eDtraceException, "probe argc max is 8"); break; } - + return Qnil; } -/* +/* * Returns the offset for this probe in the PROFFS section, based on * the location of the DOF, and the location of this probe. */ @@ -457,7 +457,7 @@ VALUE dtraceprobe_probe_offset(VALUE self, VALUE file_addr, VALUE argc) return INT2FIX((int)probe_addr - (int)FIX2INT(file_addr) + offset); } -/* +/* * Returns the offset for this probe's is-enabled tracepoint in the * PRENOFFS section, based on the location of the DOF, and the * location of this probe. diff --git a/ext/sparc-solaris/dtrace_probe.c b/ext/sparc-solaris/dtrace_probe.c index a9139a2..595dc22 100644 --- a/ext/sparc-solaris/dtrace_probe.c +++ b/ext/sparc-solaris/dtrace_probe.c @@ -39,9 +39,9 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* First initialise the is_enabled tracepoint */ uint8_t insns[FUNC_SIZE] = { /* save %sp, -104, %sp */ - 0x9d, 0xe3, 0xbf, 0x98, + 0x9d, 0xe3, 0xbf, 0x98, /* nop */ - 0x01, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, /* clr %o0 */ 0x90, 0x10, 0x00, 0x00, /* ba 0x11c */ @@ -53,13 +53,13 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* or %l0, %g0, %i0 */ 0xb0, 0x14, 0x00, 0x00, /* ret */ - 0x81, 0xc7, 0xe0, 0x08, + 0x81, 0xc7, 0xe0, 0x08, /* restore */ 0x81, 0xe8, 0x00, 0x00, - - 0x00, 0x01, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, + + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, }; /* Now build probe tracepoint */ @@ -69,13 +69,13 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* save %sp, -96, %sp */ - 0x9d, 0xe3, 0xbf, 0x90, + 0x9d, 0xe3, 0xbf, 0x90, /* nop */ - 0x01, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, /* nop */ - 0x01, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, /* ret */ - 0x81, 0xc7, 0xe0, 0x08, + 0x81, 0xc7, 0xe0, 0x08, /* restore */ 0x81, 0xe8, 0x00, 0x00, }; @@ -87,13 +87,13 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) { uint8_t probe_insns[FUNC_SIZE] = { /* save %sp, -96, %sp */ - 0x9d, 0xe3, 0xbf, 0xa0, + 0x9d, 0xe3, 0xbf, 0xa0, /* st %i0, [%fp + 68] */ 0xf0, 0x27, 0xa0, 0x44, /* ld [%fp + 68], %l0 */ 0xe0, 0x07, 0xa0, 0x44, /* nop */ - 0x01, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, /* or %l0, %g0, %o0 */ 0x90, 0x14, 0x00, 0x00, /* ret */ @@ -427,7 +427,7 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* ret */ 0x81, 0xc7, 0xe0, 0x08, /* restore */ - 0x81, 0xe8, 0x00, 0x00, + 0x81, 0xe8, 0x00, 0x00, }; install_insns(probe_insns, &insns[IS_ENABLED_FUNC_LEN], 32); } @@ -445,29 +445,29 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) rb_raise(eDtraceException, "malloc failed: %s\n", strerror(errno)); return Qnil; } - + if ((mprotect((void *)probe->func, FUNC_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC)) < 0) { rb_raise(eDtraceException, "mprotect failed: %s\n", strerror(errno)); return Qnil; } - + if ((memcpy(probe->func, insns, FUNC_SIZE)) < 0) { rb_raise(eDtraceException, "memcpy failed: %s\n", strerror(errno)); return Qnil; - } - + } + return self; } VALUE dtraceprobe_free(void *arg) { dtrace_probe_t *probe = (dtrace_probe_t *)arg; - + if (probe) { free(probe); } } - + VALUE dtraceprobe_alloc(VALUE klass) { VALUE obj; @@ -487,7 +487,7 @@ VALUE dtraceprobe_alloc(VALUE klass) VALUE dtraceprobe_addr(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return INT2FIX(probe->func); } @@ -495,7 +495,7 @@ VALUE dtraceprobe_addr(VALUE self) VALUE dtraceprobe_is_enabled(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return ((int)(*probe->func)()) ? Qtrue : Qfalse; } @@ -522,7 +522,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { break; } } - + func = (void (*)())(probe->func + IS_ENABLED_FUNC_LEN); switch (argc) { @@ -542,7 +542,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { (void)(*func)(argv[0], argv[1], argv[2], argv[3]); break; case 5: - (void)(*func)(argv[0], argv[1], argv[2], argv[3], + (void)(*func)(argv[0], argv[1], argv[2], argv[3], argv[4]); break; case 6: @@ -561,7 +561,7 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { rb_raise(eDtraceException, "probe argc max is 8"); break; } - + return Qnil; } diff --git a/ext/stubs.txt b/ext/stubs.txt index ba03eac..b20206d 100644 --- a/ext/stubs.txt +++ b/ext/stubs.txt @@ -58,9 +58,9 @@ disassembly of is_enabled function: [21] 805142d: subl $8,%esp 22. return TEST_TEST_PROBE_ENABLED() ? 1 : 0; [22] 8051430: xorl %eax,%eax - [22] 8051432: nop - [22] 8051433: nop - [22] 8051434: nop + [22] 8051432: nop + [22] 8051433: nop + [22] 8051434: nop [22] 8051435: movl %eax,-4(%ebp) [22] 8051438: cmpl $0,-4(%ebp) [22] 805143c: setne %al @@ -68,8 +68,8 @@ disassembly of is_enabled function: [22] 8051442: movl %eax,-4(%ebp) [22] 8051445: movl -4(%ebp),%eax 23. } - [23] 8051448: leave - [23] 8051449: ret + [23] 8051448: leave + [23] 8051449: ret Binary: diff --git a/ext/x86_64-darwin/dtrace_probe.c b/ext/x86_64-darwin/dtrace_probe.c index 52ef35e..7fb3798 100644 --- a/ext/x86_64-darwin/dtrace_probe.c +++ b/ext/x86_64-darwin/dtrace_probe.c @@ -39,17 +39,17 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) /* First initialise the is_enabled tracepoint */ uint8_t insns[FUNC_SIZE] = { - 0x55, 0x48, 0x89, 0xe5, - 0x48, 0x33, 0xc0, 0x90, + 0x55, 0x48, 0x89, 0xe5, + 0x48, 0x33, 0xc0, 0x90, 0x90, 0xc9, 0xc3, 0x00 }; if (argc <= ARGC_MAX) { { uint8_t probe_insns[FUNC_SIZE] = { - 0x55, 0x48, 0x89, 0xe5, - 0x90, 0x0f, 0x1f, 0x40, - 0x00, 0xc9, 0xc3, 0x0f, + 0x55, 0x48, 0x89, 0xe5, + 0x90, 0x0f, 0x1f, 0x40, + 0x00, 0xc9, 0xc3, 0x0f, 0x1f, 0x44, 0x00, 0x00 }; install_insns(probe_insns, &insns[IS_ENABLED_FUNC_LEN], 4); @@ -66,30 +66,30 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) rb_raise(eDtraceException, "malloc failed: %s\n", strerror(errno)); return Qnil; } - + if ((mprotect((void *)probe->func, FUNC_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC)) < 0) { rb_raise(eDtraceException, "mprotect failed: %s\n", strerror(errno)); return Qnil; } - + if ((memcpy(probe->func, insns, FUNC_SIZE)) < 0) { rb_raise(eDtraceException, "memcpy failed: %s\n", strerror(errno)); return Qnil; - } - + } + return self; } VALUE dtraceprobe_free(void *arg) { dtrace_probe_t *probe = (dtrace_probe_t *)arg; - + if (probe) { free(probe->func); free(probe); } } - + VALUE dtraceprobe_alloc(VALUE klass) { VALUE obj; @@ -109,7 +109,7 @@ VALUE dtraceprobe_alloc(VALUE klass) VALUE dtraceprobe_addr(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return LL2NUM((uint64_t)(probe->func)); } @@ -117,7 +117,7 @@ VALUE dtraceprobe_addr(VALUE self) VALUE dtraceprobe_is_enabled(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return ((int)(*probe->func)()) ? Qtrue : Qfalse; } @@ -144,14 +144,14 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { break; } } - + func = (void (*)())(probe->func + IS_ENABLED_FUNC_LEN); (void)(*func)(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); - + return Qnil; } -/* +/* * Returns the offset for this probe in the PROFFS section, based on * the location of the DOF, and the location of this probe. */ @@ -164,7 +164,7 @@ VALUE dtraceprobe_probe_offset(VALUE self, VALUE file_addr, VALUE argc) return INT2FIX((uint64_t)probe_addr - (uint64_t)NUM2LL(file_addr) + offset); } -/* +/* * Returns the offset for this probe's is-enabled tracepoint in the * PRENOFFS section, based on the location of the DOF, and the * location of this probe. diff --git a/ext/x86_64-solaris/dtrace_probe.c b/ext/x86_64-solaris/dtrace_probe.c index 7b1b158..c395bc0 100644 --- a/ext/x86_64-solaris/dtrace_probe.c +++ b/ext/x86_64-solaris/dtrace_probe.c @@ -63,30 +63,30 @@ VALUE dtraceprobe_init(VALUE self, VALUE rargc) rb_raise(eDtraceException, "malloc failed: %s\n", strerror(errno)); return Qnil; } - + if ((mprotect((void *)probe->func, FUNC_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC)) < 0) { rb_raise(eDtraceException, "mprotect failed: %s\n", strerror(errno)); return Qnil; } - + if ((memcpy(probe->func, insns, FUNC_SIZE)) < 0) { rb_raise(eDtraceException, "memcpy failed: %s\n", strerror(errno)); return Qnil; - } - + } + return self; } VALUE dtraceprobe_free(void *arg) { dtrace_probe_t *probe = (dtrace_probe_t *)arg; - + if (probe) { free(probe->func); free(probe); } } - + VALUE dtraceprobe_alloc(VALUE klass) { VALUE obj; @@ -106,7 +106,7 @@ VALUE dtraceprobe_alloc(VALUE klass) VALUE dtraceprobe_addr(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return LL2NUM((uint64_t)(probe->func)); } @@ -114,7 +114,7 @@ VALUE dtraceprobe_addr(VALUE self) VALUE dtraceprobe_is_enabled(VALUE self) { dtrace_probe_t *probe; - + Data_Get_Struct(self, dtrace_probe_t, probe); return ((int)(*probe->func)()) ? Qtrue : Qfalse; } @@ -141,10 +141,10 @@ VALUE dtraceprobe_fire(int argc, VALUE *ruby_argv, VALUE self) { break; } } - + func = (void (*)())(probe->func + IS_ENABLED_FUNC_LEN); (void)(*func)(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); - + return Qnil; } diff --git a/lib/dtrace.rb b/lib/dtrace.rb index c44e29b..83f8a40 100644 --- a/lib/dtrace.rb +++ b/lib/dtrace.rb @@ -73,7 +73,7 @@ class Dtrace # Yields each probe on the system, optionally matching against a # probe specification: - # + # # e.g. # syscall::: -> all probes in the syscall provider # pid123:::return -> all return probes in pid 123. diff --git a/lib/dtrace/aggregate.rb b/lib/dtrace/aggregate.rb index 54e0420..6264247 100644 --- a/lib/dtrace/aggregate.rb +++ b/lib/dtrace/aggregate.rb @@ -20,7 +20,7 @@ class Aggregate def initialize @tuple = Array.new end - + # Add a Dtrace::AggData record to this aggregate. Returns nil until it # receives a record of aggtype "last", when it returns the complete # Dtrace::Aggregate. diff --git a/lib/dtrace/aggregateset.rb b/lib/dtrace/aggregateset.rb index e515d89..fefa00c 100644 --- a/lib/dtrace/aggregateset.rb +++ b/lib/dtrace/aggregateset.rb @@ -10,10 +10,10 @@ class AggregateSet def initialize @data = Array.new end - + def add_aggregate(agg) @data << agg end - + end end diff --git a/lib/dtrace/consumer.rb b/lib/dtrace/consumer.rb index a4a87a4..dd155a6 100644 --- a/lib/dtrace/consumer.rb +++ b/lib/dtrace/consumer.rb @@ -5,7 +5,7 @@ # A Dtrace::Consumer provides access to the data produced by the running # D program. Having compiled and executed a D program, you typically -# create a Dtrace::Consumer, and wait for data. +# create a Dtrace::Consumer, and wait for data. # # You can either wait indefinitely for data, or consume all the data # waiting and then stop: if your D program consists of only of @@ -28,7 +28,7 @@ # progtext = "..." # prog = t.compile progtext # prog.execute -# t.go +# t.go # c = Dtrace::Consumer.new(t) # c.consume_once do |d| # # handle Dtrace::Data objects @@ -61,11 +61,11 @@ def initialize(t) # data in the @curr Dtrace::Data based on this: # # Dtrace::ProbeData (initial callback for a probe firing) - # Dtrace::RecDesc + # Dtrace::RecDesc # ... # Dtrace::RecDesc = nil (end of data) # - + def rec_consumer(block) proc do |rec| if rec @@ -77,7 +77,7 @@ def rec_consumer(block) end end end - + def probe_consumer proc do |probe| @curr.add_probedata(probe) @@ -94,7 +94,7 @@ def filter_types(types) @types = types @curr = Dtrace::Data.new(types) end - + public # Provide a proc which will be executed when a drop record is @@ -119,12 +119,12 @@ def errhandler(&block) end) end - # Signals that the client wishes to stop consuming trace data. + # Signals that the client wishes to stop consuming trace data. def finish @t.stop @done = true end - + # Waits for data from the D program, and yields the records returned # to the block given. Returns when the D program exits. # @@ -152,7 +152,7 @@ def consume(*types, &block) @t.work(probe_consumer) end end - + # Yields the data waiting from the current program, then returns. # # Pass a list of classes to restrict the types of data returned, @@ -169,6 +169,6 @@ def consume_once(*types, &block) @t.stop @t.work(probe_consumer, rec_consumer(block)) end - + end end diff --git a/lib/dtrace/data.rb b/lib/dtrace/data.rb index ec4880b..dde7d66 100644 --- a/lib/dtrace/data.rb +++ b/lib/dtrace/data.rb @@ -52,7 +52,7 @@ def add_probedata(probedata) @prefix = probedata.prefix @flow = probedata.flow end - + def add_bufdata(buf) r = buf.record # buf records can be empty (trace();) @@ -77,6 +77,6 @@ def add_bufdata(buf) end end end - + end end diff --git a/lib/dtrace/dof/file.rb b/lib/dtrace/dof/file.rb index 6048270..416f849 100644 --- a/lib/dtrace/dof/file.rb +++ b/lib/dtrace/dof/file.rb @@ -23,7 +23,7 @@ def generate if s.section_type == DOF_SECT_PRENOFFS dof_version = 2 end - + length = s.generate s.offset = filesz @@ -43,17 +43,17 @@ def generate filesz += (s.size + pad) end - + hdr.loadsz = loadsz hdr.filesz = filesz hdr.dof_version = dof_version self << hdr.generate - + @sections.each do |s| self << s.generate_header end - + @sections.each do |s| self << s.pad if s.pad self << s.dof @@ -61,4 +61,4 @@ def generate end end - + diff --git a/lib/dtrace/dof/section.rb b/lib/dtrace/dof/section.rb index b864ce5..2a41d92 100644 --- a/lib/dtrace/dof/section.rb +++ b/lib/dtrace/dof/section.rb @@ -10,7 +10,7 @@ class Dtrace::Dof::Section attr_writer :entsize attr_accessor :flags, :data, :offset, :align, :pad, :size attr_reader :section_type, :dof - + def initialize(type, index) @section_type = type @index = index @@ -55,7 +55,7 @@ def generate end @entsize = compute_entsize - + return @dof.length end diff --git a/lib/dtrace/dof/section/strtab.rb b/lib/dtrace/dof/section/strtab.rb index 7516890..5339a9e 100644 --- a/lib/dtrace/dof/section/strtab.rb +++ b/lib/dtrace/dof/section/strtab.rb @@ -22,7 +22,7 @@ def length return @idx end - def compute_entsize + def compute_entsize 0 end end diff --git a/lib/dtrace/printfrecord.rb b/lib/dtrace/printfrecord.rb index dbf2d36..4b79801 100644 --- a/lib/dtrace/printfrecord.rb +++ b/lib/dtrace/printfrecord.rb @@ -2,7 +2,7 @@ # Ruby-Dtrace # (c) 2007 Chris Andrews # -# A DTrace record for the formatted part of a printf() action. +# A DTrace record for the formatted part of a printf() action. class Dtrace class PrintfRecord attr_accessor :value diff --git a/lib/dtrace/probe.rb b/lib/dtrace/probe.rb index 0a47245..e4b628b 100644 --- a/lib/dtrace/probe.rb +++ b/lib/dtrace/probe.rb @@ -4,12 +4,12 @@ class Dtrace # Using dynamically created USDT probes in Ruby programs. - # + # # Having created the following probes with Dtrace::Provider: # # 74777 action_controller12297 action_controller.so process_finish process-finish # 74778 action_controller12297 action_controller.so process_start process-start - # + # # you can fire them with the following Ruby statements: # # Dtrace::Probe::ActionController.process_start do |p| @@ -17,22 +17,22 @@ class Dtrace # end # # Note that the generated class corresponding to the provider is - # simply the provider class, camelized. + # simply the provider class, camelized. # # The generated method corresponding to the probe name (with - # replaced by _) yields a probe object, on which you can call fire(), # passing arguments of the appropriate types -- you are responsible - # for any type conversions necessary. + # for any type conversions necessary. # # fire() takes as many arguments as you defined for the probe: if # you have generated a list of arguments to pass to fire(), use the # splat operator to expand the list: - # + # # Dtrace::Probe::MyProvider.my_probe do |p| # args_list = [ some operation to get a list ] # p.fire(*args_list) # end - # + # # This yield/fire() syntax exposes the is-enabled feature of the # generated USDT probes: if the probe is not enabled, then the yield # does not happen: this allows you to put relatively expensive work diff --git a/lib/dtrace/probedata.rb b/lib/dtrace/probedata.rb index 3f56101..0c696ef 100644 --- a/lib/dtrace/probedata.rb +++ b/lib/dtrace/probedata.rb @@ -5,7 +5,7 @@ class Dtrace class ProbeData - + def records records = Array.new self.each_record do |rec| diff --git a/lib/dtrace/probedesc.rb b/lib/dtrace/probedesc.rb index 186e139..2f9b010 100644 --- a/lib/dtrace/probedesc.rb +++ b/lib/dtrace/probedesc.rb @@ -5,11 +5,11 @@ class Dtrace class ProbeDesc - + def to_s "#{provider}:#{mod}:#{func}:#{name}" end end end - + diff --git a/lib/dtrace/provider.rb b/lib/dtrace/provider.rb index 731b784..c024b7f 100644 --- a/lib/dtrace/provider.rb +++ b/lib/dtrace/provider.rb @@ -20,12 +20,12 @@ class Dtrace class Provider include Dtrace::Dof::Constants - Typemap = { :string => 'char *', :integer => 'int' } + Typemap = { :string => 'char *', :integer => 'int' } # Creates a DTrace provider. # # Example: - # + # # Dtrace::Provider.create :action_controller do |p| # p.probe :process_start, :string # p.probe :process_finish, :string, :integer @@ -34,10 +34,10 @@ class Provider # The symbol passed to create becomes the name of the provider, # and the class exposed under Dtrace::Probe in Ruby (camelized, so # the above statement creates Dtrace::Probe::ActionController). - # + # # create yields a Provider for the current platform, on which you - # can call probe, to create the individual probes. - # + # can call probe, to create the individual probes. + # # You can override the module name in the created probes, by # passing in an hash: # @@ -64,7 +64,7 @@ def self.create(name, options={}) # # p.probe :foo, { :function => 'somefunction' }, :int, ... # - def probe(name, *types) + def probe(name, *types) options = {} if types[0].respond_to? :keys options = types.shift @@ -100,7 +100,7 @@ def initialize(provider_name, module_name) def dof_size probes = @probe_defs.length args = (@probe_defs.inject(0) {|sum, pd| sum + pd.args.length }) + 1 - + size = 0 [ DOF_DOFHDR_SIZE, @@ -135,13 +135,13 @@ def enable offidx = 0 @probe_defs.each do |pd| argc = pd.argc - + argv = 0 pd.args.each do |type| i = @strtab.add(type) argv = i if argv == 0 end - + probe = Dtrace::Probe.new(argc) probes << { @@ -158,7 +158,7 @@ def enable :nargv => argv, :xargv => argv, } - + stubs[pd.name] = probe argidx += argc offidx += 1 @@ -177,7 +177,7 @@ def enable s.data = [ 0 ] end f.sections << s - + # After last addition to strtab, but before first offset! f.allocate(self.dof_size) @@ -200,7 +200,7 @@ def enable s.data = [ 0 ] end f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :strtab => 0, @@ -209,22 +209,22 @@ def enable :proffs => 3, :prenoffs => 4, :name => provider_name_idx, - :provattr => { + :provattr => { :name => DTRACE_STABILITY_EVOLVING, :data => DTRACE_STABILITY_EVOLVING, - :class => DTRACE_STABILITY_EVOLVING + :class => DTRACE_STABILITY_EVOLVING }, - :modattr => { + :modattr => { :name => DTRACE_STABILITY_PRIVATE, :data => DTRACE_STABILITY_PRIVATE, - :class => DTRACE_STABILITY_EVOLVING + :class => DTRACE_STABILITY_EVOLVING }, - :funcattr => { + :funcattr => { :name => DTRACE_STABILITY_PRIVATE, :data => DTRACE_STABILITY_PRIVATE, :class => DTRACE_STABILITY_EVOLVING }, - :nameattr => { + :nameattr => { :name => DTRACE_STABILITY_EVOLVING, :data => DTRACE_STABILITY_EVOLVING, :class => DTRACE_STABILITY_EVOLVING @@ -239,7 +239,7 @@ def enable f.generate Dtrace::Dof.loaddof(f, @module) - + provider = Dtrace::Provider::Klass.new(f, stubs) Dtrace::Probe.const_set(@class, provider) @@ -252,6 +252,6 @@ def camelize(lower_case_and_underscored_word) # Pinched from ActiveSupport's Inflector lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } end - + end end diff --git a/lib/dtrace/provider/klass.rb b/lib/dtrace/provider/klass.rb index 3b6f616..2a55c4c 100644 --- a/lib/dtrace/provider/klass.rb +++ b/lib/dtrace/provider/klass.rb @@ -6,22 +6,22 @@ class Dtrace class Provider - # A dynamically-created DTrace provider class. + # A dynamically-created DTrace provider class. # class Klass - + def initialize(dof, probes) # must stash a reference to the DOF in the provider: # on OSX at least, freeing the generated DOF removes - # the probes from the kernel. + # the probes from the kernel. @dof = dof @probes = probes end - + def method_missing(probe, *args, &block) if @probes[probe].nil? raise Dtrace::Exception.new("no such probe in #{self.to_s}: #{probe.to_s}") - else + else if @probes[probe].is_enabled? block.call @probes[probe] end diff --git a/lib/dtrace/stackrecord.rb b/lib/dtrace/stackrecord.rb index 3cdb654..5c4c059 100644 --- a/lib/dtrace/stackrecord.rb +++ b/lib/dtrace/stackrecord.rb @@ -5,7 +5,7 @@ # A record representing the result of a stack() or ustack() # action. Its value is a list of symbolic stack frames: -# +# # # :self - or + or dtrace :on, :tracer => :helper @@ -41,9 +41,9 @@ vendor/plugins/dtrace/scripts/ directory with the :script option: dtrace :on, :tracer => :self, :script => 'rails_mysql.d' -There are two scripts in the distribution: +There are two scripts in the distribution: * default.d - - a very simple script to log system calls, which doesn't require + - a very simple script to log system calls, which doesn't require a DTrace-enabled ruby. * rails_mysql.d diff --git a/plugin/dtrace/lib/dtrace_report.rb b/plugin/dtrace/lib/dtrace_report.rb index 81d8505..5d025ce 100644 --- a/plugin/dtrace/lib/dtrace_report.rb +++ b/plugin/dtrace/lib/dtrace_report.rb @@ -50,7 +50,7 @@ def enable_dtrace end def append_dtrace_report - if @@tracer + if @@tracer @dtrace_script = @@tracer.script @dtrace_report = @@tracer.end_dtrace # yuck! @@ -63,5 +63,5 @@ def append_dtrace_report end end end - + end diff --git a/plugin/dtrace/lib/dtracer.rb b/plugin/dtrace/lib/dtracer.rb index c36acda..8d413e7 100644 --- a/plugin/dtrace/lib/dtracer.rb +++ b/plugin/dtrace/lib/dtracer.rb @@ -28,7 +28,7 @@ def start_dtrace(pid) @logger.warn("DTrace start compile: #{e.message}") end end - + def end_dtrace # Check presence of handle and correct status. return [] unless @d && @d.status == Dtrace::STATUS_OKAY @@ -42,7 +42,7 @@ def end_dtrace rescue Dtrace::Exception => e @logger.warn("DTrace end: #{e.message}") end - + if dtrace_data return dtrace_data.data else diff --git a/plugin/dtrace/lib/dtracer_client.rb b/plugin/dtrace/lib/dtracer_client.rb index 7873d78..d83bffb 100644 --- a/plugin/dtrace/lib/dtracer_client.rb +++ b/plugin/dtrace/lib/dtracer_client.rb @@ -6,7 +6,7 @@ class DtracerClient def initialize DRb.start_service - @tracer = DRbObject.new(nil, 'druby://localhost:2999') + @tracer = DRbObject.new(nil, 'druby://localhost:2999') end def script=(script) @@ -18,7 +18,7 @@ def script=(script) def start_dtrace(pid) @tracer.start_dtrace(pid) end - + def end_dtrace @tracer.end_dtrace end diff --git a/plugin/dtrace/tasks/dtrace.rake b/plugin/dtrace/tasks/dtrace.rake index c009fcb..2426856 100644 --- a/plugin/dtrace/tasks/dtrace.rake +++ b/plugin/dtrace/tasks/dtrace.rake @@ -5,9 +5,9 @@ namespace :dtrace do ['dtracer'].each do |script| script_dest = "#{RAILS_ROOT}/script/#{script}" script_src = File.dirname(__FILE__) + "/../bin/#{script}.rb" - + FileUtils.chmod 0774, script_src - + unless File.exists?(script_dest) puts "Copying acts_as_encrypted script #{script}.rb to #{script_dest}" FileUtils.cp_r(script_src, script_dest) @@ -17,18 +17,18 @@ namespace :dtrace do ['stylesheets/dtrace.css'].each do |asset| asset_dest = "#{RAILS_ROOT}/public/#{asset}" asset_src = File.dirname(__FILE__) + "/../public/#{asset}" - + FileUtils.chmod 0774, asset_src - + unless File.exists?(asset_dest) puts "Copying acts_as_encrypted asset #{asset} to #{asset_dest}" FileUtils.cp_r(asset_src, asset_dest) end end end - + desc 'Remove dtrace from your rails application' - task :remove do + task :remove do ['dtracer'].each do |script| script_dest = "#{RAILS_ROOT}/script/#{script}" @@ -49,4 +49,4 @@ namespace :dtrace do end end - + diff --git a/plugin/dtrace_probes/README b/plugin/dtrace_probes/README index 587d683..13b30e5 100644 --- a/plugin/dtrace_probes/README +++ b/plugin/dtrace_probes/README @@ -1,6 +1,6 @@ DtraceProbes ============ -This is "Dynamic USDT Probes" for Rails, using ruby-dtrace. +This is "Dynamic USDT Probes" for Rails, using ruby-dtrace. Copyright (c) 2008 Chris Andrews , released under the MIT license diff --git a/plugin/dtrace_probes/lib/probes/action_controller.rb b/plugin/dtrace_probes/lib/probes/action_controller.rb index bc22320..fefd2e0 100644 --- a/plugin/dtrace_probes/lib/probes/action_controller.rb +++ b/plugin/dtrace_probes/lib/probes/action_controller.rb @@ -17,9 +17,9 @@ def self.included(base) p.probe :process_start, :string p.probe :process_finish, :string, :integer end - + base.alias_method_chain :process, :probes end - + end end diff --git a/plugin/dtrace_probes/lib/probes/active_record.rb b/plugin/dtrace_probes/lib/probes/active_record.rb index 565fc46..f97eff6 100644 --- a/plugin/dtrace_probes/lib/probes/active_record.rb +++ b/plugin/dtrace_probes/lib/probes/active_record.rb @@ -22,8 +22,8 @@ def self.included(base) p.probe :find_by_sql_start, :string p.probe :find_by_sql_finish, :integer end - - base.class_eval do + + base.class_eval do class << self alias_method_chain :find_by_sql, :probes end @@ -50,10 +50,10 @@ def self.included(base) p.probe :execute_start, :string p.probe :execute_finish, :string end - + base.alias_method_chain :execute, :probes end - + end end diff --git a/ruby-dtrace.gemspec b/ruby-dtrace.gemspec index 89c9fa5..1b855ba 100644 --- a/ruby-dtrace.gemspec +++ b/ruby-dtrace.gemspec @@ -1,5 +1,5 @@ Gem::Specification.new do |s| - + s.name = 'ruby-dtrace' s.version = '0.3.0' s.platform = Gem::Platform::RUBY @@ -8,10 +8,10 @@ Ruby-DTrace is Ruby bindings for Dtrace, which allows you to add DTrace probes to your Ruby programs, and to write D-based programs with Ruby. DESC - + s.has_rdoc = true s.extra_rdoc_files << 'README.txt' - + s.extensions << "ext/extconf.rb" s.extensions << "ext/dof/extconf.rb" s.require_paths << 'ext' diff --git a/test/test_disabled_probe_effect.rb b/test/test_disabled_probe_effect.rb index 0b1de79..4e6edea 100644 --- a/test/test_disabled_probe_effect.rb +++ b/test/test_disabled_probe_effect.rb @@ -11,22 +11,22 @@ class TestDisabledProbeEffect < Test::Unit::TestCase def test_probe_no_args - + n = 20000 Benchmark.bm do |x| - - x.report "noprobes:" do + + x.report "noprobes:" do # First time a loop with no probes created (1..n).each do |i| # no op end end - + Dtrace::Provider.create :dpe do |p| p.probe :p1 end - - x.report "disabled:" do + + x.report "disabled:" do # Second time a loop with probes created but not enabled. (1..n).each do |i| Dtrace::Probe::Dpe.p1 { |p| p.fire } @@ -35,15 +35,15 @@ def test_probe_no_args x.report "enabled: " do # Third time a loop with probes enabled - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") progtext = "dpe#{$$}:::p1 { }" - + prog = t.compile progtext prog.execute t.go - + (1..n).each do |i| Dtrace::Probe::Dpe.p1 { |p| p.fire } end diff --git a/test/test_dof_generator.rb b/test/test_dof_generator.rb index 7380f31..4537569 100644 --- a/test/test_dof_generator.rb +++ b/test/test_dof_generator.rb @@ -27,7 +27,7 @@ def test_generate_section_utsname dof = s.generate assert dof end - + def test_generate_section_probes s = Dtrace::Dof::Section.new(DOF_SECT_PROBES, 3) s.data = [ @@ -56,7 +56,7 @@ def test_generate_section_probes :noffs=>1, :xargv=>7}, ] - + dof = s.generate assert dof end diff --git a/test/test_dof_helper.rb b/test/test_dof_helper.rb index 79a05e0..e470bc9 100644 --- a/test/test_dof_helper.rb +++ b/test/test_dof_helper.rb @@ -11,7 +11,7 @@ class TestDofHelper < Test::Unit::TestCase include Dtrace::Dof::Constants - + def test_sun_dof flunk # platform test for Solaris @@ -28,7 +28,7 @@ def test_sun_dof end assert_equal 1, matches end - + def test_file f = Dtrace::Dof::File.new f.allocate(4096) @@ -65,7 +65,7 @@ def test_file s = Dtrace::Dof::Section.new(DOF_SECT_PRENOFFS, 4) s.data = [ 0 ] f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :strtab => 0, diff --git a/test/test_dof_providers.rb b/test/test_dof_providers.rb index 0a7605e..e487a85 100644 --- a/test/test_dof_providers.rb +++ b/test/test_dof_providers.rb @@ -9,7 +9,7 @@ class TestDofProviders < Test::Unit::TestCase include Dtrace::Dof::Constants - + def test_probe_no_args f = Dtrace::Dof::File.new f.allocate(4096) @@ -48,7 +48,7 @@ def test_probe_no_args s = Dtrace::Dof::Section.new(DOF_SECT_PRENOFFS, 4) s.data = [ 0 ] f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :strtab => 0, @@ -115,7 +115,7 @@ def test_probe_with_char_arg s = Dtrace::Dof::Section.new(DOF_SECT_PRENOFFS, 4) s.data = [ 0 ] f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :strtab => 0, @@ -182,7 +182,7 @@ def test_probe_with_int_arg s = Dtrace::Dof::Section.new(DOF_SECT_PRENOFFS, 4) s.data = [ 36 ] f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :strtab => 0, @@ -249,7 +249,7 @@ def test_probe_is_enabled s = Dtrace::Dof::Section.new(DOF_SECT_PRENOFFS, 4) s.data = [ 44 ] f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :name => 11, diff --git a/test/test_dof_strtabs.rb b/test/test_dof_strtabs.rb index f3444c0..d0b7d9c 100644 --- a/test/test_dof_strtabs.rb +++ b/test/test_dof_strtabs.rb @@ -9,11 +9,11 @@ class TestDofStrtabs < Test::Unit::TestCase include Dtrace::Dof::Constants - + def test_strtab_stridxs sec = Dtrace::Dof::Section::Strtab.new(1) assert sec - + assert_equal 1, sec.add('foo') assert_equal 5, sec.add('bar') assert_equal 9, sec.add('baz') @@ -56,7 +56,7 @@ def test_strtab_dof s = Dtrace::Dof::Section.new(DOF_SECT_PRENOFFS, 4) s.data = [ 36 ] f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :strtab => 0, @@ -65,22 +65,22 @@ def test_strtab_dof :proffs => 3, :prenoffs => 4, :name => strtab.add('teststrtabs'), - :provattr => { + :provattr => { :name => DTRACE_STABILITY_EVOLVING, :data => DTRACE_STABILITY_EVOLVING, - :class => DTRACE_STABILITY_EVOLVING + :class => DTRACE_STABILITY_EVOLVING }, - :modattr => { + :modattr => { :name => DTRACE_STABILITY_PRIVATE, :data => DTRACE_STABILITY_PRIVATE, - :class => DTRACE_STABILITY_EVOLVING + :class => DTRACE_STABILITY_EVOLVING }, - :funcattr => { + :funcattr => { :name => DTRACE_STABILITY_PRIVATE, :data => DTRACE_STABILITY_PRIVATE, :class => DTRACE_STABILITY_EVOLVING }, - :nameattr => { + :nameattr => { :name => DTRACE_STABILITY_EVOLVING, :data => DTRACE_STABILITY_EVOLVING, :class => DTRACE_STABILITY_EVOLVING diff --git a/test/test_dtrace.rb b/test/test_dtrace.rb index 682e042..48c25b7 100644 --- a/test/test_dtrace.rb +++ b/test/test_dtrace.rb @@ -57,7 +57,7 @@ def test_list_probes_match_usdt def test_list_probes_match_prog t = Dtrace.new - + progtext = "syscall:::return { @calls[execname] = count(); @@ -87,7 +87,7 @@ def test_list_probes_match_prog def test_list_probes_match_badpattern t = Dtrace.new probe_count = 0 - assert_raises Dtrace::Exception do + assert_raises Dtrace::Exception do t.each_probe('syscall') do |probe| nil end @@ -114,7 +114,7 @@ def test_compile assert info.recgens_count assert info.matches_count end - + def test_compile_with_args t = Dtrace.new @@ -134,11 +134,11 @@ def test_compile_with_args assert_equal 2, info.aggregates_count assert_equal 0, info.speculations_count assert_equal 4, info.recgens_count - + # matches_count is platform dependent assert info.matches_count end - + def test_run t = Dtrace.new @@ -173,5 +173,5 @@ def test_bad_program end assert_equal "probe description :::blah does not match any probes", e.message end - + end diff --git a/test/test_dtrace_aggregates.rb b/test/test_dtrace_aggregates.rb index 9a06c56..be3ae80 100644 --- a/test/test_dtrace_aggregates.rb +++ b/test/test_dtrace_aggregates.rb @@ -10,13 +10,13 @@ class TestDtraceAggregates < Test::Unit::TestCase def test_aggregate_group - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") t.setopt("aggsize", "4m") progtext =< 0 data.each do |d| assert d diff --git a/test/test_dtrace_drops_errors.rb b/test/test_dtrace_drops_errors.rb index f5eb47e..dd498f5 100644 --- a/test/test_dtrace_drops_errors.rb +++ b/test/test_dtrace_drops_errors.rb @@ -11,7 +11,7 @@ class TestDtraceDropsErrors < Test::Unit::TestCase def test_drops - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "512") t.setopt("strsize", "1024") @@ -38,7 +38,7 @@ def test_drops assert c i = 0 - c.drophandler do |d| + c.drophandler do |d| assert_match(/1 drop on CPU [0-9]+/, d.msg) assert_equal "drop to principal buffer", d.kind assert_not_nil d.cpu @@ -55,7 +55,7 @@ def test_drops end def test_error_handler_too_late - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "512") t.setopt("strsize", "1024") @@ -65,10 +65,10 @@ def test_error_handler_too_late *(char *)NULL; } EOD - + prog = t.compile progtext prog.execute - t.go + t.go c = Dtrace::Consumer.new(t) assert c @@ -84,7 +84,7 @@ def test_error_handler_too_late end def test_errors - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "512") t.setopt("strsize", "1024") @@ -94,7 +94,7 @@ def test_errors *(char *)NULL; } EOD - + prog = t.compile progtext prog.execute @@ -121,7 +121,7 @@ def test_errors def test_error_and_drop_handler - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "512") t.setopt("strsize", "1024") @@ -144,7 +144,7 @@ def test_error_and_drop_handler exit(0); } EOD - + prog = t.compile progtext prog.execute @@ -163,7 +163,7 @@ def test_error_and_drop_handler end drops = 0 - c.drophandler do |d| + c.drophandler do |d| assert_match(/1 drop on CPU [0-9]+/, d.msg) assert_equal "drop to principal buffer", d.kind assert_not_nil d.cpu diff --git a/test/test_dtrace_multi_provider.rb b/test/test_dtrace_multi_provider.rb index 7695d3c..9c282cf 100644 --- a/test/test_dtrace_multi_provider.rb +++ b/test/test_dtrace_multi_provider.rb @@ -8,7 +8,7 @@ require 'test/unit' class TestDtraceMultiProvider < Test::Unit::TestCase - + def test_multiple_providers_and_list Dtrace::Provider.create :multi1 do |p| p.probe :test1, :integer, :integer @@ -57,7 +57,7 @@ def test_multiple_providers_and_fire trace("fired 2"); } EOD - + t = Dtrace.new t.setopt("bufsize", "4m") prog = t.compile progtext @@ -80,7 +80,7 @@ def test_multiple_providers_and_fire assert_equal 2, data.length assert_equal 'fired 1', data[0].data[0].value - assert_equal 'fired 2', data[1].data[0].value + assert_equal 'fired 2', data[1].data[0].value end end diff --git a/test/test_dtrace_probe.rb b/test/test_dtrace_probe.rb index 4a6521b..e4d5db3 100644 --- a/test/test_dtrace_probe.rb +++ b/test/test_dtrace_probe.rb @@ -9,7 +9,7 @@ class TestDtraceProbe < Test::Unit::TestCase include Dtrace::Dof::Constants - + def test_probe p = Dtrace::Probe.new(0) end @@ -65,7 +65,7 @@ def test_fire_probe_no_args s = Dtrace::Dof::Section.new(DOF_SECT_PRENOFFS, 4) s.data = [ probe.is_enabled_offset(f.addr) ] f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :strtab => 0, @@ -84,8 +84,8 @@ def test_fire_probe_no_args f.generate Dtrace::Dof.loaddof(f, 'testmodule') - - t = Dtrace.new + + t = Dtrace.new t.setopt("bufsize", "4m") matches = 0 @@ -158,7 +158,7 @@ def test_fire_probe_two_int_args s = Dtrace::Dof::Section.new(DOF_SECT_PRENOFFS, 4) s.data = [ probe.is_enabled_offset(f.addr) ] f.sections << s - + s = Dtrace::Dof::Section.new(DOF_SECT_PROVIDER, 5) s.data = { :strtab => 0, @@ -178,7 +178,7 @@ def test_fire_probe_two_int_args f.generate Dtrace::Dof.loaddof(f, 'testmodule') - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") progtext = < 0, @@ -267,7 +267,7 @@ def test_fire_probe_two_charstar_args f.generate Dtrace::Dof.loaddof(f, 'testmodule') - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") progtext = < 0 end - + def test_dprogram_aggregate - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") t.setopt("aggsize", "4m") progtext = < 0 + assert i > 0 end - + def test_stack - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "8m") t.setopt("aggsize", "4m") t.setopt("stackframes", "5") @@ -188,7 +188,7 @@ def test_stack assert_equal 2, d.data.length assert_equal Dtrace::Record, d.data[0].class assert_equal Dtrace::StackRecord, d.data[1].class - + i = i + 1 if i > 10 c.finish @@ -198,7 +198,7 @@ def test_stack end def test_ustack - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "8m") t.setopt("aggsize", "4m") t.setopt("stackframes", "5") @@ -229,4 +229,4 @@ def test_ustack assert i > 0 end -end +end diff --git a/test/test_dtrace_provider.rb b/test/test_dtrace_provider.rb index fd17783..3e73c22 100644 --- a/test/test_dtrace_provider.rb +++ b/test/test_dtrace_provider.rb @@ -16,7 +16,7 @@ def test_massive_provider p.probe "#{i}".to_sym end end - + t = Dtrace.new matches = 0 t.each_probe("test_massive1#{$$}:ruby:test_massive_provider:") do |p| diff --git a/test/test_dtrace_repeat.rb b/test/test_dtrace_repeat.rb index 3596112..3a7278f 100644 --- a/test/test_dtrace_repeat.rb +++ b/test/test_dtrace_repeat.rb @@ -12,19 +12,19 @@ # the end). class TestDtraceRepeat < Test::Unit::TestCase - + def test_repeats (0..9).each do |i| - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") t.setopt("aggsize", "4m") progtext = 'syscall:::entry { trace("foo"); }' - + prog = t.compile progtext prog.execute t.go - + # Let some activity happen. sleep 1 diff --git a/test/test_dtrace_rubyprobe.rb b/test/test_dtrace_rubyprobe.rb index e582b59..5e0105e 100644 --- a/test/test_dtrace_rubyprobe.rb +++ b/test/test_dtrace_rubyprobe.rb @@ -10,7 +10,7 @@ class TestDtrace < Test::Unit::TestCase def test_rubyprobe flunk # platform test for Joyent patched Ruby - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") progtext = < 0 data.each do |d| assert d @@ -56,13 +56,13 @@ def test_filter end def test_filter_two_classes - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") t.setopt("aggsize", "4m") progtext =< 0 data.each do |d| assert d diff --git a/test/test_legacy_consumer.rb b/test/test_legacy_consumer.rb index 6ae3375..d28ef75 100644 --- a/test/test_legacy_consumer.rb +++ b/test/test_legacy_consumer.rb @@ -10,13 +10,13 @@ class TestLegacyConsumer < Test::Unit::TestCase def test_aggregate_group - t = Dtrace.new + t = Dtrace.new t.setopt("bufsize", "4m") t.setopt("aggsize", "4m") progtext =< 0 data.each do |d| assert d