Search in sources :

Example 1 with MemoryMapConfigMemory

use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory in project memory-map-plugin by Praqma.

the class GccMemoryMapParser method parseConfigFile.

@Override
public MemoryMapConfigMemory parseConfigFile(File f) throws IOException {
    // Collect sections from both the MEMORY and the SECTIONS areas from the command file.
    // The memory are the top level components, sections belong to one of these sections
    CharSequence stripped = stripComments(createCharSequenceFromFile(f));
    MemoryMapConfigMemory memConfig = getMemory(stripped);
    memConfig.addAll(getSections(stripped));
    for (MemoryMapGraphConfiguration g : getGraphConfiguration()) {
        for (String gItem : g.itemizeGraphDataList()) {
            for (String gSplitItem : gItem.split("\\+")) {
                // We will fail if the name of the data section does not match any of the named items in the map file.
                if (!memConfig.containsSectionWithName(gSplitItem)) {
                    throw new MemoryMapMemorySelectionError(String.format("The memory section named %s not found in map file%nAvailable sections are:%n%s", gSplitItem, memConfig.getItemNames()));
                }
            }
        }
    }
    return memConfig;
}
Also used : MemoryMapGraphConfiguration(net.praqma.jenkins.memorymap.graph.MemoryMapGraphConfiguration) MemoryMapMemorySelectionError(net.praqma.jenkins.memorymap.util.MemoryMapMemorySelectionError) MemoryMapConfigMemory(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory) HexifiableString(net.praqma.jenkins.memorymap.util.HexUtils.HexifiableString)

Example 2 with MemoryMapConfigMemory

use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory in project memory-map-plugin by Praqma.

the class GccMemoryMapParser method getMemory.

/**
 * Parses the MEMORY section of the GCC file. Throws an abort exception
 * which will be shown in the Jenkins console log.
 *
 * @param seq The content of the map file
 * @return a list of the defined MEMORY in the map file
 * @throws hudson.AbortException when a illegal value of memory found
 */
public MemoryMapConfigMemory getMemory(CharSequence seq) throws AbortException {
    Pattern allMemory = Pattern.compile("^\\s*(\\S+).*?(?:ORIGIN|org|o)\\s*=\\s*([^,]*).*?(?:LENGTH|len|l)\\s*\\=\\s*([^\\s]*)", Pattern.MULTILINE);
    Matcher match = allMemory.matcher(seq);
    MemoryMapConfigMemory memory = new MemoryMapConfigMemory();
    while (match.find()) {
        try {
            String hexLength = new HexUtils.HexifiableString(match.group(3)).toValidHexString().rawString;
            MemoryMapConfigMemoryItem item = new MemoryMapConfigMemoryItem(match.group(1), match.group(2), hexLength);
            memory.add(item);
        } catch (Throwable ex) {
            logger.log(Level.SEVERE, "Unable to convert %s to a valid hex string.", ex);
            throw new AbortException(String.format("Unable to convert %s to a valid hex string.", match.group(3)));
        }
    }
    return memory;
}
Also used : Pattern(java.util.regex.Pattern) MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem) Matcher(java.util.regex.Matcher) MemoryMapConfigMemory(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory) HexifiableString(net.praqma.jenkins.memorymap.util.HexUtils.HexifiableString) HexifiableString(net.praqma.jenkins.memorymap.util.HexUtils.HexifiableString) AbortException(hudson.AbortException)

Example 3 with MemoryMapConfigMemory

use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory in project memory-map-plugin by Praqma.

the class TexasInstrumentsMemoryMapParser method parseConfigFile.

