GP-571: dbgeng schema implementation

This commit is contained in:
d-millar 2021-01-07 19:16:39 +00:00 committed by Dan
parent eb66a90f6c
commit c81a17405d
49 changed files with 397 additions and 80 deletions

View file

@ -24,7 +24,6 @@ import ghidra.dbg.agent.DefaultTargetObject;
import ghidra.dbg.target.TargetEnvironment;
import ghidra.dbg.target.TargetObject;
import ghidra.dbg.target.schema.*;
import ghidra.util.Msg;
@TargetObjectSchemaInfo(name = "Environment", elements = {
@TargetElementType(type = Void.class)
@ -36,6 +35,10 @@ public class GdbModelTargetEnvironment
implements TargetEnvironment<GdbModelTargetEnvironment> {
public static final String NAME = "Environment";
public static final String VISIBLE_ARCH_ATTRIBUTE_NAME = "arch";
public static final String VISIBLE_OS_ATTRIBUTE_NAME = "os";
public static final String VISIBLE_ENDIAN_ATTRIBUTE_NAME = "endian";
protected final GdbModelImpl impl;
protected String arch = "(unknown)";
@ -96,7 +99,7 @@ public class GdbModelTargetEnvironment
// But, that may also be (perhaps more) version dependent
this.arch = arch;
}).exceptionally(e -> {
Msg.error(this, "Could not get target architecture", e);
model.reportError(this, "Could not get target architecture", e);
return null;
});
}
@ -130,7 +133,7 @@ public class GdbModelTargetEnvironment
// Would need to ignore "auto", "default", and "none"?
this.os = os;
}).exceptionally(e -> {
Msg.error(this, "Could not get target os", e);
model.reportError(this, "Could not get target os", e);
return null;
});
}
@ -148,7 +151,7 @@ public class GdbModelTargetEnvironment
endian = "(unknown)";
}
}).exceptionally(e -> {
Msg.error(this, "Could not get target endian", e);
model.reportError(this, "Could not get target endian", e);
return null;
});
}
@ -170,21 +173,18 @@ public class GdbModelTargetEnvironment
});
}
@TargetAttributeType(name = ARCH_ATTRIBUTE_NAME, hidden = true)
@Deprecated(forRemoval = true)
public String getInvisibleArch() {
@TargetAttributeType(name = VISIBLE_ARCH_ATTRIBUTE_NAME)
public String getVisibleArch() {
return arch;
}
@TargetAttributeType(name = OS_ATTRIBUTE_NAME, hidden = true)
@Deprecated(forRemoval = true)
public String getInvisibleOs() {
@TargetAttributeType(name = VISIBLE_OS_ATTRIBUTE_NAME)
public String getVisibleOs() {
return os;
}
@TargetAttributeType(name = ENDIAN_ATTRIBUTE_NAME, hidden = true)
@Deprecated(forRemoval = true)
public String getInvisibleEndian() {
@TargetAttributeType(name = VISIBLE_ENDIAN_ATTRIBUTE_NAME)
public String getVisibleEndian() {
return endian;
}

View file

@ -37,6 +37,9 @@ import ghidra.util.Msg;
public class GdbModelTargetModule
extends DefaultTargetObject<TargetObject, GdbModelTargetModuleContainer>
implements TargetModule<GdbModelTargetModule> {
public static final String VISIBLE_RANGE_ATTRIBUTE_NAME = "range";
protected static String indexModule(GdbModule module) {
return module.getName();
}
@ -124,9 +127,10 @@ public class GdbModelTargetModule
return range;
}
@Deprecated(forRemoval = true)
@TargetAttributeType(name = RANGE_ATTRIBUTE_NAME)
public AddressRange getInvisibleRange() {
// TODO: Consider a way to override the "hidden" field of an attribute
// Otherwise, this information is duplicated in memory and on the wire
@TargetAttributeType(name = VISIBLE_RANGE_ATTRIBUTE_NAME)
public AddressRange getVisibleRange() {
return range;
}
}

View file

@ -34,6 +34,9 @@ import ghidra.program.model.address.*;
public class GdbModelTargetSection
extends DefaultTargetObject<TargetObject, GdbModelTargetSectionContainer>
implements TargetSection<GdbModelTargetSection> {
public static final String VISIBLE_RANGE_ATTRIBUTE_NAME = "range";
protected static String indexSection(GdbModuleSection section) {
return section.getName();
}
@ -85,9 +88,8 @@ public class GdbModelTargetSection
return range;
}
@Deprecated(forRemoval = true)
@TargetAttributeType(name = RANGE_ATTRIBUTE_NAME)
public AddressRange getInvisibleRange() {
@TargetAttributeType(name = VISIBLE_RANGE_ATTRIBUTE_NAME)
public AddressRange getVisibleRange() {
return range;
}

View file

@ -230,7 +230,7 @@ public class GdbModelTargetThread
protected CompletableFuture<?> updateStack() {
Msg.debug(this, "Updating stack for " + this);
return stack.update().thenCompose(__ -> updateInfo()).exceptionally(ex -> {
Msg.error(this, "Could not update stack for thread " + this, ex);
model.reportError(this, "Could not update stack for thread " + this, ex);
return null;
});
}