byebug 9.0.5 → 11.1.3
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +399 -264
- data/CONTRIBUTING.md +12 -19
- data/GUIDE.md +40 -26
- data/LICENSE +18 -18
- data/README.md +103 -74
- data/exe/byebug +6 -0
- data/ext/byebug/breakpoint.c +2 -2
- data/ext/byebug/byebug.c +26 -31
- data/ext/byebug/byebug.h +44 -28
- data/ext/byebug/context.c +45 -32
- data/ext/byebug/extconf.rb +7 -5
- data/ext/byebug/locker.c +4 -4
- data/ext/byebug/threads.c +12 -12
- data/lib/byebug/attacher.rb +18 -4
- data/lib/byebug/breakpoint.rb +26 -6
- data/lib/byebug/command.rb +20 -14
- data/lib/byebug/command_list.rb +3 -1
- data/lib/byebug/commands/break.rb +36 -22
- data/lib/byebug/commands/catch.rb +16 -18
- data/lib/byebug/commands/condition.rb +11 -11
- data/lib/byebug/commands/continue.rb +32 -12
- data/lib/byebug/commands/debug.rb +7 -5
- data/lib/byebug/commands/delete.rb +13 -11
- data/lib/byebug/commands/disable/breakpoints.rb +7 -5
- data/lib/byebug/commands/disable/display.rb +7 -5
- data/lib/byebug/commands/disable.rb +8 -6
- data/lib/byebug/commands/display.rb +11 -9
- data/lib/byebug/commands/down.rb +10 -8
- data/lib/byebug/commands/edit.rb +11 -8
- data/lib/byebug/commands/enable/breakpoints.rb +7 -5
- data/lib/byebug/commands/enable/display.rb +7 -5
- data/lib/byebug/commands/enable.rb +8 -6
- data/lib/byebug/commands/finish.rb +9 -7
- data/lib/byebug/commands/frame.rb +11 -9
- data/lib/byebug/commands/help.rb +7 -5
- data/lib/byebug/commands/history.rb +7 -5
- data/lib/byebug/commands/info/breakpoints.rb +18 -14
- data/lib/byebug/commands/info/display.rb +16 -9
- data/lib/byebug/commands/info/file.rb +13 -14
- data/lib/byebug/commands/info/line.rb +5 -3
- data/lib/byebug/commands/info/program.rb +8 -6
- data/lib/byebug/commands/info.rb +11 -9
- data/lib/byebug/commands/interrupt.rb +8 -4
- data/lib/byebug/commands/irb.rb +13 -12
- data/lib/byebug/commands/kill.rb +11 -11
- data/lib/byebug/commands/list.rb +41 -46
- data/lib/byebug/commands/method.rb +10 -8
- data/lib/byebug/commands/next.rb +8 -6
- data/lib/byebug/commands/pry.rb +10 -10
- data/lib/byebug/commands/quit.rb +10 -8
- data/lib/byebug/commands/restart.rb +30 -11
- data/lib/byebug/commands/save.rb +10 -8
- data/lib/byebug/commands/set.rb +13 -11
- data/lib/byebug/commands/show.rb +7 -5
- data/lib/byebug/commands/skip.rb +85 -0
- data/lib/byebug/commands/source.rb +7 -7
- data/lib/byebug/commands/step.rb +8 -6
- data/lib/byebug/commands/thread/current.rb +6 -4
- data/lib/byebug/commands/thread/list.rb +7 -5
- data/lib/byebug/commands/thread/resume.rb +7 -7
- data/lib/byebug/commands/thread/stop.rb +6 -4
- data/lib/byebug/commands/thread/switch.rb +6 -4
- data/lib/byebug/commands/thread.rb +11 -9
- data/lib/byebug/commands/tracevar.rb +10 -11
- data/lib/byebug/commands/undisplay.rb +12 -11
- data/lib/byebug/commands/untracevar.rb +8 -6
- data/lib/byebug/commands/up.rb +10 -8
- data/lib/byebug/commands/var/all.rb +7 -5
- data/lib/byebug/commands/var/args.rb +6 -4
- data/lib/byebug/commands/var/const.rb +9 -9
- data/lib/byebug/commands/var/global.rb +5 -3
- data/lib/byebug/commands/var/instance.rb +6 -4
- data/lib/byebug/commands/var/local.rb +6 -4
- data/lib/byebug/commands/var.rb +12 -10
- data/lib/byebug/commands/where.rb +9 -7
- data/lib/byebug/commands.rb +40 -37
- data/lib/byebug/context.rb +7 -5
- data/lib/byebug/core.rb +26 -25
- data/lib/byebug/errors.rb +4 -2
- data/lib/byebug/frame.rb +19 -22
- data/lib/byebug/helpers/bin.rb +47 -0
- data/lib/byebug/helpers/eval.rb +15 -13
- data/lib/byebug/helpers/file.rb +6 -4
- data/lib/byebug/helpers/frame.rb +7 -5
- data/lib/byebug/helpers/parse.rb +5 -5
- data/lib/byebug/helpers/path.rb +9 -11
- data/lib/byebug/helpers/reflection.rb +2 -0
- data/lib/byebug/helpers/string.rb +11 -2
- data/lib/byebug/helpers/thread.rb +10 -8
- data/lib/byebug/helpers/toggle.rb +28 -27
- data/lib/byebug/helpers/var.rb +9 -7
- data/lib/byebug/history.rb +20 -11
- data/lib/byebug/interface.rb +13 -11
- data/lib/byebug/interfaces/local_interface.rb +25 -7
- data/lib/byebug/interfaces/remote_interface.rb +21 -9
- data/lib/byebug/interfaces/script_interface.rb +4 -1
- data/lib/byebug/interfaces/test_interface.rb +5 -3
- data/lib/byebug/option_setter.rb +14 -12
- data/lib/byebug/printers/base.rb +10 -10
- data/lib/byebug/printers/plain.rb +9 -8
- data/lib/byebug/printers/texts/base.yml +7 -3
- data/lib/byebug/printers/texts/plain.yml +1 -1
- data/lib/byebug/processors/command_processor.rb +11 -12
- data/lib/byebug/processors/control_processor.rb +4 -6
- data/lib/byebug/processors/post_mortem_processor.rb +4 -2
- data/lib/byebug/processors/script_processor.rb +7 -3
- data/lib/byebug/remote/client.rb +57 -0
- data/lib/byebug/remote/server.rb +47 -0
- data/lib/byebug/remote.rb +46 -66
- data/lib/byebug/runner.rb +43 -49
- data/lib/byebug/setting.rb +11 -5
- data/lib/byebug/settings/autoirb.rb +7 -5
- data/lib/byebug/settings/autolist.rb +7 -5
- data/lib/byebug/settings/autopry.rb +7 -5
- data/lib/byebug/settings/autosave.rb +4 -2
- data/lib/byebug/settings/basename.rb +4 -2
- data/lib/byebug/settings/callstyle.rb +4 -3
- data/lib/byebug/settings/fullpath.rb +4 -2
- data/lib/byebug/settings/histfile.rb +5 -3
- data/lib/byebug/settings/histsize.rb +4 -2
- data/lib/byebug/settings/linetrace.rb +6 -4
- data/lib/byebug/settings/listsize.rb +4 -2
- data/lib/byebug/settings/post_mortem.rb +6 -4
- data/lib/byebug/settings/savefile.rb +4 -2
- data/lib/byebug/settings/stack_on_error.rb +4 -2
- data/lib/byebug/settings/width.rb +3 -1
- data/lib/byebug/source_file_formatter.rb +71 -0
- data/lib/byebug/subcommands.rb +6 -4
- data/lib/byebug/version.rb +2 -1
- data/lib/byebug.rb +3 -1
- metadata +22 -20
- data/bin/byebug +0 -7
data/ext/byebug/byebug.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#include "byebug.h"
|
2
2
|
|
3
|
-
static VALUE mByebug;
|
3
|
+
static VALUE mByebug; /* Ruby Byebug Module object */
|
4
4
|
|
5
5
|
static VALUE tracing = Qfalse;
|
6
6
|
static VALUE post_mortem = Qfalse;
|
@@ -75,7 +75,7 @@ check_started()
|
|
75
75
|
}
|
76
76
|
|
77
77
|
static void
|
78
|
-
trace_print(rb_trace_arg_t *
|
78
|
+
trace_print(rb_trace_arg_t *trace_arg, debug_context_t *dc,
|
79
79
|
const char *file_filter, const char *debug_msg)
|
80
80
|
{
|
81
81
|
char *fullpath = NULL;
|
@@ -127,7 +127,7 @@ trace_print(rb_trace_arg_t * trace_arg, debug_context_t * dc,
|
|
127
127
|
}
|
128
128
|
|
129
129
|
static void
|
130
|
-
cleanup(debug_context_t *
|
130
|
+
cleanup(debug_context_t *dc)
|
131
131
|
{
|
132
132
|
dc->stop_reason = CTX_STOP_NONE;
|
133
133
|
|
@@ -156,11 +156,11 @@ cleanup(debug_context_t * dc)
|
|
156
156
|
if (CTX_FL_TEST(dc, CTX_FL_IGNORE)) \
|
157
157
|
return; \
|
158
158
|
\
|
159
|
-
acquire_lock(dc);
|
160
|
-
|
159
|
+
acquire_lock(dc);
|
160
|
+
|
161
161
|
|
162
|
-
#define CALL_EVENT_SETUP
|
163
|
-
dc->calced_stack_size++;
|
162
|
+
#define CALL_EVENT_SETUP \
|
163
|
+
dc->calced_stack_size++; \
|
164
164
|
dc->steps_out = dc->steps_out < 0 ? -1 : dc->steps_out + 1;
|
165
165
|
|
166
166
|
#define RETURN_EVENT_SETUP \
|
@@ -176,7 +176,7 @@ cleanup(debug_context_t * dc)
|
|
176
176
|
/* Functions that return control to byebug after the different events */
|
177
177
|
|
178
178
|
static VALUE
|
179
|
-
call_at(VALUE ctx, debug_context_t *
|
179
|
+
call_at(VALUE ctx, debug_context_t *dc, ID mid, int argc, VALUE arg)
|
180
180
|
{
|
181
181
|
struct call_with_inspection_data cwi;
|
182
182
|
VALUE argv[1];
|
@@ -193,19 +193,19 @@ call_at(VALUE ctx, debug_context_t * dc, ID mid, int argc, VALUE arg)
|
|
193
193
|
}
|
194
194
|
|
195
195
|
static VALUE
|
196
|
-
call_at_line(VALUE ctx, debug_context_t *
|
196
|
+
call_at_line(VALUE ctx, debug_context_t *dc)
|
197
197
|
{
|
198
198
|
return call_at(ctx, dc, rb_intern("at_line"), 0, Qnil);
|
199
199
|
}
|
200
200
|
|
201
201
|
static VALUE
|
202
|
-
call_at_tracing(VALUE ctx, debug_context_t *
|
202
|
+
call_at_tracing(VALUE ctx, debug_context_t *dc)
|
203
203
|
{
|
204
204
|
return call_at(ctx, dc, rb_intern("at_tracing"), 0, Qnil);
|
205
205
|
}
|
206
206
|
|
207
207
|
static VALUE
|
208
|
-
call_at_breakpoint(VALUE ctx, debug_context_t *
|
208
|
+
call_at_breakpoint(VALUE ctx, debug_context_t *dc, VALUE breakpoint)
|
209
209
|
{
|
210
210
|
dc->stop_reason = CTX_STOP_BREAKPOINT;
|
211
211
|
|
@@ -213,7 +213,7 @@ call_at_breakpoint(VALUE ctx, debug_context_t * dc, VALUE breakpoint)
|
|
213
213
|
}
|
214
214
|
|
215
215
|
static VALUE
|
216
|
-
call_at_catchpoint(VALUE ctx, debug_context_t *
|
216
|
+
call_at_catchpoint(VALUE ctx, debug_context_t *dc, VALUE exp)
|
217
217
|
{
|
218
218
|
dc->stop_reason = CTX_STOP_CATCHPOINT;
|
219
219
|
|
@@ -221,7 +221,7 @@ call_at_catchpoint(VALUE ctx, debug_context_t * dc, VALUE exp)
|
|
221
221
|
}
|
222
222
|
|
223
223
|
static VALUE
|
224
|
-
call_at_return(VALUE ctx, debug_context_t *
|
224
|
+
call_at_return(VALUE ctx, debug_context_t *dc, VALUE return_value)
|
225
225
|
{
|
226
226
|
dc->stop_reason = CTX_STOP_BREAKPOINT;
|
227
227
|
|
@@ -229,7 +229,7 @@ call_at_return(VALUE ctx, debug_context_t * dc, VALUE return_value)
|
|
229
229
|
}
|
230
230
|
|
231
231
|
static VALUE
|
232
|
-
call_at_end(VALUE ctx, debug_context_t *
|
232
|
+
call_at_end(VALUE ctx, debug_context_t *dc)
|
233
233
|
{
|
234
234
|
dc->stop_reason = CTX_STOP_BREAKPOINT;
|
235
235
|
|
@@ -237,14 +237,14 @@ call_at_end(VALUE ctx, debug_context_t * dc)
|
|
237
237
|
}
|
238
238
|
|
239
239
|
static void
|
240
|
-
call_at_line_check(VALUE ctx, debug_context_t *
|
240
|
+
call_at_line_check(VALUE ctx, debug_context_t *dc, VALUE breakpoint)
|
241
241
|
{
|
242
242
|
dc->stop_reason = CTX_STOP_STEP;
|
243
243
|
|
244
244
|
if (!NIL_P(breakpoint))
|
245
245
|
call_at_breakpoint(ctx, dc, breakpoint);
|
246
246
|
|
247
|
-
|
247
|
+
byebug_reset_stepping_stop_points(dc);
|
248
248
|
|
249
249
|
call_at_line(ctx, dc);
|
250
250
|
}
|
@@ -305,14 +305,7 @@ call_event(VALUE trace_point, void *data)
|
|
305
305
|
|
306
306
|
CALL_EVENT_SETUP;
|
307
307
|
|
308
|
-
/* nil method_id means we are at top level so there can't be a method
|
309
|
-
* breakpoint here. Just leave then. */
|
310
308
|
msym = rb_tracearg_method_id(trace_arg);
|
311
|
-
if (NIL_P(msym))
|
312
|
-
{
|
313
|
-
EVENT_TEARDOWN;
|
314
|
-
return;
|
315
|
-
}
|
316
309
|
|
317
310
|
mid = SYM2ID(msym);
|
318
311
|
klass = rb_tracearg_defined_class(trace_arg);
|
@@ -344,7 +337,7 @@ return_event(VALUE trace_point, void *data)
|
|
344
337
|
|
345
338
|
if ((dc->steps_out == 0) && (CTX_FL_TEST(dc, CTX_FL_STOP_ON_RET)))
|
346
339
|
{
|
347
|
-
|
340
|
+
byebug_reset_stepping_stop_points(dc);
|
348
341
|
|
349
342
|
call_at_return(context, dc, rb_tracearg_return_value(trace_arg));
|
350
343
|
}
|
@@ -367,7 +360,9 @@ return_event(VALUE trace_point, void *data)
|
|
367
360
|
* [#7] b_return@/hort/core_ext/numeric/conversions.rb:133 BigDecimal#to_s
|
368
361
|
* [#7] return@:0 Fixnum#to_s # => This guy...
|
369
362
|
*/
|
370
|
-
if (
|
363
|
+
if (NIL_P(file))
|
364
|
+
rb_warn("The TracePoint API emitted a return event without file information. It might be a bug, please report this.");
|
365
|
+
else
|
371
366
|
{
|
372
367
|
line = rb_tracearg_lineno(trace_arg);
|
373
368
|
binding = rb_tracearg_binding(trace_arg);
|
@@ -393,7 +388,7 @@ end_event(VALUE trace_point, void *data)
|
|
393
388
|
|
394
389
|
if ((dc->steps_out == 0) && (CTX_FL_TEST(dc, CTX_FL_STOP_ON_RET)))
|
395
390
|
{
|
396
|
-
|
391
|
+
byebug_reset_stepping_stop_points(dc);
|
397
392
|
|
398
393
|
call_at_end(context, dc);
|
399
394
|
}
|
@@ -436,7 +431,7 @@ raise_event(VALUE trace_point, void *data)
|
|
436
431
|
|
437
432
|
raised_exception = rb_tracearg_raised_exception(trace_arg);
|
438
433
|
|
439
|
-
if (post_mortem == Qtrue)
|
434
|
+
if (post_mortem == Qtrue && !rb_ivar_defined(raised_exception, rb_intern("@__bb_context")))
|
440
435
|
{
|
441
436
|
pm_context = context_dup(dc);
|
442
437
|
rb_ivar_set(raised_exception, rb_intern("@__bb_context"), pm_context);
|
@@ -721,7 +716,7 @@ Start(VALUE self)
|
|
721
716
|
* +stop+ parameter forces byebug to stop at the first line of code in +file+
|
722
717
|
*/
|
723
718
|
static VALUE
|
724
|
-
Debug_load(int argc, VALUE *
|
719
|
+
Debug_load(int argc, VALUE *argv, VALUE self)
|
725
720
|
{
|
726
721
|
VALUE file, stop, context;
|
727
722
|
debug_context_t *dc;
|
@@ -747,7 +742,7 @@ Debug_load(int argc, VALUE * argv, VALUE self)
|
|
747
742
|
if (0 != state)
|
748
743
|
{
|
749
744
|
status = rb_errinfo();
|
750
|
-
|
745
|
+
byebug_reset_stepping_stop_points(dc);
|
751
746
|
}
|
752
747
|
|
753
748
|
return status;
|
@@ -891,8 +886,8 @@ Init_byebug()
|
|
891
886
|
rb_define_module_function(mByebug, "verbose=", Set_verbose, 1);
|
892
887
|
|
893
888
|
Init_threads_table(mByebug);
|
894
|
-
|
895
|
-
|
889
|
+
Init_byebug_context(mByebug);
|
890
|
+
Init_byebug_breakpoint(mByebug);
|
896
891
|
|
897
892
|
rb_global_variable(&breakpoints);
|
898
893
|
rb_global_variable(&catchpoints);
|
data/ext/byebug/byebug.h
CHANGED
@@ -8,18 +8,26 @@
|
|
8
8
|
#define UNUSED(x) (void)(x)
|
9
9
|
|
10
10
|
/* flags */
|
11
|
-
#define CTX_FL_DEAD
|
12
|
-
#define CTX_FL_IGNORE
|
13
|
-
#define CTX_FL_SUSPEND
|
14
|
-
#define CTX_FL_TRACING
|
15
|
-
#define CTX_FL_WAS_RUNNING
|
16
|
-
#define CTX_FL_STOP_ON_RET
|
17
|
-
#define CTX_FL_IGNORE_STEPS (1<<7)
|
11
|
+
#define CTX_FL_DEAD (1 << 1) /* this context belonged to a dead thread */
|
12
|
+
#define CTX_FL_IGNORE (1 << 2) /* this context belongs to ignored thread */
|
13
|
+
#define CTX_FL_SUSPEND (1 << 3) /* thread currently suspended */
|
14
|
+
#define CTX_FL_TRACING (1 << 4) /* call at_tracing method */
|
15
|
+
#define CTX_FL_WAS_RUNNING (1 << 5) /* thread was previously running */
|
16
|
+
#define CTX_FL_STOP_ON_RET (1 << 6) /* can stop on method 'end' */
|
17
|
+
#define CTX_FL_IGNORE_STEPS (1 << 7) /* doesn't countdown steps to break */
|
18
18
|
|
19
19
|
/* macro functions */
|
20
|
-
#define CTX_FL_TEST(c,f) ((c)->flags & (f))
|
21
|
-
#define CTX_FL_SET(c,
|
22
|
-
|
20
|
+
#define CTX_FL_TEST(c, f) ((c)->flags & (f))
|
21
|
+
#define CTX_FL_SET(c, f) \
|
22
|
+
do \
|
23
|
+
{ \
|
24
|
+
(c)->flags |= (f); \
|
25
|
+
} while (0)
|
26
|
+
#define CTX_FL_UNSET(c, f) \
|
27
|
+
do \
|
28
|
+
{ \
|
29
|
+
(c)->flags &= ~(f); \
|
30
|
+
} while (0)
|
23
31
|
|
24
32
|
/* types */
|
25
33
|
typedef enum
|
@@ -39,12 +47,12 @@ typedef struct
|
|
39
47
|
VALUE thread;
|
40
48
|
int thnum;
|
41
49
|
|
42
|
-
int dest_frame;
|
43
|
-
int lines;
|
44
|
-
int steps;
|
45
|
-
int steps_out;
|
50
|
+
int dest_frame; /* next stop's frame if stopped by next */
|
51
|
+
int lines; /* # of lines in dest_frame before stopping */
|
52
|
+
int steps; /* # of steps before stopping */
|
53
|
+
int steps_out; /* # of returns before stopping */
|
46
54
|
|
47
|
-
VALUE backtrace;
|
55
|
+
VALUE backtrace; /* [[loc, self, klass, binding], ...] */
|
48
56
|
} debug_context_t;
|
49
57
|
|
50
58
|
typedef enum
|
@@ -70,10 +78,18 @@ typedef struct
|
|
70
78
|
} threads_table_t;
|
71
79
|
|
72
80
|
enum bp_type
|
73
|
-
{
|
81
|
+
{
|
82
|
+
BP_POS_TYPE,
|
83
|
+
BP_METHOD_TYPE
|
84
|
+
};
|
74
85
|
|
75
86
|
enum hit_condition
|
76
|
-
{
|
87
|
+
{
|
88
|
+
HIT_COND_NONE,
|
89
|
+
HIT_COND_GE,
|
90
|
+
HIT_COND_EQ,
|
91
|
+
HIT_COND_MOD
|
92
|
+
};
|
77
93
|
|
78
94
|
typedef struct
|
79
95
|
{
|
@@ -93,16 +109,16 @@ typedef struct
|
|
93
109
|
} breakpoint_t;
|
94
110
|
|
95
111
|
/* functions from locker.c */
|
96
|
-
extern void
|
97
|
-
extern VALUE
|
98
|
-
extern void
|
112
|
+
extern void byebug_add_to_locked(VALUE thread);
|
113
|
+
extern VALUE byebug_pop_from_locked();
|
114
|
+
extern void byebug_remove_from_locked(VALUE thread);
|
99
115
|
|
100
116
|
/* functions from threads.c */
|
101
117
|
extern void Init_threads_table(VALUE mByebug);
|
102
118
|
extern VALUE create_threads_table(void);
|
103
|
-
extern void thread_context_lookup(VALUE thread, VALUE *
|
119
|
+
extern void thread_context_lookup(VALUE thread, VALUE *context);
|
104
120
|
extern int is_living_thread(VALUE thread);
|
105
|
-
extern void acquire_lock(debug_context_t *
|
121
|
+
extern void acquire_lock(debug_context_t *dc);
|
106
122
|
extern void release_lock(void);
|
107
123
|
|
108
124
|
/* global variables */
|
@@ -110,16 +126,16 @@ extern VALUE threads;
|
|
110
126
|
extern VALUE next_thread;
|
111
127
|
|
112
128
|
/* functions from context.c */
|
113
|
-
extern void
|
114
|
-
extern VALUE
|
115
|
-
extern VALUE context_dup(debug_context_t *
|
116
|
-
extern void
|
129
|
+
extern void Init_byebug_context(VALUE mByebug);
|
130
|
+
extern VALUE byebug_context_create(VALUE thread);
|
131
|
+
extern VALUE context_dup(debug_context_t *context);
|
132
|
+
extern void byebug_reset_stepping_stop_points(debug_context_t *context);
|
117
133
|
extern VALUE call_with_debug_inspector(struct call_with_inspection_data *data);
|
118
|
-
extern VALUE context_backtrace_set(const rb_debug_inspector_t *
|
134
|
+
extern VALUE context_backtrace_set(const rb_debug_inspector_t *inspector,
|
119
135
|
void *data);
|
120
136
|
|
121
137
|
/* functions from breakpoint.c */
|
122
|
-
extern void
|
138
|
+
extern void Init_byebug_breakpoint(VALUE mByebug);
|
123
139
|
extern VALUE find_breakpoint_by_pos(VALUE breakpoints, VALUE source, VALUE pos,
|
124
140
|
VALUE bind);
|
125
141
|
|
data/ext/byebug/context.c
CHANGED
@@ -5,9 +5,9 @@ static VALUE cDebugThread;
|
|
5
5
|
static int thnum_max = 0;
|
6
6
|
|
7
7
|
/* "Step", "Next" and "Finish" do their work by saving information about where
|
8
|
-
* to stop next.
|
8
|
+
* to stop next. byebug_reset_stepping_stop_points removes/resets this information. */
|
9
9
|
extern void
|
10
|
-
|
10
|
+
byebug_reset_stepping_stop_points(debug_context_t *context)
|
11
11
|
{
|
12
12
|
context->dest_frame = -1;
|
13
13
|
context->lines = -1;
|
@@ -34,19 +34,19 @@ Context_dead(VALUE self)
|
|
34
34
|
static void
|
35
35
|
context_mark(void *data)
|
36
36
|
{
|
37
|
-
debug_context_t *context = (debug_context_t *)
|
37
|
+
debug_context_t *context = (debug_context_t *)data;
|
38
38
|
|
39
39
|
rb_gc_mark(context->backtrace);
|
40
40
|
}
|
41
41
|
|
42
42
|
static VALUE
|
43
|
-
dc_backtrace(const debug_context_t *
|
43
|
+
dc_backtrace(const debug_context_t *context)
|
44
44
|
{
|
45
45
|
return context->backtrace;
|
46
46
|
}
|
47
47
|
|
48
48
|
static int
|
49
|
-
dc_stack_size(debug_context_t *
|
49
|
+
dc_stack_size(debug_context_t *context)
|
50
50
|
{
|
51
51
|
|
52
52
|
if (NIL_P(dc_backtrace(context)))
|
@@ -56,14 +56,14 @@ dc_stack_size(debug_context_t * context)
|
|
56
56
|
}
|
57
57
|
|
58
58
|
extern VALUE
|
59
|
-
|
59
|
+
byebug_context_create(VALUE thread)
|
60
60
|
{
|
61
61
|
debug_context_t *context = ALLOC(debug_context_t);
|
62
62
|
|
63
63
|
context->flags = 0;
|
64
64
|
context->thnum = ++thnum_max;
|
65
65
|
context->thread = thread;
|
66
|
-
|
66
|
+
byebug_reset_stepping_stop_points(context);
|
67
67
|
context->stop_reason = CTX_STOP_NONE;
|
68
68
|
|
69
69
|
rb_debug_inspector_open(context_backtrace_set, (void *)context);
|
@@ -76,12 +76,12 @@ context_create(VALUE thread)
|
|
76
76
|
}
|
77
77
|
|
78
78
|
extern VALUE
|
79
|
-
context_dup(debug_context_t *
|
79
|
+
context_dup(debug_context_t *context)
|
80
80
|
{
|
81
81
|
debug_context_t *new_context = ALLOC(debug_context_t);
|
82
82
|
|
83
83
|
memcpy(new_context, context, sizeof(debug_context_t));
|
84
|
-
|
84
|
+
byebug_reset_stepping_stop_points(new_context);
|
85
85
|
new_context->backtrace = context->backtrace;
|
86
86
|
CTX_FL_SET(new_context, CTX_FL_DEAD);
|
87
87
|
|
@@ -90,7 +90,7 @@ context_dup(debug_context_t * context)
|
|
90
90
|
|
91
91
|
|
92
92
|
static VALUE
|
93
|
-
dc_frame_get(const debug_context_t *
|
93
|
+
dc_frame_get(const debug_context_t *context, int frame_index, frame_part type)
|
94
94
|
{
|
95
95
|
VALUE frame;
|
96
96
|
|
@@ -105,31 +105,31 @@ dc_frame_get(const debug_context_t * context, int frame_index, frame_part type)
|
|
105
105
|
}
|
106
106
|
|
107
107
|
static VALUE
|
108
|
-
dc_frame_location(const debug_context_t *
|
108
|
+
dc_frame_location(const debug_context_t *context, int frame_index)
|
109
109
|
{
|
110
110
|
return dc_frame_get(context, frame_index, LOCATION);
|
111
111
|
}
|
112
112
|
|
113
113
|
static VALUE
|
114
|
-
dc_frame_self(const debug_context_t *
|
114
|
+
dc_frame_self(const debug_context_t *context, int frame_index)
|
115
115
|
{
|
116
116
|
return dc_frame_get(context, frame_index, SELF);
|
117
117
|
}
|
118
118
|
|
119
119
|
static VALUE
|
120
|
-
dc_frame_class(const debug_context_t *
|
120
|
+
dc_frame_class(const debug_context_t *context, int frame_index)
|
121
121
|
{
|
122
122
|
return dc_frame_get(context, frame_index, CLASS);
|
123
123
|
}
|
124
124
|
|
125
125
|
static VALUE
|
126
|
-
dc_frame_binding(const debug_context_t *
|
126
|
+
dc_frame_binding(const debug_context_t *context, int frame_index)
|
127
127
|
{
|
128
128
|
return dc_frame_get(context, frame_index, BINDING);
|
129
129
|
}
|
130
130
|
|
131
131
|
static VALUE
|
132
|
-
load_backtrace(const rb_debug_inspector_t *
|
132
|
+
load_backtrace(const rb_debug_inspector_t *inspector)
|
133
133
|
{
|
134
134
|
VALUE backtrace = rb_ary_new();
|
135
135
|
VALUE locs = rb_debug_inspector_backtrace_locations(inspector);
|
@@ -151,9 +151,9 @@ load_backtrace(const rb_debug_inspector_t * inspector)
|
|
151
151
|
}
|
152
152
|
|
153
153
|
extern VALUE
|
154
|
-
context_backtrace_set(const rb_debug_inspector_t *
|
154
|
+
context_backtrace_set(const rb_debug_inspector_t *inspector, void *data)
|
155
155
|
{
|
156
|
-
debug_context_t *dc = (debug_context_t *)
|
156
|
+
debug_context_t *dc = (debug_context_t *)data;
|
157
157
|
|
158
158
|
dc->backtrace = load_backtrace(inspector);
|
159
159
|
|
@@ -161,7 +161,7 @@ context_backtrace_set(const rb_debug_inspector_t * inspector, void *data)
|
|
161
161
|
}
|
162
162
|
|
163
163
|
static VALUE
|
164
|
-
open_debug_inspector_i(const rb_debug_inspector_t *
|
164
|
+
open_debug_inspector_i(const rb_debug_inspector_t *inspector, void *data)
|
165
165
|
{
|
166
166
|
struct call_with_inspection_data *cwi =
|
167
167
|
(struct call_with_inspection_data *)data;
|
@@ -177,6 +177,13 @@ open_debug_inspector(struct call_with_inspection_data *cwi)
|
|
177
177
|
return rb_debug_inspector_open(open_debug_inspector_i, cwi);
|
178
178
|
}
|
179
179
|
|
180
|
+
static VALUE
|
181
|
+
open_debug_inspector_ensure(VALUE v)
|
182
|
+
{
|
183
|
+
return open_debug_inspector((struct call_with_inspection_data *)v);
|
184
|
+
}
|
185
|
+
|
186
|
+
|
180
187
|
static VALUE
|
181
188
|
close_debug_inspector(struct call_with_inspection_data *cwi)
|
182
189
|
{
|
@@ -184,11 +191,17 @@ close_debug_inspector(struct call_with_inspection_data *cwi)
|
|
184
191
|
return Qnil;
|
185
192
|
}
|
186
193
|
|
194
|
+
static VALUE
|
195
|
+
close_debug_inspector_ensure(VALUE v)
|
196
|
+
{
|
197
|
+
return close_debug_inspector((struct call_with_inspection_data *)v);
|
198
|
+
}
|
199
|
+
|
187
200
|
extern VALUE
|
188
201
|
call_with_debug_inspector(struct call_with_inspection_data *data)
|
189
202
|
{
|
190
|
-
return rb_ensure(
|
191
|
-
(VALUE)
|
203
|
+
return rb_ensure(open_debug_inspector_ensure, (VALUE)data, close_debug_inspector_ensure,
|
204
|
+
(VALUE)data);
|
192
205
|
}
|
193
206
|
|
194
207
|
#define FRAME_SETUP \
|
@@ -208,7 +221,7 @@ call_with_debug_inspector(struct call_with_inspection_data *data)
|
|
208
221
|
* Returns frame's binding.
|
209
222
|
*/
|
210
223
|
static VALUE
|
211
|
-
Context_frame_binding(int argc, VALUE *
|
224
|
+
Context_frame_binding(int argc, VALUE *argv, VALUE self)
|
212
225
|
{
|
213
226
|
FRAME_SETUP;
|
214
227
|
|
@@ -217,12 +230,12 @@ Context_frame_binding(int argc, VALUE * argv, VALUE self)
|
|
217
230
|
|
218
231
|
/*
|
219
232
|
* call-seq:
|
220
|
-
* context.frame_class(frame_position = 0) ->
|
233
|
+
* context.frame_class(frame_position = 0) -> class
|
221
234
|
*
|
222
235
|
* Returns frame's defined class.
|
223
236
|
*/
|
224
237
|
static VALUE
|
225
|
-
Context_frame_class(int argc, VALUE *
|
238
|
+
Context_frame_class(int argc, VALUE *argv, VALUE self)
|
226
239
|
{
|
227
240
|
FRAME_SETUP;
|
228
241
|
|
@@ -236,7 +249,7 @@ Context_frame_class(int argc, VALUE * argv, VALUE self)
|
|
236
249
|
* Returns the name of the file in the frame.
|
237
250
|
*/
|
238
251
|
static VALUE
|
239
|
-
Context_frame_file(int argc, VALUE *
|
252
|
+
Context_frame_file(int argc, VALUE *argv, VALUE self)
|
240
253
|
{
|
241
254
|
VALUE loc, absolute_path;
|
242
255
|
|
@@ -259,7 +272,7 @@ Context_frame_file(int argc, VALUE * argv, VALUE self)
|
|
259
272
|
* Returns the line number in the file in the frame.
|
260
273
|
*/
|
261
274
|
static VALUE
|
262
|
-
Context_frame_line(int argc, VALUE *
|
275
|
+
Context_frame_line(int argc, VALUE *argv, VALUE self)
|
263
276
|
{
|
264
277
|
VALUE loc;
|
265
278
|
|
@@ -277,7 +290,7 @@ Context_frame_line(int argc, VALUE * argv, VALUE self)
|
|
277
290
|
* Returns the sym of the method in the frame.
|
278
291
|
*/
|
279
292
|
static VALUE
|
280
|
-
Context_frame_method(int argc, VALUE *
|
293
|
+
Context_frame_method(int argc, VALUE *argv, VALUE self)
|
281
294
|
{
|
282
295
|
VALUE loc;
|
283
296
|
|
@@ -295,7 +308,7 @@ Context_frame_method(int argc, VALUE * argv, VALUE self)
|
|
295
308
|
* Returns self object of the frame.
|
296
309
|
*/
|
297
310
|
static VALUE
|
298
|
-
Context_frame_self(int argc, VALUE *
|
311
|
+
Context_frame_self(int argc, VALUE *argv, VALUE self)
|
299
312
|
{
|
300
313
|
FRAME_SETUP;
|
301
314
|
|
@@ -395,7 +408,7 @@ Context_stop_reason(VALUE self)
|
|
395
408
|
* +frame+ (by default the newest one).
|
396
409
|
*/
|
397
410
|
static VALUE
|
398
|
-
Context_step_into(int argc, VALUE *
|
411
|
+
Context_step_into(int argc, VALUE *argv, VALUE self)
|
399
412
|
{
|
400
413
|
VALUE steps, v_frame;
|
401
414
|
int n_args, from_frame;
|
@@ -435,7 +448,7 @@ Context_step_into(int argc, VALUE * argv, VALUE self)
|
|
435
448
|
* event for that frame is triggered.
|
436
449
|
*/
|
437
450
|
static VALUE
|
438
|
-
Context_step_out(int argc, VALUE *
|
451
|
+
Context_step_out(int argc, VALUE *argv, VALUE self)
|
439
452
|
{
|
440
453
|
int n_args, n_frames;
|
441
454
|
VALUE v_frames, force;
|
@@ -468,7 +481,7 @@ Context_step_out(int argc, VALUE * argv, VALUE self)
|
|
468
481
|
* higher (if frame +frame+ finishes).
|
469
482
|
*/
|
470
483
|
static VALUE
|
471
|
-
Context_step_over(int argc, VALUE *
|
484
|
+
Context_step_over(int argc, VALUE *argv, VALUE self)
|
472
485
|
{
|
473
486
|
int n_args, frame;
|
474
487
|
VALUE lines, v_frame;
|
@@ -642,7 +655,7 @@ dt_inherited(VALUE klass)
|
|
642
655
|
* Byebug keeps a single instance of this class per thread.
|
643
656
|
*/
|
644
657
|
void
|
645
|
-
|
658
|
+
Init_byebug_context(VALUE mByebug)
|
646
659
|
{
|
647
660
|
cContext = rb_define_class_under(mByebug, "Context", rb_cObject);
|
648
661
|
|
@@ -669,5 +682,5 @@ Init_context(VALUE mByebug)
|
|
669
682
|
rb_define_method(cContext, "tracing=", Context_set_tracing, 1);
|
670
683
|
|
671
684
|
cDebugThread = rb_define_class_under(mByebug, "DebugThread", rb_cThread);
|
672
|
-
rb_define_singleton_method(cDebugThread, "inherited", dt_inherited,
|
685
|
+
rb_define_singleton_method(cDebugThread, "inherited", dt_inherited, 0);
|
673
686
|
}
|
data/ext/byebug/extconf.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mkmf"
|
2
4
|
|
3
5
|
makefile_config = RbConfig::MAKEFILE_CONFIG
|
4
6
|
|
5
|
-
makefile_config[
|
7
|
+
makefile_config["CC"] = ENV["CC"] if ENV["CC"]
|
6
8
|
|
7
|
-
makefile_config[
|
9
|
+
makefile_config["CFLAGS"] << " -gdwarf-2 -g3 -O0" if ENV["debug"]
|
8
10
|
|
9
|
-
dir_config(
|
10
|
-
with_cflags(makefile_config[
|
11
|
+
dir_config("ruby")
|
12
|
+
with_cflags(makefile_config["CFLAGS"]) { create_makefile("byebug/byebug") }
|
data/ext/byebug/locker.c
CHANGED
@@ -29,7 +29,7 @@ is_in_locked(VALUE thread)
|
|
29
29
|
}
|
30
30
|
|
31
31
|
extern void
|
32
|
-
|
32
|
+
byebug_add_to_locked(VALUE thread)
|
33
33
|
{
|
34
34
|
locked_thread_t *node;
|
35
35
|
|
@@ -50,7 +50,7 @@ add_to_locked(VALUE thread)
|
|
50
50
|
}
|
51
51
|
|
52
52
|
extern VALUE
|
53
|
-
|
53
|
+
byebug_pop_from_locked()
|
54
54
|
{
|
55
55
|
VALUE thread;
|
56
56
|
locked_thread_t *node;
|
@@ -71,7 +71,7 @@ pop_from_locked()
|
|
71
71
|
}
|
72
72
|
|
73
73
|
extern void
|
74
|
-
|
74
|
+
byebug_remove_from_locked(VALUE thread)
|
75
75
|
{
|
76
76
|
locked_thread_t *node;
|
77
77
|
locked_thread_t *next_node;
|
@@ -81,7 +81,7 @@ remove_from_locked(VALUE thread)
|
|
81
81
|
|
82
82
|
if (locked_head->thread == thread)
|
83
83
|
{
|
84
|
-
|
84
|
+
byebug_pop_from_locked();
|
85
85
|
return;
|
86
86
|
}
|
87
87
|
|