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_ACTION_NAME = "ApplyModelToSelection";
private static final String APPLY_MODEL_SELECTION_MENU_TEXT = "Apply Model To Selection"; 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_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_LOCAL = "A0_ApplyLocal";
private static final String ACTION_GROUP_APPLY_OTHER = "A1_ApplyOther"; private static final String ACTION_GROUP_APPLY_OTHER = "A1_ApplyOther";
private static final String ACTION_GROUP_DEBUG = "A2_Debug";
private JTextField initialBytesField; private JTextField initialBytesField;
private JTextField preBytesField; private JTextField preBytesField;
@ -335,7 +336,7 @@ public class FunctionStartRFParamsDialog extends ReusableDialogComponentProvider
.popupWhen(c -> trainingSource != null) .popupWhen(c -> trainingSource != null)
.enabledWhen(c -> tableModel.getLastSelectedObjects().size() == 1) .enabledWhen(c -> tableModel.getLastSelectedObjects().size() == 1)
.popupMenuPath(DEBUG_MODEL_MENU_TEXT) .popupMenuPath(DEBUG_MODEL_MENU_TEXT)
.popupMenuGroup(ACTION_GROUP_APPLY_OTHER) .popupMenuGroup(ACTION_GROUP_DEBUG)
.inWindow(ActionBuilder.When.ALWAYS) .inWindow(ActionBuilder.When.ALWAYS)
.onAction(c -> { .onAction(c -> {
showTestErrors(tableModel.getLastSelectedObjects().get(0)); showTestErrors(tableModel.getLastSelectedObjects().get(0));

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -205,16 +205,16 @@ public class RandomForestFunctionFinderPlugin extends ProgramPlugin
private void createActions() { private void createActions() {
new ActionBuilder(ACTION_NAME, getName()) new ActionBuilder(ACTION_NAME, getName())
.menuPath(ToolConstants.MENU_SEARCH, MENU_PATH_ENTRY) .menuPath(ToolConstants.MENU_SEARCH, MENU_PATH_ENTRY)
.menuGroup("search for", null) .menuGroup("search for", null)
.description("Train models to search for function starts") .description("Train models to search for function starts")
.helpLocation(new HelpLocation(getName(), getName())) .helpLocation(new HelpLocation(getName(), getName()))
.withContext(NavigatableActionContext.class, true) .withContext(NavigatableActionContext.class, true)
.validContextWhen(c -> !(c instanceof RestrictedAddressSetContext)) .validWhen(c -> !(c instanceof RestrictedAddressSetContext))
.onAction(c -> { .onAction(c -> {
displayDialog(c); displayDialog(c);
}) })
.buildAndInstall(tool); .buildAndInstall(tool);
} }
private void displayDialog(NavigatableActionContext c) { private void displayDialog(NavigatableActionContext c) {

View file

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