ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Partitioner::Function Class Reference

Represents a function within the Partitioner. More...

#include <Partitioner.h>

Collaboration diagram for Partitioner::Function:

Public Member Functions

 Function (rose_addr_t entry_va)
 
 Function (rose_addr_t entry_va, unsigned r)
 
 Function (rose_addr_t entry_va, unsigned r, const std::string &name)
 
void clear_basic_blocks ()
 Remove all basic blocks from this function w/out deleting the blocks. More...
 
void clear_data_blocks ()
 Remove all data blocks from this function w/out deleting the blocks. More...
 
void move_basic_blocks_from (Function *other)
 Move all basic blocks from the other function to this one. More...
 
void move_data_blocks_from (Function *other)
 Move all data blocks from the other function to this one. More...
 
bool possible_may_return () const
 Can this function return? Returns true if it is known that this function can return to its caller. More...
 
void promote_may_return (SgAsmFunction::MayReturn new_value)
 Increase knowledge about the returnability of this function. More...
 
Functioninit_properties (const Function &other)
 Initialize properties from another function. More...
 
void show_properties (FILE *) const
 Emit function property values. More...
 
BasicBlockentry_basic_block () const
 Return the pointer to the basic block at the entry address. More...
 
SgAsmFunction::MayReturn get_may_return () const
 Accessor for the may-return property. More...
 
void set_may_return (SgAsmFunction::MayReturn may_return)
 Accessor for the may-return property. More...
 
bool changed_may_return () const
 Accessor for the may-return property. More...
 
void commit_may_return ()
 Accessor for the may-return property. More...
 

Public Attributes

unsigned reason
 SgAsmFunction::FunctionReason bit flags. More...
 
std::string name
 Name of function if known. More...
 
BasicBlocks basic_blocks
 Basic blocks belonging to this function. More...
 
DataBlocks data_blocks
 Data blocks belonging to this function. More...
 
bool pending
 True if we need to (re)discover the basic blocks. More...
 
rose_addr_t entry_va
 Entry virtual address. More...
 
Disassembler::AddressSet heads
 CFG heads, excluding func entry: addresses of additional blocks. More...
 

Private Attributes

SgAsmFunction::MayReturn may_return_cur
 Is it possible for this function to return? Current value of property. More...
 
SgAsmFunction::MayReturn may_return_old
 Is it possible for this function to return? Previous value of property. More...
 

Detailed Description

Represents a function within the Partitioner.

Each non-empty function will become an SgAsmFunction in the AST.

Definition at line 279 of file Partitioner.h.

Constructor & Destructor Documentation

Partitioner::Function::Function ( rose_addr_t  entry_va)
inline

Definition at line 281 of file Partitioner.h.

Partitioner::Function::Function ( rose_addr_t  entry_va,
unsigned  r 
)
inline

Definition at line 284 of file Partitioner.h.

Partitioner::Function::Function ( rose_addr_t  entry_va,
unsigned  r,
const std::string &  name 
)
inline

Definition at line 287 of file Partitioner.h.

Member Function Documentation

void Partitioner::Function::clear_basic_blocks ( )

Remove all basic blocks from this function w/out deleting the blocks.

Definition at line 534 of file Partitioner.C.

Referenced by Partitioner::build_ast().

void Partitioner::Function::clear_data_blocks ( )

Remove all data blocks from this function w/out deleting the blocks.

Definition at line 543 of file Partitioner.C.

Referenced by Partitioner::build_ast().

void Partitioner::Function::move_basic_blocks_from ( Function other)

Move all basic blocks from the other function to this one.

Definition at line 552 of file Partitioner.C.

References basic_blocks, and heads.

Referenced by Partitioner::merge_functions().

void Partitioner::Function::move_data_blocks_from ( Function other)

Move all data blocks from the other function to this one.

Definition at line 566 of file Partitioner.C.

References data_blocks.

Referenced by Partitioner::merge_functions().

SgAsmFunction::MayReturn Partitioner::Function::get_may_return ( ) const
inline

Accessor for the may-return property.

The may-return property indicates whether this function returns to its caller. This is a two-part property storing both the current value and the previous value; this enables us to detect transitions after the fact, when it is more efficient to process them than when they actually occur. Setting the current value does not update the old value; the old value is updated only by the commit_may_return() method.

Definition at line 309 of file Partitioner.h.

References may_return_cur.

Referenced by Partitioner::build_ast(), Partitioner::detach_thunk(), Partitioner::merge_functions(), and possible_may_return().

void Partitioner::Function::set_may_return ( SgAsmFunction::MayReturn  may_return)
inline

Accessor for the may-return property.

The may-return property indicates whether this function returns to its caller. This is a two-part property storing both the current value and the previous value; this enables us to detect transitions after the fact, when it is more efficient to process them than when they actually occur. Setting the current value does not update the old value; the old value is updated only by the commit_may_return() method.

Definition at line 310 of file Partitioner.h.

References may_return_cur.

Referenced by Partitioner::detach_thunk(), and Partitioner::mark_elf_plt_entries().

bool Partitioner::Function::changed_may_return ( ) const
inline

Accessor for the may-return property.

The may-return property indicates whether this function returns to its caller. This is a two-part property storing both the current value and the previous value; this enables us to detect transitions after the fact, when it is more efficient to process them than when they actually occur. Setting the current value does not update the old value; the old value is updated only by the commit_may_return() method.

Definition at line 311 of file Partitioner.h.

References may_return_cur, and may_return_old.

Referenced by Partitioner::analyze_cfg().

void Partitioner::Function::commit_may_return ( )
inline

Accessor for the may-return property.

The may-return property indicates whether this function returns to its caller. This is a two-part property storing both the current value and the previous value; this enables us to detect transitions after the fact, when it is more efficient to process them than when they actually occur. Setting the current value does not update the old value; the old value is updated only by the commit_may_return() method.

Definition at line 312 of file Partitioner.h.

References may_return_cur, and may_return_old.

Referenced by Partitioner::analyze_cfg().

bool Partitioner::Function::possible_may_return ( ) const
inline

Can this function return? Returns true if it is known that this function can return to its caller.

Definition at line 316 of file Partitioner.h.

References get_may_return(), SgAsmFunction::RET_ALWAYS, and SgAsmFunction::RET_SOMETIMES.

Referenced by Partitioner::analyze_cfg(), and Partitioner::successors().

void Partitioner::Function::promote_may_return ( SgAsmFunction::MayReturn  new_value)

Increase knowledge about the returnability of this function.

A current value of RET_UNKNOWN is always changed to the new_value. A current value of RET_SOMETIMES can be changed to RET_ALWAYS or RET_NEVER. A current value of RET_ALWAYS or RET_NEVER is not modified (not even to change RET_ALWAYS to RET_NEVER or vice versa).

Definition at line 577 of file Partitioner.C.

References SgAsmFunction::RET_ALWAYS, SgAsmFunction::RET_NEVER, SgAsmFunction::RET_SOMETIMES, and SgAsmFunction::RET_UNKNOWN.

Referenced by Partitioner::analyze_cfg(), Partitioner::append(), and Partitioner::merge_functions().

Function* Partitioner::Function::init_properties ( const Function other)

Initialize properties from another function.

This causes the properties of the other function to be copied into this function without changing this function's list of blocks or entry address. The pending status of this function may be set if set in other, but it will never be cleared. Returns this.

void Partitioner::Function::show_properties ( FILE *  debug) const

Emit function property values.

This is mostly for debugging. If the file handle is null then nothing happens.

Definition at line 593 of file Partitioner.C.

References rose::stringifySgAsmFunctionMayReturn().

Referenced by Partitioner::discover_first_block().

Partitioner::BasicBlock * Partitioner::Function::entry_basic_block ( ) const

Return the pointer to the basic block at the entry address.

Returns null if there is no basic block assigned to this function at that address.

Definition at line 605 of file Partitioner.C.

Referenced by Partitioner::is_pe_dynlink_thunk(), and Partitioner::name_pe_dynlink_thunks().

Member Data Documentation

DataBlocks Partitioner::Function::data_blocks
Disassembler::AddressSet Partitioner::Function::heads

CFG heads, excluding func entry: addresses of additional blocks.

Definition at line 345 of file Partitioner.h.

Referenced by Partitioner::append(), Partitioner::detach_thunk(), Partitioner::discover_blocks(), move_basic_blocks_from(), and Partitioner::post_cfg().

SgAsmFunction::MayReturn Partitioner::Function::may_return_cur
private

Is it possible for this function to return? Current value of property.

Definition at line 349 of file Partitioner.h.

Referenced by changed_may_return(), commit_may_return(), get_may_return(), and set_may_return().

SgAsmFunction::MayReturn Partitioner::Function::may_return_old
private

Is it possible for this function to return? Previous value of property.

Definition at line 350 of file Partitioner.h.

Referenced by changed_may_return(), and commit_may_return().


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