Proc Class Reference

#include <include/proc.h>

Inheritance diagram for Proc:

LibProc UserProc List of all members.

Detailed Description

Interface for the procedure classes, which are used to store information about variables in the procedure such as parameters and locals.

Definition at line 62 of file proc.h.

Public Member Functions

void addCaller (CallStatement *caller)
 Add to the set of callers.
void addCallers (std::set< UserProc * > &callers)
 Add to a set of caller Procs.
void clearVisited ()
std::set< CallStatement * > & getCallers ()
 Get the callers Note: the callers will be in a random order (determined by memory allocation).
ClustergetCluster ()
ProcgetFirstCaller ()
 Get/Set the first procedure that calls this procedure (or null for main/start).
const char * getName ()
 Gets name of this procedure.
ADDRESS getNativeAddress ()
 Get the native address.
std::list< Type > * getParamTypeList (const std::list< Exp * > &actuals)
 Get a list of types to cast a given list of actual parameters to.
virtual ExpgetPremised (Exp *left)=0
ProggetProg ()
 Get the program this procedure belongs to.
virtual ExpgetProven (Exp *left)=0
SignaturegetSignature ()
 Returns a pointer to the Signature.
virtual bool isLib ()
 Return true if this is a library proc.
virtual bool isNoReturn ()=0
 Return true if this procedure doesn't return.
virtual bool isPreserved (Exp *e)=0
 Return whether e is preserved by this proc.
bool isVisited ()
void matchParams (std::list< Exp * > &actuals, UserProc &caller)
 Modify actuals so that it is now the list of locations that must be passed to this procedure.
virtual void printCallGraphXML (std::ostream &os, int depth, bool recurse=true)
void printDetailsXML ()
 Proc (Prog *prog, ADDRESS uNative, Signature *sig)
 Constructor with name, native address and optional bLib.
void removeParameter (Exp *e)
virtual void removeReturn (Exp *e)
virtual void renameParam (const char *oldName, const char *newName)
void setCluster (Cluster *c)
void setFirstCaller (Proc *p)
void setName (const char *nam)
 Gets sets the name of this procedure.
void setNativeAddress (ADDRESS a)
 Set the native address.
void setProg (Prog *p)
void setProvenTrue (Exp *fact)
 Set an equation as proven. Useful for some sorts of testing.
void setSignature (Signature *sig)
virtual ~Proc ()

Protected Member Functions

 Proc ()

Protected Attributes

ADDRESS address
 Persistent state Procedure's address.
std::set< CallStatement * > callerSet
 Set of callers (CallStatements that call this procedure).
Clustercluster
 Cluster this procedure is contained within.
Procm_firstCaller
 first procedure to call this procedure.
ADDRESS m_firstCallerAddr
 can only be used once.
Progprog
 Program containing this procedure.
std::map< Exp *, Exp *, lessExpStarprovenTrue
 Proof the form r28 = r28 + 4 is stored as map from "r28" to "r28+4" (NOTE: no subscripts).
std::map< Exp *, Exp *, lessExpStarrecurPremises
Signaturesignature
 The formal signature of this procedure.
bool visited
 For printCallGraphXML.

Friends

std::ostream & operator<< (std::ostream &os, Proc &proc)
 OutPut operator for a Proc object.
class XMLProgParser


Constructor & Destructor Documentation

Proc::Proc Prog prog,
ADDRESS  uNative,
Signature sig
 

Constructor with name, native address and optional bLib.

Definition at line 89 of file proc.cpp.

References cluster, Prog::getDefaultCluster(), Signature::getName(), Prog::getRootCluster(), and prog.

Proc::~Proc  )  [virtual]
 

Definition at line 80 of file proc.cpp.

Proc::Proc  )  [inline, protected]
 

Definition at line 256 of file proc.h.


Member Function Documentation

void Proc::addCaller CallStatement caller  )  [inline]
 

Add to the set of callers.

Definition at line 202 of file proc.h.

References callerSet.

