diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/AddressInput.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/AddressInput.java index f0b3014195..0228fc05d0 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/AddressInput.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/AddressInput.java @@ -197,6 +197,14 @@ public class AddressInput extends JPanel implements FocusableEditor { } } + /** + * Sets the selected AddressSpace to the given space. + * @param addressSpace the address space to set selected + */ + public void setAddressSpace(AddressSpace addressSpace) { + addressSpaceField.setAddressSpace(addressSpace); + } + /** * Returns the address in the field or null if the address can't * be parsed. @@ -577,4 +585,5 @@ public class AddressInput extends JPanel implements FocusableEditor { return model; } } + } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/symboltree/AbstractSymbolTreePluginExternalsTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/symboltree/AbstractSymbolTreePluginExternalsTest.java index da92c266bb..8682ca2895 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/symboltree/AbstractSymbolTreePluginExternalsTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/symboltree/AbstractSymbolTreePluginExternalsTest.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. @@ -435,6 +435,9 @@ public abstract class AbstractSymbolTreePluginExternalsTest createDialog.getComponent().getRootPane(), EditExternalLocationPanel.class); AddressInput extAddressInputWidget = (AddressInput) getInstanceField("extAddressInputWidget", extLocPanel); + extAddressInputWidget.setAddressSpace(addressSpace); + extAddressInputWidget.setText(address); + if (extAddressInputWidget.containsAddressSpaces()) { JComboBox addressSpaceWidget = (JComboBox) getInstanceField("combo", extAddressInputWidget); diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/AddressEvaluator.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/AddressEvaluator.java index ae03a5a009..d85879999e 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/AddressEvaluator.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/AddressEvaluator.java @@ -71,7 +71,7 @@ public class AddressEvaluator extends ExpressionEvaluator { public static Address evaluate(Program p, Address baseAddr, String inputExpression) { AddressEvaluator evaluator = new AddressEvaluator(p, true); try { - return evaluator.parseAsAddress(inputExpression); + return evaluator.parseAsRelativeAddress(inputExpression, baseAddr); } catch (ExpressionException e) { return null;