use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem in project memory-map-plugin by Praqma.
the class GccMemoryMapParser method getSections.
/*
* SECTIONS {
* ---
* secname start BLOCK(align) (NOLOAD) : AT ( ldadr )
{ contents } >region =fill
...
}
*
*/
public List<MemoryMapConfigMemoryItem> getSections(CharSequence m) {
List<MemoryMapConfigMemoryItem> items = new ArrayList<>();
Pattern section = Pattern.compile("SECTIONS\\s?\\r?\\n?\\{([\\s\\S]*)\\n\\}", Pattern.MULTILINE);
Matcher sectionMatched = section.matcher(m);
String sectionString = null;
while (sectionMatched.find()) {
sectionString = sectionMatched.group(1);
}
// Find the good stuff (SECTION): *SECTIONS\n\{(.*)\n\}
Matcher fm = MEM_SECTIONS.matcher(sectionString);
while (fm.find()) {
MemoryMapConfigMemoryItem it = new MemoryMapConfigMemoryItem(fm.group(1), "0");
items.add(it);
}
return items;
}
use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem 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;
}
use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem in project memory-map-plugin by Praqma.
the class TexasInstrumentsMemoryMapParser method parseMapFile.
@Override
public MemoryMapConfigMemory parseMapFile(File f, MemoryMapConfigMemory config) throws IOException {
CharSequence sequence = createCharSequenceFromFile(f);
for (MemoryMapConfigMemoryItem item : config) {
Matcher matcher = MemoryMapMapParserDelegate.getPatternForMemorySection(item.getName()).matcher(sequence);
boolean found = false;
while (matcher.find()) {
item.setUsed(matcher.group(8));
item.setUnused(matcher.group(10));
found = true;
}
if (!found) {
logger.logp(Level.WARNING, "parseMapFile", AbstractMemoryMapParser.class.getName(), String.format("parseMapFile(File f, MemoryMapConfigMemory configuration) non existing item: %s", item));
throw new MemoryMapMemorySelectionError(String.format("Linker command element %s not found in .map file", item));
}
}
return config;
}
use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem 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;
}
use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem 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");
});
}
Aggregations