Skip to content

Ghidra is a software reverse engineering (SRE) framework

GT-3198: Simplifying ContextRegisterInfo representation.

Ryan Kurtz5adfe717dbb4
diff --git a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterExtent.java b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterExtent.java
index 2168fecd89..2249b70ecd 100644
--- a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterExtent.java
+++ b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterExtent.java
@@ -43,7 +43,7 @@ public class ContextRegisterExtent {
return;
}
for (ContextRegisterInfo cRegInfo : contextRegisterInfo) {
- addRegisterAndValue(cRegInfo.getContextRegister(), cRegInfo.getValueAsBigInteger());
+ addRegisterAndValue(cRegInfo.getContextRegister(), cRegInfo.getValue());
}
}
diff --git a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterFilter.java b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterFilter.java
index 67d6e7a6b1..643c0613b5 100644
--- a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterFilter.java
+++ b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterFilter.java
@@ -56,7 +56,7 @@ public class ContextRegisterFilter {
public boolean allows(List<ContextRegisterInfo> contextRegisterInfos) {
for (ContextRegisterInfo cInfo : contextRegisterInfos) {
if (contextRegisters.contains(cInfo.getContextRegister())) {
- if (!values.get(cInfo.getContextRegister()).equals(cInfo.getValueAsBigInteger())) {
+ if (!values.get(cInfo.getContextRegister()).equals(cInfo.getValue())) {
return false;
}
}
diff --git a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterInfo.java b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterInfo.java
index 3b918786e7..cfd7ded47e 100644
--- a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterInfo.java
+++ b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/info/ContextRegisterInfo.java
@@ -27,8 +27,7 @@ public class ContextRegisterInfo {
static final String XML_ELEMENT_NAME = "ContextRegisterInfo";
String contextRegister;//the context register
- String value;//the value it assumes (needed because a BigInteger will not serialize to xml)
- BigInteger valueAsBigInteger;//the value it assumes
+ BigInteger value;//the value it assumes
/**
* Default constructor (used by XMLEncoder)
@@ -60,22 +59,12 @@ public class ContextRegisterInfo {
this.contextRegister = contextRegister;
}
- /**
- * Returns the value associated with this {@link ContextRegisterInfo} object as a
- * {@link BigInteger}.
- * @return
- */
- public BigInteger getValueAsBigInteger() {
- return valueAsBigInteger;
- }
-
/**
* Sets the value associated with this {@link ContextRegisterInfo} object
- * @param valueAsBigInteger
+ * @param value
*/
- public void setValue(BigInteger valueAsBigInteger) {
- this.valueAsBigInteger = valueAsBigInteger;
- this.value = valueAsBigInteger.toString();
+ public void setValue(BigInteger value) {
+ this.value = value;
}
@@ -84,19 +73,10 @@ public class ContextRegisterInfo {
* {@link String}.
* @return
*/
- public String getValue() {
+ public BigInteger getValue() {
return value;
}
- /**
- * Sets the value associated with this {@link ContextRegisterInfo} object
- * @param value
- */
- public void setValue(String value) {
- this.value = value;
- this.valueAsBigInteger = new BigInteger(value);
- }
-
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -152,7 +132,7 @@ public class ContextRegisterInfo {
ContextRegisterInfo result = new ContextRegisterInfo();
result.setContextRegister(contextRegister);
- result.setValue(value);
+ result.setValue(value != null ? new BigInteger(value) : null);
return result;
}
@@ -167,7 +147,7 @@ public class ContextRegisterInfo {
Element e = new Element(XML_ELEMENT_NAME);
e.setAttribute("contextRegister", contextRegister);
if (value != null) {
- e.setAttribute("value", value);
+ e.setAttribute("value", value.toString());
}
return e;