sageInterfaceAsm.h

Go to the documentation of this file.
00001 #ifndef ROSE_SAGE_INTERFACE_ASM
00002 #define ROSE_SAGE_INTERFACE_ASM
00003 
00004 // These functions in this file are expected to become a part of the 
00005 // Binary Analysis and Transformation interfaces in the new ROSE API.
00006 
00007 namespace SageInterface
00008    {
00009   // DQ (4/26/2010): Added this file of functions to support binary analysis work.
00010 
00011      void addComment(SgAsmStatement* stmt, const std::string & input_string );
00012 
00013      SgAsmElfSection* getSection ( SgProject* project, const std::string & name );
00014 
00015   // Simple way to get the section that that a pointer points into (if any).
00016      SgAsmElfSection* getSection ( SgProject* project, size_t ptr );
00017 
00019      SgAsmFunction* getAsmFunction ( SgAsmInstruction* asmInstruction );
00020 
00022      SgAsmBlock* getAsmBlock ( SgAsmInstruction* asmInstruction );
00023 
00025      SgAsmInterpretation* getAsmInterpretation ( SgAsmNode* asmNode );
00026 
00027      std::string generateUniqueName ( size_t value, std::map<size_t,int> & usedOffsets, size_t & counter );
00028 
00029      size_t get_value ( SgAsmValueExpression* asmValueExpression );
00030      std::string get_valueString( SgAsmValueExpression* asmValueExpression );
00031 
00032      bool isMovInstruction ( SgAsmInstruction* asmInstruction );
00033 
00034      bool isInstructionKind ( SgAsmInstruction* asmInstruction, X86InstructionKind instuctionKind );
00035 
00036      typedef bool (*EquivalenceTestFunctionType) (SgNode* x, SgNode* y);
00037 
00038   // Definition of object equivalence for purposes of the AST matching using for instruction recognition.
00039      bool equivalenceTest(SgNode* x, SgNode* y);
00040 
00041   // These functions are used internally within the find function.
00042      std::vector<SgNode*> flattenAST ( SgNode* node );
00043      std::vector<SgNode*> matchAST ( SgNode* node, std::vector<SgNode*> & listOfNodes, EquivalenceTestFunctionType equivalenceTest );
00044 
00045   // General function to find matching target AST in larger AST.
00046   // SgNode* find ( SgNode* astNode, SgNode* target, EquivalenceTestFunctionType equivalenceTest );
00047      std::vector<SgNode*> find ( SgNode* astNode, SgNode* target, EquivalenceTestFunctionType equivalenceTest );
00048 
00049   // DQ (4/28/2010): Added support for interface to detect NOP's in all their glory.
00051   // bool isNOP ( const SgAsmInstruction* asmInstruction );
00052      bool isNOP ( SgAsmInstruction* asmInstruction );
00054      bool isNOP ( const std::vector<SgAsmInstruction*> & asmInstructionList );
00056      std::vector<std::vector<SgAsmInstruction*> > find_NOP_sequences ( SgAsmBlock* asmBlock );
00057 
00058   // DQ (5/1/2010): We need a whole set of interface functions similar to this.
00060      void insertInstruction(SgAsmInstruction* targetInstruction, SgAsmInstruction* newInstruction, bool insertBefore);
00061 
00063      void insertInstructionBefore(SgAsmInstruction* targetInstruction, SgAsmInstruction* newInstruction);
00064 
00066      void removeInstruction(SgAsmStatement* instruction);
00067 
00068    }
00069 
00070 // endif for ROSE_SAGE_INTERFACE_ASM
00071 #endif

Generated on Sat May 19 00:53:07 2012 for ROSE by  doxygen 1.4.7