Referenced by CallStatement::setSigArguments().

void Proc::addCallers std::set< UserProc * > &  callers  ) 
 

Add to a set of caller Procs.

Definition at line 3720 of file proc.cpp.

References callerSet.

void Proc::clearVisited  )  [inline]
 

Definition at line 216 of file proc.h.

References visited.

std::set<CallStatement*>& Proc::getCallers  )  [inline]
 

Get the callers Note: the callers will be in a random order (determined by memory allocation).

Definition at line 197 of file proc.h.

References callerSet.

Cluster* Proc::getCluster  )  [inline]
 

Definition at line 219 of file proc.h.

References cluster.

Referenced by Prog::generateRTL(), Prog::getStmtAtLex(), and XMLProgParser::persistToXML().

Proc * Proc::getFirstCaller  ) 
 

Get/Set the first procedure that calls this procedure (or null for main/start).

Definition at line 361 of file proc.cpp.

References Prog::findProc(), m_firstCaller, m_firstCallerAddr, NO_ADDRESS, NULL, and prog.

const char * Proc::getName  ) 
 

Gets name of this procedure.

Definition at line 104 of file proc.cpp.

References Signature::getName(), and signature.

Referenced by Decompiler::alert_considering(), Decompiler::alert_decompile_debug_point(), Boomerang::alert_decompile_debug_point(), Decompiler::alert_decompiling(), Decompiler::alert_remove(), Cfg::checkEntryBB(), UserProc::clearUses(), UserProc::conTypeAnalysis(), UserProc::decompile(), UserProc::doRenameBlockVars(), UserProc::earlyDecompile(), UserProc::eliminateDuplicateArgs(), UserProc::findPreserveds(), UserProc::findSpPreservation(), UserProc::fixCallAndPhiRefs(), UserProc::fixUglyBranches(), Prog::fromSSAform(), UserProc::fromSSAform(), CallStatement::generateCode(), BasicBlock::generateCode(), Prog::generateDotFile(), Prog::globalTypeAnalysis(), UserProc::initialiseDecompile(), UserProc::initialParameters(), LibProc::isNoReturn(), UserProc::mapExpressionsToLocals(), UserProc::mapLocalsAndParams(), UserProc::middleDecompile(), UserProc::printAnalysedXML(), UserProc::printAST(), Prog::printCallGraph(), UserProc::printCallGraphXML(), printCallGraphXML(), UserProc::printDecodedXML(), printDetailsXML(), UserProc::printDFG(), UserProc::printSSAXML(), UserProc::printUseGraph(), UserProc::prove(), CallingConvention::StdC::PPCSignature::qualified(), CallingConvention::StdC::SparcSignature::qualified(), CallingConvention::StdC::ST20Signature::qualified(), CallingConvention::StdC::PentiumSignature::qualified(), CallingConvention::Win32Signature::qualified(), CallStatement::rangeAnalysis(), UserProc::rangeAnalysis(), UserProc::removeCallLiveness(), UserProc::removeRedundantParameters(), UserProc::removeRedundantReturns(), UserProc::removeUnusedLocals(), UserProc::remUnusedStmtEtc(), ProcTest::testName(), UserProc::typeAnalysis(), UserProc::updateArguments(), UserProc::updateCallDefines(), UserProc::updateCalls(), and UserProc::updateForUseChange().

ADDRESS Proc::getNativeAddress  ) 
 

Get the native address.

Definition at line 127 of file proc.cpp.

References address.

Referenced by CHLLCode::AddProcStart(), Prog::decodeEverythingUndecoded(), FrontEnd::decodeOnly(), Prog::findContainingProc(), Prog::printCallGraph(), Prog::reDecode(), Prog::remProc(), and ProcTest::testName().

std::list<Type>* Proc::getParamTypeList const std::list< Exp * > &  actuals  ) 
 

Get a list of types to cast a given list of actual parameters to.

virtual Exp* Proc::getPremised Exp left  )  [pure virtual]
 

Implemented in LibProc, and UserProc.

