Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2021-10-19 07:19:14 -04:00
commit 389a0ae441
3 changed files with 49 additions and 29 deletions

View File

@ -35,6 +35,7 @@ import ghidra.util.Msg;
import ghidra.util.database.UndoableTransaction; import ghidra.util.database.UndoableTransaction;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
import utilities.util.IDHashed;
interface LogicalBreakpointInternal extends LogicalBreakpoint { interface LogicalBreakpointInternal extends LogicalBreakpoint {
public static class ProgramBreakpoint { public static class ProgramBreakpoint {
@ -248,33 +249,6 @@ interface LogicalBreakpointInternal extends LogicalBreakpoint {
} }
static class TraceBreakpointSet { static class TraceBreakpointSet {
private static class IDHashed<T> {
final T obj;
public IDHashed(T obj) {
this.obj = obj;
}
@Override
public String toString() {
return obj.toString();
}
@Override
public int hashCode() {
return System.identityHashCode(obj);
}
@Override
public boolean equals(Object o) {
if (!(o instanceof IDHashed<?>)) {
return false;
}
IDHashed<?> that = (IDHashed<?>) o;
return this.obj.equals(that.obj);
}
}
private final TraceRecorder recorder; private final TraceRecorder recorder;
private final Trace trace; private final Trace trace;
private final Address address; private final Address address;

View File

@ -22,9 +22,11 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSpace; import ghidra.program.model.address.AddressSpace;
import ghidra.trace.model.map.UnsignedUtils; import ghidra.trace.model.map.UnsignedUtils;
import ghidra.util.database.spatial.rect.EuclideanSpace2D; import ghidra.util.database.spatial.rect.EuclideanSpace2D;
import utilities.util.IDHashed;
public class TraceAddressSnapSpace implements EuclideanSpace2D<Address, Long> { public class TraceAddressSnapSpace implements EuclideanSpace2D<Address, Long> {
private static final Map<AddressSpace, TraceAddressSnapSpace> SPACES = new HashMap<>(); private static final Map<IDHashed<AddressSpace>, TraceAddressSnapSpace> SPACES =
new HashMap<>();
/** /**
* Get the trace-address-snap space for a given address space * Get the trace-address-snap space for a given address space
@ -38,7 +40,8 @@ public class TraceAddressSnapSpace implements EuclideanSpace2D<Address, Long> {
*/ */
public static TraceAddressSnapSpace forAddressSpace(AddressSpace space) { public static TraceAddressSnapSpace forAddressSpace(AddressSpace space) {
synchronized (SPACES) { synchronized (SPACES) {
return SPACES.computeIfAbsent(space, TraceAddressSnapSpace::new); return SPACES.computeIfAbsent(new IDHashed<>(space),
s -> new TraceAddressSnapSpace(space));
} }
} }

View File

@ -0,0 +1,43 @@
/* ###
* IP: GHIDRA
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package utilities.util;
public class IDHashed<T> {
public final T obj;
public IDHashed(T obj) {
this.obj = obj;
}
@Override
public String toString() {
return obj.toString();
}
@Override
public int hashCode() {
return System.identityHashCode(obj);
}
@Override
public boolean equals(Object o) {
if (!(o instanceof IDHashed<?>)) {
return false;
}
IDHashed<?> that = (IDHashed<?>) o;
return this.obj.equals(that.obj);
}
}