Sha256: ff2cfe7fed793392708d46fa134f983c7472c3b22e9ff8afa1c7ed9afcf78a2a

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

= TracePoint 

To demonstrate TracePoint, we will simply have it feed all
event 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 our 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.2.0 test/demos/trace.qed