Search in sources :

Example 1 with Config

use of com.jopdesign.common.config.Config in project jop by jop-devel.

the class WCAInvoker method setWCETOptions.

private void setWCETOptions(MethodInfo targetMethod, boolean generateReports) {
    Config config = wcetTool.getConfig();
    config.setOption(ProjectConfig.TARGET_METHOD, targetMethod.getMemberID().toString());
    config.setOption(ProjectConfig.DO_GENERATE_REPORTS, generateReports);
    config.setOption(IPETConfig.DUMP_ILP, false);
    config.getDebugGroup().setOption(ProjectConfig.DUMP_TARGET_CALLGRAPH, DUMPTYPE.off);
}
Also used : Config(com.jopdesign.common.config.Config) IPETConfig(com.jopdesign.wcet.ipet.IPETConfig) ProjectConfig(com.jopdesign.wcet.ProjectConfig)

Example 2 with Config

use of com.jopdesign.common.config.Config in project jop by jop-devel.

the class WCETTool method recordResult.

/* recording for scripted evaluation */
public void recordResult(WcetCost wcet, double timeDiff, double solverTime) {
    if (resultRecord == null)
        return;
    Config c = projectConfig.getConfig();
    OptionGroup o = JOPConfig.getOptions(c);
    if (projectConfig.addPerformanceResults()) {
        recordCVS("wcet", "ipet", wcet, timeDiff, solverTime, o.getOption(JOPConfig.CACHE_IMPL), o.getOption(JOPConfig.CACHE_SIZE_WORDS), o.getOption(JOPConfig.CACHE_BLOCKS), c.getOption(IPETConfig.STATIC_CACHE_APPROX), c.getOption(IPETConfig.ASSUME_MISS_ONCE_ON_INVOKE));
    } else {
        recordCVS("wcet", "ipet", wcet, o.getOption(JOPConfig.CACHE_IMPL), o.getOption(JOPConfig.CACHE_SIZE_WORDS), o.getOption(JOPConfig.CACHE_BLOCKS), c.getOption(IPETConfig.STATIC_CACHE_APPROX), c.getOption(IPETConfig.ASSUME_MISS_ONCE_ON_INVOKE));
    }
}
Also used : OptionGroup(com.jopdesign.common.config.OptionGroup) JOPConfig(com.jopdesign.common.processormodel.JOPConfig) IPETConfig(com.jopdesign.wcet.ipet.IPETConfig) UppAalConfig(com.jopdesign.wcet.uppaal.UppAalConfig) Config(com.jopdesign.common.config.Config) ReportConfig(com.jopdesign.wcet.report.ReportConfig)

Example 3 with Config

use of com.jopdesign.common.config.Config in project jop by jop-devel.

the class AppSetup method setupConfig.

/**
     * Load the config file, parse and check options.
     *
     * @param args cmdline arguments to parse
     * @return arguments not consumed.
     */
public String[] setupConfig(String[] args) {
    if (configFilename != null) {
        File file = findConfigFile(configFilename);
        if (file != null && file.exists()) {
            try {
                InputStream is = new BufferedInputStream(new FileInputStream(file));
                config.addProperties(is);
                is.close();
            } catch (FileNotFoundException e) {
                // should never happen
                System.out.flush();
                System.err.println("Configuration file '" + configFilename + "' not found: " + e.getMessage());
            } catch (IOException e) {
                System.out.flush();
                System.err.println("Could not read config file '" + file + "': " + e.getMessage());
                System.exit(3);
            }
        }
    }
    String[] rest = null;
    try {
        rest = config.parseArguments(args);
        // TODO options of non-enabled tools should not be required (but checked if present?)
        config.checkOptions();
        // we parse the main method signature here, so it is available to the tools before
        // AppInfo is initialized
        mainMethodID = getMainSignature(rest.length > 0 ? rest[0] : null);
    } catch (Config.BadConfigurationException e) {
        System.out.flush();
        System.err.println(e.getMessage());
        if (config.getOptions().containsOption(Config.SHOW_HELP)) {
            System.err.println("Use '--help' to show a usage message.");
        }
        System.exit(2);
    }
    // handle standard options
    if (config.getOption(Config.SHOW_HELP)) {
        printUsage();
        System.exit(0);
    }
    if (config.getOption(Config.SHOW_VERSION)) {
        printVersion();
        System.exit(0);
    }
    // let modules process their config options
    try {
        for (String tool : tools.keySet()) {
            if (useTool(tool)) {
                tools.get(tool).onSetupConfig(this);
            }
        }
    } catch (Config.BadConfigurationException e) {
        System.out.flush();
        System.err.println(e.getMessage());
        if (config.getOptions().containsOption(Config.SHOW_HELP)) {
            System.err.println("Use '--help' to show a usage message.");
        }
        System.exit(2);
    }
    // Dump the config only after we let the tools initialize the config first
    if (config.getOption(Config.SHOW_CONFIG)) {
        config.printConfiguration(config.getDefaultIndent());
        System.exit(0);
    }
    return rest;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) BadConfigurationException(com.jopdesign.common.config.Config.BadConfigurationException) Config(com.jopdesign.common.config.Config) JOPConfig(com.jopdesign.common.processormodel.JOPConfig) LogConfig(com.jopdesign.common.logger.LogConfig) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 4 with Config