Prog * Proc::getProg  )  [inline]
 

Get the program this procedure belongs to.

Definition at line 95 of file proc.h.

References prog.

Referenced by CHLLCode::AddAssignmentStatement(), CHLLCode::AddProcDec(), Unary::descendType(), Binary::descendType(), DfaLocalMapper::DfaLocalMapper(), Assignment::dfaTypeAnalysis(), ExpRegMapper::ExpRegMapper(), findSwParams(), SparcFrontEnd::handleCall(), BasicBlock::processSwitch(), CallingConvention::StdC::PPCSignature::qualified(), CallingConvention::StdC::SparcSignature::qualified(), CallingConvention::StdC::ST20Signature::qualified(), CallingConvention::StdC::PentiumSignature::qualified(), CallingConvention::Win32Signature::qualified(), and CallStatement::rangeAnalysis().

virtual Exp* Proc::getProven Exp left  )  [pure virtual]
 

Implemented in LibProc, and UserProc.

Referenced by CallStatement::getProven().

Signature * Proc::getSignature  )  [inline]
 

Returns a pointer to the Signature.

Definition at line 107 of file proc.h.

References signature.

Referenced by CHLLCode::AddProcDec(), CHLLCode::AddReturnStatement(), Decompiler::alert_new(), CallStatement::bypassRef(), CallStatement::calcResults(), Binary::descendType(), DfaLocalMapper::DfaLocalMapper(), Assignment::dfaTypeAnalysis(), CallStatement::dfaTypeAnalysis(), PentiumFrontEnd::extraProcessCall(), CallStatement::genConstraints(), CallStatement::generateCode(), Decompiler::getSigFile(), Prog::newProc(), CallStatement::rangeAnalysis(), CallStatement::setNumArguments(), CallStatement::setSigArguments(), CallStatement::updateArguments(), CallStatement::updateDefines(), ReturnStatement::updateModifieds(), and ReturnStatement::updateReturns().

virtual bool Proc::isLib  )  [inline, virtual]
 

Return true if this is a library proc.

Reimplemented in LibProc.

Definition at line 174 of file proc.h.

Referenced by Decompiler::alert_new(), Decompiler::alert_remove(), ArgSourceProvider::ArgSourceProvider(), CallStatement::bypassRef(), CallStatement::calcResults(), UserProc::checkForGainfulUse(), Prog::conTypeAnalysis(), Prog::decodeEntryPoint(), Prog::decodeEverythingUndecoded(), FrontEnd::decodeOnly(), UserProc::doesParamChainToCall(), Prog::findContainingProc(), Prog::fromSSAform(), Prog::getLibraryProc(), Decompiler::getRtlForProc(), Decompiler::getSigFile(), Prog::globalTypeAnalysis(), CallStatement::isChildless(), Boomerang::parseCmd(), XMLProgParser::persistToXML(), Prog::printCallGraph(), Prog::rangeAnalysis(), Prog::removeUnusedReturns(), Prog::setEntryPoint(), CallStatement::setSigArguments(), CallStatement::updateDefines(), UserProc::updateForUseChange(), and StmtSsaXformer::visit().

virtual bool Proc::isNoReturn  )  [pure virtual]
 

Return true if this procedure doesn't return.

Implemented in LibProc, and UserProc.

Referenced by UserProc::initStatements(), and UserProc::isNoReturn().

virtual bool Proc::isPreserved Exp e  )  [pure virtual]
 

Return whether e is preserved by this proc.

Implemented in LibProc, and UserProc.

bool Proc::isVisited  )  [inline]
 

Definition at line 217 of file proc.h.

References visited.

void Proc::matchParams std::list< Exp * > &  actuals,
UserProc caller
 

Modify actuals so that it is now the list of locations that must be passed to this procedure.

The modification will be to either add dummy locations to actuals, delete from actuals, or leave it unchanged. Add "dummy" params: this will be required when there are less live outs at a call site than the number of parameters expected by the procedure called. This will be a result of one of two things: i) a value returned by a preceeding call is used as a parameter and as such is not detected as defined by the procedure. E.g.:

