mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch 'origin/GP-1-dragonmacher-function-color-fix--SQUASHED'
This commit is contained in:
commit
c7aa190b40
13 changed files with 669 additions and 290 deletions
|
@ -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.
|
||||
|
@ -86,7 +86,7 @@ public class FieldLocation implements Comparable<FieldLocation> {
|
|||
* @param index the index of the layout containing the location
|
||||
* @param fieldNum the index of the field in the layout containing the location
|
||||
* @param row the text row in the field containing the location.
|
||||
* @param col the character position the row containing the location.
|
||||
* @param col the character position in the row containing the location.
|
||||
*/
|
||||
public FieldLocation(int index, int fieldNum, int row, int col) {
|
||||
this(BigInteger.valueOf(index), fieldNum, row, col);
|
||||
|
|
|
@ -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.
|
||||
|
@ -18,6 +18,8 @@ package ghidra.util;
|
|||
import java.awt.Color;
|
||||
import java.util.Comparator;
|
||||
|
||||
import generic.theme.GColor;
|
||||
|
||||
public class ColorUtils {
|
||||
|
||||
private static final int MAX_COLOR_VALUE = 255;
|
||||
|
@ -348,6 +350,26 @@ public class ColorUtils {
|
|||
return new Color(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if both colors are not null and have the same RGB value. This is useful to
|
||||
* compare colors that may have different classes, such as {@link Color} and {@link GColor}.
|
||||
*
|
||||
* @param c1 the first color
|
||||
* @param c2 the second color
|
||||
* @return true if the colors have the same RGB value
|
||||
*/
|
||||
public static boolean hasSameRgb(Color c1, Color c2) {
|
||||
int rgb1 = 0;
|
||||
int rgb2 = 0;
|
||||
if (c1 != null) {
|
||||
rgb1 = c1.getRGB();
|
||||
}
|
||||
if (c2 != null) {
|
||||
rgb2 = c2.getRGB();
|
||||
}
|
||||
return rgb1 == rgb2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blender of colors
|
||||
*/
|
||||
|
|
|
@ -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,27 +15,38 @@
|
|||
*/
|
||||
package ghidra.program.model.listing;
|
||||
|
||||
public class LabelString {
|
||||
|
||||
public enum LabelType { CODE_LABEL, VARIABLE, EXTERNAL }
|
||||
import ghidra.program.model.symbol.Symbol;
|
||||
|
||||
public class LabelString {
|
||||
|
||||
public enum LabelType {
|
||||
CODE_LABEL, VARIABLE, EXTERNAL
|
||||
}
|
||||
|
||||
public static final LabelType CODE_LABEL = LabelType.CODE_LABEL;
|
||||
public static final LabelType VARIABLE = LabelType.VARIABLE;
|
||||
public static final LabelType EXTERNAL = LabelType.EXTERNAL;
|
||||
|
||||
private final String label;
|
||||
private final LabelType type;
|
||||
private Symbol symbol;
|
||||
|
||||
public LabelString(String label, LabelType type) {
|
||||
this.label = label;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public LabelString(String label, Symbol symbol, LabelType type) {
|
||||
this.label = label;
|
||||
this.symbol = symbol;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Symbol getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
public LabelType getLabelType() {
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -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,12 +15,12 @@
|
|||
*/
|
||||
package ghidra.program.model.listing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.listing.LabelString.LabelType;
|
||||
import ghidra.program.model.scalar.Scalar;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
@ -43,7 +43,7 @@ public class VariableOffset {
|
|||
|
||||
/**
|
||||
* Constructor for an implied variable reference.
|
||||
* @param variable function variable
|
||||
* @param var function variable
|
||||
* @param offset offset into variable
|
||||
* @param indirect if true and variable data-type is a pointer, the offset
|
||||
* is relative to underlying data-type of the pointer-type. This should generally be
|
||||
|
@ -51,8 +51,8 @@ public class VariableOffset {
|
|||
* whereas it would be false for stack-references.
|
||||
* @param dataAccess true if content of variable is being read and/or written
|
||||
*/
|
||||
public VariableOffset(Variable variable, long offset, boolean indirect, boolean dataAccess) {
|
||||
this.variable = variable;
|
||||
public VariableOffset(Variable var, long offset, boolean indirect, boolean dataAccess) {
|
||||
this.variable = Objects.requireNonNull(var, "Variable reference not bound to a variable");
|
||||
this.offset = offset;
|
||||
this.indirect = indirect;
|
||||
this.dataAccess = dataAccess;
|
||||
|
@ -65,20 +65,14 @@ public class VariableOffset {
|
|||
*/
|
||||
public VariableOffset(Reference ref, Variable var) {
|
||||
|
||||
indirect = false;
|
||||
variable = var;
|
||||
if (variable == null) {
|
||||
throw new IllegalArgumentException("Variable reference not bound to a variable");
|
||||
}
|
||||
|
||||
this.indirect = false;
|
||||
this.variable = Objects.requireNonNull(var, "Variable reference not bound to a variable");
|
||||
RefType rt = ref.getReferenceType();
|
||||
dataAccess = rt.isRead() || rt.isWrite();
|
||||
this.dataAccess = rt.isRead() || rt.isWrite();
|
||||
|
||||
if (ref instanceof StackReference && variable.isStackVariable()) {
|
||||
offset = variable.getStackOffset();
|
||||
offset = ((StackReference) ref).getStackOffset() - variable.getStackOffset();
|
||||
this.offset = ((StackReference) ref).getStackOffset() - variable.getStackOffset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,6 +88,7 @@ public class VariableOffset {
|
|||
|
||||
/**
|
||||
* Sets the original replaced sub-operand Register.
|
||||
* @param reg the register
|
||||
*/
|
||||
public void setReplacedElement(Register reg) {
|
||||
replacedElement = reg;
|
||||
|
@ -107,9 +102,6 @@ public class VariableOffset {
|
|||
return replacedElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
@ -204,7 +196,7 @@ public class VariableOffset {
|
|||
}
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(new LabelString(name.toString(), LabelString.VARIABLE));
|
||||
list.add(new LabelString(name.toString(), LabelType.VARIABLE));
|
||||
|
||||
if (absOffset != 0 || scalarAdjustment != 0) {
|
||||
long adjustedOffset = (offset < 0 ? -absOffset : absOffset) + scalarAdjustment;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue