Package ghidra.program.model.pcode
Class HighFunction
- java.lang.Object
-
- ghidra.program.model.pcode.PcodeSyntaxTree
-
- ghidra.program.model.pcode.HighFunction
-
- All Implemented Interfaces:
PcodeFactory
public class HighFunction extends PcodeSyntaxTree
High-level abstraction associated with a low level function made up of assembly instructions. Based on information the decompiler has produced after working on a function.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DECOMPILER_TAG_MAP
-
Constructor Summary
Constructors Constructor Description HighFunction(Function function, Language language, CompilerSpec compilerSpec, PcodeDataTypeManager dtManager)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
buildFunctionXML(long id, Namespace namespace, Address entryPoint, int size)
Build an XML string that represents all the information about this HighFunction.static boolean
clearNamespace(SymbolTable symtab, Namespace space)
static boolean
collapseToGlobal(Namespace namespace)
The decompiler treats some namespaces as equivalent to the "global" namespace.static void
createLabelSymbol(SymbolTable symtab, Address addr, java.lang.String name, Namespace namespace, SourceType source, boolean useLocalNamespace)
static void
createNamespaceTag(java.lang.StringBuilder buf, Namespace namespace)
Append an XML <parent> tag to the buffer describing the formal path elements from the root (global) namespace up to the given namespacestatic void
deleteSymbol(SymbolTable symtab, Address addr, java.lang.String name, Namespace space)
static Namespace
findCreateNamespace(SymbolTable symtab, Namespace parentspace, java.lang.String name)
static Namespace
findCreateOverrideSpace(Function func)
static Namespace
findNamespace(SymbolTable symtab, Namespace parent, java.lang.String name)
static Namespace
findOverrideSpace(Function func)
CompilerSpec
getCompilerSpec()
static org.xml.sax.ErrorHandler
getErrorHandler(java.lang.Object errOriginator, java.lang.String targetName)
Function
getFunction()
FunctionPrototype
getFunctionPrototype()
GlobalSymbolMap
getGlobalSymbolMap()
long
getID()
Get the id with the associated function symbol, if it exists.JumpTable[]
getJumpTables()
Language
getLanguage()
LocalSymbolMap
getLocalSymbolMap()
HighSymbol
getMappedSymbol(Address addr, Address pcaddr)
protected Address
getPCAddress(Varnode rep)
HighSymbol
getSymbol(long symbolId)
void
grabFromFunction(int overrideExtrapop, boolean includeDefaultNames, boolean doOverride)
Populate the information for the HighFunction from the information in the Function object.Varnode
newVarnode(int sz, Address addr)
Create a new Varnode with the given size an locationVarnode
newVarnode(int sz, Address addr, int id)
void
readXML(XmlPullParser parser)
HighVariable
splitOutMergeGroup(HighVariable high, Varnode vn)
If a HighVariable consists of more than one (forced) merge group, split out the group that contains vn as a separate HighVariable.static XmlPullParser
stringTree(java.io.InputStream xml, org.xml.sax.ErrorHandler handler)
Create XML parse tree from an input XML string TODO: this probably doesn't belong here.static java.lang.String
tagFindExclude(java.lang.String tagname, java.lang.String doc)
-
Methods inherited from class ghidra.program.model.pcode.PcodeSyntaxTree
buildStorage, clear, createFromStorage, delete, findInputVarnode, findVarnode, findVarnode, getAddressFactory, getBasicBlocks, getDataTypeManager, getNumVarnodes, getOpRef, getPcodeOp, getPcodeOps, getPcodeOps, getRef, getVarnodes, getVarnodes, getVarnodes, getVbank, insertAfter, insertBefore, locRange, newOp, readXMLVarnodePieces, setAddrTied, setDataType, setInput, setInput, setMergeGroup, setOpcode, setOutput, setPersistent, setUnaffected, unInsert, unlink, unSetInput, unSetOutput
-
-
-
-
Field Detail
-
DECOMPILER_TAG_MAP
public static final java.lang.String DECOMPILER_TAG_MAP
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HighFunction
public HighFunction(Function function, Language language, CompilerSpec compilerSpec, PcodeDataTypeManager dtManager)
- Parameters:
function
- function associated with the higher level function abstraction.language
- description of the processor language of the functioncompilerSpec
- description of the compiler that produced the functiondtManager
- data type manager
-
-
Method Detail
-
getFunction
public Function getFunction()
- Returns:
- get the associated low level function
-
getID
public long getID()
Get the id with the associated function symbol, if it exists. Otherwise return a dynamic id based on the entry point.- Returns:
- the symbol id, or possibly a dynamic id
-
getLanguage
public Language getLanguage()
- Returns:
- get the language parser used to disassemble
-
getCompilerSpec
public CompilerSpec getCompilerSpec()
-
getFunctionPrototype
public FunctionPrototype getFunctionPrototype()
- Returns:
- the function prototype for the function (how things are passed/returned)
-
getJumpTables
public JumpTable[] getJumpTables()
- Returns:
- an array of jump table definitions found for this function decompilation
-
getLocalSymbolMap
public LocalSymbolMap getLocalSymbolMap()
- Returns:
- the local variable map describing the defined local variables
-
getGlobalSymbolMap
public GlobalSymbolMap getGlobalSymbolMap()
- Returns:
- a map describing global variables accessed by this function
-
getMappedSymbol
public HighSymbol getMappedSymbol(Address addr, Address pcaddr)
-
getSymbol
public HighSymbol getSymbol(long symbolId)
- Specified by:
getSymbol
in interfacePcodeFactory
- Overrides:
getSymbol
in classPcodeSyntaxTree
-
grabFromFunction
public void grabFromFunction(int overrideExtrapop, boolean includeDefaultNames, boolean doOverride)
Populate the information for the HighFunction from the information in the Function object.- Parameters:
overrideExtrapop
- is the value to use if extrapop is overriddenincludeDefaultNames
- is true if default symbol names should be considered lockeddoOverride
- is true if extrapop is overridden
-
newVarnode
public Varnode newVarnode(int sz, Address addr)
Description copied from interface:PcodeFactory
Create a new Varnode with the given size an location- Specified by:
newVarnode
in interfacePcodeFactory
- Overrides:
newVarnode
in classPcodeSyntaxTree
- Parameters:
sz
- size of varnodeaddr
- location of varnode- Returns:
- a new varnode
-
newVarnode
public Varnode newVarnode(int sz, Address addr, int id)
- Specified by:
newVarnode
in interfacePcodeFactory
- Overrides:
newVarnode
in classPcodeSyntaxTree
-
readXML
public void readXML(XmlPullParser parser) throws PcodeXMLException
- Overrides:
readXML
in classPcodeSyntaxTree
- Throws:
PcodeXMLException
-
splitOutMergeGroup
public HighVariable splitOutMergeGroup(HighVariable high, Varnode vn) throws PcodeException
If a HighVariable consists of more than one (forced) merge group, split out the group that contains vn as a separate HighVariable. Otherwise just return the original high.- Parameters:
high
- is the HighVariable to splitvn
- is a representative of the merge group to split out- Returns:
- a HighVariable containing just the forced merge group of vn
- Throws:
PcodeException
- if the split can't be performed
-
buildFunctionXML
public java.lang.String buildFunctionXML(long id, Namespace namespace, Address entryPoint, int size)
Build an XML string that represents all the information about this HighFunction. The size describes how many bytes starting from the entry point are used by the function, but this doesn't need to be strictly accurate as it is only used to associate the function with addresses near its entry point.- Parameters:
id
- is the id associated with the function symbolnamespace
- is the namespace containing the function symbolentryPoint
- pass null to use the function entryPoint, pass an address to force an entry pointsize
- describes how many bytes the function occupies as code- Returns:
- the XML string
-
getErrorHandler
public static org.xml.sax.ErrorHandler getErrorHandler(java.lang.Object errOriginator, java.lang.String targetName)
-
findNamespace
public static Namespace findNamespace(SymbolTable symtab, Namespace parent, java.lang.String name)
-
createLabelSymbol
public static void createLabelSymbol(SymbolTable symtab, Address addr, java.lang.String name, Namespace namespace, SourceType source, boolean useLocalNamespace) throws InvalidInputException
- Throws:
InvalidInputException
-
deleteSymbol
public static void deleteSymbol(SymbolTable symtab, Address addr, java.lang.String name, Namespace space) throws InvalidInputException
- Throws:
InvalidInputException
-
clearNamespace
public static boolean clearNamespace(SymbolTable symtab, Namespace space) throws InvalidInputException
- Throws:
InvalidInputException
-
findCreateNamespace
public static Namespace findCreateNamespace(SymbolTable symtab, Namespace parentspace, java.lang.String name)
-
stringTree
public static XmlPullParser stringTree(java.io.InputStream xml, org.xml.sax.ErrorHandler handler) throws PcodeXMLException
Create XML parse tree from an input XML string TODO: this probably doesn't belong here.- Parameters:
xml
- is the XML string to parsehandler
- is the handler to use for parsing errors- Returns:
- the XML tree
- Throws:
PcodeXMLException
- for format errors in the XML
-
collapseToGlobal
public static final boolean collapseToGlobal(Namespace namespace)
The decompiler treats some namespaces as equivalent to the "global" namespace. Return true if the given namespace is treated as equivalent.- Parameters:
namespace
- is the namespace- Returns:
- true if equivalent
-
createNamespaceTag
public static void createNamespaceTag(java.lang.StringBuilder buf, Namespace namespace)
Append an XML <parent> tag to the buffer describing the formal path elements from the root (global) namespace up to the given namespace- Parameters:
buf
- is the buffer to write tonamespace
- is the namespace being described
-
tagFindExclude
public static java.lang.String tagFindExclude(java.lang.String tagname, java.lang.String doc)
- Parameters:
tagname
- -- Name of tag to search fordoc
- -- String through which to search for tags- Returns:
- all characters between beginning and ending XML tags, excluding tags themselves
-
-