rbtrace 0.4.11 → 0.4.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb8fa0f63b60cff1f92eebde1a7a69e907a8c2f89d026ada05a1b059720d9f3f
4
- data.tar.gz: db1534f9c0fd26a521b3d24cfc1f6153c47633b1404125306aa44e7ec2aa3553
3
+ metadata.gz: 90ef44223d9a9594cd447443fff128884825d19b5bb553ba3d4c2924df6c2da0
4
+ data.tar.gz: a09e1b41bca4f998e47b7de04a711915440deb4bbc81007cbf27264dac9bfcbb
5
5
  SHA512:
6
- metadata.gz: 7810fbf225e045a4f7a9eea100546cb9f076261f829255266ee99a046eebef74b9891d4ecda0ecb37e97f6d01485977ea4a70b4d3e88539829edf9fa019aa59a
7
- data.tar.gz: 88730842962e602cbe033910ae900f68e5aae87b33a4f8149db39465a5c7b9df4f28fd8712432015509f1260371ff61e6e724fc1d43c1b2446252c4b0bc9481f
6
+ metadata.gz: 828eead6b86f3b21b743b6391e69ae854bb19ba0b1a6e84258a9b67f2675036dd46a91b6178a622d7568466e480e858b519fa7aa9d099e3030470422a3fa706e
7
+ data.tar.gz: b735bf29d7fb23d56a36a008df77d8ea23325fc0f1c9d0f16826941077000c11a25fa4e7b9b637cd7157e988bd2db5e0f5017ca53218a6b1b23bab8b7df4d46e
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  ext/src/msgpack*
4
4
  tmp/*
5
+ Gemfile.lock
@@ -862,6 +862,22 @@ msgq_setup()
862
862
  #endif
863
863
  }
864
864
 
865
+ static VALUE
866
+ eval_inspect(VALUE rb_code) {
867
+ VALUE binding, result;
868
+
869
+ binding = rb_eval_string("$rbtrace_binding ||= binding");
870
+ result = rb_funcall(binding, rb_intern("eval"), 1, rb_code);
871
+ return rb_funcall(result, rb_intern("inspect"), 0);
872
+ }
873
+
874
+ static VALUE
875
+ rescue_inspect(VALUE arg) {
876
+ VALUE exception = rb_errinfo(); /* get last exception */
877
+ rb_set_errinfo(Qnil);
878
+ return rb_funcall(exception, rb_intern("inspect"), 0);
879
+ }
880
+
865
881
  static void
866
882
  rbtrace__process_event(msgpack_object cmd)
867
883
  {
@@ -1012,8 +1028,10 @@ rbtrace__process_event(msgpack_object cmd)
1012
1028
  strncpy(query, str.ptr, str.size);
1013
1029
  query[str.size] = 0;
1014
1030
 
1015
- snprintf(code, BUF_SIZE+150, "(begin; %s; rescue Exception => e; e; end).inspect", query);
1016
- val = rb_eval_string_protect(code, 0);
1031
+ VALUE rb_code, binding;
1032
+ rb_code = rb_str_new2(query);
1033
+
1034
+ val = rb_rescue(eval_inspect, rb_code, rescue_inspect, Qnil);
1017
1035
 
1018
1036
  if (TYPE(val) == T_STRING) {
1019
1037
  rbtrace__send_event(1,
@@ -1021,7 +1039,6 @@ rbtrace__process_event(msgpack_object cmd)
1021
1039
  's', RSTRING_PTR(val)
1022
1040
  );
1023
1041
  }
1024
-
1025
1042
  }
1026
1043
  }
1027
1044
 
@@ -1102,9 +1119,26 @@ signal_handler_wrapper(VALUE arg, VALUE ctx)
1102
1119
  }
1103
1120
  #endif
1104
1121
 
