Skip to content

Commit

Permalink
Start packaging. Add Rakefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Dec 23, 2010
1 parent 391e70d commit 6f76245
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 33 deletions.
52 changes: 52 additions & 0 deletions .gemspec
@@ -0,0 +1,52 @@
# -*- Ruby -*-
# -*- encoding: utf-8 -*-
require 'rake'
require 'rubygems' unless
Object.const_defined?(:Gem)
require File.dirname(__FILE__) + "/lib/set_trace"

FILES = FileList[
'README',
'ChangeLog',
'LICENSE',
'NEWS',
'Rakefile',
'THANKS',
'app/*',
'interface/*',
'io/*',
'lib/*',
'processor/**/*.rb',
'test/data/**/*.cmd',
'test/data/**/*.right',
'test/**/*.rb',
]

Gem::Specification.new do |spec|
spec.add_dependency('diff-lcs') # For testing only
spec.add_dependency('rbx-require-relative')
spec.authors = ['R. Bernstein']
spec.date = Time.now
spec.description = <<-EOF
Emulates Ruby set_trace_func in Rubinus and contains related step-tracing
features.
EOF
## spec.add_dependency('diff-lcs') # For testing only
spec.author = 'R. Bernstein'
spec.email = 'rockyb@rubyforge.net'
spec.files = FILES.to_a
spec.has_rdoc = true
spec.homepage = 'http://wiki.github.com/rocky/rbx-tracer'
spec.name = 'rbx-tracer'
spec.license = 'MIT'
spec.platform = Gem::Platform::new ['universal', 'rubinius']
spec.require_path = 'lib'
spec.required_ruby_version = '~> 1.8.7'
spec.summary = 'set_trace_func Rubinius 1.2 and above'
spec.version = Rubinius::SetTrace::VERSION

# Make the readme file the start page for the generated html
## spec.rdoc_options += %w(--main README)
spec.rdoc_options += ['--title', "Rubinius::SetTrace #{Rubinius::SetTrace::VERSION} Documentation"]

end
37 changes: 37 additions & 0 deletions ChangeLog
@@ -0,0 +1,37 @@
2010-12-23 rocky <rockyb@rubyforge.org>

* breakpoint.rb, frame.rb, set_trace.rb: runtime_context ->
vm_location

2010-12-22 rocky <rockyb@rubyforge.org>

* breakpoint.rb, commands.rb, frame.rb, set_trace.rb: Remove more
(but not all) of the "command"-ness for step/continue that is not
needed in set_trace_func. location -> runtime_context.

2010-12-21 rocky <rockyb@rubyforge.org>

* commands.rb, set_trace.rb: Handle set_trace_func nil.

2010-12-21 rocky <rockyb@rubyforge.org>

* breakpoint.rb, commands.rb, frame.rb, set_trace.rb: Set call and
return events

2010-12-21 rocky <rockyb@rubyforge.org>

* set_trace.rb: Closer to having all of the set_trace_func
parameters filled in.

2010-12-21 rocky <rockyb@rubyforge.org>

* README: See above

2010-12-21 rocky <rockyb@rubyforge.org>

* README: What we're about. github suggests this.

2010-12-20 rvm <rocky-rvm@static-71-183-236-17.nycmny.fios.verizon.net>

* First Hope (of sometine useful).

25 changes: 25 additions & 0 deletions LICENSE
@@ -0,0 +1,25 @@
Copyright (c) 2007, Evan Phoenix
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Evan Phoenix nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109 changes: 109 additions & 0 deletions Rakefile
@@ -0,0 +1,109 @@
#!/usr/bin/env rake
# Are we Rubinius? We'll test by checking the specific function we need.
raise RuntimeError, 'This package is for Rubinius 1.2 or 1.2.1dev only!' unless
Object.constants.include?('Rubinius') &&
Rubinius.constants.include?('VM') &&
%w(1.2 1.2.1dev).member?(Rubinius::VERSION)

