Merge remote-tracking branch

'origin/GP-7265_ryanmkurtz_script-error-output' into patch
(Closes #9551)
This commit is contained in:
Ryan Kurtz
2026-09-09 13:29:04 -04:00
2 changed files with 16 additions and 7 deletions

View File

@@ -838,11 +838,12 @@ public class GhidraSourceBundle extends GhidraBundle {
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()) {
String error = diagnostic.toString() + "\n";
writer.write(error);
ResourceFileJavaFileObject sourceFileObject =
(ResourceFileJavaFileObject) diagnostic.getSource();
ResourceFile sourceFile = sourceFileObject.getFile();
buildError(sourceFile, error); // remember all errors for this file
filesWithErrors.add(sourceFileObject);
JavaFileObject obj = diagnostic.getSource();
if (obj instanceof ResourceFileJavaFileObject sourceFileObject) {
ResourceFile sourceFile = sourceFileObject.getFile();
buildError(sourceFile, error); // remember all errors for this file
filesWithErrors.add(sourceFileObject);
}
}
for (ResourceFileJavaFileObject sourceFileObject : filesWithErrors) {
if (sourceFiles.remove(sourceFileObject)) {

View File

@@ -911,8 +911,16 @@ public class HeadlessAnalyzer {
// GhidraScriptProvider case
GhidraScriptProvider provider = GhidraScriptUtil.getProvider(currScriptFile);
PrintWriter errWriter = new PrintWriter(System.err);
currScript = provider.getScriptInstance(currScriptFile, errWriter);
StringWriter stringWriter = new StringWriter();
PrintWriter errorWriter = new PrintWriter(stringWriter);
try {
currScript = provider.getScriptInstance(currScriptFile, errorWriter);
}
catch (GhidraScriptLoadException e) {
errorWriter.flush();
Msg.error(this, stringWriter.toString());
throw e;
}
currScript.setScriptArgs(scriptArgs);
if (options.propertiesFilePaths.size() > 0) {