Sha256: d238ba2a24f062187071459b20e4f3ef74365a1ffbc4a037b21b0d9bab5f5064

Contents?: true

Size: 840 Bytes

Versions: 1

Compression:

Stored size: 840 Bytes

Contents

= TracePoint 

To demonstrate TracePoint, we will simply have it feed all
even parameters into the log for a simple arethmetic call.

First we need to load the tracepoint.rb library.

  require 'tracepoint'

Now we can setup the trace procedure.

  trace_log = []

  TracePoint.trace do |tp|
    trace_log << [tp.self.class, tp.callee, tp.event, tp.return?, tp.back == tp.bind]
  end

And then we can activate the trace, call out arethmetic function,
and deactivate the trace.

  TracePoint.activate
  1 + 1
  TracePoint.deactivate

We should now see in the log the set of events required to
perform the addition operation.

  trace_log[1].assert == [Fixnum, :'+', 'c-call',   false, false]
  trace_log[2].assert == [Fixnum, :'+', 'c-return', false, false]

For reference, trace_log[0] and trace_log[3] simply refer to the
QED run context.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracepoint-1.1 test/demo/trace.qed