require 'rubygems'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'

ROOT_DIR = File.dirname(__FILE__)

def gemspec
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
end

desc "Build the gem"
task :package=>:gem
task :gem=>:gemspec do
Dir.chdir(ROOT_DIR) do
sh "gem build .gemspec"
FileUtils.mkdir_p 'pkg'
FileUtils.mv("#{gemspec.name}-#{gemspec.version}-universal-rubinius.gem",
'pkg')
end
end

desc "Install the gem locally"
task :install => :gem do
Dir.chdir(ROOT_DIR) do
sh %{gem install --local pkg/#{gemspec.name}-#{gemspec.version}}
end
end

require 'rbconfig'
RUBY_PATH = File.join(RbConfig::CONFIG['bindir'],
RbConfig::CONFIG['RUBY_INSTALL_NAME'])

def run_standalone_ruby_files(list)
puts '*' * 40
list.each do |ruby_file|
system(RUBY_PATH, ruby_file)
end
end

def run_standalone_ruby_file(directory)
puts ('*' * 10) + ' ' + directory + ' ' + ('*' * 10)
Dir.chdir(directory) do
Dir.glob('*.rb').each do |ruby_file|
puts(('-' * 20) + ' ' + ruby_file + ' ' + ('-' * 20))
system(RUBY_PATH, ruby_file)
end
end
end

desc 'Create a GNU-style ChangeLog via git2cl'
task :ChangeLog do
system('git log --pretty --numstat --summary | git2cl > ChangeLog')
end

desc 'the tests'
Rake::TestTask.new(:'test') do |t|
t.test_files = FileList['test**/test-*.rb']
# t.pattern = 'test/**/*test-*.rb' # instead of above
t.verbose = true
end

desc 'Test everything - unit tests for now.'
task :default => :test

desc "Run each Ruby app file in standalone mode."
task :'check:app' do
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} app)))
end

desc "Generate the gemspec"
task :generate do
puts gemspec.to_ruby
end

desc "Validate the gemspec"
task :gemspec do
gemspec.validate
end

# --------- RDoc Documentation ------
desc "Generate rdoc documentation"
Rake::RDocTask.new("rdoc") do |rdoc|
rdoc.rdoc_dir = 'doc'
# rdoc.title = "rbx-trepaning #{Rubinius::SetTrace::VERSION} Documentation"

