GP-4400 minor tweaks

This commit is contained in:
James 2025-07-29 17:47:44 +00:00
parent efb837ef34
commit 168cbc7e7a
3 changed files with 27 additions and 40 deletions

View file

@ -132,10 +132,11 @@ public class FunctionStartRFParamsDialog extends ReusableDialogComponentProvider
private static final String APPLY_MODEL_SELECTION_ACTION_NAME = "ApplyModelToSelection";
private static final String APPLY_MODEL_SELECTION_MENU_TEXT = "Apply Model To Selection";
private static final String DEBUG_MODEL_ACTION_NAME = "DebugModel";
private static final String DEBUG_MODEL_MENU_TEXT = "DEBUG - Show test set errors";
private static final String DEBUG_MODEL_MENU_TEXT = "DEBUG - Show Test Set Errors";
private static final String ACTION_GROUP_APPLY_LOCAL = "A0_ApplyLocal";
private static final String ACTION_GROUP_APPLY_OTHER = "A1_ApplyOther";
private static final String ACTION_GROUP_DEBUG = "A2_Debug";
private JTextField initialBytesField;
private JTextField preBytesField;
@ -335,7 +336,7 @@ public class FunctionStartRFParamsDialog extends ReusableDialogComponentProvider
.popupWhen(c -> trainingSource != null)
.enabledWhen(c -> tableModel.getLastSelectedObjects().size() == 1)
.popupMenuPath(DEBUG_MODEL_MENU_TEXT)
.popupMenuGroup(ACTION_GROUP_APPLY_OTHER)
.popupMenuGroup(ACTION_GROUP_DEBUG)
.inWindow(ActionBuilder.When.ALWAYS)
.onAction(c -> {
showTestErrors(tableModel.getLastSelectedObjects().get(0));

View file

@ -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.
@ -205,16 +205,16 @@ public class RandomForestFunctionFinderPlugin extends ProgramPlugin
private void createActions() {
new ActionBuilder(ACTION_NAME, getName())
.menuPath(ToolConstants.MENU_SEARCH, MENU_PATH_ENTRY)
.menuGroup("search for", null)
.description("Train models to search for function starts")
.helpLocation(new HelpLocation(getName(), getName()))
.withContext(NavigatableActionContext.class, true)
.validContextWhen(c -> !(c instanceof RestrictedAddressSetContext))
.onAction(c -> {
displayDialog(c);
})
.buildAndInstall(tool);
.menuPath(ToolConstants.MENU_SEARCH, MENU_PATH_ENTRY)
.menuGroup("search for", null)
.description("Train models to search for function starts")
.helpLocation(new HelpLocation(getName(), getName()))
.withContext(NavigatableActionContext.class, true)
.validWhen(c -> !(c instanceof RestrictedAddressSetContext))
.onAction(c -> {
displayDialog(c);
})
.buildAndInstall(tool);
}
private void displayDialog(NavigatableActionContext c) {

View file

@ -167,57 +167,43 @@ public class SimilarStartsTableModel extends AddressBasedTableModel<SimilarStart
private class DisassemblyTableColumn
extends AbstractDynamicTableColumn<SimilarStartRowObject, String, Object> {
@Override
public String getColumnName() {
return "Disassembly";
}
@Override
public String getColumnDescription() {
return "Disassembly (ignoring pre-bytes)";
}
@Override
public String getValue(SimilarStartRowObject rowObject, Settings settings, Object data,
ServiceProvider services) throws IllegalArgumentException {
PseudoDisassembler disasm = new PseudoDisassembler(program);
StringBuilder sb1 = new StringBuilder();
try {
Address addr = rowObject.funcStart().subtract(randomForestRow.getNumPreBytes());
while (addr.compareTo(rowObject.funcStart()) < 0) {
PseudoInstruction instr = disasm.disassemble(addr);
if (instr.isValid()) {
sb1.append(instr.toString());
sb1.append(" ");
}
else {
sb1.append("? ");
}
addr = instr.getMaxAddress().add(1);
}
}
catch (Exception e) {
sb1 = new StringBuilder("?? ");
}
StringBuilder sb2 = new StringBuilder();
StringBuilder sb = new StringBuilder();
try {
Address addr = rowObject.funcStart();
while (addr.compareTo(
rowObject.funcStart().add(randomForestRow.getNumInitialBytes())) < 0) {
PseudoInstruction instr = disasm.disassemble(addr);
if (instr.isValid()) {
sb2.append(instr.toString());
sb2.append(" ");
sb.append(instr.toString());
sb.append(" ");
}
else {
sb2.append("? ");
sb.append("? ");
}
addr = instr.getMaxAddress().add(1);
}
}
catch (Exception e) {
sb2 = new StringBuilder("??");
sb = new StringBuilder("??");
}
return sb1.toString() + "* " + sb2.toString();
return sb.toString();
}
}