rb-threadframe 0.32 → 0.33

Sign up to get free protection for your applications and to get access to all the features.
data/Makefile ADDED
@@ -0,0 +1,14 @@
1
+ # I'll admit it -- I'm an absent-minded old-timer who has trouble
2
+ # learning new tricks.
3
+ .PHONY: all test
4
+
5
+ all: test
6
+ rake $@
7
+
8
+ check:
9
+ rake test
10
+ test:
11
+ rake test
12
+
13
+ %:
14
+ rake $@
data/NEWS CHANGED
@@ -1,2 +1,7 @@
1
+ October 27 2010 (0.33)
2
+ - Revise rvm install script to be more roboust
3
+ - Change bug report location so we don't spam Ruby's redmine
4
+ - Add RubyVM::InstructionSequence#parent and #local_iseq fields
5
+
1
6
  September 12 2010 (0.32)
2
- First release on gemcutter
7
+ - First release on gemcutter
data/Rakefile CHANGED
@@ -1,30 +1,35 @@
1
1
  #!/usr/bin/env rake
2
2
  # -*- Ruby -*-
3
3
  require 'rubygems'
4
- require 'rake'
5
- require 'rake/gempackagetask'
6
- require 'rake/rdoctask'
7
- require 'rake/testtask'
4
+ require 'fileutils'
8
5
 
9
- rake_dir = File.dirname(__FILE__)
6
+ ROOT_DIR = File.dirname(__FILE__)
10
7
 
11
8
  require 'rbconfig'
12
9
  RUBY_PATH = File.join(RbConfig::CONFIG['bindir'],
13
10
  RbConfig::CONFIG['RUBY_INSTALL_NAME'])
14
11
 
15
- SO_NAME = 'thread_frame.so'
12
+ def gemspec
13
+ @gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
14
+ end
16
15
 
