daikon
Class Debug

Object
  extended by Debug

public 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 a print to occur.


Field Summary
 Class<?> cache_class
          cached class
 boolean cache_match
          True if the cached variables are printable.
 Ppt cache_ppt
          cached ppt
 VarInfo[] cache_vis
          cached variables
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_logDetail
          Determines whether or not detailed info (such as from add_modified) is printed.
static boolean dkconfig_showTraceback
          Determines whether or not traceback information is printed for each call to log.
static String function_binary_method
          Restrict function binary prints to the specified method.
 
Constructor Summary
Debug(Class<?> c, Ppt ppt, List<VarInfo> vis)
          Sets up the cache for c, ppt, and whatever variable (if any) from vis that is on the debugTrackVar list.
Debug(Class<?> c, Ppt ppt, VarInfo[] vis)
          Sets the cache for class, ppt, and vis so that future calls to log don't have to set them.
 
Method Summary
static 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(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(Class<?> inv_class, Ppt ppt, String msg)
          Logs a description of the class, ppt, ppt variables and the specified msg via the logger as described in log(Logger, Class, Ppt, VarInfo[], String).
static boolean log(Class<?> inv_class, Ppt ppt, VarInfo[] vis, String msg)
          Logs a description of the class, ppt, variables and the specified msg via the logger as described in log(Logger, Class, Ppt, String).
static void log(Logger debug, Class<?> inv_class, Ppt ppt, String msg)
          Logs a description of the class, ppt, ppt variables and the specified msg via the logger as described in log(Logger, Class, Ppt, VarInfo[], String).
static void log(Logger debug, Class<?> inv_class, Ppt ppt, VarInfo[] vis, String msg)
          Logs a description of the class, ppt, variables and the specified msg via the logger.
 void log(Logger debug, String msg)
          Logs the cached class, cached ppt, cached variables and the specified msg via the logger as described in log(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 in log(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 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(Ppt ppt)
          Returns whether onot 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(Object val)
           
static String toString(VarInfo[] vis)
           
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, etc.
static boolean var_match(VarInfo[] 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)
           
 VarInfo visTracked(List<VarInfo> vis)
          Looks for each of the variables in vis in the DebugTrackVar list.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 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 variables are printable.


cache_class

public Class<?> cache_class
cached class


cache_ppt

public Ppt cache_ppt
cached ppt


cache_vis

public VarInfo[] cache_vis
cached variables


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 from add_modified) is printed.

See Also:
log(Logger, Class, Ppt, String), logDetail()
Constructor Detail

Debug

public Debug(Class<?> c,
             Ppt ppt,
             VarInfo[] vis)
Sets the cache for class, ppt, and vis so that future calls to log don't have to set them.


Debug

public Debug(Class<?> c,
             Ppt ppt,
             List<VarInfo> vis)
Sets up the cache for 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 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 VarInfo visTracked(List<VarInfo> vis)
Looks for each of the variables in vis in the DebugTrackVar list. If any match, returns that variable. Null is returned if there are no matches.


vis

public static VarInfo[] vis(VarInfo v1)

vis

public static VarInfo[] vis(VarInfo v1,
                            VarInfo v2)

vis

public static VarInfo[] vis(VarInfo v1,
                            VarInfo v2,
                            VarInfo v3)

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 in log(Logger, Class, Ppt, VarInfo[], String).


log

public static void log(Logger debug,
                       Class<?> inv_class,
                       Ppt ppt,
                       String msg)
Logs a description of the class, ppt, ppt variables and the specified msg via the logger as described in log(Logger, Class, Ppt, VarInfo[], String).


log

public static void log(Logger debug,
                       Class<?> inv_class,
                       Ppt ppt,
                       VarInfo[] 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 in debugTrackClass, debugTrackPpt, and debugTrackVars. 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 check logOn() 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

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.class
ppt - Program point
vis - 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 in log(Logger, Class, Ppt, VarInfo[], String)

Returns:
whether or not it logged anything

log

public static boolean log(Class<?> inv_class,
                          Ppt ppt,
                          String msg)
Logs a description of the class, ppt, ppt variables and the specified msg via the logger as described in log(Logger, Class, Ppt, VarInfo[], String).

Returns:
whether or not it logged anything

log

public static boolean log(Class<?> inv_class,
                          Ppt ppt,
                          VarInfo[] vis,
                          String msg)
Logs a description of the class, ppt, variables and the specified msg via the logger as described in log(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(Class<?> inv_class)
Returns whether or not the specified class matches the classes being tracked


ppt_match

public static boolean ppt_match(Ppt ppt)
Returns whether onot the specified ppt matches the ppts being tracked


var_match

public static boolean var_match(VarInfo[] 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(Object val)

toString

public static String toString(VarInfo[] vis)

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, etc.


add_track

public static String add_track(String def)
Parses the specified argument to --track and sets up the track arrays accordingly. The syntax of the argument is class|class|...@ppt As shown, multiple class arguments can be specified separated by pipe symbols (|). The variables are specified in angle brackets (<>) 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.