use of com.jopdesign.common.config.Config in project jop by jop-devel.

the class AppSetup method setupAppInfo.

/**
     * Setup AppInfo using the config previously initialized with {@link #setupConfig(String[])}.
     * 
     * @param args the arguments containing the name of the main method and additional roots without config options.
     * @param loadTransitiveHull if true, load the transitive hull of the root classes too.
     */
public void setupAppInfo(String[] args, boolean loadTransitiveHull) {
    CustomAttribute.registerDefaultReader();
    appInfo.setClassPath(new ClassPath(config.getOption(Config.CLASSPATH)));
    appInfo.setExitOnMissingClass(!config.getOption(Config.VERBOSE));
    // handle class loading options if set
    if (config.hasOption(Config.LIBRARY_CLASSES)) {
        List<String> libs = Config.splitStringList(config.getOption(Config.LIBRARY_CLASSES));
        for (String lib : libs) {
            appInfo.addLibrary(lib.replaceAll("/", "."));
        }
    }
    if (config.hasOption(Config.IGNORE_CLASSES)) {
        List<String> ignore = Config.splitStringList(config.getOption(Config.IGNORE_CLASSES));
        for (String cls : ignore) {
            appInfo.addLibrary(cls.replaceAll("/", "."));
        }
    }
    if (config.hasOption(Config.EXCLUDE_LIBRARIES)) {
        appInfo.setLoadLibraries(!config.getOption(Config.EXCLUDE_LIBRARIES));
    }
    if (config.hasOption(Config.EXCLUDE_NATIVES)) {
        appInfo.setLoadNatives(!config.getOption(Config.EXCLUDE_NATIVES));
    }
    appInfo.setCallstringLength(config.getOption(Config.CALLSTRING_LENGTH).intValue());
    for (String hwObject : Config.splitStringList(config.getOption(Config.HW_OBJECTS))) {
        appInfo.addHwObjectName(hwObject);
    }
    if (getDebugGroup().isSet(Config.DUMP_CACHEKEY)) {
        appInfo.setDumpCacheKeyFile(getDebugGroup().getOption(Config.DUMP_CACHEKEY));
    }
    // register handler
    for (String toolName : tools.keySet()) {
        if (useTool(toolName)) {
            AppEventHandler handler = tools.get(toolName).getEventHandler();
            if (handler != null) {
                appInfo.registerEventHandler(handler);
            }
        }
    }
    if (config.hasOption(Config.PROCESSOR_MODEL)) {
        initProcessorModel(config.getOption(Config.PROCESSOR_MODEL));
    }
    // add system classes as roots
    List<String> roots = Config.splitStringList(config.getOption(Config.ROOTS));
    for (String root : roots) {
        ClassInfo rootInfo = appInfo.loadClass(root.replaceAll("/", "."));
        if (rootInfo == null) {
            System.out.flush();
            System.err.println("Error loading root class '" + root + "'.");
            System.exit(4);
        }
        appInfo.addRoot(rootInfo);
    }
    // check arguments
    String mainClassName = null;
    if (args.length > 0 && !"".equals(args[0])) {
        mainClassName = args[0];
    } else if (config.hasOption(Config.MAIN_METHOD_NAME)) {
        mainClassName = MemberID.parse(config.getOption(Config.MAIN_METHOD_NAME)).getClassName();
    } else {
        System.out.flush();
        System.err.println("You need to specify a main class or entry method.");
        if (config.getOptions().containsOption(Config.SHOW_HELP)) {
            System.err.println("Use '--help' to show a usage message.");
        }
        System.exit(2);
    }
    // try to find main entry method
    try {
        MethodInfo main = getMainMethod(mainClassName.replaceAll("/", "."));
        appInfo.setMainMethod(main);
    } catch (Config.BadConfigurationException e) {
        System.out.flush();
        System.err.println(e.getMessage());
        if (config.getOptions().containsOption(Config.SHOW_HELP)) {
            System.err.println("Use '--help' to show a usage message.");
        }
        System.exit(2);
    }
    // load other root classes
    for (int i = 1; i < args.length; i++) {
        ClassInfo clsInfo = appInfo.loadClass(args[i].replaceAll("/", "."));
        appInfo.addRoot(clsInfo);
    }
    // notify the tools about the root classes
    try {
        for (String tool : tools.keySet()) {
            if (useTool(tool)) {
                tools.get(tool).onSetupRoots(this, appInfo);
            }
        }
    } catch (Config.BadConfigurationException e) {
        System.out.flush();
        System.err.println(e.getMessage());
        if (config.getOptions().containsOption(Config.SHOW_HELP)) {
            System.err.println("Use '--help' to show a usage message.");
        }
        System.exit(2);
    }
    // load and initialize all app classes
    if (loadTransitiveHull) {
        loadClassInfos();
        // register source line loader before other event handlers
        if (config.hasOption(Config.LOAD_SOURCELINES)) {
            String filename = config.getOption(Config.LOAD_SOURCELINES);
            if (filename != null && !"".equals(filename.trim())) {
                File storage = new File(filename);
                if (storage.exists()) {
                    new SourceLineStorage(storage).loadSourceInfos();
                }
            }
        }
    }
    // let modules process their config options
    try {
        for (String tool : tools.keySet()) {
            if (useTool(tool)) {
                tools.get(tool).onSetupAppInfo(this, appInfo);
            }
        }
    } catch (Config.BadConfigurationException e) {
        System.out.flush();
        System.err.println(e.getMessage());
        if (config.getOptions().containsOption(Config.SHOW_HELP)) {
            System.err.println("Use '--help' to show a usage message.");
        }
        System.exit(2);
    }
}
Also used : ClassPath(org.apache.bcel.util.ClassPath) BadConfigurationException(com.jopdesign.common.config.Config.BadConfigurationException) Config(com.jopdesign.common.config.Config) JOPConfig(com.jopdesign.common.processormodel.JOPConfig) LogConfig(com.jopdesign.common.logger.LogConfig) SourceLineStorage(com.jopdesign.common.tools.SourceLineStorage) File(java.io.File)

