Class Trace
Declare a new class "Trace" into Lua global table
This class is a helper-class to manage low-level probes and tracing in a
user friendlier way.
The fundamental friendliness is based of the concept of
selections (see method sel below).
See also:
Tables
| trace.mt | Meta-table
Complements base-class. |
Methods
| trace:version () | version |
| trace:p_stat ([filename][, funcname][, kind]) | p_stat
Return a pretty formatted sting of status for a selection of probes, that in interactive mode prints to console by Lua. |
| trace:stat ([filename][, funcname][, kind]) | stat
Return a table of status for a selection of probes. |
| trace:set ([s=self], ctrl[, cntr[, ts=0]]) | set
Set ctrl bit-mask for a selection of probe(s) and optionally it's/their counter and time-stamp values. |
| trace:dprobe (dep[, own=self]) | dprobe
Set up a low level probe-dependency using high-level code references When the owner-probe is passed, a difference in both number of passed and time is calculated. |
Tables
Methods
- trace:version ()
-
version Returns (1) version string
Returns:
- String utrace version
- String Cref base-class version
Usage:
Trace:version() -- utrace <0.3.4-8269c16>
- trace:p_stat ([filename][, funcname][, kind])
-
p_stat
Return a pretty formatted sting of status for a selection of probes, that in interactive mode prints to console by Lua. This is handy for determining if one or several probes are live or not. I.e. it's "passed-counters" and "latest time-stamps" are changing.
Print is a columns of: ID ,kind ,filename ,func-name ,line [,d-time ,d-counts ,linked-probe-ID]
Note that the last three columns are conditional and depends of if probe is diff-event linked to another or not (see
utrace-probe.dprobe)Arguments are the same as
sel(follow "See also") OR one Trace instance with a selection.Parameters:
- filename String -OR- Trace instance (optional)
- funcname String (optional)
- kind String (optional)
Returns:
- Integer Number of probes fitting selection
- String Pretty-formatted string
See also:
- trace:stat ([filename][, funcname][, kind])
-
stat
Return a table of status for a selection of probes. Identical to p_stat except that nothing is printed and the return is a table. Note that the table is not live, i.e. Function needs to be re-iterated for current values.
Parameters:
- filename String -OR- Trace instance (optional)
- funcname String (optional)
- kind String (optional)
Returns:
-
Table
of statuses
See also:
Usage:
a = Trace('test_main.c','thread_A',nil,1) b = Trace('test_main.c','thread_A',nil,2) Trace:set(a + b, 1) -- 2 Trace:dprobe(b, a) -- Establish relation t = Trace:stat(a + b) -- Table with probes and stats print("Time between probes: " .. t[2][5]/1E6 .. " (mS)") -- Time between probes: 5.05918 (mS)
- trace:set ([s=self], ctrl[, cntr[, ts=0]])
-
set
Set ctrl bit-mask for a selection of probe(s) and optionally it's/their counter and time-stamp values.
First argument can be either a table of size and selection as returned by
selor just the selection as size is implicit in the selection's base-type/class (table)It can also be omitted, in which case the selection in
selfis assumed and the rest of the arguments starts at second argument.Central operation about method is operating on groups of probes, i.e. selections. An instance of Trace can have a selection (from
CTORor appended), therefore it can operate onselfParameters:
- s Table Trace instance or Trace-selection table (default self)
- ctrl Integer Control (bit-mask). Required
- cntr Integer Counter. (optional)
- ts Integer Time-stamp. (default 0)
Returns:
- Integer Number of probes fitting selection
- String Pretty-formatted string
See also:
Usage:
-- Class static tps = Trace('test_main.c','thread_A') Trace:set(tps, 1) Trace:p_stat(tps)
-- Object instances tps = Trace('test_main.c','thread_A') tps:set(1) tps:p_stat() tps:set(1, 0) -- Continue counting, reset counters but not timestamps tps:p_stat()
- trace:dprobe (dep[, own=self])
-
dprobe
Set up a low level probe-dependency using high-level code references
When the owner-probe is passed, a difference in both number of passed and time is calculated. I.e. the second probe (the owner) also drives the event to perform the diff-operation.
Function one or two Trace instance arguments,
dep(dependent) andown(owner). If one argument (dependent), the other (owner) is impliedself. Both instances is a symbolic selection containing exactly one probe each.Parameters:
Returns:
-
Boolean
success
Usage:
-- Using static class a = Trace('test_main.c','thread_A',nil,1) b = Trace('test_main.c','thread_A',nil,2) Trace:set(a + b, 1) -- Enable both Trace:dprobe(a, b) -- Establish relation Trace:p_stat(a + b) -- Print current status of both -- 2 -- 1 94660412502144 T 1 68615 3021884646707045 -- 2 94660412502208 T 1 68615 3021884651775924 5068879 0 94660412502144
-- Equivalent with instances a = Trace('test_main.c','thread_A',nil,1) b = Trace('test_main.c','thread_A',nil,2) (a + b):set(1) -- Enable both a:dprobe(b) -- Establish relation (a + b):p_stat() -- Print current status of both -- 2 -- 1 94660412502144 T 1 68615 3021884646707045 -- 2 94660412502208 T 1 68615 3021884651775924 5068879 0 94660412502144