Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial version of debugger support
Use Rubinus::Debugger but provide some fancy-specific output on method names / signatures etc.
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
class Rubinius CompiledMethod { | |||
forwards_unary_ruby_methods | |||
|
|||
def selectors_with_args { | |||
local_names = local_names to_a | |||
if: (required_args > 0) then: { | |||
name to_s split: ":" . map_with_index: |sel i| { | |||
"#{sel}: #{local_names[i]}" | |||
} . join: " " | |||
} else: { | |||
name to_s rest | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,72 @@ | |||
require("rubinius/debugger") | |||
|
|||
class Rubinius Debugger { | |||
forwards_unary_ruby_methods | |||
metaclass forwards_unary_ruby_methods | |||
} | |||
|
|||
class Rubinius Debugger Command SetBreakPoint { | |||
def match_method: method_identifier { | |||
match method_identifier { | |||
case /##/ -> | |||
class_name, method_name = method_identifier split: "##" | |||
method_identifier = "#{class_name}::#{method_name message_name}" | |||
case /#/ -> | |||
class_name, method_name = method_identifier split: "#" | |||
method_identifier = "#{class_name}##{method_name message_name}" | |||
} | |||
|
|||
/([A-Z]\w*(?:::[A-Z]\w*)*)([.#]|::)([a-zA-Z0-9_\[\]:]+[!?=]?)(?:[:](\d+))?/ match: method_identifier | |||
} | |||
|
|||
alias_method('match_method, 'match_method:) | |||
} | |||
|
|||
class Rubinius Location { | |||
forwards_unary_ruby_methods | |||
} | |||
|
|||
class Rubinius Debugger Frame { | |||
forwards_unary_ruby_methods | |||
|
|||
def describe { | |||
arg_str = "" | |||
recv = nil | |||
signature = method selectors_with_args | |||
|
|||
loc = @location | |||
|
|||
if: (loc is_block) then: { | |||
if: (method required_args == 0) then: { | |||
recv = "{ } in #{loc describe_receiver}#{loc name}" | |||
} else: { | |||
block_args = method local_names join: ", " | |||
recv = "|#{block_args}| { } in #{loc describe_receiver}#{loc name}" | |||
} | |||
} else: { | |||
if: (method required_args == 0) then: { | |||
recv = loc describe | |||
} else: { | |||
recv = "#{loc describe}" | |||
} | |||
} | |||
|
|||
recv = recv replace: "#:" with: "#" | |||
recv = recv replace: ".:" with: "##" | |||
recv = recv replace: "." with: "##" | |||
|
|||
str = "#{recv} at #{loc method active_path}:#{loc line} (#{loc ip})" | |||
{ str << " (+#{loc ip})" } if: $ @debugger variables['show_ip] | |||
str | |||
} | |||
|
|||
alias_method('describe, ':describe) | |||
|
|||
def run: code { | |||
Fancy eval: (code to_s) binding: binding | |||
} | |||
|
|||
alias_method('run, 'run:) | |||
} | |||
|
|||
Rubinius Debugger start |