byebug 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/.travis.yml +0 -5
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/LICENSE +23 -20
- data/byebug.gemspec +5 -5
- data/ext/byebug/breakpoint.c +102 -134
- data/ext/byebug/byebug.c +110 -64
- data/ext/byebug/byebug.h +2 -3
- data/ext/byebug/context.c +72 -39
- data/lib/byebug.rb +34 -38
- data/lib/byebug/command.rb +19 -24
- data/lib/byebug/commands/breakpoints.rb +11 -12
- data/lib/byebug/commands/catchpoint.rb +1 -1
- data/lib/byebug/commands/control.rb +2 -4
- data/lib/byebug/commands/finish.rb +1 -1
- data/lib/byebug/commands/frame.rb +15 -17
- data/lib/byebug/commands/info.rb +29 -28
- data/lib/byebug/commands/irb.rb +23 -21
- data/lib/byebug/commands/method.rb +4 -4
- data/lib/byebug/commands/reload.rb +8 -6
- data/lib/byebug/commands/set.rb +27 -23
- data/lib/byebug/commands/show.rb +6 -4
- data/lib/byebug/commands/stepping.rb +2 -2
- data/lib/byebug/commands/threads.rb +10 -10
- data/lib/byebug/commands/trace.rb +13 -14
- data/lib/byebug/commands/variables.rb +14 -12
- data/lib/byebug/context.rb +2 -15
- data/lib/byebug/interface.rb +5 -0
- data/lib/byebug/processor.rb +59 -64
- data/lib/byebug/version.rb +2 -1
- data/old_doc/Makefile +20 -0
- data/{man/rdebug.1 → old_doc/byebug.1} +5 -5
- data/old_doc/byebug.html +6178 -0
- data/old_doc/byebug.texi +3775 -0
- data/{doc → old_doc}/hanoi.rb +0 -0
- data/{doc → old_doc}/primes.rb +0 -0
- data/{doc → old_doc}/test-tri2.rb +0 -0
- data/{doc → old_doc}/tri3.rb +0 -0
- data/{doc → old_doc}/triangle.rb +0 -0
- data/test/breakpoints_test.rb +96 -60
- data/test/conditions_test.rb +15 -12
- data/test/examples/info.rb +5 -5
- data/test/examples/stepping.rb +1 -1
- data/test/frame_test.rb +40 -39
- data/test/info_test.rb +105 -96
- data/test/irb_test.rb +66 -61
- data/test/jump_test.rb +18 -9
- data/test/list_test.rb +114 -107
- data/test/restart_test.rb +51 -58
- data/test/save_test.rb +8 -7
- data/test/set_test.rb +8 -11
- data/test/show_test.rb +3 -5
- data/test/stepping_test.rb +43 -53
- data/test/support/context.rb +1 -0
- data/test/support/processor.rb +10 -4
- data/test/support/test_dsl.rb +46 -18
- data/test/support/test_interface.rb +8 -5
- data/test/test_helper.rb +2 -2
- data/test/trace_test.rb +123 -124
- metadata +39 -17
- data/AUTHORS +0 -10
- data/doc/rdebug-emacs.texi +0 -1030
data/ext/byebug/byebug.h
CHANGED
@@ -16,9 +16,8 @@ typedef struct rb_trace_arg_struct rb_trace_point_t;
|
|
16
16
|
#define CTX_FL_DEAD (1<<5)
|
17
17
|
#define CTX_FL_WAS_RUNNING (1<<6)
|
18
18
|
#define CTX_FL_ENABLE_BKPT (1<<7)
|
19
|
-
#define
|
20
|
-
#define
|
21
|
-
#define CTX_FL_CATCHING (1<<10)
|
19
|
+
#define CTX_FL_FORCE_MOVE (1<<8)
|
20
|
+
#define CTX_FL_CATCHING (1<<9)
|
22
21
|
|
23
22
|
/* macro functions */
|
24
23
|
#define CTX_FL_TEST(c,f) ((c)->flags & (f))
|
data/ext/byebug/context.c
CHANGED
@@ -162,22 +162,17 @@ context_create(VALUE thread, VALUE cDebugThread) {
|
|
162
162
|
return Data_Wrap_Struct(cContext, Context_mark, Context_free, context);
|
163
163
|
}
|
164
164
|
|
165
|
-
static inline void
|
166
|
-
check_frame_number_valid(debug_context_t *context, int frame_no)
|
167
|
-
{
|
168
|
-
if (frame_no < 0 || frame_no >= context->stack_size) {
|
169
|
-
rb_raise(rb_eArgError, "Invalid frame number %d, stack (0...%d)",
|
170
|
-
frame_no, context->stack_size);
|
171
|
-
}
|
172
|
-
}
|
173
|
-
|
174
165
|
static debug_frame_t*
|
175
166
|
get_frame_no(debug_context_t *context, int frame_n)
|
176
167
|
{
|
177
168
|
debug_frame_t *frame;
|
178
169
|
int i;
|
179
170
|
|
180
|
-
|
171
|
+
if (frame_n < 0 || frame_n >= context->stack_size) {
|
172
|
+
rb_raise(rb_eArgError, "Invalid frame number %d, stack (0...%d)",
|
173
|
+
frame_n, context->stack_size);
|
174
|
+
}
|
175
|
+
|
181
176
|
frame = context->stack;
|
182
177
|
for (i = 0; i < frame_n; i++) {
|
183
178
|
frame = frame->prev;
|
@@ -255,22 +250,39 @@ Context_frame_self(int argc, VALUE *argv, VALUE self)
|
|
255
250
|
return frame->self;
|
256
251
|
}
|
257
252
|
|
258
|
-
|
253
|
+
static VALUE
|
254
|
+
Context_frame_locals(int argc, VALUE *argv, VALUE self)
|
255
|
+
{
|
256
|
+
VALUE binding = Context_frame_binding(argc, argv, self);
|
257
|
+
const char src[] =
|
258
|
+
"local_variables.inject({}){|h, v| h[v] = eval(\"#{v}\"); h}";
|
259
|
+
return NIL_P(binding) ?
|
260
|
+
rb_hash_new() :
|
261
|
+
rb_funcall(binding, rb_intern("eval"), 1, rb_str_new2(src));
|
262
|
+
}
|
263
|
+
|
259
264
|
static VALUE
|
260
265
|
Context_frame_args(int argc, VALUE *argv, VALUE self)
|
261
266
|
{
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
267
|
+
VALUE binding = Context_frame_binding(argc, argv, self);
|
268
|
+
const char src[] =
|
269
|
+
"__method__ ? " \
|
270
|
+
"self.method(__method__).parameters.map{|(attr, mid)| mid} : []";
|
271
|
+
return NIL_P(binding) ?
|
272
|
+
rb_ary_new() :
|
273
|
+
rb_funcall(binding, rb_intern("eval"), 1, rb_str_new2(src));
|
274
|
+
}
|
266
275
|
|
267
|
-
|
268
|
-
|
269
|
-
|
276
|
+
static VALUE
|
277
|
+
Context_frame_args_info(int argc, VALUE *argv, VALUE self)
|
278
|
+
{
|
279
|
+
VALUE binding = Context_frame_binding(argc, argv, self);
|
280
|
+
const char src[] = "method(__method__).parameters";
|
270
281
|
|
271
|
-
|
282
|
+
return NIL_P(binding) ?
|
283
|
+
rb_ary_new() :
|
284
|
+
rb_funcall(binding, rb_intern("eval"), 1, rb_str_new2(src));
|
272
285
|
}
|
273
|
-
*/
|
274
286
|
|
275
287
|
static VALUE
|
276
288
|
Context_tracing(VALUE self)
|
@@ -324,6 +336,30 @@ Context_stop_reason(VALUE self)
|
|
324
336
|
return ID2SYM(rb_intern(symbol));
|
325
337
|
}
|
326
338
|
|
339
|
+
#if 0
|
340
|
+
|
341
|
+
static VALUE
|
342
|
+
Context_jump(VALUE self, VALUE line, VALUE file)
|
343
|
+
{
|
344
|
+
debug_context_t *context;
|
345
|
+
debug_frame_t *frame;
|
346
|
+
int i, lineno;
|
347
|
+
|
348
|
+
Data_Get_Struct(self, debug_context_t, context);
|
349
|
+
|
350
|
+
frame = context->stack;
|
351
|
+
lineno = FIX2INT(line);
|
352
|
+
|
353
|
+
for (i = 0; i < context->stack_size; i++) {
|
354
|
+
if (strcmp(frame->file, RSTRING_PTR(file))) {
|
355
|
+
/* And now? */
|
356
|
+
}
|
357
|
+
frame = frame->prev;
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
#endif
|
362
|
+
|
327
363
|
static VALUE
|
328
364
|
Context_stop_next(int argc, VALUE *argv, VALUE self)
|
329
365
|
{
|
@@ -332,7 +368,8 @@ Context_stop_next(int argc, VALUE *argv, VALUE self)
|
|
332
368
|
debug_context_t *context;
|
333
369
|
|
334
370
|
rb_scan_args(argc, argv, "11", &steps, &force);
|
335
|
-
if(FIX2INT(steps) < 0)
|
371
|
+
if (FIX2INT(steps) < 0)
|
372
|
+
rb_raise(rb_eRuntimeError, "Steps argument can't be negative.");
|
336
373
|
|
337
374
|
Data_Get_Struct(self, debug_context_t, context);
|
338
375
|
context->stop_next = FIX2INT(steps);
|
@@ -351,23 +388,17 @@ Context_step_over(int argc, VALUE *argv, VALUE self)
|
|
351
388
|
debug_context_t *context;
|
352
389
|
|
353
390
|
Data_Get_Struct(self, debug_context_t, context);
|
354
|
-
if(context->stack_size == 0)
|
391
|
+
if (context->stack_size == 0)
|
355
392
|
rb_raise(rb_eRuntimeError, "No frames collected.");
|
356
393
|
|
357
394
|
rb_scan_args(argc, argv, "12", &lines, &frame, &force);
|
358
395
|
context->stop_line = FIX2INT(lines);
|
359
|
-
|
360
|
-
if(frame
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
{
|
366
|
-
if(FIX2INT(frame) < 0 && FIX2INT(frame) >= context->stack_size)
|
367
|
-
rb_raise(rb_eRuntimeError, "Destination frame is out of range.");
|
368
|
-
context->dest_frame = context->stack_size - FIX2INT(frame);
|
369
|
-
}
|
370
|
-
if(RTEST(force))
|
396
|
+
|
397
|
+
if (FIX2INT(frame) < 0 && FIX2INT(frame) >= context->stack_size)
|
398
|
+
rb_raise(rb_eRuntimeError, "Destination frame is out of range.");
|
399
|
+
context->dest_frame = context->stack_size - FIX2INT(frame);
|
400
|
+
|
401
|
+
if (RTEST(force))
|
371
402
|
CTX_FL_SET(context, CTX_FL_FORCE_MOVE);
|
372
403
|
else
|
373
404
|
CTX_FL_UNSET(context, CTX_FL_FORCE_MOVE);
|
@@ -378,12 +409,12 @@ Context_step_over(int argc, VALUE *argv, VALUE self)
|
|
378
409
|
static VALUE
|
379
410
|
Context_stop_frame(VALUE self, VALUE frame)
|
380
411
|
{
|
381
|
-
debug_context_t *
|
412
|
+
debug_context_t *context;
|
382
413
|
|
383
|
-
Data_Get_Struct(self, debug_context_t,
|
384
|
-
if(FIX2INT(frame) < 0 && FIX2INT(frame) >=
|
414
|
+
Data_Get_Struct(self, debug_context_t, context);
|
415
|
+
if(FIX2INT(frame) < 0 && FIX2INT(frame) >= context->stack_size)
|
385
416
|
rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
|
386
|
-
|
417
|
+
context->stop_frame = context->stack_size - FIX2INT(frame);
|
387
418
|
|
388
419
|
return frame;
|
389
420
|
}
|
@@ -412,7 +443,9 @@ Init_context(VALUE mByebug)
|
|
412
443
|
rb_define_method(cContext, "frame_method", Context_frame_method, -1);
|
413
444
|
rb_define_method(cContext, "frame_binding", Context_frame_binding, -1);
|
414
445
|
rb_define_method(cContext, "frame_self", Context_frame_self, -1);
|
415
|
-
|
446
|
+
rb_define_method(cContext, "frame_args", Context_frame_args, -1);
|
447
|
+
rb_define_method(cContext, "frame_args_info", Context_frame_args_info, -1);
|
448
|
+
rb_define_method(cContext, "frame_locals", Context_frame_locals, -1);
|
416
449
|
rb_define_method(cContext, "stop_next=", Context_stop_next, -1);
|
417
450
|
rb_define_method(cContext, "step", Context_stop_next, -1);
|
418
451
|
rb_define_method(cContext, "step_over", Context_step_over, -1);
|
data/lib/byebug.rb
CHANGED
@@ -11,7 +11,6 @@ require 'linecache19'
|
|
11
11
|
module Byebug
|
12
12
|
|
13
13
|
@reload_source_on_change = false
|
14
|
-
@tracing_started = false
|
15
14
|
|
16
15
|
self.handler = CommandProcessor.new
|
17
16
|
|
@@ -19,21 +18,19 @@ module Byebug
|
|
19
18
|
DEFAULT_START_SETTINGS = {
|
20
19
|
:init => true, # Set $0 and save ARGV?
|
21
20
|
:post_mortem => false, # post-mortem debugging on uncaught exception?
|
22
|
-
:tracing => nil # Byebug.tracing value. true/false resets
|
21
|
+
:tracing => nil # Byebug.tracing value. true/false resets
|
23
22
|
} unless defined?(DEFAULT_START_SETTINGS)
|
24
23
|
|
25
|
-
#
|
24
|
+
# Port number used for remote debugging
|
26
25
|
PORT = 8989 unless defined?(PORT)
|
27
26
|
|
28
|
-
#
|
29
|
-
unless defined?(INITFILE)
|
30
|
-
INITFILE = '.rdebugrc'
|
31
|
-
HOME_DIR = ENV['HOME'].to_s
|
32
|
-
end
|
27
|
+
# Configuration file used for startup commands. Default value is .byebugrc
|
28
|
+
INITFILE = '.byebugrc' unless defined?(INITFILE)
|
33
29
|
|
34
30
|
class << self
|
35
31
|
|
36
|
-
#
|
32
|
+
# If true, checks the modification time of source files and reloads them if
|
33
|
+
# they were modified
|
37
34
|
attr_accessor :reload_source_on_change
|
38
35
|
|
39
36
|
attr_accessor :last_exception
|
@@ -42,11 +39,10 @@ module Byebug
|
|
42
39
|
# gdb-style annotation mode. Used in GNU Emacs interface
|
43
40
|
attr_accessor :annotate
|
44
41
|
|
45
|
-
# in remote mode, wait for the remote connection
|
42
|
+
# If in remote mode, wait for the remote connection
|
46
43
|
attr_accessor :wait_connection
|
47
44
|
|
48
|
-
#
|
49
|
-
# if the call stack is truncated.
|
45
|
+
# A string to look for in caller() to see if the call stack is truncated
|
50
46
|
attr_accessor :start_sentinal
|
51
47
|
|
52
48
|
attr_reader :thread, :control_thread, :cmd_port, :ctrl_port
|
@@ -75,13 +71,13 @@ module Byebug
|
|
75
71
|
LineCache::clear_file_cache
|
76
72
|
end
|
77
73
|
|
78
|
-
# Get line +line_number+ from file named +filename+.
|
79
|
-
# there was a problem. Leaking blanks are stripped off.
|
80
|
-
def line_at(filename, line_number)
|
81
|
-
@reload_on_change=nil unless defined?(@reload_on_change)
|
74
|
+
# Get line +line_number+ from file named +filename+.
|
75
|
+
# @return "\n" if there was a problem. Leaking blanks are stripped off.
|
76
|
+
def line_at(filename, line_number)
|
77
|
+
@reload_on_change = nil unless defined?(@reload_on_change)
|
82
78
|
line = LineCache::getline(filename, line_number, @reload_on_change)
|
83
79
|
return "\n" unless line
|
84
|
-
return "#{line.gsub(/^\s+/, '').chomp}
|
80
|
+
return "#{line.gsub(/^\s+/, '').chomp}"
|
85
81
|
end
|
86
82
|
|
87
83
|
alias stop remove_tracepoints
|
@@ -110,16 +106,14 @@ module Byebug
|
|
110
106
|
# If it's called without a block it returns +true+, unless byebug was
|
111
107
|
# already started.
|
112
108
|
#
|
113
|
-
# If a block is given, it starts byebug and yields
|
114
|
-
#
|
115
|
-
#
|
116
|
-
# Byebug.byebug. For example:
|
109
|
+
# If a block is given, it starts byebug and yields block. When the block is
|
110
|
+
# executed it stops byebug with Byebug.stop method. Inside the block you
|
111
|
+
# will probably want to have a call to Byebug.byebug. For example:
|
117
112
|
#
|
118
113
|
# Byebug.start{byebug; foo} # Stop inside of foo
|
119
114
|
#
|
120
115
|
# Also, byebug only allows one invocation of byebug at a time; nested
|
121
|
-
# Byebug.start's have no effect and you can't use this inside
|
122
|
-
# itself.
|
116
|
+
# Byebug.start's have no effect and you can't use this inside byebug itself.
|
123
117
|
#
|
124
118
|
# <i>Note that if you want to stop byebug, you must call Byebug.stop as
|
125
119
|
# many times as you called Byebug.start method.</i>
|
@@ -141,15 +135,15 @@ module Byebug
|
|
141
135
|
Byebug.const_set('PROG_SCRIPT', $0) unless defined? Byebug::PROG_SCRIPT
|
142
136
|
Byebug.const_set('INITIAL_DIR', Dir.pwd) unless defined? Byebug::INITIAL_DIR
|
143
137
|
end
|
144
|
-
|
138
|
+
Byebug.tracing = options[:tracing] unless options[:tracing].nil?
|
145
139
|
if Byebug.started?
|
146
140
|
retval = block && block.call(self)
|
147
141
|
else
|
148
142
|
retval = Byebug._start(&block)
|
149
143
|
end
|
150
|
-
if options[:post_mortem]
|
151
|
-
|
152
|
-
end
|
144
|
+
#if options[:post_mortem]
|
145
|
+
# post_mortem
|
146
|
+
#end
|
153
147
|
return retval
|
154
148
|
end
|
155
149
|
|
@@ -247,12 +241,13 @@ module Byebug
|
|
247
241
|
# program you are debugging, in the directory where you invoke byebug.
|
248
242
|
#
|
249
243
|
def run_init_script(out = handler.interface)
|
250
|
-
|
251
|
-
run_script(
|
244
|
+
cwd_script = File.expand_path(File.join(".", INITFILE))
|
245
|
+
run_script(cwd_script, out) if File.exists?(script_file)
|
252
246
|
|
253
|
-
|
254
|
-
|
255
|
-
|
247
|
+
home_script = File.expand_path(File.join(ENV['HOME'].to_s, INITFILE))
|
248
|
+
if File.exists?(home_script) and cwd_script != home_script
|
249
|
+
run_script(home_script_file, out)
|
250
|
+
end
|
256
251
|
end
|
257
252
|
|
258
253
|
#
|
@@ -374,14 +369,15 @@ class Module
|
|
374
369
|
end
|
375
370
|
module Kernel
|
376
371
|
|
372
|
+
##
|
377
373
|
# Enters byebug in the current thread after _steps_ line events occur.
|
378
374
|
#
|
379
|
-
# Before entering byebug startup, the init script is read. Setting _steps_ to
|
380
|
-
# will cause a break in
|
381
|
-
# occur. You will have to go "up 1" in order to be back to your debugged
|
382
|
-
# from byebug
|
383
|
-
# right after the last statement in some scope, because the next step
|
384
|
-
# you out of some scope.
|
375
|
+
# Before entering byebug startup, the init script is read. Setting _steps_ to
|
376
|
+
# 0 will cause a break in byebug's subroutine and not wait for a line event to
|
377
|
+
# occur. You will have to go "up 1" in order to be back to your debugged
|
378
|
+
# program from byebug. Setting _steps_ to 0 could be useful if you want to
|
379
|
+
# stop right after the last statement in some scope, because the next step
|
380
|
+
# will take you out of some scope.
|
385
381
|
def byebug(steps = 1)
|
386
382
|
Byebug.start
|
387
383
|
Byebug.run_init_script(StringIO.new)
|
data/lib/byebug/command.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require 'columnize'
|
2
|
+
require 'forwardable'
|
2
3
|
require_relative 'helper'
|
3
4
|
|
4
5
|
module Byebug
|
5
6
|
|
7
|
+
# Root dir for byebug
|
6
8
|
BYEBUG_DIR = File.expand_path(File.dirname(__FILE__)) unless
|
7
9
|
defined?(BYEBUG_DIR)
|
8
10
|
|
9
|
-
class Command
|
11
|
+
class Command
|
12
|
+
|
10
13
|
SubcmdStruct = Struct.new(:name, :min, :short_help, :long_help) unless
|
11
14
|
defined?(SubcmdStruct)
|
12
15
|
|
@@ -32,11 +35,11 @@ module Byebug
|
|
32
35
|
|
33
36
|
DEF_OPTIONS = {
|
34
37
|
:allow_in_control => false,
|
35
|
-
:allow_in_post_mortem => true,
|
36
|
-
:event
|
37
|
-
:always_run
|
38
|
-
:unknown
|
39
|
-
:need_context
|
38
|
+
:allow_in_post_mortem => true ,
|
39
|
+
:event => true ,
|
40
|
+
:always_run => 0 ,
|
41
|
+
:unknown => false,
|
42
|
+
:need_context => false,
|
40
43
|
} unless defined?(DEF_OPTIONS)
|
41
44
|
|
42
45
|
def inherited(klass)
|
@@ -47,12 +50,10 @@ module Byebug
|
|
47
50
|
end
|
48
51
|
|
49
52
|
def load_commands
|
50
|
-
Dir[File.join(Byebug.const_get(:BYEBUG_DIR), 'commands', '*')].each
|
51
|
-
require file if file =~ /\.rb$/
|
52
|
-
|
53
|
-
|
54
|
-
include mod
|
55
|
-
end
|
53
|
+
Dir[File.join(Byebug.const_get(:BYEBUG_DIR), 'commands', '*')].each {
|
54
|
+
|file| require file if file =~ /\.rb$/ }
|
55
|
+
Byebug.constants.grep(/Functions$/).map {
|
56
|
+
|name| Byebug.const_get(name) }.each { |mod| include mod }
|
56
57
|
end
|
57
58
|
|
58
59
|
def method_missing(meth, *args, &block)
|
@@ -155,14 +156,8 @@ module Byebug
|
|
155
156
|
|
156
157
|
protected
|
157
158
|
|
158
|
-
|
159
|
-
|
160
|
-
@state.errmsg(*args)
|
161
|
-
end
|
162
|
-
|
163
|
-
def print(*args)
|
164
|
-
@state.print(*args)
|
165
|
-
end
|
159
|
+
extend Forwardable
|
160
|
+
def_delegators :@state, :errmsg, :print
|
166
161
|
|
167
162
|
def confirm(msg)
|
168
163
|
@state.confirm(msg) == 'y'
|
@@ -197,9 +192,9 @@ module Byebug
|
|
197
192
|
@state.context.frame_binding(@state.frame_pos)
|
198
193
|
end
|
199
194
|
|
200
|
-
def line_at(file, line)
|
201
|
-
|
202
|
-
end
|
195
|
+
#def line_at(file, line)
|
196
|
+
# Byebug.line_at(file, line)
|
197
|
+
#end
|
203
198
|
|
204
199
|
def get_context(thnum)
|
205
200
|
Byebug.contexts.find{|c| c.thnum == thnum}
|
@@ -208,7 +203,7 @@ module Byebug
|
|
208
203
|
|
209
204
|
Command.load_commands
|
210
205
|
|
211
|
-
|
206
|
+
##
|
212
207
|
# Returns ths settings object.
|
213
208
|
# Use Byebug.settings[] and Byebug.settings[]= methods to query and set
|
214
209
|
# byebug settings. These settings are available:
|
@@ -32,14 +32,13 @@ module Byebug
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
brkpt_filename =
|
35
|
+
brkpt_filename = file
|
36
36
|
if file.nil?
|
37
37
|
unless @state.context
|
38
38
|
errmsg "We are not in a state that has an associated file.\n"
|
39
39
|
return
|
40
40
|
end
|
41
41
|
brkpt_filename = @state.file
|
42
|
-
file = File.basename(@state.file)
|
43
42
|
if line.nil?
|
44
43
|
# Set breakpoint at current line
|
45
44
|
line = @state.line.to_s
|
@@ -53,11 +52,6 @@ module Byebug
|
|
53
52
|
errmsg "Unknown class #{file}.\n"
|
54
53
|
throw :debug_error
|
55
54
|
end
|
56
|
-
else
|
57
|
-
# FIXME: This should be done in LineCache.
|
58
|
-
file = File.expand_path(file) if file.index(File::SEPARATOR) || \
|
59
|
-
File::ALT_SEPARATOR && file.index(File::ALT_SEPARATOR)
|
60
|
-
brkpt_filename = file
|
61
55
|
end
|
62
56
|
|
63
57
|
if line =~ /^\d+$/
|
@@ -65,15 +59,19 @@ module Byebug
|
|
65
59
|
if LineCache.cache(brkpt_filename, Command.settings[:reload_source_on_change])
|
66
60
|
last_line = LineCache.size(brkpt_filename)
|
67
61
|
if line > last_line
|
68
|
-
errmsg
|
62
|
+
errmsg \
|
63
|
+
"There are only %d lines in file %s\n",
|
64
|
+
last_line, brkpt_filename
|
69
65
|
return
|
70
66
|
end
|
71
67
|
unless LineCache.trace_line_numbers(brkpt_filename).member?(line)
|
72
|
-
errmsg
|
68
|
+
errmsg \
|
69
|
+
"Line %d is not a stopping point in file %s\n",
|
70
|
+
line, brkpt_filename
|
73
71
|
return
|
74
72
|
end
|
75
73
|
else
|
76
|
-
errmsg("No source file named %s\n"
|
74
|
+
errmsg("No source file named %s\n", brkpt_filename)
|
77
75
|
return unless confirm("Set breakpoint anyway? (y/n) ")
|
78
76
|
end
|
79
77
|
|
@@ -82,7 +80,8 @@ module Byebug
|
|
82
80
|
return
|
83
81
|
end
|
84
82
|
b = Byebug.add_breakpoint brkpt_filename, line, expr
|
85
|
-
print "
|
83
|
+
print "Created breakpoint #{b.id} at " \
|
84
|
+
"#{CommandProcessor.canonic_file(brkpt_filename)}:#{line.to_s}"
|
86
85
|
unless syntax_valid?(expr)
|
87
86
|
errmsg("Expression \"#{expr}\" syntactically incorrect; breakpoint disabled.\n")
|
88
87
|
b.enabled = false
|
@@ -90,7 +89,7 @@ module Byebug
|
|
90
89
|
else
|
91
90
|
method = line.intern
|
92
91
|
b = Byebug.add_breakpoint class_name, method, expr
|
93
|
-
print "
|
92
|
+
print "Created breakpoint #{b.id} at #{class_name}::#{method.to_s}"
|
94
93
|
end
|
95
94
|
end
|
96
95
|
|