17
- PACKAGE_VERSION = open("ext/thread_frame.c") do |f|
18
- f.grep(/^#define THREADFRAME_VERSION/).first[/"(.+)"/,1]
16
+ require 'rake/gempackagetask'
17
+ desc "Build the gem"
18
+ task :package=>:gem
19
+ task :gem=>:gemspec do
20
+ Dir.chdir(ROOT_DIR) do
21
+ sh "gem build .gemspec"
22
+ FileUtils.mkdir_p 'pkg'
23
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
24
+ end
19
25
  end
20
26
 
21
- EXT_FILES = FileList[%w(ext/*.c ext/*.h)]
22
- INCLUDE_FILES = FileList['include/*.h']
23
- LIB_FILES = FileList['lib/*.rb']
24
- TEST_FILES = FileList['test/**/*.rb']
25
- COMMON_FILES = FileList[%w(README.md Rakefile LICENSE NEWS)]
26
- ALL_FILES = COMMON_FILES + INCLUDE_FILES + LIB_FILES + EXT_FILES +
27
- TEST_FILES
27
+ desc "Install the gem locally"
28
+ task :install => :gem do
29
+ Dir.chdir(ROOT_DIR) do
30
+ sh %{gem install --local pkg/#{gemspec.name}-#{gemspec.version}}
31
+ end
32
+ end
28
33
 
29
34
  desc 'Create the core thread-frame shared library extension'
30
35
  task :ext do
@@ -35,7 +40,7 @@ end
35
40
 
36
41
  desc 'Remove built files'
37
42
  task :clean do
38
- cd 'ext' do
43
+ Dir.chdir File.join(ROOT_DIR, 'ext') do
39
44
  if File.exist?('Makefile')
40
45
  sh 'make clean'
41
46
  rm 'Makefile'
@@ -62,6 +67,7 @@ end
62
67
 
63
68
  task :default => [:test]
64
69
 
70
+ require 'rake/testtask'
65
71
  desc 'Test units - the smaller tests'
66
72
  task :'test:unit' => [:ext] do |t|
67
73
  Rake::TestTask.new(:'test:unit') do |t|
@@ -87,76 +93,39 @@ task :test do
87
93
  raise "Test failures" unless exceptions.empty?
88
94
  end
89
95
 
90
- desc "Test everything - same as test."
91
-
96
+ desc "test in isolation."
92
97
  task :'check' do
93
- run_standalone_ruby_file(File.join(%W(#{rake_dir} test unit)))
98
+ run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test unit)))
99
+ end
100
+
101
+ desc "Generate the gemspec"
102
+ task :generate do
103
+ puts gemspec.to_ruby
104
+ end
105
+
106
+ desc "Validate the gemspec"
107
+ task :gemspec do
108
+ gemspec.validate
94
109
  end
95
110
 
96
111
  # --------- RDoc Documentation ------
112
+ require 'rake/rdoctask'
97
113
  desc 'Generate rdoc documentation'
98
114
  Rake::RDocTask.new('rdoc') do |rdoc|
99
- rdoc.rdoc_dir = 'doc/rdoc'
115
+ rdoc.rdoc_dir = 'doc'
100
116
  rdoc.title = 'rb-threadframe'
101
- # Show source inline with line numbers
102
- rdoc.options << '--inline-source' << '--line-numbers'
103
117
  # Make the readme file the start page for the generated html
104
- rdoc.options << '--main' << 'README.md'
118
+ rdoc.options += %w(--main README.md)
105
119
  rdoc.rdoc_files.include('ext/**/*.c',
106
120
  'README.md')
107
121
  end
122
+ desc "Same as rdoc"
123
+ task :doc => :rdoc
108
124
 
109
- # Base GEM Specification
110
- spec = Gem::Specification.new do |spec|
111
- spec.name = "rb-threadframe"
112
-
113
- spec.homepage = "http://github.com/rocky/rb-threadframe/tree/master"
114
- spec.summary = "Frame introspection"
115
- spec.description = <<-EOF
116
-
117
- rb-threadframe gives introspection access for frames of a thread.
118
- EOF
119
-
120
- spec.version = PACKAGE_VERSION
121
- spec.require_path = 'lib'
122
- spec.extensions = ["ext/extconf.rb"]
123
-
124
- spec.author = "R. Bernstein"
125
- spec.email = "rocky@gnu.org"
126
- spec.platform = Gem::Platform::RUBY
127
- spec.files = ALL_FILES.to_a
128
-
129
- spec.required_ruby_version = '>= 1.9.2'
130
- spec.date = Time.now
131
- # spec.rubyforge_project = 'rocky-hacks'
132
-
133
- # rdoc
134
- spec.has_rdoc = true
135
- spec.extra_rdoc_files = ['README.md', 'threadframe.rd'] +
136
- FileList['ext/*.c']
137
- end
138
-
139
- # Rake task to build the default package
140
- Rake::GemPackageTask.new(spec) do |pkg|
141
- pkg.need_tar = true
125
+ task :clobber_package do
126
+ FileUtils.rm_rf File.join(ROOT_DIR, 'pkg')
142
127
  end
143
128
 
144
- def install(spec, *opts)
145
- args = ['gem', 'install', "pkg/#{spec.name}-#{spec.version}.gem"] + opts
146
- system(*args)
129
+ task :clobber_rdoc do
130
+ FileUtils.rm_rf File.join(ROOT_DIR, 'doc')
147
131
  end
148
-
149
- desc 'Install locally'
150
- task :install => :package do
151
- Dir.chdir(File::dirname(__FILE__)) do
152
- # ri and rdoc take lots of time
153
- install(spec, '--no-ri', '--no-rdoc')
154
- end
155
- end
156
-
157
- task :install_full => :package do
158
- Dir.chdir(File::dirname(__FILE__)) do
159
- install(spec)
160
- end
161
- end
162
-
data/ext/iseq_extra.c CHANGED
@@ -5,7 +5,8 @@
5
5
  /*
6
6
  * Additions to the RubyVM::InstructionSequence class
7
7
  */
8
- VALUE rb_cIseq = rb_define_class_under(rb_cRubyVM, "InstructionSequence", ...)
8
+ VALUE rb_cIseq = rb_define_class_under(rb_cRubyVM, "InstructionSequence",
9
+ rb_cObject);
9
10
  #endif
10
11
 
11
12
  #include "../include/vm_core_mini.h" /* Pulls in ruby.h and node.h */
@@ -103,6 +104,35 @@ iseq_equal(VALUE iseqval1, VALUE iseqval2)
103
104
  return Qfalse;
104
105
  }
105
106
 
107
+ VALUE
108
+ iseq_parent(VALUE self)
109
+ {
110
+ rb_iseq_t *piseq;
111
+ rb_iseq_t *parent_iseq;
112
+ VALUE parent_iseqval;
113
+ GetISeqPtr(self, piseq);
114
+
115
+ if (!RTEST(piseq->parent_iseq)) return Qnil;
116
+ parent_iseqval = iseq_alloc_shared(rb_cISeq);
117
+ GetISeqPtr(parent_iseqval, parent_iseq);
118
+ memcpy(parent_iseq, piseq->parent_iseq, sizeof(struct rb_iseq_struct));
119
+ return parent_iseqval;
120
+ }
121
+
122
+ VALUE
123
+ iseq_local_iseq(VALUE self)
124
+ {
125
+ rb_iseq_t *piseq;
126
+ rb_iseq_t *local_iseq;
127
+ VALUE local_iseqval;
128
+ GetISeqPtr(self, piseq);
129
+
130
+ if (!RTEST(piseq->local_iseq)) return Qnil;
131
+ local_iseqval = iseq_alloc_shared(rb_cISeq);
132
+ GetISeqPtr(local_iseqval, local_iseq);
133
+ memcpy(local_iseq, piseq->local_iseq, sizeof(struct rb_iseq_struct));
134
+ return local_iseqval;
135
+ }
106
136
 
107
137
  /*
108
138
  * call-seq:
@@ -390,12 +420,14 @@ Init_iseq_extra(void)
390
420
  rb_define_method(rb_cISeq, "klass", iseq_klass, 0) ;
391
421
  rb_define_method(rb_cISeq, "lineno", iseq_line_no, 0) ;
392
422
  rb_define_method(rb_cISeq, "line_range", iseq_line_range, 0) ;
423
+ rb_define_method(rb_cISeq, "local_iseq", iseq_local_iseq, 0) ;
393
424
  rb_define_method(rb_cISeq, "local_name", iseq_local_name, 1) ;
394
425
  rb_define_method(rb_cISeq, "local_size", iseq_local_size, 0) ;
395
426
  rb_define_method(rb_cISeq, "local_table_size", iseq_local_table_size, 0) ;
396
427
  rb_define_method(rb_cISeq, "offset2lines", iseq_offset2lines, 1) ;
397
428
  rb_define_method(rb_cISeq, "offsetlines", iseq_offsetlines, 0) ;
398
429
  rb_define_method(rb_cISeq, "orig", iseq_orig, 0) ;
430
+ rb_define_method(rb_cISeq, "parent", iseq_parent, 0) ;
399
431
  rb_define_method(rb_cISeq, "name", iseq_name, 0) ;
400
432
  rb_define_method(rb_cISeq, "self", iseq_self, 0) ;
401
433
  rb_define_method(rb_cISeq, "source_container", iseq_source_container, 0) ;
data/ext/thread_frame.c CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  /* What release we got? */
9
- #define THREADFRAME_VERSION "0.32"
9
+ #define THREADFRAME_VERSION "0.33"
10
10
 
11
11
  #include <string.h>
12
12
  #include "../include/vm_core_mini.h" /* Pulls in ruby.h and node.h */
@@ -134,7 +134,7 @@ typedef struct rb_iseq_struct {
134
134
  * arg_block = M+N + 1 + O + 1 // -1 if no block arg
135
135
  * arg_simple = 0 if not simple arguments.
136
136
  * = 1 if no opt, rest, post, block.
137
- * = 2 if ambiguos block parameter ({|a|}).
137
+ * = 2 if ambiguous block parameter ({|a|}).
138
138
  * arg_size = argument size.
139
139
  */
140
140
 
@@ -54,4 +54,12 @@ class TestLibISeqExtra < Test::Unit::TestCase
54
54
  assert_equal(0, sha1 =~ /^[0-9a-f]+$/)
55
55
  end
56
56
 
57
+ def test_iseq_parent
58
+ parent_iseq = RubyVM::ThreadFrame::current.iseq
59
+ 1.times do
60
+ tf = RubyVM::ThreadFrame::current
61
+ assert_equal(true, tf.iseq.parent.equal?(parent_iseq))
62
+ end
63
+ end
64
+
57
65
  end
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 32
8
- version: "0.32"
7
+ - 33
8
+ version: "0.33"
9
9
  platform: ruby
10
10
  authors:
11
11
  - R. Bernstein
@@ -13,13 +13,13 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-09-12 00:00:00 -04:00
16
+ date: 2010-10-27 00:00:00 -04:00
17
17
  default_executable:
18
18
  dependencies: []
19
19
 
20
20
  description: "\n\
21
21
  rb-threadframe gives introspection access for frames of a thread.\n"
22
- email: rocky@gnu.org
22
+ email: rockyb@rubyforge.net
23
23
  executables: []
24
24
 
25
25
  extensions:
@@ -27,13 +27,10 @@ extensions:
27
27
  extra_rdoc_files:
28
28
  - README.md
29
29
  - threadframe.rd
30
- - ext/iseq_extra.c
31
- - ext/thread_frame.c
32
- - ext/proc_extra.c
33
- - ext/thread_extra.c
34
30
  files:
35
31
  - README.md
36
32
  - Rakefile
33
+ - Makefile
37
34
  - LICENSE
38
35
  - NEWS
39
36
  - include/thread_pthread.h
@@ -74,17 +71,20 @@ files:
74
71
  - ext/extconf.rb
75
72
  has_rdoc: true
76
73
  homepage: http://github.com/rocky/rb-threadframe/tree/master
77
- licenses: []
78
-
74
+ licenses:
75
+ - MIT
79
76
  post_install_message:
80
- rdoc_options: []
81
-
77
+ rdoc_options:
78
+ - --main
79
+ - README.md
80
+ - --title
81
+ - ThreadFrame 0.33 Documentation
82
82
  require_paths:
83
83
  - lib
84
84
  required_ruby_version: !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
- - - ">="
87
+ - - "="
88
88
  - !ruby/object:Gem::Version
89
89
  segments:
90
90
  - 1