Merge remote-tracking branch 'origin/GP-705-dragonmacher-gnu-demangler-regex-fixes' into patch

This commit is contained in:
ghidra1 2021-02-23 12:47:45 -05:00
commit d12d1ec739
4 changed files with 26 additions and 11 deletions

View File

@ -57,19 +57,38 @@ public abstract class AbstractDemanglerAnalyzer extends AbstractAnalyzer {
public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
throws CancelledException {
try {
monitor.setIndeterminate(true);
return doAdded(program, set, monitor, log);
}
finally {
monitor.setIndeterminate(false);
}
}
private boolean doAdded(Program program, AddressSetView set, TaskMonitor monitor,
MessageLog log)
throws CancelledException {
DemanglerOptions options = getOptions();
if (!validateOptions(options, log)) {
log.appendMsg(getName(), "Invalid demangler options--cannot demangle");
return false;
}
monitor.initialize(100);
int count = 0;
String defaultMessage = monitor.getMessage();
SymbolTable symbolTable = program.getSymbolTable();
SymbolIterator it = symbolTable.getPrimarySymbolIterator(set, true);
while (it.hasNext()) {
monitor.checkCanceled();
if (++count % 100 == 0) {
monitor.setMessage(defaultMessage + " - " + count + " symbols");
}
Symbol symbol = it.next();
if (skipSymbol(symbol)) {
continue;
@ -81,12 +100,6 @@ public abstract class AbstractDemanglerAnalyzer extends AbstractAnalyzer {
if (demangled != null) {
apply(program, address, demangled, options, log, monitor);
}
Address min = set.getMinAddress();
Address max = set.getMaxAddress();
int distance = (int) (address.getOffset() - min.getOffset());
int percent = (int) ((distance / max.getOffset()) * 100);
monitor.setProgress(percent);
}
return true;

View File

@ -244,6 +244,8 @@ public class GnuDemanglerParser {
*
* Parts:
* -required text (capture group 2)
* --note: this uses '++', a possessive quantifier, to help keep the
* backtracking to a minimum
* -a space
* -'for' or 'to' (capture group 3)
* -a space
@ -262,7 +264,7 @@ public class GnuDemanglerParser {
* non-virtual thunk to
*/
private static final Pattern DESCRIPTIVE_PREFIX_PATTERN =
Pattern.compile("((.+ )+(for|to) )(.+)");
Pattern.compile("((.+ )(for|to) )(.+)");
/**
* The c 'decltype' keyword pattern
@ -307,7 +309,7 @@ public class GnuDemanglerParser {
// note: this capture group seems to fail with excessive templating
String operatorTemplates = "(<.+>){0,1}";
String operatorPrefix =
".*(.*" + OPERATOR + "(" + alternated + ")\\s*" + operatorTemplates + ".*)\\s*";
"(.*" + OPERATOR + "(" + alternated + ")\\s*" + operatorTemplates + ")\\s*";
String parameters = "(\\(.*\\))";
String trailing = "(.*)";

View File

@ -78,7 +78,7 @@ class ClassPackage extends ClassLocation {
pkg = packageName + "." + pkg;
}
monitor.setMessage("scanning package: " + pkg);
monitor.setMessage("Scanning package: " + pkg);
children.add(new ClassPackage(rootDir, pkg, monitor));
}
}

View File

@ -222,7 +222,7 @@ public final class LocalTreeNodeHandler
GTreeNode copyNode = toCopy.get(i);
monitor.setMessage(
"Processing file " + i + " of " + size + ": " + copyNode.getName());
"Processing file " + (i + 1) + " of " + size + ": " + copyNode.getName());
add(destination, copyNode, dropAction, subMonitors[i]);
monitor.setProgress(i);