FloatTracker.Event
— TypeEvent
Struct representing some exceptional floating point event.
category
options:
:nan
:inf
evt_type
options:
:injected
:gen
:prop
:kill
FloatTracker.FtConfig
— TypeFloatTracker config struct
Logger Config
Injector Config
Session Config
FloatTracker.FunctionRef
— TypeStruct to describe a function location; used by the Injector
The avoid
field defaults to false
—setting this to true
will make it so that if that function will not be considered a candidate for injection.
FloatTracker.InjectorConfig
— TypeStruct describing parameters for injecting NaNs
Fields
active::Boolean
inject only if truen_inject::Int
maximum number of NaNs to inject; gets decremented every time a NaN gets injectedodds::Int
inject a NaN with 1:odds probability—higher value → rarer to injectfunctions::Array{FunctionRef}
if given, only inject NaNs when within these functions; default is to not discriminate on functionslibraries::Array{String}
if given, only inject NaNs when within this library.NOTE: Libraries MUST NOT have a
.jl
suffix—we strip out that suffix when looking for the name of a library by default, so don't include it here otherwise it will never match.record::String
if given, record injection invents in a way that can be replayed later with thereplay
argument.replay::String
if given, ignore all previous directives and use this file for injection replay.
functions
and libraries
work together as a union: i.e. the set of possible NaN injection points is a union of the places matched by functions
and libraries
.
FloatTracker.LoggerConfig
— TypeStruct containing all configuration for the logger.
Fields
filename::String
Basename of the file to write logs to.Constructors automatically prefix the timestamp to the beginning of this basename so the logs are grouped together chronologically.
buffersize::Int
Number of logs to buffer in memory before writing to file.Defaults to 1000. Decrease if you are crashing without getting the logs that you need.
printToStdOut::Bool
Whether or not to write logs to STDOUT; defaults tofalse
.allErrors::Bool
Record all errors in the*_error_log.txt
file.cstg::Bool
Write logs in CSTG format.cstgLineNum::Bool
Include the line number in CSTG output.cstgArgs::Bool
Include arguments to functions in CSTG output.maxLogs::Union{Int,Unbounded}
Maximum number of events to log; defaults toUnbounded
.maxFrames::Union{Int,Unbounded}
Maximum number of stack frames to print in logging; defaults toUnbounded
.exclusions::Array{Symbol}
Events to not log; defaults to[:prop]
.
FloatTracker.ReplayPoint
— TypeReplayPoint(counter, check, module_list)
Represents a point where a NaN
was injected during program execution.
FloatTracker.config_injector
— Methodconfig_injector(log::InjectorConfig)
config_injector(; args...)
Set the injector for the global FloatTracker configuration instance.
Takes either a InjectorConfig
struct, or the same keyword arguments as the InjectorConfig
constructor.
Passing a partial list of keyword arguments has the same behavior as it does with config_logger
.
FloatTracker.config_logger
— Methodconfig_logger(log::LoggerConfig)
config_logger(; args...)
Set the logger for the global FloatTracker configuration instance.
Takes either a LoggerConfig
struct, or the same keyword arguments as the LoggerConfig
constructor.
In the case where only a few arguments are specified, it will override only those fields, i.e. the entire LoggerConfig won't be replaced. This is useful, for example, if you need to adjust a field in the middle of a test.
FloatTracker.config_session
— Methodconfig_session(log::SessionConfig)
config_session(; args...)
Set the session for the global FloatTracker configuration instance.
Takes either a SessionConfig
struct, or the same keyword arguments as the SessionConfig
constructor.
Passing a partial list of keyword arguments has the same behavior as it does with config_logger
.
FloatTracker.disable_nan_injection
— Methoddisable_nan_injection()
Turn off NaN injection.
If you want to re-enable NaN injection after calling disable_nan_injection
, consider using the one-argument form of enable_nan_injection(n_inject::Int)
.
FloatTracker.enable_nan_injection
— Methodenable_nan_injection(n_inject::Int)
Turn on NaN injection and injection n_inject
NaNs. Does not modify odds, function and library lists, or recording/replay state.
enable_nan_injection(; odds::Int = 10, n_inject::Int = 1, functions::Array{FunctionRef} = [], libraries::Array{String} = [])
Turn on NaN injection. Optionally configure the odds for injection, as well as the number of NaNs to inject, and the functions/libraries in which to inject NaNs. Overrides unspecified arguments to their defaults.
FloatTracker.event
— Functionevent(op, args, result, is_injected = false)
Constructs one or more Event
structs based off of the operation.
Uses the argument values and the return result to determine what kind of an event we're looking at here. Types:
:injected
–- injections:gen
–- generating operations:prop
–- NaN propagation:kill
–- killing operations
Returns one or more events in a list
FloatTracker.exclude_stacktrace
— Functionexclude_stacktrace(exclusions = [:prop])
Globally set the types of stack traces to not collect.
See documentation for the event()
function for details on the types of events that can be put into this list.
Convenience function; You can also set the stack trace exclusions with a keyword argument to config_logger
.
FloatTracker.frame_library
— Methodframe_library(frame::StackTraces.StackFrame)::Symbol
Return the name of the library that the current stack frame references.
Returns nothing
if unable to find library.
FloatTracker.ft_init
— Methodft_init()
Initialize the global FloatTracker configuration. (Automatically called when using function by __init__
)
We need to make this a function, otherwise it can cache the value of the timestamp used for writing unique log files.
FloatTracker.injectable_region
— Methodinjectable_region(i::InjectorConfig, frames::StackTrace)::Bool
Returns whether or not the current point in the code (indicated by the StackTrace) is a valid point to inject a NaN.
FloatTracker.record_injection
— Functionrecord_injection(recording_file::String="ft_recording")
Turn on recording.
FloatTracker.replay_injection
— Methodreplay_injection(replay_file::String)
Sets the injector to read from a replay file.
Note that this overwrites all previous configuration to the injector file, as once you are replaying an injection recording, all other configuration ceases to matter.
FloatTracker.should_inject
— Methodshould_inject(i::InjectorConfig)
Return whether or not we should inject a NaN
.
Decision process:
Checks whether or not the given injector is active.
Checks that there are some NaNs remaining to inject.
Rolls an
InjectorConfig.odds
-sided die; if 1, proceed, otherwise, don't do anything.Checks that we're inside the scope of a function in
InjectorConfig.functions
OR that we're in a library that we're interested in. If yes, inject.Defaults to not injecting.