mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-25 05:32:14 +00:00
GP-0 GNU Demangler process startup improvement
This commit is contained in:
parent
b54a7e85b0
commit
db8da86456
@ -90,7 +90,7 @@ public class DemanglerCmd extends BackgroundCommand<Program> {
|
||||
// tell a mangled from a non-mangled symbol.
|
||||
// Msg.debug(this, "Unable to demangle name: " + mangled);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception e) { e.printStackTrace();
|
||||
// Demangler IndexOutOfBoundsException that we're not sure how to fix
|
||||
setStatusMsg("Unable to demangle symbol: " + mangled + " at " + addr + ". Message: " +
|
||||
e.getMessage());
|
||||
|
@ -18,6 +18,8 @@ package ghidra.app.util.demangler.gnu;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.app.util.demangler.*;
|
||||
import ghidra.app.util.opinion.ElfLoader;
|
||||
@ -106,8 +108,12 @@ public class GnuDemangler implements Demangler {
|
||||
try {
|
||||
|
||||
GnuDemanglerNativeProcess process = getNativeProcess(options);
|
||||
String demangled = process.demangle(mangled).trim();
|
||||
if (mangled.equals(demangled) || demangled.length() == 0) {
|
||||
String demangled = process.demangle(mangled);
|
||||
if (demangled == null) {
|
||||
throw new DemangledException(false);
|
||||
}
|
||||
demangled = demangled.trim();
|
||||
if (demangled.length() == 0 || mangled.equals(demangled)) {
|
||||
throw new DemangledException(true);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ package ghidra.app.util.demangler.gnu;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@ -166,35 +165,30 @@ public class GnuDemanglerNativeProcess {
|
||||
|
||||
String[] command = buildCommand();
|
||||
IOException exc = null;
|
||||
String err = "";
|
||||
isDisposed = true;
|
||||
try {
|
||||
process = Runtime.getRuntime().exec(command);
|
||||
// Give process time to load and report possible error
|
||||
process.waitFor(200, TimeUnit.MILLISECONDS);
|
||||
InputStream in = process.getInputStream();
|
||||
OutputStream out = process.getOutputStream();
|
||||
reader = new BufferedReader(new InputStreamReader(in));
|
||||
writer = new PrintWriter(out);
|
||||
isDisposed = !process.isAlive();
|
||||
if (isDisposed) {
|
||||
err = new String(process.getErrorStream().readAllBytes());
|
||||
process.destroy();
|
||||
process = null;
|
||||
}
|
||||
|
||||
checkForError(command);
|
||||
|
||||
isDisposed = false;
|
||||
}
|
||||
catch (IOException e) {
|
||||
exc = e;
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
finally {
|
||||
if (isDisposed) {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
if (!getAndSetErrorDisplayed()) {
|
||||
String errorDetail = err;
|
||||
String errorDetail = "";
|
||||
if (exc != null) {
|
||||
errorDetail = exc.getMessage() + "\n" + errorDetail;
|
||||
errorDetail = exc.getMessage();
|
||||
}
|
||||
errorDetail = "GNU Demangler executable may not be compatible with your system and may need to be rebuilt.\n" +
|
||||
"(see InstallationGuide.html, 'Building Native Components').\n\n" +
|
||||
@ -207,8 +201,6 @@ public class GnuDemanglerNativeProcess {
|
||||
throw exc;
|
||||
}
|
||||
}
|
||||
|
||||
checkForError(command);
|
||||
|
||||
String key = getKey(applicationName, options);
|
||||
processesByName.put(key, this);
|
||||
|
Loading…
Reference in New Issue
Block a user