byebug 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 489c114f27cc5006d198149fccf0ff0e6390cd2a
4
- data.tar.gz: be024abb6bfc9d9f989e29e9f97da9cdca1a1daf
3
+ metadata.gz: c36e72ad4ee68660bcdc6d5b7e1b053abe9846c5
4
+ data.tar.gz: efa45e7ec838ec213867c8b1543fef5846589681
5
5
  SHA512:
6
- metadata.gz: da63414df26b9564f6818645b1451f8780fcb324c7b30916675841b053fbfee0070f3e6c0a7d420e21fff5c07a0dd8a7c20b99cf1ed4dbba869d84c4089ea957
7
- data.tar.gz: 4f5c740d9b6ea6e41115b43e982a2a1b1fc28b4c0baefa12ce0c796d005cd23e07df3fc5f43f539a9edc790385a7e4978e06d1dcf065c81f3210c6cc0fa6e37c
6
+ metadata.gz: 796c8e489b574c80dba56c3898ab54831b7ead9fb15579336cbb2331831e52267fce12b0c96aff3c1116ae6ee421bcfdef55c2fb8e81238c2c5dcf85555f4e3a
7
+ data.tar.gz: b665b2c10ad39cec530808dc30a016d45198706c4737d752de4c6557d398626305833e0f4a18bfc1a7963abb1cfe8c6dfc5410a5e5a9a618e4d1b709326474cc
@@ -1,3 +1,8 @@
1
+ ## 1.8.0
2
+
3
+ * Remote debugging support
4
+
5
+
1
6
  ## 1.7.0
2
7
 
3
8
  * Callstack display: specifically mark c-frames
data/GUIDE.md CHANGED
@@ -673,7 +673,7 @@ puts "rocky's byebugrc run"
673
673
 
674
674
  Here are the default values in `options`
675
675
 
676
- ```ruby
676
+ ```
677
677
  #<OpenStruct annotate=nil, nx=false, quit=true, restart_script=nil, script=nil,
678
678
  stop=true, tracing=false, verbose_long=false>
679
679
  ```
@@ -907,3 +907,257 @@ Status of user-settable breakpoints.
907
907
  Without argument, list info about all breakpoints.
908
908
  With an integer argument, list info on that breakpoint.
909
909
  ```
