mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-24 13:11:47 +00:00
GT-2703: changed "force" option to "drop extra bytes" in intel hex
options
This commit is contained in:
parent
3cbd8de918
commit
6fad64426a
@ -308,7 +308,7 @@
|
|||||||
address space.</LI>
|
address space.</LI>
|
||||||
<LI><B>Record Size</B> - Specifies the size (in bytes) of each record in the
|
<LI><B>Record Size</B> - Specifies the size (in bytes) of each record in the
|
||||||
output file. The default 16.</LI>
|
output file. The default 16.</LI>
|
||||||
<LI><B>Force</B> - If checked, this will ensure that <b>only</b> records matching
|
<LI><B>Drop Extra Bytes</B> - If checked, this will ensure that <b>only</b> records matching
|
||||||
the record size will be output. eg: if you set the record size to 16 but there are
|
the record size will be output. eg: if you set the record size to 16 but there are
|
||||||
18 bytes selected, you will see only one line of 16 bytes in the output; the remaining
|
18 bytes selected, you will see only one line of 16 bytes in the output; the remaining
|
||||||
2 bytes will be dropped.</LI>
|
2 bytes will be dropped.</LI>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 8.6 KiB |
@ -39,8 +39,8 @@ import ghidra.util.task.TaskMonitor;
|
|||||||
* <p>
|
* <p>
|
||||||
* The output defaults to lines of 16-bytes but this is configurable using the
|
* The output defaults to lines of 16-bytes but this is configurable using the
|
||||||
* {@link #recordSizeOption} attribute. This allows users to select any record size
|
* {@link #recordSizeOption} attribute. This allows users to select any record size
|
||||||
* up to the max of 0xFF. Users may also choose to <code>force</code> a record size for every line
|
* up to the max of 0xFF. Users may also choose to <code>Drop Extra Bytes</code>, which will
|
||||||
* of output, which will only print out lines that match the max record size; any other
|
* cause only lines that match the max record size to be printed; any other
|
||||||
* bytes will be dropped. If this option is not set, every byte will be represented in the output.
|
* bytes will be dropped. If this option is not set, every byte will be represented in the output.
|
||||||
*/
|
*/
|
||||||
public class IntelHexExporter extends Exporter {
|
public class IntelHexExporter extends Exporter {
|
||||||
@ -100,8 +100,8 @@ public class IntelHexExporter extends Exporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Option for exporting Intel Hex records that allows users to specify a record size for the
|
* Option for exporting Intel Hex records that allows users to specify a record size for the
|
||||||
* output. Users may also optionally specify a <code>force</code> option that will only output
|
* output. Users may also optionally select the <code>Drop Extra Bytes</code> option that
|
||||||
* lines that match this maximum size.
|
* will cause only those records that match the maximum size to be output to the file.
|
||||||
*
|
*
|
||||||
* @see RecordSizeComponent
|
* @see RecordSizeComponent
|
||||||
*/
|
*/
|
||||||
@ -140,8 +140,8 @@ public class IntelHexExporter extends Exporter {
|
|||||||
return Integer.class;
|
return Integer.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getForce() {
|
public boolean dropExtraBytes() {
|
||||||
return comp.getForce();
|
return comp.dropExtraBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,28 +151,28 @@ public class IntelHexExporter extends Exporter {
|
|||||||
* <ul>
|
* <ul>
|
||||||
* <li><code>input</code>: a {@link HintTextField} for entering numeric digits; these
|
* <li><code>input</code>: a {@link HintTextField} for entering numeric digits; these
|
||||||
* represent the record size for each line of output</li>
|
* represent the record size for each line of output</li>
|
||||||
* <li>forceCb: a {@link JCheckBox} for specifying the <code>force</code> setting; this
|
* <li>dropCb: a {@link JCheckBox} for specifying a setting that enforces that every line in
|
||||||
* enforces that every line in the output matches the specified record size</li>
|
* the output matches the specified record size</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* Note: If the <code>force</code> option is set, any bytes that are left over after outputting
|
* Note: If the <code>Drop Extra Bytes</code> option is set, any bytes that are left over
|
||||||
* all lines that match the record size will be dropped on the floor.
|
* after outputting all lines that match the record size will be omitted from the output.
|
||||||
*/
|
*/
|
||||||
private class RecordSizeComponent extends JPanel {
|
private class RecordSizeComponent extends JPanel {
|
||||||
|
|
||||||
private HintTextField input;
|
private HintTextField input;
|
||||||
private JCheckBox forceCb;
|
private JCheckBox dropCb;
|
||||||
|
|
||||||
public RecordSizeComponent(int recordSize) {
|
public RecordSizeComponent(int recordSize) {
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
input = new HintTextField(String.valueOf(recordSize), false, new BoundedIntegerVerifier());
|
input = new HintTextField(String.valueOf(recordSize), false, new BoundedIntegerVerifier());
|
||||||
forceCb = new JCheckBox("force");
|
dropCb = new JCheckBox("Drop Extra Bytes");
|
||||||
|
|
||||||
input.setText(String.valueOf(recordSize));
|
input.setText(String.valueOf(recordSize));
|
||||||
|
|
||||||
add(input, BorderLayout.CENTER);
|
add(input, BorderLayout.CENTER);
|
||||||
add(forceCb, BorderLayout.EAST);
|
add(dropCb, BorderLayout.EAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getValue() {
|
public int getValue() {
|
||||||
@ -184,8 +184,8 @@ public class IntelHexExporter extends Exporter {
|
|||||||
return Integer.valueOf(val);
|
return Integer.valueOf(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getForce() {
|
public boolean dropExtraBytes() {
|
||||||
return forceCb.isSelected();
|
return dropCb.isSelected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,9 +276,9 @@ public class IntelHexExporter extends Exporter {
|
|||||||
AddressSetView addrSetView, TaskMonitor monitor) throws MemoryAccessException {
|
AddressSetView addrSetView, TaskMonitor monitor) throws MemoryAccessException {
|
||||||
|
|
||||||
int size = (int) recordSizeOption.getValue();
|
int size = (int) recordSizeOption.getValue();
|
||||||
boolean forceSize = recordSizeOption.getForce();
|
boolean dropBytes = recordSizeOption.dropExtraBytes();
|
||||||
|
|
||||||
IntelHexRecordWriter writer = new IntelHexRecordWriter(size, forceSize);
|
IntelHexRecordWriter writer = new IntelHexRecordWriter(size, dropBytes);
|
||||||
|
|
||||||
AddressSet set = new AddressSet(addrSetView);
|
AddressSet set = new AddressSet(addrSetView);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import ghidra.program.model.address.*;
|
|||||||
public class IntelHexRecordWriter {
|
public class IntelHexRecordWriter {
|
||||||
|
|
||||||
private final int maxBytesPerLine;
|
private final int maxBytesPerLine;
|
||||||
private final boolean forceSize;
|
private final boolean dropExtraBytes;
|
||||||
|
|
||||||
private Address startAddress = null;
|
private Address startAddress = null;
|
||||||
private Long oldSegment = null;
|
private Long oldSegment = null;
|
||||||
@ -36,15 +36,15 @@ public class IntelHexRecordWriter {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param maxBytesPerLine the maximum number of bytes to write per line in the hex output
|
* @param maxBytesPerLine the maximum number of bytes to write per line in the hex output
|
||||||
* @param forceSize if true, only lines matching {@link #maxBytesPerLine} will be output;
|
* @param dropExtraBytes if true, only lines matching {@link #maxBytesPerLine} will be output;
|
||||||
* remaining bytes will be left out
|
* remaining bytes will be left out
|
||||||
*/
|
*/
|
||||||
public IntelHexRecordWriter(int maxBytesPerLine, boolean forceSize) {
|
public IntelHexRecordWriter(int maxBytesPerLine, boolean dropExtraBytes) {
|
||||||
if (maxBytesPerLine > IntelHexRecord.MAX_RECORD_LENGTH) {
|
if (maxBytesPerLine > IntelHexRecord.MAX_RECORD_LENGTH) {
|
||||||
throw new IllegalArgumentException("maxBytesPerLine > IntelHexRecord.MAX_RECORD_LENGTH");
|
throw new IllegalArgumentException("maxBytesPerLine > IntelHexRecord.MAX_RECORD_LENGTH");
|
||||||
}
|
}
|
||||||
this.maxBytesPerLine = maxBytesPerLine;
|
this.maxBytesPerLine = maxBytesPerLine;
|
||||||
this.forceSize = forceSize;
|
this.dropExtraBytes = dropExtraBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addByte(Address address, byte b) {
|
public void addByte(Address address, byte b) {
|
||||||
@ -129,8 +129,9 @@ public class IntelHexRecordWriter {
|
|||||||
public List<IntelHexRecord> finish(Address entryPoint) {
|
public List<IntelHexRecord> finish(Address entryPoint) {
|
||||||
|
|
||||||
// Before finalizing things, write out any remaining bytes that haven't yet been written, if
|
// Before finalizing things, write out any remaining bytes that haven't yet been written, if
|
||||||
// the user has specified to do so via the force option (false = write out everything).
|
// the user has specified to do so via the drop extra bytes option (false =
|
||||||
if (bytes.size() > 0 && !forceSize) {
|
// write out everything).
|
||||||
|
if (bytes.size() > 0 && !dropExtraBytes) {
|
||||||
emitData();
|
emitData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user