@Override
public MemoryMapConfigMemory parseConfigFile(File f) throws IOException {
    MemoryMapConfigMemory config = new MemoryMapConfigMemory();
    CharSequence sequence = createCharSequenceFromFile(f);
    for (MemoryMapGraphConfiguration graph : getGraphConfiguration()) {
        String[] split = graph.getGraphDataList().split(",");
        for (String s : split) {
            String[] multiSections = s.trim().split("\\+");
            for (String ms : multiSections) {
                Matcher m = MemoryMapConfigFileParserDelegate.getPatternForMemoryLayout(ms.replace(" ", "")).matcher(sequence);
                MemoryMapConfigMemoryItem item = null;
                while (m.find()) {
                    item = new MemoryMapConfigMemoryItem(m.group(1), m.group(3), m.group(5));
                    config.add(item);
                }
                if (item == null) {
                    logger.logp(Level.WARNING, "parseConfigFile", AbstractMemoryMapParser.class.getName(), String.format("parseConfigFile(List<MemoryMapGraphConfiguration> graphConfig, File f) non existing item: %s", s));
                    throw new MemoryMapMemorySelectionError(String.format("No match found for program memory named %s", s));
                }
            }
        }
    }
    return config;
}
Also used : MemoryMapGraphConfiguration(net.praqma.jenkins.memorymap.graph.MemoryMapGraphConfiguration) MemoryMapMemorySelectionError(net.praqma.jenkins.memorymap.util.MemoryMapMemorySelectionError) MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem) Matcher(java.util.regex.Matcher) MemoryMapConfigMemory(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory) AbstractMemoryMapParser(net.praqma.jenkins.memorymap.parser.AbstractMemoryMapParser)

Example 4 with MemoryMapConfigMemory

use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory in project memory-map-plugin by Praqma.

the class TexasInstrumentsMemoryMapParserTest method testParseMapFile.

@Test
public void testParseMapFile() throws IOException {
    TexasInstrumentsMemoryMapParser parser = new TexasInstrumentsMemoryMapParser();
    String file = TexasInstrumentsMemoryMapParserTest.class.getResource("TexasInstrumentsMapFile.txt").getFile();
    File f = new File(file);
    MemoryMapConfigMemory configMemory = new MemoryMapConfigMemory();
    configMemory.add(new MemoryMapConfigMemoryItem("RAMM0", "00000050", "000003b0", "00000195", "0000021b"));
    configMemory = parser.parseMapFile(f, configMemory);
    assertTrue(configMemory.size() > 0);
    configMemory.stream().filter(item -> item.getName().equals("RAMM0")).forEach(item -> {
        assertEquals(item.getUsed(), "00000195");
        assertEquals(item.getUnused(), "0000021b");
    });
}
Also used : MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem) TexasInstrumentsMemoryMapParser(net.praqma.jenkins.memorymap.parser.ti.TexasInstrumentsMemoryMapParser) IOException(java.io.IOException) Test(org.junit.Test) Assert(org.junit.Assert) File(java.io.File) MemoryMapConfigMemory(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory) MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem) MemoryMapConfigMemory(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory) TexasInstrumentsMemoryMapParser(net.praqma.jenkins.memorymap.parser.ti.TexasInstrumentsMemoryMapParser) File(java.io.File) Test(org.junit.Test)

Example 5 with MemoryMapConfigMemory

use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory in project memory-map-plugin by Praqma.

the class MemoryMapBuildAction method buildDataSet.

/**
 * Builds the data set. Returns the maximum value.
 *
 * @param graphData GraphData
 * @param dataSet the data set
 * @param graphDataSet the graph data set
 * @param markers markers to add (max values)
 * @return a double with the value to be drawn on graph
 */