910
+
911
+ ### Control Commands: quit, restart, source
912
+
913
+ #### Quit
914
+
915
+ To exit `byebug`, type `quit` (abbreviated `q` and aliased `exit`). Normally if
916
+ you are in an interactive session, this command will prompt you to confirm you
917
+ really want to quit. If you don't want any questions asked, enter
918
+ `quit unconditionally` (abbreviated `q!`).
919
+
920
+ #### Restart
921
+
922
+ To restart the program, use the `restart|r` command. This is a re-exec - all
923
+ `byebug` state is lost. If command arguments are passed, those are used.
924
+ Otherwise program arguments from the last invocation are used.
925
+
926
+ You won't be able to restart your program in all cases. First, the program
927
+ should have been invoked at the outset rather than having been called from
928
+ inside your program or invoked as a result of post-mortem handling.
929
+
930
+ #### Source
931
+
932
+ You can run `byebug` commands inside a file, using the command `source <file>`.
933
+ The lines in a command file are executed sequentially. They are not printed as
934
+ they are executed. If there is an error, execution proceeds to the next command
935
+ in the file. For information about command files that get run automatically on
936
+ startup see [Command Files]().
937
+
938
+
939
+ ### Display Commands: display, undisplay
940
+
941
+ #### Display
942
+
943
+ If you find that you want to print the value of an expression frequently (to see
944
+ how it changes), you might want to add it to the *automatic display list** so
945
+ that `byebug` evaluates it each time your program stops or after a line is
946
+ printed if line tracing is enabled. Each expression added to the list is given a
947
+ number to identify it; to remove an expression from the list, you specify that
948
+ number. The automatic display looks like this:
949
+
950
+ ```bash
951
+ (byebug) display n
952
+ 1: n = 3
953
+ ```
954
+
955
+ This display shows item numbers, expressions and their current values. If the
956
+ expression is undefined or illegal the expression will be printed but no value
957
+ will appear.
958
+
959
+ ```bash
960
+ (byebug) display undefined_variable
961
+ 2: undefined_variable =
962
+ (byebug) display 1/0
963
+ 3: 1/0 =
964
+ ```
965
+
966
+ If you use `display` with no argument, `byebug` will display the current values
967
+ of the expressions in the list, just as it is done when your program stops.
968
+ Using `info display` has the same effect.
969
+
970
+ #### Undisplay
971
+
972
+ To remove an item from the list, use `undisplay` followed by the number
973
+ identifying the expression you want to remove. `undisplay` does not repeat if
974
+ you press `<RET>`after using it (otherwise you would just get the error _No
975
+ display number n_)
976
+
977
+ You can also temporarily disable or enable display expressions, so that the will
978
+ not be printed but they won't be forgotten either, so you can toggle them again
979
+ later. To do that, use `disable display` or `enable display` followed by the
980
+ expression number.
981
+
982
+
983
+ ### Print Commands
984
+
985
+ One way to examine and change data in your script is with the `eval` command
986
+ (abbreviated `p`). `byebug` by default evaluates any input that is not
987
+ recognized as a command, so in most situations `eval` is not necessary and
988
+ `byebug` will work like a REPL. One case where it's necessary could be when
989
+ trying to print a variable called `n`. In this case, you have no choice because
990
+ typing just `n` will execute `byebug`'s command `next`.
991
+
992
+ A similar command to `eval|p` is `pp` which tries to pretty print the result.
993
+
994
+ If the value you want to print is an array, sometimes a columnized list looks
995
+ nicer. Use `putl` for that. Notice however that entries are sorted to run down
996
+ first rather than across. If the value is not an array `putl` will just call
997
+ pretty-print.
998
+
999
+ Sometimes you may want to print the array not only columnized, but sorted as
1000
+ well. The list of byebug help commands appears this way, and so does the output
1001
+ of the `method` commands. Use `ps` for that. If the value is not an array `ps`
1002
+ will just call pretty-print.
1003
+
1004
+ ```bash
1005
+ (byebug) Kernel.instance_methods
1006
+ [:nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone,
1007
+ :dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze,
1008
+ :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods,
1009
+ :private_methods, :public_methods, :instance_variables, :instance_variable_get,
1010
+ :instance_variable_set, :instance_variable_defined?, :remove_instance_variable,
1011
+ :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?,
1012
+ :extend, :display, :method, :public_method, :define_singleton_method,
1013
+ :object_id, :to_enum, :enum_for, :gem, :pretty_inspect, :byebug]
1014
+ (byebug) p Kernel.instance_methods
1015
+ [:nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone,
1016
+ :dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze,
1017
+ :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods,
1018
+ :private_methods, :public_methods, :instance_variables, :instance_variable_get,
1019
+ :instance_variable_set, :instance_variable_defined?, :remove_instance_variable,
1020
+ :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?,
1021
+ :extend, :display, :method, :public_method, :define_singleton_method,
1022
+ :object_id, :to_enum, :enum_for, :gem, :pretty_inspect, :byebug]
1023
+ (byebug) pp Kernel.instance_methods
1024
+ [:nil?,
1025
+ :===,
1026
+ :=~,
1027
+ :!~,
1028
+ :eql?,
1029
+ :hash,
1030
+ :<=>,
1031
+ :class,
1032
+ :singleton_class,
1033
+ :clone,
1034
+ :dup,
1035
+ :taint,
1036
+ :tainted?,
1037
+ :untaint,
1038
+ :untrust,
1039
+ :untrusted?,
1040
+ :trust,
1041
+ :freeze,
1042
+ :frozen?,
1043
+ :to_s,
1044
+ :inspect,
1045
+ :methods,
1046
+ :singleton_methods,
1047
+ :protected_methods,
1048
+ :private_methods,
1049
+ :public_methods,
1050
+ :instance_variables,
1051
+ :instance_variable_get,
1052
+ :instance_variable_set,
1053
+ :instance_variable_defined?,
1054
+ :remove_instance_variable,
1055
+ :instance_of?,
1056
+ :kind_of?,
1057
+ :is_a?,
1058
+ :tap,
1059
+ :send,
1060
+ :public_send,
1061
+ :respond_to?,
1062
+ :extend,
1063
+ :display,
1064
+ :method,
1065
+ :public_method,
1066
+ :define_singleton_method,
1067
+ :object_id,
1068
+ :to_enum,
1069
+ :enum_for,
1070
+ :gem,
1071
+ :pretty_inspect,
1072
+ :byebug]
1073
+ (byebug) putl Kernel.instance_methods
1074
+ nil? <=> tainted? frozen? private_methods remove_instance_variable public_send define_singleton_method byebug
1075
+ === class untaint to_s public_methods instance_of? respond_to? object_id
1076
+ =~ singleton_class untrust inspect instance_variables kind_of? extend to_enum
1077
+ !~ clone untrusted? methods instance_variable_get is_a? display enum_for
1078
+ eql? dup trust singleton_methods instance_variable_set tap method gem
1079
+ hash taint freeze protected_methods instance_variable_defined? send public_method pretty_inspect
1080
+ (byebug) ps Kernel.instance_methods
1081
+ !~ clone extend instance_of? kind_of? private_methods respond_to? tap untrusted?
1082
+ <=> define_singleton_method freeze instance_variable_defined? method protected_methods send to_enum
1083
+ === display frozen? instance_variable_get methods public_method singleton_class to_s
1084
+ =~ dup gem instance_variable_set nil? public_methods singleton_methods trust
1085
+ byebug enum_for hash instance_variables object_id public_send taint untaint
1086
+ class eql? inspect is_a? pretty_inspect remove_instance_variable tainted? untrust
1087
+ ```
1088
+
1089
+ Finally, if you need more advanced functionality from REPL's, you can enter
1090
+ `irb` or `pry` using `irb` or `pry` commands. The bindings environment will be
1091
+ set to the current state in the program. When you leave the repl and go back to
1092
+ `byebug`'s command prompt we show the file, line and text position of the
1093
+ program. If you issue a `list` without location information, the default
1094
+ location used is the current line rather than the current position that may have
1095
+ got updated via a prior `list` command.
1096
+
1097
+ ```
1098
+ $ byebug triangle.rb
1099
+ [1, 10] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
1100
+ 1: # Compute the n'th triangle number, the hard way: triangle(n) == (n*(n+1))/2
1101
+ => 2: def triangle(n)
1102
+ 3: tri = 0
1103
+ 4: 0.upto(n) do |i|
1104
+ 5: tri += i
1105
+ 6: end
1106
+ 7: tri
1107
+ 8: end
1108
+ 9:
1109
+ 10: if __FILE__ == $0
1110
+ (byebug) irb
1111
+ 2.0.0-p247 :001 > (0..6).inject{|sum, i| sum +=i}
1112
+ => 21
1113
+ 2.0.0-p247 :002 > exit
1114
+ /home/davidr/Proyectos/byebug/old_doc/triangle.rb @ 2
1115
+ def triangle(n)
1116
+ (byebug) list # same line range as before going into irb
1117
+ [1, 10] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
1118
+ 1: # Compute the n'th triangle number, the hard way: triangle(n) == (n*(n+1))/2
1119
+ => 2: def triangle(n)
1120
+ 3: tri = 0
1121
+ 4: 0.upto(n) do |i|
1122
+ 5: tri += i
1123
+ 6: end
1124
+ 7: tri
1125
+ 8: end
1126
+ 9:
1127
+ 10: if __FILE__ == $0
1128
+ (byebug)
1129
+ ```
1130
+
1131
+ ### Printing variables
1132
+
1133
+ Byebug can print many different information about variables. Such as
1134
+ * `var const <object>`. Show the constants of `<object>`. This is basically
1135
+ listing variables and their values in `<object>.constant`.
1136
+ * `var instance <object>`. Show the instance variables of `<object>`. This is
1137
+ basically listing `<object>.instance_variables`.
1138
+ * `info instance_variables`. Show instance_variables of `self`.
1139
+ * `info locals`. Show local variables.
1140
+ * `info globals`. Show global variables.
1141
+ * `info variables`. Show local and instance variables of `self`.
1142
+ * `method instance <object>`. Show methods of `<object>`. Basically this is the
1143
+ same as running `ps <object>.instance_methods(false)`.
1144
+ * `method iv <object>`. Show method instance variables of `object`. Basically
1145
+ this is the same as running
1146
+ ```
1147
+ <object>.instance_variables.each do |v|
1148
+ puts "%s = %s\n" % [v, <object>.instance_variable_get(v)]
1149
+ end
1150
+ ```
1151
+ * `signature <object>`. Show signature of method `<object>`. _This command is
1152
+ available only if the nodewrap gem is installed_.
1153
+
1154
+ ```ruby
1155
+ def mymethod(a, b=5, &bock)
1156
+ end
1157
+ (byebug) method sig mymethod
1158
+ Mine#mymethod(a, b=5, &bock)
1159
+ ```
1160
+
1161
+ * `method <class-or-module>`. Show methods of the class or module
1162
+ `<class-or-module>`. Basically this is the same as running
1163
+ `ps <class-or-module>.methods`.
data/README.md CHANGED
@@ -89,8 +89,7 @@ because it is a default option in byebug.
89
89
  ## Getting Started