rdoc.rdoc_files.include(%w(lib/set_trace.rb app/*.rb))
end

desc "Same as rdoc"
task :doc => :rdoc

task :clobber_package do
FileUtils.rm_rf File.join(ROOT_DIR, 'pkg')
end

task :clobber_rdoc do
FileUtils.rm_rf File.join(ROOT_DIR, 'doc')
end

desc "Remove built files"
task :clean => [:clobber_package, :clobber_rdoc]
2 changes: 2 additions & 0 deletions app/.gitignore
@@ -0,0 +1,2 @@
/*.rbc
/*~
File renamed without changes.
3 changes: 2 additions & 1 deletion commands.rb → app/commands.rb
@@ -1,4 +1,5 @@
require 'breakpoint'
require 'rubygems'; require 'require_relative'
require_relative './breakpoint'

class Rubinius::SetTrace
class Command
Expand Down
6 changes: 3 additions & 3 deletions frame.rb → app/frame.rb
Expand Up @@ -14,9 +14,9 @@ def run(code)

def binding
@binding ||= Binding.setup(
@vm_location.variables,
@vm_location.method,
@vm_location.static_scope)
@vm_location.variables,
@vm_location.method,
@vm_location.static_scope)
end

def method
Expand Down
2 changes: 2 additions & 0 deletions lib/.gitignore
@@ -0,0 +1,2 @@
/*.rbc
/*~
62 changes: 33 additions & 29 deletions set_trace.rb → lib/set_trace.rb
@@ -1,30 +1,32 @@
require 'rubygems'; require 'require_relative'
require_relative './frame'
require_relative './commands'
require_relative './breakpoint'
require_relative '../app/frame'
require_relative '../app/commands'
require_relative '../app/breakpoint'
require 'compiler/iseq'

#
# A Rubinius implementation of set_trace_func.
#
# This debugger is wired into the debugging APIs provided by Rubinius.
# It serves as a simple, builtin debugger that others can use as
# an example for how to build a better debugger.
# This code is wired into the debugging APIs provided by Rubinius.
# It tries to isolate the complicated stepping logic as well as simulate
# Ruby's set_trace_func.
#

class Rubinius::SetTrace
VERSION = '0.0.1.dev'

# Used to try and show the source for the kernel. Should
# mostly work, but it's a hack.
ROOT_DIR = File.expand_path(File.dirname(__FILE__) + "/..")
DEFAULT_SETTINGS = {
:callback_style => :classic
}

# Create a new debugger object. The debugger starts up a thread
# which is where the command line interface executes from. Other
# threads that you wish to debug are told that their debugging
# thread is the debugger thread. This is how the debugger is handed
# control of execution.
#
def initialize(meth=nil)
def initialize(opts={})
@opts = DEFAULT_SETTINGS.merge(opts)
@file_lines = Hash.new do |hash, path|
if File.exists? path
hash[path] = File.readlines(path)
Expand All @@ -38,39 +40,36 @@ def initialize(meth=nil)
end
end

@meth = meth
@thread = nil
@frames = []
@user_variables = 0
@breakpoints = []
@root_dir = ROOT_DIR
end

attr_reader :variables, :current_frame, :breakpoints, :user_variables
attr_reader :vm_locations

def self.global(callback_method)
# FIXME: if @global is set, we need to *change* method.
@global ||= new(callback_method)
def self.global(opts={})
@global ||= new
end

def self.set_trace_func(callback_method)
global(callback_method).set_trace_func(callback_method, 1)
global.set_trace_func(callback_method, 1)
end

# Startup the debugger, skipping back +offset+ frames. This lets you start
# the debugger straight into callers method.
#
def set_trace_func(callback_method, offset=0)
def set_trace_func(callback_method, call_offset=0)
if callback_method
@callback_method = callback_method
@tracing = true
@tracing = true
@step_cmd = Command.commands['step']
@continue_cmd = Command.commands['continue']
spinup_thread

# Feed info to the debugger thread!
vm_locations = Rubinius::VM.backtrace(offset + 1, true)
vm_locations = Rubinius::VM.backtrace(call_offset + 1, true)

method = Rubinius::CompiledMethod.of_sender

Expand Down Expand Up @@ -132,13 +131,18 @@ def listen(step_into=false)

# call callback
def call_callback
line = @current_frame.line
file = @current_frame.file
meth = @current_frame.method
binding = @current_frame.binding
id = nil
classname = nil
@callback_method.call(@event, file, line, id, binding, classname)
case @opts[:callback_style]
when :classic
line = @current_frame.line
file = @current_frame.file
meth = @current_frame.method
binding = @current_frame.binding
id = nil
classname = nil
@callback_method.call(@event, file, line, id, binding, classname)
else
@callback_method.call(@event, @locs)
end
if @tracing
@step_cmd.new(self).run
else
Expand All @@ -164,9 +168,9 @@ def delete_breakpoint(i)
end

def send_between(exec, start, fin)
ss = Rubinius::InstructionSet.opcodes_map[:send_stack]
sm = Rubinius::InstructionSet.opcodes_map[:send_method]
sb = Rubinius::InstructionSet.opcodes_map[:send_stack_with_block]
ss = Rubinius::InstructionSet.opcodes_map[:send_stack]
sm = Rubinius::InstructionSet.opcodes_map[:send_method]
sb = Rubinius::InstructionSet.opcodes_map[:send_stack_with_block]

iseq = exec.iseq

Expand Down

0 comments on commit 6f76245

Please sign in to comment.