Fixed gnu parser test by updating recent temp fix for rust symbols

This commit is contained in:
dragonmacher 2020-09-22 14:21:44 -04:00
parent c50d32c792
commit 1d43c4139c

View file

@ -32,6 +32,8 @@ import ghidra.program.model.symbol.Namespace;
*/ */
public class SymbolPathParser { public class SymbolPathParser {
private static String ANONYMOUS_NAMESPACE = "(anonymous_namespace)";
/** /**
* Parses a String pathname into its constituent namespace and name components. * Parses a String pathname into its constituent namespace and name components.
* The list does not contain the global namespace, which is implied, but then * The list does not contain the global namespace, which is implied, but then
@ -45,11 +47,8 @@ public class SymbolPathParser {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Symbol list must contain at least one symbol name!"); "Symbol list must contain at least one symbol name!");
} }
// if (name.indexOf(Namespace.DELIMITER) == -1) {
// following is temporary kludge due to struct (blah). TODO: figure/fix if (skipParsing(name)) {
// This particular test for starting with the open parenthesis is to work around a type
// seen in "Rust."
if (name.startsWith("(") || name.indexOf(Namespace.DELIMITER) == -1) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add(name); list.add(name);
return list; return list;
@ -57,6 +56,22 @@ public class SymbolPathParser {
return naiveParse(name); return naiveParse(name);
} }
private static boolean skipParsing(String name) {
// if (name.indexOf(Namespace.DELIMITER) == -1) {
// following is temporary kludge due to struct (blah). TODO: figure/fix
// This particular test for starting with the open parenthesis is to work around a type
// seen in "Rust."
if (name.startsWith("(")) {
// anonymous namespace is a gnu c++ construct. We do not have any way of modeling
// this yet, but still wish not to lose this information, so we do not strip it out of
// the name when parsing gnu demangled symbols.
return !name.startsWith(ANONYMOUS_NAMESPACE);
}
return !name.contains(Namespace.DELIMITER);
}
/** /**
* Naive parsing that assumes evenly matched angle brackets (templates) with no operator * Naive parsing that assumes evenly matched angle brackets (templates) with no operator
* overloading that contains these and no other rule breakers. * overloading that contains these and no other rule breakers.