decompiler  1.0.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ghidra::GhidraCommand Class Referenceabstract

Base class for a command to the decompiler as issued by a Ghidra client. More...

#include <ghidra_process.hh>

Inheritance diagram for ghidra::GhidraCommand:
ghidra::DecompileAt ghidra::DeregisterProgram ghidra::FlushNative ghidra::RegisterProgram ghidra::SetAction ghidra::SetOptions ghidra::StructureGraph

Public Member Functions

 GhidraCommand (void)
 Construct given i/o streams.
 
virtual ~GhidraCommand (void)
 Destructor.
 
virtual void rawAction (void)=0
 Perform the action of the command. More...
 
int4 doit (void)
 Configure and execute the command, then send back results. More...
 

Protected Member Functions

virtual void loadParameters (void)
 Read parameters directing command execution. More...
 
virtual void sendResult (void)
 Send results of the command (if any) back to the Ghidra client. More...
 

Protected Attributes

istream & sin
 The input stream from the Ghidra client.
 
ostream & sout
 The output stream to the Ghidra client.
 
ArchitectureGhidraghidra
 The Architecture on which to perform the command.
 
int4 status
 Meta-command to system (0=wait for next command, 1=terminate process)
 

Detailed Description

Base class for a command to the decompiler as issued by a Ghidra client.

A command object is provided i/o streams to the client, and the action of the command is performed by calling the doit() method. This wraps the main sequence of methods:

At a minimum, loadParameters() will read an id to select the active ArchitectureGhidra object, and sendResult() will send back any accumulated warning/error messages.

Member Function Documentation

◆ doit()

int4 ghidra::GhidraCommand::doit ( void  )

Configure and execute the command, then send back results.

This method calls the main overloaded methods:

It wraps the sequence with appropriate error handling and message protocol.

Returns
the meta-command (0=continue, 1=terminate) as issued by the command.

References ghidra::LowlevelError::explain, ghidra::DecoderError::explain, loadParameters(), ghidra::ArchitectureGhidra::passJavaException(), rawAction(), ghidra::ArchitectureGhidra::readToAnyBurst(), sendResult(), sin, sout, status, and ghidra::JavaError::type.

◆ loadParameters()

void ghidra::GhidraCommand::loadParameters ( void  )
protectedvirtual

Read parameters directing command execution.

This method reads an id selecting the Architecture to act on, but it can be overloaded to read any set of data from the Ghidra client to configure how the command is executed. Individual parameters are read using the method protocol.

Reimplemented in ghidra::SetOptions, ghidra::SetAction, ghidra::StructureGraph, ghidra::DecompileAt, ghidra::DeregisterProgram, and ghidra::RegisterProgram.

References ghidra::ArchitectureGhidra::readToAnyBurst(), and sin.

Referenced by doit(), ghidra::DecompileAt::loadParameters(), ghidra::StructureGraph::loadParameters(), ghidra::SetAction::loadParameters(), and ghidra::SetOptions::loadParameters().

◆ rawAction()

virtual void ghidra::GhidraCommand::rawAction ( void  )
pure virtual

Perform the action of the command.

Configuration is assumed to have happened, and this object can immediately begin examining and manipulating data under the active Architecture object to perform the command.

Implemented in ghidra::SetOptions, ghidra::SetAction, ghidra::StructureGraph, ghidra::DecompileAt, ghidra::FlushNative, ghidra::DeregisterProgram, and ghidra::RegisterProgram.

Referenced by doit().

◆ sendResult()

void ghidra::GhidraCommand::sendResult ( void  )
protectedvirtual

Send results of the command (if any) back to the Ghidra client.

This method sends any warnings accumulated during execution back, but it can be overloaded to send back any kind of information. Individual records are sent using the message protocol.

Reimplemented in ghidra::SetOptions, ghidra::SetAction, ghidra::FlushNative, ghidra::DeregisterProgram, and ghidra::RegisterProgram.

References sout.

Referenced by doit(), ghidra::RegisterProgram::sendResult(), ghidra::DeregisterProgram::sendResult(), ghidra::FlushNative::sendResult(), ghidra::SetAction::sendResult(), and ghidra::SetOptions::sendResult().


The documentation for this class was generated from the following files: