Merge branch 'GP-272-dragonmacher-demangler-failures' into patch

This commit is contained in:
dragonmacher 2020-11-13 16:26:31 -05:00
commit dad3d92b72
9 changed files with 720 additions and 173 deletions

View file

@ -32,8 +32,6 @@ import ghidra.program.model.symbol.Namespace;
*/
public class SymbolPathParser {
private static String ANONYMOUS_NAMESPACE = "(anonymous_namespace)";
/**
* Parses a String pathname into its constituent namespace and name components.
* The list does not contain the global namespace, which is implied, but then
@ -43,12 +41,26 @@ public class SymbolPathParser {
* @return {@literal List<String>} containing the sequence of namespaces and trailing name.
*/
public static List<String> parse(String name) {
return parse(name, true);
}
/**
* Parses a String pathname into its constituent namespace and name components.
* The list does not contain the global namespace, which is implied, but then
* has each more deeply nested namespace contained in order in the list, followed
* by the trailing name.
* @param name The input String to be parsed.
* @param ignoreLeaderParens true signals to ignore any string that starts with a '(' char.
* This is useful to work around some problem characters.
* @return {@literal List<String>} containing the sequence of namespaces and trailing name.
*/
public static List<String> parse(String name, boolean ignoreLeaderParens) {
if (StringUtils.isBlank(name)) {
throw new IllegalArgumentException(
"Symbol list must contain at least one symbol name!");
}
if (skipParsing(name)) {
if (skipParsing(name, ignoreLeaderParens)) {
List<String> list = new ArrayList<>();
list.add(name);
return list;
@ -56,17 +68,14 @@ public class SymbolPathParser {
return naiveParse(name);
}
private static boolean skipParsing(String name) {
private static boolean skipParsing(String name, boolean ignoreLeaderParens) {
// 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);
if (ignoreLeaderParens && name.startsWith("(")) {
return true;
}
return !name.contains(Namespace.DELIMITER);