foo(bar(x));

Here, the result of bar(x) is used as the first and only parameter to foo. On some architectures (such as SPARC), the location used as the first parameter (e.g. o0) is also the location in which a value is returned. So, the call to bar defines this location implicitly as shown in the following SPARC assembly that may be generated by from the above code:

mov x, o0 call bar nop call foo

As can be seen, there is no definition of o0 after the call to bar and before the call to foo. Adding the integer return location is therefore a good guess for the dummy location to add (but may occasionally be wrong).

ii) uninitialised variables are used as parameters to a call

Note that both of these situations can only occur on architectures such as SPARC that use registers for parameter passing. Stack parameters must always be pushed so that the callee doesn't access the caller's non-parameter portion of stack.

This used to be a virtual function, implemented differenty for LibProcs and for UserProcs. But in fact, both need the exact same treatment; the only difference is how the local member "parameters" is set (from common.hs in the case of LibProc objects, or from analysis in the case of UserProcs).

void Proc::printCallGraphXML std::ostream &  os,
int  depth,
bool  recurse = true
[virtual]
 

Reimplemented in UserProc.

Definition at line 216 of file proc.cpp.

References DUMP_XML, getName(), and visited.

void Proc::printDetailsXML  ) 
 

Definition at line 245 of file proc.cpp.

References DUMP_XML, Boomerang::get(), Type::getCtype(), getName(), Signature::getNumParams(), Signature::getNumReturns(), Signature::getParamExp(), Signature::getParamName(), Signature::getParamType(), Signature::getReturnExp(), Signature::getReturnType(), and signature.

Referenced by UserProc::printXML().

void Proc::removeParameter Exp e  ) 
 

Definition at line 2333 of file proc.cpp.

References callerSet, Signature::findParam(), LOG, Signature::removeParameter(), and signature.

Referenced by UserProc::addParameter().

void Proc::removeReturn Exp e  )  [virtual]
 

Reimplemented in UserProc.

Definition at line 2345 of file proc.cpp.

References Signature::removeReturn(), and signature.

void Proc::renameParam const char *  oldName,
const char *  newName
[virtual]
 

Reimplemented in UserProc.

Definition at line 172 of file proc.cpp.

References Signature::renameParam(), and signature.

Referenced by UserProc::renameParam().

void Proc::setCluster Cluster c  )  [inline]
 

Definition at line 220 of file proc.h.

References cluster.

Referenced by Boomerang::objcDecode().

void Proc::setFirstCaller Proc p  )  [inline]
 

Definition at line 102 of file proc.h.

References m_firstCaller, and NULL.

void Proc::setName const char *  nam  ) 
 

Gets sets the name of this procedure.

Definition at line 115 of file proc.cpp.

References Signature::setName(), and signature.

Referenced by Decompiler::renameProc().

void Proc::setNativeAddress ADDRESS  a  ) 
 

Set the native address.

Definition at line 131 of file proc.cpp.

References address.

void Proc::setProg Prog p  )  [inline]
 

Definition at line 96 of file proc.h.

References prog.

void Proc::setProvenTrue Exp fact  ) 
 

Set an equation as proven. Useful for some sorts of testing.

Definition at line 5301 of file proc.cpp.

References Exp::getSubExp1(), Exp::getSubExp2(), Exp::isEquality(), and provenTrue.

void Proc::setSignature Signature sig  )  [inline]
 

Definition at line 108 of file proc.h.

References signature.

Referenced by Prog::newProc().


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  os,
Proc proc
[friend]
 

OutPut operator for a Proc object.

friend class XMLProgParser [friend]
 

Reimplemented in LibProc, and UserProc.

Definition at line 255 of file proc.h.


Member Data Documentation

ADDRESS Proc::address [protected]
 

Persistent state Procedure's address.

Definition at line 238 of file proc.h.

