Class: Debugger::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-debug.rb,
ext/ruby_debug.c

Defined Under Namespace

Classes: Frame

Instance Method Summary collapse

Instance Method Details

#clear_suspendnil

Clears a suspend flag.

Returns:

  • (nil)


1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
# File 'ext/ruby_debug.c', line 1176

static VALUE
context_clear_suspend(VALUE self)
{
    debug_context_t *debug_context;

    debug_check_started();

    Data_Get_Struct(self, debug_context_t, debug_context);
    debug_context->suspend = 0;
    return Qnil;
}

#framesArray

Returns an array of frames.

Returns:

  • (Array)


1113
1114
1115
1116
1117
1118
1119
1120
# File 'ext/ruby_debug.c', line 1113

static VALUE
context_frames(VALUE self)
{
    debug_context_t *debug_context;

    Data_Get_Struct(self, debug_context_t, debug_context);
    return debug_context->frames;
}

#interruptObject



17
18
19
# File 'lib/ruby-debug.rb', line 17

def interrupt
  self.stop_next = 1
end

#set_suspendnil

Suspends the thread when it is running.

Returns:

  • (nil)


1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
# File 'ext/ruby_debug.c', line 1158

static VALUE
context_set_suspend(VALUE self)
{
    debug_context_t *debug_context;

    debug_check_started();

    Data_Get_Struct(self, debug_context_t, debug_context);
    debug_context->suspend = 1;
    return Qnil;
}

#step_over(steps) ⇒ Object

Steps over a steps number of times.



1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
# File 'ext/ruby_debug.c', line 1058

static VALUE
context_step_over(int argc, VALUE *argv, VALUE self)
{
    VALUE lines, frame;
    debug_context_t *debug_context;

    debug_check_started();

    Data_Get_Struct(self, debug_context_t, debug_context);
    if(RARRAY(debug_context->frames)->len == 0)
        rb_raise(rb_eRuntimeError, "No frames collected.");

    rb_scan_args(argc, argv, "11", &lines, &frame);
    debug_context->stop_line = FIX2INT(lines);
    if(argc == 1)
    {
        debug_context->dest_frame = RARRAY(debug_context->frames)->len;
    }
    else
    {
        if(FIX2INT(frame) < 0 && FIX2INT(frame) >= RARRAY(debug_context->frames)->len)
            rb_raise(rb_eRuntimeError, "Destination frame is out of range.");
        debug_context->dest_frame = FIX2INT(frame);
    }

    return Qnil;
}

#stop_frame(frame) ⇒ Object

Stops when a frame with number frame is activated. Implements up and down commands.



1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
# File 'ext/ruby_debug.c', line 1092

static VALUE
context_stop_frame(VALUE self, VALUE frame)
{
    debug_context_t *debug_context;

    debug_check_started();

    Data_Get_Struct(self, debug_context_t, debug_context);
    if(FIX2INT(frame) < 0 && FIX2INT(frame) >= RARRAY(debug_context->frames)->len)
        rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
    debug_context->stop_frame = FIX2INT(frame);

    return frame;
}

#stop_next=(steps) ⇒ Object

Stops the current context after a number steps are made.



1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
# File 'ext/ruby_debug.c', line 1037

static VALUE
context_stop_next(VALUE self, VALUE steps)
{
    debug_context_t *debug_context;

    debug_check_started();
    
    Data_Get_Struct(self, debug_context_t, debug_context);
    if(FIX2INT(steps) < 0)
    rb_raise(rb_eRuntimeError, "Steps argument can't be negative.");
    debug_context->stop_next = FIX2INT(steps);
    
    return steps;
}

#thnumInteger

Returns the context’s number.

Returns:

  • (Integer)


1143
1144
1145
1146
1147
1148
1149
1150
# File 'ext/ruby_debug.c', line 1143

static VALUE
context_thnum(VALUE self)
{
    debug_context_t *debug_context;

    Data_Get_Struct(self, debug_context_t, debug_context);
    return INT2FIX(debug_context->thnum);
}

#threadObject

Returns a thread this context is associated with.



1128
1129
1130
1131
1132
1133
1134
1135
# File 'ext/ruby_debug.c', line 1128

static VALUE
context_thread(VALUE self)
{
    debug_context_t *debug_context;

    Data_Get_Struct(self, debug_context_t, debug_context);
    return debug_context->thread;
}

#tracingBoolean

Returns the tracing flag for the current context.

Returns:

  • (Boolean)


1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
# File 'ext/ruby_debug.c', line 1194

static VALUE
context_tracing(VALUE self)
{
    debug_context_t *debug_context;

    debug_check_started();

    Data_Get_Struct(self, debug_context_t, debug_context);
    return debug_context->tracing ? Qtrue : Qfalse;
}

#tracking=(bool) ⇒ Object

Controls the tracing for this context.



1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
# File 'ext/ruby_debug.c', line 1211

static VALUE
context_set_tracing(VALUE self, VALUE value)
{
    debug_context_t *debug_context;

    debug_check_started();

    Data_Get_Struct(self, debug_context_t, debug_context);
    debug_context->tracing = RTEST(value) ? 1 : 0;
    return value;
}