GP-619: dbgeng reports full image path, when possible.

This commit is contained in:
d-millar 2021-01-21 13:55:57 -05:00 committed by Dan
parent 01bd8b9ef0
commit 86caedef05
8 changed files with 59 additions and 12 deletions

View file

@ -26,6 +26,8 @@ public interface DbgModule {
String getImageName();
String getModuleName();
Long getKnownBase();
Integer getSize();

View file

@ -72,6 +72,11 @@ public class DbgModuleImpl implements DbgModule {
return info == null ? getName() : info.imageName;
}
@Override
public String getModuleName() {
return info == null ? getName() : info.moduleName;
}
@Override
public Long getKnownBase() {
return info == null ? 0L : info.baseOffset;

View file

@ -43,6 +43,11 @@ public interface DbgModelTargetModule extends //
: nameAttr.getCachedAttribute(VALUE_ATTRIBUTE_NAME).toString();
String sizestr =
size == null ? "1" : size.getCachedAttribute(VALUE_ATTRIBUTE_NAME).toString();
String shortnamestr = namestr;
int sep = shortnamestr.lastIndexOf('\\');
if (sep > 0 && sep < shortnamestr.length()) {
shortnamestr = shortnamestr.substring(sep + 1);
}
Long base = Long.parseUnsignedLong(basestr, 16);
Integer sz = Integer.parseInt(sizestr, 16);
Address min = space.getAddress(base);
@ -52,8 +57,9 @@ public interface DbgModelTargetModule extends //
String oldval = (String) getCachedAttribute(DISPLAY_ATTRIBUTE_NAME);
map.put(MODULE_NAME_ATTRIBUTE_NAME, namestr);
map.put(DISPLAY_ATTRIBUTE_NAME, namestr);
setModified(map, !namestr.equals(oldval));
map.put(SHORT_DISPLAY_ATTRIBUTE_NAME, shortnamestr);
map.put(DISPLAY_ATTRIBUTE_NAME, shortnamestr);
setModified(map, !shortnamestr.equals(oldval));
}
});
}

View file

@ -65,7 +65,8 @@ public class DbgModelTargetModuleImpl extends DbgModelTargetObjectImpl
// sections.getName(), sections, //
), Map.of( //
DISPLAY_ATTRIBUTE_NAME, getIndex(), //
MODULE_NAME_ATTRIBUTE_NAME, module.getName(), //
SHORT_DISPLAY_ATTRIBUTE_NAME, module.getName(), //
MODULE_NAME_ATTRIBUTE_NAME, module.getImageName(), //
"BaseAddress", space.getAddress(module.getKnownBase()), //
"ImageName", module.getImageName(), //
"TimeStamp", module.getTimeStamp(), //

View file

@ -29,14 +29,17 @@ import ghidra.dbg.util.PathUtils;
import ghidra.program.model.address.*;
import ghidra.util.Msg;
@TargetObjectSchemaInfo(name = "Module", elements = {
@TargetElementType(type = Void.class) }, attributes = {
@TargetAttributeType(type = Void.class) })
@TargetObjectSchemaInfo(name = "Module", elements = { //
@TargetElementType(type = Void.class) //
}, attributes = { //
@TargetAttributeType(type = Void.class) //
})
public class GdbModelTargetModule
extends DefaultTargetObject<TargetObject, GdbModelTargetModuleContainer>
implements TargetModule<GdbModelTargetModule> {
public static final String VISIBLE_RANGE_ATTRIBUTE_NAME = "range";
public static final String VISIBLE_MODULE_NAME_ATTRIBUTE_NAME = "module name";
protected static String indexModule(GdbModule module) {
return module.getName();
@ -66,11 +69,15 @@ public class GdbModelTargetModule
this.symbols = new GdbModelTargetSymbolContainer(this);
range = doGetRange(); // Likely [0,0]
changeAttributes(List.of(), List.of(sections, symbols),
Map.of(VISIBLE_RANGE_ATTRIBUTE_NAME, range, RANGE_ATTRIBUTE_NAME, range,
MODULE_NAME_ATTRIBUTE_NAME, module.getName(), UPDATE_MODE_ATTRIBUTE_NAME,
TargetUpdateMode.FIXED, DISPLAY_ATTRIBUTE_NAME, module.getName()),
"Initialized");
changeAttributes(List.of(), List.of(sections, symbols), Map.of( //
VISIBLE_RANGE_ATTRIBUTE_NAME, range, //
VISIBLE_MODULE_NAME_ATTRIBUTE_NAME, module.getName(), //
RANGE_ATTRIBUTE_NAME, range, //
MODULE_NAME_ATTRIBUTE_NAME, module.getName(), //
UPDATE_MODE_ATTRIBUTE_NAME, TargetUpdateMode.FIXED, //
SHORT_DISPLAY_ATTRIBUTE_NAME, getDisplay(), //
DISPLAY_ATTRIBUTE_NAME, getDisplay() //
), "Initialized");
}
public CompletableFuture<Void> init() {
@ -92,7 +99,12 @@ public class GdbModelTargetModule
@Override
public String getDisplay() {
return module.getName();
String shortName = module.getName();
int sep = shortName.lastIndexOf('/');
if (sep > 0 && sep < shortName.length()) {
shortName = shortName.substring(sep + 1);
}
return shortName;
}
protected AddressRange doGetRange() {
@ -124,4 +136,10 @@ public class GdbModelTargetModule
public AddressRange getVisibleRange() {
return range;
}
@TargetAttributeType(name = VISIBLE_MODULE_NAME_ATTRIBUTE_NAME)
public String getVisibleModuleName() {
return module.getName();
}
}

View file

@ -74,6 +74,7 @@ public class JdiModelTargetReferenceType extends JdiModelTargetType implements /
Address zero = impl.getAddressSpace("ram").getAddress(0L);
changeAttributes(List.of(), List.of(), Map.of( //
DISPLAY_ATTRIBUTE_NAME, reftype.name(), //
SHORT_DISPLAY_ATTRIBUTE_NAME, reftype.name(), //
RANGE_ATTRIBUTE_NAME, new AddressRangeImpl(zero, zero), //
MODULE_NAME_ATTRIBUTE_NAME, reftype.name(), //
UPDATE_MODE_ATTRIBUTE_NAME, TargetUpdateMode.FIXED //

View file

@ -73,6 +73,7 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
implements EnumeratedTableColumn<ModuleTableColumns, ModuleRow> {
BASE("Base Address", Address.class, ModuleRow::getBase),
MAX("Max Address", Address.class, ModuleRow::getMaxAddress),
SHORT_NAME("Name", String.class, ModuleRow::getShortName),
NAME("Module Name", String.class, ModuleRow::getName, ModuleRow::setName),
LIFESPAN("Lifespan", Range.class, ModuleRow::getLifespan),
LENGTH("Length", Long.class, ModuleRow::getLength);

View file

@ -39,6 +39,19 @@ public class ModuleRow {
}
}
public String getShortName() {
String name = module.getName();
int sep = name.lastIndexOf('\\');
if (sep > 0 && sep < name.length()) {
name = name.substring(sep + 1);
}
sep = name.lastIndexOf('/');
if (sep > 0 && sep < name.length()) {
name = name.substring(sep + 1);
}
return name;
}
public String getName() {
return module.getName();
}