Merge remote-tracking branch

'origin/GP-5910_ryanmkurtz_IntelHexExporter--SQUASHED' into patch
(Closes #8409)
This commit is contained in:
Ryan Kurtz
2025-08-13 06:00:14 -04:00
2 changed files with 22 additions and 26 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.
@@ -184,7 +184,7 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
return "Unexpected exception validating options: " + e.getMessage();
}
};
AddressFactoryService svc = (domainObject instanceof Program) ? null : this;
AddressFactoryService svc = (domainObject instanceof Program) ? this : null;
OptionsDialog optionsDialog = new OptionsDialog(options, validator, svc);
optionsDialog
.setHelpLocation(new HelpLocation("ExporterPlugin", getAnchorForSelectedFormat()));

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.
@@ -150,15 +150,10 @@ public class IntelHexExporter extends Exporter {
log.clear();
if (!(domainObj instanceof Program)) {
if (!(domainObj instanceof Program program)) {
log.appendMsg("Unsupported type: " + domainObj.getClass().getName());
return false;
}
Program program = (Program) domainObj;
if (program.getMaxAddress().getSize() > 32) {
log.appendMsg("Cannot be used for programs larger than 32 bits");
return false;
}
if (addressSpaceOption == null || recordSizeOption == null) {
getOptions(() -> program);
@@ -168,12 +163,23 @@ public class IntelHexExporter extends Exporter {
Memory memory = program.getMemory();
if (addrSet == null) {
addrSet = memory;
AddressSet set = new AddressSet(addrSet != null ? addrSet : memory);
for (MemoryBlock block : memory.getBlocks()) {
if (!block.isInitialized() ||
block.getStart().getAddressSpace() != addressSpaceOption.getValue()) {
set.delete(new AddressRangeImpl(block.getStart(), block.getEnd()));
}
}
Address maxAddr = set.getMaxAddress();
if (maxAddr != null && maxAddr.getSize() > 32) {
log.appendMsg("Cannot be used for address spaces larger than 32 bits");
return false;
}
try {
List<IntelHexRecord> records = dumpMemory(program, memory, addrSet, monitor);
List<IntelHexRecord> records = dumpMemory(program, memory, set, monitor);
for (IntelHexRecord record : records) {
writer.println(record.format());
}
@@ -198,17 +204,7 @@ public class IntelHexExporter extends Exporter {
IntelHexRecordWriter writer = new IntelHexRecordWriter(size, dropBytes);
AddressSet set = new AddressSet(addrSetView);
MemoryBlock[] blocks = memory.getBlocks();
for (MemoryBlock block : blocks) {
if (!block.isInitialized() ||
block.getStart().getAddressSpace() != addressSpaceOption.getValue()) {
set.delete(new AddressRangeImpl(block.getStart(), block.getEnd()));
}
}
AddressIterator addresses = set.getAddresses(true);
AddressIterator addresses = addrSetView.getAddresses(true);
while (addresses.hasNext()) {
Address address = addresses.next();
byte b = memory.getByte(address);
@@ -220,7 +216,7 @@ public class IntelHexExporter extends Exporter {
program.getSymbolTable().getExternalEntryPointIterator();
while (entryPoint == null && entryPointIterator.hasNext()) {
Address address = entryPointIterator.next();
if (set.contains(address)) {
if (addrSetView.contains(address)) {
entryPoint = address;
}
}