Merge remote-tracking branch

'origin/GP-3612_emteere_parsetoprogram_procarch' into patch
(Closes #5502)
This commit is contained in:
Ryan Kurtz
2023-07-10 17:22:58 -04:00
2 changed files with 25 additions and 15 deletions
@@ -41,6 +41,7 @@ import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.PluginStatus; import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.database.data.ProgramDataTypeManager; import ghidra.program.database.data.ProgramDataTypeManager;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.lang.LanguageCompilerSpecPair;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.util.*; import ghidra.util.*;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
@@ -300,16 +301,25 @@ public class CParserPlugin extends ProgramPlugin {
/* /*
* Parse into the current programs data type manager * Parse into the current programs data type manager
*
* Always uses the program's processor architecture
*/ */
protected void parse(String[] filenames, String[] includePaths, String options, protected void parse(String[] filenames, String[] includePaths, String options) {
String languageIDString, String compilerIDString) {
if (currentProgram == null) { if (currentProgram == null) {
Msg.showInfo(getClass(), parseDialog.getComponent(), "No Open Program", Msg.showInfo(getClass(), parseDialog.getComponent(), "No Open Program",
"A program must be open to \"Parse to Program\""); "A program must be open to \"Parse to Program\"");
return; return;
} }
/*
* always use the processor/compiler for the program when parsing to program
*/
LanguageCompilerSpecPair languageCompilerSpecPair = currentProgram.getLanguageCompilerSpecPair();
String procID = languageCompilerSpecPair.languageID.getIdAsString();
String compilerID = languageCompilerSpecPair.compilerSpecID.getIdAsString();
int result = OptionDialog.showOptionDialog(parseDialog.getComponent(), "Confirm", int result = OptionDialog.showOptionDialog(parseDialog.getComponent(), "Confirm",
"Parse C source to \"" + currentProgram.getDomainFile().getName() + "\"?", "Continue"); "Parse C source to \"" + currentProgram.getDomainFile().getName() + "\"?" + "\n\n" +
"Using program architecture: " + procID + " / " + compilerID, "Continue");
if (result == OptionDialog.CANCEL_OPTION) { if (result == OptionDialog.CANCEL_OPTION) {
return; return;
@@ -320,8 +330,8 @@ public class CParserPlugin extends ProgramPlugin {
.setFileNames(filenames) .setFileNames(filenames)
.setIncludePaths(includePaths) .setIncludePaths(includePaths)
.setOptions(options) .setOptions(options)
.setLanguageID(languageIDString) .setLanguageID(procID)
.setCompilerID(compilerIDString); .setCompilerID(compilerID);
tool.execute(parseTask); tool.execute(parseTask);
} }
@@ -804,22 +804,22 @@ class ParseDialog extends ReusableDialogComponentProvider {
paths = expandPaths(paths); paths = expandPaths(paths);
pathPanel.setPaths(paths); pathPanel.setPaths(paths);
if (languageIDString == null || compilerIDString == null) {
Msg.showWarn(getClass(), rootPanel, "Program Architecture not Specified",
"A Program Architecture must be specified in order to parse to a file.");
return;
}
if (parseToFile) { if (parseToFile) {
if (languageIDString == null || compilerIDString == null) {
Msg.showWarn(getClass(), rootPanel, "Program Architecture not Specified",
"A Program Architecture must be specified in order to parse to a file.");
return;
}
File file = getSaveFile(); File file = getSaveFile();
if (file != null) { if (file != null) {
plugin.parse(paths, includePaths, options, languageIDString, compilerIDString, plugin.parse(paths, includePaths, options, languageIDString, compilerIDString,
file.getAbsolutePath()); file.getAbsolutePath());
} }
return;
} }
else {
plugin.parse(paths, includePaths, options, languageIDString, compilerIDString); plugin.parse(paths, includePaths, options);
}
} }
private String[] expandPaths(String[] paths) { private String[] expandPaths(String[] paths) {