mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch
'origin/GP-5565-dragonmacher-decompiler-rename-label-action' (Closes #7507)
This commit is contained in:
commit
c75c852001
2 changed files with 21 additions and 16 deletions
|
@ -190,7 +190,7 @@ public class AddEditDialog extends ReusableDialogComponentProvider {
|
||||||
|
|
||||||
boolean isCurrentlyEntryPoint = false;
|
boolean isCurrentlyEntryPoint = false;
|
||||||
boolean isCurrentlyPinned = false;
|
boolean isCurrentlyPinned = false;
|
||||||
CompoundCmd cmd = new CompoundCmd(symbol == null ? "Add Label" : "Edit Label");
|
CompoundCmd<Program> cmd = new CompoundCmd<>(symbol == null ? "Add Label" : "Edit Label");
|
||||||
if (symbol == null) {
|
if (symbol == null) {
|
||||||
cmd.add(new AddLabelCmd(addr, symbolName, parent, SourceType.USER_DEFINED));
|
cmd.add(new AddLabelCmd(addr, symbolName, parent, SourceType.USER_DEFINED));
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ public class AddEditDialog extends ReusableDialogComponentProvider {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = new CompoundCmd(symbol == null ? "Add Label" : "Edit Label");
|
cmd = new CompoundCmd<>(symbol == null ? "Add Label" : "Edit Label");
|
||||||
if (primaryCheckBox.isEnabled() && primaryCheckBox.isSelected()) {
|
if (primaryCheckBox.isEnabled() && primaryCheckBox.isSelected()) {
|
||||||
cmd.add(new SetLabelPrimaryCmd(addr, symbolName, parent));
|
cmd.add(new SetLabelPrimaryCmd(addr, symbolName, parent));
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,8 @@ public class AddEditDialog extends ReusableDialogComponentProvider {
|
||||||
"You have removed the label text--would you like to remove the existing label?");
|
"You have removed the label text--would you like to remove the existing label?");
|
||||||
if (choice == OptionDialog.YES_OPTION) {
|
if (choice == OptionDialog.YES_OPTION) {
|
||||||
|
|
||||||
Command cmd = new DeleteLabelCmd(addr, symbol.getName(), symbol.getParentNamespace());
|
Command<Program> cmd =
|
||||||
|
new DeleteLabelCmd(addr, symbol.getName(), symbol.getParentNamespace());
|
||||||
if (!tool.execute(cmd, program)) {
|
if (!tool.execute(cmd, program)) {
|
||||||
setStatusText(cmd.getStatusMsg());
|
setStatusText(cmd.getStatusMsg());
|
||||||
}
|
}
|
||||||
|
@ -328,18 +329,17 @@ public class AddEditDialog extends ReusableDialogComponentProvider {
|
||||||
|
|
||||||
private void initRecentChoices() {
|
private void initRecentChoices() {
|
||||||
labelNameChoices.removeAllItems();
|
labelNameChoices.removeAllItems();
|
||||||
Iterator<String> it = recentLabels.iterator();
|
for (String recentLabel : recentLabels) {
|
||||||
while (it.hasNext()) {
|
labelNameChoices.addItem(recentLabel);
|
||||||
labelNameChoices.addItem(it.next());
|
|
||||||
}
|
}
|
||||||
if (recentLabels.size() > 0) {
|
if (recentLabels.size() > 0) {
|
||||||
labelNameChoices.setSelectedIndex(-1);
|
labelNameChoices.setSelectedIndex(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method only gets the namespace associated with the current address
|
// This method only gets the namespace associated with the current address
|
||||||
// and it's tree of namespaces. It does not walk the namespace tree of
|
// and it's tree of namespaces. It does not walk the namespace tree of
|
||||||
// the symbol, which can be different than that of the address.
|
// the symbol, which can be different than that of the address.
|
||||||
private void initNamespaces() {
|
private void initNamespaces() {
|
||||||
namespaceChoices.removeAllItems();
|
namespaceChoices.removeAllItems();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import ghidra.app.decompiler.ClangToken;
|
||||||
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
|
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
|
||||||
import ghidra.app.util.AddEditDialog;
|
import ghidra.app.util.AddEditDialog;
|
||||||
import ghidra.app.util.HelpTopics;
|
import ghidra.app.util.HelpTopics;
|
||||||
import ghidra.program.model.symbol.Symbol;
|
import ghidra.program.model.symbol.*;
|
||||||
import ghidra.util.HelpLocation;
|
import ghidra.util.HelpLocation;
|
||||||
|
|
||||||
public class RenameLabelAction extends AbstractDecompilerAction {
|
public class RenameLabelAction extends AbstractDecompilerAction {
|
||||||
|
@ -47,10 +47,15 @@ public class RenameLabelAction extends AbstractDecompilerAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decompilerActionPerformed(DecompilerActionContext context) {
|
protected void decompilerActionPerformed(DecompilerActionContext context) {
|
||||||
Symbol symbol = getSymbol(context);
|
Symbol s = getSymbol(context);
|
||||||
if (symbol != null) {
|
if (s != null) {
|
||||||
AddEditDialog dialog = new AddEditDialog("", context.getTool());
|
AddEditDialog dialog = new AddEditDialog("Add/Edit Label", context.getTool());
|
||||||
dialog.editLabel(symbol, context.getProgram());
|
if (s.getSource() == SourceType.DEFAULT && s.getSymbolType() == SymbolType.LABEL) {
|
||||||
|
dialog.addLabel(s.getAddress(), context.getProgram());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dialog.editLabel(s, context.getProgram());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue