Class Debug
- Object
-
- Debug
-
public final class Debug extends Object
Debug class used with the logger to create standardized output. It can be setup to track combinations of classes, program points, and variables. The most common class to track is an invariant, but any class can be used.This allows detailed information about a particular class/ppt/variable combination to be printed without getting lost in a mass of other information (which is a particular problem in Daikon due to the volume of data considered).
Note that each of the three items (class, ppt, variable) must match in order for printing to occur.
-
-
Field Summary
Fields Modifier and Type Field Description @Nullable Class<?>
cache_class
cached class: class to use by default when calling variants of log() with few arguments.boolean
cache_match
True if the cached values should be printed --- that is, they match what is currently being debugged.@Nullable Ppt
cache_ppt
Cached ppt: ppt to use by default when calling variants of log() with few arguments.VarInfo @Nullable []
cache_vis
Cached variables: variables to use by default when calling variants of log() with few arguments.static Logger
debugTrack
Debug Logger.static String[]
debugTrackClass
List of classes for logging.static String[]
debugTrackPpt
List of Ppts for logging.static String[][]
debugTrackVars
List of variable names for logging.static boolean
dkconfig_internal_check
When true, perform detailed internal checking.static boolean
dkconfig_logDetail
Determines whether or not detailed info (such as fromadd_modified
) is printed.static boolean
dkconfig_show_stack_trace
If true, show stack traces for errors such as file format errors.static boolean
dkconfig_showTraceback
Determines whether or not traceback information is printed for each call to log.static @Nullable String
function_binary_method
Restrict function binary prints to the specified method.
-
Constructor Summary
Constructors Constructor Description Debug(Class<?> c, Ppt ppt, VarInfo[] vis)
Ordinarily, a client would have to supply a Class, Ppt, andList<Varinfo>
with each call to a log method.Debug(Class<?> c, Ppt ppt, List<VarInfo> vis)
Ordinarily, a client would have to supply a Class, Ppt, andList<Varinfo>
with each call to a log method.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static @Nullable String
add_track(String def)
Parses the specified argument to--track
and sets up the track arrays accordingly.static void
check(PptMap all_ppts, String msg)
Looks through entire ppt tree and checks for any items we are interested in.static boolean
class_match(@Nullable Class<?> inv_class)
Returns whether or not the specified class matches the classes being tracked.static String
int_vars(PptTopLevel ppt, ValueTuple vt)
Returns a string containing the integer variables and their values.static boolean
log(@Nullable Class<?> inv_class, @Nullable @UnknownInitialization(PptTopLevel.class) Ppt ppt, VarInfo @Nullable [] vis, String msg)
Logs a description of the class, ppt, variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, String)
.static boolean
log(Class<?> inv_class, @UnknownInitialization(PptTopLevel.class) Ppt ppt, String msg)
Logs a description of the class, ppt, ppt variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, VarInfo[], String)
.boolean
log(String msg)
Logs a description of the cached class, ppt, and variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, VarInfo[], String)
static void
log(Logger debug, @Nullable Class<?> inv_class, @Nullable Ppt ppt, VarInfo @Nullable [] vis, String msg)
Logs a description of the class, ppt, variables and the specified msg via the logger.static void
log(Logger debug, Class<?> inv_class, @Nullable Ppt ppt, String msg)
Logs a description of the class, ppt, ppt variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, VarInfo[], String)
.void
log(Logger debug, String msg)
Logs the cached class, cached ppt, cached variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, VarInfo[], String)
.static boolean
logDetail()
Returns whether or not detailed logging is on.static boolean
logOn()
Returns whether or not logging is on.static @Nullable Debug
newDebug(Class<?> c, Ppt ppt, VarInfo[] vis)
Returns a Debug object if the specified class, ppt, and vis match what is being tracked.static boolean
ppt_match(@Nullable @UnknownInitialization(PptTopLevel.class) Ppt ppt)
Returns whether or not the specified ppt matches the ppts being tracked.static String
related_vars(PptTopLevel ppt, ValueTuple vt)
Returns a string containing the variable values for any variables that are currently being tracked in ppt.static String
toString(@Nullable Object val)
Like Object.toString(), but handles null, and has special handling for arrays.static String
toString(VarInfo[] vis, ValueTuple vt)
Returns a string containing each variable and its value.static boolean
var_match(VarInfo @Nullable [] vis)
Returns whether or not the specified vars match the ones being tracked.static VarInfo[]
vis(VarInfo v1)
static VarInfo[]
vis(VarInfo v1, VarInfo v2)
static VarInfo[]
vis(VarInfo v1, VarInfo v2, VarInfo v3)
@Nullable VarInfo
visTracked(List<VarInfo> vis)
Looks for each of the variables in vis in the DebugTrackVar list.
-
-
-
Field Detail
-
debugTrack
public static final Logger debugTrack
Debug Logger.
-
debugTrackClass
public static String[] debugTrackClass
List of classes for logging. Each name listed is compared to the fully qualified class name. If it matches (shows up anywhere in the class name) it will be included in debug prints. This is not a regular expression match- See Also:
log(Logger, Class, Ppt, String)
-
function_binary_method
public static @Nullable String function_binary_method
Restrict function binary prints to the specified method. Implementation is in the FunctionBinary specific log functions. If null, there is no restriction (all function binary methods are printed). See Functions.java for a list of function names.
-
debugTrackPpt
public static String[] debugTrackPpt
List of Ppts for logging. Each name listed is compared to the full program point name. If it matches (shows up anywhere in the ppt name) it will be included in the debug prints. This is not a regular expression match.- See Also:
log(Logger, Class, Ppt, String)
-
debugTrackVars
public static String[][] debugTrackVars
List of variable names for logging. Each name listed is compared to each variable in turn. If each matches exactly it will be included in track debug prints. This is not a regular expression match. Note that the number of variables must match the slice exactly.- See Also:
log(Logger, Class, Ppt, String)
-
cache_match
public boolean cache_match
True if the cached values should be printed --- that is, they match what is currently being debugged.
-
cache_class
public @Nullable Class<?> cache_class
cached class: class to use by default when calling variants of log() with few arguments.
-
cache_ppt
public @Nullable Ppt cache_ppt
Cached ppt: ppt to use by default when calling variants of log() with few arguments.
-
cache_vis
public VarInfo @Nullable [] cache_vis
Cached variables: variables to use by default when calling variants of log() with few arguments.
-
dkconfig_internal_check
public static boolean dkconfig_internal_check
When true, perform detailed internal checking. These are essentially additional, possibly costly assert statements.
-
dkconfig_show_stack_trace
public static boolean dkconfig_show_stack_trace
If true, show stack traces for errors such as file format errors.
-
dkconfig_showTraceback
public static boolean dkconfig_showTraceback
Determines whether or not traceback information is printed for each call to log.- See Also:
log(Logger, Class, Ppt, String)
-
dkconfig_logDetail
public static boolean dkconfig_logDetail
Determines whether or not detailed info (such as fromadd_modified
) is printed.- See Also:
log(Logger, Class, Ppt, String)
,logDetail()
-
-
Constructor Detail
-
Debug
public Debug(Class<?> c, Ppt ppt, VarInfo[] vis)
Ordinarily, a client would have to supply a Class, Ppt, andList<Varinfo>
with each call to a log method. This constructor sets as defaults c, ppt, and whatever variable (if any) from vis that is on the debugTrackVar list. Essentially this creates a debug object that will print if any of the variables in vis are being tracked (and c and ppt match).
-
Debug
public Debug(Class<?> c, Ppt ppt, List<VarInfo> vis)
Ordinarily, a client would have to supply a Class, Ppt, andList<Varinfo>
with each call to a log method. This constructor sets as defaults c, ppt, and whatever variable (if any) from vis that is on the debugTrackVar list. Essentially this creates a debug object that will print if any of the variables in vis are being tracked (and c and ppt match).
-
-
Method Detail
-
newDebug
public static @Nullable Debug newDebug(Class<?> c, Ppt ppt, VarInfo[] vis)
Returns a Debug object if the specified class, ppt, and vis match what is being tracked. Otherwise, return NULL. Preferred over calling the constructor directly, since it doesn't create the object if it doesn't have to.
-
visTracked
public @Nullable VarInfo visTracked(@UnknownInitialization Debug this, List<VarInfo> vis)
Looks for each of the variables in vis in the DebugTrackVar list. If any match, returns that variable. Returns null if there are no matches.
-
logDetail
public static final boolean logDetail()
Returns whether or not detailed logging is on. Note that this check is not performed inside the logging calls themselves, it must be performed by the caller.- See Also:
log(Logger, Class, Ppt, String)
,logOn()
-
logOn
public static final boolean logOn()
Returns whether or not logging is on.- See Also:
log(Logger, Class, Ppt, String)
-
log
public void log(Logger debug, String msg)
Logs the cached class, cached ppt, cached variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, VarInfo[], String)
.
-
log
public static void log(Logger debug, Class<?> inv_class, @Nullable Ppt ppt, String msg)
Logs a description of the class, ppt, ppt variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, VarInfo[], String)
.
-
log
public static void log(Logger debug, @Nullable Class<?> inv_class, @Nullable Ppt ppt, VarInfo @Nullable [] vis, String msg)
Logs a description of the class, ppt, variables and the specified msg via the logger. The class, ppt, and variables are checked against those described indebugTrackClass
,debugTrackPpt
, anddebugTrackVars
. Only those that match are printed. Variables will match if they are in the same equality set. The information is written as:class: ppt : var1 : var2 : var3 : msg
Note that if
debugTrack
is not enabled then nothing is printed. It is somewhat faster to checklogOn()
directly rather than relying on the check here.Other versions of this method (noted below) work without the Logger parameter and take class, ppt, and vis from the cached values, which were set by the constructor or by the set() method.
- Parameters:
debug
- a second Logger to query if debug tracking is turned off or does not match. If this logger is enabled, the same information will be written to it. Note that the information is never written to both loggers.inv_class
- the class. Can be obtained in a static context by ClassName.classppt
- program pointvis
- variables at the program point. These are sometimes different from the ones in the ppt itself.msg
- string message to log- See Also:
logOn()
,logDetail()
,log(Class, Ppt, VarInfo[], String)
,log(Class, Ppt, String)
,log(Logger, String)
,log(String)
-
log
public boolean log(String msg)
Logs a description of the cached class, ppt, and variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, VarInfo[], String)
- Returns:
- whether or not it logged anything
-
log
public static boolean log(Class<?> inv_class, @UnknownInitialization(PptTopLevel.class) Ppt ppt, String msg)
Logs a description of the class, ppt, ppt variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, VarInfo[], String)
.- Returns:
- whether or not it logged anything
-
log
public static boolean log(@Nullable Class<?> inv_class, @Nullable @UnknownInitialization(PptTopLevel.class) Ppt ppt, VarInfo @Nullable [] vis, String msg)
Logs a description of the class, ppt, variables and the specified msg via the logger as described inlog(Logger, Class, Ppt, String)
. Accepts vis because sometimes the variables are different from those in the ppt.- Returns:
- whether or not it logged anything
-
class_match
public static boolean class_match(@Nullable Class<?> inv_class)
Returns whether or not the specified class matches the classes being tracked.
-
ppt_match
public static boolean ppt_match(@Nullable @UnknownInitialization(PptTopLevel.class) Ppt ppt)
Returns whether or not the specified ppt matches the ppts being tracked.
-
var_match
public static boolean var_match(VarInfo @Nullable [] vis)
Returns whether or not the specified vars match the ones being tracked. Also, sets Debug.ourvars with the names of the variables matched if they are not the leader of their equality sets.
-
check
public static void check(PptMap all_ppts, String msg)
Looks through entire ppt tree and checks for any items we are interested in. If found, prints them out.
-
int_vars
public static String int_vars(PptTopLevel ppt, ValueTuple vt)
Returns a string containing the integer variables and their values.
-
related_vars
public static String related_vars(PptTopLevel ppt, ValueTuple vt)
Returns a string containing the variable values for any variables that are currently being tracked in ppt. The string is of the form 'v1 = val1: v2 = val2, etc.
-
toString
public static String toString(@Nullable Object val)
Like Object.toString(), but handles null, and has special handling for arrays.
-
toString
public static String toString(VarInfo[] vis, ValueTuple vt)
Returns a string containing each variable and its value.The string is of the form "v1 = val1: v2 = val2, ...".
-
add_track
public static @Nullable String add_track(String def)
Parses the specified argument to--track
and sets up the track arrays accordingly. The syntax of the argument is
As shown, multiple class arguments can be specified separated by pipe symbols (|). The variables are specified in angle brackets (class|class|...<var,var,var>@ppt
<>
) and the program point is preceeded by an at sign (@). Each is optional and can be left out. The add_track routine can be called multiple times. An invariant that matches any of the specifications will be tracked.
-
-