decompiler
1.0.0
|
An implementation of the Architecture interface and connection to a Ghidra client. More...
#include <ghidra_arch.hh>
Public Member Functions | |
ArchitectureGhidra (const string &pspec, const string &cspec, const string &tspec, const string &corespec, istream &i, ostream &o) | |
Construct given specification files and i/o streams. More... | |
const string & | getWarnings (void) const |
Get warnings produced by the last decompilation. | |
void | clearWarnings (void) |
Clear warnings. | |
Document * | getRegister (const string ®name) |
Retrieve a register description given a name. More... | |
string | getRegisterName (const VarnodeData &vndata) |
Retrieve a register name given its storage location. More... | |
Document * | getTrackedRegisters (const Address &addr) |
Retrieve tracked register values at the given address. More... | |
string | getUserOpName (int4 index) |
Get the name of a user-defined p-code op. More... | |
uint1 * | getPcodePacked (const Address &addr) |
Get p-code for a single instruction. More... | |
Document * | getMappedSymbolsXML (const Address &addr) |
Get symbols associated with the given address. More... | |
Document * | getExternalRefXML (const Address &addr) |
Retrieve a description of an external function. More... | |
string | getCodeLabel (const Address &addr) |
Retrieve a label at the given address. More... | |
Document * | getType (const string &name, uint8 id) |
Retrieve a data-type description for the given name and id. More... | |
Document * | getComments (const Address &fad, uint4 flags) |
Retrieve comments for a particular function. More... | |
void | getBytes (uint1 *buf, int4 size, const Address &inaddr) |
Retrieve bytes in the LoadImage at the given address. More... | |
Document * | getPcodeInject (const string &name, int4 type, const InjectContext &con) |
Retrieve p-code to inject for a specific context. More... | |
Document * | getCPoolRef (const vector< uintb > &refs) |
Resolve a constant pool reference. More... | |
void | setSendSyntaxTree (bool val) |
Toggle whether the data-flow and control-flow is emitted as part of the main decompile action. More... | |
bool | getSendSyntaxTree (void) const |
Get the current setting for emitting data/control-flow. | |
void | setSendCCode (bool val) |
Toggle whether the recovered source code is emitted as part of the main decompile action. More... | |
bool | getSendCCode (void) const |
Get the current setting for emitting source code. | |
void | setSendParamMeasures (bool val) |
Toggle whether recovered parameter information is emitted as part of the main decompile action. More... | |
bool | getSendParamMeasures (void) const |
Get the current setting for emitting parameter info. | |
virtual void | printMessage (const string &message) const |
Print an error message to console. More... | |
Public Member Functions inherited from Architecture | |
Architecture (void) | |
Construct an uninitialized Architecture. More... | |
void | init (DocumentStorage &store) |
Load the image and configure architecture. More... | |
ProtoModel * | getModel (const string &nm) const |
Get a specific PrototypeModel. More... | |
bool | hasModel (const string &nm) const |
Does this Architecture have a specific PrototypeModel. More... | |
bool | highPtrPossible (const Address &loc, int4 size) const |
Are pointers possible to the given location? More... | |
AddrSpace * | getSpaceBySpacebase (const Address &loc, int4 size) const |
Get space associated with a spacebase register. More... | |
void | setDefaultModel (const string &nm) |
Set the default PrototypeModel. More... | |
void | clearAnalysis (Funcdata *fd) |
Clear analysis specific to a function. More... | |
void | readLoaderSymbols (void) |
Read any symbols from loader into database. More... | |
void | collectBehaviors (vector< OpBehavior * > &behave) const |
Provide a list of OpBehavior objects. More... | |
bool | hasNearPointers (AddrSpace *spc) const |
Does the given address space support near pointers. More... | |
void | setPrototype (const PrototypePieces &pieces) |
Set the prototype for a particular function. More... | |
void | setPrintLanguage (const string &nm) |
Establish a particular output language. More... | |
void | globalify (void) |
Mark all spaces as global. More... | |
void | restoreFlowOverride (const Element *el) |
Set flow overrides from XML. More... | |
virtual | ~Architecture (void) |
Destructor. More... | |
virtual void | saveXml (ostream &s) const |
Serialize this architecture to XML. More... | |
virtual void | restoreXml (DocumentStorage &store) |
Restore the Architecture state from an XML stream. More... | |
virtual void | nameFunction (const Address &addr, string &name) const |
Pick a default name for a function. More... | |
Public Member Functions inherited from AddrSpaceManager | |
AddrSpaceManager (void) | |
Construct an empty address space manager. More... | |
virtual | ~AddrSpaceManager (void) |
Destroy the manager. More... | |
char | assignShortcut (spacetype tp) const |
Select a shortcut character for a new space. More... | |
int4 | getDefaultSize (void) const |
Get size of addresses for the default space. More... | |
AddrSpace * | getSpaceByName (const string &nm) const |
Get address space by name. More... | |
AddrSpace * | getSpaceByShortcut (char sc) const |
Get address space from its shortcut. More... | |
AddrSpace * | getIopSpace (void) const |
Get the internal pcode op space. More... | |
AddrSpace * | getFspecSpace (void) const |
Get the internal callspec space. More... | |
AddrSpace * | getJoinSpace (void) const |
Get the joining space. More... | |
AddrSpace * | getStackSpace (void) const |
Get the stack space for this processor. More... | |
AddrSpace * | getUniqueSpace (void) const |
Get the temporary register space for this processor. More... | |
AddrSpace * | getDefaultSpace (void) const |
Get the default address space of this processor. More... | |
AddrSpace * | getConstantSpace (void) const |
Get the constant space. More... | |
Address | getConstant (uintb val) const |
Get a constant encoded as an Address. More... | |
Address | createConstFromSpace (AddrSpace *spc) const |
Create a constant address encoding an address space. More... | |
Address | resolveConstant (AddrSpace *spc, uintb val, int4 sz, const Address &point) const |
Resolve native constant to address. | |
int4 | numSpaces (void) const |
Get the number of address spaces for this processor. More... | |
AddrSpace * | getSpace (int4 i) const |
Get an address space via its index. More... | |
AddrSpace * | getNextSpaceInOrder (AddrSpace *spc) const |
Get the next contiguous address space. More... | |
JoinRecord * | findAddJoin (const vector< VarnodeData > &pieces, uint4 logicalsize) |
Get (or create) JoinRecord for pieces. More... | |
JoinRecord * | findJoin (uintb offset) const |
Find JoinRecord for offset in the join space. More... | |
void | setDeadcodeDelay (int4 spcnum, int4 delaydelta) |
Set the deadcodedelay for a specific space. More... | |
void | truncateSpace (const TruncationTag &tag) |
Mark a space as truncated from its original size. More... | |
Address | constructFloatExtensionAddress (const Address &realaddr, int4 realsize, int4 logicalsize) |
Build a logically lower precision storage location for a bigger floating point register. More... | |
Address | constructJoinAddress (const Translate *translate, const Address &hiaddr, int4 hisz, const Address &loaddr, int4 losz) |
Build a logical whole from register pairs. More... | |
Static Public Member Functions | |
static void | segvHandler (int4 sig) |
Handler for a segment violation (SIGSEGV) signal. More... | |
static int4 | readToAnyBurst (istream &s) |
Read the next message protocol marker. More... | |
static void | readStringStream (istream &s, string &res) |
Receive a string from the client. More... | |
static void | writeStringStream (ostream &s, const string &msg) |
Send a string to the client. More... | |
static void | readToResponse (istream &s) |
Read the query response protocol marker. More... | |
static void | readResponseEnd (istream &s) |
Read the ending query response protocol marker. More... | |
static Document * | readXMLAll (istream &s) |
Read a whole response as an XML document. More... | |
static Document * | readXMLStream (istream &s) |
Receive an XML document from the client. More... | |
static uint1 * | readPackedStream (istream &s) |
Read packed p-code op information. More... | |
static uint1 * | readPackedAll (istream &s) |
Read a whole response as packed p-code op information. More... | |
static void | passJavaException (ostream &s, const string &tp, const string &msg) |
Send an exception message to the Ghidra client. More... | |
Private Member Functions | |
virtual Scope * | buildGlobalScope (void) |
Build the global scope for this executable. More... | |
virtual Translate * | buildTranslator (DocumentStorage &store) |
Build the Translator object. More... | |
virtual void | buildLoader (DocumentStorage &store) |
Build the LoadImage object and load the executable image. More... | |
virtual PcodeInjectLibrary * | buildPcodeInjectLibrary (void) |
Build the injection library. More... | |
virtual void | buildTypegrp (DocumentStorage &store) |
Build the data-type factory/container. More... | |
virtual void | buildCommentDB (DocumentStorage &store) |
Build the comment database. More... | |
virtual void | buildConstantPool (DocumentStorage &store) |
Build the constant pool. More... | |
virtual void | buildContext (DocumentStorage &store) |
Build the Context database. More... | |
virtual void | buildSpecFile (DocumentStorage &store) |
Load any relevant specification files. More... | |
virtual void | modifySpaces (Translate *trans) |
Modify address spaces as required by this Architecture. More... | |
virtual void | postSpecFile (void) |
Let components initialize after Translate is built. | |
virtual void | resolveArchitecture (void) |
Figure out the processor and compiler of the target executable. | |
Private Attributes | |
istream & | sin |
Input stream for interfacing with Ghidra. | |
ostream & | sout |
Output stream for interfacing with Ghidra. | |
string | warnings |
Warnings accumulated by the decompiler. | |
string | pspecxml |
XML pspec passed from Ghidra. | |
string | cspecxml |
XML cspec passed from Ghidra. | |
string | tspecxml |
Stripped down .sla file passed from Ghidra. | |
string | corespecxml |
A specification of the core data-types. | |
bool | sendsyntaxtree |
True if the syntax tree should be sent with function output. | |
bool | sendCcode |
True if C code should be sent with function output. | |
bool | sendParamMeasures |
True if measurements for argument and return parameters should be sent. | |
Additional Inherited Members | |
Public Attributes inherited from Architecture | |
string | archid |
ID string uniquely describing this architecture. | |
string | description |
Description of architecture. | |
string | version |
Configuration version. | |
int4 | trim_recurse_max |
How many levels to let parameter trims recurse. | |
int4 | max_implied_ref |
Maximum number of references to an implied var. | |
int4 | max_term_duplication |
Max terms duplicated without a new variable. | |
int4 | max_basetype_size |
Maximum size of an "integer" type before creating an array type. | |
int4 | min_funcsymbol_size |
Minimum size of a function symbol. | |
bool | aggressive_ext_trim |
Aggressively trim inputs that look like they are sign extended. | |
bool | readonlypropagate |
true if readonly values should be treated as constants | |
bool | infer_pointers |
True if we should infer pointers from constants that are likely addresses. | |
uintb | pointer_lowerbound |
Zero or lowest value that can be inferred as an address. | |
int4 | funcptr_align |
How many bits of alignment a function ptr has. | |
uint4 | flowoptions |
options passed to flow following engine | |
vector< Rule * > | extra_pool_rules |
Extra rules that go in the main pool (cpu specific, experimental) | |
Database * | symboltab |
Memory map of global variables and functions. | |
ContextDatabase * | context |
Map from addresses to context settings. | |
map< string, ProtoModel * > | protoModels |
Parsed forms of possible prototypes. | |
ProtoModel * | defaultfp |
Parsed form of default prototype. | |
VarnodeData | defaultReturnAddr |
Default storage location of return address (for current function) | |
ProtoModel * | evalfp_current |
Function proto to use when evaluating current function. | |
ProtoModel * | evalfp_called |
Function proto to use when evaluating called functions. | |
TypeFactory * | types |
List of types for this binary. | |
const Translate * | translate |
Translation method for this binary. | |
LoadImage * | loader |
Method for loading portions of binary. | |
PcodeInjectLibrary * | pcodeinjectlib |
Pcode injection manager. | |
RangeList | nohighptr |
Ranges for which high-level pointers are not possible. | |
CommentDatabase * | commentdb |
Comments for this architecture. | |
ConstantPool * | cpool |
Deferred constant values. | |
PrintLanguage * | |
Current high-level language printer. | |
vector< PrintLanguage * > | printlist |
List of high-level language printers supported. | |
OptionDatabase * | options |
Options that can be configured. | |
vector< TypeOp * > | inst |
Registered p-code instructions. | |
UserOpManage | userops |
Specifically registered user-defined p-code ops. | |
vector< PreferSplitRecord > | splitrecords |
registers that we would prefer to see split for this processor | |
ActionDatabase | allacts |
Actions that can be applied in this architecture. | |
bool | loadersymbols_parsed |
True if loader symbols have been read. | |
Protected Member Functions inherited from Architecture | |
void | addSpacebase (AddrSpace *basespace, const string &nm, const VarnodeData &ptrdata, int4 truncSize, bool isreversejustified, bool stackGrowth) |
Create a new space and associated pointer. More... | |
void | addNoHighPtr (const Range &rng) |
Add a new region where pointers do not exist. More... | |
virtual void | buildInstructions (DocumentStorage &store) |
Register the p-code operations. More... | |
virtual void | buildAction (DocumentStorage &store) |
Build the Action framework. More... | |
void | restoreFromSpec (DocumentStorage &store) |
Fully initialize the Translate object. More... | |
void | fillinReadOnlyFromLoader (void) |
Load info about read-only sections. More... | |
void | initializeSegments () |
Set up segment resolvers. More... | |
void | parseProcessorConfig (DocumentStorage &store) |
Apply processor specific configuration. More... | |
void | parseCompilerConfig (DocumentStorage &store) |
Apply compiler specific configuration. More... | |
void | parseExtraRules (DocumentStorage &store) |
Apply any Rule tags. More... | |
void | parseDynamicRule (const Element *el) |
Apply details of a dynamic Rule object. More... | |
ProtoModel * | parseProto (const Element *el) |
Build a proto-type model from an XML tag. More... | |
void | parseProtoEval (const Element *el) |
Apply prototype evaluation configuration. More... | |
void | parseDefaultProto (const Element *el) |
Apply default prototype model configuration. More... | |
void | parseGlobal (const Element *el) |
Apply global space configuration. More... | |
void | parseReadOnly (const Element *el) |
Apply read-only region configuration. More... | |
void | parseVolatile (const Element *el) |
Apply volatile region configuration. More... | |
void | parseReturnAddress (const Element *el) |
Apply return address configuration. More... | |
void | parseIncidentalCopy (const Element *el) |
Apply incidental copy configuration. More... | |
void | parseStackPointer (const Element *el) |
Apply stack pointer configuration. More... | |
void | parseDeadcodeDelay (const Element *el) |
Apply dead-code delay configuration. More... | |
void | parseFuncPtrAlign (const Element *el) |
Apply function pointer alignment configuration. More... | |
void | parseSpacebase (const Element *el) |
Create an additional indexed space. More... | |
void | parseNoHighPtr (const Element *el) |
Apply memory alias configuration. More... | |
void | parsePreferSplit (const Element *el) |
Designate registers to be split. More... | |
void | parseAggressiveTrim (const Element *el) |
Designate how to trim extension p-code ops. More... | |
Protected Member Functions inherited from AddrSpaceManager | |
AddrSpace * | restoreXmlSpace (const Element *el, const Translate *trans) |
Add a space to the model based an on XML tag. More... | |
void | restoreXmlSpaces (const Element *el, const Translate *trans) |
Restore address spaces in the model from an XML tag. More... | |
void | setDefaultSpace (int4 index) |
Set the default address space. More... | |
void | setReverseJustified (AddrSpace *spc) |
Set reverse justified property on this space. More... | |
void | insertSpace (AddrSpace *spc) |
Add a new address space to the model. More... | |
void | copySpaces (const AddrSpaceManager *op2) |
Copy spaces from another manager. More... | |
void | addSpacebasePointer (SpacebaseSpace *basespace, const VarnodeData &ptrdata, int4 truncSize, bool stackGrowth) |
Set the base register of a spacebase space. More... | |
void | insertResolver (AddrSpace *spc, AddressResolver *rsolv) |
Override the base resolver for a space. More... | |
An implementation of the Architecture interface and connection to a Ghidra client.
In addition to managing the major pieces of the architecture (LoadImage, Translate, Database, TypeFactory, ContextDatbase, CommentDatabase etc.), this class manages a communication channel between the decompiler and a Ghidra client for a single executable. The protocol supports a simple query/response format with exceptions. On top of the low level protocol, this class manages a higher level interface that performs specific queries, providing addresses, names, and other info as input, and returning an XML document or other structure as a result.
This class overrides the build* methods to produce Architecture components that are also backed by the Ghidra client. These all use this same object to do their communication.
This class acts as a main control point for what information gets sent back to the Ghidra client when it requests the main decompilation action. Generally the decompiler sends back the recovered source representation of the function but optionally it can send back:
ArchitectureGhidra::ArchitectureGhidra | ( | const string & | pspec, |
const string & | cspec, | ||
const string & | tspec, | ||
const string & | corespec, | ||
istream & | i, | ||
ostream & | o | ||
) |
Construct given specification files and i/o streams.
pspec | is the processor specification presented as an XML string |
cspec | is the compiler specification presented as an XML string |
tspec | is a stripped down form of the SLEIGH specification presented as an XML string |
corespec | is a list of core data-types presented as a <coretypes> XML tag |
i | is the input stream from the Ghidra client |
o | is the output stream to the Ghidra client |
References corespecxml, cspecxml, Architecture::print, pspecxml, sendCcode, sendParamMeasures, sendsyntaxtree, PrintLanguage::setOutputStream(), PrintLanguage::setXML(), sout, and tspecxml.
|
privatevirtual |
Build the comment database.
Build the container that holds comments for executable in this Architecture.
store | may hold configuration information |
Reimplemented from Architecture.
References Architecture::commentdb.
|
privatevirtual |
Build the constant pool.
Some processor models (Java byte-code) need a database of constants. The database is always built, but may remain empty.
store | may hold configuration information |
Reimplemented from Architecture.
References Architecture::cpool.
|
privatevirtual |
Build the Context database.
This builds the database which holds the status registers setings and other information that can affect disassembly depending on context.
store | may hold configuration information |
Reimplemented from Architecture.
References Architecture::context.
|
privatevirtual |
Build the global scope for this executable.
If it does not already exist create the glocal Scope object
Reimplemented from Architecture.
References Database::attachScope(), Database::getGlobalScope(), and Architecture::symboltab.
|
privatevirtual |
Build the LoadImage object and load the executable image.
store | may hold configuration information |
Implements Architecture.
References Architecture::loader.
|
privatevirtual |
Build the injection library.
This creates the container for p-code injections. It is initially empty.
Implements Architecture.
|
privatevirtual |
Load any relevant specification files.
Processor/architecture specific configuration files are loaded into the XML store
store | is the document store that will hold the configuration |
Implements Architecture.
References corespecxml, cspecxml, pspecxml, and tspecxml.
|
privatevirtual |
Build the Translator object.
This builds the main disassembly component for the Architecture This does not initially the engine for a specific processor.
store | may hold configuration information |
Implements Architecture.
|
privatevirtual |
Build the data-type factory/container.
This builds the TypeFactory object specific to this architecture and prepopulates it with the core types. Core types may be pulled from the configuration information, or default core types are used.
store | contains possible configuration information |
Reimplemented from Architecture.
References TypeFactory::cacheCoreTypes(), TypeFactory::restoreXmlCoreTypes(), TypeFactory::setCoreType(), TYPE_BOOL, TYPE_CODE, TYPE_FLOAT, TYPE_INT, TYPE_UINT, TYPE_UNKNOWN, TYPE_VOID, and Architecture::types.
void ArchitectureGhidra::getBytes | ( | uint1 * | buf, |
int4 | size, | ||
const Address & | inaddr | ||
) |
Retrieve bytes in the LoadImage at the given address.
The Ghidra client is queried for a range of bytes, which are returned in the given array. This method throws a DataUnavailError if the provided address doesn't make sense.
buf | is the preallocated array in which to store the bytes |
size | is the number of bytes requested |
inaddr | is the address in the LoadImage from which to grab bytes |
References Address::getShortcut(), Address::printRaw(), readResponseEnd(), readToAnyBurst(), readToResponse(), Address::saveXml(), sin, sout, and writeStringStream().
Referenced by LoadImageGhidra::loadFill().
string ArchitectureGhidra::getCodeLabel | ( | const Address & | addr | ) |
Retrieve a label at the given address.
Get the name of the primary symbol at the given address. This is used to fetch within function labels. Only a name is returned.
addr | is the given address |
References readResponseEnd(), readStringStream(), readToResponse(), Address::saveXml(), sin, sout, and writeStringStream().
Referenced by ScopeGhidra::findCodeLabel().
Retrieve comments for a particular function.
Ask Ghidra client for all comments associated with one function. The caller must provide the sub-set of properties (Comment::comment_type) for the query to match. The client will return a <commentdb> tag with a <comment> tag child for each comment found.
fad | is the address of the function to query |
flags | specifies the properties the query will match (must be non-zero) |
References readXMLAll(), Address::saveXml(), sin, sout, and writeStringStream().
Referenced by CommentDatabaseGhidra::fillCache().
Document * ArchitectureGhidra::getCPoolRef | ( | const vector< uintb > & | refs | ) |
Resolve a constant pool reference.
The Ghidra client is provided a sequence of 1 or more integer values extracted from a CPOOLREF op. It returns an XML document describing the constant pool record referenced by the integer(s) or will throw an exception if record isn't properly referenced.
refs | is an array of 1 or more integer values referencing a constant pool record |
References readXMLAll(), sin, sout, and writeStringStream().
Referenced by ConstantPoolGhidra::getRecord().
Retrieve a description of an external function.
This asks the Ghidra client to resolve an external reference. This is an address for which the client holds a reference to a function that is elsewhere in memory or not in memory at all. The client should unravel the reference from the given address and return either a <function> tag describing the referred to function symbol or a <hole> tag if the reference can't be resolved
addr | is the given address |
References readXMLAll(), Address::saveXml(), sin, sout, and writeStringStream().
Referenced by ScopeGhidra::resolveExternalRefFunction().
Get symbols associated with the given address.
The Ghidra client will return a <symbol> tag, <function> tag, or some other related Symbol information. If there no symbol at the address the client should return a <hole> tag describing the size of the memory region that is free of symbols.
addr | is the given address |
References readXMLAll(), Address::saveXml(), sin, sout, and writeStringStream().
Referenced by ScopeGhidra::removeQuery().
Document * ArchitectureGhidra::getPcodeInject | ( | const string & | name, |
int4 | type, | ||
const InjectContext & | con | ||
) |
Retrieve p-code to inject for a specific context.
The particular injection is named and is of one of the types:
This and additional context is provided to the Ghidra client which returns an XML document describing the p-code. The document will be an <inst> tag containing individual <op> tags corresponding to individual p-code ops.
name | is the name of the injection |
type | is the type of injection |
con | is the context object |
References InjectPayload::CALLFIXUP_TYPE, InjectPayload::CALLMECHANISM_TYPE, InjectPayload::CALLOTHERFIXUP_TYPE, readXMLAll(), InjectContext::saveXml(), sin, sout, and writeStringStream().
Referenced by InjectPayloadGhidra::inject(), and ExecutablePcodeGhidra::inject().
uint1 * ArchitectureGhidra::getPcodePacked | ( | const Address & | addr | ) |
Get p-code for a single instruction.
Get a description of all the p-code ops for the instruction at the given address. The information is stored in a special compressed format. (See PcodeEmit::restorePackedOp)
addr | is the address of the instruction |
References readPackedAll(), Address::saveXml(), sin, sout, and writeStringStream().
Referenced by GhidraTranslate::oneInstruction().
Document * ArchitectureGhidra::getRegister | ( | const string & | regname | ) |
Retrieve a register description given a name.
Ask the Ghidra client if it knows about a specific processor register. The client responds with a <addr> XML element describing the storage location of the register.
regname | is the name to query for |
References readXMLAll(), sin, sout, and writeStringStream().
Referenced by GhidraTranslate::getRegister().
string ArchitectureGhidra::getRegisterName | ( | const VarnodeData & | vndata | ) |
Retrieve a register name given its storage location.
Given a storage location and size, ask the Ghidra client if it knows of a register that occupies those bytes. The register name is passed back. The name may not exactly match the given memory range, it may contain it.
vndata | is the location and size |
References VarnodeData::offset, readResponseEnd(), readStringStream(), readToResponse(), Address::saveXml(), sin, VarnodeData::size, sout, VarnodeData::space, and writeStringStream().
Referenced by GhidraTranslate::getRegisterName().
Retrieve tracked register values at the given address.
The Ghidra client will return a description of registers that have known values at the given address. The response is generally a <tracked_pointset> which contains <set> children which contains a storage location and value.
addr | is the given address |
References readXMLAll(), Address::saveXml(), sin, sout, and writeStringStream().
Document * ArchitectureGhidra::getType | ( | const string & | name, |
uint8 | id | ||
) |
Retrieve a data-type description for the given name and id.
The Ghidra client should respond with a <type> tag giving details about the data-type.
name | is the name of the data-type |
id | is a unique id associated with the data-type, pass 0 if unknown |
References readXMLAll(), sin, sout, and writeStringStream().
string ArchitectureGhidra::getUserOpName | ( | int4 | index | ) |
Get the name of a user-defined p-code op.
The first operand to a CALLOTHER op indicates the specific user-defined op. This method queries the Ghidra client and passes back the name of the op.
index | is the value of the CALLOTHER operand |
References readResponseEnd(), readStringStream(), readToResponse(), sin, sout, and writeStringStream().
Referenced by GhidraTranslate::getUserOpNames().
|
inlineprivatevirtual |
Modify address spaces as required by this Architecture.
If spaces need to be truncated or otherwise changed from processor defaults, this routine performs the modification.
trans | is the processor disassembly object |
Implements Architecture.
|
static |
Send an exception message to the Ghidra client.
This generally called because of some sort of alignment issue in the message protocol and lets the client know to abort (and hopefully resync)
s | is the output stream to the client |
tp | is the type of exception |
msg | is the exception message |
References writeStringStream().
Referenced by GhidraCommand::doit().
|
virtual |
Print an error message to console.
Write the given message to whatever the registered error stream is
message | is the error message |
Implements Architecture.
References warnings.
Referenced by GhidraCommand::doit().
|
static |
Read a whole response as packed p-code op information.
Read up to the beginning of a query response, check for an exception record, otherwise read in packed p-code op data.
s | is the input stream from the client |
References readPackedStream(), readResponseEnd(), and readToResponse().
Referenced by getPcodePacked().
|
static |
Read packed p-code op information.
The method expects to see protocol markers indicating a string from the client, otherwise it throws and exception. An array size is encoded in the first 4 characters of the string. An array of this size is allocated and filled with the rest of the string.
s | is the input stream from the client |
References readToAnyBurst().
Referenced by readPackedAll().
|
static |
Read the ending query response protocol marker.
Read the next protocol marker. If it does not indicate the end of a query response, throw an exception
s | is the input stream from the client |
References readToAnyBurst().
Referenced by getBytes(), getCodeLabel(), getRegisterName(), getUserOpName(), readPackedAll(), and readXMLAll().
|
static |
Receive a string from the client.
Characters are read up to the next protocol marked and placed into a string. The protocol marker is consumed and must indicate the end of a string or an exception is thrown.
s | is the input stream from the client |
res | will hold the string |
References readToAnyBurst().
Referenced by getCodeLabel(), getRegisterName(), getUserOpName(), RegisterProgram::loadParameters(), SetAction::loadParameters(), GhidraCapability::readCommand(), and readToResponse().
|
static |
Read the next message protocol marker.
All communications between the Ghidra client and the decompiler are surrounded by alignment bursts. A burst is 1 or more zero bytes followed by an 0x01 byte, then followed by a code byte. Open alignment (as in open paren) is even. Close alignment is odd. Code bytes are as follows:
The protocol is as follows:
Commands, queries, and responses all consist of zero or more string streams or byte streams.
In place of any response an exception can be sent. The decompiler can interrupt a command response with a query or exception once the query is finished the response picks up where it left off an exception however permanently cancels the query. Ghidra cannot interrupt either of its responses.
s | is the input stream from the client |
Referenced by GhidraCommand::doit(), getBytes(), GhidraCommand::loadParameters(), DeregisterProgram::loadParameters(), GhidraCapability::readCommand(), readPackedStream(), readResponseEnd(), readStringStream(), readToResponse(), and readXMLStream().
|
static |
Read the query response protocol marker.
Consume the query response header. If it indicates an exception, read details of the exception and throw JavaError.
s | is the input stream from the client |
References readStringStream(), and readToAnyBurst().
Referenced by getBytes(), getCodeLabel(), getRegisterName(), getUserOpName(), readPackedAll(), and readXMLAll().
|
static |
Read a whole response as an XML document.
Read up to the beginning of a query response, check for an exception record, otherwise read in a string as an XML document.
s | is the input stream from the client |
References readResponseEnd(), readToResponse(), and readXMLStream().
Referenced by getComments(), getCPoolRef(), getExternalRefXML(), getMappedSymbolsXML(), getPcodeInject(), getRegister(), getTrackedRegisters(), and getType().
|
static |
Receive an XML document from the client.
The method expects to see protocol markers indicating a string from the client, otherwise it throws and exception. The string is read in and then parsed as XML.
s | is the input stream from the client. |
References readToAnyBurst().
Referenced by DecompileAt::loadParameters(), StructureGraph::loadParameters(), SetOptions::loadParameters(), and readXMLAll().
|
static |
Handler for a segment violation (SIGSEGV) signal.
Catch the signal so the OS doesn't pop up a dialog
sig | is the OS signal (should always be SIGSEGV) |
|
inline |
Toggle whether the recovered source code is emitted as part of the main decompile action.
If the toggle is on, the decompiler will emit source code (marked up in an XML document)
val | is true to enable emitting |
References sendCcode.
Referenced by SetAction::rawAction().
|
inline |
Toggle whether recovered parameter information is emitted as part of the main decompile action.
If the toggle is on, the decompiler will emit a more detailed description of what it thinks the input parameters to the function are.
val | is true enable emitting |
References sendParamMeasures.
Referenced by SetAction::rawAction().
|
inline |
Toggle whether the data-flow and control-flow is emitted as part of the main decompile action.
If the toggle is on, the decompiler will emit complete descriptions of the graphs.
val | is true to enable emitting |
References sendsyntaxtree.
Referenced by SetAction::rawAction().
|
static |
Send a string to the client.
Write out a string with correct protocol markers
s | is the output stream to the client |
msg | is the string to send |
Referenced by getBytes(), getCodeLabel(), getComments(), getCPoolRef(), getExternalRefXML(), getMappedSymbolsXML(), getPcodeInject(), getPcodePacked(), getRegister(), getRegisterName(), getTrackedRegisters(), getType(), getUserOpName(), passJavaException(), SetAction::sendResult(), and SetOptions::sendResult().