GP-0: Protecting from errors in broken opinions. Fixing ARM opinion.

This commit is contained in:
Dan
2021-05-03 09:33:42 -04:00
parent 36d2f6dc99
commit f33d94d421
2 changed files with 15 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ import java.util.*;
import ghidra.dbg.DebuggerObjectModel; import ghidra.dbg.DebuggerObjectModel;
import ghidra.dbg.target.*; import ghidra.dbg.target.*;
import ghidra.util.Msg;
import ghidra.util.classfinder.ClassSearcher; import ghidra.util.classfinder.ClassSearcher;
import ghidra.util.classfinder.ExtensionPoint; import ghidra.util.classfinder.ExtensionPoint;
@@ -29,6 +30,7 @@ public interface DebuggerMappingOpinion extends ExtensionPoint {
/** /**
* Query all known opinions for recording/tracing a debug session * Query all known opinions for recording/tracing a debug session
* *
* <p>
* The returned offers are ordered highest-confidence first. * The returned offers are ordered highest-confidence first.
* *
* @param target the target to be recorded, usually a process * @param target the target to be recorded, usually a process
@@ -38,8 +40,15 @@ public interface DebuggerMappingOpinion extends ExtensionPoint {
List<DebuggerMappingOffer> result = new ArrayList<>(); List<DebuggerMappingOffer> result = new ArrayList<>();
for (DebuggerMappingOpinion opinion : ClassSearcher for (DebuggerMappingOpinion opinion : ClassSearcher
.getInstances(DebuggerMappingOpinion.class)) { .getInstances(DebuggerMappingOpinion.class)) {
synchronized (result) { try {
result.addAll(opinion.getOffers(target)); Set<DebuggerMappingOffer> offers = opinion.getOffers(target);
synchronized (result) {
result.addAll(offers);
}
}
catch (Throwable t) {
Msg.error(DebuggerMappingOpinion.class,
"Problem querying opinion " + opinion + " for recording/mapping offers");
} }
} }
result.sort(HIGHEST_CONFIDENCE_FIRST); result.sort(HIGHEST_CONFIDENCE_FIRST);

View File

@@ -45,7 +45,11 @@ public class GdbArmDebuggerMappingOpinion implements DebuggerMappingOpinion {
} }
} }
@Override
public Set<DebuggerMappingOffer> offersForEnv(TargetEnvironment env, TargetProcess process) { public Set<DebuggerMappingOffer> offersForEnv(TargetEnvironment env, TargetProcess process) {
if (env == null) {
return Set.of();
}
if (!env.getDebugger().toLowerCase().contains("gdb")) { if (!env.getDebugger().toLowerCase().contains("gdb")) {
return Set.of(); return Set.of();
} }