Package daikon

Class FileIO


  • public final class FileIO
    extends Object
    File I/O utilities.
    • Field Detail

      • 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_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 (|).
      • debug_missing

        public static boolean debug_missing
        If true, then print the variable name each time the variable's value is first missing/nonsensical.
      • debugRead

        public static final Logger debugRead
        Debug tracer for reading.
      • debugVars

        public static final Logger debugVars
        Debug tracer for printing variable values.
      • 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
      • 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,
                                                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

        @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
      • 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.
      • 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.
      • 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.