mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 19:42:14 +00:00
GP-4885 - Gnu Demangler - Save the raw demangled string
This commit is contained in:
parent
058ecb5eef
commit
8f08f2730d
@ -49,8 +49,13 @@ public abstract class DemangledObject implements Demangled {
|
|||||||
Source: The original mangled string as seen in the program
|
Source: The original mangled string as seen in the program
|
||||||
Usage: Can be used to see if a program symbol has already been demangled
|
Usage: Can be used to see if a program symbol has already been demangled
|
||||||
|
|
||||||
originalDemangled -
|
rawDemangled -
|
||||||
Source: The raw demangled string returned from the demangler
|
Source: The raw demangled string returned from the demangler
|
||||||
|
Usage: for debugging
|
||||||
|
|
||||||
|
originalDemangled -
|
||||||
|
Source: The starting demangled string. This will usually be the same as the raw
|
||||||
|
demangled string. This may have simplifications applied.
|
||||||
Usage: for display
|
Usage: for display
|
||||||
|
|
||||||
demangledName -
|
demangledName -
|
||||||
@ -71,14 +76,16 @@ public abstract class DemangledObject implements Demangled {
|
|||||||
|
|
||||||
mangled
|
mangled
|
||||||
rawDemangled
|
rawDemangled
|
||||||
escapedDemangled
|
simplifiedDemangled --| These two could be combined into 'transformedDemangled'
|
||||||
|
escapedDemangled --|
|
||||||
symbolName
|
symbolName
|
||||||
|
|
||||||
*/
|
*/
|
||||||
protected MangledContext mangledContext; // the mangled context, which includes mangled string
|
protected MangledContext mangledContext; // the mangled context, which includes mangled string
|
||||||
protected final String mangled; // original mangled string
|
protected final String mangled; // original mangled string
|
||||||
protected String originalDemangled; // raw demangled string
|
protected String rawDemangled; // demangled string from the demangler without any simplifications
|
||||||
private String demangledName; // updated demangled string
|
protected String originalDemangled; // starting demangled string that may have been simplified
|
||||||
|
private String demangledName; // updated demangled string, possibly with changes made while building
|
||||||
private String name; // version of demangled name suitable for symbols
|
private String name; // version of demangled name suitable for symbols
|
||||||
|
|
||||||
protected String specialPrefix;
|
protected String specialPrefix;
|
||||||
@ -120,6 +127,7 @@ public abstract class DemangledObject implements Demangled {
|
|||||||
DemangledObject(String mangled, String originalDemangled) {
|
DemangledObject(String mangled, String originalDemangled) {
|
||||||
this.mangled = mangled;
|
this.mangled = mangled;
|
||||||
this.originalDemangled = originalDemangled;
|
this.originalDemangled = originalDemangled;
|
||||||
|
this.rawDemangled = originalDemangled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,6 +140,7 @@ public abstract class DemangledObject implements Demangled {
|
|||||||
this.mangledContext = mangledContext;
|
this.mangledContext = mangledContext;
|
||||||
this.mangled = mangledContext.getMangled();
|
this.mangled = mangledContext.getMangled();
|
||||||
this.originalDemangled = originalDemangled;
|
this.originalDemangled = originalDemangled;
|
||||||
|
this.rawDemangled = originalDemangled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -280,6 +289,24 @@ public abstract class DemangledObject implements Demangled {
|
|||||||
this.originalDemangled = originalDemangled;
|
this.originalDemangled = originalDemangled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw demangled string. This is the value returned from the demangler before any
|
||||||
|
* simplifications or transformations have been made.
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public String getRawDemangled() {
|
||||||
|
return rawDemangled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the raw demangled string. This is the value returned from the demangler before any
|
||||||
|
* simplifications or transformations have been made.
|
||||||
|
* @param s the string
|
||||||
|
*/
|
||||||
|
public void setRawDemangledString(String s) {
|
||||||
|
this.rawDemangled = s;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Demangled getNamespace() {
|
public Demangled getNamespace() {
|
||||||
return namespace;
|
return namespace;
|
||||||
|
@ -412,6 +412,7 @@ public class GnuDemanglerParser {
|
|||||||
|
|
||||||
demangled = cleanupRustLegacySymbol(demangled);
|
demangled = cleanupRustLegacySymbol(demangled);
|
||||||
|
|
||||||
|
String rawDemangled = demangled;
|
||||||
if (simplify) {
|
if (simplify) {
|
||||||
demangled = replaceStdLibraryTypes(demangled);
|
demangled = replaceStdLibraryTypes(demangled);
|
||||||
}
|
}
|
||||||
@ -421,10 +422,16 @@ public class GnuDemanglerParser {
|
|||||||
|
|
||||||
DemangledObjectBuilder builder = getSpecializedBuilder(demangled);
|
DemangledObjectBuilder builder = getSpecializedBuilder(demangled);
|
||||||
if (builder != null) {
|
if (builder != null) {
|
||||||
return builder.build();
|
DemangledObject dobj = builder.build();
|
||||||
|
// note: the raw demangled is before any simplifications
|
||||||
|
dobj.setRawDemangledString(rawDemangled);
|
||||||
|
return dobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseFunctionOrVariable(demangled);
|
DemangledObject dobj = parseFunctionOrVariable(demangled);
|
||||||
|
// note: the raw demangled is before any simplifications
|
||||||
|
dobj.setRawDemangledString(rawDemangled);
|
||||||
|
return dobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DemangledObjectBuilder getSpecializedBuilder(String demangled) {
|
private DemangledObjectBuilder getSpecializedBuilder(String demangled) {
|
||||||
|
@ -115,6 +115,10 @@ public class GnuDemanglerTest extends AbstractGenericTest {
|
|||||||
"virtual thunk to undefined __thiscall std::ostringstream::~ostringstream(void)",
|
"virtual thunk to undefined __thiscall std::ostringstream::~ostringstream(void)",
|
||||||
signature);
|
signature);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"virtual thunk to std::basic_ostringstream<char, std::char_traits<char>, pool_allocator<char> >::~basic_ostringstream()",
|
||||||
|
dobj.getRawDemangled());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now disable demangled string replacement
|
// Now disable demangled string replacement
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user