thread_backtrace 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -5,6 +5,10 @@ Thread Backtrace
5
5
 
6
6
  It adds Thread#backtrace. Although I abuse private APIs of Ruby, no ruby patches are required. It **does not** work with 1.9.
7
7
 
8
+ Installation is simple as
9
+
10
+ gem install thread_backtrace
11
+
8
12
  Example
9
13
  -------
10
14
 
data/Rakefile CHANGED
@@ -4,13 +4,14 @@ require 'rake/gempackagetask'
4
4
 
5
5
  spec = Gem::Specification.new do |s|
6
6
  s.name = 'thread_backtrace'
7
- s.version = '0.1'
7
+ s.version = '0.1.1'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.has_rdoc = true
10
+ s.authors = ['Eugene Pimenov']
10
11
  s.extra_rdoc_files = ["README.markdown"]
11
12
  s.summary = "Adds Thread\#backtrace"
12
- s.description = "Adds Thread\#backtrace for inspecting bactrace of a thread. Only works on 1.8"
13
- s.files = PKG_FILES = %w(README.markdown Rakefile) + Dir.glob("{ext,lib}/**/*.{rb,c}")
13
+ s.description = "Adds Thread\#backtrace for inspecting backtrace of a thread. Only supports 1.8"
14
+ s.files = %w(README.markdown Rakefile) + Dir.glob("{ext,lib}/**/*.{rb,c}")
14
15
  s.extensions << 'ext/thread_backtrace/extconf.rb'
15
16
  s.require_paths = ["lib"]
16
17
  s.required_ruby_version = "~>1.8"
@@ -4,6 +4,7 @@
4
4
 
5
5
  extern rb_thread_t rb_main_thread, rb_curr_thread;
6
6
  extern struct FRAME * ruby_frame;
7
+ static VALUE cThreadError;
7
8
 
8
9
  static rb_thread_t find_thread(VALUE thread)
9
10
  {
@@ -14,17 +15,17 @@ static rb_thread_t find_thread(VALUE thread)
14
15
  t = t->next;
15
16
  } while (t != rb_main_thread);
16
17
 
17
- // todo: raise exception
18
- return 0;
18
+ rb_raise(cThreadError, "killed thread");
19
+ return NULL;
19
20
  }
20
21
 
21
22
  static void * convert_pointer(rb_thread_t thread, void * ptr)
22
23
  {
23
24
  VALUE *p = (VALUE*)ptr;
24
25
 
25
- if(thread == rb_curr_thread) return ptr;
26
+ if (thread == rb_curr_thread) return ptr;
26
27
 
27
- if(p >= thread->stk_pos && p <= thread->stk_pos + thread->stk_len)
28
+ if (p >= thread->stk_pos && p <= thread->stk_pos + thread->stk_len)
28
29
  return (p - thread->stk_pos) + thread->stk_ptr;
29
30
 
30
31
  return p;
@@ -68,6 +69,8 @@ static VALUE thread_backtrace(VALUE self)
68
69
 
69
70
  void Init_thread_backtrace()
70
71
  {
71
- VALUE cThread = rb_define_class("Thread", rb_cObject);
72
+ VALUE cThread = rb_const_get(rb_cObject, rb_intern("Thread"));
72
73
  rb_define_method(cThread, "backtrace", thread_backtrace, 0);
74
+
75
+ cThreadError = rb_const_get(rb_cObject, rb_intern("ThreadError"));
73
76
  }
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thread_backtrace
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.1
5
5
  platform: ruby
6
- authors: []
7
-
6
+ authors:
7
+ - Eugene Pimenov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-16 00:00:00 +03:00
12
+ date: 2010-02-17 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Adds Thread#backtrace for inspecting bactrace of a thread. Only works on 1.8
16
+ description: Adds Thread#backtrace for inspecting backtrace of a thread. Only supports 1.8
17
17
  email:
18
18
  executables: []
19
19