diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java index 3306cb2dbb..23f55a735e 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java @@ -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. @@ -135,28 +135,26 @@ public class AddressFieldFactory extends FieldFactory { private String getAddressString(CodeUnit cu) { Address addr = cu.getMinAddress(); AddressSpace space = addr.getAddressSpace(); - String text; + int minDigits = padZeros ? 16 : minHexDigits; + String addrText = addr.toString(false, minDigits); + if (displayUpperCase) { + addrText = addrText.toUpperCase(); + } + if (displayBlockName) { - text = addr.toString(false, padZeros ? 16 : minHexDigits); MemoryBlock block = cu.getProgram().getMemory().getBlock(addr); if (block != null) { - if (displayUpperCase) { - text = text.toUpperCase(); - } - return block.getName() + ":" + text; + return block.getName() + ":" + addrText; } } - text = addr.toString(space.showSpaceName(), padZeros ? 16 : minHexDigits); - if (displayUpperCase) { - int colonIdx = text.lastIndexOf(':'); - if (colonIdx >= 0) { - text = text.substring(0, colonIdx + 1) + text.substring(colonIdx + 1).toUpperCase(); - } - else { - text = text.toUpperCase(); - } + + String spaceText = ""; + if (space.showSpaceName()) { + // this will be the space name followed by one or two colons + spaceText = space.toString(); } - return text; + + return spaceText + addrText; } @Override @@ -195,8 +193,7 @@ public class AddressFieldFactory extends FieldFactory { } else if (loc instanceof AddressFieldLocation) { if (hasSamePath(lf, loc)) { - return new FieldLocation(index, fieldNum, 0, - ((AddressFieldLocation) loc).getCharOffset()); + return new FieldLocation(index, fieldNum, 0, loc.getCharOffset()); } } return null; diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldOptionsPropertyEditor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldOptionsPropertyEditor.java index 5b5ebe9a52..86858db870 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldOptionsPropertyEditor.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldOptionsPropertyEditor.java @@ -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. @@ -142,7 +142,7 @@ public class AddressFieldOptionsPropertyEditor extends PropertyEditorSupport } addressFieldOptionsWrappedOption = (AddressFieldOptionsWrappedOption) value; - setLocalValues(addressFieldOptionsWrappedOption); + setValuesFromOption(addressFieldOptionsWrappedOption); firePropertyChange(); } @@ -150,29 +150,30 @@ public class AddressFieldOptionsPropertyEditor extends PropertyEditorSupport return minDigitsField.getIntValue(); } - private void setLocalValues(AddressFieldOptionsWrappedOption addressPaddingOption) { - if (addressPaddingOption.showBlockName() != showBlocknameCheckbox.isSelected()) { - showBlocknameCheckbox.setSelected(addressPaddingOption.showBlockName()); + private void setValuesFromOption(AddressFieldOptionsWrappedOption option) { + if (option.showBlockName() != showBlocknameCheckbox.isSelected()) { + showBlocknameCheckbox.setSelected(option.showBlockName()); } boolean rightJust = justificationCombobox.getSelectedItem().equals("Right"); - if (addressPaddingOption.rightJustify() != rightJust) { - justificationCombobox.setSelectedIndex(addressPaddingOption.rightJustify() ? 1 : 0); + if (option.rightJustify() != rightJust) { + justificationCombobox.setSelectedIndex(option.rightJustify() ? 1 : 0); } - if (addressPaddingOption.padWithZeros() != padCheckBox.isSelected()) { - padCheckBox.setSelected(addressPaddingOption.padWithZeros()); + if (option.padWithZeros() != padCheckBox.isSelected()) { + padCheckBox.setSelected(option.padWithZeros()); } - if (!Integer.toString(addressPaddingOption.getMinimumHexDigits()).equals( - minDigitsField.getText())) { - minDigitsField.setValue(addressPaddingOption.getMinimumHexDigits()); + if (!Integer.toString(option.getMinimumHexDigits()) + .equals( + minDigitsField.getText())) { + minDigitsField.setValue(option.getMinimumHexDigits()); } boolean enabled = !padCheckBox.isSelected(); minDigitsField.setEnabled(enabled); - if (addressPaddingOption.displayUpperCase() != upperCaseCheckbox.isSelected()) { - upperCaseCheckbox.setSelected(addressPaddingOption.displayUpperCase()); + if (option.displayUpperCase() != upperCaseCheckbox.isSelected()) { + upperCaseCheckbox.setSelected(option.displayUpperCase()); } } - private AddressFieldOptionsWrappedOption cloneAddressPadValues() { + private AddressFieldOptionsWrappedOption createOptionFromValues() { AddressFieldOptionsWrappedOption newOption = new AddressFieldOptionsWrappedOption(); newOption.setPadWithZeros(padCheckBox.isSelected()); newOption.setMinimumHexDigits(getMinNumberOfDigits()); @@ -194,7 +195,7 @@ public class AddressFieldOptionsPropertyEditor extends PropertyEditorSupport @Override public Object getValue() { - return cloneAddressPadValues(); + return createOptionFromValues(); } @Override diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldOptionsWrappedOption.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldOptionsWrappedOption.java index e7c48e2587..478cedbd6f 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldOptionsWrappedOption.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldOptionsWrappedOption.java @@ -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. diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/OverlayAddressSpace.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/OverlayAddressSpace.java index b75ec0721d..c631054478 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/OverlayAddressSpace.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/OverlayAddressSpace.java @@ -148,7 +148,7 @@ public abstract class OverlayAddressSpace extends AbstractAddressSpace { } /** - * If the given address is outside the overlay block, then the address is tranlated to an + * If the given address is outside the overlay block, then the address is translated to an * address in the base space with the same offset, otherwise (if the address exists in the * overlay block), it is returned * @@ -161,7 +161,7 @@ public abstract class OverlayAddressSpace extends AbstractAddressSpace { } /** - * Tranlated an overlay-space address (addr, which may exceed the bounds of the overlay space) + * Translated an overlay-space address (addr, which may exceed the bounds of the overlay space) * to an address in the base space with the same offset. If forceTranslation is false and addr * is contained within the overlay-space the original addr is returned. * @@ -221,8 +221,8 @@ public abstract class OverlayAddressSpace extends AbstractAddressSpace { } /** - * Compare this overlay to the spacified overlay. - * @param overlay other overlay to be checked for eqauality + * Compare this overlay to the specified overlay. + * @param overlay other overlay to be checked for equality * @return see {@link Comparable#compareTo(Object)} */ int compareOverlay(OverlayAddressSpace overlay) { diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/SegmentedAddress.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/SegmentedAddress.java index 4b939baa17..40b6482f98 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/SegmentedAddress.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/address/SegmentedAddress.java @@ -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. @@ -15,7 +15,6 @@ */ package ghidra.program.model.address; - /** * Address class for dealing with (intel) segmented addresses. The class itself is agnostic * about the mapping from segmented encoding to flat address offset, it uses the @@ -88,7 +87,7 @@ public class SegmentedAddress extends GenericAddress { /** * Returns a new address that is equivalent to this address using * the given segment number. - * @param seg the seqment value to normalize to. + * @param seg the segment value to normalize to. * @return the new address */ public SegmentedAddress normalize(int seg) { @@ -135,17 +134,11 @@ public class SegmentedAddress extends GenericAddress { return zeros.substring(0, 4 - str.length()) + str; } - /** - * @see ghidra.program.model.address.Address#toString(String) - */ @Override public String toString(String prefix) { return prefix + getString(segment) + SEPARATOR_CHAR + getString(getSegmentOffset()); } - /** - * @see ghidra.program.model.address.Address#getPhysicalAddress() - */ @Override public Address getPhysicalAddress() { return this; // A segmented address is already a physical address. @@ -155,7 +148,7 @@ public class SegmentedAddress extends GenericAddress { public String toString(boolean showAddressSpace, int minNumDigits) { String addr = getString(segment) + SEPARATOR_CHAR + getString(getSegmentOffset()); if (showAddressSpace) { - addr = addrSpace.getName() + SEPARATOR_CHAR + addr; + addr = addrSpace + addr; } return addr; } diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/MemoryBlock.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/MemoryBlock.java index fe898e6feb..3c100acd63 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/MemoryBlock.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/MemoryBlock.java @@ -33,7 +33,7 @@ public interface MemoryBlock extends Serializable, Comparable { * A special purpose EXTERNAL block may be created by certain program loaders * (e.g., Elf) to act as a stand-in for unknown external symbol locations when * relocation support is required using a valid memory address. While the - * EXTERNAL block is created out of neccessity for relocation processing it + * EXTERNAL block is created out of necessity for relocation processing it * introduces a number of limitations when used to carry data symbols * where pointer math and offset-references may occur. *

@@ -65,6 +65,7 @@ public interface MemoryBlock extends Serializable, Comparable { /** * Get memory data in the form of an InputStream. Null is returned for thos memory blocks which * have no data. + * @return the input stream */ public InputStream getData(); @@ -72,6 +73,7 @@ public interface MemoryBlock extends Serializable, Comparable { * Return whether addr is contained in this block. * * @param addr address + * @return true if contained */ public boolean contains(Address addr); @@ -303,8 +305,8 @@ public interface MemoryBlock extends Serializable, Comparable { public int putBytes(Address addr, byte[] b) throws MemoryAccessException; /** - * Tries to put len bytes from the specified byte array to this block. All the bytes may not be - * written if the requested length is beyond the end of the block. + * Tries to put {@code len} bytes from the specified byte array to this block. All the bytes may + * not be written if the requested length is beyond the end of the block. * * @param addr the address of where to put the bytes. * @param b the byte array containing the bytes to write. @@ -328,7 +330,7 @@ public interface MemoryBlock extends Serializable, Comparable { /** * Return whether this block has been initialized. *

- * WARNING: A mapped memory block may have a mix of intialized, uninitialized, and undefined + * WARNING: A mapped memory block may have a mix of initialized, uninitialized, and undefined * regions. The value returned by this method for a mapped memory block is always false * even if some regions are initialized. * @return true if block is fully initialized and not a memory-mapped-block, else false @@ -347,10 +349,10 @@ public interface MemoryBlock extends Serializable, Comparable { * (see {@link MemoryBlock#EXTERNAL_BLOCK_NAME}). Checks for individual addresses may be done * using {@link Memory#isExternalBlockAddress(Address)}. *

- * Note that EXTERNAL blocks always resides within a memory space and never within the artifial - * {@link AddressSpace#EXTERNAL_SPACE} which is not a memory space. This can be a source of confusion. - * An EXTERNAL memory block exists to facilitate relocation processing for some external - * symbols which require a real memory address. + * Note that EXTERNAL blocks always resides within a memory space and never within the + * artificial {@link AddressSpace#EXTERNAL_SPACE} which is not a memory space. This can be a + * source of confusion. An EXTERNAL memory block exists to facilitate relocation processing for + * some external symbols which require a real memory address. * * @return true if this is a reserved EXTERNAL memory block */