ruby-changes:68251
From: Koichi <ko1@a...>
Date: Tue, 5 Oct 2021 02:07:49 +0900 (JST)
Subject: [ruby-changes:68251] ae1da7e1f7 (master): remove lib/debug.rb
https://git.ruby-lang.org/ruby.git/commit/?id=ae1da7e1f7 From ae1da7e1f76cabc6c2d9b45a6c56b1607200147a Mon Sep 17 00:00:00 2001 From: Koichi Sasada <ko1@a...> Date: Fri, 1 Oct 2021 02:56:59 +0900 Subject: remove lib/debug.rb --- lib/debug.gemspec | 22 -- lib/debug.rb | 1106 ----------------------------------------------------- 2 files changed, 1128 deletions(-) delete mode 100644 lib/debug.gemspec delete mode 100644 lib/debug.rb diff --git a/lib/debug.gemspec b/lib/debug.gemspec deleted file mode 100644 index 71f93f7409..0000000000 --- a/lib/debug.gemspec +++ /dev/null @@ -1,22 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/#L0 -Gem::Specification.new do |spec| - spec.name = "debug" - spec.version = "0.1.0" - spec.authors = ["Yukihiro Matsumoto"] - spec.email = ["matz@r..."] - - spec.summary = %q{Debugging functionality for Ruby} - spec.description = %q{Debugging functionality for Ruby} - spec.homepage = "https://github.com/ruby/debug" - spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") - spec.licenses = ["Ruby", "BSD-2-Clause"] - - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = spec.homepage - - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] -end diff --git a/lib/debug.rb b/lib/debug.rb deleted file mode 100644 index bf53eb80a4..0000000000 --- a/lib/debug.rb +++ /dev/null @@ -1,1106 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/#L0 -# frozen_string_literal: true -# Copyright (C) 2000 Network Applied Communication Laboratory, Inc. -# Copyright (C) 2000 Information-technology Promotion Agency, Japan -# Copyright (C) 2000-2003 NAKAMURA, Hiroshi <nahi@r...> - -require 'continuation' - -require 'tracer' -require 'pp' - -class Tracer # :nodoc: - def Tracer.trace_func(*vars) - Single.trace_func(*vars) - end -end - -SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__ # :nodoc: - -## -# This library provides debugging functionality to Ruby. -# -# To add a debugger to your code, start by requiring +debug+ in your -# program: -# -# def say(word) -# require 'debug' -# puts word -# end -# -# This will cause Ruby to interrupt execution and show a prompt when the +say+ -# method is run. -# -# Once you're inside the prompt, you can start debugging your program. -# -# (rdb:1) p word -# "hello" -# -# == Getting help -# -# You can get help at any time by pressing +h+. -# -# (rdb:1) h -# Debugger help v.-0.002b -# Commands -# b[reak] [file:|class:]<line|method> -# b[reak] [class.]<line|method> -# set breakpoint to some position -# wat[ch] <expression> set watchpoint to some expression -# cat[ch] (<exception>|off) set catchpoint to an exception -# b[reak] list breakpoints -# cat[ch] show catchpoint -# del[ete][ nnn] delete some or all breakpoints -# disp[lay] <expression> add expression into display expression list -# undisp[lay][ nnn] delete one particular or all display expressions -# c[ont] run until program ends or hit breakpoint -# s[tep][ nnn] step (into methods) one line or till line nnn -# n[ext][ nnn] go over one line or till line nnn -# w[here] display frames -# f[rame] alias for where -# l[ist][ (-|nn-mm)] list program, - lists backwards -# nn-mm lists given lines -# up[ nn] move to higher frame -# down[ nn] move to lower frame -# fin[ish] return to outer frame -# tr[ace] (on|off) set trace mode of current thread -# tr[ace] (on|off) all set trace mode of all threads -# q[uit] exit from debugger -# v[ar] g[lobal] show global variables -# v[ar] l[ocal] show local variables -# v[ar] i[nstance] <object> show instance variables of object -# v[ar] c[onst] <object> show constants of object -# m[ethod] i[nstance] <obj> show methods of object -# m[ethod] <class|module> show instance methods of class or module -# th[read] l[ist] list all threads -# th[read] c[ur[rent]] show current thread -# th[read] [sw[itch]] <nnn> switch thread context to nnn -# th[read] stop <nnn> stop thread nnn -# th[read] resume <nnn> resume thread nnn -# p expression evaluate expression and print its value -# h[elp] print this help -# <everything else> evaluate -# -# == Usage -# -# The following is a list of common functionalities that the debugger -# provides. -# -# === Navigating through your code -# -# In general, a debugger is used to find bugs in your program, which -# often means pausing execution and inspecting variables at some point -# in time. -# -# Let's look at an example: -# -# def my_method(foo) -# require 'debug' -# foo = get_foo if foo.nil? -# raise if foo.nil? -# end -# -# When you run this program, the debugger will kick in just before the -# +foo+ assignment. -# -# (rdb:1) p foo -# nil -# -# In this example, it'd be interesting to move to the next line and -# inspect the value of +foo+ again. You can do that by pressing +n+: -# -# (rdb:1) n # goes to next line -# (rdb:1) p foo -# nil -# -# You now know that the original value of +foo+ was nil, and that it -# still was nil after calling +get_foo+. -# -# Other useful commands for navigating through your code are: -# -# +c+:: -# Runs the program until it either exists or encounters another breakpoint. -# You usually press +c+ when you are finished debugging your program and -# want to resume its execution. -# +s+:: -# Steps into method definition. In the previous example, +s+ would take you -# inside the method definition of +get_foo+. -# +r+:: -# Restart the program. -# +q+:: -# Quit the program. -# -# === Inspecting variables -# -# You can use the debugger to easily inspect both local and global variables. -# We've seen how to inspect local variables before: -# -# (rdb:1) p my_arg -# 42 -# -# You can also pretty print the result of variables or expressions: -# -# (rdb:1) pp %w{a very long long array containing many words} -# ["a", -# "very", -# "long", -# ... -# ] -# -# You can list all local variables with +v l+: -# -# (rdb:1) v l -# foo => "hello" -# -# Similarly, you can show all global variables with +v g+: -# -# (rdb:1) v g -# all global variables -# -# Finally, you can omit +p+ if you simply want to evaluate a variable or -# expression -# -# (rdb:1) 5**2 -# 25 -# -# === Going beyond basics -# -# Ruby Debug provides more advanced functionalities like switching -# between threads, setting breakpoints and watch expressions, and more. -# The full list of commands is available at any time by pressing +h+. -# -# == Staying out of trouble -# -# Make sure you remove every instance of +require 'debug'+ before -# shipping your code. Failing to do so may result in your program -# hanging unpredictably. -# -# Debug is not available in safe mode. - -class DEBUGGER__ - MUTEX = Thread::Mutex.new # :nodoc: - - class Context # :nodoc: - DEBUG_LAST_CMD = [] - - begin - require 'readline' - def readline(prompt, hist) - Readline::readline(prompt, hist) - end - rescue LoadError - def readline(prompt, hist) - STDOUT.print prompt - STDOUT.flush - line = STDIN.gets - exit unless line - line.chomp! - line - end - USE_READLINE = false - end - - def initialize - if Thread.current == Thread.main - @stop_next = 1 - else - @stop_next = 0 - end - @last_file = nil - @file = nil - @line = nil - @no_step = nil - @frames = [] - @finish_pos = 0 - @trace = false - @catch = "StandardError" - @suspend_next = false - end - - def stop_next(n=1) - @stop_next = n - end - - def set_suspend - @suspend_next = true - end - - def clear_suspend - @suspend_next = false - end - - def suspend_all - DEBUGGER__.suspend - end - - def resume_all - DEBUGGER__.resume - end - - def check_suspend - while MUTEX.synchronize { - if @suspend_next - DEBUGGER__.waiting.push Thread.current - @suspend_next = false - true - end - } - end - end - - def trace? - @trace - end - - def set_trace(arg) - @trace = arg - end - - def stdout - DEBUGGER__.stdout - end - - def break_points - DEBUGGER__.break_points - end - - def display - DEBUGGER__.display - end - - def context(th) - DEBUGGER__.context(th) - end - - def set_trace_all(arg) - DEBUGGER__.set_trace(arg) - end - - def set_last_thread(th) - DEBUGGER__.set_last_thread(th) - end - - def debug_eval(str, binding) - begin - eval(str, binding) - rescue StandardError, ScriptError => e - at = eval("caller(1)", binding) - stdout.printf "%s:%s\n", at.shift, e.to_s.sub(/\(eval\):1:(in `.*?':)?/, '') - for i in at - stdout.printf "\tfrom %s\n", i - end - throw :debug_error - end - end - - def debug_silent_eval(str, binding) - begin - eval(str, binding) - rescue StandardError, ScriptError - nil - end - end - - def var_list(ary, binding) - ary.sort! - for v in ary - stdout.printf " %s => %s\n", v, eval(v.to_s, bi (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/