mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-23 04:39:55 +00:00
Merge remote-tracking branch 'origin/GP-4885-dragonmacher-gnu-demangler-keep-raw-demangled--SQUASHED'
This commit is contained in:
commit
9421ec0ab0
@ -44,41 +44,48 @@ public abstract class DemangledObject implements Demangled {
|
||||
/*
|
||||
The following names probably need to be refactored. Until then, this is how the following
|
||||
fields are used.
|
||||
|
||||
mangled -
|
||||
|
||||
mangled -
|
||||
Source: The original mangled string as seen in the program
|
||||
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
|
||||
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
|
||||
|
||||
demangledName -
|
||||
|
||||
demangledName -
|
||||
Source: The name as created by the parser which may transform or even replace the
|
||||
string returned from the demangler
|
||||
Usage: for display
|
||||
|
||||
name -
|
||||
|
||||
name -
|
||||
Source: This is derived from the 'demangledName' This is updated to be suitable
|
||||
for use as a symbol name. This may be null while building, but is
|
||||
expected to be non-null when applyTo() is called
|
||||
Usage: The name that will be applied when applyTo() is called.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future: These variables should be refactored and renamed to be clearer and more cohesive,
|
||||
something like:
|
||||
|
||||
|
||||
mangled
|
||||
rawDemangled
|
||||
escapedDemangled
|
||||
simplifiedDemangled --| These two could be combined into 'transformedDemangled'
|
||||
escapedDemangled --|
|
||||
symbolName
|
||||
|
||||
|
||||
*/
|
||||
protected MangledContext mangledContext; // the mangled context, which includes mangled string
|
||||
protected final String mangled; // original mangled string
|
||||
protected String originalDemangled; // raw demangled string
|
||||
private String demangledName; // updated demangled string
|
||||
protected String rawDemangled; // demangled string from the demangler without any simplifications
|
||||
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
|
||||
|
||||
protected String specialPrefix;
|
||||
@ -120,6 +127,7 @@ public abstract class DemangledObject implements Demangled {
|
||||
DemangledObject(String mangled, String originalDemangled) {
|
||||
this.mangled = mangled;
|
||||
this.originalDemangled = originalDemangled;
|
||||
this.rawDemangled = originalDemangled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,6 +140,7 @@ public abstract class DemangledObject implements Demangled {
|
||||
this.mangledContext = mangledContext;
|
||||
this.mangled = mangledContext.getMangled();
|
||||
this.originalDemangled = originalDemangled;
|
||||
this.rawDemangled = originalDemangled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -280,6 +289,24 @@ public abstract class DemangledObject implements Demangled {
|
||||
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
|
||||
public Demangled getNamespace() {
|
||||
return namespace;
|
||||
|
@ -412,6 +412,7 @@ public class GnuDemanglerParser {
|
||||
|
||||
demangled = cleanupRustLegacySymbol(demangled);
|
||||
|
||||
String rawDemangled = demangled;
|
||||
if (simplify) {
|
||||
demangled = replaceStdLibraryTypes(demangled);
|
||||
}
|
||||
@ -421,10 +422,16 @@ public class GnuDemanglerParser {
|
||||
|
||||
DemangledObjectBuilder builder = getSpecializedBuilder(demangled);
|
||||
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) {
|
||||
|
@ -115,6 +115,10 @@ public class GnuDemanglerTest extends AbstractGenericTest {
|
||||
"virtual thunk to undefined __thiscall std::ostringstream::~ostringstream(void)",
|
||||
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
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user