Skip to content

Commit

Permalink
Add dyninstAPI/src/parse-cfg.C
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent 376a329 commit 3f9b04f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
29 changes: 23 additions & 6 deletions docs/dyninstAPI/developer/parse-cfg.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ parse-cfg.h
.. cpp:class:: parse_block : public codeRange, public Dyninst::ParseAPI::Block

.. cpp:function:: private parse_block(Dyninst::ParseAPI::CodeObject *, Dyninst::ParseAPI::CodeRegion*, Dyninst::Address)

For CFGFactory::mksink only

.. cpp:function:: parse_block(parse_func*,Dyninst::ParseAPI::CodeRegion*,Dyninst::Address)
.. cpp:function:: ~parse_block()
.. cpp:function:: Dyninst::Address firstInsnOffset() const
Expand All @@ -20,6 +23,10 @@ parse-cfg.h
cfg access & various predicates

.. cpp:function:: bool isExitBlock()

Checks if the block has a return edge or a call that does not return (i.e., a tail call or
non-returning call).

.. cpp:function:: bool isCallBlock()
.. cpp:function:: bool isIndirectTailCallBlock()
.. cpp:function:: bool isEntryBlock(parse_func * f) const
Expand Down Expand Up @@ -52,7 +59,11 @@ parse-cfg.h
.. cpp:function:: void markAsNeedingRelocation()
.. cpp:function:: void *getPtrToInstruction(Dyninst::Address addr) const

codeRange implementation
Returns ``NULL`` if the address is not within a block belonging to this function.

..note::
Why do we even bother returning ``NULL`` if the address is outside of this function?
FIXME check whether we can do away with that.

.. cpp:function:: Dyninst::Address get_address() const
.. cpp:function:: unsigned get_size() const
Expand Down Expand Up @@ -161,7 +172,13 @@ parse-cfg.h
.. rubric::
Mutable function code, used for hybrid analysis

.. cpp:function:: void getReachableBlocks(const std::set<parse_block *> &exceptBlocks, const std::list<parse_block *> &seedBlocks, std::set<parse_block *> &reachableBlocks)
.. cpp:function:: void getReachableBlocks(const std::set<parse_block *> &exceptBlocks,\
const std::list<parse_block *> &seedBlocks,\
std::set<parse_block *> &reachableBlocks)

Returns in ``reachableBlocks`` the blocks that are reachable from ``seedBlocks``, if the
blocks in ``exceptBlocks`` are not part of the CFG.

.. cpp:function:: Dyninst::ParseAPI::FuncReturnStatus init_retstatus() const

Only call on defensive binaries
Expand Down Expand Up @@ -189,22 +206,22 @@ parse-cfg.h

.. cpp:function:: std::string calcParentFunc(const parse_func *imf, std::vector<image_parRegion *> &pR)

.. warning:: Not implemented
.. warning:: Not implemented on ARMv8

.. cpp:function:: void parseOMP(image_parRegion *parReg, parse_func *parentFunc, int &currentSectionNum)

.. warning:: Not implemented
.. warning:: Not implemented on ARMv8

.. cpp:function:: void parseOMPFunc(bool hasLoop)

.. warning:: Not implemented
.. warning:: Not implemented on ARMv8

.. cpp:function:: bool parseOMPParent(image_parRegion *iPar, int desiredNum, int &currentSectionNum)

By parsing the function that actually sets up the parameters for the OMP region we discover informations such
as what type of parallel region we're dealing with.

.. warning:: Not implemented
.. warning:: Not implemented on ARMv8

.. cpp:function:: void addRegion(image_parRegion *iPar)
.. cpp:function:: bool OMPparsed()
Expand Down
16 changes: 0 additions & 16 deletions dyninstAPI/src/parse-cfg.C
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ bool parse_func::isPLTFunction() {

int parse_block_count = 0;

/*
* For CFGFactory::mksink only
*/
parse_block::parse_block(
CodeObject * obj,
CodeRegion * reg,
Expand Down Expand Up @@ -275,10 +272,6 @@ void *parse_block::getPtrToInstruction(Address addr) const {
return region()->getPtrToInstruction(addr);
}

/* Returns NULL if the address is not within a block belonging to this function.
Why do we even bother returning NULL if the address is outside of this
function? FIXME check whether we can do away with that.
*/
void *parse_func::getPtrToInstruction(Address addr) const {
// The commented-out code checks whether the address is within
// the bytes of this function (one of its basic blocks). Instead,
Expand Down Expand Up @@ -309,10 +302,6 @@ bool parse_block::isEntryBlock(parse_func * f) const
return f->entryBlock() == this;
}

/*
* True if the block has a return edge, or a call that does
* not return (i.e., a tail call or non-returning call)
*/
bool parse_block::isExitBlock()
{
const Block::edgelist & trgs = targets();
Expand Down Expand Up @@ -434,11 +423,6 @@ void parse_block::getInsns(Insns &insns, Address base) {
}


/* This function is static.
*
* Find the blocks that are reachable from the seed blocks
* if the except blocks are not part of the CFG
*/
void parse_func::getReachableBlocks
(const std::set<parse_block*> &exceptBlocks,
const std::list<parse_block*> &seedBlocks,
Expand Down

0 comments on commit 3f9b04f

Please sign in to comment.