Referenced by getNativeAddress(), XMLProgParser::persistToXML(), UserProc::setEntryBB(), and setNativeAddress().

std::set<CallStatement*> Proc::callerSet [protected]
 

Set of callers (CallStatements that call this procedure).

Definition at line 252 of file proc.h.

Referenced by addCaller(), addCallers(), getCallers(), XMLProgParser::persistToXML(), and removeParameter().

Cluster* Proc::cluster [protected]
 

Cluster this procedure is contained within.

Definition at line 253 of file proc.h.

Referenced by getCluster(), XMLProgParser::persistToXML(), UserProc::print(), Proc(), and setCluster().

Proc* Proc::m_firstCaller [protected]
 

first procedure to call this procedure.

Definition at line 239 of file proc.h.

Referenced by getFirstCaller(), XMLProgParser::persistToXML(), and setFirstCaller().

ADDRESS Proc::m_firstCallerAddr [protected]
 

can only be used once.

Definition at line 240 of file proc.h.

Referenced by getFirstCaller(), and XMLProgParser::persistToXML().

Prog* Proc::prog [protected]
 

Program containing this procedure.

Definition at line 226 of file proc.h.

Referenced by UserProc::assignProcsToCalls(), UserProc::decompile(), UserProc::ellipsisProcessing(), UserProc::filterParams(), UserProc::findSpPreservation(), getFirstCaller(), getProg(), UserProc::getRegName(), LibProc::LibProc(), UserProc::mapExpressionsToLocals(), UserProc::printXML(), Proc(), UserProc::processDecodedICTs(), UserProc::processFloatConstants(), UserProc::removeSpAssignsIfPossible(), and setProg().

std::map<Exp*, Exp*, lessExpStar> Proc::provenTrue [protected]
 

Proof the form r28 = r28 + 4 is stored as map from "r28" to "r28+4" (NOTE: no subscripts).

Definition at line 245 of file proc.h.

Referenced by UserProc::getProven(), UserProc::isPreserved(), XMLProgParser::persistToXML(), UserProc::prove(), UserProc::removeStatement(), and setProvenTrue().

std::map<Exp*, Exp*, lessExpStar> Proc::recurPremises [protected]
 

Definition at line 250 of file proc.h.

Referenced by UserProc::getPremised(), UserProc::killPremise(), and UserProc::setPremise().

Signature* Proc::signature [protected]
 

The formal signature of this procedure.

This information is determined either by the common.hs file (for a library function) or by analysis.

NOTE: This belongs in the CALL, because the same procedure can have different signatures if it happens to have varargs. Temporarily here till it can be permanently moved.

Definition at line 235 of file proc.h.

Referenced by UserProc::addParameter(), UserProc::addParameterSymbols(), UserProc::dfaTypeAnalysis(), UserProc::filterParams(), UserProc::findFinalParameters(), UserProc::findSpPreservation(), UserProc::fixCallAndPhiRefs(), UserProc::getDefinitions(), getName(), UserProc::getParamType(), LibProc::getProven(), getSignature(), UserProc::getSymbolExp(), UserProc::insertParameter(), UserProc::isLocalOrParamPattern(), LibProc::isPreserved(), LibProc::LibProc(), UserProc::mapExpressionsToLocals(), XMLProgParser::persistToXML(), UserProc::print(), printDetailsXML(), UserProc::promoteSignature(), removeParameter(), UserProc::removeRedundantParameters(), UserProc::removeRedundantReturns(), removeReturn(), UserProc::removeSpAssignsIfPossible(), renameParam(), setName(), UserProc::setParamType(), and setSignature().

bool Proc::visited [protected]
 

For printCallGraphXML.

Definition at line 224 of file proc.h.

Referenced by clearVisited(), isVisited(), UserProc::printCallGraphXML(), printCallGraphXML(), and UserProc::removeRedundantParameters().


The documentation for this class was generated from the following files:
Generated on Tue Sep 19 21:18:45 2006 for Boomerang by  doxygen 1.4.6