Class: RuntimeInspection::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/rti/tracer.rb

Overview

This will help track the tracing of a particular StopPoint in a given thread. Having a tracer assigned to a thread (via the :rti_tracer element stored in the thread from Thread#handle_tracing) ensures that a RTIManager#bp_finish, RTIManager#bp_next, or RTIManager#bp_step will always occur within in the same thread. Note that it is still possible for another breakpoint to “interrupt” this tracer and stop processing somewhere else.

Instance Method Summary collapse

Constructor Details

#initialize(portal, cmd) ⇒ Tracer

Returns a new instance of Tracer.



22
23
24
25
# File 'lib/rti/tracer.rb', line 22

def initialize( portal, cmd )
    @portal = portal
    @cmd = cmd
end

Instance Method Details

#stoppoint(sp) ⇒ Object

Given a generic StopPoint, adjust it where necessary if we are at the next real StopPoint that should be passed off to the client.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rti/tracer.rb', line 31

def stoppoint( sp )
    case @cmd
    when :step
        sp.state = @portal.stoppoint.state
        return sp
    when :next
        case sp.event
        when 'line'
            if( @portal.stoppoint.classname == sp.classname and
                @portal.stoppoint.methodname == sp.methodname )
                sp.state = @portal.stoppoint.state
                return sp
            end
        when 'return'
            if( @portal.stoppoint.classname == sp.classname and
                @portal.stoppoint.methodname == sp.methodname )
                @cmd = :any_line
            end
        end
        return :continue
    when :fin
        if( sp.event == 'return' and
            @portal.stoppoint.classname == sp.classname and
            @portal.stoppoint.methodname == sp.methodname )
            sp.state = @portal.stoppoint.state
            return sp
        end
    when :any_line
        if sp.event == 'line'
            sp.state = @portal.stoppoint.state
            return sp
        else
            return :continue
        end
    else
        raise "Unknown tracer command: #{@cmd}"
    end
end