pry-byebug-3.10.1/0000755000004100000410000000000014527327376013731 5ustar www-datawww-datapry-byebug-3.10.1/README.md0000644000004100000410000001405714527327376015217 0ustar www-datawww-data# pry-byebug [![Version][VersionBadge]][VersionURL] [![Build][CIBadge]][CIURL] [![Inline docs][InchCIBadge]][InchCIURL] Adds step-by-step debugging and stack navigation capabilities to [pry] using [byebug]. To use, invoke pry normally. No need to start your script or app differently. Execution will stop in the first statement after your `binding.pry`. ```ruby def some_method puts 'Hello World' # Run 'step' in the console to move here end binding.pry some_method # Execution will stop here. puts 'Goodbye World' # Run 'next' in the console to move here. ``` ## Requirements MRI 2.4.0 or higher. ## Installation Add ```ruby gem 'pry-byebug' ``` to your Gemfile and run ```console bundle install ``` Make sure you include the gem globally or inside the `:test` group if you plan to use it to debug your tests! ## Commands ### Step-by-step debugging **break:** Manage breakpoints. **step:** Step execution into the next line or method. Takes an optional numeric argument to step multiple times. **next:** Step over to the next line within the same frame. Also takes an optional numeric argument to step multiple lines. **finish:** Execute until current stack frame returns. **continue:** Continue program execution and end the Pry session. ### Callstack navigation **backtrace:** Shows the current stack. You can use the numbers on the left side with the `frame` command to navigate the stack. **up:** Moves the stack frame up. Takes an optional numeric argument to move multiple frames. **down:** Moves the stack frame down. Takes an optional numeric argument to move multiple frames. **frame:** Moves to a specific frame. Called without arguments will show the current frame. ## Matching Byebug Behaviour If you're coming from Byebug or from Pry-Byebug versions previous to 3.0, you may be lacking the 'n', 's', 'c' and 'f' aliases for the stepping commands. These aliases were removed by default because they usually conflict with scratch variable names. But it's very easy to reenable them if you still want them, just add the following shortcuts to your `~/.pryrc` file: ```ruby if defined?(PryByebug) Pry.commands.alias_command 'c', 'continue' Pry.commands.alias_command 's', 'step' Pry.commands.alias_command 'n', 'next' Pry.commands.alias_command 'f', 'finish' end ``` Also, you might find useful as well the repeat the last command by just hitting the `Enter` key (e.g., with `step` or `next`). To achieve that, add this to your `~/.pryrc` file: ```ruby # Hit Enter to repeat last command Pry::Commands.command /^$/, "repeat last command" do pry_instance.run_command Pry.history.to_a.last end ``` ## Breakpoints You can set and adjust breakpoints directly from a Pry session using the `break` command: **break:** Set a new breakpoint from a line number in the current file, a file and line number, or a method. Pass an optional expression to create a conditional breakpoint. Edit existing breakpoints via various flags. Examples: ```ruby break SomeClass#run # Break at the start of `SomeClass#run`. break Foo#bar if baz? # Break at `Foo#bar` only if `baz?`. break app/models/user.rb:15 # Break at line 15 in user.rb. break 14 # Break at line 14 in the current file. break --condition 4 x > 2 # Change condition on breakpoint #4 to 'x > 2'. break --condition 3 # Remove the condition on breakpoint #3. break --delete 5 # Delete breakpoint #5. break --disable-all # Disable all breakpoints. break # List all breakpoints. break --show 2 # Show details about breakpoint #2. ``` Type `break --help` from a Pry session to see all available options. ## Alternatives Note that all of the alternatives here are incompatible with pry-byebug. If your platform is supported by pry-byebug, you should remove any of the gems mentioned here if they are present in your Gemfile. * [pry-debugger]: Provides step-by-step debugging for MRI 1.9.3 or older rubies. If you're still using those and need a step-by-step debugger to help with the upgrade, pry-debugger can be handy. * [pry-stack_explorer]: Provides stack navigation capabilities for MRI 1.9.3 or older rubies. If you're still using those and need to navigate your stack to help with the upgrade, pry-stack_explorer can be handy. * [pry-nav]: Provides step-by-step debugging for JRuby. ## Contribute See [Getting Started with Development](CONTRIBUTING.md). ## Funding Subscribe to [Tidelift] to ensure pry-byebug stays actively maintained, and at the same time get licensing assurances and timely security notifications for your open source dependencies. You can also help `pry-byebug` by leaving a small (or big) tip through [Liberapay]. [Tidelift]: https://tidelift.com/subscription/pkg/rubygems-pry-byebug?utm_source=rubygems-pry-byebug&utm_medium=referral&utm_campaign=readme [Liberapay]: https://liberapay.com/pry-byebug/donate ## Security contact information Please use the Tidelift security contact to [report a security vulnerability]. Tidelift will coordinate the fix and disclosure. [report a security vulnerability]: https://tidelift.com/security ## Credits * Gopal Patel (@nixme), creator of [pry-debugger], and everybody who contributed to it. pry-byebug is a fork of pry-debugger so it wouldn't exist as it is without those contributions. * John Mair (@banister), creator of [pry]. Patches and bug reports are welcome. [pry]: https://pry.github.io [byebug]: https://github.com/deivid-rodriguez/byebug [pry-debugger]: https://github.com/nixme/pry-debugger [pry-nav]: https://github.com/nixme/pry-nav [pry-stack_explorer]: https://github.com/pry/pry-stack_explorer [VersionBadge]: https://badge.fury.io/rb/pry-byebug.svg [VersionURL]: http://badge.fury.io/rb/pry-byebug [CIBadge]: https://github.com/deivid-rodriguez/pry-byebug/workflows/ubuntu/badge.svg?branch=master [CIURL]: https://github.com/deivid-rodriguez/pry-byebug/actions?query=workflow%3Aubuntu [InchCIBadge]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug.svg?branch=master [InchCIURL]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug pry-byebug-3.10.1/CHANGELOG.md0000644000004100000410000000773514527327376015556 0ustar www-datawww-data# CHANGELOG ## Master (Unreleased) ## 3.10.1 (2022-08-16) ### Fixed * Rails console loading a debugger REPL instead of the standard Pry REPL (#392) ## 3.10.0 (2022-08-15) ### Added * Support for pry 0.14 (#346, #386). NOTE: pry-byebug now needs to be explicitly required from `~/.pryrc` since plugin autoloading has been removed from Pry. ### Removed * Support for Ruby 2.4, 2.5, and 2.6. Pry-byebug no longer installs on these platforms (#380). ## 3.9.0 (2020-03-21) ### Fixed * Dependency on pry being too loose. Now breaking minor releases of pry won't affect pry-byebug users (#289). ### Added * Support for pry 0.13.0 (#266). ### Removed * Support for pry older than 0.13.0 (#289). ## 3.8.0 (2020-01-22) ### Fixed * Use `Binding#source_location` instead of evaluating `__FILE__` to avoid warnings on Ruby 2.7 and on Ruby 2.6 in verbose mode (#221). ### Removed * Support for Ruby 2.3. Pry-byebug no longer installs on this platform. ## 3.7.0 (2019-02-21) * Byebug 11 compatibility, with ruby 2.6 support. ## 3.6.0 (2018-02-07) ### Added * Byebug 10 compatibility, with ruby 2.5 support. ## 3.5.1 (2017-11-27) ### Fixed * Allow other threads like Pry (#142). ## 3.5.0 (2017-08-23) ### Added * Byebug 9.1 support. As a result, Ruby 2.0 & Ruby 2.1 support has been dropped. Pry-byebug no longer installs on these platforms. ## 3.4.3 (2017-08-22) ### Fixed * Installation on old rubies after byebug dropping support for them. ## 3.4.2 (2016-12-06) ### Fixed * Byebug doesn't start after `disable-pry` command. ## 3.4.1 (2016-11-22) ### Fixed * control_d handler not being required properly when `pry-byebug` loaded as a `pry` plugin and not through explicit require. ## 3.4.0 (2016-05-15) ### Fixed * Byebug 9 compatibility. ### Added * A new `backtrace` command. ## 3.3.0 (2015-11-05) ### Fixed * Byebug 8 compatibility. * Fix encoding error in gemspec file (#70). * Debugger being too slow (#80, thanks @k0kubun). ## 3.2.0 (2015-07-18) ### Added * `continue` can now receive a line number argument (#56). ### Fixed * Conflicts with `break` and `next` Ruby keywords inside multiline statements (#44). ### Removed * `breaks` command. It was broken anyways (#47). ## 3.1.0 (2015-04-14) ### Added * Frame navigation commands `up`, `down` and `frame`. ## 3.0.1 (2015-04-02) ### Fixed * Several formatting and alignment issues. ## 3.0.0 (2015-02-02) ### Fixed * `binding.pry` would not stop at the correct place when called at the last line of a method/block. ### Removed * Stepping aliases for `next` (`n`), `step` (`s`), `finish` (`f`) and `continue` (`c`). See #34. ## 2.0.0 (2014-01-09) ### Fixed * Byebug 3 compatibility. * Pry not starting at the first line after `binding.pry` but at `binding.pry`. * `continue` not finishing pry instance (#13). ## 1.3.3 (2014-25-06) ### Fixed * Pry 0.10 series and further minor version level releases compatibility. ## 1.3.2 (2014-24-02) ### Fixed * Bug inherited from `byebug`. ## 1.3.1 (2014-08-02) ### Fixed * Bug #22 (thanks @andreychernih). ## 1.3.0 (2014-05-02) ### Added * Breakpoints on method names (thanks @andreychernih & @palkan). ### Fixed * "Undefined method `interface`" error (huge thanks to @andreychernih). ## 1.2.1 (2013-30-12) ### Fixed * "Uncaught throw :breakout_nav" error (thanks @lukebergen). ## 1.2.0 (2013-24-09) ### Fixed * Compatibility with byebug's 2.x series ## 1.1.2 (2013-11-07) ### Fixed * Compatibility with backwards compatible byebug versions. ## 1.1.1 (2013-02-07) ### Fixed * Bug when doing `step n` or `next n` where n > 1 right after `binding.pry`. ## 1.1.0 (2013-06-06) ### Added * `s`, `n`, `f` and `c` aliases (thanks @jgakos!). ## 1.0.1 (2013-05-07) ### Fixed * Unwanted debugging printf. ## 1.0.0 (2013-05-07) ### Added * Initial release forked from [pry-debugger](https://github.com/nixme/pry-debugger) to support byebug. ### Removed * pry-remote support. ## Older releases * Check [pry-debugger](https://github.com/nixme/pry-debugger)'s CHANGELOG. pry-byebug-3.10.1/LICENSE0000644000004100000410000000211714527327376014737 0ustar www-datawww-dataMIT License Copyright (c) 2018 David Rodríguez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pry-byebug-3.10.1/pry-byebug.gemspec0000644000004100000410000000477014527327376017373 0ustar www-datawww-data######################################################### # This file has been automatically generated by gem2tgz # ######################################################### # -*- encoding: utf-8 -*- # stub: pry-byebug 3.10.1 ruby lib Gem::Specification.new do |s| s.name = "pry-byebug".freeze s.version = "3.10.1" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["David Rodr\u00EDguez".freeze, "Gopal Patel".freeze] s.date = "2022-08-16" s.description = "Combine 'pry' with 'byebug'. Adds 'step', 'next', 'finish',\n 'continue' and 'break' commands to control execution.".freeze s.email = "deivid.rodriguez@gmail.com".freeze s.extra_rdoc_files = ["CHANGELOG.md".freeze, "README.md".freeze] s.files = ["CHANGELOG.md".freeze, "LICENSE".freeze, "README.md".freeze, "lib/byebug/processors/pry_processor.rb".freeze, "lib/pry-byebug.rb".freeze, "lib/pry-byebug/base.rb".freeze, "lib/pry-byebug/cli.rb".freeze, "lib/pry-byebug/commands.rb".freeze, "lib/pry-byebug/commands/backtrace.rb".freeze, "lib/pry-byebug/commands/breakpoint.rb".freeze, "lib/pry-byebug/commands/continue.rb".freeze, "lib/pry-byebug/commands/down.rb".freeze, "lib/pry-byebug/commands/exit_all.rb".freeze, "lib/pry-byebug/commands/finish.rb".freeze, "lib/pry-byebug/commands/frame.rb".freeze, "lib/pry-byebug/commands/next.rb".freeze, "lib/pry-byebug/commands/step.rb".freeze, "lib/pry-byebug/commands/up.rb".freeze, "lib/pry-byebug/control_d_handler.rb".freeze, "lib/pry-byebug/helpers/breakpoints.rb".freeze, "lib/pry-byebug/helpers/location.rb".freeze, "lib/pry-byebug/helpers/multiline.rb".freeze, "lib/pry-byebug/helpers/navigation.rb".freeze, "lib/pry-byebug/pry_ext.rb".freeze, "lib/pry-byebug/pry_remote_ext.rb".freeze, "lib/pry-byebug/version.rb".freeze, "lib/pry/byebug/breakpoints.rb".freeze] s.homepage = "https://github.com/deivid-rodriguez/pry-byebug".freeze s.licenses = ["MIT".freeze] s.required_ruby_version = Gem::Requirement.new(">= 2.7.0".freeze) s.rubygems_version = "3.3.15".freeze s.summary = "Fast debugging with Pry.".freeze if s.respond_to? :specification_version then s.specification_version = 4 end if s.respond_to? :add_runtime_dependency then s.add_runtime_dependency(%q.freeze, ["~> 11.0"]) s.add_runtime_dependency(%q.freeze, [">= 0.13", "< 0.15"]) else s.add_dependency(%q.freeze, ["~> 11.0"]) s.add_dependency(%q.freeze, [">= 0.13", "< 0.15"]) end end pry-byebug-3.10.1/lib/0000755000004100000410000000000014527327376014477 5ustar www-datawww-datapry-byebug-3.10.1/lib/pry-byebug.rb0000644000004100000410000000010614527327376017106 0ustar www-datawww-data# frozen_string_literal: true require "pry" require "pry-byebug/cli" pry-byebug-3.10.1/lib/pry-byebug/0000755000004100000410000000000014527327376016564 5ustar www-datawww-datapry-byebug-3.10.1/lib/pry-byebug/pry_remote_ext.rb0000644000004100000410000000211714527327376022157 0ustar www-datawww-data# frozen_string_literal: true require "pry-remote" module PryRemote # # Overrides PryRemote::Server # class Server # # Override the call to Pry.start to save off current Server, and not # teardown the server right after Pry.start finishes. # def run raise("Already running a pry-remote session!") if PryByebug.current_remote_server PryByebug.current_remote_server = self setup Pry.start @object, input: client.input_proxy, output: client.output end # # Override to reset our saved global current server session. # alias teardown_without_pry_byebug teardown def teardown_with_pry_byebug return if @torn teardown_without_pry_byebug PryByebug.current_remote_server = nil @torn = true end alias teardown teardown_with_pry_byebug end end # Ensure cleanup when a program finishes without another break. For example, # 'next' on the last line of a program won't hit Byebug::PryProcessor#run, # which normally handles cleanup. at_exit do PryByebug.current_remote_server&.teardown end pry-byebug-3.10.1/lib/pry-byebug/version.rb0000644000004100000410000000020214527327376020570 0ustar www-datawww-data# frozen_string_literal: true # # Main container module for Pry-Byebug functionality # module PryByebug VERSION = "3.10.1" end pry-byebug-3.10.1/lib/pry-byebug/pry_ext.rb0000644000004100000410000000077614527327376020615 0ustar www-datawww-data# frozen_string_literal: true require "byebug/processors/pry_processor" class << Pry::REPL alias start_without_pry_byebug start def start_with_pry_byebug(options = {}) target = options[:target] if target.is_a?(Binding) && PryByebug.file_context?(target) Byebug::PryProcessor.start unless ENV["DISABLE_PRY"] else # No need for the tracer unless we have a file context to step through start_without_pry_byebug(options) end end alias start start_with_pry_byebug end pry-byebug-3.10.1/lib/pry-byebug/helpers/0000755000004100000410000000000014527327376020226 5ustar www-datawww-datapry-byebug-3.10.1/lib/pry-byebug/helpers/breakpoints.rb0000644000004100000410000000363314527327376023101 0ustar www-datawww-data# frozen_string_literal: true require "byebug" module PryByebug module Helpers # # Common helpers for breakpoint related commands # module Breakpoints # # Byebug's array of breakpoints. # def breakpoints Pry::Byebug::Breakpoints end # # Prints a message with bold font. # def bold_puts(msg) output.puts(bold(msg)) end # # Print out full information about a breakpoint. # # Includes surrounding code at that point. # def print_full_breakpoint(breakpoint) header = "Breakpoint #{breakpoint.id}:" status = breakpoint.enabled? ? "Enabled" : "Disabled" code = breakpoint.source_code.with_line_numbers.to_s condition = if breakpoint.expr "#{bold('Condition:')} #{breakpoint.expr}\n" else "" end output.puts <<-BREAKPOINT.gsub(/ {8}/, "") #{bold(header)} #{breakpoint} (#{status}) #{condition} #{code} BREAKPOINT end # # Print out concise information about a breakpoint. # def print_short_breakpoint(breakpoint) id = format("%*d", max_width, breakpoint.id) status = breakpoint.enabled? ? "Yes" : "No " expr = breakpoint.expr ? " #{breakpoint.expr} " : "" output.puts(" #{id} #{status} #{breakpoint}#{expr}") end # # Prints a header for the breakpoint list. # def print_breakpoints_header header = "#{' ' * (max_width - 1)}# Enabled At " output.puts <<-BREAKPOINTS.gsub(/ {8}/, "") #{bold(header)} #{bold('-' * header.size)} BREAKPOINTS end # # Max width of breakpoints id column # def max_width breakpoints.last ? breakpoints.last.id.to_s.length : 1 end end end end pry-byebug-3.10.1/lib/pry-byebug/helpers/location.rb0000644000004100000410000000115314527327376022363 0ustar www-datawww-data# frozen_string_literal: true module PryByebug module Helpers # # Compatibility helper to handle source location # module Location module_function # # Current file in the target binding. Used as the default breakpoint # location. # def current_file(source = target) # Guard clause for Ruby >= 2.6 providing now Binding#source_location ... return source.source_location[0] if source.respond_to?(:source_location) # ... to avoid warning: 'eval may not return location in binding' source.eval("__FILE__") end end end end pry-byebug-3.10.1/lib/pry-byebug/helpers/multiline.rb0000644000004100000410000000103214527327376022551 0ustar www-datawww-data# frozen_string_literal: true module PryByebug module Helpers # # Helpers to help handling multiline inputs # module Multiline # # Returns true if we are in a multiline context and, as a side effect, # updates the partial evaluation string with the current input. # # Returns false otherwise # def check_multiline_context return false if eval_string.empty? eval_string.replace("#{eval_string}#{match} #{arg_string}\n") true end end end end pry-byebug-3.10.1/lib/pry-byebug/helpers/navigation.rb0000644000004100000410000000065014527327376022713 0ustar www-datawww-data# frozen_string_literal: true module PryByebug module Helpers # # Helpers to aid breaking out of the REPL loop # module Navigation # # Breaks out of the REPL loop and signals tracer # def breakout_navigation(action, options = {}) pry_instance.binding_stack.clear throw :breakout_nav, action: action, options: options, pry: pry_instance end end end end pry-byebug-3.10.1/lib/pry-byebug/base.rb0000644000004100000410000000140214527327376020020 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/location" # # Main container module for Pry-Byebug functionality # module PryByebug # Reference to currently running pry-remote server. Used by the processor. attr_accessor :current_remote_server module_function # # Checks that a target binding is in a local file context. # def file_context?(target) file = Helpers::Location.current_file(target) file == Pry.eval_path || !Pry::Helpers::BaseHelpers.not_a_real_file?(file) end # # Ensures that a command is executed in a local file context. # def check_file_context(target, msg = nil) msg ||= "Cannot find local context. Did you use `binding.pry`?" raise(Pry::CommandError, msg) unless file_context?(target) end end pry-byebug-3.10.1/lib/pry-byebug/control_d_handler.rb0000644000004100000410000000032414527327376022570 0ustar www-datawww-data# frozen_string_literal: true original_handler = Pry.config.control_d_handler Pry.config.control_d_handler = proc do |pry_instance| Byebug.stop if Byebug.stoppable? original_handler.call(pry_instance) end pry-byebug-3.10.1/lib/pry-byebug/cli.rb0000644000004100000410000000023314527327376017656 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/base" require "pry-byebug/pry_ext" require "pry-byebug/commands" require "pry-byebug/control_d_handler" pry-byebug-3.10.1/lib/pry-byebug/commands.rb0000644000004100000410000000062114527327376020711 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/commands/backtrace" require "pry-byebug/commands/next" require "pry-byebug/commands/step" require "pry-byebug/commands/continue" require "pry-byebug/commands/finish" require "pry-byebug/commands/up" require "pry-byebug/commands/down" require "pry-byebug/commands/frame" require "pry-byebug/commands/breakpoint" require "pry-byebug/commands/exit_all" pry-byebug-3.10.1/lib/pry-byebug/commands/0000755000004100000410000000000014527327376020365 5ustar www-datawww-datapry-byebug-3.10.1/lib/pry-byebug/commands/breakpoint.rb0000644000004100000410000001031214527327376023045 0ustar www-datawww-data# frozen_string_literal: true require "pry/byebug/breakpoints" require "pry-byebug/helpers/breakpoints" require "pry-byebug/helpers/location" require "pry-byebug/helpers/multiline" module PryByebug # # Add, show and remove breakpoints # class BreakCommand < Pry::ClassCommand include Helpers::Breakpoints include Helpers::Location include Helpers::Multiline match "break" group "Byebug" description "Set or edit a breakpoint." banner <<-BANNER Usage: break [if CONDITION] break --condition N [CONDITION] break [--show | --delete | --enable | --disable] N break [--delete-all | --disable-all] break Set a breakpoint. Accepts a line number in the current file, a file and line number, or a method, and an optional condition. Pass appropriate flags to manipulate existing breakpoints. Examples: break SomeClass#run Break at the start of `SomeClass#run`. break Foo#bar if baz? Break at `Foo#bar` only if `baz?`. break app/models/user.rb:15 Break at line 15 in user.rb. break 14 Break at line 14 in the current file. break --condition 4 x > 2 Add/change condition on breakpoint #4. break --condition 3 Remove the condition on breakpoint #3. break --delete 5 Delete breakpoint #5. break --disable-all Disable all breakpoints. break --show 2 Show details about breakpoint #2. break List all breakpoints. BANNER def options(opt) defaults = { argument: true, as: Integer } opt.on :c, :condition, "Change condition of a breakpoint.", defaults opt.on :s, :show, "Show breakpoint details and source.", defaults opt.on :D, :delete, "Delete a breakpoint.", defaults opt.on :d, :disable, "Disable a breakpoint.", defaults opt.on :e, :enable, "Enable a disabled breakpoint.", defaults opt.on :'disable-all', "Disable all breakpoints." opt.on :'delete-all', "Delete all breakpoints." end def process return if check_multiline_context PryByebug.check_file_context(target) option, = opts.to_hash.find { |key, _value| opts.present?(key) } return send(option_to_method(option)) if option return new_breakpoint unless args.empty? print_all end private %w[delete disable enable disable_all delete_all].each do |command| define_method(:"process_#{command}") do breakpoints.send(*[command, opts[command]].compact) print_all end end def process_show print_full_breakpoint(breakpoints.find_by_id(opts[:show])) end def process_condition expr = args.empty? ? nil : args.join(" ") breakpoints.change(opts[:condition], expr) end def new_breakpoint place = args.shift condition = args.join(" ") if args.shift == "if" bp = add_breakpoint(place, condition) print_full_breakpoint(bp) end def option_to_method(option) "process_#{option.to_s.tr('-', '_')}" end def print_all print_breakpoints_header breakpoints.each { |b| print_short_breakpoint(b) } end def add_breakpoint(place, condition) case place when /^(\d+)$/ errmsg = "Line number declaration valid only in a file context." PryByebug.check_file_context(target, errmsg) lineno = Regexp.last_match[1].to_i breakpoints.add_file(current_file, lineno, condition) when /^(.+):(\d+)$/ file = Regexp.last_match[1] lineno = Regexp.last_match[2].to_i breakpoints.add_file(file, lineno, condition) when /^(.*)[.#].+$/ # Method or class name if Regexp.last_match[1].strip.empty? errmsg = "Method name declaration valid only in a file context." PryByebug.check_file_context(target, errmsg) place = target.eval("self.class.to_s") + place end breakpoints.add_method(place, condition) else raise(ArgumentError, "Cannot identify arguments as breakpoint") end end end end Pry::Commands.add_command(PryByebug::BreakCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/up.rb0000644000004100000410000000121614527327376021336 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Travel up the frame stack # class UpCommand < Pry::ClassCommand include Helpers::Navigation match "up" group "Byebug" description "Move current frame up." banner <<-BANNER Usage: up [TIMES] Move current frame up. By default, moves by 1 frame. Examples: up #=> Move up 1 frame. up 5 #=> Move up 5 frames. BANNER def process PryByebug.check_file_context(target) breakout_navigation :up, times: args.first end end end Pry::Commands.add_command(PryByebug::UpCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/step.rb0000644000004100000410000000135414527327376021670 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Run a number of Ruby statements and then stop again # class StepCommand < Pry::ClassCommand include Helpers::Navigation match "step" group "Byebug" description "Step execution into the next line or method." banner <<-BANNER Usage: step [TIMES] Step execution forward. By default, moves a single step. Examples: step #=> Move a single step forward. step 5 #=> Execute the next 5 steps. BANNER def process PryByebug.check_file_context(target) breakout_navigation :step, times: args.first end end end Pry::Commands.add_command(PryByebug::StepCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/next.rb0000644000004100000410000000154714527327376021677 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/navigation" require "pry-byebug/helpers/multiline" module PryByebug # # Run a number of lines and then stop again # class NextCommand < Pry::ClassCommand include Helpers::Navigation include Helpers::Multiline match "next" group "Byebug" description "Execute the next line within the current stack frame." banner <<-BANNER Usage: next [LINES] Step over within the same frame. By default, moves forward a single line. Examples: next #=> Move a single line forward. next 4 #=> Execute the next 4 lines. BANNER def process return if check_multiline_context PryByebug.check_file_context(target) breakout_navigation :next, lines: args.first end end end Pry::Commands.add_command(PryByebug::NextCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/frame.rb0000644000004100000410000000125314527327376022005 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Move to a specific frame in the callstack # class FrameCommand < Pry::ClassCommand include Helpers::Navigation match "frame" group "Byebug" description "Move to specified frame #." banner <<-BANNER Usage: frame [TIMES] Move to specified frame #. Examples: frame #=> Show current frame #. frame 5 #=> Move to frame 5. BANNER def process PryByebug.check_file_context(target) breakout_navigation :frame, index: args.first end end end Pry::Commands.add_command(PryByebug::FrameCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/down.rb0000644000004100000410000000124614527327376021664 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Travel down the frame stack # class DownCommand < Pry::ClassCommand include Helpers::Navigation match "down" group "Byebug" description "Move current frame down." banner <<-BANNER Usage: down [TIMES] Move current frame down. By default, moves by 1 frame. Examples: down #=> Move down 1 frame. down 5 #=> Move down 5 frames. BANNER def process PryByebug.check_file_context(target) breakout_navigation :down, times: args.first end end end Pry::Commands.add_command(PryByebug::DownCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/exit_all.rb0000644000004100000410000000050114527327376022507 0ustar www-datawww-data# frozen_string_literal: true require "pry/commands/exit_all" module PryByebug # # Exit pry REPL with Byebug.stop # class ExitAllCommand < Pry::Command::ExitAll def process super ensure Byebug.stop if Byebug.stoppable? end end end Pry::Commands.add_command(PryByebug::ExitAllCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/backtrace.rb0000644000004100000410000000105214527327376022627 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Display the current stack # class BacktraceCommand < Pry::ClassCommand include Helpers::Navigation match "backtrace" group "Byebug" description "Display the current stack." banner <<-BANNER Usage: backtrace Display the current stack. BANNER def process PryByebug.check_file_context(target) breakout_navigation :backtrace end end end Pry::Commands.add_command(PryByebug::BacktraceCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/continue.rb0000644000004100000410000000211614527327376022536 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/navigation" require "pry-byebug/helpers/breakpoints" require "pry-byebug/helpers/location" module PryByebug # # Continue program execution until the next breakpoint # class ContinueCommand < Pry::ClassCommand include Helpers::Navigation include Helpers::Breakpoints include Helpers::Location match "continue" group "Byebug" description "Continue program execution and end the Pry session." banner <<-BANNER Usage: continue [LINE] Continue program execution until the next breakpoint, or the program ends. Optionally continue to the specified line number. Examples: continue #=> Continue until the next breakpoint. continue 4 #=> Continue to line number 4. BANNER def process PryByebug.check_file_context(target) breakpoints.add_file(current_file, args.first.to_i) if args.first breakout_navigation :continue ensure Byebug.stop if Byebug.stoppable? end end end Pry::Commands.add_command(PryByebug::ContinueCommand) pry-byebug-3.10.1/lib/pry-byebug/commands/finish.rb0000644000004100000410000000103414527327376022170 0ustar www-datawww-data# frozen_string_literal: true require "pry-byebug/helpers/navigation" module PryByebug # # Run until the end of current frame # class FinishCommand < Pry::ClassCommand include PryByebug::Helpers::Navigation match "finish" group "Byebug" description "Execute until current stack frame returns." banner <<-BANNER Usage: finish BANNER def process PryByebug.check_file_context(target) breakout_navigation :finish end end end Pry::Commands.add_command(PryByebug::FinishCommand) pry-byebug-3.10.1/lib/byebug/0000755000004100000410000000000014527327376015754 5ustar www-datawww-datapry-byebug-3.10.1/lib/byebug/processors/0000755000004100000410000000000014527327376020156 5ustar www-datawww-datapry-byebug-3.10.1/lib/byebug/processors/pry_processor.rb0000644000004100000410000000650514527327376023422 0ustar www-datawww-data# frozen_string_literal: true require "byebug/core" module Byebug # # Extends raw byebug's processor. # class PryProcessor < CommandProcessor attr_accessor :pry extend Forwardable def_delegators :@pry, :output def_delegators Pry::Helpers::Text, :bold def self.start Byebug.start Setting[:autolist] = false Context.processor = self Byebug.current_context.step_out(5, true) end # # Wrap a Pry REPL to catch navigational commands and act on them. # def run(&_block) return_value = nil command = catch(:breakout_nav) do # Throws from PryByebug::Commands return_value = allowing_other_threads { yield } {} # Nothing thrown == no navigational command end # Pry instance to resume after stepping @pry = command[:pry] perform(command[:action], command[:options]) return_value end # # Set up a number of navigational commands to be performed by Byebug. # def perform(action, options = {}) return unless %i[ backtrace down finish frame next step up ].include?(action) send("perform_#{action}", options) end # --- Callbacks from byebug C extension --- # # Called when the debugger wants to stop at a regular line # def at_line resume_pry end # # Called when the debugger wants to stop right before a method return # def at_return(_return_value) resume_pry end # # Called when a breakpoint is hit. Note that `at_line`` is called # inmediately after with the context's `stop_reason == :breakpoint`, so we # must not resume the pry instance here # def at_breakpoint(breakpoint) @pry ||= Pry.new output.puts bold("\n Breakpoint #{breakpoint.id}. ") + n_hits(breakpoint) expr = breakpoint.expr return unless expr output.puts bold("Condition: ") + expr end private def n_hits(breakpoint) n_hits = breakpoint.hit_count n_hits == 1 ? "First hit" : "Hit #{n_hits} times." end # # Resume an existing Pry REPL at the paused point. # def resume_pry new_binding = frame._binding run do if defined?(@pry) && @pry @pry.repl(new_binding) else @pry = Pry::REPL.start_without_pry_byebug(target: new_binding) end end end def perform_backtrace(_options) Byebug::WhereCommand.new(self, "backtrace").execute resume_pry end def perform_next(options) lines = (options[:lines] || 1).to_i context.step_over(lines, frame.pos) end def perform_step(options) times = (options[:times] || 1).to_i context.step_into(times, frame.pos) end def perform_finish(*) context.step_out(1) end def perform_up(options) times = (options[:times] || 1).to_i Byebug::UpCommand.new(self, "up #{times}").execute resume_pry end def perform_down(options) times = (options[:times] || 1).to_i Byebug::DownCommand.new(self, "down #{times}").execute resume_pry end def perform_frame(options) index = options[:index] ? options[:index].to_i : "" Byebug::FrameCommand.new(self, "frame #{index}").execute resume_pry end end end pry-byebug-3.10.1/lib/pry/0000755000004100000410000000000014527327376015311 5ustar www-datawww-datapry-byebug-3.10.1/lib/pry/byebug/0000755000004100000410000000000014527327376016566 5ustar www-datawww-datapry-byebug-3.10.1/lib/pry/byebug/breakpoints.rb0000644000004100000410000000712014527327376021434 0ustar www-datawww-data# frozen_string_literal: true class Pry module Byebug # # Wrapper for Byebug.breakpoints that respects our Processor and has better # failure behavior. Acts as an Enumerable. # module Breakpoints extend Enumerable extend self # # Breakpoint in a file:line location # class FileBreakpoint < SimpleDelegator def source_code Pry::Code.from_file(source).around(pos, 3).with_marker(pos) end def to_s "#{source} @ #{pos}" end end # # Breakpoint in a Class#method location # class MethodBreakpoint < SimpleDelegator def initialize(byebug_bp, method) __setobj__ byebug_bp @method = method end def source_code Pry::Code.from_method(Pry::Method.from_str(@method)) end def to_s @method end end def breakpoints @breakpoints ||= [] end # # Adds a method breakpoint. # def add_method(method, expression = nil) validate_expression expression owner, name = method.split(/[\.#]/) byebug_bp = ::Byebug::Breakpoint.add(owner, name.to_sym, expression) bp = MethodBreakpoint.new byebug_bp, method breakpoints << bp bp end # # Adds a file breakpoint. # def add_file(file, line, expression = nil) real_file = (file != Pry.eval_path) raise(ArgumentError, "Invalid file!") if real_file && !File.exist?(file) validate_expression expression path = (real_file ? File.expand_path(file) : file) bp = FileBreakpoint.new ::Byebug::Breakpoint.add(path, line, expression) breakpoints << bp bp end # # Changes the conditional expression for a breakpoint. # def change(id, expression = nil) validate_expression expression breakpoint = find_by_id(id) breakpoint.expr = expression breakpoint end # # Deletes an existing breakpoint with the given ID. # def delete(id) deleted = ::Byebug::Breakpoint.remove(id) && breakpoints.delete(find_by_id(id)) raise(ArgumentError, "No breakpoint ##{id}") unless deleted end # # Deletes all breakpoints. # def delete_all @breakpoints = [] ::Byebug.breakpoints.clear end # # Enables a disabled breakpoint with the given ID. # def enable(id) change_status id, true end # # Disables a breakpoint with the given ID. # def disable(id) change_status id, false end # # Disables all breakpoints. # def disable_all each do |breakpoint| breakpoint.enabled = false end end def to_a breakpoints end def size to_a.size end def each(&block) to_a.each(&block) end def last to_a.last end def find_by_id(id) breakpoint = find { |b| b.id == id } raise(ArgumentError, "No breakpoint ##{id}!") unless breakpoint breakpoint end private def change_status(id, enabled = true) breakpoint = find_by_id(id) breakpoint.enabled = enabled breakpoint end def validate_expression(exp) valid = exp && (exp.empty? || !Pry::Code.complete_expression?(exp)) return unless valid raise("Invalid breakpoint conditional: #{expression}") end end end end