Package daikon
Class FileIO
- Object
-
- FileIO
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileIO.ParentRelation
Parents in the ppt/variable hierarchy for a particular program point.static class
FileIO.ParseState
ParseState indicates: Some global information about the state of the parser while reading a decl or dtrace file.static class
FileIO.Processor
A Processor is used to read a dtrace file.static class
FileIO.RecordType
The type of the record that was most recently read.static class
FileIO.VarDefinition
Class that holds information from the declaration record (in the file).
-
Field Summary
Fields Modifier and Type Field Description static String
class_static_suffix
String used to identify class ppt names.static String
class_static_tag
String used to mark class ppt names.static @MonotonicNonNull FileIO.ParseState
data_trace_state
Logically, this is a local variable in static method read_data_trace_file.static boolean
debug_missing
If true, then print the variable name each time the variable's value is first missing/nonsensical.static Logger
debugPrint
Debug tracer for printing.static Logger
debugRead
Debug tracer for reading.static Logger
debugVars
Debug tracer for printing variable values.static boolean
dkconfig_add_changed
Boolean.static boolean
dkconfig_continue_after_file_exception
Boolean.static boolean
dkconfig_count_lines
Boolean.static long
dkconfig_dtrace_line_count
Long integer.static boolean
dkconfig_ignore_missing_enter
When true, just ignore exit ppts that don't have a matching enter ppt rather than exiting with an error.static int
dkconfig_max_line_number
Integer.static boolean
dkconfig_read_samples_only
Boolean.static boolean
dkconfig_rm_stack_dups
If true, modified all ppt names to remove duplicate routine names within the ppt name.static boolean
dkconfig_unmatched_procedure_entries_quiet
Boolean.static boolean
dkconfig_verbose_unmatched_procedure_entries
Boolean.static String
enter_suffix
String used to identify entry ppt names.static String
enter_tag
String used to mark entry ppt names.static String
exit_suffix
String used to identify exit ppt names.static String
exit_tag
String used to mark exit ppt names.static String
global_suffix
String used to identify global ppt names.static @MonotonicNonNull Boolean
new_decl_format
True if declaration records are in the new format -- that is, decl-version 2.0.static String
object_suffix
static String
object_tag
String used to mark object ppt names.static int
omitted_declarations
static String
ppt_tag_separator
String used to append a ppt type to a ppt name.static int
samples_processed
Total number of samples passed to process_sample().static String
throws_suffix
To be deleted.static String
throws_tag
To be deleted.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
compute_derived_variables(PptTopLevel ppt, @Nullable Object[] vals, int[] mods)
Computes values of derived variables.static boolean
compute_orig_variables(PptTopLevel ppt, @Nullable Object[] vals, int[] mods, @Nullable Integer nonce)
If this is a function entry ppt, stores the values of all of the variables away for use at the exit.static int
get_linenum()
Returns the current line number in the input file, or -1 if not available.static boolean
isComment(@Nullable String s)
static @Interned String
need(FileIO.ParseState state, Scanner scanner, String description)
Helper function, returns the next string token unescaped and interned.static void
need_eol(FileIO.ParseState state, Scanner scanner)
Throws a Daikon.UserError if the scanner is not at end of linestatic boolean
nextLineIsComment(BufferedReader reader)
Returns true if the next line is a comment.static <E extends Enum<E>>
Eparse_enum_val(FileIO.ParseState state, Scanner scanner, Class<E> enum_class, String descr)
Looks up the next token as a member of enum_class.static boolean
ppt_included(String ppt_name)
Returns whether or not the specified ppt name should be included in processing.static void
process_sample(PptMap all_ppts, PptTopLevel ppt, ValueTuple vt, @Nullable Integer nonce)
Add orig() and derived variables to vt (by side effect), then supply it to the program point for flowing.static void
process_unmatched_procedure_entries()
Print each call that does not have a matching exit.static void
read_data_trace_file(String filename, PptMap all_ppts)
Read only samples from.dtrace
file.static void
read_data_trace_file(String filename, PptMap all_ppts, FileIO.Processor processor, boolean is_decl_file, boolean ppts_may_be_new)
Read declarations AND samples (not just sample data as the name might imply) from.dtrace
file.static void
read_data_trace_files(Collection<String> files, PptMap all_ppts)
Reads data from.dtrace
files.static void
read_data_trace_files(Collection<String> files, PptMap all_ppts, FileIO.Processor processor, boolean ppts_may_be_new)
Reads data from.dtrace
files.static void
read_data_trace_record(FileIO.ParseState state)
Read a single record of ANY type (sample, declaration, comparability, etc.) from a dtrace file.static void
read_data_trace_record_setstate(FileIO.ParseState state)
Like read_data_trace_record, but sets global FileIO.data_trace_state for the duration of the call then clears it before returning.static void
read_declaration_file(File filename, PptMap all_ppts)
Read one decls file; add it to all_ppts.static PptMap
read_declaration_files(Collection<File> files)
Returns a new PptMap containing declarations read from the files listed in the argument; connection information (controlling variables and entry ppts) is set correctly upon return.static PptMap
read_serialized_pptmap(File file, boolean use_saved_config)
Read either a serialized PptMap or a InvMap and return a PptMap.static void
resetNewDeclFormat()
Do not use this routine unless you know what you are doing.static String
user_mod_ppt_name(String ppt_name)
Handle any possible modifications to the ppt name.static boolean
var_included(String var_name)
Returns true if the given variable is included, according to Daikon's--var-select-pattern
and--var-omit-pattern
flags.static void
write_serialized_pptmap(PptMap map, File file)
Write a serialized PptMap to a file.
-
-
-
Field Detail
-
ppt_tag_separator
public static final String ppt_tag_separator
String used to append a ppt type to a ppt name.- See Also:
- Constant Field Values
-
enter_suffix
public static final String enter_suffix
String used to identify entry ppt names.- See Also:
- Constant Field Values
-
enter_tag
public static final String enter_tag
String used to mark entry ppt names.- See Also:
- Constant Field Values
-
exit_suffix
public static final String exit_suffix
String used to identify exit ppt names.- See Also:
- Constant Field Values
-
exit_tag
public static final String exit_tag
String used to mark exit ppt names.- See Also:
- Constant Field Values
-
throws_suffix
public static final String throws_suffix
To be deleted.- See Also:
- Constant Field Values
-
throws_tag
public static final String throws_tag
To be deleted.- See Also:
- Constant Field Values
-
object_suffix
public static final String object_suffix
- See Also:
- Constant Field Values
-
object_tag
public static final String object_tag
String used to mark object ppt names.- See Also:
- Constant Field Values
-
class_static_suffix
public static final String class_static_suffix
String used to identify class ppt names.- See Also:
- Constant Field Values
-
class_static_tag
public static final String class_static_tag
String used to mark class ppt names.- See Also:
- Constant Field Values
-
global_suffix
public static final String global_suffix
String used to identify global ppt names.- See Also:
- Constant Field Values
-
dkconfig_ignore_missing_enter
public static boolean dkconfig_ignore_missing_enter
When true, just ignore exit ppts that don't have a matching enter ppt rather than exiting with an error. Unmatched exits can occur if only a portion of a dtrace file is processed.
-
dkconfig_add_changed
public static boolean dkconfig_add_changed
Boolean. When false, set modbits to 1 iff the printed representation has changed. When true, set modbits to 1 if the printed representation has changed; leave other modbits as is.
-
dkconfig_max_line_number
public static int dkconfig_max_line_number
Integer. Maximum number of lines to read from the dtrace file. If 0, reads the entire file.
-
dkconfig_count_lines
public static boolean dkconfig_count_lines
Boolean. When false, don't count the number of lines in the dtrace file before reading. This will disable the percentage progress printout.
-
dkconfig_read_samples_only
public static boolean dkconfig_read_samples_only
Boolean. When true, only read the samples, but don't process them. Used to gather timing information.
-
dkconfig_unmatched_procedure_entries_quiet
public static boolean dkconfig_unmatched_procedure_entries_quiet
Boolean. When true, don't print a warning about unmatched procedure entries, which are ignored by Daikon (unless the--nohierarchy
command-line argument is provided).
-
dkconfig_verbose_unmatched_procedure_entries
public static boolean dkconfig_verbose_unmatched_procedure_entries
Boolean. If true, prints the unmatched procedure entries verbosely.
-
dkconfig_continue_after_file_exception
public static boolean dkconfig_continue_after_file_exception
Boolean. When true, suppress exceptions related to file reading. This permits Daikon to continue even if there is a malformed trace file. Use this with care: in general, it is better to fix the problem that caused a bad trace file, rather than to suppress the exception.
-
dkconfig_dtrace_line_count
public static long dkconfig_dtrace_line_count
Long integer. If non-zero, this value will be used as the number of lines in (each) dtrace file input for the purposes of the progress display, and the counting of the lines in the file will be suppressed.
-
new_decl_format
public static @MonotonicNonNull Boolean new_decl_format
True if declaration records are in the new format -- that is, decl-version 2.0.
-
dkconfig_rm_stack_dups
public static boolean dkconfig_rm_stack_dups
If true, modified all ppt names to remove duplicate routine names within the ppt name. This is used when a stack trace (of active methods) is used as the ppt name. The routine names must be separated by vertical bars (|).
-
omitted_declarations
public static int omitted_declarations
-
debug_missing
public static boolean debug_missing
If true, then print the variable name each time the variable's value is first missing/nonsensical.
-
debugPrint
public static final Logger debugPrint
Debug tracer for printing.
-
samples_processed
public static int samples_processed
Total number of samples passed to process_sample(). Not part of ParseState because it's global over all files processed by Daikon.
-
data_trace_state
public static @MonotonicNonNull FileIO.ParseState data_trace_state
Logically, this is a local variable in static method read_data_trace_file. It is used for status output, and to give the line number at which a problem was detected.
-
-
Method Detail
-
resetNewDeclFormat
public static void resetNewDeclFormat()
Do not use this routine unless you know what you are doing. This routine breaks the representation invariant that new_decl_format, once set, is never reset to null. This routine should be used only if you can guarantee that new_decl_format will be once again set to a non-null value before any code runs that depends on the fact that new_decl_format is non-null.
-
isComment
@EnsuresNonNullIf(result=true, expression="#1") @Pure public static final boolean isComment(@Nullable String s)
-
nextLineIsComment
@EnsuresNonNullIf(result=true, expression="#1.readLine()") public static final boolean nextLineIsComment(BufferedReader reader)
Returns true if the next line is a comment.- Parameters:
reader
- the reader whose next line to check- Returns:
- true if the next line is a comment
-
read_declaration_files
public static PptMap read_declaration_files(Collection<File> files) throws IOException
Returns a new PptMap containing declarations read from the files listed in the argument; connection information (controlling variables and entry ppts) is set correctly upon return.- Parameters:
files
- files to be read (java.io.File)- Returns:
- a new PptMap containing declarations read from the files listed in the argument
- Throws:
IOException
-
read_declaration_file
public static void read_declaration_file(File filename, PptMap all_ppts) throws IOException
Read one decls file; add it to all_ppts.- Throws:
IOException
-
read_data_trace_files
public static void read_data_trace_files(Collection<String> files, PptMap all_ppts) throws IOException
Reads data from.dtrace
files. For each record in the files, calls the appropriate callback in the processor.
-
read_data_trace_files
public static void read_data_trace_files(Collection<String> files, PptMap all_ppts, FileIO.Processor processor, boolean ppts_may_be_new) throws IOException
Reads data from.dtrace
files. Callsread_data_trace_file(String,PptMap,Processor,boolean,boolean)
for each element of filenames.- Parameters:
ppts_may_be_new
- true if declarations of ppts read from the data trace file are new (and thus are not in all_ppts). false if the ppts may already be there.- Throws:
IOException
- See Also:
read_data_trace_file(String,PptMap,Processor,boolean,boolean)
-
get_linenum
public static int get_linenum()
Returns the current line number in the input file, or -1 if not available.
-
read_data_trace_file
public static void read_data_trace_file(String filename, PptMap all_ppts) throws IOException
Read only samples from.dtrace
file. Uses the standard data processor which callsprocess_sample(PptMap, PptTopLevel, ValueTuple, Integer)
on each record, and ignores records other than samples.- Throws:
IOException
-
read_data_trace_file
public static void read_data_trace_file(String filename, PptMap all_ppts, FileIO.Processor processor, boolean is_decl_file, boolean ppts_may_be_new) throws IOException
Read declarations AND samples (not just sample data as the name might imply) from.dtrace
file. For each record read from the file, passes the record to a method of the processor.- Throws:
IOException
-
read_data_trace_record_setstate
public static void read_data_trace_record_setstate(FileIO.ParseState state) throws IOException
Like read_data_trace_record, but sets global FileIO.data_trace_state for the duration of the call then clears it before returning. Intended for most external callers.- Throws:
IOException
-
read_data_trace_record
@RequiresNonNull("FileIO.data_trace_state") public static void read_data_trace_record(FileIO.ParseState state) throws IOException
Read a single record of ANY type (sample, declaration, comparability, etc.) from a dtrace file. If the record is anything but a sample, also processes it. The record is stored by side effect into the state argument.- Throws:
IOException
-
process_sample
@RequiresNonNull("FileIO.data_trace_state") public static void process_sample(PptMap all_ppts, PptTopLevel ppt, ValueTuple vt, @Nullable Integer nonce)
Add orig() and derived variables to vt (by side effect), then supply it to the program point for flowing.- Parameters:
vt
- trace data only; modified by side effect to add derived vars
-
process_unmatched_procedure_entries
public static void process_unmatched_procedure_entries()
Print each call that does not have a matching exit.
-
compute_orig_variables
@RequiresNonNull("FileIO.data_trace_state") public static boolean compute_orig_variables(PptTopLevel ppt, @Nullable Object[] vals, int[] mods, @Nullable Integer nonce)
If this is a function entry ppt, stores the values of all of the variables away for use at the exit. If this is an exit, finds the values at enter and adds them as the values of the orig variables. Normally returns false. Returns true if this is an exit without a matching enter. See dkconfig_ignore_missing_enter for more info. If true is returned, this ppt should be ignored by the caller.
-
compute_derived_variables
public static void compute_derived_variables(PptTopLevel ppt, @Nullable Object[] vals, int[] mods)
Computes values of derived variables.
-
write_serialized_pptmap
public static void write_serialized_pptmap(PptMap map, File file) throws IOException
Write a serialized PptMap to a file.- Parameters:
map
- a PptMapfile
- the file to which to write- Throws:
IOException
- if there is trouble writing the file
-
read_serialized_pptmap
@EnsuresNonNull("FileIO.new_decl_format") public static PptMap read_serialized_pptmap(File file, boolean use_saved_config) throws IOException
Read either a serialized PptMap or a InvMap and return a PptMap. If an InvMap is specified, it is converted to a PptMap.- Throws:
IOException
-
ppt_included
public static boolean ppt_included(String ppt_name)
Returns whether or not the specified ppt name should be included in processing. Ppts can be excluded because they match the omit_regexp, don't match ppt_regexp, or are greater than ppt_max_name.
-
var_included
public static boolean var_included(String var_name)
Returns true if the given variable is included, according to Daikon's--var-select-pattern
and--var-omit-pattern
flags.
-
need
public static @Interned String need(FileIO.ParseState state, Scanner scanner, String description)
Helper function, returns the next string token unescaped and interned. Throws Daikon.UserError if there is no next token.
-
need_eol
public static void need_eol(FileIO.ParseState state, Scanner scanner)
Throws a Daikon.UserError if the scanner is not at end of line
-
parse_enum_val
public static <E extends Enum<E>> E parse_enum_val(FileIO.ParseState state, Scanner scanner, Class<E> enum_class, String descr)
Looks up the next token as a member of enum_class. Throws Daikon.UserError if there is no token or if it is not valid member of the class. Enums are presumed to be in in upper case.
-
user_mod_ppt_name
public static String user_mod_ppt_name(String ppt_name)
Handle any possible modifications to the ppt name. For now, just support the Applications Communities specific modification to remove duplicate stack entries. But a more generic technique could be implemented in the future.
-
-