Example 5 with Config

use of com.jopdesign.common.config.Config in project jop by jop-devel.

the class WCETTool method onSetupConfig.

@Override
public void onSetupConfig(AppSetup setup) throws BadConfigurationException {
    appInfo = setup.getAppInfo();
    Config config = setup.getConfig();
    projectConfig = new ProjectConfig(config);
    projectConfig.initConfig(setup.getMainMethodID());
    this.projectName = projectConfig.getProjectName();
    if (projectConfig.doGenerateReport()) {
        this.results = new Report(this, setup.getLoggerConfig());
        try {
            this.results.initVelocity();
        } catch (Exception e) {
            throw new BadConfigurationException("Error initializing Velocity: " + e, e);
        }
        this.genWCETReport = true;
    } else {
        this.genWCETReport = false;
    }
}
Also used : Report(com.jopdesign.wcet.report.Report) JOPConfig(com.jopdesign.common.processormodel.JOPConfig) IPETConfig(com.jopdesign.wcet.ipet.IPETConfig) UppAalConfig(com.jopdesign.wcet.uppaal.UppAalConfig) Config(com.jopdesign.common.config.Config) ReportConfig(com.jopdesign.wcet.report.ReportConfig) BadConfigurationException(com.jopdesign.common.config.Config.BadConfigurationException) AppInfoException(com.jopdesign.common.misc.AppInfoException) BadAnnotationException(com.jopdesign.wcet.annotations.BadAnnotationException) FileNotFoundException(java.io.FileNotFoundException) MethodNotFoundException(com.jopdesign.common.misc.MethodNotFoundException) BadConfigurationException(com.jopdesign.common.config.Config.BadConfigurationException) IOException(java.io.IOException) BadGraphException(com.jopdesign.common.misc.BadGraphException)

Aggregations

Config (com.jopdesign.common.config.Config)7 JOPConfig (com.jopdesign.common.processormodel.JOPConfig)5 IPETConfig (com.jopdesign.wcet.ipet.IPETConfig)4 BadConfigurationException (com.jopdesign.common.config.Config.BadConfigurationException)3 ReportConfig (com.jopdesign.wcet.report.ReportConfig)3 UppAalConfig (com.jopdesign.wcet.uppaal.UppAalConfig)3 File (java.io.File)3 IOException (java.io.IOException)3 OptionGroup (com.jopdesign.common.config.OptionGroup)2 LogConfig (com.jopdesign.common.logger.LogConfig)2 FileNotFoundException (java.io.FileNotFoundException)2 AppInfo (com.jopdesign.common.AppInfo)1 AppSetup (com.jopdesign.common.AppSetup)1 ClassInfo (com.jopdesign.common.ClassInfo)1 CallGraph (com.jopdesign.common.code.CallGraph)1 SuperGraph (com.jopdesign.common.code.SuperGraph)1 TypeGraph (com.jopdesign.common.graphutils.TypeGraph)1 AppInfoException (com.jopdesign.common.misc.AppInfoException)1 BadGraphException (com.jopdesign.common.misc.BadGraphException)1 MethodNotFoundException (com.jopdesign.common.misc.MethodNotFoundException)1