Merge remote-tracking branch 'origin/GP-4742_emteere_PSPECImprovements--SQUASHED'

This commit is contained in:
ghidra1 2024-07-29 18:05:41 -04:00
commit 47b08753e5
8 changed files with 319 additions and 81 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -756,14 +756,28 @@ public class SleighLanguage implements Language {
}
else if (elName.equals("default_symbols")) {
XmlElement subel = parser.start();
Address previousAddr = null;
int previousSize = 1;
while (parser.peek().getName().equals("symbol")) {
XmlElement symbol = parser.start();
String labelName = symbol.getAttribute("name");
String addressString = symbol.getAttribute("address");
String typeString = symbol.getAttribute("type");
String comment = symbol.getAttribute("description");
ProcessorSymbolType type = ProcessorSymbolType.getType(typeString);
boolean isEntry = SpecXmlUtils.decodeBoolean(symbol.getAttribute("entry"));
Address startAddress = addressFactory.getAddress(addressString);
Address startAddress = null;
if (addressString.equalsIgnoreCase("next")) {
if (previousAddr == null) {
Msg.error(this, "use of addr=\"next\" tag with no previous address for " +
labelName + " : " + description.getSpecFile());
} else {
startAddress = previousAddr.add(previousSize);
}
}
else {
startAddress = addressFactory.getAddress(addressString);
}
int rangeSize = SpecXmlUtils.decodeInt(symbol.getAttribute("size"));
Boolean isVolatile =
SpecXmlUtils.decodeNullableBoolean(symbol.getAttribute("volatile"));
@ -774,7 +788,7 @@ public class SleighLanguage implements Language {
else {
AddressLabelInfo info;
try {
info = new AddressLabelInfo(startAddress, rangeSize, labelName, false,
info = new AddressLabelInfo(startAddress, rangeSize, labelName, comment, false,
isEntry, type, isVolatile);
}
catch (AddressOverflowException e) {
@ -801,6 +815,8 @@ public class SleighLanguage implements Language {
}
// skip the end tag
parser.end(symbol);
previousAddr = startAddress;
previousSize = rangeSize;
}
parser.end(subel);
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -29,6 +29,7 @@ public class AddressLabelInfo implements Comparable<AddressLabelInfo> {
private Address addr;
private Address endAddr;
private String label;
private String description;
private boolean isPrimary;
private boolean isEntry;
private ProcessorSymbolType processorSymbolType;
@ -41,12 +42,13 @@ public class AddressLabelInfo implements Comparable<AddressLabelInfo> {
* @param addr Address object that describes the memory address
* @param sizeInBytes Integer describing the Size in bytes that the label applies to.
* @param label String label or alias for the Address
* @param description Label description
* @param isPrimary boolean describes if this object is the primary label for the Address 'addr'
* @param isEntry boolean describes if this object is an entry label for the Address 'addr'
* @param type ProcessorSymbolType the type of symbol
* @param isVolatile Boolean describes if the memory at this address is volatile
*/
public AddressLabelInfo(Address addr, Integer sizeInBytes, String label, boolean isPrimary,
public AddressLabelInfo(Address addr, Integer sizeInBytes, String label, String description, boolean isPrimary,
boolean isEntry, ProcessorSymbolType type, Boolean isVolatile) throws AddressOverflowException {
this.addr = addr;
if ( sizeInBytes == null || sizeInBytes <= 0 ) {
@ -57,6 +59,7 @@ public class AddressLabelInfo implements Comparable<AddressLabelInfo> {
}
this.endAddr = this.addr.addNoWrap(this.sizeInBytes-1);
this.label = label;
this.description = description;
this.isPrimary = isPrimary;
this.isEntry = isEntry;
this.processorSymbolType = type;
@ -64,28 +67,35 @@ public class AddressLabelInfo implements Comparable<AddressLabelInfo> {
}
/**
* Returns the object's address.
* @return object's address.
*/
public final Address getAddress() {
return addr;
}
/**
* Returns the object's end address.
* @return the object's end address.
*/
public final Address getEndAddress() {
return endAddr;
}
/**
* Returns the object's label or alias.
* @return the object's label or alias.
*/
public final String getLabel() {
return label;
}
/**
* @return the object's description if it has one, null otherwise
*/
public final String getDescription() {
return description;
}
/**
* Returns the object's size in bytes. Always non-zero positive value and defaults to
* @return the object's size in bytes. Always non-zero positive value and defaults to
* addressable unit size of associated address space.
*/
public final int getByteSize() {
@ -93,14 +103,14 @@ public class AddressLabelInfo implements Comparable<AddressLabelInfo> {
}
/**
* Returns whether the object is the primary label at the address.
* @return whether the object is the primary label at the address.
*/
public final boolean isPrimary() {
return isPrimary;
}
/**
* Returns whether the object is volatile.
* @return whether the object is volatile.
* Boolean.False when the address is explicitly not volatile.
* Boolean.True when the address is volatile.
* NULL when the volatility is not defined at this address.
@ -164,6 +174,9 @@ public class AddressLabelInfo implements Comparable<AddressLabelInfo> {
buf.append("isEntry = " + isEntry);
buf.append(", ");
buf.append("type = " + processorSymbolType);
if (description != null) {
buf.append("description = " + description);
}
return buf.toString();
}
}