-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add commands to start and use the debugger (#449)
* Seamlessly integrate a few debug commands * Improve the break command support * Utilize skip_src option if available * Add step and delete commands * Write end-to-end tests for each debugger command * Add documentation * Add backtrace, info, catch commands
- Loading branch information
Showing
19 changed files
with
487 additions
and
37 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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "debug" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class Backtrace < Debug | ||
def self.transform_args(args) | ||
args&.dump | ||
end | ||
|
||
def execute(*args) | ||
super(pre_cmds: ["backtrace", *args].join(" ")) | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "debug" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class Break < Debug | ||
def self.transform_args(args) | ||
args&.dump | ||
end | ||
|
||
def execute(args = nil) | ||
super(pre_cmds: "break #{args}") | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "debug" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class Catch < Debug | ||
def self.transform_args(args) | ||
args&.dump | ||
end | ||
|
||
def execute(*args) | ||
super(pre_cmds: ["catch", *args].join(" ")) | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "debug" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class Continue < Debug | ||
def execute(*args) | ||
super(do_cmds: ["continue", *args].join(" ")) | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "debug" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class Delete < Debug | ||
def execute(*args) | ||
super(pre_cmds: ["delete", *args].join(" ")) | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "debug" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class Finish < Debug | ||
def execute(*args) | ||
super(do_cmds: ["finish", *args].join(" ")) | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: false | ||
|
||
require_relative "nop" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class IrbInfo < Nop | ||
def execute | ||
Class.new { | ||
def inspect | ||
str = "Ruby version: #{RUBY_VERSION}\n" | ||
str += "IRB version: #{IRB.version}\n" | ||
str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n" | ||
str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file) | ||
str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n" | ||
str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty? | ||
str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty? | ||
str += "East Asian Ambiguous Width: #{Reline.ambiguous_width.inspect}\n" | ||
if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/ | ||
codepage = `chcp`.b.sub(/.*: (\d+)\n/, '\1') | ||
str += "Code page: #{codepage}\n" | ||
end | ||
str | ||
end | ||
alias_method :to_s, :inspect | ||
}.new | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "debug" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class Next < Debug | ||
def execute(*args) | ||
super(do_cmds: ["next", *args].join(" ")) | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "debug" | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class Step < Debug | ||
def execute(*args) | ||
# Run `next` first to move out of binding.irb | ||
super(pre_cmds: "next", do_cmds: ["step", *args].join(" ")) | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end |
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
Oops, something went wrong.