90
90
 
91
91
  A handful of commands are enough to get started using `byebug`. The following
92
- session illustrates these commands. Below is Ruby code to compute a triangle
93
- number of a given length (there are shorter ways to do it, of course).
92
+ session illustrates these commands.
94
93
 
95
94
  ```
96
95
  $ byebug triangle.rb
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/lib/byebug/version'
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'byebug'
5
5
  s.version = Byebug::VERSION
6
- s.authors = ['David Rodríguez', 'Kent Sibilev', 'Mark Moseley']
6
+ s.authors = ['David Rodriguez', 'Kent Sibilev', 'Mark Moseley']
7
7
  s.email = 'deivid.rodriguez@mail.com'
8
8
  s.license = 'BSD'
9
9
  s.homepage = 'http://github.com/deivid-rodriguez/byebug'
@@ -27,6 +27,6 @@ Gem::Specification.new do |s|
27
27
  s.add_dependency "debugger-linecache", '~> 1.2.0'
28
28
 
29
29
  s.add_development_dependency 'rake', '~> 10.1.0'
30
- s.add_development_dependency 'rake-compiler', '~> 0.8.3'
30
+ s.add_development_dependency 'rake-compiler', '~> 0.9.1'
31
31
  s.add_development_dependency 'mocha', '~> 0.14.0'
32
32
  end
@@ -2,9 +2,7 @@ require_relative 'byebug.so'
2
2
  require_relative 'byebug/version'
3
3
  require_relative 'byebug/context'
4
4
  require_relative 'byebug/processor'
5
- require 'pp'
6
- require 'stringio'
7
- require 'socket'
5
+ require_relative 'byebug/remote'
8
6
  require 'linecache19'
9
7
 
10
8
  module Byebug
@@ -33,9 +31,6 @@ module Byebug
33
31
  # gdb-style annotation mode. Used in GNU Emacs interface
34
32
  attr_accessor :annotate
35
33
 
36
- # If in remote mode, wait for the remote connection
37
- attr_accessor :wait_connection
38
-
39
34
  def source_reload
40
35
  Object.send(:remove_const, "SCRIPT_LINES__") if
41
36
  Object.const_defined?("SCRIPT_LINES__")
@@ -175,8 +175,8 @@ module Byebug
175
175
  register_setting_var(:listsize, 10)
176
176
  register_setting_var(:stack_trace_on_error, false)
177
177
  register_setting_var(:tracing_plus, false)
178
- cols = terminal_width || 80
179
- register_setting_var(:width, cols > 10 ? cols : 80)
178
+ cols = terminal_width || 160
179
+ register_setting_var(:width, cols > 10 ? cols : 160)
180
180
  Byebug::ARGV = ARGV.clone unless defined? Byebug::ARGV
181
181
  register_setting_var(:argv, Byebug::ARGV)
182
182
 
@@ -1,5 +1,6 @@
1
- module Byebug
1
+ require 'pp'
2
2
 
3
+ module Byebug
3
4
  module EvalFunctions
4
5
  def run_with_binding
5
6
  binding = get_binding
@@ -136,8 +137,6 @@ module Byebug
136
137
  include Columnize
137
138
  self.allow_in_control = true
138
139
 
139
- include EvalFunctions
140
-
141
140
  def regexp
142
141
  /^\s*ps\s+/
143
142
  end
@@ -104,7 +104,13 @@ module Byebug
104
104
  end
105
105
 
106
106
  def print_backtrace
107
- (0...@state.context.stack_size).each do |idx|
107
+ realsize = caller.drop_while {|e| e[/\(eval\)|byebug/] }.size
108
+ if @state.context.stack_size != realsize
109
+ errmsg "Warning, Byebug's stacksize (#{@state.context.stack_size}) is" \
110
+ " incorrect (must be #{realsize}). This might be a bug in " \
111
+ "byebug or ruby's debugging API's\n"
112
+ end
113
+ (0...realsize).each do |idx|
108
114
  print_frame(idx)
109
115
  end
110
116
  end
@@ -0,0 +1,95 @@
1
+ require 'socket'
2
+
3
+ module Byebug
4
+
5
+ # Port number used for remote debugging
6
+ PORT = 8989 unless defined?(PORT)
7
+
8
+ class << self
9
+
10
+ # If in remote mode, wait for the remote connection
11
+ attr_accessor :wait_connection
12
+
13
+ #
14
+ # Starts a remote byebug
15
+ #
16
+ def start_server(host = nil, port = PORT)
17
+ return if @thread
18
+
19
+ self.interface = nil
20
+ start
21
+
22
+ if port.kind_of?(Array)
23
+ cmd_port, ctrl_port = port
24
+ else
25
+ cmd_port, ctrl_port = port, port + 1
26
+ end
27
+
28
+ ctrl_port = start_control(host, ctrl_port)
29
+
30
+ yield if block_given?
31
+
32
+ mutex = Mutex.new
33
+ proceed = ConditionVariable.new
34
+
35
+ server = TCPServer.new(host, cmd_port)
36
+ @cmd_port = cmd_port = server.addr[1]
37
+ @thread = Thread.new do
38
+ while (session = server.accept)
39
+ self.interface = RemoteInterface.new(session)
40
+ if wait_connection
41
+ mutex.synchronize do
42
+ proceed.signal
43
+ end
44
+ end
45
+ end
46
+ end
47
+ if wait_connection
48
+ mutex.synchronize do
49
+ proceed.wait(mutex)
50
+ end
51
+ end
52
+ end
53
+
54
+ def start_control(host = nil, ctrl_port = PORT + 1)
55
+ return @ctrl_port if defined?(@control_thread) && @control_thread
56
+ server = TCPServer.new(host, ctrl_port)
57
+ @ctrl_port = server.addr[1]
58
+ @control_thread = Thread.new do
59
+ while (session = server.accept)
60
+ interface = RemoteInterface.new(session)
61
+ processor = ControlCommandProcessor.new(interface)
62
+ processor.process_commands
63
+ end
64
+ end
65
+ @ctrl_port
66
+ end
67
+
68
+ #
69
+ # Connects to the remote byebug
70
+ #
71
+ def start_client(host = 'localhost', port = PORT)
72
+ interface = Byebug::LocalInterface.new
73
+ socket = TCPSocket.new(host, port)
74
+ puts "Connected."
75
+
76
+ catch(:exit) do
77
+ while (line = socket.gets)
78
+ case line
79
+ when /^PROMPT (.*)$/
80
+ input = interface.read_command($1)
81
+ throw :exit unless input
82
+ socket.puts input
83
+ when /^CONFIRM (.*)$/
84
+ input = interface.confirm($1)
85
+ throw :exit unless input
86
+ socket.puts input
87
+ else
88
+ print line
89
+ end
90
+ end
91
+ end
92
+ socket.close
93
+ end
94
+ end
95
+ end
@@ -1,3 +1,3 @@
1
1
  module Byebug
2
- VERSION = '1.7.0'
2
+ VERSION = '1.8.0'
3
3
  end
@@ -3,15 +3,15 @@ require_relative 'test_helper'
3
3
  class TestInfo < TestDsl::TestCase
4
4
  include Columnize
5
5
 
6
- describe 'Args info' do
7
- temporary_change_hash Byebug::Command.settings, :width, 15
8
-
9
- it 'must show info about all args' do
10
- enter 'break 3', 'cont', 'info args'
11
- debug_file 'info'
12
- check_output_includes 'a = "aaaaaaa...', 'b = "b"'
13
- end
14
- end
6
+ describe 'Args info' do
7
+ temporary_change_hash Byebug::Command.settings, :width, 15
8
+
9
+ it 'must show info about all args' do
10
+ enter 'break 3', 'cont', 'info args'
11
+ debug_file 'info'
12
+ check_output_includes 'a = "aaaaaaa...', 'b = "b"'
13
+ end
14
+ end
15
15
 
16
16
  describe 'Breakpoints info' do
17
17
  it 'must show info about all breakpoints' do
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
- - David Rodríguez
7
+ - David Rodriguez
8
8
  - Kent Sibilev
9
9
  - Mark Moseley
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-03 00:00:00.000000000 Z
13
+ date: 2013-08-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: columnize
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - ~>
62
62
  - !ruby/object:Gem::Version
63
- version: 0.8.3
63
+ version: 0.9.1
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ~>
69
69
  - !ruby/object:Gem::Version
70
- version: 0.8.3
70
+ version: 0.9.1
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: mocha
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -147,6 +147,7 @@ files:
147
147
  - lib/byebug/helper.rb
148
148
  - lib/byebug/interface.rb
149
149
  - lib/byebug/processor.rb
150
+ - lib/byebug/remote.rb
150
151
  - lib/byebug/version.rb
151
152
  - logo.png
152
153
  - old_doc/byebug.1
@@ -314,4 +315,3 @@ test_files:
314
315
  - test/test_helper.rb
315
316
  - test/trace_test.rb
316
317
  - test/variables_test.rb
317
- has_rdoc: