ruby-debug-base 0.9.3-mswin32 → 0.10.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/CHANGES +41 -0
- data/README +27 -13
- data/Rakefile +220 -0
- data/ext/ChangeLog +1110 -0
- data/ext/ruby_debug.c +274 -34
- data/ext/win32/Makefile +149 -0
- data/ext/win32/ruby_debug.o +0 -0
- data/ext/win32/ruby_debug.so +0 -0
- data/lib/ChangeLog +1147 -0
- data/lib/ruby-debug-base.rb +17 -11
- data/lib/ruby_debug.so +0 -0
- data/test/test-ruby-debug-base.rb +76 -0
- metadata +18 -12
data/ext/ruby_debug.c
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
#include <node.h>
|
4
4
|
#include <rubysig.h>
|
5
5
|
#include <st.h>
|
6
|
+
#include <version.h>
|
6
7
|
|
7
|
-
#define DEBUG_VERSION "0.
|
8
|
+
#define DEBUG_VERSION "0.10.0"
|
8
9
|
|
9
10
|
#ifdef _WIN32
|
10
11
|
struct FRAME {
|
@@ -67,6 +68,7 @@ RUBY_EXTERN struct RVarmap *ruby_dyna_vars;
|
|
67
68
|
#define STACK_SIZE_INCREMENT 128
|
68
69
|
|
69
70
|
typedef struct {
|
71
|
+
int argc; /* Number of arguments a frame should have. */
|
70
72
|
VALUE binding;
|
71
73
|
ID id;
|
72
74
|
ID orig_id;
|
@@ -74,6 +76,7 @@ typedef struct {
|
|
74
76
|
const char * file;
|
75
77
|
short dead;
|
76
78
|
VALUE self;
|
79
|
+
VALUE arg_ary;
|
77
80
|
union {
|
78
81
|
struct {
|
79
82
|
struct FRAME *frame;
|
@@ -81,7 +84,9 @@ typedef struct {
|
|
81
84
|
struct RVarmap *dyna_vars;
|
82
85
|
} runtime;
|
83
86
|
struct {
|
87
|
+
VALUE args;
|
84
88
|
VALUE locals;
|
89
|
+
VALUE arg_ary;
|
85
90
|
} copy;
|
86
91
|
} info;
|
87
92
|
} debug_frame_t;
|
@@ -118,6 +123,7 @@ typedef struct {
|
|
118
123
|
ID mid;
|
119
124
|
} pos;
|
120
125
|
VALUE expr;
|
126
|
+
VALUE enabled;
|
121
127
|
int hit_count;
|
122
128
|
int hit_value;
|
123
129
|
enum hit_condition hit_condition;
|
@@ -135,6 +141,7 @@ static VALUE locker = Qnil;
|
|
135
141
|
static VALUE post_mortem = Qfalse;
|
136
142
|
static VALUE keep_frame_binding = Qfalse;
|
137
143
|
static VALUE debug = Qfalse;
|
144
|
+
static VALUE track_frame_args = Qfalse;
|
138
145
|
|
139
146
|
static VALUE last_context = Qnil;
|
140
147
|
static VALUE last_thread = Qnil;
|
@@ -165,9 +172,11 @@ static unsigned long hook_count = 0;
|
|
165
172
|
static VALUE create_binding(VALUE);
|
166
173
|
static VALUE debug_stop(VALUE);
|
167
174
|
static void save_current_position(debug_context_t *);
|
175
|
+
static VALUE context_copy_args(debug_frame_t *);
|
168
176
|
static VALUE context_copy_locals(debug_frame_t *);
|
169
177
|
static void context_suspend_0(debug_context_t *);
|
170
178
|
static void context_resume_0(debug_context_t *);
|
179
|
+
static void copy_scalar_args(debug_frame_t *);
|
171
180
|
|
172
181
|
typedef struct locked_thread_t {
|
173
182
|
VALUE thread_id;
|
@@ -221,7 +230,8 @@ id2ref_unprotected(VALUE id)
|
|
221
230
|
static VALUE
|
222
231
|
id2ref_error()
|
223
232
|
{
|
224
|
-
|
233
|
+
if(debug == Qtrue)
|
234
|
+
rb_p(ruby_errinfo);
|
225
235
|
return Qnil;
|
226
236
|
}
|
227
237
|
|
@@ -409,6 +419,7 @@ debug_context_mark(void *data)
|
|
409
419
|
if(frame->dead)
|
410
420
|
{
|
411
421
|
rb_gc_mark(frame->info.copy.locals);
|
422
|
+
rb_gc_mark(frame->info.copy.args);
|
412
423
|
}
|
413
424
|
}
|
414
425
|
rb_gc_mark(debug_context->breakpoint);
|
@@ -471,6 +482,7 @@ debug_context_dup(debug_context_t *debug_context)
|
|
471
482
|
new_frame = &(new_debug_context->frames[i]);
|
472
483
|
old_frame = &(debug_context->frames[i]);
|
473
484
|
new_frame->dead = 1;
|
485
|
+
new_frame->info.copy.args = context_copy_args(old_frame);
|
474
486
|
new_frame->info.copy.locals = context_copy_locals(old_frame);
|
475
487
|
}
|
476
488
|
return Data_Wrap_Struct(cContext, debug_context_mark, debug_context_free, new_debug_context);
|
@@ -521,7 +533,7 @@ static VALUE
|
|
521
533
|
call_at_line(VALUE context, debug_context_t *debug_context, VALUE file, VALUE line)
|
522
534
|
{
|
523
535
|
VALUE args;
|
524
|
-
|
536
|
+
|
525
537
|
last_debugged_thnum = debug_context->thnum;
|
526
538
|
save_current_position(debug_context);
|
527
539
|
|
@@ -545,6 +557,7 @@ save_call_frame(rb_event_t event, VALUE self, char *file, int line, ID mid, debu
|
|
545
557
|
debug_context->frames = REALLOC_N(debug_context->frames, debug_frame_t, debug_context->stack_len);
|
546
558
|
}
|
547
559
|
debug_frame = &debug_context->frames[frame_n];
|
560
|
+
debug_frame->argc = ruby_frame->argc;
|
548
561
|
debug_frame->file = file;
|
549
562
|
debug_frame->line = line;
|
550
563
|
debug_frame->binding = binding;
|
@@ -555,8 +568,11 @@ save_call_frame(rb_event_t event, VALUE self, char *file, int line, ID mid, debu
|
|
555
568
|
debug_frame->info.runtime.frame = ruby_frame;
|
556
569
|
debug_frame->info.runtime.scope = ruby_scope;
|
557
570
|
debug_frame->info.runtime.dyna_vars = event == RUBY_EVENT_LINE ? ruby_dyna_vars : NULL;
|
571
|
+
if (RTEST(track_frame_args))
|
572
|
+
copy_scalar_args(debug_frame);
|
558
573
|
}
|
559
574
|
|
575
|
+
|
560
576
|
#if defined DOSISH
|
561
577
|
#define isdirsep(x) ((x) == '/' || (x) == '\\')
|
562
578
|
#else
|
@@ -593,7 +609,9 @@ filename_cmp(VALUE source, char *file)
|
|
593
609
|
inline static int
|
594
610
|
classname_cmp(VALUE name, VALUE klass)
|
595
611
|
{
|
596
|
-
|
612
|
+
VALUE class_name = (Qnil == name) ? rb_str_new2("main") : name;
|
613
|
+
return (klass != Qnil
|
614
|
+
&& rb_str_cmp(class_name, rb_mod_name(klass)) == 0);
|
597
615
|
}
|
598
616
|
|
599
617
|
static int
|
@@ -606,6 +624,7 @@ check_breakpoint_hit_condition(VALUE breakpoint)
|
|
606
624
|
Data_Get_Struct(breakpoint, debug_breakpoint_t, debug_breakpoint);
|
607
625
|
|
608
626
|
debug_breakpoint->hit_count++;
|
627
|
+
if (!Qtrue == debug_breakpoint->enabled) return 0;
|
609
628
|
switch(debug_breakpoint->hit_condition)
|
610
629
|
{
|
611
630
|
case HIT_COND_NONE:
|
@@ -640,6 +659,7 @@ check_breakpoint_by_pos(VALUE breakpoint, char *file, int line)
|
|
640
659
|
if(breakpoint == Qnil)
|
641
660
|
return 0;
|
642
661
|
Data_Get_Struct(breakpoint, debug_breakpoint_t, debug_breakpoint);
|
662
|
+
if (!Qtrue == debug_breakpoint->enabled) return 0;
|
643
663
|
if(debug_breakpoint->type != BP_POS_TYPE)
|
644
664
|
return 0;
|
645
665
|
if(debug_breakpoint->pos.line != line)
|
@@ -657,6 +677,7 @@ check_breakpoint_by_method(VALUE breakpoint, VALUE klass, ID mid)
|
|
657
677
|
if(breakpoint == Qnil)
|
658
678
|
return 0;
|
659
679
|
Data_Get_Struct(breakpoint, debug_breakpoint_t, debug_breakpoint);
|
680
|
+
if (!Qtrue == debug_breakpoint->enabled) return 0;
|
660
681
|
if(debug_breakpoint->type != BP_METHOD_TYPE)
|
661
682
|
return 0;
|
662
683
|
if(debug_breakpoint->pos.mid != mid)
|
@@ -713,8 +734,8 @@ check_breakpoints_by_method(debug_context_t *debug_context, VALUE klass, ID mid)
|
|
713
734
|
}
|
714
735
|
|
715
736
|
/*
|
716
|
-
* This is a NASTY HACK. For some reasons rb_f_binding is
|
717
|
-
* static in eval.c
|
737
|
+
* This is a NASTY HACK. For some reasons rb_f_binding is declared
|
738
|
+
* static in eval.c. So we create a cons up call to binding in C.
|
718
739
|
*/
|
719
740
|
static VALUE
|
720
741
|
create_binding(VALUE self)
|
@@ -1167,11 +1188,12 @@ debug_start(VALUE self)
|
|
1167
1188
|
* call-seq:
|
1168
1189
|
* Debugger.stop -> bool
|
1169
1190
|
*
|
1170
|
-
* This method
|
1191
|
+
* This method disables the debugger. It returns +true+ if the debugger is disabled,
|
1171
1192
|
* otherwise it returns +false+.
|
1172
1193
|
*
|
1173
|
-
* <i>Note that if you want to stop debugger, you must call
|
1174
|
-
* called Debugger.start
|
1194
|
+
* <i>Note that if you want to stop debugger, you must call
|
1195
|
+
* Debugger.stop as many times as you called Debugger.start
|
1196
|
+
* method.</i>
|
1175
1197
|
*/
|
1176
1198
|
static VALUE
|
1177
1199
|
debug_stop(VALUE self)
|
@@ -1224,6 +1246,7 @@ create_breakpoint_from_args(int argc, VALUE *argv, int id)
|
|
1224
1246
|
breakpoint->pos.line = FIX2INT(pos);
|
1225
1247
|
else
|
1226
1248
|
breakpoint->pos.mid = rb_intern(RSTRING(pos)->ptr);
|
1249
|
+
breakpoint->enabled = Qtrue;
|
1227
1250
|
breakpoint->expr = NIL_P(expr) ? expr: StringValue(expr);
|
1228
1251
|
breakpoint->hit_count = 0;
|
1229
1252
|
breakpoint->hit_value = 0;
|
@@ -1568,6 +1591,31 @@ debug_set_post_mortem(VALUE self, VALUE value)
|
|
1568
1591
|
return value;
|
1569
1592
|
}
|
1570
1593
|
|
1594
|
+
/*
|
1595
|
+
* call-seq:
|
1596
|
+
* Debugger.track_fame_args? -> bool
|
1597
|
+
*
|
1598
|
+
* Returns +true+ if the debugger track frame argument values on calls.
|
1599
|
+
*/
|
1600
|
+
static VALUE
|
1601
|
+
debug_track_frame_args(VALUE self)
|
1602
|
+
{
|
1603
|
+
return track_frame_args;
|
1604
|
+
}
|
1605
|
+
|
1606
|
+
/*
|
1607
|
+
* call-seq:
|
1608
|
+
* Debugger.track_frame_args = bool
|
1609
|
+
*
|
1610
|
+
* Setting to +true+ will make the debugger save argument info on calls.
|
1611
|
+
*/
|
1612
|
+
static VALUE
|
1613
|
+
debug_set_track_frame_args(VALUE self, VALUE value)
|
1614
|
+
{
|
1615
|
+
track_frame_args = RTEST(value) ? Qtrue : Qfalse;
|
1616
|
+
return value;
|
1617
|
+
}
|
1618
|
+
|
1571
1619
|
/*
|
1572
1620
|
* call-seq:
|
1573
1621
|
* Debugger.keep_frame_binding? -> bool
|
@@ -1816,36 +1864,73 @@ check_frame_number(debug_context_t *debug_context, VALUE frame)
|
|
1816
1864
|
return frame_n;
|
1817
1865
|
}
|
1818
1866
|
|
1867
|
+
static int
|
1868
|
+
optional_frame_position(int argc, VALUE *argv) {
|
1869
|
+
unsigned int i_scanned;
|
1870
|
+
VALUE level;
|
1871
|
+
|
1872
|
+
if ((argc > 1) || (argc < 0))
|
1873
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc);
|
1874
|
+
i_scanned = rb_scan_args(argc, argv, "01", &level);
|
1875
|
+
if (0 == i_scanned) {
|
1876
|
+
level = INT2FIX(0);
|
1877
|
+
}
|
1878
|
+
return level;
|
1879
|
+
}
|
1880
|
+
|
1819
1881
|
/*
|
1820
1882
|
* call-seq:
|
1821
|
-
* context.
|
1883
|
+
* context.frame_args_info(frame_position=0) -> list
|
1884
|
+
if track_frame_args or nil otherwise
|
1885
|
+
*
|
1886
|
+
* Returns info saved about call arguments (if any saved).
|
1887
|
+
*/
|
1888
|
+
static VALUE
|
1889
|
+
context_frame_args_info(int argc, VALUE *argv, VALUE self)
|
1890
|
+
{
|
1891
|
+
VALUE frame;
|
1892
|
+
debug_context_t *debug_context;
|
1893
|
+
|
1894
|
+
debug_check_started();
|
1895
|
+
frame = optional_frame_position(argc, argv);
|
1896
|
+
Data_Get_Struct(self, debug_context_t, debug_context);
|
1897
|
+
|
1898
|
+
return RTEST(track_frame_args) ? GET_FRAME->arg_ary : Qnil;
|
1899
|
+
}
|
1900
|
+
|
1901
|
+
/*
|
1902
|
+
* call-seq:
|
1903
|
+
* context.frame_binding(frame_position=0) -> binding
|
1822
1904
|
*
|
1823
1905
|
* Returns frame's binding.
|
1824
1906
|
*/
|
1825
1907
|
static VALUE
|
1826
|
-
context_frame_binding(VALUE
|
1908
|
+
context_frame_binding(int argc, VALUE *argv, VALUE self)
|
1827
1909
|
{
|
1910
|
+
VALUE frame;
|
1828
1911
|
debug_context_t *debug_context;
|
1829
1912
|
|
1830
1913
|
debug_check_started();
|
1914
|
+
frame = optional_frame_position(argc, argv);
|
1831
1915
|
Data_Get_Struct(self, debug_context_t, debug_context);
|
1832
1916
|
return GET_FRAME->binding;
|
1833
1917
|
}
|
1834
1918
|
|
1835
1919
|
/*
|
1836
1920
|
* call-seq:
|
1837
|
-
* context.frame_method(
|
1921
|
+
* context.frame_method(frame_position=0) -> sym
|
1838
1922
|
*
|
1839
1923
|
* Returns the sym of the called method.
|
1840
1924
|
*/
|
1841
1925
|
static VALUE
|
1842
|
-
context_frame_id(VALUE
|
1926
|
+
context_frame_id(int argc, VALUE *argv, VALUE self)
|
1843
1927
|
{
|
1844
|
-
|
1928
|
+
VALUE frame;
|
1845
1929
|
debug_context_t *debug_context;
|
1846
1930
|
ID id;
|
1847
1931
|
|
1848
1932
|
debug_check_started();
|
1933
|
+
frame = optional_frame_position(argc, argv);
|
1849
1934
|
Data_Get_Struct(self, debug_context_t, debug_context);
|
1850
1935
|
|
1851
1936
|
id = GET_FRAME->id;
|
@@ -1854,16 +1939,18 @@ context_frame_id(VALUE self, VALUE frame)
|
|
1854
1939
|
|
1855
1940
|
/*
|
1856
1941
|
* call-seq:
|
1857
|
-
* context.frame_line(
|
1942
|
+
* context.frame_line(frame_position) -> int
|
1858
1943
|
*
|
1859
1944
|
* Returns the line number in the file.
|
1860
1945
|
*/
|
1861
1946
|
static VALUE
|
1862
|
-
context_frame_line(VALUE
|
1947
|
+
context_frame_line(int argc, VALUE *argv, VALUE self)
|
1863
1948
|
{
|
1949
|
+
VALUE frame;
|
1864
1950
|
debug_context_t *debug_context;
|
1865
1951
|
|
1866
1952
|
debug_check_started();
|
1953
|
+
frame = optional_frame_position(argc, argv);
|
1867
1954
|
Data_Get_Struct(self, debug_context_t, debug_context);
|
1868
1955
|
|
1869
1956
|
return INT2FIX(GET_FRAME->line);
|
@@ -1871,21 +1958,100 @@ context_frame_line(VALUE self, VALUE frame)
|
|
1871
1958
|
|
1872
1959
|
/*
|
1873
1960
|
* call-seq:
|
1874
|
-
* context.frame_file(
|
1961
|
+
* context.frame_file(frame_position) -> string
|
1875
1962
|
*
|
1876
1963
|
* Returns the name of the file.
|
1877
1964
|
*/
|
1878
1965
|
static VALUE
|
1879
|
-
context_frame_file(VALUE
|
1966
|
+
context_frame_file(int argc, VALUE *argv, VALUE self)
|
1880
1967
|
{
|
1968
|
+
VALUE frame;
|
1881
1969
|
debug_context_t *debug_context;
|
1882
1970
|
|
1883
1971
|
debug_check_started();
|
1972
|
+
frame = optional_frame_position(argc, argv);
|
1884
1973
|
Data_Get_Struct(self, debug_context_t, debug_context);
|
1885
1974
|
|
1886
1975
|
return rb_str_new2(GET_FRAME->file);
|
1887
1976
|
}
|
1888
1977
|
|
1978
|
+
static int
|
1979
|
+
arg_value_is_small(VALUE val)
|
1980
|
+
{
|
1981
|
+
switch (TYPE(val)) {
|
1982
|
+
case T_FIXNUM: case T_FLOAT: case T_CLASS:
|
1983
|
+
case T_NIL: case T_MODULE: case T_FILE:
|
1984
|
+
case T_TRUE: case T_FALSE: case T_UNDEF:
|
1985
|
+
return 1;
|
1986
|
+
default:
|
1987
|
+
return SYMBOL_P(val);
|
1988
|
+
}
|
1989
|
+
}
|
1990
|
+
|
1991
|
+
/*
|
1992
|
+
* Save scalar arguments or a class name.
|
1993
|
+
*/
|
1994
|
+
static void
|
1995
|
+
copy_scalar_args(debug_frame_t *debug_frame)
|
1996
|
+
{
|
1997
|
+
unsigned int i;
|
1998
|
+
ID *tbl = ruby_scope->local_tbl;;
|
1999
|
+
if (tbl && ruby_scope->local_vars)
|
2000
|
+
{
|
2001
|
+
int n = *tbl++;
|
2002
|
+
if (debug_frame->argc+2 < n) n = debug_frame->argc+2;
|
2003
|
+
debug_frame->arg_ary = rb_ary_new2(n);
|
2004
|
+
for (i=2; i<n; i++)
|
2005
|
+
{
|
2006
|
+
/* skip flip states */
|
2007
|
+
if (rb_is_local_id(tbl[i]))
|
2008
|
+
{
|
2009
|
+
const char *name = rb_id2name(tbl[i]);
|
2010
|
+
VALUE val = rb_eval_string (name);
|
2011
|
+
if (arg_value_is_small(val))
|
2012
|
+
rb_ary_push(debug_frame->arg_ary, val);
|
2013
|
+
else
|
2014
|
+
rb_ary_push(debug_frame->arg_ary,
|
2015
|
+
rb_str_new2(rb_obj_classname(val)));
|
2016
|
+
}
|
2017
|
+
}
|
2018
|
+
}
|
2019
|
+
}
|
2020
|
+
|
2021
|
+
|
2022
|
+
/*
|
2023
|
+
* call-seq:
|
2024
|
+
* context.copy_args(frame) -> list of args
|
2025
|
+
*
|
2026
|
+
* Returns a array of argument names.
|
2027
|
+
*/
|
2028
|
+
static VALUE
|
2029
|
+
context_copy_args(debug_frame_t *debug_frame)
|
2030
|
+
{
|
2031
|
+
ID *tbl;
|
2032
|
+
int n, i;
|
2033
|
+
struct SCOPE *scope;
|
2034
|
+
VALUE list = rb_ary_new2(0); /* [] */
|
2035
|
+
|
2036
|
+
scope = debug_frame->info.runtime.scope;
|
2037
|
+
tbl = scope->local_tbl;
|
2038
|
+
|
2039
|
+
if (tbl && scope->local_vars)
|
2040
|
+
{
|
2041
|
+
n = *tbl++;
|
2042
|
+
if (debug_frame->argc+2 < n) n = debug_frame->argc+2;
|
2043
|
+
list = rb_ary_new2(n);
|
2044
|
+
/* skip first 2 ($_ and $~) */
|
2045
|
+
for (i=2; i<n; i++)
|
2046
|
+
{
|
2047
|
+
/* skip first 2 ($_ and $~) */
|
2048
|
+
if (!rb_is_local_id(tbl[i])) continue; /* skip flip states */
|
2049
|
+
rb_ary_push(list, rb_str_new2(rb_id2name(tbl[i])));
|
2050
|
+
}
|
2051
|
+
}
|
2052
|
+
|
2053
|
+
return list;
|
2054
|
+
}
|
1889
2055
|
static VALUE
|
1890
2056
|
context_copy_locals(debug_frame_t *debug_frame)
|
1891
2057
|
{
|
@@ -1927,12 +2093,14 @@ context_copy_locals(debug_frame_t *debug_frame)
|
|
1927
2093
|
* Returns frame's local variables.
|
1928
2094
|
*/
|
1929
2095
|
static VALUE
|
1930
|
-
context_frame_locals(VALUE
|
2096
|
+
context_frame_locals(int argc, VALUE *argv, VALUE self)
|
1931
2097
|
{
|
2098
|
+
VALUE frame;
|
1932
2099
|
debug_context_t *debug_context;
|
1933
2100
|
debug_frame_t *debug_frame;
|
1934
2101
|
|
1935
2102
|
debug_check_started();
|
2103
|
+
frame = optional_frame_position(argc, argv);
|
1936
2104
|
Data_Get_Struct(self, debug_context_t, debug_context);
|
1937
2105
|
|
1938
2106
|
debug_frame = GET_FRAME;
|
@@ -1944,17 +2112,43 @@ context_frame_locals(VALUE self, VALUE frame)
|
|
1944
2112
|
|
1945
2113
|
/*
|
1946
2114
|
* call-seq:
|
1947
|
-
* context.
|
2115
|
+
* context.frame_args(frame_position=0) -> list
|
2116
|
+
*
|
2117
|
+
* Returns frame's argument parameters
|
2118
|
+
*/
|
2119
|
+
static VALUE
|
2120
|
+
context_frame_args(int argc, VALUE *argv, VALUE self)
|
2121
|
+
{
|
2122
|
+
VALUE frame;
|
2123
|
+
debug_context_t *debug_context;
|
2124
|
+
debug_frame_t *debug_frame;
|
2125
|
+
|
2126
|
+
debug_check_started();
|
2127
|
+
frame = optional_frame_position(argc, argv);
|
2128
|
+
Data_Get_Struct(self, debug_context_t, debug_context);
|
2129
|
+
|
2130
|
+
debug_frame = GET_FRAME;
|
2131
|
+
if(debug_frame->dead)
|
2132
|
+
return debug_frame->info.copy.args;
|
2133
|
+
else
|
2134
|
+
return context_copy_args(debug_frame);
|
2135
|
+
}
|
2136
|
+
|
2137
|
+
/*
|
2138
|
+
* call-seq:
|
2139
|
+
* context.frame_self(frame_postion=0) -> obj
|
1948
2140
|
*
|
1949
2141
|
* Returns self object of the frame.
|
1950
2142
|
*/
|
1951
2143
|
static VALUE
|
1952
|
-
context_frame_self(VALUE
|
2144
|
+
context_frame_self(int argc, VALUE *argv, VALUE self)
|
1953
2145
|
{
|
2146
|
+
VALUE frame;
|
1954
2147
|
debug_context_t *debug_context;
|
1955
2148
|
debug_frame_t *debug_frame;
|
1956
2149
|
|
1957
2150
|
debug_check_started();
|
2151
|
+
frame = optional_frame_position(argc, argv);
|
1958
2152
|
Data_Get_Struct(self, debug_context_t, debug_context);
|
1959
2153
|
|
1960
2154
|
debug_frame = GET_FRAME;
|
@@ -1963,27 +2157,34 @@ context_frame_self(VALUE self, VALUE frame)
|
|
1963
2157
|
|
1964
2158
|
/*
|
1965
2159
|
* call-seq:
|
1966
|
-
* context.frame_class(
|
2160
|
+
* context.frame_class(frame_position) -> obj
|
1967
2161
|
*
|
1968
2162
|
* Returns the real class of the frame.
|
1969
2163
|
* It could be different than context.frame_self(frame).class
|
1970
2164
|
*/
|
1971
2165
|
static VALUE
|
1972
|
-
context_frame_class(VALUE
|
2166
|
+
context_frame_class(int argc, VALUE *argv, VALUE self)
|
1973
2167
|
{
|
2168
|
+
VALUE frame;
|
1974
2169
|
debug_context_t *debug_context;
|
1975
2170
|
debug_frame_t *debug_frame;
|
1976
2171
|
VALUE klass;
|
1977
2172
|
|
1978
2173
|
debug_check_started();
|
2174
|
+
frame = optional_frame_position(argc, argv);
|
1979
2175
|
Data_Get_Struct(self, debug_context_t, debug_context);
|
1980
2176
|
|
1981
2177
|
debug_frame = GET_FRAME;
|
1982
2178
|
|
1983
2179
|
if(CTX_FL_TEST(debug_context, CTX_FL_DEAD))
|
1984
2180
|
return Qnil;
|
1985
|
-
|
2181
|
+
|
2182
|
+
#if RUBY_VERSION_CODE >= 190
|
2183
|
+
klass = debug_frame->info.runtime.frame->this_class;
|
2184
|
+
#else
|
1986
2185
|
klass = debug_frame->info.runtime.frame->last_class;
|
2186
|
+
#endif
|
2187
|
+
|
1987
2188
|
klass = real_class(klass);
|
1988
2189
|
if(TYPE(klass) == T_CLASS || TYPE(klass) == T_MODULE)
|
1989
2190
|
return klass;
|
@@ -2010,7 +2211,7 @@ context_stack_size(VALUE self)
|
|
2010
2211
|
|
2011
2212
|
/*
|
2012
2213
|
* call-seq:
|
2013
|
-
* context.thread ->
|
2214
|
+
* context.thread -> thread
|
2014
2215
|
*
|
2015
2216
|
* Returns a thread this context is associated with.
|
2016
2217
|
*/
|
@@ -2277,6 +2478,36 @@ context_stop_reason(VALUE self)
|
|
2277
2478
|
}
|
2278
2479
|
|
2279
2480
|
|
2481
|
+
/*
|
2482
|
+
* call-seq:
|
2483
|
+
* breakpoint.enabled?
|
2484
|
+
*
|
2485
|
+
* Returns whether breakpoint is enabled or not.
|
2486
|
+
*/
|
2487
|
+
static VALUE
|
2488
|
+
breakpoint_enabled(VALUE self)
|
2489
|
+
{
|
2490
|
+
debug_breakpoint_t *breakpoint;
|
2491
|
+
|
2492
|
+
Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
|
2493
|
+
return breakpoint->enabled;
|
2494
|
+
}
|
2495
|
+
|
2496
|
+
/*
|
2497
|
+
* call-seq:
|
2498
|
+
* breakpoint.enabled = bool
|
2499
|
+
*
|
2500
|
+
* Enables or disables breakpoint.
|
2501
|
+
*/
|
2502
|
+
static VALUE
|
2503
|
+
breakpoint_set_enabled(VALUE self, VALUE bool)
|
2504
|
+
{
|
2505
|
+
debug_breakpoint_t *breakpoint;
|
2506
|
+
|
2507
|
+
Data_Get_Struct(self, debug_breakpoint_t, breakpoint);
|
2508
|
+
return breakpoint->enabled = bool;
|
2509
|
+
}
|
2510
|
+
|
2280
2511
|
/*
|
2281
2512
|
* call-seq:
|
2282
2513
|
* breakpoint.source -> string
|
@@ -2521,14 +2752,16 @@ Init_context()
|
|
2521
2752
|
rb_define_method(cContext, "tracing", context_tracing, 0);
|
2522
2753
|
rb_define_method(cContext, "tracing=", context_set_tracing, 1);
|
2523
2754
|
rb_define_method(cContext, "ignored?", context_ignored, 0);
|
2524
|
-
rb_define_method(cContext, "
|
2525
|
-
rb_define_method(cContext, "
|
2526
|
-
rb_define_method(cContext, "
|
2527
|
-
rb_define_method(cContext, "
|
2528
|
-
rb_define_method(cContext, "frame_file", context_frame_file, 1);
|
2529
|
-
rb_define_method(cContext, "
|
2530
|
-
rb_define_method(cContext, "
|
2531
|
-
rb_define_method(cContext, "
|
2755
|
+
rb_define_method(cContext, "frame_args", context_frame_args, -1);
|
2756
|
+
rb_define_method(cContext, "frame_args_info", context_frame_args_info, -1);
|
2757
|
+
rb_define_method(cContext, "frame_binding", context_frame_binding, -1);
|
2758
|
+
rb_define_method(cContext, "frame_class", context_frame_class, -1);
|
2759
|
+
rb_define_method(cContext, "frame_file", context_frame_file, -1);
|
2760
|
+
rb_define_method(cContext, "frame_id", context_frame_id, -1);
|
2761
|
+
rb_define_method(cContext, "frame_line", context_frame_line, -1);
|
2762
|
+
rb_define_method(cContext, "frame_locals", context_frame_locals, -1);
|
2763
|
+
rb_define_method(cContext, "frame_method", context_frame_id, -1);
|
2764
|
+
rb_define_method(cContext, "frame_self", context_frame_self, -1);
|
2532
2765
|
rb_define_method(cContext, "stack_size", context_stack_size, 0);
|
2533
2766
|
rb_define_method(cContext, "dead?", context_dead, 0);
|
2534
2767
|
rb_define_method(cContext, "breakpoint", context_breakpoint, 0);
|
@@ -2550,6 +2783,8 @@ Init_breakpoint()
|
|
2550
2783
|
rb_define_method(cBreakpoint, "id", breakpoint_id, 0);
|
2551
2784
|
rb_define_method(cBreakpoint, "source", breakpoint_source, 0);
|
2552
2785
|
rb_define_method(cBreakpoint, "source=", breakpoint_set_source, 1);
|
2786
|
+
rb_define_method(cBreakpoint, "enabled?", breakpoint_enabled, 0);
|
2787
|
+
rb_define_method(cBreakpoint, "enabled=", breakpoint_set_enabled, 1);
|
2553
2788
|
rb_define_method(cBreakpoint, "pos", breakpoint_pos, 0);
|
2554
2789
|
rb_define_method(cBreakpoint, "pos=", breakpoint_set_pos, 1);
|
2555
2790
|
rb_define_method(cBreakpoint, "expr", breakpoint_expr, 0);
|
@@ -2583,7 +2818,8 @@ Init_ruby_debug()
|
|
2583
2818
|
rb_define_module_function(mDebugger, "started?", debug_is_started, 0);
|
2584
2819
|
rb_define_module_function(mDebugger, "breakpoints", debug_breakpoints, 0);
|
2585
2820
|
rb_define_module_function(mDebugger, "add_breakpoint", debug_add_breakpoint, -1);
|
2586
|
-
rb_define_module_function(mDebugger, "remove_breakpoint",
|
2821
|
+
rb_define_module_function(mDebugger, "remove_breakpoint",
|
2822
|
+
debug_remove_breakpoint, 1);
|
2587
2823
|
rb_define_module_function(mDebugger, "catchpoint", debug_catchpoint, 0);
|
2588
2824
|
rb_define_module_function(mDebugger, "catchpoint=", debug_set_catchpoint, 1);
|
2589
2825
|
rb_define_module_function(mDebugger, "last_context", debug_last_interrupted, 0);
|
@@ -2601,6 +2837,10 @@ Init_ruby_debug()
|
|
2601
2837
|
rb_define_module_function(mDebugger, "post_mortem=", debug_set_post_mortem, 1);
|
2602
2838
|
rb_define_module_function(mDebugger, "keep_frame_binding?", debug_keep_frame_binding, 0);
|
2603
2839
|
rb_define_module_function(mDebugger, "keep_frame_binding=", debug_set_keep_frame_binding, 1);
|
2840
|
+
rb_define_module_function(mDebugger, "track_frame_args?",
|
2841
|
+
debug_track_frame_args, 0);
|
2842
|
+
rb_define_module_function(mDebugger, "track_frame_args=",
|
2843
|
+
debug_set_track_frame_args, 1);
|
2604
2844
|
rb_define_module_function(mDebugger, "debug", debug_debug, 0);
|
2605
2845
|
rb_define_module_function(mDebugger, "debug=", debug_set_debug, 1);
|
2606
2846
|
|