public double buildDataSet(List<String> graphData, String dataSet, DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> graphDataSet, HashMap<String, ValueMarker> markers) {
    logger.log(Level.FINE, "Entering buildDataSet with data set {0}", dataSet);
    double max = 0d;
    for (String s : graphData) {
        if (s.contains(" ")) {
            String[] parts = s.split(" ");
            String maxLabel = constructMaxLabel(parts);
            String categoryLabel = constructCategoryLabel(parts);
            for (MemoryMapBuildAction memBuild = this; memBuild != null; memBuild = memBuild.getPreviousAction()) {
                logger.log(Level.FINE, "Building graph data set for build #{0}", memBuild.build.number);
                MemoryMapConfigMemory result = memBuild.getMemoryMapConfigs().get(dataSet);
                logger.log(Level.FINE, "Building MemoryMapConfig: {0}", result);
                if (result == null) {
                    logger.log(Level.FINEST, "Data set {0} not found", dataSet);
                    for (String key : memBuild.getMemoryMapConfigs().keySet()) {
                        logger.log(Level.FINEST, "found {0}", key);
                    }
                }
                ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(memBuild.build);
                if (result != null) {
                    List<MemoryMapConfigMemoryItem> ourItems = result.getItemByNames(parts);
                    MemoryMapConfigMemoryItem[] ourItemsArray = ourItems.toArray(new MemoryMapConfigMemoryItem[ourItems.size()]);
                    double value = extractValue(ourItemsArray);
                    boolean allBelongSameParent = MemoryMapConfigMemoryItem.allBelongSameParent(ourItemsArray);
                    if (allBelongSameParent) {
                        max = extractMaxNonZeroValue(ourItemsArray);
                    } else {
                        max = extractMaxValue(ourItemsArray);
                    }
                    graphDataSet.add(value, categoryLabel, label);
                    makeMarker(maxLabel, max, markers);
                }
            }
        } else {
            for (MemoryMapBuildAction memBuild = this; memBuild != null; memBuild = memBuild.getPreviousAction()) {
                logger.log(Level.FINE, "Building graph data set for build #{0}", memBuild.build.number);
                MemoryMapConfigMemory result = memBuild.getMemoryMapConfigs().get(dataSet);
                logger.log(Level.FINE, "Building MemoryMapConfig: {0}", result);
                if (result == null) {
                    logger.log(Level.FINEST, "Data set {0} not found", dataSet);
                    for (String key : memBuild.getMemoryMapConfigs().keySet()) {
                        logger.log(Level.FINEST, "found {0}", key);
                    }
                }
                ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(memBuild.build);
                if (result != null) {
                    for (MemoryMapConfigMemoryItem item : result) {
                        if (item.getName().equals(s)) {
                            String maxLabel = constructMaxLabel(item.getName());
                            double newMax = extractMaxNonZeroValue(item);
                            double value = extractValue(item);
                            String categoryLabel = constructCategoryLabel(item.getName());
                            graphDataSet.add(value, categoryLabel, label);
                            if (newMax >= max) {
                                max = newMax;
                            }
                            if (newMax > 0d) {
                                makeMarker(maxLabel, newMax, markers);
                            }
                        }
                    }
                }
            }
        }
    }
    return max;
}
Also used : ChartUtil(hudson.util.ChartUtil) MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem) MemoryMapConfigMemory(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory)

Aggregations

MemoryMapConfigMemory (net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory)7 MemoryMapConfigMemoryItem (net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem)4 File (java.io.File)2 IOException (java.io.IOException)2 Matcher (java.util.regex.Matcher)2 MemoryMapGraphConfiguration (net.praqma.jenkins.memorymap.graph.MemoryMapGraphConfiguration)2 HexifiableString (net.praqma.jenkins.memorymap.util.HexUtils.HexifiableString)2 MemoryMapMemorySelectionError (net.praqma.jenkins.memorymap.util.MemoryMapMemorySelectionError)2 Test (org.junit.Test)2 AbortException (hudson.AbortException)1 ChartUtil (hudson.util.ChartUtil)1 PrintStream (java.io.PrintStream)1 Pattern (java.util.regex.Pattern)1 AbstractMemoryMapParser (net.praqma.jenkins.memorymap.parser.AbstractMemoryMapParser)1 GccMemoryMapParser (net.praqma.jenkins.memorymap.parser.gcc.GccMemoryMapParser)1 TexasInstrumentsMemoryMapParser (net.praqma.jenkins.memorymap.parser.ti.TexasInstrumentsMemoryMapParser)1 MemoryMapError (net.praqma.jenkins.memorymap.util.MemoryMapError)1 Assert (org.junit.Assert)1