1122
+ static VALUE
1123
+ send_write(VALUE klass, VALUE val) {
1124
+ if (TYPE(val) == T_STRING) {
1125
+ rbtrace__send_event(1,
1126
+ "write",
1127
+ 's', RSTRING_PTR(val)
1128
+ );
1129
+ }
1130
+
1131
+ return Qnil;
1132
+ }
1133
+
1105
1134
  void
1106
1135
  Init_rbtrace()
1107
1136
  {
1137
+ VALUE mod = rb_define_module("RBTrace");
1138
+ VALUE output = rb_define_module_under(mod, "OUT");
1139
+
1140
+ rb_define_singleton_method(output, "write", send_write, 1);
1141
+
1108
1142
  // hook into the gc
1109
1143
  gc_hook = Data_Wrap_Struct(rb_cObject, rbtrace_gc_mark, NULL, NULL);
1110
1144
  rb_global_variable(&gc_hook);
@@ -34,7 +34,7 @@ class RBTraceCLI
34
34
  # Returns nothing.
35
35
  def self.cleanup_queues
36
36
  if (pids = `ps ax -o pid`.split("\n").map{ |p| p.strip.to_i }).any?
37
- ipcs = `ipcs -q`.split("\n").grep(/^(q|0x)/).map{ |line| line[/(0x[a-f0-9]+)/,1] }
37
+ ipcs = `ipcs -q`.split("\n").grep(/^(q|0x)/).map{ |line| line[/(0x[a-f0-9]+)/,1] }.compact
38
38
  ipcs.each do |ipci|
39
39
  next if ipci.match(/^0xf/)
40
40
 
@@ -321,7 +321,9 @@ class RBTracer
321
321
  def send_cmd(*cmd)
322
322
  begin
323
323
  msg = cmd.to_msgpack
324
- raise ArgumentError, 'command is too long' if msg.bytesize > MsgQ::EventMsg::BUF_SIZE
324
+ # A message is null-terminated, but bytesize gives the unterminated
325
+ # length.
326
+ raise ArgumentError, 'command is too long' if msg.bytesize >= MsgQ::EventMsg::BUF_SIZE
325
327
  MsgQ::EventMsg.send_cmd(@qo, msg)
326
328
  rescue Errno::EINTR
327
329
  retry
@@ -575,6 +577,10 @@ class RBTracer
575
577
  puts if @watch_slow
576
578
  end
577
579
 
580
+ when 'write'
581
+ data, = *cmd
582
+ STDOUT.write(data)
583
+
578
584
  else
579
585
  puts "unknown event #{event}: #{cmd.inspect}"
580
586
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class RBTracer
2
- VERSION = '0.4.11'
4
+ VERSION = '0.4.12'
3
5
  end
@@ -1,3 +1,4 @@
1
+ ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter#execute(sql)
1
2
  ActiveRecord::ConnectionAdapters::MysqlAdapter#execute(sql)
2
3
  ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#execute(sql)
3
4
  ActiveRecord::ConnectionAdapters::SQLiteAdapter#execute(sql)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbtrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-05 00:00:00.000000000 Z
11
+ date: 2020-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -77,7 +77,6 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - ".gitignore"
79
79
  - Gemfile
80
- - Gemfile.lock
81
80
  - LICENSE
82
81
  - README.md
83
82
  - Rakefile
@@ -124,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
123
  - !ruby/object:Gem::Version
125
124
  version: '0'
126
125
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 2.7.6
126
+ rubygems_version: 3.0.3
129
127
  signing_key:
130
128
  specification_version: 4
131
129
  summary: 'rbtrace: like strace but for ruby code'
@@ -1,25 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- rbtrace (0.4.11)
5
- ffi (>= 1.0.6)
6
- msgpack (>= 0.4.3)
7
- optimist (>= 3.0.0)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- ffi (1.9.25)
13
- msgpack (1.2.4)
14
- optimist (3.0.0)
15
- rake (10.5.0)
16
-
17
- PLATFORMS
18
- ruby
19
-
20
- DEPENDENCIES
21
- rake (~> 10.0)
22
- rbtrace!
23
-
24
- BUNDLED WITH
25
- 1.16.4