debugger-linecache 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +1 -0
- data/README.md +4 -0
- data/Rakefile +2 -45
- data/debugger-linecache.gemspec +2 -4
- data/lib/debugger/linecache.rb +1 -1
- data/lib/tracelines19.rb +17 -1
- metadata +6 -40
- data/ext/trace_nums/extconf.rb +0 -15
- data/ext/trace_nums/trace_nums.c +0 -105
- data/ext/trace_nums/trace_nums.h +0 -111
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Thanks for trying out this project! [See here for contribution guidelines.](http://tagaholic.me/contributing.html)
|
data/README.md
CHANGED
@@ -7,10 +7,14 @@ For more info see OLD\_README.
|
|
7
7
|
## Credits
|
8
8
|
|
9
9
|
* Original authors: R. Bernstein, Mark Moseley
|
10
|
+
* @ko1 - replace C extension with ruby
|
10
11
|
|
11
12
|
## TODO
|
12
13
|
* Fix todo test
|
13
14
|
|
15
|
+
## Contributing
|
16
|
+
[See here](http://tagaholic.me/contributing.html)
|
17
|
+
|
14
18
|
## LICENSE
|
15
19
|
|
16
20
|
This library is licensed under LICENSE.txt. Original was GNU.
|
data/Rakefile
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
# -*- Ruby -*-
|
2
|
+
|
2
3
|
require 'rubygems/package_task'
|
3
4
|
require 'rake/testtask'
|
4
|
-
require 'rake/extensiontask'
|
5
|
-
|
6
|
-
Rake::ExtensionTask.new('trace_nums')
|
7
|
-
|
8
|
-
SO_NAME = "trace_nums.so"
|
9
5
|
|
10
6
|
desc "Test everything."
|
11
7
|
test_task = task :test => :lib do
|
@@ -16,13 +12,6 @@ test_task = task :test => :lib do
|
|
16
12
|
end
|
17
13
|
end
|
18
14
|
|
19
|
-
desc "Create the core ruby-debug shared library extension"
|
20
|
-
task :lib do
|
21
|
-
Dir.chdir("ext") do
|
22
|
-
system("#{Gem.ruby} extconf.rb && make")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
15
|
desc "Test everything - same as test."
|
27
16
|
task :check => :test
|
28
17
|
|
@@ -32,40 +21,8 @@ Gem::PackageTask.new(base_spec) do |pkg|
|
|
32
21
|
pkg.need_tar = true
|
33
22
|
end
|
34
23
|
|
35
|
-
# Windows specification
|
36
|
-
win_spec = base_spec.clone
|
37
|
-
win_spec.extensions = []
|
38
|
-
## win_spec.platform = Gem::Platform::WIN32 # deprecated
|
39
|
-
win_spec.platform = 'mswin32'
|
40
|
-
win_spec.files += ["lib/#{SO_NAME}"]
|
41
|
-
|
42
|
-
desc "Create Windows Gem"
|
43
|
-
task :win32_gem do
|
44
|
-
# Copy the win32 extension the top level directory.
|
45
|
-
current_dir = File.expand_path(File.dirname(__FILE__))
|
46
|
-
source = File.join(current_dir, "ext", "win32", SO_NAME)
|
47
|
-
target = File.join(current_dir, "lib", SO_NAME)
|
48
|
-
cp(source, target)
|
49
|
-
|
50
|
-
# Create the gem, then move it to pkg.
|
51
|
-
Gem::Builder.new(win_spec).build
|
52
|
-
gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
|
53
|
-
mv(gem_file, "pkg/#{gem_file}")
|
54
|
-
|
55
|
-
# Remove win extension from top level directory.
|
56
|
-
rm(target)
|
57
|
-
end
|
58
|
-
|
59
24
|
desc "Remove built files"
|
60
|
-
task :clean => [:clobber_package
|
61
|
-
cd "ext" do
|
62
|
-
if File.exists?("Makefile")
|
63
|
-
sh "make clean"
|
64
|
-
rm "Makefile"
|
65
|
-
end
|
66
|
-
derived_files = Dir.glob(".o") + Dir.glob("*.so")
|
67
|
-
rm derived_files unless derived_files.empty?
|
68
|
-
end
|
25
|
+
task :clean => [:clobber_package] do
|
69
26
|
end
|
70
27
|
|
71
28
|
task :default => [:test]
|
data/debugger-linecache.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
2
|
require 'rubygems' unless defined? Gem
|
3
3
|
require File.dirname(__FILE__) + "/lib/debugger/linecache"
|
4
4
|
|
@@ -15,8 +15,6 @@ example in a debugger where the same lines are shown many times.
|
|
15
15
|
s.required_rubygems_version = ">= 1.3.6"
|
16
16
|
s.extra_rdoc_files = ["README.md"]
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
|
-
s.extensions << "ext/trace_nums/extconf.rb"
|
19
|
-
s.add_dependency "debugger-ruby_core_source", '>= 1.1.1'
|
20
18
|
s.add_development_dependency 'rake', '~> 0.9.2.2'
|
21
|
-
s.
|
19
|
+
s.license = "MIT"
|
22
20
|
end
|
data/lib/debugger/linecache.rb
CHANGED
data/lib/tracelines19.rb
CHANGED
@@ -1,10 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# $Id$
|
3
|
-
require 'trace_nums'
|
4
3
|
|
5
4
|
module TraceLineNumbers
|
6
5
|
# Return an array of lines numbers that could be
|
7
6
|
# stopped at given a file name of a Ruby program.
|
7
|
+
|
8
|
+
def self.lnums_for_str src
|
9
|
+
name = "#{Time.new.to_i}_#{rand(2**31)}"
|
10
|
+
iseq = RubyVM::InstructionSequence.compile(src, name)
|
11
|
+
lines = {}
|
12
|
+
iseq.disasm.each_line{|line|
|
13
|
+
if /^\d+ (\w+)\s+.+\(\s*(\d+)\)$/ =~ line
|
14
|
+
insn = $1
|
15
|
+
lineno = $2.to_i
|
16
|
+
next unless insn == 'trace'
|
17
|
+
lines[lineno] = true
|
18
|
+
# p [lineno, line]
|
19
|
+
end
|
20
|
+
}
|
21
|
+
lines.keys
|
22
|
+
end
|
23
|
+
|
8
24
|
def lnums_for_file(file)
|
9
25
|
lnums_for_str(File.read(file))
|
10
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debugger-linecache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,24 +11,8 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: debugger-ruby_core_source
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
|
-
requirements:
|
21
|
-
- - ! '>='
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.1.1
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
|
-
requirements:
|
29
|
-
- - ! '>='
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: 1.1.1
|
32
16
|
- !ruby/object:Gem::Dependency
|
33
17
|
name: rake
|
34
18
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,22 +29,6 @@ dependencies:
|
|
45
29
|
- - ~>
|
46
30
|
- !ruby/object:Gem::Version
|
47
31
|
version: 0.9.2.2
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: rake-compiler
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 0.8.0
|
56
|
-
type: :development
|
57
|
-
prerelease: false
|
58
|
-
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
|
-
requirements:
|
61
|
-
- - ~>
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: 0.8.0
|
64
32
|
description: ! 'Linecache is a module for reading and caching lines. This may be useful
|
65
33
|
for
|
66
34
|
|
@@ -69,22 +37,19 @@ description: ! 'Linecache is a module for reading and caching lines. This may be
|
|
69
37
|
'
|
70
38
|
email: gabriel.horner@gmail.com
|
71
39
|
executables: []
|
72
|
-
extensions:
|
73
|
-
- ext/trace_nums/extconf.rb
|
40
|
+
extensions: []
|
74
41
|
extra_rdoc_files:
|
75
42
|
- README.md
|
76
43
|
files:
|
77
44
|
- .travis.yml
|
78
45
|
- CHANGELOG.md
|
46
|
+
- CONTRIBUTING.md
|
79
47
|
- LICENSE.txt
|
80
48
|
- OLD_CHANGELOG
|
81
49
|
- OLD_README
|
82
50
|
- README.md
|
83
51
|
- Rakefile
|
84
52
|
- debugger-linecache.gemspec
|
85
|
-
- ext/trace_nums/extconf.rb
|
86
|
-
- ext/trace_nums/trace_nums.c
|
87
|
-
- ext/trace_nums/trace_nums.h
|
88
53
|
- lib/debugger/linecache.rb
|
89
54
|
- lib/linecache19.rb
|
90
55
|
- lib/tracelines19.rb
|
@@ -123,7 +88,8 @@ files:
|
|
123
88
|
- test/test-lnum.rb
|
124
89
|
- test/test-tracelines.rb
|
125
90
|
homepage: http://github.com/cldwalker/debugger-linecache
|
126
|
-
licenses:
|
91
|
+
licenses:
|
92
|
+
- MIT
|
127
93
|
post_install_message:
|
128
94
|
rdoc_options: []
|
129
95
|
require_paths:
|
data/ext/trace_nums/extconf.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "mkmf"
|
2
|
-
require "debugger/ruby_core_source"
|
3
|
-
|
4
|
-
if RUBY_VERSION < '1.9'
|
5
|
-
abort("Ruby version is too old")
|
6
|
-
end
|
7
|
-
|
8
|
-
hdrs = proc {
|
9
|
-
have_header("vm_core.h") and have_header("version.h")
|
10
|
-
}
|
11
|
-
|
12
|
-
dir_config("ruby")
|
13
|
-
if !Debugger::RubyCoreSource.create_makefile_with_core(hdrs, "trace_nums")
|
14
|
-
abort("Makefile creation failed.")
|
15
|
-
end
|
data/ext/trace_nums/trace_nums.c
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Ruby 1.9 version: (7/20/2009, Mark Moseley, mark@fast-software.com)
|
3
|
-
|
4
|
-
Now works with Ruby-1.9.1. Tested with p129 and p243.
|
5
|
-
|
6
|
-
This does not (and can not) function identically to the 1.8 version.
|
7
|
-
Line numbers are ordered differently. But ruby-debug doesn't seem
|
8
|
-
to mind the difference.
|
9
|
-
|
10
|
-
Also, 1.9 does not number lines with a "begin" statement.
|
11
|
-
|
12
|
-
All this 1.9 version does is compile into bytecode, disassemble it
|
13
|
-
using rb_iseq_disasm(), and parse the text output. This isn't a
|
14
|
-
great solution; it will break if the disassembly format changes.
|
15
|
-
Walking the iseq tree and decoding each instruction is pretty hairy,
|
16
|
-
though, so until I have a really compelling reason to go that route,
|
17
|
-
I'll leave it at this.
|
18
|
-
*/
|
19
|
-
#include <ruby.h>
|
20
|
-
#include <version.h>
|
21
|
-
#include <vm_core.h>
|
22
|
-
#include "trace_nums.h"
|
23
|
-
|
24
|
-
VALUE mTraceLineNumbers;
|
25
|
-
|
26
|
-
static inline const rb_data_type_t *
|
27
|
-
threadptr_data_type(void)
|
28
|
-
{
|
29
|
-
static const rb_data_type_t *thread_data_type;
|
30
|
-
if (!thread_data_type)
|
31
|
-
{
|
32
|
-
VALUE current_thread = rb_thread_current();
|
33
|
-
thread_data_type = RTYPEDDATA_TYPE(current_thread);
|
34
|
-
}
|
35
|
-
return thread_data_type;
|
36
|
-
}
|
37
|
-
|
38
|
-
#define ruby_threadptr_data_type *threadptr_data_type()
|
39
|
-
#define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))
|
40
|
-
|
41
|
-
/* Return a list of trace hook line numbers for the string in Ruby source src*/
|
42
|
-
static VALUE
|
43
|
-
lnums_for_str(VALUE self, VALUE src)
|
44
|
-
{
|
45
|
-
VALUE result = rb_ary_new(); /* The returned array of line numbers. */
|
46
|
-
int len;
|
47
|
-
char *token;
|
48
|
-
char *disasm;
|
49
|
-
rb_thread_t *th;
|
50
|
-
VALUE iseqval;
|
51
|
-
VALUE disasm_val;
|
52
|
-
|
53
|
-
StringValue(src); /* Check that src is a string. */
|
54
|
-
th = GET_THREAD();
|
55
|
-
|
56
|
-
/* First compile to bytecode, using the method in eval_string_with_cref() in vm_eval.c */
|
57
|
-
th->parse_in_eval++;
|
58
|
-
th->mild_compile_error++;
|
59
|
-
iseqval = rb_iseq_compile(src, rb_str_new_cstr("(numbers_for_str)"), INT2FIX(1));
|
60
|
-
th->mild_compile_error--;
|
61
|
-
th->parse_in_eval--;
|
62
|
-
|
63
|
-
/* Disassemble the bytecode into text and parse into lines */
|
64
|
-
disasm_val = rb_iseq_disasm(iseqval);
|
65
|
-
if (disasm_val == Qnil)
|
66
|
-
return(result);
|
67
|
-
|
68
|
-
disasm = (char*)malloc(strlen(RSTRING_PTR(disasm_val))+1);
|
69
|
-
strcpy(disasm, RSTRING_PTR(disasm_val));
|
70
|
-
|
71
|
-
for (token = strtok(disasm, "\n"); token != NULL; token = strtok(NULL, "\n"))
|
72
|
-
{
|
73
|
-
/* look only for lines tracing RUBY_EVENT_LINE (1) */
|
74
|
-
if (strstr(token, "trace 1 ") == NULL)
|
75
|
-
continue;
|
76
|
-
len = strlen(token) - 1;
|
77
|
-
if (token[len] != ')')
|
78
|
-
continue;
|
79
|
-
len--;
|
80
|
-
if ((token[len] == '(') || (token[len] == ' '))
|
81
|
-
continue;
|
82
|
-
|
83
|
-
for (; len > 0; len--)
|
84
|
-
{
|
85
|
-
if (token[len] == ' ')
|
86
|
-
continue;
|
87
|
-
if ((token[len] >= '0') && (token[len] <= '9'))
|
88
|
-
continue;
|
89
|
-
if (token[len] == '(')
|
90
|
-
rb_ary_push(result, INT2NUM(atoi(token + len + 1))); /* trace found */
|
91
|
-
|
92
|
-
break;
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
free(disasm);
|
97
|
-
return result;
|
98
|
-
}
|
99
|
-
|
100
|
-
void Init_trace_nums(void)
|
101
|
-
{
|
102
|
-
mTraceLineNumbers = rb_define_module("TraceLineNumbers");
|
103
|
-
rb_define_module_function(mTraceLineNumbers, "lnums_for_str",
|
104
|
-
lnums_for_str, 1);
|
105
|
-
}
|
data/ext/trace_nums/trace_nums.h
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
/* Order is in C enum order. The below is correct for Ruby 1.8.6.
|
2
|
-
Possibly others, but there may need some adjustment here.
|
3
|
-
*/
|
4
|
-
const char *NODE2NAME[] =
|
5
|
-
{
|
6
|
-
"method",
|
7
|
-
"fbody",
|
8
|
-
"cfunc",
|
9
|
-
"scope",
|
10
|
-
"block",
|
11
|
-
"if",
|
12
|
-
"case",
|
13
|
-
"when",
|
14
|
-
"opt_n (-n)",
|
15
|
-
"while",
|
16
|
-
"until",
|
17
|
-
"iter",
|
18
|
-
"for",
|
19
|
-
"break",
|
20
|
-
"next",
|
21
|
-
"redo",
|
22
|
-
"retry",
|
23
|
-
"begin",
|
24
|
-
"rescue",
|
25
|
-
"resbody",
|
26
|
-
"ensure",
|
27
|
-
"and",
|
28
|
-
"or",
|
29
|
-
"not",
|
30
|
-
"masgn",
|
31
|
-
"lasgn (x=)",
|
32
|
-
"dasgn",
|
33
|
-
"dasgn_curr",
|
34
|
-
"gasgn",
|
35
|
-
"iasgn",
|
36
|
-
"cdecl",
|
37
|
-
"cvasgn",
|
38
|
-
"cvdecl",
|
39
|
-
"op_asgn1",
|
40
|
-
"op_asgn2",
|
41
|
-
"op_asgn_and",
|
42
|
-
"op_asgn_or",
|
43
|
-
"call",
|
44
|
-
"fcall",
|
45
|
-
"vcall",
|
46
|
-
"super",
|
47
|
-
"zsuper",
|
48
|
-
"array",
|
49
|
-
"zarray",
|
50
|
-
"hash",
|
51
|
-
"return",
|
52
|
-
"yield",
|
53
|
-
"lvar",
|
54
|
-
"dvar",
|
55
|
-
"gvar",
|
56
|
-
"ivar",
|
57
|
-
"const",
|
58
|
-
"cvar",
|
59
|
-
"nth_ref",
|
60
|
-
"back_ref",
|
61
|
-
"match",
|
62
|
-
"match2 (~=, !~)",
|
63
|
-
"match3 (~=, !~)",
|
64
|
-
"lit",
|
65
|
-
"str",
|
66
|
-
"dstr",
|
67
|
-
"xstr",
|
68
|
-
"dxstr",
|
69
|
-
"evstr",
|
70
|
-
"dregx",
|
71
|
-
"dregx_once",
|
72
|
-
"args",
|
73
|
-
"argscat",
|
74
|
-
"argspush",
|
75
|
-
"splat (*args)",
|
76
|
-
"to_ary",
|
77
|
-
"svalue",
|
78
|
-
"block_arg",
|
79
|
-
"block_pass",
|
80
|
-
"defn",
|
81
|
-
"defs",
|
82
|
-
"alias",
|
83
|
-
"valias",
|
84
|
-
"undef",
|
85
|
-
"class",
|
86
|
-
"module",
|
87
|
-
"sclass",
|
88
|
-
"colon2 (::)",
|
89
|
-
"colon3",
|
90
|
-
"cref",
|
91
|
-
"dot2 (..)",
|
92
|
-
"dot3 (...)",
|
93
|
-
"flip2",
|
94
|
-
"flip3",
|
95
|
-
"attrset",
|
96
|
-
"self",
|
97
|
-
"nil",
|
98
|
-
"true",
|
99
|
-
"false",
|
100
|
-
"defined?",
|
101
|
-
"newline (; or \\n)",
|
102
|
-
"postexe",
|
103
|
-
"alloca",
|
104
|
-
"dmethod",
|
105
|
-
"bmethod",
|
106
|
-
"memo",
|
107
|
-
"ifunc",
|
108
|
-
"dsym",
|
109
|
-
"attrasgn",
|
110
|
-
"last"
|
111
|
-
};
|